asterisk-11.7.0/0000755000175000007640000000000012254071137013347 5ustar sharkyjerrywebasterisk-11.7.0/formats/0000755000175000007640000000000012254071136015021 5ustar sharkyjerrywebasterisk-11.7.0/formats/format_g729.c0000644000175000007640000001072311747315641017240 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Save to raw, headerless G729 data. * \note This is not an encoder/decoder. The codec fo g729 is only * available with a commercial license from Digium, due to patent * restrictions. Check http://www.digium.com for information. * \arg Extensions: g729 * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" /* Some Ideas for this code came from makeg729e.c by Jeffrey Chilton */ /* Portions of the conversion code are by guido@sienanet.it */ #define BUF_SIZE 20 /* two G729 frames */ #define G729A_SAMPLES 160 static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_G729A, 0); s->fr.mallocd = 0; s->fr.samples = G729A_SAMPLES; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res && (res != 10)) /* XXX what for ? */ ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples; return &s->fr; } static int g729_write(struct ast_filestream *fs, struct ast_frame *f) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_G729A) { ast_log(LOG_WARNING, "Asked to write non-G729 frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if (f->datalen % 10) { ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 10\n", f->datalen); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/10): %s\n", res, strerror(errno)); return -1; } return 0; } static int g729_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { long bytes; off_t min,cur,max,offset=0; min = 0; cur = ftello(fs->f); fseeko(fs->f, 0, SEEK_END); max = ftello(fs->f); bytes = BUF_SIZE * (sample_offset / G729A_SAMPLES); if (whence == SEEK_SET) offset = bytes; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = cur + bytes; else if (whence == SEEK_END) offset = max - bytes; if (whence != SEEK_FORCECUR) { offset = (offset > max)?max:offset; } /* protect against seeking beyond begining. */ offset = (offset < min)?min:offset; if (fseeko(fs->f, offset, SEEK_SET) < 0) return -1; return 0; } static int g729_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for g729 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in g729 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t g729_tell(struct ast_filestream *fs) { off_t offset = ftello(fs->f); return (offset/BUF_SIZE)*G729A_SAMPLES; } static struct ast_format_def g729_f = { .name = "g729", .exts = "g729", .write = g729_write, .seek = g729_seek, .trunc = g729_trunc, .tell = g729_tell, .read = g729_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, }; static int load_module(void) { ast_format_set(&g729_f.format, AST_FORMAT_G729A, 0); if (ast_format_def_register(&g729_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(g729_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw G.729 data", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_siren7.c0000644000175000007640000001115111747315641017753 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2008, Anthony Minessale and Digium, Inc. * Anthony Minessale (anthmct@yahoo.com) * Kevin P. Fleming * * 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 ITU G.722.1 (Siren7, licensed from Polycom) format, 32kbps bitrate only * \arg File name extensions: siren7 * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #define BUF_SIZE 80 /* 20 milliseconds == 80 bytes, 320 samples */ #define SAMPLES_TO_BYTES(x) x / (320 / 80) #define BYTES_TO_SAMPLES(x) x * (320 / 80) static struct ast_frame *siren7read(struct ast_filestream *s, int *whennext) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_SIREN7, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples = BYTES_TO_SAMPLES(res); return &s->fr; } static int siren7write(struct ast_filestream *fs, struct ast_frame *f) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_SIREN7) { ast_log(LOG_WARNING, "Asked to write non-Siren7 frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } static int siren7seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t offset = 0, min = 0, cur, max; sample_offset = SAMPLES_TO_BYTES(sample_offset); if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in siren7 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of siren7 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in siren7 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (whence == SEEK_SET) offset = sample_offset; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = sample_offset + cur; else if (whence == SEEK_END) offset = max - sample_offset; if (whence != SEEK_FORCECUR) offset = (offset > max) ? max : offset; /* always protect against seeking past begining. */ offset = (offset < min) ? min : offset; return fseeko(fs->f, offset, SEEK_SET); } static int siren7trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for siren7 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in siren7 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t siren7tell(struct ast_filestream *fs) { return BYTES_TO_SAMPLES(ftello(fs->f)); } static struct ast_format_def siren7_f = { .name = "siren7", .exts = "siren7", .write = siren7write, .seek = siren7seek, .trunc = siren7trunc, .tell = siren7tell, .read = siren7read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, }; static int load_module(void) { ast_format_set(&siren7_f.format, AST_FORMAT_SIREN7, 0); if (ast_format_def_register(&siren7_f)) return AST_MODULE_LOAD_DECLINE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(siren7_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ITU G.722.1 (Siren7, licensed from Polycom)", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_h263.c0000644000175000007640000001247211747315641017235 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Save to raw, headerless h263 data. * \arg File name extension: h263 * \ingroup formats * \arg See \ref AstVideo */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" /* Some Ideas for this code came from makeh263e.c by Jeffrey Chilton */ /* Portions of the conversion code are by guido@sienanet.it */ /* According to: * http://lists.mpegif.org/pipermail/mp4-tech/2005-July/005741.html * the maximum actual frame size is not 2048, but 8192. Since the maximum * theoretical limit is not much larger (32k = 15bits), we'll go for that * size to ensure we don't corrupt frames sent to us (unless they're * ridiculously large). */ #define BUF_SIZE 32768 /* Four real h.263 Frames */ struct h263_desc { unsigned int lastts; }; static int h263_open(struct ast_filestream *s) { unsigned int ts; if (fread(&ts, 1, sizeof(ts), s->f) < sizeof(ts)) { ast_log(LOG_WARNING, "Empty file!\n"); return -1; } return 0; } static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext) { int res; uint32_t mark; unsigned short len; unsigned int ts; struct h263_desc *fs = (struct h263_desc *)s->_private; /* Send a frame from the file to the appropriate channel */ if ((res = fread(&len, 1, sizeof(len), s->f)) < 1) return NULL; len = ntohs(len); mark = (len & 0x8000) ? 1 : 0; len &= 0x7fff; if (len > BUF_SIZE) { ast_log(LOG_WARNING, "Length %d is too long\n", len); return NULL; } s->fr.frametype = AST_FRAME_VIDEO; ast_format_set(&s->fr.subclass.format, AST_FORMAT_H263, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } s->fr.samples = fs->lastts; /* XXX what ? */ s->fr.datalen = len; if (mark) { ast_format_set_video_mark(&s->fr.subclass.format); } s->fr.delivery.tv_sec = 0; s->fr.delivery.tv_usec = 0; if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) { fs->lastts = ntohl(ts); *whennext = fs->lastts * 4/45; } else *whennext = 0; return &s->fr; } static int h263_write(struct ast_filestream *fs, struct ast_frame *f) { int res; unsigned int ts; unsigned short len; uint32_t mark = 0; if (f->frametype != AST_FRAME_VIDEO) { ast_log(LOG_WARNING, "Asked to write non-video frame!\n"); return -1; } mark = ast_format_get_video_mark(&f->subclass.format) ? 0x8000 : 0; if (f->subclass.format.id != AST_FORMAT_H263) { ast_log(LOG_WARNING, "Asked to write non-h263 frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } ts = htonl(f->samples); if ((res = fwrite(&ts, 1, sizeof(ts), fs->f)) != sizeof(ts)) { ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno)); return -1; } len = htons(f->datalen | mark); if ((res = fwrite(&len, 1, sizeof(len), fs->f)) != sizeof(len)) { ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } static int h263_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { /* No way Jose */ return -1; } static int h263_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for h263 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in h263 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t h263_tell(struct ast_filestream *fs) { off_t offset = ftello(fs->f); return offset; /* XXX totally bogus, needs fixing */ } static struct ast_format_def h263_f = { .name = "h263", .exts = "h263", .open = h263_open, .write = h263_write, .seek = h263_seek, .trunc = h263_trunc, .tell = h263_tell, .read = h263_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct h263_desc), }; static int load_module(void) { ast_format_set(&h263_f.format, AST_FORMAT_H263, 0); if (ast_format_def_register(&h263_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(h263_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw H.263 data", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_ilbc.c0000644000175000007640000001043511747315641017461 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Brian K. West * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Save to raw, headerless iLBC data. * \arg File name extension: ilbc * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" /* Some Ideas for this code came from makeg729e.c by Jeffrey Chilton */ /* Portions of the conversion code are by guido@sienanet.it */ #define ILBC_BUF_SIZE 50 /* One Real iLBC Frame */ #define ILBC_SAMPLES 240 static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_ILBC, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples = ILBC_SAMPLES; return &s->fr; } static int ilbc_write(struct ast_filestream *fs, struct ast_frame *f) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_ILBC) { ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if (f->datalen % 50) { ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 50\n", f->datalen); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/50): %s\n", res, strerror(errno)); return -1; } return 0; } static int ilbc_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { long bytes; off_t min,cur,max,offset=0; min = 0; cur = ftello(fs->f); fseeko(fs->f, 0, SEEK_END); max = ftello(fs->f); bytes = ILBC_BUF_SIZE * (sample_offset / ILBC_SAMPLES); if (whence == SEEK_SET) offset = bytes; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = cur + bytes; else if (whence == SEEK_END) offset = max - bytes; if (whence != SEEK_FORCECUR) { offset = (offset > max)?max:offset; } /* protect against seeking beyond begining. */ offset = (offset < min)?min:offset; if (fseeko(fs->f, offset, SEEK_SET) < 0) return -1; return 0; } static int ilbc_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for iLBC filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in iLBC filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t ilbc_tell(struct ast_filestream *fs) { off_t offset = ftello(fs->f); return (offset/ILBC_BUF_SIZE)*ILBC_SAMPLES; } static struct ast_format_def ilbc_f = { .name = "iLBC", .exts = "ilbc", .write = ilbc_write, .seek = ilbc_seek, .trunc = ilbc_trunc, .tell = ilbc_tell, .read = ilbc_read, .buf_size = ILBC_BUF_SIZE + AST_FRIENDLY_OFFSET, }; static int load_module(void) { ast_format_set(&ilbc_f.format, AST_FORMAT_ILBC, 0); if (ast_format_def_register(&ilbc_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(ilbc_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw iLBC data", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_sln.c0000644000175000007640000002264411747315641017351 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Anthony Minessale * Anthony Minessale (anthmct@yahoo.com) * * 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 RAW SLINEAR Formats * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" static struct ast_frame *generic_read(struct ast_filestream *s, int *whennext, unsigned int buf_size, enum ast_format_id id) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, id, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, buf_size); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples = res/2; s->fr.datalen = res; return &s->fr; } static int generic_write(struct ast_filestream *fs, struct ast_frame *f, enum ast_format_id id) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != id) { ast_log(LOG_WARNING, "Asked to write non-slinear frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } static int slinear_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t offset=0, min = 0, cur, max; sample_offset <<= 1; if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in sln filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of sln filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in sln filestream %p: %s\n", fs, strerror(errno)); return -1; } if (whence == SEEK_SET) offset = sample_offset; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = sample_offset + cur; else if (whence == SEEK_END) offset = max - sample_offset; if (whence != SEEK_FORCECUR) { offset = (offset > max)?max:offset; } /* always protect against seeking past begining. */ offset = (offset < min)?min:offset; return fseeko(fs->f, offset, SEEK_SET); } static int slinear_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for sln filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in sln filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t slinear_tell(struct ast_filestream *fs) { return ftello(fs->f) / 2; } static int slinear_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR);} static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 320, AST_FORMAT_SLINEAR);} static struct ast_format_def slin_f = { .name = "sln", .exts = "sln|raw", .write = slinear_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear_read, .buf_size = 320 + AST_FRIENDLY_OFFSET, }; static int slinear12_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR12);} static struct ast_frame *slinear12_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 480, AST_FORMAT_SLINEAR12);} static struct ast_format_def slin12_f = { .name = "sln12", .exts = "sln12", .write = slinear12_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear12_read, .buf_size = 480 + AST_FRIENDLY_OFFSET, }; static int slinear16_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR16);} static struct ast_frame *slinear16_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 640, AST_FORMAT_SLINEAR16);} static struct ast_format_def slin16_f = { .name = "sln16", .exts = "sln16", .write = slinear16_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear16_read, .buf_size = 640 + AST_FRIENDLY_OFFSET, }; static int slinear24_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR24);} static struct ast_frame *slinear24_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 960, AST_FORMAT_SLINEAR24);} static struct ast_format_def slin24_f = { .name = "sln24", .exts = "sln24", .write = slinear24_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear24_read, .buf_size = 960 + AST_FRIENDLY_OFFSET, }; static int slinear32_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR32);} static struct ast_frame *slinear32_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1280, AST_FORMAT_SLINEAR32);} static struct ast_format_def slin32_f = { .name = "sln32", .exts = "sln32", .write = slinear32_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear32_read, .buf_size = 1280 + AST_FRIENDLY_OFFSET, }; static int slinear44_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR44);} static struct ast_frame *slinear44_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1764, AST_FORMAT_SLINEAR44);} static struct ast_format_def slin44_f = { .name = "sln44", .exts = "sln44", .write = slinear44_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear44_read, .buf_size = 1764 + AST_FRIENDLY_OFFSET, }; static int slinear48_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR48);} static struct ast_frame *slinear48_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 1920, AST_FORMAT_SLINEAR48);} static struct ast_format_def slin48_f = { .name = "sln48", .exts = "sln48", .write = slinear48_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear48_read, .buf_size = 1920 + AST_FRIENDLY_OFFSET, }; static int slinear96_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR96);} static struct ast_frame *slinear96_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 3840, AST_FORMAT_SLINEAR96);} static struct ast_format_def slin96_f = { .name = "sln96", .exts = "sln96", .write = slinear96_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear96_read, .buf_size = 3840 + AST_FRIENDLY_OFFSET, }; static int slinear192_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR192);} static struct ast_frame *slinear192_read(struct ast_filestream *s, int *whennext){return generic_read(s, whennext, 7680, AST_FORMAT_SLINEAR192);} static struct ast_format_def slin192_f = { .name = "sln192", .exts = "sln192", .write = slinear192_write, .seek = slinear_seek, .trunc = slinear_trunc, .tell = slinear_tell, .read = slinear192_read, .buf_size = 7680 + AST_FRIENDLY_OFFSET, }; static struct ast_format_def *slin_list[] = { &slin_f, &slin12_f, &slin16_f, &slin24_f, &slin32_f, &slin44_f, &slin48_f, &slin96_f, &slin192_f, }; static int load_module(void) { int i; ast_format_set(&slin_f.format, AST_FORMAT_SLINEAR, 0); ast_format_set(&slin12_f.format, AST_FORMAT_SLINEAR12, 0); ast_format_set(&slin16_f.format, AST_FORMAT_SLINEAR16, 0); ast_format_set(&slin24_f.format, AST_FORMAT_SLINEAR24, 0); ast_format_set(&slin32_f.format, AST_FORMAT_SLINEAR32, 0); ast_format_set(&slin44_f.format, AST_FORMAT_SLINEAR44, 0); ast_format_set(&slin48_f.format, AST_FORMAT_SLINEAR48, 0); ast_format_set(&slin96_f.format, AST_FORMAT_SLINEAR96, 0); ast_format_set(&slin192_f.format, AST_FORMAT_SLINEAR192, 0); for (i = 0; i < ARRAY_LEN(slin_list); i++) { if (ast_format_def_register(slin_list[i])) { return AST_MODULE_LOAD_FAILURE; } } return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res = 0; int i = 0; for (i = 0; i < ARRAY_LEN(slin_list); i++) { if (ast_format_def_unregister(slin_list[i]->name)) { res |= AST_MODULE_LOAD_FAILURE; } } return res; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw Signed Linear Audio support (SLN) 8khz-192khz", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_vox.c0000644000175000007640000001060411747315641017362 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Flat, binary, ADPCM vox file format. * \arg File name extensions: vox * * \ingroup formats */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #define BUF_SIZE 80 /* 80 bytes, 160 samples */ #define VOX_SAMPLES 160 static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_ADPCM, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples = res * 2; s->fr.datalen = res; return &s->fr; } static int vox_write(struct ast_filestream *s, struct ast_frame *f) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_ADPCM) { ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } static int vox_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t offset = 0, min = 0, cur, max, distance; if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* have to fudge to frame here, so not fully to sample */ distance = sample_offset/2; if (whence == SEEK_SET) { offset = distance; } else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) { offset = distance + cur; } else if (whence == SEEK_END) { offset = max - distance; } if (whence != SEEK_FORCECUR) { offset = (offset > max)?max:offset; offset = (offset < min)?min:offset; } return fseeko(fs->f, offset, SEEK_SET); } static int vox_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for vox filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in vox filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur);} static off_t vox_tell(struct ast_filestream *fs) { off_t offset; offset = ftello(fs->f) << 1; return offset; } static struct ast_format_def vox_f = { .name = "vox", .exts = "vox", .write = vox_write, .seek = vox_seek, .trunc = vox_trunc, .tell = vox_tell, .read = vox_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, }; static int load_module(void) { ast_format_set(&vox_f.format, AST_FORMAT_ADPCM, 0); if (ast_format_def_register(&vox_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(vox_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Dialogic VOX (ADPCM) File Format", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_jpeg.c0000644000175000007640000000555111607650606017476 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 JPEG File format support. * * \arg File name extension: jpeg, jpg * \ingroup formats */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/image.h" #include "asterisk/endian.h" static struct ast_frame *jpeg_read_image(int fd, int len) { struct ast_frame fr; int res; char buf[65536]; if (len > sizeof(buf) || len < 0) { ast_log(LOG_WARNING, "JPEG image too large to read\n"); return NULL; } res = read(fd, buf, len); if (res < len) { ast_log(LOG_WARNING, "Only read %d of %d bytes: %s\n", res, len, strerror(errno)); } memset(&fr, 0, sizeof(fr)); fr.frametype = AST_FRAME_IMAGE; ast_format_set(&fr.subclass.format, AST_FORMAT_JPEG, 0); fr.data.ptr = buf; fr.src = "JPEG Read"; fr.datalen = len; return ast_frisolate(&fr); } static int jpeg_identify(int fd) { char buf[10]; int res; res = read(fd, buf, sizeof(buf)); if (res < sizeof(buf)) return 0; if (memcmp(buf + 6, "JFIF", 4)) return 0; return 1; } static int jpeg_write_image(int fd, struct ast_frame *fr) { int res=0; if (fr->frametype != AST_FRAME_IMAGE) { ast_log(LOG_WARNING, "Not an image\n"); return -1; } if (fr->subclass.format.id != AST_FORMAT_JPEG) { ast_log(LOG_WARNING, "Not a jpeg image\n"); return -1; } if (fr->datalen) { res = write(fd, fr->data.ptr, fr->datalen); if (res != fr->datalen) { ast_log(LOG_WARNING, "Only wrote %d of %d bytes: %s\n", res, fr->datalen, strerror(errno)); return -1; } } return res; } static struct ast_imager jpeg_format = { .name = "jpg", .desc = "JPEG (Joint Picture Experts Group)", .exts = "jpg|jpeg", .read_image = jpeg_read_image, .identify = jpeg_identify, .write_image = jpeg_write_image, }; static int load_module(void) { ast_format_set(&jpeg_format.format, AST_FORMAT_JPEG, 0); if (ast_image_register(&jpeg_format)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { ast_image_unregister(&jpeg_format); return 0; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "jpeg (joint picture experts group) image format", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_g723.c0000644000175000007640000001072111747315641017230 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Old-style G.723.1 frame/timestamp format. * * \arg Extensions: g723, g723sf * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #define G723_MAX_SIZE 1024 static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext) { unsigned short size; int res; int delay; /* Read the delay for the next packet, and schedule again if necessary */ /* XXX is this ignored ? */ if (fread(&delay, 1, 4, s->f) == 4) delay = ntohl(delay); else delay = -1; if (fread(&size, 1, 2, s->f) != 2) { /* Out of data, or the file is no longer valid. In any case go ahead and stop the stream */ return NULL; } /* Looks like we have a frame to read from here */ size = ntohs(size); if (size > G723_MAX_SIZE) { ast_log(LOG_WARNING, "Size %d is invalid\n", size); /* The file is apparently no longer any good, as we shouldn't ever get frames even close to this size. */ return NULL; } /* Read the data into the buffer */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_G723_1, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != size) { ast_log(LOG_WARNING, "Short read (%d of %d bytes) (%s)!\n", res, size, strerror(errno)); return NULL; } *whennext = s->fr.samples = 240; return &s->fr; } static int g723_write(struct ast_filestream *s, struct ast_frame *f) { uint32_t delay; uint16_t size; int res; /* XXX there used to be a check s->fr means a read stream */ if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_G723_1) { ast_log(LOG_WARNING, "Asked to write non-g723 frame!\n"); return -1; } delay = 0; if (f->datalen <= 0) { ast_log(LOG_WARNING, "Short frame ignored (%d bytes long?)\n", f->datalen); return 0; } if ((res = fwrite(&delay, 1, 4, s->f)) != 4) { ast_log(LOG_WARNING, "Unable to write delay: res=%d (%s)\n", res, strerror(errno)); return -1; } size = htons(f->datalen); if ((res = fwrite(&size, 1, 2, s->f)) != 2) { ast_log(LOG_WARNING, "Unable to write size: res=%d (%s)\n", res, strerror(errno)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Unable to write frame: res=%d (%s)\n", res, strerror(errno)); return -1; } return 0; } static int g723_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { return -1; } static int g723_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for g723 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in g723 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t g723_tell(struct ast_filestream *fs) { return -1; } static struct ast_format_def g723_1_f = { .name = "g723sf", .exts = "g723|g723sf", .write = g723_write, .seek = g723_seek, .trunc = g723_trunc, .tell = g723_tell, .read = g723_read, .buf_size = G723_MAX_SIZE + AST_FRIENDLY_OFFSET, }; static int load_module(void) { ast_format_set(&g723_1_f.format, AST_FORMAT_G723_1, 0); if (ast_format_def_register(&g723_1_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(g723_1_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "G.723.1 Simple Timestamp File Format", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_siren14.c0000644000175000007640000001130511747315641020032 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2008, Anthony Minessale and Digium, Inc. * Anthony Minessale (anthmct@yahoo.com) * Kevin P. Fleming * * 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 ITU G.722.1 Annex C (Siren14, licensed from Polycom) format, 48kbps bitrate only * \arg File name extensions: siren14 * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #define BUF_SIZE 120 /* 20 milliseconds == 120 bytes, 640 samples */ #define SAMPLES_TO_BYTES(x) ((typeof(x)) x / ((float) 640 / 120)) #define BYTES_TO_SAMPLES(x) ((typeof(x)) x * ((float) 640 / 120)) static struct ast_frame *siren14read(struct ast_filestream *s, int *whennext) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_SIREN14, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples = BYTES_TO_SAMPLES(res); return &s->fr; } static int siren14write(struct ast_filestream *fs, struct ast_frame *f) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_SIREN14) { ast_log(LOG_WARNING, "Asked to write non-Siren14 frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } static int siren14seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t offset = 0, min = 0, cur, max; sample_offset = SAMPLES_TO_BYTES(sample_offset); if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in siren14 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of siren14 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in siren14 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (whence == SEEK_SET) offset = sample_offset; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = sample_offset + cur; else if (whence == SEEK_END) offset = max - sample_offset; if (whence != SEEK_FORCECUR) offset = (offset > max) ? max : offset; /* always protect against seeking past begining. */ offset = (offset < min) ? min : offset; return fseeko(fs->f, offset, SEEK_SET); } static int siren14trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for siren14 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in siren14 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t siren14tell(struct ast_filestream *fs) { return BYTES_TO_SAMPLES(ftello(fs->f)); } static struct ast_format_def siren14_f = { .name = "siren14", .exts = "siren14", .write = siren14write, .seek = siren14seek, .trunc = siren14trunc, .tell = siren14tell, .read = siren14read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, }; static int load_module(void) { ast_format_set(&siren14_f.format, AST_FORMAT_SIREN14, 0); if (ast_format_def_register(&siren14_f)) return AST_MODULE_LOAD_DECLINE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(siren14_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ITU G.722.1 Annex C (Siren14, licensed from Polycom)", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_ogg_vorbis.c0000644000175000007640000002777611764204135020722 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2005, Jeff Ollie * * 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 OGG/Vorbis streams. * \arg File name extension: ogg * \ingroup formats */ /* the order of these dependencies is important... it also specifies the link order of the libraries during linking */ /*** MODULEINFO vorbis ogg core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 368668 $") #include #include #include #ifdef _WIN32 #include #endif #include "asterisk/mod_format.h" #include "asterisk/module.h" /* * this is the number of samples we deal with. Samples are converted * to SLINEAR so each one uses 2 bytes in the buffer. */ #define SAMPLES_MAX 512 #define BUF_SIZE (2*SAMPLES_MAX) #define BLOCK_SIZE 4096 /* used internally in the vorbis routines */ struct ogg_vorbis_desc { /* format specific parameters */ /* OggVorbis_File structure for libvorbisfile interface */ OggVorbis_File ov_f; /* structures for handling the Ogg container */ ogg_stream_state os; ogg_page og; ogg_packet op; /* structures for handling Vorbis audio data */ vorbis_info vi; vorbis_comment vc; vorbis_dsp_state vd; vorbis_block vb; /*! \brief Indicates whether this filestream is set up for reading or writing. */ int writing; /*! \brief Stores the current pcm position to support tell() on writing mode. */ off_t writing_pcm_pos; /*! \brief Indicates whether an End of Stream condition has been detected. */ int eos; }; #if !defined(HAVE_VORBIS_OPEN_CALLBACKS) /* * Declared for backward compatibility with vorbisfile v1.1.2. * Code taken from vorbisfile.h v1.2.0. */ static int _ov_header_fseek_wrap(FILE *f, ogg_int64_t off, int whence) { if (f == NULL) { return -1; } return fseek(f, off, whence); } static ov_callbacks OV_CALLBACKS_NOCLOSE = { (size_t (*)(void *, size_t, size_t, void *)) fread, (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, (int (*)(void *)) NULL, (long (*)(void *)) ftell }; #endif /* !defined(HAVE_VORBIS_OPEN_CALLBACKS) */ /*! * \brief Create a new OGG/Vorbis filestream and set it up for reading. * \param s File that points to on disk storage of the OGG/Vorbis data. * \return The new filestream. */ static int ogg_vorbis_open(struct ast_filestream *s) { int result; struct ogg_vorbis_desc *desc = (struct ogg_vorbis_desc *) s->_private; /* initialize private description block */ memset(desc, 0, sizeof(struct ogg_vorbis_desc)); desc->writing = 0; /* actually open file */ result = ov_open_callbacks(s->f, &desc->ov_f, NULL, 0, OV_CALLBACKS_NOCLOSE); if (result != 0) { ast_log(LOG_ERROR, "Error opening Ogg/Vorbis file stream.\n"); return -1; } /* check stream(s) type */ if (desc->ov_f.vi->channels != 1) { ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n"); ov_clear(&desc->ov_f); return -1; } if (desc->ov_f.vi->rate != DEFAULT_SAMPLE_RATE) { ast_log(LOG_ERROR, "Only 8000Hz OGG/Vorbis files are currently supported!\n"); ov_clear(&desc->ov_f); return -1; } return 0; } /*! * \brief Create a new OGG/Vorbis filestream and set it up for writing. * \param s File pointer that points to on-disk storage. * \param comment Comment that should be embedded in the OGG/Vorbis file. * \return A new filestream. */ static int ogg_vorbis_rewrite(struct ast_filestream *s, const char *comment) { ogg_packet header; ogg_packet header_comm; ogg_packet header_code; struct ogg_vorbis_desc *tmp = (struct ogg_vorbis_desc *) s->_private; tmp->writing = 1; tmp->writing_pcm_pos = 0; vorbis_info_init(&tmp->vi); if (vorbis_encode_init_vbr(&tmp->vi, 1, DEFAULT_SAMPLE_RATE, 0.4)) { ast_log(LOG_ERROR, "Unable to initialize Vorbis encoder!\n"); return -1; } vorbis_comment_init(&tmp->vc); vorbis_comment_add_tag(&tmp->vc, "ENCODER", "Asterisk PBX"); if (comment) vorbis_comment_add_tag(&tmp->vc, "COMMENT", (char *) comment); vorbis_analysis_init(&tmp->vd, &tmp->vi); vorbis_block_init(&tmp->vd, &tmp->vb); ogg_stream_init(&tmp->os, ast_random()); vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm, &header_code); ogg_stream_packetin(&tmp->os, &header); ogg_stream_packetin(&tmp->os, &header_comm); ogg_stream_packetin(&tmp->os, &header_code); while (!tmp->eos) { if (ogg_stream_flush(&tmp->os, &tmp->og) == 0) break; if (!fwrite(tmp->og.header, 1, tmp->og.header_len, s->f)) { ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); } if (!fwrite(tmp->og.body, 1, tmp->og.body_len, s->f)) { ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); } if (ogg_page_eos(&tmp->og)) tmp->eos = 1; } return 0; } /*! * \brief Write out any pending encoded data. * \param s An OGG/Vorbis filestream. * \param f The file to write to. */ static void write_stream(struct ogg_vorbis_desc *s, FILE *f) { while (vorbis_analysis_blockout(&s->vd, &s->vb) == 1) { vorbis_analysis(&s->vb, NULL); vorbis_bitrate_addblock(&s->vb); while (vorbis_bitrate_flushpacket(&s->vd, &s->op)) { ogg_stream_packetin(&s->os, &s->op); while (!s->eos) { if (ogg_stream_pageout(&s->os, &s->og) == 0) { break; } if (!fwrite(s->og.header, 1, s->og.header_len, f)) { ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); } if (!fwrite(s->og.body, 1, s->og.body_len, f)) { ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); } if (ogg_page_eos(&s->og)) { s->eos = 1; } } } } } /*! * \brief Write audio data from a frame to an OGG/Vorbis filestream. * \param fs An OGG/Vorbis filestream. * \param f A frame containing audio to be written to the filestream. * \return -1 if there was an error, 0 on success. */ static int ogg_vorbis_write(struct ast_filestream *fs, struct ast_frame *f) { int i; float **buffer; short *data; struct ogg_vorbis_desc *s = (struct ogg_vorbis_desc *) fs->_private; if (!s->writing) { ast_log(LOG_ERROR, "This stream is not set up for writing!\n"); return -1; } if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_SLINEAR) { ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if (!f->datalen) return -1; data = (short *) f->data.ptr; buffer = vorbis_analysis_buffer(&s->vd, f->samples); for (i = 0; i < f->samples; i++) buffer[0][i] = (double)data[i] / 32768.0; vorbis_analysis_wrote(&s->vd, f->samples); write_stream(s, fs->f); s->writing_pcm_pos += f->samples; return 0; } /*! * \brief Close a OGG/Vorbis filestream. * \param fs A OGG/Vorbis filestream. */ static void ogg_vorbis_close(struct ast_filestream *fs) { struct ogg_vorbis_desc *s = (struct ogg_vorbis_desc *) fs->_private; if (s->writing) { /* Tell the Vorbis encoder that the stream is finished * and write out the rest of the data */ vorbis_analysis_wrote(&s->vd, 0); write_stream(s, fs->f); } else { /* clear OggVorbis_File handle */ ov_clear(&s->ov_f); } } /*! * \brief Read a frame full of audio data from the filestream. * \param fs The filestream. * \param whennext Number of sample times to schedule the next call. * \return A pointer to a frame containing audio data or NULL ifthere is no more audio data. */ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *fs, int *whennext) { struct ogg_vorbis_desc *desc = (struct ogg_vorbis_desc *) fs->_private; int current_bitstream = -10; char *out_buf; long bytes_read; if (desc->writing) { ast_log(LOG_WARNING, "Reading is not supported on OGG/Vorbis on write files.\n"); return NULL; } /* initialize frame */ fs->fr.frametype = AST_FRAME_VOICE; ast_format_set(&fs->fr.subclass.format, AST_FORMAT_SLINEAR, 0); fs->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); out_buf = (char *) (fs->fr.data.ptr); /* SLIN data buffer */ /* read samples from OV interface */ bytes_read = ov_read( &desc->ov_f, out_buf, /* Buffer to write data */ BUF_SIZE, /* Size of buffer */ (__BYTE_ORDER == __BIG_ENDIAN), /* Endianes (0 for little) */ 2, /* 1 = 8bit, 2 = 16bit */ 1, /* 0 = unsigned, 1 = signed */ ¤t_bitstream /* Returns the current bitstream section */ ); /* check returned data */ if (bytes_read <= 0) { /* End of stream */ return NULL; } /* Return decoded bytes */ fs->fr.datalen = bytes_read; fs->fr.samples = bytes_read / 2; *whennext = fs->fr.samples; return &fs->fr; } /*! * \brief Trucate an OGG/Vorbis filestream. * \param s The filestream to truncate. * \return 0 on success, -1 on failure. */ static int ogg_vorbis_trunc(struct ast_filestream *fs) { ast_log(LOG_WARNING, "Truncation is not supported on OGG/Vorbis streams!\n"); return -1; } /*! * \brief Tell the current position in OGG/Vorbis filestream measured in pcms. * \param s The filestream to take action on. * \return 0 or greater with the position measured in samples, or -1 for false. */ static off_t ogg_vorbis_tell(struct ast_filestream *fs) { off_t pos; struct ogg_vorbis_desc *desc = (struct ogg_vorbis_desc *) fs->_private; if (desc->writing) { return desc->writing_pcm_pos; } if ((pos = ov_pcm_tell(&desc->ov_f)) < 0) { return -1; } return pos; } /*! * \brief Seek to a specific position in an OGG/Vorbis filestream. * \param s The filestream to take action on. * \param sample_offset New position for the filestream, measured in 8KHz samples. * \param whence Location to measure * \return 0 on success, -1 on failure. */ static int ogg_vorbis_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { int seek_result = -1; off_t relative_pcm_pos; struct ogg_vorbis_desc *desc = (struct ogg_vorbis_desc *) fs->_private; if (desc->writing) { ast_log(LOG_WARNING, "Seeking is not supported on OGG/Vorbis streams in writing mode!\n"); return -1; } /* ov_pcm_seek support seeking only from begining (SEEK_SET), the rest must be emulated */ switch (whence) { case SEEK_SET: seek_result = ov_pcm_seek(&desc->ov_f, sample_offset); break; case SEEK_CUR: if ((relative_pcm_pos = ogg_vorbis_tell(fs)) < 0) { seek_result = -1; break; } seek_result = ov_pcm_seek(&desc->ov_f, relative_pcm_pos + sample_offset); break; case SEEK_END: if ((relative_pcm_pos = ov_pcm_total(&desc->ov_f, -1)) < 0) { seek_result = -1; break; } seek_result = ov_pcm_seek(&desc->ov_f, relative_pcm_pos - sample_offset); break; default: ast_log(LOG_WARNING, "Unknown *whence* to seek on OGG/Vorbis streams!\n"); break; } /* normalize error value to -1,0 */ return (seek_result == 0) ? 0 : -1; } static struct ast_format_def vorbis_f = { .name = "ogg_vorbis", .exts = "ogg", .open = ogg_vorbis_open, .rewrite = ogg_vorbis_rewrite, .write = ogg_vorbis_write, .seek = ogg_vorbis_seek, .trunc = ogg_vorbis_trunc, .tell = ogg_vorbis_tell, .read = ogg_vorbis_read, .close = ogg_vorbis_close, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct ogg_vorbis_desc), }; static int load_module(void) { ast_format_set(&vorbis_f.format, AST_FORMAT_SLINEAR, 0); if (ast_format_def_register(&vorbis_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(vorbis_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "OGG/Vorbis audio", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_g726.c0000644000175000007640000001427311607650606017237 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (c) 2004 - 2005, inAccess Networks * * Michael Manousos * * 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 Headerless G.726 (16/24/32/40kbps) data format for Asterisk. * * File name extensions: * \arg 40 kbps: g726-40 * \arg 32 kbps: g726-32 * \arg 24 kbps: g726-24 * \arg 16 kbps: g726-16 * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #define RATE_40 0 #define RATE_32 1 #define RATE_24 2 #define RATE_16 3 /* We can only read/write chunks of FRAME_TIME ms G.726 data */ #define FRAME_TIME 10 /* 10 ms size */ #define BUF_SIZE (5*FRAME_TIME) /* max frame size in bytes ? */ /* Frame sizes in bytes */ static int frame_size[4] = { FRAME_TIME * 5, FRAME_TIME * 4, FRAME_TIME * 3, FRAME_TIME * 2 }; struct g726_desc { int rate; /* RATE_* defines */ }; /* * Rate dependant format functions (open, rewrite) */ static int g726_open(struct ast_filestream *tmp, int rate) { struct g726_desc *s = (struct g726_desc *)tmp->_private; s->rate = rate; ast_debug(1, "Created filestream G.726-%dk.\n", 40 - s->rate * 8); return 0; } static int g726_40_open(struct ast_filestream *s) { return g726_open(s, RATE_40); } static int g726_32_open(struct ast_filestream *s) { return g726_open(s, RATE_32); } static int g726_24_open(struct ast_filestream *s) { return g726_open(s, RATE_24); } static int g726_16_open(struct ast_filestream *s) { return g726_open(s, RATE_16); } static int g726_40_rewrite(struct ast_filestream *s, const char *comment) { return g726_open(s, RATE_40); } static int g726_32_rewrite(struct ast_filestream *s, const char *comment) { return g726_open(s, RATE_32); } static int g726_24_rewrite(struct ast_filestream *s, const char *comment) { return g726_open(s, RATE_24); } static int g726_16_rewrite(struct ast_filestream *s, const char *comment) { return g726_open(s, RATE_16); } /* * Rate independent format functions (read, write) */ static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext) { int res; struct g726_desc *fs = (struct g726_desc *)s->_private; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_G726, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]); s->fr.samples = 8 * FRAME_TIME; if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples; return &s->fr; } static int g726_write(struct ast_filestream *s, struct ast_frame *f) { int res; struct g726_desc *fs = (struct g726_desc *)s->_private; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_G726) { ast_log(LOG_WARNING, "Asked to write non-G726 frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if (f->datalen % frame_size[fs->rate]) { ast_log(LOG_WARNING, "Invalid data length %d, should be multiple of %d\n", f->datalen, frame_size[fs->rate]); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, frame_size[fs->rate], strerror(errno)); return -1; } return 0; } static int g726_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { return -1; } static int g726_trunc(struct ast_filestream *fs) { return -1; } static off_t g726_tell(struct ast_filestream *fs) { return -1; } static struct ast_format_def f[] = { { .name = "g726-40", .exts = "g726-40", .open = g726_40_open, .rewrite = g726_40_rewrite, .write = g726_write, .seek = g726_seek, .trunc = g726_trunc, .tell = g726_tell, .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), }, { .name = "g726-32", .exts = "g726-32", .open = g726_32_open, .rewrite = g726_32_rewrite, .write = g726_write, .seek = g726_seek, .trunc = g726_trunc, .tell = g726_tell, .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), }, { .name = "g726-24", .exts = "g726-24", .open = g726_24_open, .rewrite = g726_24_rewrite, .write = g726_write, .seek = g726_seek, .trunc = g726_trunc, .tell = g726_tell, .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), }, { .name = "g726-16", .exts = "g726-16", .open = g726_16_open, .rewrite = g726_16_rewrite, .write = g726_write, .seek = g726_seek, .trunc = g726_trunc, .tell = g726_tell, .read = g726_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct g726_desc), }, { .desc_size = 0 } /* terminator */ }; static int load_module(void) { int i; for (i = 0; f[i].desc_size ; i++) { ast_format_set(&f[i].format, AST_FORMAT_G726, 0); if (ast_format_def_register(&f[i])) { /* errors are fatal */ ast_log(LOG_WARNING, "Failed to register format %s.\n", f[i].name); return AST_MODULE_LOAD_FAILURE; } } return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int i; for (i = 0; f[i].desc_size ; i++) { if (ast_format_def_unregister(f[i].name)) ast_log(LOG_WARNING, "Failed to unregister format %s.\n", f[i].name); } return(0); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw G.726 (16/24/32/40kbps) data", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_h264.c0000644000175000007640000001207711747315641017237 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Save to raw, headerless h264 data. * \arg File name extension: h264 * \ingroup formats * \arg See \ref AstVideo */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" /* Some Ideas for this code came from makeh264e.c by Jeffrey Chilton */ /* Portions of the conversion code are by guido@sienanet.it */ /*! \todo Check this buf size estimate, it may be totally wrong for large frame video */ #define BUF_SIZE 4096 /* Two Real h264 Frames */ struct h264_desc { unsigned int lastts; }; static int h264_open(struct ast_filestream *s) { unsigned int ts; if (fread(&ts, 1, sizeof(ts), s->f) < sizeof(ts)) { ast_log(LOG_WARNING, "Empty file!\n"); return -1; } return 0; } static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext) { int res; int mark = 0; unsigned short len; unsigned int ts; struct h264_desc *fs = (struct h264_desc *)s->_private; /* Send a frame from the file to the appropriate channel */ if ((res = fread(&len, 1, sizeof(len), s->f)) < 1) return NULL; len = ntohs(len); mark = (len & 0x8000) ? 1 : 0; len &= 0x7fff; if (len > BUF_SIZE) { ast_log(LOG_WARNING, "Length %d is too long\n", len); len = BUF_SIZE; /* XXX truncate */ } s->fr.frametype = AST_FRAME_VIDEO; ast_format_set(&s->fr.subclass.format, AST_FORMAT_H264, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d of %d) (%s)!\n", res, len, strerror(errno)); return NULL; } s->fr.samples = fs->lastts; s->fr.datalen = len; if (mark) { ast_format_set_video_mark(&s->fr.subclass.format); } s->fr.delivery.tv_sec = 0; s->fr.delivery.tv_usec = 0; if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) { fs->lastts = ntohl(ts); *whennext = fs->lastts * 4/45; } else *whennext = 0; return &s->fr; } static int h264_write(struct ast_filestream *s, struct ast_frame *f) { int res; unsigned int ts; unsigned short len; int mark; if (f->frametype != AST_FRAME_VIDEO) { ast_log(LOG_WARNING, "Asked to write non-video frame!\n"); return -1; } mark = ast_format_get_video_mark(&f->subclass.format) ? 0x8000 : 0; if (f->subclass.format.id != AST_FORMAT_H264) { ast_log(LOG_WARNING, "Asked to write non-h264 frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } ts = htonl(f->samples); if ((res = fwrite(&ts, 1, sizeof(ts), s->f)) != sizeof(ts)) { ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno)); return -1; } len = htons(f->datalen | mark); if ((res = fwrite(&len, 1, sizeof(len), s->f)) != sizeof(len)) { ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } static int h264_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { /* No way Jose */ return -1; } static int h264_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for h264 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in h264 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t h264_tell(struct ast_filestream *fs) { off_t offset = ftell(fs->f); return offset; /* XXX totally bogus, needs fixing */ } static struct ast_format_def h264_f = { .name = "h264", .exts = "h264", .open = h264_open, .write = h264_write, .seek = h264_seek, .trunc = h264_trunc, .tell = h264_tell, .read = h264_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct h264_desc), }; static int load_module(void) { ast_format_set(&h264_f.format, AST_FORMAT_H264, 0); if (ast_format_def_register(&h264_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(h264_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw H.264 data", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_wav.c0000644000175000007640000003505611747315641017353 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Work with WAV in the proprietary Microsoft format. * Microsoft WAV format (8000hz Signed Linear) * \arg File name extension: wav (lower case) * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" /* Some Ideas for this code came from makewave.c by Jeffrey Chilton */ /* Portions of the conversion code are by guido@sienanet.it */ #define WAV_BUF_SIZE 320 #define WAV_HEADER_SIZE 44 struct wav_desc { /* format-specific parameters */ int hz; int bytes; int lasttimeout; int maxlen; struct timeval last; }; #define BLOCKSIZE 160 #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 check_header_fmt(FILE *f, int hsize, int hz) { short format, chans, bysam, bisam; int bysec; int freq; if (hsize < 16) { ast_log(LOG_WARNING, "Unexpected header size %d\n", hsize); return -1; } if (fread(&format, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Read failed (format)\n"); return -1; } if (ltohs(format) != 1) { ast_log(LOG_WARNING, "Not a wav file %d\n", ltohs(format)); return -1; } if (fread(&chans, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Read failed (format)\n"); return -1; } if (ltohs(chans) != 1) { ast_log(LOG_WARNING, "Not in mono %d\n", ltohs(chans)); return -1; } if (fread(&freq, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (freq)\n"); return -1; } if (((ltohl(freq) != 8000) && (ltohl(freq) != 16000)) || ((ltohl(freq) == 8000) && (hz != 8000)) || ((ltohl(freq) == 16000) && (hz != 16000))) { ast_log(LOG_WARNING, "Unexpected frequency mismatch %d (expecting %d)\n", ltohl(freq),hz); return -1; } /* Ignore the byte frequency */ if (fread(&bysec, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (BYTES_PER_SECOND)\n"); return -1; } /* Check bytes per sample */ if (fread(&bysam, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Read failed (BYTES_PER_SAMPLE)\n"); return -1; } if (ltohs(bysam) != 2) { ast_log(LOG_WARNING, "Can only handle 16bits per sample: %d\n", ltohs(bysam)); return -1; } if (fread(&bisam, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Read failed (Bits Per Sample): %d\n", ltohs(bisam)); return -1; } /* Skip any additional header */ if (fseek(f,hsize-16,SEEK_CUR) == -1 ) { ast_log(LOG_WARNING, "Failed to skip remaining header bytes: %d\n", hsize-16 ); return -1; } return 0; } static int check_header(FILE *f, int hz) { int type, size, formtype; int data; if (fread(&type, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (type)\n"); return -1; } if (fread(&size, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (size)\n"); return -1; } size = ltohl(size); if (fread(&formtype, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (formtype)\n"); return -1; } if (memcmp(&type, "RIFF", 4)) { ast_log(LOG_WARNING, "Does not begin with RIFF\n"); return -1; } if (memcmp(&formtype, "WAVE", 4)) { ast_log(LOG_WARNING, "Does not contain WAVE\n"); return -1; } /* Skip any facts and get the first data block */ for(;;) { char buf[4]; /* Begin data chunk */ if (fread(&buf, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (block header format)\n"); return -1; } /* Data has the actual length of data in it */ if (fread(&data, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (block '%.4s' header length)\n", buf); return -1; } data = ltohl(data); if (memcmp(&buf, "fmt ", 4) == 0) { if (check_header_fmt(f, data, hz)) return -1; continue; } if(memcmp(buf, "data", 4) == 0 ) break; ast_log(LOG_DEBUG, "Skipping unknown block '%.4s'\n", buf); if (fseek(f,data,SEEK_CUR) == -1 ) { ast_log(LOG_WARNING, "Failed to skip '%.4s' block: %d\n", buf, data); return -1; } } #if 0 curpos = lseek(fd, 0, SEEK_CUR); truelength = lseek(fd, 0, SEEK_END); lseek(fd, curpos, SEEK_SET); truelength -= curpos; #endif return data; } static int update_header(FILE *f) { off_t cur,end; int datalen,filelen,bytes; cur = ftello(f); fseek(f, 0, SEEK_END); end = ftello(f); /* data starts 44 bytes in */ bytes = end - 44; datalen = htoll(bytes); /* chunk size is bytes of data plus 36 bytes of header */ filelen = htoll(36 + bytes); if (cur < 0) { ast_log(LOG_WARNING, "Unable to find our position\n"); return -1; } if (fseek(f, 4, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to set our position\n"); return -1; } if (fwrite(&filelen, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to set write file size\n"); return -1; } if (fseek(f, 40, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to set our position\n"); return -1; } if (fwrite(&datalen, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to set write datalen\n"); return -1; } if (fseeko(f, cur, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to return to position\n"); return -1; } return 0; } static int write_header(FILE *f, int writehz) { unsigned int hz; unsigned int bhz; unsigned int hs = htoll(16); unsigned short fmt = htols(1); unsigned short chans = htols(1); unsigned short bysam = htols(2); unsigned short bisam = htols(16); unsigned int size = htoll(0); if (writehz == 16000) { hz = htoll(16000); bhz = htoll(32000); } else { hz = htoll(8000); bhz = htoll(16000); } /* Write a wav header, ignoring sizes which will be filled in later */ fseek(f,0,SEEK_SET); if (fwrite("RIFF", 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&size, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite("WAVEfmt ", 1, 8, f) != 8) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&hs, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&fmt, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&chans, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&hz, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&bhz, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&bysam, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&bisam, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite("data", 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } if (fwrite(&size, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } return 0; } static int wav_open(struct ast_filestream *s) { /* We don't have any header to read or anything really, but if we did, it would go here. We also might want to check and be sure it's a valid file. */ struct wav_desc *tmp = (struct wav_desc *)s->_private; if ((tmp->maxlen = check_header(s->f, (s->fmt->format.id == AST_FORMAT_SLINEAR16 ? 16000 : 8000))) < 0) return -1; return 0; } static int wav_rewrite(struct ast_filestream *s, const char *comment) { /* We don't have any header to read or anything really, but if we did, it would go here. We also might want to check and be sure it's a valid file. */ struct wav_desc *tmp = (struct wav_desc *)s->_private; tmp->hz = (s->fmt->format.id == AST_FORMAT_SLINEAR16 ? 16000 : 8000); if (write_header(s->f,tmp->hz)) return -1; return 0; } static void wav_close(struct ast_filestream *s) { char zero = 0; struct wav_desc *fs = (struct wav_desc *)s->_private; if (s->mode == O_RDONLY) { return; } if (s->filename) { update_header(s->f); } /* Pad to even length */ if (fs->bytes & 0x1) { if (!fwrite(&zero, 1, 1, s->f)) { ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); } } } static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext) { int res; int samples; /* actual samples read */ #if __BYTE_ORDER == __BIG_ENDIAN int x; short *tmp; #endif int bytes; off_t here; /* Send a frame from the file to the appropriate channel */ struct wav_desc *fs = (struct wav_desc *)s->_private; bytes = (fs->hz == 16000 ? (WAV_BUF_SIZE * 2) : WAV_BUF_SIZE); here = ftello(s->f); if (fs->maxlen - here < bytes) /* truncate if necessary */ bytes = fs->maxlen - here; if (bytes < 0) bytes = 0; /* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, (fs->hz == 16000 ? AST_FORMAT_SLINEAR16 : AST_FORMAT_SLINEAR), 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes); if ( (res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) <= 0 ) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } s->fr.datalen = res; s->fr.samples = samples = res / 2; #if __BYTE_ORDER == __BIG_ENDIAN tmp = (short *)(s->fr.data.ptr); /* file format is little endian so we need to swap */ for( x = 0; x < samples; x++) tmp[x] = (tmp[x] << 8) | ((tmp[x] & 0xff00) >> 8); #endif *whennext = samples; return &s->fr; } static int wav_write(struct ast_filestream *fs, struct ast_frame *f) { #if __BYTE_ORDER == __BIG_ENDIAN int x; short tmp[16000], *tmpi; #endif struct wav_desc *s = (struct wav_desc *)fs->_private; int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if ((f->subclass.format.id != AST_FORMAT_SLINEAR) && (f->subclass.format.id != AST_FORMAT_SLINEAR16)) { ast_log(LOG_WARNING, "Asked to write non-SLINEAR%s frame (%s)!\n", s->hz == 16000 ? "16" : "", ast_getformatname(&f->subclass.format)); return -1; } if (ast_format_cmp(&f->subclass.format, &fs->fmt->format) == AST_FORMAT_CMP_NOT_EQUAL) { ast_log(LOG_WARNING, "Can't change SLINEAR frequency during write\n"); return -1; } if (!f->datalen) return -1; #if __BYTE_ORDER == __BIG_ENDIAN /* swap and write */ if (f->datalen > sizeof(tmp)) { ast_log(LOG_WARNING, "Data length is too long\n"); return -1; } tmpi = f->data.ptr; for (x=0; x < f->datalen/2; x++) tmp[x] = (tmpi[x] << 8) | ((tmpi[x] & 0xff00) >> 8); if ((res = fwrite(tmp, 1, f->datalen, fs->f)) != f->datalen ) { #else /* just write */ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen ) { #endif ast_log(LOG_WARNING, "Bad write (%d): %s\n", res, strerror(errno)); return -1; } s->bytes += f->datalen; return 0; } static int wav_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t min = WAV_HEADER_SIZE, max, cur, offset = 0, samples; samples = sample_offset * 2; /* SLINEAR is 16 bits mono, so sample_offset * 2 = bytes */ if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in wav filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of wav filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in wav filestream %p: %s\n", fs, strerror(errno)); return -1; } 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; } /* always protect the header space. */ offset = (offset < min)?min:offset; return fseeko(fs->f, offset, SEEK_SET); } static int wav_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for wav filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in wav filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ if (ftruncate(fd, cur)) { return -1; } return update_header(fs->f); } static off_t wav_tell(struct ast_filestream *fs) { off_t offset; offset = ftello(fs->f); /* subtract header size to get samples, then divide by 2 for 16 bit samples */ return (offset - 44)/2; } static struct ast_format_def wav16_f = { .name = "wav16", .exts = "wav16", .open = wav_open, .rewrite = wav_rewrite, .write = wav_write, .seek = wav_seek, .trunc = wav_trunc, .tell = wav_tell, .read = wav_read, .close = wav_close, .buf_size = (WAV_BUF_SIZE * 2) + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct wav_desc), }; static struct ast_format_def wav_f = { .name = "wav", .exts = "wav", .open = wav_open, .rewrite = wav_rewrite, .write = wav_write, .seek = wav_seek, .trunc = wav_trunc, .tell = wav_tell, .read = wav_read, .close = wav_close, .buf_size = WAV_BUF_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct wav_desc), }; static int load_module(void) { ast_format_set(&wav_f.format, AST_FORMAT_SLINEAR, 0); ast_format_set(&wav16_f.format, AST_FORMAT_SLINEAR16, 0); if (ast_format_def_register(&wav_f) || ast_format_def_register(&wav16_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(wav_f.name) || ast_format_def_unregister(wav16_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Microsoft WAV/WAV16 format (8kHz/16kHz Signed Linear)", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_g719.c0000644000175000007640000001076511747315641017245 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Anthony Minessale and Digium, Inc. * Anthony Minessale (anthmct@yahoo.com) * Kevin P. Fleming * * 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 ITU G.719 , 64kbps bitrate only * \arg File name extensions: g719 * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #define BUF_SIZE 160 /* 20 milliseconds == 160 bytes, 960 samples */ #define SAMPLES_TO_BYTES(x) ((typeof(x)) x / ((float) 960 / 160)) #define BYTES_TO_SAMPLES(x) ((typeof(x)) x * ((float) 960 / 160)) static struct ast_frame *g719read(struct ast_filestream *s, int *whennext) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_G719, 0); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples = BYTES_TO_SAMPLES(res); return &s->fr; } static int g719write(struct ast_filestream *fs, struct ast_frame *f) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_G719) { ast_log(LOG_WARNING, "Asked to write non-G.719 frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } static int g719seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t offset = 0, min = 0, cur, max; sample_offset = SAMPLES_TO_BYTES(sample_offset); if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (whence == SEEK_SET) offset = sample_offset; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = sample_offset + cur; else if (whence == SEEK_END) offset = max - sample_offset; if (whence != SEEK_FORCECUR) offset = (offset > max) ? max : offset; /* always protect against seeking past begining. */ offset = (offset < min) ? min : offset; return fseeko(fs->f, offset, SEEK_SET); } static int g719trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } return ftruncate(fd, cur); } static off_t g719tell(struct ast_filestream *fs) { return BYTES_TO_SAMPLES(ftello(fs->f)); } static struct ast_format_def g719_f = { .name = "g719", .exts = "g719", .write = g719write, .seek = g719seek, .trunc = g719trunc, .tell = g719tell, .read = g719read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, }; static int load_module(void) { ast_format_set(&g719_f.format, AST_FORMAT_G719, 0); if (ast_format_def_register(&g719_f)) return AST_MODULE_LOAD_DECLINE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(g719_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ITU G.719", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_wav_gsm.c0000644000175000007640000004037211747315641020216 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Save GSM in the proprietary Microsoft format. * * Microsoft WAV format (Proprietary GSM) * \arg File name extension: WAV,wav49 (Upper case WAV, lower case is another format) * This format can be played on Windows systems, used for * e-mail attachments mainly. * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #include "msgsm.h" /* Some Ideas for this code came from makewave.c by Jeffrey Chilton */ /* Portions of the conversion code are by guido@sienanet.it */ #define GSM_FRAME_SIZE 33 #define MSGSM_FRAME_SIZE 65 #define MSGSM_DATA_OFFSET 60 /* offset of data bytes */ #define GSM_SAMPLES 160 /* samples in a GSM block */ #define MSGSM_SAMPLES (2*GSM_SAMPLES) /* samples in an MSGSM block */ /* begin binary data: */ static char msgsm_silence[] = /* 65 */ {0x48,0x17,0xD6,0x84,0x02,0x80,0x24,0x49,0x92,0x24,0x89,0x02,0x80,0x24,0x49 ,0x92,0x24,0x89,0x02,0x80,0x24,0x49,0x92,0x24,0x89,0x02,0x80,0x24,0x49,0x92 ,0x24,0x09,0x82,0x74,0x61,0x4D,0x28,0x00,0x48,0x92,0x24,0x49,0x92,0x28,0x00 ,0x48,0x92,0x24,0x49,0x92,0x28,0x00,0x48,0x92,0x24,0x49,0x92,0x28,0x00,0x48 ,0x92,0x24,0x49,0x92,0x00}; /* end binary data. size = 65 bytes */ struct wavg_desc { /* Believe it or not, we must decode/recode to account for the weird MS format */ int secondhalf; /* Are we on the second half */ }; #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 check_header(FILE *f) { int type, size, formtype; int fmt, hsize, fact; short format, chans; int freq; int data; if (fread(&type, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (type)\n"); return -1; } if (fread(&size, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (size)\n"); return -1; } size = ltohl(size); if (fread(&formtype, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (formtype)\n"); return -1; } if (memcmp(&type, "RIFF", 4)) { ast_log(LOG_WARNING, "Does not begin with RIFF\n"); return -1; } if (memcmp(&formtype, "WAVE", 4)) { ast_log(LOG_WARNING, "Does not contain WAVE\n"); return -1; } if (fread(&fmt, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (fmt)\n"); return -1; } if (memcmp(&fmt, "fmt ", 4)) { ast_log(LOG_WARNING, "Does not say fmt\n"); return -1; } if (fread(&hsize, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (formtype)\n"); return -1; } if (ltohl(hsize) != 20) { ast_log(LOG_WARNING, "Unexpected header size %d\n", ltohl(hsize)); return -1; } if (fread(&format, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Read failed (format)\n"); return -1; } if (ltohs(format) != 49) { ast_log(LOG_WARNING, "Not a GSM file %d\n", ltohs(format)); return -1; } if (fread(&chans, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Read failed (format)\n"); return -1; } if (ltohs(chans) != 1) { ast_log(LOG_WARNING, "Not in mono %d\n", ltohs(chans)); return -1; } if (fread(&freq, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (freq)\n"); return -1; } if (ltohl(freq) != DEFAULT_SAMPLE_RATE) { ast_log(LOG_WARNING, "Unexpected frequency %d\n", ltohl(freq)); return -1; } /* Ignore the byte frequency */ if (fread(&freq, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (X_1)\n"); return -1; } /* Ignore the two weird fields */ if (fread(&freq, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (X_2/X_3)\n"); return -1; } /* Ignore the byte frequency */ if (fread(&freq, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (Y_1)\n"); return -1; } /* Check for the word fact */ if (fread(&fact, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (fact)\n"); return -1; } if (memcmp(&fact, "fact", 4)) { ast_log(LOG_WARNING, "Does not say fact\n"); return -1; } /* Ignore the "fact value" */ if (fread(&fact, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (fact header)\n"); return -1; } if (fread(&fact, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (fact value)\n"); return -1; } /* Check for the word data */ if (fread(&data, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (data)\n"); return -1; } if (memcmp(&data, "data", 4)) { ast_log(LOG_WARNING, "Does not say data\n"); return -1; } /* Ignore the data length */ if (fread(&data, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Read failed (data)\n"); return -1; } return 0; } static int update_header(FILE *f) { off_t cur,end,bytes; int datalen, filelen, samples; cur = ftello(f); fseek(f, 0, SEEK_END); end = ftello(f); /* in a gsm WAV, data starts 60 bytes in */ bytes = end - MSGSM_DATA_OFFSET; samples = htoll(bytes / MSGSM_FRAME_SIZE * MSGSM_SAMPLES); datalen = htoll(bytes); filelen = htoll(MSGSM_DATA_OFFSET - 8 + bytes); if (cur < 0) { ast_log(LOG_WARNING, "Unable to find our position\n"); return -1; } if (fseek(f, 4, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to set our position\n"); return -1; } if (fwrite(&filelen, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write file size\n"); return -1; } if (fseek(f, 48, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to set our position\n"); return -1; } if (fwrite(&samples, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write samples\n"); return -1; } if (fseek(f, 56, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to set our position\n"); return -1; } if (fwrite(&datalen, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write datalen\n"); return -1; } if (fseeko(f, cur, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to return to position\n"); return -1; } return 0; } static int write_header(FILE *f) { /* Samples per second (always 8000 for this format). */ unsigned int sample_rate = htoll(8000); /* Bytes per second (always 1625 for this format). */ unsigned int byte_sample_rate = htoll(1625); /* This is the size of the "fmt " subchunk */ unsigned int fmtsize = htoll(20); /* WAV #49 */ unsigned short fmt = htols(49); /* Mono = 1 channel */ unsigned short chans = htols(1); /* Each block of data is exactly 65 bytes in size. */ unsigned int block_align = htoll(MSGSM_FRAME_SIZE); /* Not actually 2, but rounded up to the nearest bit */ unsigned short bits_per_sample = htols(2); /* Needed for compressed formats */ unsigned short extra_format = htols(MSGSM_SAMPLES); /* This is the size of the "fact" subchunk */ unsigned int factsize = htoll(4); /* Number of samples in the data chunk */ unsigned int num_samples = htoll(0); /* Number of bytes in the data chunk */ unsigned int size = htoll(0); /* Write a GSM header, ignoring sizes which will be filled in later */ /* 0: Chunk ID */ if (fwrite("RIFF", 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 4: Chunk Size */ if (fwrite(&size, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 8: Chunk Format */ if (fwrite("WAVE", 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 12: Subchunk 1: ID */ if (fwrite("fmt ", 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 16: Subchunk 1: Size (minus 8) */ if (fwrite(&fmtsize, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 20: Subchunk 1: Audio format (49) */ if (fwrite(&fmt, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 22: Subchunk 1: Number of channels */ if (fwrite(&chans, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 24: Subchunk 1: Sample rate */ if (fwrite(&sample_rate, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 28: Subchunk 1: Byte rate */ if (fwrite(&byte_sample_rate, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 32: Subchunk 1: Block align */ if (fwrite(&block_align, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 36: Subchunk 1: Bits per sample */ if (fwrite(&bits_per_sample, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 38: Subchunk 1: Extra format bytes */ if (fwrite(&extra_format, 1, 2, f) != 2) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 40: Subchunk 2: ID */ if (fwrite("fact", 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 44: Subchunk 2: Size (minus 8) */ if (fwrite(&factsize, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 48: Subchunk 2: Number of samples */ if (fwrite(&num_samples, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 52: Subchunk 3: ID */ if (fwrite("data", 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } /* 56: Subchunk 3: Size */ if (fwrite(&size, 1, 4, f) != 4) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } return 0; } static int wav_open(struct ast_filestream *s) { /* We don't have any header to read or anything really, but if we did, it would go here. We also might want to check and be sure it's a valid file. */ struct wavg_desc *fs = (struct wavg_desc *)s->_private; if (check_header(s->f)) return -1; fs->secondhalf = 0; /* not strictly necessary */ return 0; } static int wav_rewrite(struct ast_filestream *s, const char *comment) { /* We don't have any header to read or anything really, but if we did, it would go here. We also might want to check and be sure it's a valid file. */ if (write_header(s->f)) return -1; return 0; } static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext) { /* Send a frame from the file to the appropriate channel */ struct wavg_desc *fs = (struct wavg_desc *)s->_private; s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_GSM, 0); s->fr.offset = AST_FRIENDLY_OFFSET; s->fr.samples = GSM_SAMPLES; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE); if (fs->secondhalf) { /* Just return a frame based on the second GSM frame */ s->fr.data.ptr = (char *)s->fr.data.ptr + GSM_FRAME_SIZE; s->fr.offset += GSM_FRAME_SIZE; } else { /* read and convert */ unsigned char msdata[MSGSM_FRAME_SIZE]; int res; if ((res = fread(msdata, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) { if (res && (res != 1)) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } /* Convert from MS format to two real GSM frames */ conv65(msdata, s->fr.data.ptr); } fs->secondhalf = !fs->secondhalf; *whennext = GSM_SAMPLES; return &s->fr; } static int wav_write(struct ast_filestream *s, struct ast_frame *f) { int len; int size; struct wavg_desc *fs = (struct wavg_desc *)s->_private; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_GSM) { ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } /* XXX this might fail... if the input is a multiple of MSGSM_FRAME_SIZE * we assume it is already in the correct format. */ if (!(f->datalen % MSGSM_FRAME_SIZE)) { size = MSGSM_FRAME_SIZE; fs->secondhalf = 0; } else { size = GSM_FRAME_SIZE; } for (len = 0; len < f->datalen ; len += size) { int res; unsigned char *src, msdata[MSGSM_FRAME_SIZE]; if (fs->secondhalf) { /* second half of raw gsm to be converted */ memcpy(s->buf + GSM_FRAME_SIZE, f->data.ptr + len, GSM_FRAME_SIZE); conv66((unsigned char *) s->buf, msdata); src = msdata; fs->secondhalf = 0; } else if (size == GSM_FRAME_SIZE) { /* first half of raw gsm */ memcpy(s->buf, f->data.ptr + len, GSM_FRAME_SIZE); src = NULL; /* nothing to write */ fs->secondhalf = 1; } else { /* raw msgsm data */ src = f->data.ptr + len; } if (src && (res = fwrite(src, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) { ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno)); return -1; } update_header(s->f); /* XXX inefficient! */ } return 0; } static int wav_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t offset = 0, min = MSGSM_DATA_OFFSET, distance, max, cur; struct wavg_desc *s = (struct wavg_desc *)fs->_private; if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in WAV filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of WAV filestream %p: %s\n", fs, strerror(errno)); return -1; } /* XXX ideally, should round correctly */ if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in WAV filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Compute the distance in bytes, rounded to the block size */ distance = (sample_offset/MSGSM_SAMPLES) * MSGSM_FRAME_SIZE; if (whence == SEEK_SET) offset = distance + min; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = distance + cur; else if (whence == SEEK_END) offset = max - distance; /* always protect against seeking past end of header */ if (offset < min) offset = min; if (whence != SEEK_FORCECUR) { if (offset > max) offset = max; } else if (offset > max) { int i; fseek(fs->f, 0, SEEK_END); for (i=0; i< (offset - max) / MSGSM_FRAME_SIZE; i++) { if (!fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f)) { ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); } } } s->secondhalf = 0; return fseeko(fs->f, offset, SEEK_SET); } static int wav_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for WAV filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in WAV filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ if (ftruncate(fd, cur)) { return -1; } return update_header(fs->f); } static off_t wav_tell(struct ast_filestream *fs) { off_t offset; offset = ftello(fs->f); /* since this will most likely be used later in play or record, lets stick * to that level of resolution, just even frames boundaries */ return (offset - MSGSM_DATA_OFFSET)/MSGSM_FRAME_SIZE*MSGSM_SAMPLES; } static struct ast_format_def wav49_f = { .name = "wav49", .exts = "WAV|wav49", .open = wav_open, .rewrite = wav_rewrite, .write = wav_write, .seek = wav_seek, .trunc = wav_trunc, .tell = wav_tell, .read = wav_read, .buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET, .desc_size = sizeof(struct wavg_desc), }; static int load_module(void) { ast_format_set(&wav49_f.format, AST_FORMAT_GSM, 0); if (ast_format_def_register(&wav49_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(wav49_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Microsoft WAV format (Proprietary GSM)", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/format_gsm.c0000644000175000007640000001337311747315641017342 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Save to raw, headerless GSM data. * \arg File name extension: gsm * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #include "msgsm.h" /* Some Ideas for this code came from makegsme.c by Jeffrey Chilton */ /* Portions of the conversion code are by guido@sienanet.it */ #define GSM_FRAME_SIZE 33 #define GSM_SAMPLES 160 /* silent gsm frame */ /* begin binary data: */ static const char gsm_silence[] = /* 33 */ {0xD8,0x20,0xA2,0xE1,0x5A,0x50,0x00,0x49,0x24,0x92,0x49,0x24,0x50,0x00,0x49 ,0x24,0x92,0x49,0x24,0x50,0x00,0x49,0x24,0x92,0x49,0x24,0x50,0x00,0x49,0x24 ,0x92,0x49,0x24}; /* end binary data. size = 33 bytes */ static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext) { int res; s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_GSM, 0); AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE) s->fr.mallocd = 0; if ((res = fread(s->fr.data.ptr, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } *whennext = s->fr.samples = GSM_SAMPLES; return &s->fr; } static int gsm_write(struct ast_filestream *fs, struct ast_frame *f) { int res; unsigned char gsm[2*GSM_FRAME_SIZE]; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (f->subclass.format.id != AST_FORMAT_GSM) { ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } if (!(f->datalen % 65)) { /* This is in MSGSM format, need to be converted */ int len=0; while(len < f->datalen) { conv65(f->data.ptr + len, gsm); if ((res = fwrite(gsm, 1, 2*GSM_FRAME_SIZE, fs->f)) != 2*GSM_FRAME_SIZE) { ast_log(LOG_WARNING, "Bad write (%d/66): %s\n", res, strerror(errno)); return -1; } len += 65; } } else { if (f->datalen % GSM_FRAME_SIZE) { ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 33\n", f->datalen); return -1; } if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/33): %s\n", res, strerror(errno)); return -1; } } return 0; } static int gsm_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t offset = 0, min = 0, cur, max, distance; if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in g719 filestream %p: %s\n", fs, strerror(errno)); return -1; } /* have to fudge to frame here, so not fully to sample */ distance = (sample_offset / GSM_SAMPLES) * GSM_FRAME_SIZE; if (whence == SEEK_SET) { offset = distance; } else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) { offset = distance + cur; } else if (whence == SEEK_END) { offset = max - distance; } /* Always protect against seeking past the begining. */ offset = (offset < min)?min:offset; if (whence != SEEK_FORCECUR) { offset = (offset > max)?max:offset; } else if (offset > max) { int i; fseeko(fs->f, 0, SEEK_END); for (i=0; i< (offset - max) / GSM_FRAME_SIZE; i++) { if (!fwrite(gsm_silence, 1, GSM_FRAME_SIZE, fs->f)) { ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); } } } return fseeko(fs->f, offset, SEEK_SET); } static int gsm_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for gsm filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in gsm filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t gsm_tell(struct ast_filestream *fs) { off_t offset = ftello(fs->f); if (offset < 0) { ast_log(AST_LOG_WARNING, "Unable to determine offset for gsm filestream %p: %s\n", fs, strerror(errno)); return 0; } return (offset / GSM_FRAME_SIZE) * GSM_SAMPLES; } static struct ast_format_def gsm_f = { .name = "gsm", .exts = "gsm", .write = gsm_write, .seek = gsm_seek, .trunc = gsm_trunc, .tell = gsm_tell, .read = gsm_read, .buf_size = 2*GSM_FRAME_SIZE + AST_FRIENDLY_OFFSET, /* 2 gsm frames */ }; static int load_module(void) { ast_format_set(&gsm_f.format, AST_FORMAT_GSM, 0); if (ast_format_def_register(&gsm_f)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(gsm_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw GSM data", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/formats/msgsm.h0000644000175000007640000007041111046610740016321 0ustar sharkyjerryweb/* Conversion routines derived from code by guido@sienanet.it */ #define GSM_MAGIC 0xD #ifndef GSM_H typedef unsigned char gsm_byte; #endif typedef unsigned char wav_byte; typedef unsigned int uword; #define readGSM_33(c1) { \ gsm_byte *__c = (c1); \ LARc[0] = (*__c++ & 0xF) << 2; /* 1 */ \ LARc[0] |= (*__c >> 6) & 0x3; \ LARc[1] = *__c++ & 0x3F; \ LARc[2] = (*__c >> 3) & 0x1F; \ LARc[3] = (*__c++ & 0x7) << 2; \ LARc[3] |= (*__c >> 6) & 0x3; \ LARc[4] = (*__c >> 2) & 0xF; \ LARc[5] = (*__c++ & 0x3) << 2; \ LARc[5] |= (*__c >> 6) & 0x3; \ LARc[6] = (*__c >> 3) & 0x7; \ LARc[7] = *__c++ & 0x7; \ Nc[0] = (*__c >> 1) & 0x7F; \ bc[0] = (*__c++ & 0x1) << 1; \ bc[0] |= (*__c >> 7) & 0x1; \ Mc[0] = (*__c >> 5) & 0x3; \ xmaxc[0] = (*__c++ & 0x1F) << 1; \ xmaxc[0] |= (*__c >> 7) & 0x1; \ xmc[0] = (*__c >> 4) & 0x7; \ xmc[1] = (*__c >> 1) & 0x7; \ xmc[2] = (*__c++ & 0x1) << 2; \ xmc[2] |= (*__c >> 6) & 0x3; \ xmc[3] = (*__c >> 3) & 0x7; \ xmc[4] = *__c++ & 0x7; \ xmc[5] = (*__c >> 5) & 0x7; \ xmc[6] = (*__c >> 2) & 0x7; \ xmc[7] = (*__c++ & 0x3) << 1; /* 10 */ \ xmc[7] |= (*__c >> 7) & 0x1; \ xmc[8] = (*__c >> 4) & 0x7; \ xmc[9] = (*__c >> 1) & 0x7; \ xmc[10] = (*__c++ & 0x1) << 2; \ xmc[10] |= (*__c >> 6) & 0x3; \ xmc[11] = (*__c >> 3) & 0x7; \ xmc[12] = *__c++ & 0x7; \ Nc[1] = (*__c >> 1) & 0x7F; \ bc[1] = (*__c++ & 0x1) << 1; \ bc[1] |= (*__c >> 7) & 0x1; \ Mc[1] = (*__c >> 5) & 0x3; \ xmaxc[1] = (*__c++ & 0x1F) << 1; \ xmaxc[1] |= (*__c >> 7) & 0x1; \ xmc[13] = (*__c >> 4) & 0x7; \ xmc[14] = (*__c >> 1) & 0x7; \ xmc[15] = (*__c++ & 0x1) << 2; \ xmc[15] |= (*__c >> 6) & 0x3; \ xmc[16] = (*__c >> 3) & 0x7; \ xmc[17] = *__c++ & 0x7; \ xmc[18] = (*__c >> 5) & 0x7; \ xmc[19] = (*__c >> 2) & 0x7; \ xmc[20] = (*__c++ & 0x3) << 1; \ xmc[20] |= (*__c >> 7) & 0x1; \ xmc[21] = (*__c >> 4) & 0x7; \ xmc[22] = (*__c >> 1) & 0x7; \ xmc[23] = (*__c++ & 0x1) << 2; \ xmc[23] |= (*__c >> 6) & 0x3; \ xmc[24] = (*__c >> 3) & 0x7; \ xmc[25] = *__c++ & 0x7; \ Nc[2] = (*__c >> 1) & 0x7F; \ bc[2] = (*__c++ & 0x1) << 1; /* 20 */ \ bc[2] |= (*__c >> 7) & 0x1; \ Mc[2] = (*__c >> 5) & 0x3; \ xmaxc[2] = (*__c++ & 0x1F) << 1; \ xmaxc[2] |= (*__c >> 7) & 0x1; \ xmc[26] = (*__c >> 4) & 0x7; \ xmc[27] = (*__c >> 1) & 0x7; \ xmc[28] = (*__c++ & 0x1) << 2; \ xmc[28] |= (*__c >> 6) & 0x3; \ xmc[29] = (*__c >> 3) & 0x7; \ xmc[30] = *__c++ & 0x7; \ xmc[31] = (*__c >> 5) & 0x7; \ xmc[32] = (*__c >> 2) & 0x7; \ xmc[33] = (*__c++ & 0x3) << 1; \ xmc[33] |= (*__c >> 7) & 0x1; \ xmc[34] = (*__c >> 4) & 0x7; \ xmc[35] = (*__c >> 1) & 0x7; \ xmc[36] = (*__c++ & 0x1) << 2; \ xmc[36] |= (*__c >> 6) & 0x3; \ xmc[37] = (*__c >> 3) & 0x7; \ xmc[38] = *__c++ & 0x7; \ Nc[3] = (*__c >> 1) & 0x7F; \ bc[3] = (*__c++ & 0x1) << 1; \ bc[3] |= (*__c >> 7) & 0x1; \ Mc[3] = (*__c >> 5) & 0x3; \ xmaxc[3] = (*__c++ & 0x1F) << 1; \ xmaxc[3] |= (*__c >> 7) & 0x1; \ xmc[39] = (*__c >> 4) & 0x7; \ xmc[40] = (*__c >> 1) & 0x7; \ xmc[41] = (*__c++ & 0x1) << 2; \ xmc[41] |= (*__c >> 6) & 0x3; \ xmc[42] = (*__c >> 3) & 0x7; \ xmc[43] = *__c++ & 0x7; /* 30 */ \ xmc[44] = (*__c >> 5) & 0x7; \ xmc[45] = (*__c >> 2) & 0x7; \ xmc[46] = (*__c++ & 0x3) << 1; \ xmc[46] |= (*__c >> 7) & 0x1; \ xmc[47] = (*__c >> 4) & 0x7; \ xmc[48] = (*__c >> 1) & 0x7; \ xmc[49] = (*__c++ & 0x1) << 2; \ xmc[49] |= (*__c >> 6) & 0x3; \ xmc[50] = (*__c >> 3) & 0x7; \ xmc[51] = *__c & 0x7; /* 33 */ \ } static inline void conv66(gsm_byte * d, wav_byte * c) { gsm_byte frame_chain; unsigned int sr; unsigned int LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4]; readGSM_33(d); sr = 0; sr = (sr >> 6) | (LARc[0] << 10); sr = (sr >> 6) | (LARc[1] << 10); *c++ = sr >> 4; sr = (sr >> 5) | (LARc[2] << 11); *c++ = sr >> 7; sr = (sr >> 5) | (LARc[3] << 11); sr = (sr >> 4) | (LARc[4] << 12); *c++ = sr >> 6; sr = (sr >> 4) | (LARc[5] << 12); sr = (sr >> 3) | (LARc[6] << 13); *c++ = sr >> 7; sr = (sr >> 3) | (LARc[7] << 13); sr = (sr >> 7) | (Nc[0] << 9); *c++ = sr >> 5; sr = (sr >> 2) | (bc[0] << 14); sr = (sr >> 2) | (Mc[0] << 14); sr = (sr >> 6) | (xmaxc[0] << 10); *c++ = sr >> 3; sr = (sr >> 3 )|( xmc[0] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[1] << 13); sr = (sr >> 3 )|( xmc[2] << 13); sr = (sr >> 3 )|( xmc[3] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[4] << 13); sr = (sr >> 3 )|( xmc[5] << 13); sr = (sr >> 3 )|( xmc[6] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[7] << 13); sr = (sr >> 3 )|( xmc[8] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[9] << 13); sr = (sr >> 3 )|( xmc[10] << 13); sr = (sr >> 3 )|( xmc[11] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[12] << 13); sr = (sr >> 7 )|( Nc[1] << 9); *c++ = sr >> 5; sr = (sr >> 2 )|( bc[1] << 14); sr = (sr >> 2 )|( Mc[1] << 14); sr = (sr >> 6 )|( xmaxc[1] << 10); *c++ = sr >> 3; sr = (sr >> 3 )|( xmc[13] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[14] << 13); sr = (sr >> 3 )|( xmc[15] << 13); sr = (sr >> 3 )|( xmc[16] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[17] << 13); sr = (sr >> 3 )|( xmc[18] << 13); sr = (sr >> 3 )|( xmc[19] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[20] << 13); sr = (sr >> 3 )|( xmc[21] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[22] << 13); sr = (sr >> 3 )|( xmc[23] << 13); sr = (sr >> 3 )|( xmc[24] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[25] << 13); sr = (sr >> 7 )|( Nc[2] << 9); *c++ = sr >> 5; sr = (sr >> 2 )|( bc[2] << 14); sr = (sr >> 2 )|( Mc[2] << 14); sr = (sr >> 6 )|( xmaxc[2] << 10); *c++ = sr >> 3; sr = (sr >> 3 )|( xmc[26] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[27] << 13); sr = (sr >> 3 )|( xmc[28] << 13); sr = (sr >> 3 )|( xmc[29] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[30] << 13); sr = (sr >> 3 )|( xmc[31] << 13); sr = (sr >> 3 )|( xmc[32] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[33] << 13); sr = (sr >> 3 )|( xmc[34] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[35] << 13); sr = (sr >> 3 )|( xmc[36] << 13); sr = (sr >> 3 )|( xmc[37] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[38] << 13); sr = (sr >> 7 )|( Nc[3] << 9); *c++ = sr >> 5; sr = (sr >> 2 )|( bc[3] << 14); sr = (sr >> 2 )|( Mc[3] << 14); sr = (sr >> 6 )|( xmaxc[3] << 10); *c++ = sr >> 3; sr = (sr >> 3 )|( xmc[39] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[40] << 13); sr = (sr >> 3 )|( xmc[41] << 13); sr = (sr >> 3 )|( xmc[42] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[43] << 13); sr = (sr >> 3 )|( xmc[44] << 13); sr = (sr >> 3 )|( xmc[45] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[46] << 13); sr = (sr >> 3 )|( xmc[47] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[48] << 13); sr = (sr >> 3 )|( xmc[49] << 13); sr = (sr >> 3 )|( xmc[50] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[51] << 13); sr = sr >> 4; *c = sr >> 8; frame_chain = *c; readGSM_33(d+33); /* puts all the parameters into LARc etc. */ sr = 0; /* sr = (sr >> 4 )|( s->frame_chain << 12); */ sr = (sr >> 4 )|( frame_chain << 12); sr = (sr >> 6 )|( LARc[0] << 10); *c++ = sr >> 6; sr = (sr >> 6 )|( LARc[1] << 10); *c++ = sr >> 8; sr = (sr >> 5 )|( LARc[2] << 11); sr = (sr >> 5 )|( LARc[3] << 11); *c++ = sr >> 6; sr = (sr >> 4 )|( LARc[4] << 12); sr = (sr >> 4 )|( LARc[5] << 12); *c++ = sr >> 6; sr = (sr >> 3 )|( LARc[6] << 13); sr = (sr >> 3 )|( LARc[7] << 13); *c++ = sr >> 8; sr = (sr >> 7 )|( Nc[0] << 9); sr = (sr >> 2 )|( bc[0] << 14); *c++ = sr >> 7; sr = (sr >> 2 )|( Mc[0] << 14); sr = (sr >> 6 )|( xmaxc[0] << 10); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[0] << 13); sr = (sr >> 3 )|( xmc[1] << 13); sr = (sr >> 3 )|( xmc[2] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[3] << 13); sr = (sr >> 3 )|( xmc[4] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[5] << 13); sr = (sr >> 3 )|( xmc[6] << 13); sr = (sr >> 3 )|( xmc[7] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[8] << 13); sr = (sr >> 3 )|( xmc[9] << 13); sr = (sr >> 3 )|( xmc[10] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[11] << 13); sr = (sr >> 3 )|( xmc[12] << 13); *c++ = sr >> 8; sr = (sr >> 7 )|( Nc[1] << 9); sr = (sr >> 2 )|( bc[1] << 14); *c++ = sr >> 7; sr = (sr >> 2 )|( Mc[1] << 14); sr = (sr >> 6 )|( xmaxc[1] << 10); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[13] << 13); sr = (sr >> 3 )|( xmc[14] << 13); sr = (sr >> 3 )|( xmc[15] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[16] << 13); sr = (sr >> 3 )|( xmc[17] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[18] << 13); sr = (sr >> 3 )|( xmc[19] << 13); sr = (sr >> 3 )|( xmc[20] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[21] << 13); sr = (sr >> 3 )|( xmc[22] << 13); sr = (sr >> 3 )|( xmc[23] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[24] << 13); sr = (sr >> 3 )|( xmc[25] << 13); *c++ = sr >> 8; sr = (sr >> 7 )|( Nc[2] << 9); sr = (sr >> 2 )|( bc[2] << 14); *c++ = sr >> 7; sr = (sr >> 2 )|( Mc[2] << 14); sr = (sr >> 6 )|( xmaxc[2] << 10); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[26] << 13); sr = (sr >> 3 )|( xmc[27] << 13); sr = (sr >> 3 )|( xmc[28] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[29] << 13); sr = (sr >> 3 )|( xmc[30] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[31] << 13); sr = (sr >> 3 )|( xmc[32] << 13); sr = (sr >> 3 )|( xmc[33] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[34] << 13); sr = (sr >> 3 )|( xmc[35] << 13); sr = (sr >> 3 )|( xmc[36] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[37] << 13); sr = (sr >> 3 )|( xmc[38] << 13); *c++ = sr >> 8; sr = (sr >> 7 )|( Nc[3] << 9); sr = (sr >> 2 )|( bc[3] << 14); *c++ = sr >> 7; sr = (sr >> 2 )|( Mc[3] << 14); sr = (sr >> 6 )|( xmaxc[3] << 10); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[39] << 13); sr = (sr >> 3 )|( xmc[40] << 13); sr = (sr >> 3 )|( xmc[41] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[42] << 13); sr = (sr >> 3 )|( xmc[43] << 13); *c++ = sr >> 8; sr = (sr >> 3 )|( xmc[44] << 13); sr = (sr >> 3 )|( xmc[45] << 13); sr = (sr >> 3 )|( xmc[46] << 13); *c++ = sr >> 7; sr = (sr >> 3 )|( xmc[47] << 13); sr = (sr >> 3 )|( xmc[48] << 13); sr = (sr >> 3 )|( xmc[49] << 13); *c++ = sr >> 6; sr = (sr >> 3 )|( xmc[50] << 13); sr = (sr >> 3 )|( xmc[51] << 13); *c++ = sr >> 8; } #define writeGSM_33(c1) { \ gsm_byte *__c = (c1); \ *__c++ = ((GSM_MAGIC & 0xF) << 4) /* 1 */ \ | ((LARc[0] >> 2) & 0xF); \ *__c++ = ((LARc[0] & 0x3) << 6) \ | (LARc[1] & 0x3F); \ *__c++ = ((LARc[2] & 0x1F) << 3) \ | ((LARc[3] >> 2) & 0x7); \ *__c++ = ((LARc[3] & 0x3) << 6) \ | ((LARc[4] & 0xF) << 2) \ | ((LARc[5] >> 2) & 0x3); \ *__c++ = ((LARc[5] & 0x3) << 6) \ | ((LARc[6] & 0x7) << 3) \ | (LARc[7] & 0x7); \ *__c++ = ((Nc[0] & 0x7F) << 1) \ | ((bc[0] >> 1) & 0x1); \ *__c++ = ((bc[0] & 0x1) << 7) \ | ((Mc[0] & 0x3) << 5) \ | ((xmaxc[0] >> 1) & 0x1F); \ *__c++ = ((xmaxc[0] & 0x1) << 7) \ | ((xmc[0] & 0x7) << 4) \ | ((xmc[1] & 0x7) << 1) \ | ((xmc[2] >> 2) & 0x1); \ *__c++ = ((xmc[2] & 0x3) << 6) \ | ((xmc[3] & 0x7) << 3) \ | (xmc[4] & 0x7); \ *__c++ = ((xmc[5] & 0x7) << 5) /* 10 */ \ | ((xmc[6] & 0x7) << 2) \ | ((xmc[7] >> 1) & 0x3); \ *__c++ = ((xmc[7] & 0x1) << 7) \ | ((xmc[8] & 0x7) << 4) \ | ((xmc[9] & 0x7) << 1) \ | ((xmc[10] >> 2) & 0x1); \ *__c++ = ((xmc[10] & 0x3) << 6) \ | ((xmc[11] & 0x7) << 3) \ | (xmc[12] & 0x7); \ *__c++ = ((Nc[1] & 0x7F) << 1) \ | ((bc[1] >> 1) & 0x1); \ *__c++ = ((bc[1] & 0x1) << 7) \ | ((Mc[1] & 0x3) << 5) \ | ((xmaxc[1] >> 1) & 0x1F); \ *__c++ = ((xmaxc[1] & 0x1) << 7) \ | ((xmc[13] & 0x7) << 4) \ | ((xmc[14] & 0x7) << 1) \ | ((xmc[15] >> 2) & 0x1); \ *__c++ = ((xmc[15] & 0x3) << 6) \ | ((xmc[16] & 0x7) << 3) \ | (xmc[17] & 0x7); \ *__c++ = ((xmc[18] & 0x7) << 5) \ | ((xmc[19] & 0x7) << 2) \ | ((xmc[20] >> 1) & 0x3); \ *__c++ = ((xmc[20] & 0x1) << 7) \ | ((xmc[21] & 0x7) << 4) \ | ((xmc[22] & 0x7) << 1) \ | ((xmc[23] >> 2) & 0x1); \ *__c++ = ((xmc[23] & 0x3) << 6) \ | ((xmc[24] & 0x7) << 3) \ | (xmc[25] & 0x7); \ *__c++ = ((Nc[2] & 0x7F) << 1) /* 20 */ \ | ((bc[2] >> 1) & 0x1); \ *__c++ = ((bc[2] & 0x1) << 7) \ | ((Mc[2] & 0x3) << 5) \ | ((xmaxc[2] >> 1) & 0x1F); \ *__c++ = ((xmaxc[2] & 0x1) << 7) \ | ((xmc[26] & 0x7) << 4) \ | ((xmc[27] & 0x7) << 1) \ | ((xmc[28] >> 2) & 0x1); \ *__c++ = ((xmc[28] & 0x3) << 6) \ | ((xmc[29] & 0x7) << 3) \ | (xmc[30] & 0x7); \ *__c++ = ((xmc[31] & 0x7) << 5) \ | ((xmc[32] & 0x7) << 2) \ | ((xmc[33] >> 1) & 0x3); \ *__c++ = ((xmc[33] & 0x1) << 7) \ | ((xmc[34] & 0x7) << 4) \ | ((xmc[35] & 0x7) << 1) \ | ((xmc[36] >> 2) & 0x1); \ *__c++ = ((xmc[36] & 0x3) << 6) \ | ((xmc[37] & 0x7) << 3) \ | (xmc[38] & 0x7); \ *__c++ = ((Nc[3] & 0x7F) << 1) \ | ((bc[3] >> 1) & 0x1); \ *__c++ = ((bc[3] & 0x1) << 7) \ | ((Mc[3] & 0x3) << 5) \ | ((xmaxc[3] >> 1) & 0x1F); \ *__c++ = ((xmaxc[3] & 0x1) << 7) \ | ((xmc[39] & 0x7) << 4) \ | ((xmc[40] & 0x7) << 1) \ | ((xmc[41] >> 2) & 0x1); \ *__c++ = ((xmc[41] & 0x3) << 6) /* 30 */ \ | ((xmc[42] & 0x7) << 3) \ | (xmc[43] & 0x7); \ *__c++ = ((xmc[44] & 0x7) << 5) \ | ((xmc[45] & 0x7) << 2) \ | ((xmc[46] >> 1) & 0x3); \ *__c++ = ((xmc[46] & 0x1) << 7) \ | ((xmc[47] & 0x7) << 4) \ | ((xmc[48] & 0x7) << 1) \ | ((xmc[49] >> 2) & 0x1); \ *__c++ = ((xmc[49] & 0x3) << 6) \ | ((xmc[50] & 0x7) << 3) \ | (xmc[51] & 0x7); \ } static inline void conv65( wav_byte * c, gsm_byte * d){ unsigned int sr = 0; unsigned int frame_chain; unsigned int LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4]; /* silence bogus compiler warning */ unsigned int xmc[13*4] = { 0, }; sr = *c++; LARc[0] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 2; LARc[1] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 4; LARc[2] = sr & 0x1f; sr >>= 5; LARc[3] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 2; LARc[4] = sr & 0xf; sr >>= 4; LARc[5] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; /* 5 */ LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[0] = sr & 0x7f; sr >>= 7; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[0] = sr & 0x3f; sr >>= 6; xmc[0] = sr & 0x7; sr >>= 3; sr = *c++; xmc[1] = sr & 0x7; sr >>= 3; xmc[2] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; xmc[5] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 10 */ xmc[6] = sr & 0x7; sr >>= 3; xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; sr = *c++; xmc[9] = sr & 0x7; sr >>= 3; xmc[10] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[1] = sr & 0x7f; sr >>= 7; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[1] = sr & 0x3f; sr >>= 6; xmc[13] = sr & 0x7; sr >>= 3; sr = *c++; /* 15 */ xmc[14] = sr & 0x7; sr >>= 3; xmc[15] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; xmc[18] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[19] = sr & 0x7; sr >>= 3; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; sr = *c++; xmc[22] = sr & 0x7; sr >>= 3; xmc[23] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; /* 20 */ Nc[2] = sr & 0x7f; sr >>= 7; bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[2] = sr & 0x3f; sr >>= 6; xmc[26] = sr & 0x7; sr >>= 3; sr = *c++; xmc[27] = sr & 0x7; sr >>= 3; xmc[28] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; xmc[31] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[32] = sr & 0x7; sr >>= 3; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; sr = *c++; /* 25 */ xmc[35] = sr & 0x7; sr >>= 3; xmc[36] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[3] = sr & 0x7f; sr >>= 7; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[3] = sr & 0x3f; sr >>= 6; xmc[39] = sr & 0x7; sr >>= 3; sr = *c++; xmc[40] = sr & 0x7; sr >>= 3; xmc[41] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 30 */ xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; xmc[44] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[45] = sr & 0x7; sr >>= 3; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; sr = *c++; xmc[49] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; frame_chain = sr & 0xf; writeGSM_33(d);/* LARc etc. -> array of 33 GSM bytes */ sr = frame_chain; sr |= (uword)*c++ << 4; /* 1 */ LARc[0] = sr & 0x3f; sr >>= 6; LARc[1] = sr & 0x3f; sr >>= 6; sr = *c++; LARc[2] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 3; LARc[3] = sr & 0x1f; sr >>= 5; LARc[4] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; LARc[5] = sr & 0xf; sr >>= 4; LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr = *c++; /* 5 */ Nc[0] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[0] = sr & 0x3f; sr >>= 6; xmc[0] = sr & 0x7; sr >>= 3; xmc[1] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[2] = sr & 0x7; sr >>= 3; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; sr = *c++; xmc[5] = sr & 0x7; sr >>= 3; xmc[6] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 10 */ xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; xmc[9] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[10] = sr & 0x7; sr >>= 3; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr = *c++; Nc[1] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[1] = sr & 0x3f; sr >>= 6; xmc[13] = sr & 0x7; sr >>= 3; xmc[14] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 15 */ xmc[15] = sr & 0x7; sr >>= 3; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; sr = *c++; xmc[18] = sr & 0x7; sr >>= 3; xmc[19] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; xmc[22] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[23] = sr & 0x7; sr >>= 3; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr = *c++; Nc[2] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; /* 20 */ bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[2] = sr & 0x3f; sr >>= 6; xmc[26] = sr & 0x7; sr >>= 3; xmc[27] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[28] = sr & 0x7; sr >>= 3; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; sr = *c++; xmc[31] = sr & 0x7; sr >>= 3; xmc[32] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; xmc[35] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 25 */ xmc[36] = sr & 0x7; sr >>= 3; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr = *c++; Nc[3] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[3] = sr & 0x3f; sr >>= 6; xmc[39] = sr & 0x7; sr >>= 3; xmc[40] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[41] = sr & 0x7; sr >>= 3; xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; sr = *c++; /* 30 */ xmc[44] = sr & 0x7; sr >>= 3; xmc[45] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; xmc[48] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[49] = sr & 0x7; sr >>= 3; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; writeGSM_33(d+33); } asterisk-11.7.0/formats/Makefile0000644000175000007640000000070410731422157016463 0ustar sharkyjerryweb# # Asterisk -- A telephony toolkit for Linux. # # Makefile for file format modules # # Copyright (C) 1999-2006, 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=format MENUSELECT_CATEGORY=FORMATS MENUSELECT_DESCRIPTION=Format Interpreters all: _all include $(ASTTOPDIR)/Makefile.moddir_rules asterisk-11.7.0/formats/format_pcm.c0000644000175000007640000003375611747315641017342 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Flat, binary, ulaw PCM file format. * \arg File name extension: alaw, al, alw, pcm, ulaw, ul, mu, ulw, g722, au * * \ingroup formats */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 364580 $") #include "asterisk/mod_format.h" #include "asterisk/module.h" #include "asterisk/endian.h" #include "asterisk/ulaw.h" #include "asterisk/alaw.h" #define BUF_SIZE 160 /* 160 bytes, and same number of samples */ static char ulaw_silence[BUF_SIZE]; static char alaw_silence[BUF_SIZE]; /* #define REALTIME_WRITE */ /* XXX does it work at all ? */ #ifdef REALTIME_WRITE struct pcm_desc { unsigned long start_time; }; /* Returns time in msec since system boot. */ static unsigned long get_time(void) { struct tms buf; clock_t cur; cur = times( &buf ); if( cur < 0 ) { ast_log( LOG_WARNING, "Cannot get current time\n" ); return 0; } return cur * 1000 / sysconf( _SC_CLK_TCK ); } static int pcma_open(struct ast_filestream *s) { if (s->fmt->format == AST_FORMAT_ALAW) pd->starttime = get_time(); return 0; } static int pcma_rewrite(struct ast_filestream *s, const char *comment) { return pcma_open(s); } #endif static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext) { int res; /* Send a frame from the file to the appropriate channel */ s->fr.frametype = AST_FRAME_VOICE; ast_format_copy(&s->fr.subclass.format, &s->fmt->format); s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; } s->fr.datalen = res; if (s->fmt->format.id == AST_FORMAT_G722) *whennext = s->fr.samples = res * 2; else *whennext = s->fr.samples = res; return &s->fr; } static int pcm_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t cur, max, offset = 0; int ret = -1; /* assume error */ if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in pcm filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of pcm filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in pcm filestream %p: %s\n", fs, strerror(errno)); return -1; } switch (whence) { case SEEK_SET: offset = sample_offset; break; case SEEK_END: offset = max - sample_offset; break; case SEEK_CUR: case SEEK_FORCECUR: offset = cur + sample_offset; break; default: ast_log(LOG_WARNING, "invalid whence %d, assuming SEEK_SET\n", whence); offset = sample_offset; } if (offset < 0) { ast_log(LOG_WARNING, "negative offset %ld, resetting to 0\n", (long) offset); offset = 0; } if (whence == SEEK_FORCECUR && offset > max) { /* extend the file */ size_t left = offset - max; const char *src = (fs->fmt->format.id == AST_FORMAT_ALAW) ? alaw_silence : ulaw_silence; while (left) { size_t written = fwrite(src, 1, (left > BUF_SIZE) ? BUF_SIZE : left, fs->f); if (written == -1) break; /* error */ left -= written; } ret = 0; /* successful */ } else { if (offset > max) { ast_log(LOG_WARNING, "offset too large %ld, truncating to %ld\n", (long) offset, (long) max); offset = max; } ret = fseeko(fs->f, offset, SEEK_SET); } return ret; } static int pcm_trunc(struct ast_filestream *fs) { int cur, fd; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for pcm filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in pcm filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ return ftruncate(fd, cur); } static off_t pcm_tell(struct ast_filestream *fs) { return ftello(fs->f); } static int pcm_write(struct ast_filestream *fs, struct ast_frame *f) { int res; if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); return -1; } if (ast_format_cmp(&f->subclass.format, &fs->fmt->format) == AST_FORMAT_CMP_NOT_EQUAL) { ast_log(LOG_WARNING, "Asked to write incompatible format frame (%s)!\n", ast_getformatname(&f->subclass.format)); return -1; } #ifdef REALTIME_WRITE if (s->fmt->format == AST_FORMAT_ALAW) { struct pcm_desc *pd = (struct pcm_desc *)fs->_private; struct stat stat_buf; unsigned long cur_time = get_time(); unsigned long fpos = ( cur_time - pd->start_time ) * 8; /* 8 bytes per msec */ /* Check if we have written to this position yet. If we have, then increment pos by one frame * for some degree of protection against receiving packets in the same clock tick. */ fstat(fileno(fs->f), &stat_buf ); if (stat_buf.st_size > fpos ) fpos += f->datalen; /* Incrementing with the size of this current frame */ if (stat_buf.st_size < fpos) { /* fill the gap with 0x55 rather than 0. */ char buf[1024]; unsigned long cur, to_write; cur = stat_buf.st_size; if (fseek(fs->f, cur, SEEK_SET) < 0) { ast_log( LOG_WARNING, "Cannot seek in file: %s\n", strerror(errno) ); return -1; } memset(buf, 0x55, 512); while (cur < fpos) { to_write = fpos - cur; if (to_write > sizeof(buf)) to_write = sizeof(buf); fwrite(buf, 1, to_write, fs->f); cur += to_write; } } if (fseek(s->f, fpos, SEEK_SET) < 0) { ast_log( LOG_WARNING, "Cannot seek in file: %s\n", strerror(errno) ); return -1; } } #endif /* REALTIME_WRITE */ if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } return 0; } /* SUN .au support routines */ #define AU_HEADER_SIZE 24 #define AU_HEADER(var) uint32_t var[6] #define AU_HDR_MAGIC_OFF 0 #define AU_HDR_HDR_SIZE_OFF 1 #define AU_HDR_DATA_SIZE_OFF 2 #define AU_HDR_ENCODING_OFF 3 #define AU_HDR_SAMPLE_RATE_OFF 4 #define AU_HDR_CHANNELS_OFF 5 #define AU_ENC_8BIT_ULAW 1 #define AU_MAGIC 0x2e736e64 #if __BYTE_ORDER == __BIG_ENDIAN #define htoll(b) (b) #define htols(b) (b) #define ltohl(b) (b) #define ltohs(b) (b) #else #if __BYTE_ORDER == __LITTLE_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 check_header(FILE *f) { AU_HEADER(header); uint32_t magic; uint32_t hdr_size; uint32_t data_size; uint32_t encoding; uint32_t sample_rate; uint32_t channels; if (fread(header, 1, AU_HEADER_SIZE, f) != AU_HEADER_SIZE) { ast_log(LOG_WARNING, "Read failed (header)\n"); return -1; } magic = ltohl(header[AU_HDR_MAGIC_OFF]); if (magic != (uint32_t) AU_MAGIC) { ast_log(LOG_WARNING, "Bad magic: 0x%x\n", magic); } hdr_size = ltohl(header[AU_HDR_HDR_SIZE_OFF]); if (hdr_size < AU_HEADER_SIZE) { hdr_size = AU_HEADER_SIZE; } /* data_size = ltohl(header[AU_HDR_DATA_SIZE_OFF]); */ encoding = ltohl(header[AU_HDR_ENCODING_OFF]); if (encoding != AU_ENC_8BIT_ULAW) { ast_log(LOG_WARNING, "Unexpected format: %d. Only 8bit ULAW allowed (%d)\n", encoding, AU_ENC_8BIT_ULAW); return -1; } sample_rate = ltohl(header[AU_HDR_SAMPLE_RATE_OFF]); if (sample_rate != DEFAULT_SAMPLE_RATE) { ast_log(LOG_WARNING, "Sample rate can only be 8000 not %d\n", sample_rate); return -1; } channels = ltohl(header[AU_HDR_CHANNELS_OFF]); if (channels != 1) { ast_log(LOG_WARNING, "Not in mono: channels=%d\n", channels); return -1; } /* Skip to data */ fseek(f, 0, SEEK_END); data_size = ftell(f) - hdr_size; if (fseek(f, hdr_size, SEEK_SET) == -1 ) { ast_log(LOG_WARNING, "Failed to skip to data: %d\n", hdr_size); return -1; } return data_size; } static int update_header(FILE *f) { off_t cur, end; uint32_t datalen; int bytes; cur = ftell(f); fseek(f, 0, SEEK_END); end = ftell(f); /* data starts 24 bytes in */ bytes = end - AU_HEADER_SIZE; datalen = htoll(bytes); if (cur < 0) { ast_log(LOG_WARNING, "Unable to find our position\n"); return -1; } if (fseek(f, AU_HDR_DATA_SIZE_OFF * sizeof(uint32_t), SEEK_SET)) { ast_log(LOG_WARNING, "Unable to set our position\n"); return -1; } if (fwrite(&datalen, 1, sizeof(datalen), f) != sizeof(datalen)) { ast_log(LOG_WARNING, "Unable to set write file size\n"); return -1; } if (fseek(f, cur, SEEK_SET)) { ast_log(LOG_WARNING, "Unable to return to position\n"); return -1; } return 0; } static int write_header(FILE *f) { AU_HEADER(header); header[AU_HDR_MAGIC_OFF] = htoll((uint32_t) AU_MAGIC); header[AU_HDR_HDR_SIZE_OFF] = htoll(AU_HEADER_SIZE); header[AU_HDR_DATA_SIZE_OFF] = 0; header[AU_HDR_ENCODING_OFF] = htoll(AU_ENC_8BIT_ULAW); header[AU_HDR_SAMPLE_RATE_OFF] = htoll(DEFAULT_SAMPLE_RATE); header[AU_HDR_CHANNELS_OFF] = htoll(1); /* Write an au header, ignoring sizes which will be filled in later */ fseek(f, 0, SEEK_SET); if (fwrite(header, 1, AU_HEADER_SIZE, f) != AU_HEADER_SIZE) { ast_log(LOG_WARNING, "Unable to write header\n"); return -1; } return 0; } static int au_open(struct ast_filestream *s) { if (check_header(s->f) < 0) return -1; return 0; } static int au_rewrite(struct ast_filestream *s, const char *comment) { if (write_header(s->f)) return -1; return 0; } /* XXX check this, probably incorrect */ static int au_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t min = AU_HEADER_SIZE, max, cur; long offset = 0, bytes; if (fs->fmt->format.id == AST_FORMAT_G722) bytes = sample_offset / 2; else bytes = sample_offset; if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in au filestream %p: %s\n", fs, strerror(errno)); return -1; } if (fseeko(fs->f, 0, SEEK_END) < 0) { ast_log(AST_LOG_WARNING, "Unable to seek to end of au filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((max = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine max position in au filestream %p: %s\n", fs, strerror(errno)); return -1; } if (whence == SEEK_SET) offset = bytes + min; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) offset = bytes + cur; else if (whence == SEEK_END) offset = max - bytes; if (whence != SEEK_FORCECUR) { offset = (offset > max) ? max : offset; } /* always protect the header space. */ offset = (offset < min) ? min : offset; return fseeko(fs->f, offset, SEEK_SET); } static int au_trunc(struct ast_filestream *fs) { int fd; off_t cur; if ((fd = fileno(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for au filestream %p: %s\n", fs, strerror(errno)); return -1; } if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in au filestream %p: %s\n", fs, strerror(errno)); return -1; } /* Truncate file to current length */ if (ftruncate(fd, cur)) { return -1; } return update_header(fs->f); } static off_t au_tell(struct ast_filestream *fs) { off_t offset = ftello(fs->f); return offset - AU_HEADER_SIZE; } static struct ast_format_def alaw_f = { .name = "alaw", .exts = "alaw|al|alw", .write = pcm_write, .seek = pcm_seek, .trunc = pcm_trunc, .tell = pcm_tell, .read = pcm_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, #ifdef REALTIME_WRITE .open = pcma_open, .rewrite = pcma_rewrite, .desc_size = sizeof(struct pcm_desc), #endif }; static struct ast_format_def pcm_f = { .name = "pcm", .exts = "pcm|ulaw|ul|mu|ulw", .write = pcm_write, .seek = pcm_seek, .trunc = pcm_trunc, .tell = pcm_tell, .read = pcm_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, }; static struct ast_format_def g722_f = { .name = "g722", .exts = "g722", .write = pcm_write, .seek = pcm_seek, .trunc = pcm_trunc, .tell = pcm_tell, .read = pcm_read, .buf_size = (BUF_SIZE * 2) + AST_FRIENDLY_OFFSET, }; static struct ast_format_def au_f = { .name = "au", .exts = "au", .open = au_open, .rewrite = au_rewrite, .write = pcm_write, .seek = au_seek, .trunc = au_trunc, .tell = au_tell, .read = pcm_read, .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, /* this many shorts */ }; static int load_module(void) { int i; /* XXX better init ? */ for (i = 0; i < ARRAY_LEN(ulaw_silence); i++) ulaw_silence[i] = AST_LIN2MU(0); for (i = 0; i < ARRAY_LEN(alaw_silence); i++) alaw_silence[i] = AST_LIN2A(0); ast_format_set(&pcm_f.format, AST_FORMAT_ULAW, 0); ast_format_set(&alaw_f.format, AST_FORMAT_ALAW, 0); ast_format_set(&au_f.format, AST_FORMAT_ULAW, 0); ast_format_set(&g722_f.format, AST_FORMAT_G722, 0); if ( ast_format_def_register(&pcm_f) || ast_format_def_register(&alaw_f) || ast_format_def_register(&au_f) || ast_format_def_register(&g722_f) ) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { return ast_format_def_unregister(pcm_f.name) || ast_format_def_unregister(alaw_f.name) || ast_format_def_unregister(au_f.name) || ast_format_def_unregister(g722_f.name); } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Raw/Sun uLaw/ALaw 8KHz (PCM,PCMA,AU), G.722 16Khz", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND ); asterisk-11.7.0/.version0000644000175000007640000000000712254067533015037 0ustar sharkyjerryweb11.7.0 asterisk-11.7.0/default.exports0000644000175000007640000000017612205345117016423 0ustar sharkyjerryweb{ global: /* See main/asterisk.exports.in for an explanation why this is * needed. */ _IO_stdin_used; local: *; }; asterisk-11.7.0/README-addons.txt0000644000175000007640000000306111222440006016300 0ustar sharkyjerryweb=============================================================================== === 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. =============================================================================== =============================================================================== asterisk-11.7.0/Makefile.moddir_rules0000644000175000007640000001343211711604714017501 0ustar sharkyjerryweb# # Asterisk -- A telephony toolkit for Linux. # # Makefile rules for subdirectories containing modules # # Copyright (C) 2006, Digium, Inc. # # Kevin P. Fleming # # This program is free software, distributed under the terms of # the GNU General Public License # # Makefile rules for building modules. # In most cases, we set target-specific variables for certain targets # (remember that they apply recursively to prerequisites). # Also note that we can only set one variable per rule, so we have to # repeat the left hand side to set multiple variables. ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) _ASTCFLAGS+=${GC_CFLAGS} endif ifneq ($(findstring STATIC_BUILD,$(MENUSELECT_CFLAGS)),) STATIC_BUILD=-static endif include $(ASTTOPDIR)/Makefile.rules # If MODULE_PREFIX is defined, use it to run the standard functions to set # C_MODS, CC_MODS, LOADABLE_MODS and EMBEDDED_MODS. # Each word of MODULE_PREFIX is a prefix for filenames that we consider # valid C or CC modules (eg. app, func ...). Note that the underscore # is added here, and does not need to be in MODULE_PREFIX # # Use MODULE_EXCLUDE to specify additional modules to exclude. ifneq ($(MODULE_PREFIX),) ALL_C_MODS:= ALL_CC_MODS:= ALL_C_MODS+=$(foreach p,$(MODULE_PREFIX),$(patsubst %.c,%,$(wildcard $(p)_*.c))) ALL_CC_MODS+=$(foreach p,$(MODULE_PREFIX),$(patsubst %.cc,%,$(wildcard $(p)_*.cc))) endif C_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_C_MODS)) CC_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_CC_MODS)) ifneq ($(findstring EMBED_$(MENUSELECT_CATEGORY),$(MENUSELECT_EMBED)),) EMBEDDED_MODS:=$(C_MODS) $(CC_MODS) else LOADABLE_MODS:=$(C_MODS) $(CC_MODS) endif # Both C++ and C++ sources need their module name in AST_MODULE # We also pass whatever _INCLUDE list is generated by menuselect # (they are stored in file 'makeopts'). This is also necessary # for components used to build modules, which can't be determined # by the rules in this file, so the MOD_ASTCFLAGS definition # is used to collect the required flags for a module... which can # then be used any place they are required. MOD_ASTCFLAGS=-DAST_MODULE=\"$(1)\" $(MENUSELECT_OPTS_$(1):%=-D%) $(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$(value $(dep)_INCLUDE)) $(addsuffix .oo,$(CC_MODS)) $(addsuffix .o,$(C_MODS)): \ _ASTCFLAGS+=$(call MOD_ASTCFLAGS,$*) ifeq ($(findstring $(OSARCH), mingw32 cygwin ),) # don't define -fPIC on mingw32 and cygwin, it is the default $(LOADABLE_MODS:%=%.so): _ASTCFLAGS+=-fPIC endif # For loadable modules, pass _LIB and _LDFLAGS from menuselect. $(LOADABLE_MODS:%=%.so): LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LIB)) $(LOADABLE_MODS:%=%.so): _ASTLDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$*),$(value $(dep)_LDFLAGS)) $(EMBEDDED_MODS:%=%.o): _ASTCFLAGS+=-DEMBEDDED_MODULE=$* $(addsuffix .so,$(filter $(LOADABLE_MODS),$(C_MODS))): %.so: %.o $(addsuffix .so,$(filter $(LOADABLE_MODS),$(CC_MODS))): %.so: %.oo modules.link: $(addsuffix .eo,$(filter $(EMBEDDED_MODS),$(C_MODS))) .PHONY: clean uninstall _all moduleinfo makeopts ifneq ($(LOADABLE_MODS),) _all: $(LOADABLE_MODS:%=%.so) ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) # linker options and extra libraries for cygwin SOLINK=-Wl,--out-implib=lib$@.a -shared LIBS+=-L$(ASTTOPDIR)/main -lasterisk -L$(ASTTOPDIR)/res $($@_LIBS) # additional libraries in res/ endif endif ifneq ($(EMBEDDED_MODS),) _all: modules.link __embed_ldscript: @echo "../$(SUBDIR)/modules.link" __embed_ldflags: @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))" @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LDFLAGS))" __embed_libs: @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(C_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))" @echo "$(foreach mod,$(filter $(EMBEDDED_MODS),$(CC_MODS)),$(foreach dep,$(MENUSELECT_DEPENDS_$(mod)),$(dep)_LIB))" else __embed_ldscript: __embed_ldflags: __embed_libs: endif modules.link: @rm -f $@ @for file in $(patsubst %,$(SUBDIR)/%,$(filter %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done @for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.eo,$^)); do echo "INPUT (../$${file})" >> $@; done clean:: rm -f *.so *.o *.oo *.eo *.i *.ii rm -f .*.d rm -f *.s *.i rm -f modules.link install:: all @echo "Installing modules from `basename $(CURDIR)`..." @for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x "$(DESTDIR)$(ASTMODDIR)" ; done uninstall:: dist-clean:: rm -f .*.moduleinfo .moduleinfo rm -f .*.makeopts .makeopts rm -f *.exports .%.moduleinfo: %.c @echo "" > $@ $(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@ echo "" >> $@ .%.moduleinfo: %.cc @echo "" > $@ $(AWK) -f $(ASTTOPDIR)/build_tools/get_moduleinfo $< >> $@ echo "" >> $@ .moduleinfo:: $(addsuffix .moduleinfo,$(addprefix .,$(sort $(ALL_C_MODS) $(ALL_CC_MODS)))) @echo "" > $@ @cat $^ >> $@ @echo "" >> $@ moduleinfo: .moduleinfo @cat $< .%.makeopts: %.c @$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@ .%.makeopts: %.cc @$(AWK) -f $(ASTTOPDIR)/build_tools/get_makeopts $< > $@ .makeopts:: $(addsuffix .makeopts,$(addprefix .,$(ALL_C_MODS) $(ALL_CC_MODS))) @cat $^ > $@ makeopts: .makeopts @cat $< ifneq ($(wildcard .*.d),) include .*.d endif asterisk-11.7.0/BSDmakefile0000644000175000007640000000044612133015136015375 0ustar sharkyjerryweb# This is a convenience script for systems on which BSD make is the default, # such that typing 'make' will do what people expect, instead of producing an # error (due to incompatibilities between BSD make and GNU make). .include "makeopts" all:: $(MAKE) $(.TARGETS):: $(MAKE) $(.TARGETS) asterisk-11.7.0/addons/0000755000175000007640000000000012254071123014612 5ustar sharkyjerrywebasterisk-11.7.0/addons/cdr_mysql.c0000644000175000007640000005266312061235223016766 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * James Sharp * * Modified August 2003 * Tilghman Lesher * * Modified August 6, 2005 * Joseph Benden * 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 * 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 mysqlclient no deprecated cdr_adaptive_odbc ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 377505 $") #include #include #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, *cdrzone = 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, ast_str_strlen(cdrzone) ? ast_str_buffer(cdrzone) : 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, ","); } if (!strcasecmp(cdrname, "billsec") && (strstr(entry->type, "float") || strstr(entry->type, "double") || strstr(entry->type, "decimal") || strstr(entry->type, "numeric") || strstr(entry->type, "real"))) { if (!ast_tvzero(cdr->answer)) { snprintf(workspace, sizeof(workspace), "%lf", (double) (ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0)); } else { ast_copy_string(workspace, "0", sizeof(workspace)); } if (!ast_strlen_zero(workspace)) { value = workspace; } } if (!strcasecmp(cdrname, "duration") && (strstr(entry->type, "float") || strstr(entry->type, "double") || strstr(entry->type, "decimal") || strstr(entry->type, "numeric") || strstr(entry->type, "real"))) { snprintf(workspace, sizeof(workspace), "%lf", (double) (ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0)); if (!ast_strlen_zero(workspace)) { value = workspace; } } 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; } tmp = ast_variable_retrieve(cfg, category, variable); ast_str_set(field, 0, "%s", tmp ? tmp : def); us->str = *field; AST_LIST_LOCK(&unload_strings); AST_LIST_INSERT_HEAD(&unload_strings, us, entry); AST_LIST_UNLOCK(&unload_strings); 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, "%30d", field) < 1) *field = def; return 0; } static int my_load_module(int reload) { int res; struct ast_config *cfg; struct ast_variable *var; /* CONFIG_STATUS_FILEUNCHANGED is impossible when config_flags is always 0, * and it has to be zero, so a reload can be sent to tell the driver to * rescan the table layout. */ struct ast_flags config_flags = { 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 /* Cannot use a conditionally different flag, because the table layout may * have changed, which is not detectable by config file change detection, * but should still cause the configuration to be re-parsed. */ cfg = ast_config_load(config, config_flags); if (cfg == CONFIG_STATUS_FILEMISSING) { 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_FILEINVALID) { ast_log(LOG_ERROR, "Unable to load configuration file '%s'\n", config); return AST_MODULE_LOAD_DECLINE; } 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); } ast_config_destroy(cfg); 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"); res |= my_load_config_string(cfg, "global", "cdrzone", &cdrzone, ""); if (ast_str_strlen(cdrzone) == 0) { for (; var; var = var->next) { if (!strcasecmp(var->name, "usegmtime") && ast_true(var->value)) { ast_str_set(&cdrzone, 0, "UTC"); } } } if (ast_true(ast_str_buffer(compat))) { calldate_compat = 1; } else { calldate_compat = 0; } if (res < 0) { if (reload) { AST_RWLIST_UNLOCK(&columns); } ast_config_destroy(cfg); 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"); ast_debug(1, "Dates and times are localized to %s\n", S_OR(ast_str_buffer(cdrzone), "local timezone")); 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_FAILURE; } 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_FAILURE; } 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, ); asterisk-11.7.0/addons/chan_mobile.c0000644000175000007640000035146512075661105017242 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Bluetooth Mobile Device channel driver * * \author Dave Bowerman * * \ingroup channel_drivers */ /*** MODULEINFO bluetooth no extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 379343 $") #include #include #include #include #include #include #include #include #include #include #include "asterisk/compat.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/options.h" #include "asterisk/utils.h" #include "asterisk/linkedlists.h" #include "asterisk/cli.h" #include "asterisk/devicestate.h" #include "asterisk/causes.h" #include "asterisk/dsp.h" #include "asterisk/app.h" #include "asterisk/manager.h" #include "asterisk/io.h" #define MBL_CONFIG "chan_mobile.conf" #define MBL_CONFIG_OLD "mobile.conf" #define DEVICE_FRAME_SIZE 48 #define DEVICE_FRAME_FORMAT AST_FORMAT_SLINEAR #define CHANNEL_FRAME_SIZE 320 static struct ast_format prefformat; static int discovery_interval = 60; /* The device discovery interval, default 60 seconds. */ static pthread_t discovery_thread = AST_PTHREADT_NULL; /* The discovery thread */ static sdp_session_t *sdp_session; AST_MUTEX_DEFINE_STATIC(unload_mutex); static int unloading_flag = 0; static inline int check_unloading(void); static inline void set_unloading(void); enum mbl_type { MBL_TYPE_PHONE, MBL_TYPE_HEADSET }; struct adapter_pvt { int dev_id; /* device id */ int hci_socket; /* device descriptor */ char id[31]; /* the 'name' from mobile.conf */ bdaddr_t addr; /* adddress of adapter */ unsigned int inuse:1; /* are we in use ? */ unsigned int alignment_detection:1; /* do alignment detection on this adpater? */ struct io_context *io; /*!< io context for audio connections */ struct io_context *accept_io; /*!< io context for sco listener */ int *sco_id; /*!< the io context id of the sco listener socket */ int sco_socket; /*!< sco listener socket */ pthread_t sco_listener_thread; /*!< sco listener thread */ AST_LIST_ENTRY(adapter_pvt) entry; }; static AST_RWLIST_HEAD_STATIC(adapters, adapter_pvt); struct msg_queue_entry; struct hfp_pvt; struct mbl_pvt { struct ast_channel *owner; /* Channel we belong to, possibly NULL */ struct ast_frame fr; /* "null" frame */ ast_mutex_t lock; /*!< pvt lock */ /*! queue for messages we are expecting */ AST_LIST_HEAD_NOLOCK(msg_queue, msg_queue_entry) msg_queue; enum mbl_type type; /* Phone or Headset */ char id[31]; /* The id from mobile.conf */ int group; /* group number for group dialling */ bdaddr_t addr; /* address of device */ struct adapter_pvt *adapter; /* the adapter we use */ char context[AST_MAX_CONTEXT]; /* the context for incoming calls */ struct hfp_pvt *hfp; /*!< hfp pvt */ int rfcomm_port; /* rfcomm port number */ int rfcomm_socket; /* rfcomm socket descriptor */ char rfcomm_buf[256]; char io_buf[CHANNEL_FRAME_SIZE + AST_FRIENDLY_OFFSET]; struct ast_smoother *smoother; /* our smoother, for making 48 byte frames */ int sco_socket; /* sco socket descriptor */ pthread_t monitor_thread; /* monitor thread handle */ int timeout; /*!< used to set the timeout for rfcomm data (may be used in the future) */ unsigned int no_callsetup:1; unsigned int has_sms:1; unsigned int do_alignment_detection:1; unsigned int alignment_detection_triggered:1; unsigned int blackberry:1; short alignment_samples[4]; int alignment_count; int ring_sched_id; struct ast_dsp *dsp; struct ast_sched_context *sched; /* flags */ unsigned int outgoing:1; /*!< outgoing call */ unsigned int incoming:1; /*!< incoming call */ unsigned int outgoing_sms:1; /*!< outgoing sms */ unsigned int incoming_sms:1; /*!< outgoing sms */ unsigned int needcallerid:1; /*!< we need callerid */ unsigned int needchup:1; /*!< we need to send a chup */ unsigned int needring:1; /*!< we need to send a RING */ unsigned int answered:1; /*!< we sent/received an answer */ unsigned int connected:1; /*!< do we have an rfcomm connection to a device */ AST_LIST_ENTRY(mbl_pvt) entry; }; static AST_RWLIST_HEAD_STATIC(devices, mbl_pvt); static int handle_response_ok(struct mbl_pvt *pvt, char *buf); static int handle_response_error(struct mbl_pvt *pvt, char *buf); static int handle_response_ciev(struct mbl_pvt *pvt, char *buf); static int handle_response_clip(struct mbl_pvt *pvt, char *buf); static int handle_response_ring(struct mbl_pvt *pvt, char *buf); static int handle_response_cmti(struct mbl_pvt *pvt, char *buf); static int handle_response_cmgr(struct mbl_pvt *pvt, char *buf); static int handle_response_cusd(struct mbl_pvt *pvt, char *buf); static int handle_sms_prompt(struct mbl_pvt *pvt, char *buf); /* CLI stuff */ static char *handle_cli_mobile_show_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *handle_cli_mobile_search(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *handle_cli_mobile_rfcomm(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *handle_cli_mobile_cusd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static struct ast_cli_entry mbl_cli[] = { AST_CLI_DEFINE(handle_cli_mobile_show_devices, "Show Bluetooth Cell / Mobile devices"), AST_CLI_DEFINE(handle_cli_mobile_search, "Search for Bluetooth Cell / Mobile devices"), AST_CLI_DEFINE(handle_cli_mobile_rfcomm, "Send commands to the rfcomm port for debugging"), AST_CLI_DEFINE(handle_cli_mobile_cusd, "Send CUSD commands to the mobile"), }; /* App stuff */ static char *app_mblstatus = "MobileStatus"; static char *mblstatus_synopsis = "MobileStatus(Device,Variable)"; static char *mblstatus_desc = "MobileStatus(Device,Variable)\n" " Device - Id of mobile device from mobile.conf\n" " Variable - Variable to store status in will be 1-3.\n" " In order, Disconnected, Connected & Free, Connected & Busy.\n"; static char *app_mblsendsms = "MobileSendSMS"; static char *mblsendsms_synopsis = "MobileSendSMS(Device,Dest,Message)"; static char *mblsendsms_desc = "MobileSendSms(Device,Dest,Message)\n" " Device - Id of device from mobile.conf\n" " Dest - destination\n" " Message - text of the message\n"; static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num, const struct ast_channel *requestor); static struct ast_channel *mbl_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause); static int mbl_call(struct ast_channel *ast, const char *dest, int timeout); static int mbl_hangup(struct ast_channel *ast); static int mbl_answer(struct ast_channel *ast); static int mbl_digit_end(struct ast_channel *ast, char digit, unsigned int duration); static struct ast_frame *mbl_read(struct ast_channel *ast); static int mbl_write(struct ast_channel *ast, struct ast_frame *frame); static int mbl_fixup(struct ast_channel *oldchan, struct ast_channel *newchan); static int mbl_devicestate(const char *data); static void do_alignment_detection(struct mbl_pvt *pvt, char *buf, int buflen); static int mbl_queue_control(struct mbl_pvt *pvt, enum ast_control_frame_type control); static int mbl_queue_hangup(struct mbl_pvt *pvt); static int mbl_ast_hangup(struct mbl_pvt *pvt); static int mbl_has_service(struct mbl_pvt *pvt); static int rfcomm_connect(bdaddr_t src, bdaddr_t dst, int remote_channel); static int rfcomm_write(int rsock, char *buf); static int rfcomm_write_full(int rsock, char *buf, size_t count); static int rfcomm_wait(int rsock, int *ms); static ssize_t rfcomm_read(int rsock, char *buf, size_t count); static int sco_connect(bdaddr_t src, bdaddr_t dst); static int sco_write(int s, char *buf, int len); static int sco_accept(int *id, int fd, short events, void *data); static int sco_bind(struct adapter_pvt *adapter); static void *do_sco_listen(void *data); static int sdp_search(char *addr, int profile); static int headset_send_ring(const void *data); /* * bluetooth handsfree profile helpers */ #define HFP_HF_ECNR (1 << 0) #define HFP_HF_CW (1 << 1) #define HFP_HF_CID (1 << 2) #define HFP_HF_VOICE (1 << 3) #define HFP_HF_VOLUME (1 << 4) #define HFP_HF_STATUS (1 << 5) #define HFP_HF_CONTROL (1 << 6) #define HFP_AG_CW (1 << 0) #define HFP_AG_ECNR (1 << 1) #define HFP_AG_VOICE (1 << 2) #define HFP_AG_RING (1 << 3) #define HFP_AG_TAG (1 << 4) #define HFP_AG_REJECT (1 << 5) #define HFP_AG_STATUS (1 << 6) #define HFP_AG_CONTROL (1 << 7) #define HFP_AG_ERRORS (1 << 8) #define HFP_CIND_UNKNOWN -1 #define HFP_CIND_NONE 0 #define HFP_CIND_SERVICE 1 #define HFP_CIND_CALL 2 #define HFP_CIND_CALLSETUP 3 #define HFP_CIND_CALLHELD 4 #define HFP_CIND_SIGNAL 5 #define HFP_CIND_ROAM 6 #define HFP_CIND_BATTCHG 7 /* call indicator values */ #define HFP_CIND_CALL_NONE 0 #define HFP_CIND_CALL_ACTIVE 1 /* callsetup indicator values */ #define HFP_CIND_CALLSETUP_NONE 0 #define HFP_CIND_CALLSETUP_INCOMING 1 #define HFP_CIND_CALLSETUP_OUTGOING 2 #define HFP_CIND_CALLSETUP_ALERTING 3 /* service indicator values */ #define HFP_CIND_SERVICE_NONE 0 #define HFP_CIND_SERVICE_AVAILABLE 1 /*! * \brief This struct holds HFP features that we support. */ struct hfp_hf { int ecnr:1; /*!< echo-cancel/noise reduction */ int cw:1; /*!< call waiting and three way calling */ int cid:1; /*!< cli presentation (callier id) */ int voice:1; /*!< voice recognition activation */ int volume:1; /*!< remote volume control */ int status:1; /*!< enhanced call status */ int control:1; /*!< enhanced call control*/ }; /*! * \brief This struct holds HFP features the AG supports. */ struct hfp_ag { int cw:1; /*!< three way calling */ int ecnr:1; /*!< echo-cancel/noise reduction */ int voice:1; /*!< voice recognition */ int ring:1; /*!< in band ring tone capability */ int tag:1; /*!< attach a number to a voice tag */ int reject:1; /*!< ability to reject a call */ int status:1; /*!< enhanced call status */ int control:1; /*!< enhanced call control*/ int errors:1; /*!< extended error result codes*/ }; /*! * \brief This struct holds mappings for indications. */ struct hfp_cind { int service; /*!< whether we have service or not */ int call; /*!< call state */ int callsetup; /*!< bluetooth call setup indications */ int callheld; /*!< bluetooth call hold indications */ int signal; /*!< signal strength */ int roam; /*!< roaming indicator */ int battchg; /*!< battery charge indicator */ }; /*! * \brief This struct holds state information about the current hfp connection. */ struct hfp_pvt { struct mbl_pvt *owner; /*!< the mbl_pvt struct that owns this struct */ int initialized:1; /*!< whether a service level connection exists or not */ int nocallsetup:1; /*!< whether we detected a callsetup indicator */ struct hfp_ag brsf; /*!< the supported feature set of the AG */ int cind_index[16]; /*!< the cind/ciev index to name mapping for this AG */ int cind_state[16]; /*!< the cind/ciev state for this AG */ struct hfp_cind cind_map; /*!< the cind name to index mapping for this AG */ int rsock; /*!< our rfcomm socket */ int rport; /*!< our rfcomm port */ }; /* Our supported features. * we only support caller id */ static struct hfp_hf hfp_our_brsf = { .ecnr = 0, .cw = 0, .cid = 1, .voice = 0, .volume = 0, .status = 0, .control = 0, }; static int hfp_parse_ciev(struct hfp_pvt *hfp, char *buf, int *value); static char *hfp_parse_clip(struct hfp_pvt *hfp, char *buf); static int hfp_parse_cmti(struct hfp_pvt *hfp, char *buf); static int hfp_parse_cmgr(struct hfp_pvt *hfp, char *buf, char **from_number, char **text); static int hfp_parse_brsf(struct hfp_pvt *hfp, const char *buf); static int hfp_parse_cind(struct hfp_pvt *hfp, char *buf); static int hfp_parse_cind_test(struct hfp_pvt *hfp, char *buf); static char *hfp_parse_cusd(struct hfp_pvt *hfp, char *buf); static int hfp_brsf2int(struct hfp_hf *hf); static struct hfp_ag *hfp_int2brsf(int brsf, struct hfp_ag *ag); static int hfp_send_brsf(struct hfp_pvt *hfp, struct hfp_hf *brsf); static int hfp_send_cind(struct hfp_pvt *hfp); static int hfp_send_cind_test(struct hfp_pvt *hfp); static int hfp_send_cmer(struct hfp_pvt *hfp, int status); static int hfp_send_clip(struct hfp_pvt *hfp, int status); static int hfp_send_vgs(struct hfp_pvt *hfp, int value); #if 0 static int hfp_send_vgm(struct hfp_pvt *hfp, int value); #endif static int hfp_send_dtmf(struct hfp_pvt *hfp, char digit); static int hfp_send_cmgf(struct hfp_pvt *hfp, int mode); static int hfp_send_cnmi(struct hfp_pvt *hfp); static int hfp_send_cmgr(struct hfp_pvt *hfp, int index); static int hfp_send_cmgs(struct hfp_pvt *hfp, const char *number); static int hfp_send_sms_text(struct hfp_pvt *hfp, const char *message); static int hfp_send_chup(struct hfp_pvt *hfp); static int hfp_send_atd(struct hfp_pvt *hfp, const char *number); static int hfp_send_ata(struct hfp_pvt *hfp); static int hfp_send_cusd(struct hfp_pvt *hfp, const char *code); /* * bluetooth headset profile helpers */ static int hsp_send_ok(int rsock); static int hsp_send_error(int rsock); static int hsp_send_vgs(int rsock, int gain); static int hsp_send_vgm(int rsock, int gain); static int hsp_send_ring(int rsock); /* * Hayes AT command helpers */ typedef enum { /* errors */ AT_PARSE_ERROR = -2, AT_READ_ERROR = -1, AT_UNKNOWN = 0, /* at responses */ AT_OK, AT_ERROR, AT_RING, AT_BRSF, AT_CIND, AT_CIEV, AT_CLIP, AT_CMTI, AT_CMGR, AT_SMS_PROMPT, AT_CMS_ERROR, /* at commands */ AT_A, AT_D, AT_CHUP, AT_CKPD, AT_CMGS, AT_VGM, AT_VGS, AT_VTS, AT_CMGF, AT_CNMI, AT_CMER, AT_CIND_TEST, AT_CUSD, } at_message_t; static int at_match_prefix(char *buf, char *prefix); static at_message_t at_read_full(int rsock, char *buf, size_t count); static inline const char *at_msg2str(at_message_t msg); struct msg_queue_entry { at_message_t expected; at_message_t response_to; void *data; AST_LIST_ENTRY(msg_queue_entry) entry; }; static int msg_queue_push(struct mbl_pvt *pvt, at_message_t expect, at_message_t response_to); static int msg_queue_push_data(struct mbl_pvt *pvt, at_message_t expect, at_message_t response_to, void *data); static struct msg_queue_entry *msg_queue_pop(struct mbl_pvt *pvt); static void msg_queue_free_and_pop(struct mbl_pvt *pvt); static void msg_queue_flush(struct mbl_pvt *pvt); static struct msg_queue_entry *msg_queue_head(struct mbl_pvt *pvt); /* * channel stuff */ static struct ast_channel_tech mbl_tech = { .type = "Mobile", .description = "Bluetooth Mobile Device Channel Driver", .requester = mbl_request, .call = mbl_call, .hangup = mbl_hangup, .answer = mbl_answer, .send_digit_end = mbl_digit_end, .read = mbl_read, .write = mbl_write, .fixup = mbl_fixup, .devicestate = mbl_devicestate }; /* CLI Commands implementation */ static char *handle_cli_mobile_show_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct mbl_pvt *pvt; char bdaddr[18]; char group[6]; #define FORMAT1 "%-15.15s %-17.17s %-5.5s %-15.15s %-9.9s %-10.10s %-3.3s\n" switch (cmd) { case CLI_INIT: e->command = "mobile show devices"; e->usage = "Usage: mobile show devices\n" " Shows the state of Bluetooth Cell / Mobile devices.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 3) return CLI_SHOWUSAGE; ast_cli(a->fd, FORMAT1, "ID", "Address", "Group", "Adapter", "Connected", "State", "SMS"); AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { ast_mutex_lock(&pvt->lock); ba2str(&pvt->addr, bdaddr); snprintf(group, sizeof(group), "%d", pvt->group); ast_cli(a->fd, FORMAT1, pvt->id, bdaddr, group, pvt->adapter->id, pvt->connected ? "Yes" : "No", (!pvt->connected) ? "None" : (pvt->owner) ? "Busy" : (pvt->outgoing_sms || pvt->incoming_sms) ? "SMS" : (mbl_has_service(pvt)) ? "Free" : "No Service", (pvt->has_sms) ? "Yes" : "No" ); ast_mutex_unlock(&pvt->lock); } AST_RWLIST_UNLOCK(&devices); #undef FORMAT1 return CLI_SUCCESS; } static char *handle_cli_mobile_search(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct adapter_pvt *adapter; inquiry_info *ii = NULL; int max_rsp, num_rsp; int len, flags; int i, phport, hsport; char addr[19] = {0}; char name[31] = {0}; #define FORMAT1 "%-17.17s %-30.30s %-6.6s %-7.7s %-4.4s\n" #define FORMAT2 "%-17.17s %-30.30s %-6.6s %-7.7s %d\n" switch (cmd) { case CLI_INIT: e->command = "mobile search"; e->usage = "Usage: mobile search\n" " Searches for Bluetooth Cell / Mobile devices in range.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 2) return CLI_SHOWUSAGE; /* find a free adapter */ AST_RWLIST_RDLOCK(&adapters); AST_RWLIST_TRAVERSE(&adapters, adapter, entry) { if (!adapter->inuse) break; } AST_RWLIST_UNLOCK(&adapters); if (!adapter) { ast_cli(a->fd, "All Bluetooth adapters are in use at this time.\n"); return CLI_SUCCESS; } len = 8; max_rsp = 255; flags = IREQ_CACHE_FLUSH; ii = ast_alloca(max_rsp * sizeof(inquiry_info)); num_rsp = hci_inquiry(adapter->dev_id, len, max_rsp, NULL, &ii, flags); if (num_rsp > 0) { ast_cli(a->fd, FORMAT1, "Address", "Name", "Usable", "Type", "Port"); for (i = 0; i < num_rsp; i++) { ba2str(&(ii + i)->bdaddr, addr); name[0] = 0x00; if (hci_read_remote_name(adapter->hci_socket, &(ii + i)->bdaddr, sizeof(name) - 1, name, 0) < 0) strcpy(name, "[unknown]"); phport = sdp_search(addr, HANDSFREE_AGW_PROFILE_ID); if (!phport) hsport = sdp_search(addr, HEADSET_PROFILE_ID); else hsport = 0; ast_cli(a->fd, FORMAT2, addr, name, (phport > 0 || hsport > 0) ? "Yes" : "No", (phport > 0) ? "Phone" : "Headset", (phport > 0) ? phport : hsport); } } else ast_cli(a->fd, "No Bluetooth Cell / Mobile devices found.\n"); #undef FORMAT1 #undef FORMAT2 return CLI_SUCCESS; } static char *handle_cli_mobile_rfcomm(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { char buf[128]; struct mbl_pvt *pvt = NULL; switch (cmd) { case CLI_INIT: e->command = "mobile rfcomm"; e->usage = "Usage: mobile rfcomm \n" " Send to the rfcomm port on the device\n" " with the specified .\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 4) return CLI_SHOWUSAGE; AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { if (!strcmp(pvt->id, a->argv[2])) break; } AST_RWLIST_UNLOCK(&devices); if (!pvt) { ast_cli(a->fd, "Device %s not found.\n", a->argv[2]); goto e_return; } ast_mutex_lock(&pvt->lock); if (!pvt->connected) { ast_cli(a->fd, "Device %s not connected.\n", a->argv[2]); goto e_unlock_pvt; } snprintf(buf, sizeof(buf), "%s\r", a->argv[3]); rfcomm_write(pvt->rfcomm_socket, buf); msg_queue_push(pvt, AT_OK, AT_UNKNOWN); e_unlock_pvt: ast_mutex_unlock(&pvt->lock); e_return: return CLI_SUCCESS; } static char *handle_cli_mobile_cusd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { char buf[128]; struct mbl_pvt *pvt = NULL; switch (cmd) { case CLI_INIT: e->command = "mobile cusd"; e->usage = "Usage: mobile cusd \n" " Send cusd to the rfcomm port on the device\n" " with the specified .\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 4) return CLI_SHOWUSAGE; AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { if (!strcmp(pvt->id, a->argv[2])) break; } AST_RWLIST_UNLOCK(&devices); if (!pvt) { ast_cli(a->fd, "Device %s not found.\n", a->argv[2]); goto e_return; } ast_mutex_lock(&pvt->lock); if (!pvt->connected) { ast_cli(a->fd, "Device %s not connected.\n", a->argv[2]); goto e_unlock_pvt; } snprintf(buf, sizeof(buf), "%s", a->argv[3]); if (hfp_send_cusd(pvt->hfp, buf) || msg_queue_push(pvt, AT_OK, AT_CUSD)) { ast_cli(a->fd, "[%s] error sending CUSD\n", pvt->id); goto e_unlock_pvt; } e_unlock_pvt: ast_mutex_unlock(&pvt->lock); e_return: return CLI_SUCCESS; } /* Dialplan applications implementation */ static int mbl_status_exec(struct ast_channel *ast, const char *data) { struct mbl_pvt *pvt; char *parse; int stat; char status[2]; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(device); AST_APP_ARG(variable); ); if (ast_strlen_zero(data)) return -1; parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.device) || ast_strlen_zero(args.variable)) return -1; stat = 1; AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { if (!strcmp(pvt->id, args.device)) break; } AST_RWLIST_UNLOCK(&devices); if (pvt) { ast_mutex_lock(&pvt->lock); if (pvt->connected) stat = 2; if (pvt->owner) stat = 3; ast_mutex_unlock(&pvt->lock); } snprintf(status, sizeof(status), "%d", stat); pbx_builtin_setvar_helper(ast, args.variable, status); return 0; } static int mbl_sendsms_exec(struct ast_channel *ast, const char *data) { struct mbl_pvt *pvt; char *parse, *message; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(device); AST_APP_ARG(dest); AST_APP_ARG(message); ); if (ast_strlen_zero(data)) return -1; parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.device)) { ast_log(LOG_ERROR,"NULL device for message -- SMS will not be sent.\n"); return -1; } if (ast_strlen_zero(args.dest)) { ast_log(LOG_ERROR,"NULL destination for message -- SMS will not be sent.\n"); return -1; } if (ast_strlen_zero(args.message)) { ast_log(LOG_ERROR,"NULL Message to be sent -- SMS will not be sent.\n"); return -1; } AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { if (!strcmp(pvt->id, args.device)) break; } AST_RWLIST_UNLOCK(&devices); if (!pvt) { ast_log(LOG_ERROR,"Bluetooth device %s wasn't found in the list -- SMS will not be sent.\n", args.device); goto e_return; } ast_mutex_lock(&pvt->lock); if (!pvt->connected) { ast_log(LOG_ERROR,"Bluetooth device %s wasn't connected -- SMS will not be sent.\n", args.device); goto e_unlock_pvt; } if (!pvt->has_sms) { ast_log(LOG_ERROR,"Bluetooth device %s doesn't handle SMS -- SMS will not be sent.\n", args.device); goto e_unlock_pvt; } message = ast_strdup(args.message); if (hfp_send_cmgs(pvt->hfp, args.dest) || msg_queue_push_data(pvt, AT_SMS_PROMPT, AT_CMGS, message)) { ast_log(LOG_ERROR, "[%s] problem sending SMS message\n", pvt->id); goto e_free_message; } ast_mutex_unlock(&pvt->lock); return 0; e_free_message: ast_free(message); e_unlock_pvt: ast_mutex_unlock(&pvt->lock); e_return: return -1; } /* Channel Driver callbacks */ static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num, const struct ast_channel *requestor) { struct ast_channel *chn; pvt->answered = 0; pvt->alignment_count = 0; pvt->alignment_detection_triggered = 0; if (pvt->adapter->alignment_detection) pvt->do_alignment_detection = 1; else pvt->do_alignment_detection = 0; ast_smoother_reset(pvt->smoother, DEVICE_FRAME_SIZE); ast_dsp_digitreset(pvt->dsp); chn = ast_channel_alloc(1, state, cid_num, pvt->id, 0, 0, pvt->context, requestor ? ast_channel_linkedid(requestor) : "", 0, "Mobile/%s-%04lx", pvt->id, ast_random() & 0xffff); if (!chn) { goto e_return; } ast_channel_tech_set(chn, &mbl_tech); ast_format_cap_add(ast_channel_nativeformats(chn), &prefformat); ast_format_copy(ast_channel_rawreadformat(chn), &prefformat); ast_format_copy(ast_channel_rawwriteformat(chn), &prefformat); ast_format_copy(ast_channel_writeformat(chn), &prefformat); ast_format_copy(ast_channel_readformat(chn), &prefformat); ast_channel_tech_pvt_set(chn, pvt); if (state == AST_STATE_RING) ast_channel_rings_set(chn, 1); ast_channel_language_set(chn, "en"); pvt->owner = chn; if (pvt->sco_socket != -1) { ast_channel_set_fd(chn, 0, pvt->sco_socket); } return chn; e_return: return NULL; } static struct ast_channel *mbl_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause) { struct ast_channel *chn = NULL; struct mbl_pvt *pvt; char *dest_dev = NULL; char *dest_num = NULL; int group = -1; if (!data) { ast_log(LOG_WARNING, "Channel requested with no data\n"); *cause = AST_CAUSE_INCOMPATIBLE_DESTINATION; return NULL; } if (!(ast_format_cap_iscompatible(cap, &prefformat))) { char tmp[256]; ast_log(LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap)); *cause = AST_CAUSE_FACILITY_NOT_IMPLEMENTED; return NULL; } dest_dev = ast_strdupa(data); dest_num = strchr(dest_dev, '/'); if (dest_num) *dest_num++ = 0x00; if (((dest_dev[0] == 'g') || (dest_dev[0] == 'G')) && ((dest_dev[1] >= '0') && (dest_dev[1] <= '9'))) { group = atoi(&dest_dev[1]); } /* Find requested device and make sure it's connected. */ AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { if (group > -1 && pvt->group == group && pvt->connected && !pvt->owner) { if (!mbl_has_service(pvt)) { continue; } break; } else if (!strcmp(pvt->id, dest_dev)) { break; } } AST_RWLIST_UNLOCK(&devices); if (!pvt || !pvt->connected || pvt->owner) { ast_log(LOG_WARNING, "Request to call on device %s which is not connected / already in use.\n", dest_dev); *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL; return NULL; } if ((pvt->type == MBL_TYPE_PHONE) && !dest_num) { ast_log(LOG_WARNING, "Can't determine destination number.\n"); *cause = AST_CAUSE_INCOMPATIBLE_DESTINATION; return NULL; } ast_mutex_lock(&pvt->lock); chn = mbl_new(AST_STATE_DOWN, pvt, NULL, requestor); ast_mutex_unlock(&pvt->lock); if (!chn) { ast_log(LOG_WARNING, "Unable to allocate channel structure.\n"); *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL; return NULL; } return chn; } static int mbl_call(struct ast_channel *ast, const char *dest, int timeout) { struct mbl_pvt *pvt; char *dest_dev; char *dest_num = NULL; dest_dev = ast_strdupa(dest); pvt = ast_channel_tech_pvt(ast); if (pvt->type == MBL_TYPE_PHONE) { dest_num = strchr(dest_dev, '/'); if (!dest_num) { ast_log(LOG_WARNING, "Cant determine destination number.\n"); return -1; } *dest_num++ = 0x00; } if ((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) { ast_log(LOG_WARNING, "mbl_call called on %s, neither down nor reserved\n", ast_channel_name(ast)); return -1; } ast_debug(1, "Calling %s on %s\n", dest, ast_channel_name(ast)); ast_mutex_lock(&pvt->lock); if (pvt->type == MBL_TYPE_PHONE) { if (hfp_send_atd(pvt->hfp, dest_num)) { ast_mutex_unlock(&pvt->lock); ast_log(LOG_ERROR, "error sending ATD command on %s\n", pvt->id); return -1; } pvt->needchup = 1; msg_queue_push(pvt, AT_OK, AT_D); } else { if (hsp_send_ring(pvt->rfcomm_socket)) { ast_log(LOG_ERROR, "[%s] error ringing device\n", pvt->id); ast_mutex_unlock(&pvt->lock); return -1; } if ((pvt->ring_sched_id = ast_sched_add(pvt->sched, 6000, headset_send_ring, pvt)) == -1) { ast_log(LOG_ERROR, "[%s] error ringing device\n", pvt->id); ast_mutex_unlock(&pvt->lock); return -1; } pvt->outgoing = 1; pvt->needring = 1; } ast_mutex_unlock(&pvt->lock); return 0; } static int mbl_hangup(struct ast_channel *ast) { struct mbl_pvt *pvt; if (!ast_channel_tech_pvt(ast)) { ast_log(LOG_WARNING, "Asked to hangup channel not connected\n"); return 0; } pvt = ast_channel_tech_pvt(ast); ast_debug(1, "[%s] hanging up device\n", pvt->id); ast_mutex_lock(&pvt->lock); ast_channel_set_fd(ast, 0, -1); close(pvt->sco_socket); pvt->sco_socket = -1; if (pvt->needchup) { hfp_send_chup(pvt->hfp); msg_queue_push(pvt, AT_OK, AT_CHUP); pvt->needchup = 0; } pvt->outgoing = 0; pvt->incoming = 0; pvt->needring = 0; pvt->owner = NULL; ast_channel_tech_pvt_set(ast, NULL); ast_mutex_unlock(&pvt->lock); ast_setstate(ast, AST_STATE_DOWN); return 0; } static int mbl_answer(struct ast_channel *ast) { struct mbl_pvt *pvt; pvt = ast_channel_tech_pvt(ast); if (pvt->type == MBL_TYPE_HEADSET) return 0; ast_mutex_lock(&pvt->lock); if (pvt->incoming) { hfp_send_ata(pvt->hfp); msg_queue_push(pvt, AT_OK, AT_A); pvt->answered = 1; } ast_mutex_unlock(&pvt->lock); return 0; } static int mbl_digit_end(struct ast_channel *ast, char digit, unsigned int duration) { struct mbl_pvt *pvt = ast_channel_tech_pvt(ast); if (pvt->type == MBL_TYPE_HEADSET) return 0; ast_mutex_lock(&pvt->lock); if (hfp_send_dtmf(pvt->hfp, digit)) { ast_mutex_unlock(&pvt->lock); ast_debug(1, "[%s] error sending digit %c\n", pvt->id, digit); return -1; } msg_queue_push(pvt, AT_OK, AT_VTS); ast_mutex_unlock(&pvt->lock); ast_debug(1, "[%s] dialed %c\n", pvt->id, digit); return 0; } static struct ast_frame *mbl_read(struct ast_channel *ast) { struct mbl_pvt *pvt = ast_channel_tech_pvt(ast); struct ast_frame *fr = &ast_null_frame; int r; ast_debug(3, "*** mbl_read()\n"); while (ast_mutex_trylock(&pvt->lock)) { CHANNEL_DEADLOCK_AVOIDANCE(ast); } if (!pvt->owner || pvt->sco_socket == -1) { goto e_return; } memset(&pvt->fr, 0x00, sizeof(struct ast_frame)); pvt->fr.frametype = AST_FRAME_VOICE; ast_format_set(&pvt->fr.subclass.format, DEVICE_FRAME_FORMAT, 0); pvt->fr.src = "Mobile"; pvt->fr.offset = AST_FRIENDLY_OFFSET; pvt->fr.mallocd = 0; pvt->fr.delivery.tv_sec = 0; pvt->fr.delivery.tv_usec = 0; pvt->fr.data.ptr = pvt->io_buf + AST_FRIENDLY_OFFSET; if ((r = read(pvt->sco_socket, pvt->fr.data.ptr, DEVICE_FRAME_SIZE)) == -1) { if (errno != EAGAIN && errno != EINTR) { ast_debug(1, "[%s] read error %d, going to wait for new connection\n", pvt->id, errno); close(pvt->sco_socket); pvt->sco_socket = -1; ast_channel_set_fd(ast, 0, -1); } goto e_return; } pvt->fr.datalen = r; pvt->fr.samples = r / 2; if (pvt->do_alignment_detection) do_alignment_detection(pvt, pvt->fr.data.ptr, r); fr = ast_dsp_process(ast, pvt->dsp, &pvt->fr); ast_mutex_unlock(&pvt->lock); return fr; e_return: ast_mutex_unlock(&pvt->lock); return fr; } static int mbl_write(struct ast_channel *ast, struct ast_frame *frame) { struct mbl_pvt *pvt = ast_channel_tech_pvt(ast); struct ast_frame *f; ast_debug(3, "*** mbl_write\n"); if (frame->frametype != AST_FRAME_VOICE) { return 0; } while (ast_mutex_trylock(&pvt->lock)) { CHANNEL_DEADLOCK_AVOIDANCE(ast); } ast_smoother_feed(pvt->smoother, frame); while ((f = ast_smoother_read(pvt->smoother))) { sco_write(pvt->sco_socket, f->data.ptr, f->datalen); } ast_mutex_unlock(&pvt->lock); return 0; } static int mbl_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) { struct mbl_pvt *pvt = ast_channel_tech_pvt(newchan); if (!pvt) { ast_debug(1, "fixup failed, no pvt on newchan\n"); return -1; } ast_mutex_lock(&pvt->lock); if (pvt->owner == oldchan) pvt->owner = newchan; ast_mutex_unlock(&pvt->lock); return 0; } static int mbl_devicestate(const char *data) { char *device; int res = AST_DEVICE_INVALID; struct mbl_pvt *pvt; device = ast_strdupa(S_OR(data, "")); ast_debug(1, "Checking device state for device %s\n", device); AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { if (!strcmp(pvt->id, device)) break; } AST_RWLIST_UNLOCK(&devices); if (!pvt) return res; ast_mutex_lock(&pvt->lock); if (pvt->connected) { if (pvt->owner) res = AST_DEVICE_INUSE; else res = AST_DEVICE_NOT_INUSE; if (!mbl_has_service(pvt)) res = AST_DEVICE_UNAVAILABLE; } ast_mutex_unlock(&pvt->lock); return res; } /* Callback helpers */ /* do_alignment_detection() This routine attempts to detect where we get misaligned sco audio data from the bluetooth adaptor. Its enabled by alignmentdetect=yes under the adapter entry in mobile.conf Some adapters suffer a problem where occasionally they will byte shift the audio stream one byte to the right. The result is static or white noise on the inbound (from the adapter) leg of the call. This is characterised by a sudden jump in magnitude of the value of the 16 bit samples. Here we look at the first 4 48 byte frames. We average the absolute values of each sample in the frame, then average the sum of the averages of frames 1, 2, and 3. Frame zero is usually zero. If the end result > 100, and it usually is if we have the problem, set a flag and compensate by shifting the bytes for each subsequent frame during the call. If the result is <= 100 then clear the flag so we don't come back in here... This seems to work OK.... */ static void do_alignment_detection(struct mbl_pvt *pvt, char *buf, int buflen) { int i; short a, *s; char *p; if (pvt->alignment_detection_triggered) { for (i=buflen, p=buf+buflen-1; i>0; i--, p--) *p = *(p-1); *(p+1) = 0; return; } if (pvt->alignment_count < 4) { s = (short *)buf; for (i=0, a=0; ialignment_samples[pvt->alignment_count++] = a; return; } ast_debug(1, "Alignment Detection result is [%-d %-d %-d %-d]\n", pvt->alignment_samples[0], pvt->alignment_samples[1], pvt->alignment_samples[2], pvt->alignment_samples[3]); a = abs(pvt->alignment_samples[1]) + abs(pvt->alignment_samples[2]) + abs(pvt->alignment_samples[3]); a /= 3; if (a > 100) { pvt->alignment_detection_triggered = 1; ast_debug(1, "Alignment Detection Triggered.\n"); } else pvt->do_alignment_detection = 0; } static int mbl_queue_control(struct mbl_pvt *pvt, enum ast_control_frame_type control) { for (;;) { if (pvt->owner) { if (ast_channel_trylock(pvt->owner)) { DEADLOCK_AVOIDANCE(&pvt->lock); } else { ast_queue_control(pvt->owner, control); ast_channel_unlock(pvt->owner); break; } } else break; } return 0; } static int mbl_queue_hangup(struct mbl_pvt *pvt) { for (;;) { if (pvt->owner) { if (ast_channel_trylock(pvt->owner)) { DEADLOCK_AVOIDANCE(&pvt->lock); } else { ast_queue_hangup(pvt->owner); ast_channel_unlock(pvt->owner); break; } } else break; } return 0; } static int mbl_ast_hangup(struct mbl_pvt *pvt) { if (pvt->owner) { ast_hangup(pvt->owner); } return 0; } /*! * \brief Check if a mobile device has service. * \param pvt a mbl_pvt struct * \retval 1 this device has service * \retval 0 no service * * \note This function will always indicate that service is available if the * given device does not support service indication. */ static int mbl_has_service(struct mbl_pvt *pvt) { if (pvt->type != MBL_TYPE_PHONE) return 1; if (!pvt->hfp->cind_map.service) return 1; if (pvt->hfp->cind_state[pvt->hfp->cind_map.service] == HFP_CIND_SERVICE_AVAILABLE) return 1; return 0; } /* rfcomm helpers */ static int rfcomm_connect(bdaddr_t src, bdaddr_t dst, int remote_channel) { struct sockaddr_rc addr; int s; if ((s = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) { ast_debug(1, "socket() failed (%d).\n", errno); return -1; } memset(&addr, 0, sizeof(addr)); addr.rc_family = AF_BLUETOOTH; bacpy(&addr.rc_bdaddr, &src); addr.rc_channel = (uint8_t) 0; if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { ast_debug(1, "bind() failed (%d).\n", errno); close(s); return -1; } memset(&addr, 0, sizeof(addr)); addr.rc_family = AF_BLUETOOTH; bacpy(&addr.rc_bdaddr, &dst); addr.rc_channel = remote_channel; if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { ast_debug(1, "connect() failed (%d).\n", errno); close(s); return -1; } return s; } /*! * \brief Write to an rfcomm socket. * \param rsock the socket to write to * \param buf the null terminated buffer to write * * This function will write characters from buf. The buffer must be null * terminated. * * \retval -1 error * \retval 0 success */ static int rfcomm_write(int rsock, char *buf) { return rfcomm_write_full(rsock, buf, strlen(buf)); } /*! * \brief Write to an rfcomm socket. * \param rsock the socket to write to * \param buf the buffer to write * \param count the number of characters from the buffer to write * * This function will write count characters from buf. It will always write * count chars unless it encounters an error. * * \retval -1 error * \retval 0 success */ static int rfcomm_write_full(int rsock, char *buf, size_t count) { char *p = buf; ssize_t out_count; ast_debug(1, "rfcomm_write() (%d) [%.*s]\n", rsock, (int) count, buf); while (count > 0) { if ((out_count = write(rsock, p, count)) == -1) { ast_debug(1, "rfcomm_write() error [%d]\n", errno); return -1; } count -= out_count; p += out_count; } return 0; } /*! * \brief Wait for activity on an rfcomm socket. * \param rsock the socket to watch * \param ms a pointer to an int containing a timeout in ms * \return zero on timeout and the socket fd (non-zero) otherwise * \retval 0 timeout */ static int rfcomm_wait(int rsock, int *ms) { int exception, outfd; outfd = ast_waitfor_n_fd(&rsock, 1, ms, &exception); if (outfd < 0) outfd = 0; return outfd; } #ifdef RFCOMM_READ_DEBUG #define rfcomm_read_debug(c) __rfcomm_read_debug(c) static void __rfcomm_read_debug(char c) { if (c == '\r') ast_debug(2, "rfcomm_read: \\r\n"); else if (c == '\n') ast_debug(2, "rfcomm_read: \\n\n"); else ast_debug(2, "rfcomm_read: %c\n", c); } #else #define rfcomm_read_debug(c) #endif /*! * \brief Append the given character to the given buffer and increase the * in_count. */ static void inline rfcomm_append_buf(char **buf, size_t count, size_t *in_count, char c) { if (*in_count < count) { (*in_count)++; *(*buf)++ = c; } } /*! * \brief Read a character from the given stream and check if it matches what * we expected. */ static int rfcomm_read_and_expect_char(int rsock, char *result, char expected) { int res; char c; if (!result) result = &c; if ((res = read(rsock, result, 1)) < 1) { return res; } rfcomm_read_debug(*result); if (*result != expected) { return -2; } return 1; } /*! * \brief Read a character from the given stream and append it to the given * buffer if it matches the expected character. */ static int rfcomm_read_and_append_char(int rsock, char **buf, size_t count, size_t *in_count, char *result, char expected) { int res; char c; if (!result) result = &c; if ((res = rfcomm_read_and_expect_char(rsock, result, expected)) < 1) { return res; } rfcomm_append_buf(buf, count, in_count, *result); return 1; } /*! * \brief Read until '\r\n'. * This function consumes the '\r\n' but does not add it to buf. */ static int rfcomm_read_until_crlf(int rsock, char **buf, size_t count, size_t *in_count) { int res; char c; while ((res = read(rsock, &c, 1)) == 1) { rfcomm_read_debug(c); if (c == '\r') { if ((res = rfcomm_read_and_expect_char(rsock, &c, '\n')) == 1) { break; } else if (res == -2) { rfcomm_append_buf(buf, count, in_count, '\r'); } else { rfcomm_append_buf(buf, count, in_count, '\r'); break; } } rfcomm_append_buf(buf, count, in_count, c); } return res; } /*! * \brief Read the remainder of an AT SMS prompt. * \note the entire parsed string is '\r\n> ' * * By the time this function is executed, only a ' ' is left to read. */ static int rfcomm_read_sms_prompt(int rsock, char **buf, size_t count, size_t *in_count) { int res; if ((res = rfcomm_read_and_append_char(rsock, buf, count, in_count, NULL, ' ')) < 1) goto e_return; return 1; e_return: ast_log(LOG_ERROR, "error parsing SMS prompt on rfcomm socket\n"); return res; } /*! * \brief Read until a \r\nOK\r\n message. */ static int rfcomm_read_until_ok(int rsock, char **buf, size_t count, size_t *in_count) { int res; char c; /* here, we read until finding a \r\n, then we read one character at a * time looking for the string '\r\nOK\r\n'. If we only find a partial * match, we place that in the buffer and try again. */ for (;;) { if ((res = rfcomm_read_until_crlf(rsock, buf, count, in_count)) != 1) { break; } rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, '\n'); if ((res = rfcomm_read_and_expect_char(rsock, &c, '\r')) != 1) { if (res != -2) { break; } rfcomm_append_buf(buf, count, in_count, c); continue; } if ((res = rfcomm_read_and_expect_char(rsock, &c, '\n')) != 1) { if (res != -2) { break; } rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, c); continue; } if ((res = rfcomm_read_and_expect_char(rsock, &c, 'O')) != 1) { if (res != -2) { break; } rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, '\n'); rfcomm_append_buf(buf, count, in_count, c); continue; } if ((res = rfcomm_read_and_expect_char(rsock, &c, 'K')) != 1) { if (res != -2) { break; } rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, '\n'); rfcomm_append_buf(buf, count, in_count, 'O'); rfcomm_append_buf(buf, count, in_count, c); continue; } if ((res = rfcomm_read_and_expect_char(rsock, &c, '\r')) != 1) { if (res != -2) { break; } rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, '\n'); rfcomm_append_buf(buf, count, in_count, 'O'); rfcomm_append_buf(buf, count, in_count, 'K'); rfcomm_append_buf(buf, count, in_count, c); continue; } if ((res = rfcomm_read_and_expect_char(rsock, &c, '\n')) != 1) { if (res != -2) { break; } rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, '\n'); rfcomm_append_buf(buf, count, in_count, 'O'); rfcomm_append_buf(buf, count, in_count, 'K'); rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, c); continue; } /* we have successfully parsed a '\r\nOK\r\n' string */ return 1; } return res; } /*! * \brief Read the remainder of a +CMGR message. * \note the entire parsed string is '+CMGR: ...\r\n...\r\n...\r\n...\r\nOK\r\n' */ static int rfcomm_read_cmgr(int rsock, char **buf, size_t count, size_t *in_count) { int res; /* append the \r\n that was stripped by the calling function */ rfcomm_append_buf(buf, count, in_count, '\r'); rfcomm_append_buf(buf, count, in_count, '\n'); if ((res = rfcomm_read_until_ok(rsock, buf, count, in_count)) != 1) { ast_log(LOG_ERROR, "error reading +CMGR message on rfcomm socket\n"); } return res; } /*! * \brief Read and AT result code. * \note the entire parsed string is '\r\n\r\n' */ static int rfcomm_read_result(int rsock, char **buf, size_t count, size_t *in_count) { int res; char c; if ((res = rfcomm_read_and_expect_char(rsock, &c, '\n')) < 1) { goto e_return; } if ((res = rfcomm_read_and_append_char(rsock, buf, count, in_count, &c, '>')) == 1) { return rfcomm_read_sms_prompt(rsock, buf, count, in_count); } else if (res != -2) { goto e_return; } rfcomm_append_buf(buf, count, in_count, c); res = rfcomm_read_until_crlf(rsock, buf, count, in_count); if (res != 1) return res; /* check for CMGR, which contains an embedded \r\n pairs terminated by * an \r\nOK\r\n message */ if (*in_count >= 5 && !strncmp(*buf - *in_count, "+CMGR", 5)) { return rfcomm_read_cmgr(rsock, buf, count, in_count); } return 1; e_return: ast_log(LOG_ERROR, "error parsing AT result on rfcomm socket\n"); return res; } /*! * \brief Read the remainder of an AT command. * \note the entire parsed string is '\r' */ static int rfcomm_read_command(int rsock, char **buf, size_t count, size_t *in_count) { int res; char c; while ((res = read(rsock, &c, 1)) == 1) { rfcomm_read_debug(c); /* stop when we get to '\r' */ if (c == '\r') break; rfcomm_append_buf(buf, count, in_count, c); } return res; } /*! * \brief Read one Hayes AT message from an rfcomm socket. * \param rsock the rfcomm socket to read from * \param buf the buffer to store the result in * \param count the size of the buffer or the maximum number of characters to read * * Here we need to read complete Hayes AT messages. The AT message formats we * support are listed below. * * \verbatim * \r\n\r\n * \r * \r\n> * \endverbatim * * These formats correspond to AT result codes, AT commands, and the AT SMS * prompt respectively. When messages are read the leading and trailing '\r' * and '\n' characters are discarded. If the given buffer is not large enough * to hold the response, what does not fit in the buffer will be dropped. * * \note The rfcomm connection to the device is asynchronous, so there is no * guarantee that responses will be returned in a single read() call. We handle * this by blocking until we can read an entire response. * * \retval 0 end of file * \retval -1 read error * \retval -2 parse error * \retval other the number of characters added to buf */ static ssize_t rfcomm_read(int rsock, char *buf, size_t count) { ssize_t res; size_t in_count = 0; char c; if ((res = rfcomm_read_and_expect_char(rsock, &c, '\r')) == 1) { res = rfcomm_read_result(rsock, &buf, count, &in_count); } else if (res == -2) { rfcomm_append_buf(&buf, count, &in_count, c); res = rfcomm_read_command(rsock, &buf, count, &in_count); } if (res < 1) return res; else return in_count; } /* sco helpers and callbacks */ static int sco_connect(bdaddr_t src, bdaddr_t dst) { struct sockaddr_sco addr; int s; if ((s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) { ast_debug(1, "socket() failed (%d).\n", errno); return -1; } /* XXX this does not work with the do_sco_listen() thread (which also bind()s * to this address). Also I am not sure if it is necessary. */ #if 0 memset(&addr, 0, sizeof(addr)); addr.sco_family = AF_BLUETOOTH; bacpy(&addr.sco_bdaddr, &src); if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { ast_debug(1, "bind() failed (%d).\n", errno); close(s); return -1; } #endif memset(&addr, 0, sizeof(addr)); addr.sco_family = AF_BLUETOOTH; bacpy(&addr.sco_bdaddr, &dst); if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { ast_debug(1, "sco connect() failed (%d).\n", errno); close(s); return -1; } return s; } static int sco_write(int s, char *buf, int len) { int r; if (s == -1) { ast_debug(3, "sco_write() not ready\n"); return 0; } ast_debug(3, "sco_write()\n"); r = write(s, buf, len); if (r == -1) { ast_debug(3, "sco write error %d\n", errno); return 0; } return 1; } /*! * \brief Accept SCO connections. * This function is an ast_io callback function used to accept incoming sco * audio connections. */ static int sco_accept(int *id, int fd, short events, void *data) { struct adapter_pvt *adapter = (struct adapter_pvt *) data; struct sockaddr_sco addr; socklen_t addrlen; struct mbl_pvt *pvt; socklen_t len; char saddr[18]; struct sco_options so; int sock; addrlen = sizeof(struct sockaddr_sco); if ((sock = accept(fd, (struct sockaddr *)&addr, &addrlen)) == -1) { ast_log(LOG_ERROR, "error accepting audio connection on adapter %s\n", adapter->id); return 0; } len = sizeof(so); getsockopt(sock, SOL_SCO, SCO_OPTIONS, &so, &len); ba2str(&addr.sco_bdaddr, saddr); ast_debug(1, "Incoming Audio Connection from device %s MTU is %d\n", saddr, so.mtu); /* figure out which device this sco connection belongs to */ pvt = NULL; AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { if (!bacmp(&pvt->addr, &addr.sco_bdaddr)) break; } AST_RWLIST_UNLOCK(&devices); if (!pvt) { ast_log(LOG_WARNING, "could not find device for incoming audio connection\n"); close(sock); return 1; } ast_mutex_lock(&pvt->lock); if (pvt->sco_socket != -1) { close(pvt->sco_socket); pvt->sco_socket = -1; } pvt->sco_socket = sock; if (pvt->owner) { ast_channel_set_fd(pvt->owner, 0, sock); } else { ast_debug(1, "incoming audio connection for pvt without owner\n"); } ast_mutex_unlock(&pvt->lock); return 1; } /*! * \brief Bind an SCO listener socket for the given adapter. * \param adapter an adapter_pvt * \return -1 on error, non zero on success */ static int sco_bind(struct adapter_pvt *adapter) { struct sockaddr_sco addr; int opt = 1; if ((adapter->sco_socket = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) { ast_log(LOG_ERROR, "Unable to create sco listener socket for adapter %s.\n", adapter->id); goto e_return; } memset(&addr, 0, sizeof(addr)); addr.sco_family = AF_BLUETOOTH; bacpy(&addr.sco_bdaddr, &adapter->addr); if (bind(adapter->sco_socket, (struct sockaddr *)&addr, sizeof(addr)) < 0) { ast_log(LOG_ERROR, "Unable to bind sco listener socket. (%d)\n", errno); goto e_close_socket; } if (setsockopt(adapter->sco_socket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1) { ast_log(LOG_ERROR, "Unable to setsockopt sco listener socket.\n"); goto e_close_socket; } if (listen(adapter->sco_socket, 5) < 0) { ast_log(LOG_ERROR, "Unable to listen sco listener socket.\n"); goto e_close_socket; } return adapter->sco_socket; e_close_socket: close(adapter->sco_socket); adapter->sco_socket = -1; e_return: return -1; } /* * Hayes AT command helpers. */ /*! * \brief Match the given buffer with the given prefix. * \param buf the buffer to match * \param prefix the prefix to match */ static int at_match_prefix(char *buf, char *prefix) { return !strncmp(buf, prefix, strlen(prefix)); } /*! * \brief Read an AT message and clasify it. * \param rsock an rfcomm socket * \param buf the buffer to store the result in * \param count the size of the buffer or the maximum number of characters to read * \return the type of message received, in addition buf will contain the * message received and will be null terminated * \see at_read() */ static at_message_t at_read_full(int rsock, char *buf, size_t count) { ssize_t s; if ((s = rfcomm_read(rsock, buf, count - 1)) < 1) return s; buf[s] = '\0'; if (!strcmp("OK", buf)) { return AT_OK; } else if (!strcmp("ERROR", buf)) { return AT_ERROR; } else if (!strcmp("RING", buf)) { return AT_RING; } else if (!strcmp("AT+CKPD=200", buf)) { return AT_CKPD; } else if (!strcmp("> ", buf)) { return AT_SMS_PROMPT; } else if (at_match_prefix(buf, "+CMTI:")) { return AT_CMTI; } else if (at_match_prefix(buf, "+CIEV:")) { return AT_CIEV; } else if (at_match_prefix(buf, "+BRSF:")) { return AT_BRSF; } else if (at_match_prefix(buf, "+CIND:")) { return AT_CIND; } else if (at_match_prefix(buf, "+CLIP:")) { return AT_CLIP; } else if (at_match_prefix(buf, "+CMGR:")) { return AT_CMGR; } else if (at_match_prefix(buf, "+VGM:")) { return AT_VGM; } else if (at_match_prefix(buf, "+VGS:")) { return AT_VGS; } else if (at_match_prefix(buf, "+CMS ERROR:")) { return AT_CMS_ERROR; } else if (at_match_prefix(buf, "AT+VGM=")) { return AT_VGM; } else if (at_match_prefix(buf, "AT+VGS=")) { return AT_VGS; } else if (at_match_prefix(buf, "+CUSD:")) { return AT_CUSD; } else { return AT_UNKNOWN; } } /*! * \brief Get the string representation of the given AT message. * \param msg the message to process * \return a string describing the given message */ static inline const char *at_msg2str(at_message_t msg) { switch (msg) { /* errors */ case AT_PARSE_ERROR: return "PARSE ERROR"; case AT_READ_ERROR: return "READ ERROR"; default: case AT_UNKNOWN: return "UNKNOWN"; /* at responses */ case AT_OK: return "OK"; case AT_ERROR: return "ERROR"; case AT_RING: return "RING"; case AT_BRSF: return "AT+BRSF"; case AT_CIND: return "AT+CIND"; case AT_CIEV: return "AT+CIEV"; case AT_CLIP: return "AT+CLIP"; case AT_CMTI: return "AT+CMTI"; case AT_CMGR: return "AT+CMGR"; case AT_SMS_PROMPT: return "SMS PROMPT"; case AT_CMS_ERROR: return "+CMS ERROR"; /* at commands */ case AT_A: return "ATA"; case AT_D: return "ATD"; case AT_CHUP: return "AT+CHUP"; case AT_CKPD: return "AT+CKPD"; case AT_CMGS: return "AT+CMGS"; case AT_VGM: return "AT+VGM"; case AT_VGS: return "AT+VGS"; case AT_VTS: return "AT+VTS"; case AT_CMGF: return "AT+CMGF"; case AT_CNMI: return "AT+CNMI"; case AT_CMER: return "AT+CMER"; case AT_CIND_TEST: return "AT+CIND=?"; case AT_CUSD: return "AT+CUSD"; } } /* * bluetooth handsfree profile helpers */ /*! * \brief Parse a CIEV event. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) * \param value a pointer to an int to store the event value in (can be NULL) * \return 0 on error (parse error, or unknown event) or a HFP_CIND_* value on * success */ static int hfp_parse_ciev(struct hfp_pvt *hfp, char *buf, int *value) { int i, v; if (!value) value = &v; if (!sscanf(buf, "+CIEV: %d,%d", &i, value)) { ast_debug(2, "[%s] error parsing CIEV event '%s'\n", hfp->owner->id, buf); return HFP_CIND_NONE; } if (i >= ARRAY_LEN(hfp->cind_state)) { ast_debug(2, "[%s] CIEV event index too high (%s)\n", hfp->owner->id, buf); return HFP_CIND_NONE; } hfp->cind_state[i] = *value; return hfp->cind_index[i]; } /*! * \brief Parse a CLIP event. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) * @note buf will be modified when the CID string is parsed * \return NULL on error (parse error) or a pointer to the caller id * information in buf */ static char *hfp_parse_clip(struct hfp_pvt *hfp, char *buf) { int i, state; char *clip = NULL; size_t s; /* parse clip info in the following format: * +CLIP: "123456789",128,... */ state = 0; s = strlen(buf); for (i = 0; i < s && state != 3; i++) { switch (state) { case 0: /* search for start of the number (") */ if (buf[i] == '"') { state++; } break; case 1: /* mark the number */ clip = &buf[i]; state++; /* fall through */ case 2: /* search for the end of the number (") */ if (buf[i] == '"') { buf[i] = '\0'; state++; } break; } } if (state != 3) { return NULL; } return clip; } /*! * \brief Parse a CMTI notification. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) * @note buf will be modified when the CMTI message is parsed * \return -1 on error (parse error) or the index of the new sms message */ static int hfp_parse_cmti(struct hfp_pvt *hfp, char *buf) { int index = -1; /* parse cmti info in the following format: * +CMTI: , */ if (!sscanf(buf, "+CMTI: %*[^,],%d", &index)) { ast_debug(2, "[%s] error parsing CMTI event '%s'\n", hfp->owner->id, buf); return -1; } return index; } /*! * \brief Parse a CMGR message. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) * \param from_number a pointer to a char pointer which will store the from * number * \param text a pointer to a char pointer which will store the message text * @note buf will be modified when the CMGR message is parsed * \retval -1 parse error * \retval 0 success */ static int hfp_parse_cmgr(struct hfp_pvt *hfp, char *buf, char **from_number, char **text) { int i, state; size_t s; /* parse cmgr info in the following format: * +CMGR: ,"+123456789",...\r\n * */ state = 0; s = strlen(buf); for (i = 0; i < s && state != 6; i++) { switch (state) { case 0: /* search for start of the number section (,) */ if (buf[i] == ',') { state++; } break; case 1: /* find the opening quote (") */ if (buf[i] == '"') { state++; } break; case 2: /* mark the start of the number */ if (from_number) { *from_number = &buf[i]; state++; } /* fall through */ case 3: /* search for the end of the number (") */ if (buf[i] == '"') { buf[i] = '\0'; state++; } break; case 4: /* search for the start of the message text (\n) */ if (buf[i] == '\n') { state++; } break; case 5: /* mark the start of the message text */ if (text) { *text = &buf[i]; state++; } break; } } if (state != 6) { return -1; } return 0; } /*! * \brief Parse a CUSD answer. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) * @note buf will be modified when the CUSD string is parsed * \return NULL on error (parse error) or a pointer to the cusd message * information in buf */ static char *hfp_parse_cusd(struct hfp_pvt *hfp, char *buf) { int i, message_start, message_end; char *cusd; size_t s; /* parse cusd message in the following format: * +CUSD: 0,"100,00 EURO, valid till 01.01.2010, you are using tariff "Mega Tariff". More informations *111#." */ message_start = 0; message_end = 0; s = strlen(buf); /* Find the start of the message (") */ for (i = 0; i < s; i++) { if (buf[i] == '"') { message_start = i + 1; break; } } if (message_start == 0 || message_start >= s) { return NULL; } /* Find the end of the message (") */ for (i = s; i > 0; i--) { if (buf[i] == '"') { message_end = i; break; } } if (message_end == 0) { return NULL; } if (message_start >= message_end) { return NULL; } cusd = &buf[message_start]; buf[message_end] = '\0'; return cusd; } /*! * \brief Convert a hfp_hf struct to a BRSF int. * \param hf an hfp_hf brsf object * \return an integer representing the given brsf struct */ static int hfp_brsf2int(struct hfp_hf *hf) { int brsf = 0; brsf |= hf->ecnr ? HFP_HF_ECNR : 0; brsf |= hf->cw ? HFP_HF_CW : 0; brsf |= hf->cid ? HFP_HF_CID : 0; brsf |= hf->voice ? HFP_HF_VOICE : 0; brsf |= hf->volume ? HFP_HF_VOLUME : 0; brsf |= hf->status ? HFP_HF_STATUS : 0; brsf |= hf->control ? HFP_HF_CONTROL : 0; return brsf; } /*! * \brief Convert a BRSF int to an hfp_ag struct. * \param brsf a brsf integer * \param ag a AG (hfp_ag) brsf object * \return a pointer to the given hfp_ag object populated with the values from * the given brsf integer */ static struct hfp_ag *hfp_int2brsf(int brsf, struct hfp_ag *ag) { ag->cw = brsf & HFP_AG_CW ? 1 : 0; ag->ecnr = brsf & HFP_AG_ECNR ? 1 : 0; ag->voice = brsf & HFP_AG_VOICE ? 1 : 0; ag->ring = brsf & HFP_AG_RING ? 1 : 0; ag->tag = brsf & HFP_AG_TAG ? 1 : 0; ag->reject = brsf & HFP_AG_REJECT ? 1 : 0; ag->status = brsf & HFP_AG_STATUS ? 1 : 0; ag->control = brsf & HFP_AG_CONTROL ? 1 : 0; ag->errors = brsf & HFP_AG_ERRORS ? 1 : 0; return ag; } /*! * \brief Send a BRSF request. * \param hfp an hfp_pvt struct * \param brsf an hfp_hf brsf struct * * \retval 0 on success * \retval -1 on error */ static int hfp_send_brsf(struct hfp_pvt *hfp, struct hfp_hf *brsf) { char cmd[32]; snprintf(cmd, sizeof(cmd), "AT+BRSF=%d\r", hfp_brsf2int(brsf)); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Send the CIND read command. * \param hfp an hfp_pvt struct */ static int hfp_send_cind(struct hfp_pvt *hfp) { return rfcomm_write(hfp->rsock, "AT+CIND?\r"); } /*! * \brief Send the CIND test command. * \param hfp an hfp_pvt struct */ static int hfp_send_cind_test(struct hfp_pvt *hfp) { return rfcomm_write(hfp->rsock, "AT+CIND=?\r"); } /*! * \brief Enable or disable indicator events reporting. * \param hfp an hfp_pvt struct * \param status enable or disable events reporting (should be 1 or 0) */ static int hfp_send_cmer(struct hfp_pvt *hfp, int status) { char cmd[32]; snprintf(cmd, sizeof(cmd), "AT+CMER=3,0,0,%d\r", status ? 1 : 0); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Send the current speaker gain level. * \param hfp an hfp_pvt struct * \param value the value to send (must be between 0 and 15) */ static int hfp_send_vgs(struct hfp_pvt *hfp, int value) { char cmd[32]; snprintf(cmd, sizeof(cmd), "AT+VGS=%d\r", value); return rfcomm_write(hfp->rsock, cmd); } #if 0 /*! * \brief Send the current microphone gain level. * \param hfp an hfp_pvt struct * \param value the value to send (must be between 0 and 15) */ static int hfp_send_vgm(struct hfp_pvt *hfp, int value) { char cmd[32]; snprintf(cmd, sizeof(cmd), "AT+VGM=%d\r", value); return rfcomm_write(hfp->rsock, cmd); } #endif /*! * \brief Enable or disable calling line identification. * \param hfp an hfp_pvt struct * \param status enable or disable calling line identification (should be 1 or * 0) */ static int hfp_send_clip(struct hfp_pvt *hfp, int status) { char cmd[32]; snprintf(cmd, sizeof(cmd), "AT+CLIP=%d\r", status ? 1 : 0); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Send a DTMF command. * \param hfp an hfp_pvt struct * \param digit the dtmf digit to send * \return the result of rfcomm_write() or -1 on an invalid digit being sent */ static int hfp_send_dtmf(struct hfp_pvt *hfp, char digit) { char cmd[10]; switch(digit) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '*': case '#': snprintf(cmd, sizeof(cmd), "AT+VTS=%c\r", digit); return rfcomm_write(hfp->rsock, cmd); default: return -1; } } /*! * \brief Set the SMS mode. * \param hfp an hfp_pvt struct * \param mode the sms mode (0 = PDU, 1 = Text) */ static int hfp_send_cmgf(struct hfp_pvt *hfp, int mode) { char cmd[32]; snprintf(cmd, sizeof(cmd), "AT+CMGF=%d\r", mode); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Setup SMS new message indication. * \param hfp an hfp_pvt struct */ static int hfp_send_cnmi(struct hfp_pvt *hfp) { return rfcomm_write(hfp->rsock, "AT+CNMI=2,1,0,0,0\r"); } /*! * \brief Read an SMS message. * \param hfp an hfp_pvt struct * \param index the location of the requested message */ static int hfp_send_cmgr(struct hfp_pvt *hfp, int index) { char cmd[32]; snprintf(cmd, sizeof(cmd), "AT+CMGR=%d\r", index); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Start sending an SMS message. * \param hfp an hfp_pvt struct * \param number the destination of the message */ static int hfp_send_cmgs(struct hfp_pvt *hfp, const char *number) { char cmd[64]; snprintf(cmd, sizeof(cmd), "AT+CMGS=\"%s\"\r", number); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Send the text of an SMS message. * \param hfp an hfp_pvt struct * \param message the text of the message */ static int hfp_send_sms_text(struct hfp_pvt *hfp, const char *message) { char cmd[162]; snprintf(cmd, sizeof(cmd), "%.160s\x1a", message); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Send AT+CHUP. * \param hfp an hfp_pvt struct */ static int hfp_send_chup(struct hfp_pvt *hfp) { return rfcomm_write(hfp->rsock, "AT+CHUP\r"); } /*! * \brief Send ATD. * \param hfp an hfp_pvt struct * \param number the number to send */ static int hfp_send_atd(struct hfp_pvt *hfp, const char *number) { char cmd[64]; snprintf(cmd, sizeof(cmd), "ATD%s;\r", number); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Send ATA. * \param hfp an hfp_pvt struct */ static int hfp_send_ata(struct hfp_pvt *hfp) { return rfcomm_write(hfp->rsock, "ATA\r"); } /*! * \brief Send CUSD. * \param hfp an hfp_pvt struct * \param code the CUSD code to send */ static int hfp_send_cusd(struct hfp_pvt *hfp, const char *code) { char cmd[128]; snprintf(cmd, sizeof(cmd), "AT+CUSD=1,\"%s\",15\r", code); return rfcomm_write(hfp->rsock, cmd); } /*! * \brief Parse BRSF data. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) */ static int hfp_parse_brsf(struct hfp_pvt *hfp, const char *buf) { int brsf; if (!sscanf(buf, "+BRSF:%d", &brsf)) return -1; hfp_int2brsf(brsf, &hfp->brsf); return 0; } /*! * \brief Parse and store the given indicator. * \param hfp an hfp_pvt struct * \param group the indicator group * \param indicator the indicator to parse */ static int hfp_parse_cind_indicator(struct hfp_pvt *hfp, int group, char *indicator) { int value; /* store the current indicator */ if (group >= ARRAY_LEN(hfp->cind_state)) { ast_debug(1, "ignoring CIND state '%s' for group %d, we only support up to %d indicators\n", indicator, group, (int) sizeof(hfp->cind_state)); return -1; } if (!sscanf(indicator, "%d", &value)) { ast_debug(1, "error parsing CIND state '%s' for group %d\n", indicator, group); return -1; } hfp->cind_state[group] = value; return 0; } /*! * \brief Read the result of the AT+CIND? command. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) * \note hfp_send_cind_test() and hfp_parse_cind_test() should be called at * least once before this function is called. */ static int hfp_parse_cind(struct hfp_pvt *hfp, char *buf) { int i, state, group; size_t s; char *indicator = NULL; /* parse current state of all of our indicators. The list is in the * following format: * +CIND: 1,0,2,0,0,0,0 */ group = 0; state = 0; s = strlen(buf); for (i = 0; i < s; i++) { switch (state) { case 0: /* search for start of the status indicators (a space) */ if (buf[i] == ' ') { group++; state++; } break; case 1: /* mark this indicator */ indicator = &buf[i]; state++; break; case 2: /* search for the start of the next indicator (a comma) */ if (buf[i] == ',') { buf[i] = '\0'; hfp_parse_cind_indicator(hfp, group, indicator); group++; state = 1; } break; } } /* store the last indicator */ if (state == 2) hfp_parse_cind_indicator(hfp, group, indicator); return 0; } /*! * \brief Parse the result of the AT+CIND=? command. * \param hfp an hfp_pvt struct * \param buf the buffer to parse (null terminated) */ static int hfp_parse_cind_test(struct hfp_pvt *hfp, char *buf) { int i, state, group; size_t s; char *indicator = NULL; hfp->nocallsetup = 1; /* parse the indications list. It is in the follwing format: * +CIND: ("ind1",(0-1)),("ind2",(0-5)) */ group = 0; state = 0; s = strlen(buf); for (i = 0; i < s; i++) { switch (state) { case 0: /* search for start of indicator block */ if (buf[i] == '(') { group++; state++; } break; case 1: /* search for '"' in indicator block */ if (buf[i] == '"') { state++; } break; case 2: /* mark the start of the indicator name */ indicator = &buf[i]; state++; break; case 3: /* look for the end of the indicator name */ if (buf[i] == '"') { buf[i] = '\0'; state++; } break; case 4: /* find the start of the value range */ if (buf[i] == '(') { state++; } break; case 5: /* mark the start of the value range */ state++; break; case 6: /* find the end of the value range */ if (buf[i] == ')') { buf[i] = '\0'; state++; } break; case 7: /* process the values we found */ if (group < sizeof(hfp->cind_index)) { if (!strcmp(indicator, "service")) { hfp->cind_map.service = group; hfp->cind_index[group] = HFP_CIND_SERVICE; } else if (!strcmp(indicator, "call")) { hfp->cind_map.call = group; hfp->cind_index[group] = HFP_CIND_CALL; } else if (!strcmp(indicator, "callsetup")) { hfp->nocallsetup = 0; hfp->cind_map.callsetup = group; hfp->cind_index[group] = HFP_CIND_CALLSETUP; } else if (!strcmp(indicator, "call_setup")) { /* non standard call setup identifier */ hfp->nocallsetup = 0; hfp->cind_map.callsetup = group; hfp->cind_index[group] = HFP_CIND_CALLSETUP; } else if (!strcmp(indicator, "callheld")) { hfp->cind_map.callheld = group; hfp->cind_index[group] = HFP_CIND_CALLHELD; } else if (!strcmp(indicator, "signal")) { hfp->cind_map.signal = group; hfp->cind_index[group] = HFP_CIND_SIGNAL; } else if (!strcmp(indicator, "roam")) { hfp->cind_map.roam = group; hfp->cind_index[group] = HFP_CIND_ROAM; } else if (!strcmp(indicator, "battchg")) { hfp->cind_map.battchg = group; hfp->cind_index[group] = HFP_CIND_BATTCHG; } else { hfp->cind_index[group] = HFP_CIND_UNKNOWN; ast_debug(2, "ignoring unknown CIND indicator '%s'\n", indicator); } } else { ast_debug(1, "can't store indicator %d (%s), we only support up to %d indicators", group, indicator, (int) sizeof(hfp->cind_index)); } state = 0; break; } } hfp->owner->no_callsetup = hfp->nocallsetup; return 0; } /* * Bluetooth Headset Profile helpers */ /*! * \brief Send an OK AT response. * \param rsock the rfcomm socket to use */ static int hsp_send_ok(int rsock) { return rfcomm_write(rsock, "\r\nOK\r\n"); } /*! * \brief Send an ERROR AT response. * \param rsock the rfcomm socket to use */ static int hsp_send_error(int rsock) { return rfcomm_write(rsock, "\r\nERROR\r\n"); } /*! * \brief Send a speaker gain unsolicited AT response * \param rsock the rfcomm socket to use * \param gain the speaker gain value */ static int hsp_send_vgs(int rsock, int gain) { char cmd[32]; snprintf(cmd, sizeof(cmd), "\r\n+VGS=%d\r\n", gain); return rfcomm_write(rsock, cmd); } /*! * \brief Send a microphone gain unsolicited AT response * \param rsock the rfcomm socket to use * \param gain the microphone gain value */ static int hsp_send_vgm(int rsock, int gain) { char cmd[32]; snprintf(cmd, sizeof(cmd), "\r\n+VGM=%d\r\n", gain); return rfcomm_write(rsock, cmd); } /*! * \brief Send a RING unsolicited AT response. * \param rsock the rfcomm socket to use */ static int hsp_send_ring(int rsock) { return rfcomm_write(rsock, "\r\nRING\r\n"); } /* * message queue functions */ /*! * \brief Add an item to the back of the queue. * \param pvt a mbl_pvt structure * \param expect the msg we expect to receive * \param response_to the message that was sent to generate the expected * response */ static int msg_queue_push(struct mbl_pvt *pvt, at_message_t expect, at_message_t response_to) { struct msg_queue_entry *msg; if (!(msg = ast_calloc(1, sizeof(*msg)))) { return -1; } msg->expected = expect; msg->response_to = response_to; AST_LIST_INSERT_TAIL(&pvt->msg_queue, msg, entry); return 0; } /*! * \brief Add an item to the back of the queue with data. * \param pvt a mbl_pvt structure * \param expect the msg we expect to receive * \param response_to the message that was sent to generate the expected * response * \param data data associated with this message, it will be freed when the * message is freed */ static int msg_queue_push_data(struct mbl_pvt *pvt, at_message_t expect, at_message_t response_to, void *data) { struct msg_queue_entry *msg; if (!(msg = ast_calloc(1, sizeof(*msg)))) { return -1; } msg->expected = expect; msg->response_to = response_to; msg->data = data; AST_LIST_INSERT_TAIL(&pvt->msg_queue, msg, entry); return 0; } /*! * \brief Remove an item from the front of the queue. * \param pvt a mbl_pvt structure * \return a pointer to the removed item */ static struct msg_queue_entry *msg_queue_pop(struct mbl_pvt *pvt) { return AST_LIST_REMOVE_HEAD(&pvt->msg_queue, entry); } /*! * \brief Remove an item from the front of the queue, and free it. * \param pvt a mbl_pvt structure */ static void msg_queue_free_and_pop(struct mbl_pvt *pvt) { struct msg_queue_entry *msg; if ((msg = msg_queue_pop(pvt))) { if (msg->data) ast_free(msg->data); ast_free(msg); } } /*! * \brief Remove all itmes from the queue and free them. * \param pvt a mbl_pvt structure */ static void msg_queue_flush(struct mbl_pvt *pvt) { struct msg_queue_entry *msg; while ((msg = msg_queue_head(pvt))) msg_queue_free_and_pop(pvt); } /*! * \brief Get the head of a queue. * \param pvt a mbl_pvt structure * \return a pointer to the head of the given msg queue */ static struct msg_queue_entry *msg_queue_head(struct mbl_pvt *pvt) { return AST_LIST_FIRST(&pvt->msg_queue); } /* sdp helpers */ static int sdp_search(char *addr, int profile) { sdp_session_t *session = 0; bdaddr_t bdaddr; uuid_t svc_uuid; uint32_t range = 0x0000ffff; sdp_list_t *response_list, *search_list, *attrid_list; int status, port; sdp_list_t *proto_list; sdp_record_t *sdprec; str2ba(addr, &bdaddr); port = 0; session = sdp_connect(BDADDR_ANY, &bdaddr, SDP_RETRY_IF_BUSY); if (!session) { ast_debug(1, "sdp_connect() failed on device %s.\n", addr); return 0; } sdp_uuid32_create(&svc_uuid, profile); search_list = sdp_list_append(0, &svc_uuid); attrid_list = sdp_list_append(0, &range); response_list = 0x00; status = sdp_service_search_attr_req(session, search_list, SDP_ATTR_REQ_RANGE, attrid_list, &response_list); if (status == 0) { if (response_list) { sdprec = (sdp_record_t *) response_list->data; proto_list = 0x00; if (sdp_get_access_protos(sdprec, &proto_list) == 0) { port = sdp_get_proto_port(proto_list, RFCOMM_UUID); sdp_list_free(proto_list, 0); } sdp_record_free(sdprec); sdp_list_free(response_list, 0); } else ast_debug(1, "No responses returned for device %s.\n", addr); } else ast_debug(1, "sdp_service_search_attr_req() failed on device %s.\n", addr); sdp_list_free(search_list, 0); sdp_list_free(attrid_list, 0); sdp_close(session); return port; } static sdp_session_t *sdp_register(void) { uint32_t service_uuid_int[] = {0, 0, 0, GENERIC_AUDIO_SVCLASS_ID}; uint8_t rfcomm_channel = 1; const char *service_name = "Asterisk PABX"; const char *service_dsc = "Asterisk PABX"; const char *service_prov = "Asterisk"; uuid_t root_uuid, l2cap_uuid, rfcomm_uuid, svc_uuid, svc_class1_uuid, svc_class2_uuid; sdp_list_t *l2cap_list = 0, *rfcomm_list = 0, *root_list = 0, *proto_list = 0, *access_proto_list = 0, *svc_uuid_list = 0; sdp_data_t *channel = 0; sdp_session_t *session = 0; sdp_record_t *record = sdp_record_alloc(); sdp_uuid128_create(&svc_uuid, &service_uuid_int); sdp_set_service_id(record, svc_uuid); sdp_uuid32_create(&svc_class1_uuid, GENERIC_AUDIO_SVCLASS_ID); sdp_uuid32_create(&svc_class2_uuid, HEADSET_PROFILE_ID); svc_uuid_list = sdp_list_append(0, &svc_class1_uuid); svc_uuid_list = sdp_list_append(svc_uuid_list, &svc_class2_uuid); sdp_set_service_classes(record, svc_uuid_list); sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP); root_list = sdp_list_append(0, &root_uuid); sdp_set_browse_groups( record, root_list ); sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID); l2cap_list = sdp_list_append(0, &l2cap_uuid); proto_list = sdp_list_append(0, l2cap_list); sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID); channel = sdp_data_alloc(SDP_UINT8, &rfcomm_channel); rfcomm_list = sdp_list_append(0, &rfcomm_uuid); sdp_list_append(rfcomm_list, channel); sdp_list_append(proto_list, rfcomm_list); access_proto_list = sdp_list_append(0, proto_list); sdp_set_access_protos(record, access_proto_list); sdp_set_info_attr(record, service_name, service_prov, service_dsc); if (!(session = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY))) ast_log(LOG_WARNING, "Failed to connect sdp and create session.\n"); else { if (sdp_record_register(session, record, 0) < 0) { ast_log(LOG_WARNING, "Failed to sdp_record_register error: %d\n", errno); return NULL; } } sdp_data_free(channel); sdp_list_free(rfcomm_list, 0); sdp_list_free(root_list, 0); sdp_list_free(access_proto_list, 0); sdp_list_free(svc_uuid_list, 0); return session; } /* Thread routines */ /*! * \brief Handle the BRSF response. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_brsf(struct mbl_pvt *pvt, char *buf) { struct msg_queue_entry *entry; if ((entry = msg_queue_head(pvt)) && entry->expected == AT_BRSF) { if (hfp_parse_brsf(pvt->hfp, buf)) { ast_debug(1, "[%s] error parsing BRSF\n", pvt->id); goto e_return; } if (msg_queue_push(pvt, AT_OK, AT_BRSF)) { ast_debug(1, "[%s] error handling BRSF\n", pvt->id); goto e_return; } msg_queue_free_and_pop(pvt); } else if (entry) { ast_debug(1, "[%s] received unexpected AT message 'BRSF' when expecting %s, ignoring\n", pvt->id, at_msg2str(entry->expected)); } else { ast_debug(1, "[%s] received unexpected AT message 'BRSF'\n", pvt->id); } return 0; e_return: msg_queue_free_and_pop(pvt); return -1; } /*! * \brief Handle the CIND response. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_cind(struct mbl_pvt *pvt, char *buf) { struct msg_queue_entry *entry; if ((entry = msg_queue_head(pvt)) && entry->expected == AT_CIND) { switch (entry->response_to) { case AT_CIND_TEST: if (hfp_parse_cind_test(pvt->hfp, buf) || msg_queue_push(pvt, AT_OK, AT_CIND_TEST)) { ast_debug(1, "[%s] error performing CIND test\n", pvt->id); goto e_return; } break; case AT_CIND: if (hfp_parse_cind(pvt->hfp, buf) || msg_queue_push(pvt, AT_OK, AT_CIND)) { ast_debug(1, "[%s] error getting CIND state\n", pvt->id); goto e_return; } break; default: ast_debug(1, "[%s] error getting CIND state\n", pvt->id); goto e_return; } msg_queue_free_and_pop(pvt); } else if (entry) { ast_debug(1, "[%s] received unexpected AT message 'CIND' when expecting %s, ignoring\n", pvt->id, at_msg2str(entry->expected)); } else { ast_debug(1, "[%s] received unexpected AT message 'CIND'\n", pvt->id); } return 0; e_return: msg_queue_free_and_pop(pvt); return -1; } /*! * \brief Handle OK AT messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_ok(struct mbl_pvt *pvt, char *buf) { struct msg_queue_entry *entry; if ((entry = msg_queue_head(pvt)) && entry->expected == AT_OK) { switch (entry->response_to) { /* initialization stuff */ case AT_BRSF: ast_debug(1, "[%s] BSRF sent successfully\n", pvt->id); /* If this is a blackberry do CMER now, otherwise * continue with CIND as normal. */ if (pvt->blackberry) { if (hfp_send_cmer(pvt->hfp, 1) || msg_queue_push(pvt, AT_OK, AT_CMER)) { ast_debug(1, "[%s] error sending CMER\n", pvt->id); goto e_return; } } else { if (hfp_send_cind_test(pvt->hfp) || msg_queue_push(pvt, AT_CIND, AT_CIND_TEST)) { ast_debug(1, "[%s] error sending CIND test\n", pvt->id); goto e_return; } } break; case AT_CIND_TEST: ast_debug(1, "[%s] CIND test sent successfully\n", pvt->id); ast_debug(2, "[%s] call: %d\n", pvt->id, pvt->hfp->cind_map.call); ast_debug(2, "[%s] callsetup: %d\n", pvt->id, pvt->hfp->cind_map.callsetup); ast_debug(2, "[%s] service: %d\n", pvt->id, pvt->hfp->cind_map.service); if (hfp_send_cind(pvt->hfp) || msg_queue_push(pvt, AT_CIND, AT_CIND)) { ast_debug(1, "[%s] error requesting CIND state\n", pvt->id); goto e_return; } break; case AT_CIND: ast_debug(1, "[%s] CIND sent successfully\n", pvt->id); /* check if a call is active */ if (pvt->hfp->cind_state[pvt->hfp->cind_map.call]) { ast_verb(3, "Bluetooth Device %s has a call in progress - delaying connection.\n", pvt->id); goto e_return; } /* If this is NOT a blackberry proceed with CMER, * otherwise send CLIP. */ if (!pvt->blackberry) { if (hfp_send_cmer(pvt->hfp, 1) || msg_queue_push(pvt, AT_OK, AT_CMER)) { ast_debug(1, "[%s] error sending CMER\n", pvt->id); goto e_return; } } else { if (hfp_send_clip(pvt->hfp, 1) || msg_queue_push(pvt, AT_OK, AT_CLIP)) { ast_debug(1, "[%s] error enabling calling line notification\n", pvt->id); goto e_return; } } break; case AT_CMER: ast_debug(1, "[%s] CMER sent successfully\n", pvt->id); /* If this is a blackberry proceed with the CIND test, * otherwise send CLIP. */ if (pvt->blackberry) { if (hfp_send_cind_test(pvt->hfp) || msg_queue_push(pvt, AT_CIND, AT_CIND_TEST)) { ast_debug(1, "[%s] error sending CIND test\n", pvt->id); goto e_return; } } else { if (hfp_send_clip(pvt->hfp, 1) || msg_queue_push(pvt, AT_OK, AT_CLIP)) { ast_debug(1, "[%s] error enabling calling line notification\n", pvt->id); goto e_return; } } break; case AT_CLIP: ast_debug(1, "[%s] caling line indication enabled\n", pvt->id); if (hfp_send_vgs(pvt->hfp, 15) || msg_queue_push(pvt, AT_OK, AT_VGS)) { ast_debug(1, "[%s] error synchronizing gain settings\n", pvt->id); goto e_return; } pvt->timeout = -1; pvt->hfp->initialized = 1; ast_verb(3, "Bluetooth Device %s initialized and ready.\n", pvt->id); break; case AT_VGS: ast_debug(1, "[%s] volume level synchronization successful\n", pvt->id); /* set the SMS operating mode to text mode */ if (pvt->has_sms) { if (hfp_send_cmgf(pvt->hfp, 1) || msg_queue_push(pvt, AT_OK, AT_CMGF)) { ast_debug(1, "[%s] error setting CMGF\n", pvt->id); goto e_return; } } break; case AT_CMGF: ast_debug(1, "[%s] sms text mode enabled\n", pvt->id); /* turn on SMS new message indication */ if (hfp_send_cnmi(pvt->hfp) || msg_queue_push(pvt, AT_OK, AT_CNMI)) { ast_debug(1, "[%s] error setting CNMI\n", pvt->id); goto e_return; } break; case AT_CNMI: ast_debug(1, "[%s] sms new message indication enabled\n", pvt->id); pvt->has_sms = 1; break; /* end initialization stuff */ case AT_A: ast_debug(1, "[%s] answer sent successfully\n", pvt->id); pvt->needchup = 1; break; case AT_D: ast_debug(1, "[%s] dial sent successfully\n", pvt->id); pvt->needchup = 1; pvt->outgoing = 1; mbl_queue_control(pvt, AST_CONTROL_PROGRESS); break; case AT_CHUP: ast_debug(1, "[%s] successful hangup\n", pvt->id); break; case AT_CMGS: ast_debug(1, "[%s] successfully sent sms message\n", pvt->id); pvt->outgoing_sms = 0; break; case AT_VTS: ast_debug(1, "[%s] digit sent successfully\n", pvt->id); break; case AT_CUSD: ast_debug(1, "[%s] CUSD code sent successfully\n", pvt->id); break; case AT_UNKNOWN: default: ast_debug(1, "[%s] received OK for unhandled request: %s\n", pvt->id, at_msg2str(entry->response_to)); break; } msg_queue_free_and_pop(pvt); } else if (entry) { ast_debug(1, "[%s] received AT message 'OK' when expecting %s, ignoring\n", pvt->id, at_msg2str(entry->expected)); } else { ast_debug(1, "[%s] received unexpected AT message 'OK'\n", pvt->id); } return 0; e_return: msg_queue_free_and_pop(pvt); return -1; } /*! * \brief Handle ERROR AT messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_error(struct mbl_pvt *pvt, char *buf) { struct msg_queue_entry *entry; if ((entry = msg_queue_head(pvt)) && (entry->expected == AT_OK || entry->expected == AT_ERROR || entry->expected == AT_CMS_ERROR || entry->expected == AT_CMGR || entry->expected == AT_SMS_PROMPT)) { switch (entry->response_to) { /* initialization stuff */ case AT_BRSF: ast_debug(1, "[%s] error reading BSRF\n", pvt->id); goto e_return; case AT_CIND_TEST: ast_debug(1, "[%s] error during CIND test\n", pvt->id); goto e_return; case AT_CIND: ast_debug(1, "[%s] error requesting CIND state\n", pvt->id); goto e_return; case AT_CMER: ast_debug(1, "[%s] error during CMER request\n", pvt->id); goto e_return; case AT_CLIP: ast_debug(1, "[%s] error enabling calling line indication\n", pvt->id); goto e_return; case AT_VGS: ast_debug(1, "[%s] volume level synchronization failed\n", pvt->id); /* this is not a fatal error, let's continue with initialization */ /* set the SMS operating mode to text mode */ if (hfp_send_cmgf(pvt->hfp, 1) || msg_queue_push(pvt, AT_OK, AT_CMGF)) { ast_debug(1, "[%s] error setting CMGF\n", pvt->id); goto e_return; } break; case AT_CMGF: pvt->has_sms = 0; ast_debug(1, "[%s] error setting CMGF\n", pvt->id); ast_debug(1, "[%s] no SMS support\n", pvt->id); break; case AT_CNMI: pvt->has_sms = 0; ast_debug(1, "[%s] error setting CNMI\n", pvt->id); ast_debug(1, "[%s] no SMS support\n", pvt->id); break; /* end initialization stuff */ case AT_A: ast_debug(1, "[%s] answer failed\n", pvt->id); mbl_queue_hangup(pvt); break; case AT_D: ast_debug(1, "[%s] dial failed\n", pvt->id); pvt->needchup = 0; mbl_queue_control(pvt, AST_CONTROL_CONGESTION); break; case AT_CHUP: ast_debug(1, "[%s] error sending hangup, disconnecting\n", pvt->id); goto e_return; case AT_CMGR: ast_debug(1, "[%s] error reading sms message\n", pvt->id); pvt->incoming_sms = 0; break; case AT_CMGS: ast_debug(1, "[%s] error sending sms message\n", pvt->id); pvt->outgoing_sms = 0; break; case AT_VTS: ast_debug(1, "[%s] error sending digit\n", pvt->id); break; case AT_CUSD: ast_verb(0, "[%s] error sending CUSD command\n", pvt->id); break; case AT_UNKNOWN: default: ast_debug(1, "[%s] received ERROR for unhandled request: %s\n", pvt->id, at_msg2str(entry->response_to)); break; } msg_queue_free_and_pop(pvt); } else if (entry) { ast_debug(1, "[%s] received AT message 'ERROR' when expecting %s, ignoring\n", pvt->id, at_msg2str(entry->expected)); } else { ast_debug(1, "[%s] received unexpected AT message 'ERROR'\n", pvt->id); } return 0; e_return: msg_queue_free_and_pop(pvt); return -1; } /*! * \brief Handle AT+CIEV messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_ciev(struct mbl_pvt *pvt, char *buf) { int i; switch (hfp_parse_ciev(pvt->hfp, buf, &i)) { case HFP_CIND_CALL: switch (i) { case HFP_CIND_CALL_NONE: ast_debug(1, "[%s] line disconnected\n", pvt->id); if (pvt->owner) { ast_debug(1, "[%s] hanging up owner\n", pvt->id); if (mbl_queue_hangup(pvt)) { ast_log(LOG_ERROR, "[%s] error queueing hangup, disconnectiong...\n", pvt->id); return -1; } } pvt->needchup = 0; pvt->needcallerid = 0; pvt->incoming = 0; pvt->outgoing = 0; break; case HFP_CIND_CALL_ACTIVE: if (pvt->outgoing) { ast_debug(1, "[%s] remote end answered\n", pvt->id); mbl_queue_control(pvt, AST_CONTROL_ANSWER); } else if (pvt->incoming && pvt->answered) { ast_setstate(pvt->owner, AST_STATE_UP); } else if (pvt->incoming) { /* user answered from handset, disconnecting */ ast_verb(3, "[%s] user answered bluetooth device from handset, disconnecting\n", pvt->id); mbl_queue_hangup(pvt); return -1; } break; } break; case HFP_CIND_CALLSETUP: switch (i) { case HFP_CIND_CALLSETUP_NONE: if (pvt->hfp->cind_state[pvt->hfp->cind_map.call] != HFP_CIND_CALL_ACTIVE) { if (pvt->owner) { if (mbl_queue_hangup(pvt)) { ast_log(LOG_ERROR, "[%s] error queueing hangup, disconnectiong...\n", pvt->id); return -1; } } pvt->needchup = 0; pvt->needcallerid = 0; pvt->incoming = 0; pvt->outgoing = 0; } break; case HFP_CIND_CALLSETUP_INCOMING: ast_debug(1, "[%s] incoming call, waiting for caller id\n", pvt->id); pvt->needcallerid = 1; pvt->incoming = 1; break; case HFP_CIND_CALLSETUP_OUTGOING: if (pvt->outgoing) { ast_debug(1, "[%s] outgoing call\n", pvt->id); } else { ast_verb(3, "[%s] user dialed from handset, disconnecting\n", pvt->id); return -1; } break; case HFP_CIND_CALLSETUP_ALERTING: if (pvt->outgoing) { ast_debug(1, "[%s] remote alerting\n", pvt->id); mbl_queue_control(pvt, AST_CONTROL_RINGING); } break; } break; case HFP_CIND_NONE: ast_debug(1, "[%s] error parsing CIND: %s\n", pvt->id, buf); break; } return 0; } /*! * \brief Handle AT+CLIP messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_clip(struct mbl_pvt *pvt, char *buf) { char *clip; struct msg_queue_entry *msg; struct ast_channel *chan; if ((msg = msg_queue_head(pvt)) && msg->expected == AT_CLIP) { msg_queue_free_and_pop(pvt); pvt->needcallerid = 0; if (!(clip = hfp_parse_clip(pvt->hfp, buf))) { ast_debug(1, "[%s] error parsing CLIP: %s\n", pvt->id, buf); } if (!(chan = mbl_new(AST_STATE_RING, pvt, clip, NULL))) { ast_log(LOG_ERROR, "[%s] unable to allocate channel for incoming call\n", pvt->id); hfp_send_chup(pvt->hfp); msg_queue_push(pvt, AT_OK, AT_CHUP); return -1; } /* from this point on, we need to send a chup in the event of a * hangup */ pvt->needchup = 1; if (ast_pbx_start(chan)) { ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming call\n", pvt->id); mbl_ast_hangup(pvt); return -1; } } return 0; } /*! * \brief Handle RING messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_ring(struct mbl_pvt *pvt, char *buf) { if (pvt->needcallerid) { ast_debug(1, "[%s] got ring while waiting for caller id\n", pvt->id); return msg_queue_push(pvt, AT_CLIP, AT_UNKNOWN); } else { return 0; } } /*! * \brief Handle AT+CMTI messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_cmti(struct mbl_pvt *pvt, char *buf) { int index = hfp_parse_cmti(pvt->hfp, buf); if (index > 0) { ast_debug(1, "[%s] incoming sms message\n", pvt->id); if (hfp_send_cmgr(pvt->hfp, index) || msg_queue_push(pvt, AT_CMGR, AT_CMGR)) { ast_debug(1, "[%s] error sending CMGR to retrieve SMS message\n", pvt->id); return -1; } pvt->incoming_sms = 1; return 0; } else { ast_debug(1, "[%s] error parsing incoming sms message alert, disconnecting\n", pvt->id); return -1; } } /*! * \brief Handle AT+CMGR messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_cmgr(struct mbl_pvt *pvt, char *buf) { char *from_number = NULL, *text = NULL; struct ast_channel *chan; struct msg_queue_entry *msg; if ((msg = msg_queue_head(pvt)) && msg->expected == AT_CMGR) { msg_queue_free_and_pop(pvt); if (hfp_parse_cmgr(pvt->hfp, buf, &from_number, &text)) { ast_debug(1, "[%s] error parsing sms message, disconnecting\n", pvt->id); return -1; } ast_debug(1, "[%s] successfully read sms message\n", pvt->id); pvt->incoming_sms = 0; /* XXX this channel probably does not need to be associated with this pvt */ if (!(chan = mbl_new(AST_STATE_DOWN, pvt, NULL, NULL))) { ast_debug(1, "[%s] error creating sms message channel, disconnecting\n", pvt->id); return -1; } ast_channel_exten_set(chan, "sms"); pbx_builtin_setvar_helper(chan, "SMSSRC", from_number); pbx_builtin_setvar_helper(chan, "SMSTXT", text); if (ast_pbx_start(chan)) { ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming sms\n", pvt->id); mbl_ast_hangup(pvt); } } else { ast_debug(1, "[%s] got unexpected +CMGR message, ignoring\n", pvt->id); } return 0; } /*! * \brief Send an SMS message from the queue. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_sms_prompt(struct mbl_pvt *pvt, char *buf) { struct msg_queue_entry *msg; if (!(msg = msg_queue_head(pvt))) { ast_debug(1, "[%s] error, got sms prompt with no pending sms messages\n", pvt->id); return 0; } if (msg->expected != AT_SMS_PROMPT) { ast_debug(1, "[%s] error, got sms prompt but no pending sms messages\n", pvt->id); return 0; } if (hfp_send_sms_text(pvt->hfp, msg->data) || msg_queue_push(pvt, AT_OK, AT_CMGS)) { msg_queue_free_and_pop(pvt); ast_debug(1, "[%s] error sending sms message\n", pvt->id); return 0; } msg_queue_free_and_pop(pvt); return 0; } /*! * \brief Handle CUSD messages. * \param pvt a mbl_pvt structure * \param buf a null terminated buffer containing an AT message * \retval 0 success * \retval -1 error */ static int handle_response_cusd(struct mbl_pvt *pvt, char *buf) { char *cusd; if (!(cusd = hfp_parse_cusd(pvt->hfp, buf))) { ast_verb(0, "[%s] error parsing CUSD: %s\n", pvt->id, buf); return 0; } ast_verb(0, "[%s] CUSD response: %s\n", pvt->id, cusd); return 0; } static void *do_monitor_phone(void *data) { struct mbl_pvt *pvt = (struct mbl_pvt *)data; struct hfp_pvt *hfp = pvt->hfp; char buf[256]; int t; at_message_t at_msg; struct msg_queue_entry *entry; /* Note: At one point the initialization procedure was neatly contained * in the hfp_init() function, but that initialization method did not * work with non standard devices. As a result, the initialization * procedure is not spread throughout the event handling loop. */ /* start initialization with the BRSF request */ ast_mutex_lock(&pvt->lock); pvt->timeout = 10000; if (hfp_send_brsf(hfp, &hfp_our_brsf) || msg_queue_push(pvt, AT_BRSF, AT_BRSF)) { ast_debug(1, "[%s] error sending BRSF\n", hfp->owner->id); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); while (!check_unloading()) { ast_mutex_lock(&pvt->lock); t = pvt->timeout; ast_mutex_unlock(&pvt->lock); if (!rfcomm_wait(pvt->rfcomm_socket, &t)) { ast_debug(1, "[%s] timeout waiting for rfcomm data, disconnecting\n", pvt->id); ast_mutex_lock(&pvt->lock); if (!hfp->initialized) { if ((entry = msg_queue_head(pvt))) { switch (entry->response_to) { case AT_CIND_TEST: if (pvt->blackberry) ast_debug(1, "[%s] timeout during CIND test\n", hfp->owner->id); else ast_debug(1, "[%s] timeout during CIND test, try setting 'blackberry=yes'\n", hfp->owner->id); break; case AT_CMER: if (pvt->blackberry) ast_debug(1, "[%s] timeout after sending CMER, try setting 'blackberry=no'\n", hfp->owner->id); else ast_debug(1, "[%s] timeout after sending CMER\n", hfp->owner->id); break; default: ast_debug(1, "[%s] timeout while waiting for %s in response to %s\n", pvt->id, at_msg2str(entry->expected), at_msg2str(entry->response_to)); break; } } } ast_mutex_unlock(&pvt->lock); goto e_cleanup; } if ((at_msg = at_read_full(hfp->rsock, buf, sizeof(buf))) < 0) { /* XXX gnu specific strerror_r is assummed here, this * is not really safe. See the strerror(3) man page * for more info. */ ast_debug(1, "[%s] error reading from device: %s (%d)\n", pvt->id, strerror_r(errno, buf, sizeof(buf)), errno); break; } ast_debug(1, "[%s] %s\n", pvt->id, buf); switch (at_msg) { case AT_BRSF: ast_mutex_lock(&pvt->lock); if (handle_response_brsf(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_CIND: ast_mutex_lock(&pvt->lock); if (handle_response_cind(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_OK: ast_mutex_lock(&pvt->lock); if (handle_response_ok(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_CMS_ERROR: case AT_ERROR: ast_mutex_lock(&pvt->lock); if (handle_response_error(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_RING: ast_mutex_lock(&pvt->lock); if (handle_response_ring(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_CIEV: ast_mutex_lock(&pvt->lock); if (handle_response_ciev(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_CLIP: ast_mutex_lock(&pvt->lock); if (handle_response_clip(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_CMTI: ast_mutex_lock(&pvt->lock); if (handle_response_cmti(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_CMGR: ast_mutex_lock(&pvt->lock); if (handle_response_cmgr(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_SMS_PROMPT: ast_mutex_lock(&pvt->lock); if (handle_sms_prompt(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_CUSD: ast_mutex_lock(&pvt->lock); if (handle_response_cusd(pvt, buf)) { ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_mutex_unlock(&pvt->lock); break; case AT_UNKNOWN: ast_debug(1, "[%s] ignoring unknown message: %s\n", pvt->id, buf); break; case AT_PARSE_ERROR: ast_debug(1, "[%s] error parsing message\n", pvt->id); goto e_cleanup; case AT_READ_ERROR: ast_debug(1, "[%s] error reading from device: %s (%d)\n", pvt->id, strerror_r(errno, buf, sizeof(buf)), errno); goto e_cleanup; default: break; } } e_cleanup: if (!hfp->initialized) ast_verb(3, "Error initializing Bluetooth device %s.\n", pvt->id); ast_mutex_lock(&pvt->lock); if (pvt->owner) { ast_debug(1, "[%s] device disconnected, hanging up owner\n", pvt->id); pvt->needchup = 0; mbl_queue_hangup(pvt); } close(pvt->rfcomm_socket); close(pvt->sco_socket); pvt->sco_socket = -1; msg_queue_flush(pvt); pvt->connected = 0; hfp->initialized = 0; pvt->adapter->inuse = 0; ast_mutex_unlock(&pvt->lock); ast_verb(3, "Bluetooth Device %s has disconnected.\n", pvt->id); manager_event(EVENT_FLAG_SYSTEM, "MobileStatus", "Status: Disconnect\r\nDevice: %s\r\n", pvt->id); return NULL; } static int headset_send_ring(const void *data) { struct mbl_pvt *pvt = (struct mbl_pvt *) data; ast_mutex_lock(&pvt->lock); if (!pvt->needring) { ast_mutex_unlock(&pvt->lock); return 0; } ast_mutex_unlock(&pvt->lock); if (hsp_send_ring(pvt->rfcomm_socket)) { ast_debug(1, "[%s] error sending RING\n", pvt->id); return 0; } return 1; } static void *do_monitor_headset(void *data) { struct mbl_pvt *pvt = (struct mbl_pvt *)data; char buf[256]; int t; at_message_t at_msg; struct ast_channel *chan = NULL; ast_verb(3, "Bluetooth Device %s initialised and ready.\n", pvt->id); while (!check_unloading()) { t = ast_sched_wait(pvt->sched); if (t == -1) { t = 6000; } ast_sched_runq(pvt->sched); if (rfcomm_wait(pvt->rfcomm_socket, &t) == 0) continue; if ((at_msg = at_read_full(pvt->rfcomm_socket, buf, sizeof(buf))) < 0) { if (strerror_r(errno, buf, sizeof(buf))) ast_debug(1, "[%s] error reading from device\n", pvt->id); else ast_debug(1, "[%s] error reading from device: %s (%d)\n", pvt->id, buf, errno); goto e_cleanup; } ast_debug(1, "[%s] %s\n", pvt->id, buf); switch (at_msg) { case AT_VGS: case AT_VGM: /* XXX volume change requested, we will just * pretend to do something with it */ if (hsp_send_ok(pvt->rfcomm_socket)) { ast_debug(1, "[%s] error sending AT message 'OK'\n", pvt->id); goto e_cleanup; } break; case AT_CKPD: ast_mutex_lock(&pvt->lock); if (pvt->outgoing) { pvt->needring = 0; hsp_send_ok(pvt->rfcomm_socket); if (pvt->answered) { /* we have an answered call up to the * HS, he wants to hangup */ mbl_queue_hangup(pvt); } else { /* we have an outgoing call to the HS, * he wants to answer */ if ((pvt->sco_socket = sco_connect(pvt->adapter->addr, pvt->addr)) == -1) { ast_log(LOG_ERROR, "[%s] unable to create audio connection\n", pvt->id); mbl_queue_hangup(pvt); ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_channel_set_fd(pvt->owner, 0, pvt->sco_socket); mbl_queue_control(pvt, AST_CONTROL_ANSWER); pvt->answered = 1; if (hsp_send_vgs(pvt->rfcomm_socket, 13) || hsp_send_vgm(pvt->rfcomm_socket, 13)) { ast_debug(1, "[%s] error sending VGS/VGM\n", pvt->id); mbl_queue_hangup(pvt); ast_mutex_unlock(&pvt->lock); goto e_cleanup; } } } else if (pvt->incoming) { /* we have an incoming call from the * HS, he wants to hang up */ mbl_queue_hangup(pvt); } else { /* no call is up, HS wants to dial */ hsp_send_ok(pvt->rfcomm_socket); if ((pvt->sco_socket = sco_connect(pvt->adapter->addr, pvt->addr)) == -1) { ast_log(LOG_ERROR, "[%s] unable to create audio connection\n", pvt->id); ast_mutex_unlock(&pvt->lock); goto e_cleanup; } pvt->incoming = 1; if (!(chan = mbl_new(AST_STATE_UP, pvt, NULL, NULL))) { ast_log(LOG_ERROR, "[%s] unable to allocate channel for incoming call\n", pvt->id); ast_mutex_unlock(&pvt->lock); goto e_cleanup; } ast_channel_set_fd(chan, 0, pvt->sco_socket); ast_channel_exten_set(chan, "s"); if (ast_pbx_start(chan)) { ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming call\n", pvt->id); ast_hangup(chan); ast_mutex_unlock(&pvt->lock); goto e_cleanup; } } ast_mutex_unlock(&pvt->lock); break; default: ast_debug(1, "[%s] received unknown AT command: %s (%s)\n", pvt->id, buf, at_msg2str(at_msg)); if (hsp_send_error(pvt->rfcomm_socket)) { ast_debug(1, "[%s] error sending AT message 'ERROR'\n", pvt->id); goto e_cleanup; } break; } } e_cleanup: ast_mutex_lock(&pvt->lock); if (pvt->owner) { ast_debug(1, "[%s] device disconnected, hanging up owner\n", pvt->id); mbl_queue_hangup(pvt); } close(pvt->rfcomm_socket); close(pvt->sco_socket); pvt->sco_socket = -1; pvt->connected = 0; pvt->needring = 0; pvt->outgoing = 0; pvt->incoming = 0; pvt->adapter->inuse = 0; ast_mutex_unlock(&pvt->lock); manager_event(EVENT_FLAG_SYSTEM, "MobileStatus", "Status: Disconnect\r\nDevice: %s\r\n", pvt->id); ast_verb(3, "Bluetooth Device %s has disconnected\n", pvt->id); return NULL; } static int start_monitor(struct mbl_pvt *pvt) { if (pvt->type == MBL_TYPE_PHONE) { pvt->hfp->rsock = pvt->rfcomm_socket; if (ast_pthread_create_background(&pvt->monitor_thread, NULL, do_monitor_phone, pvt) < 0) { pvt->monitor_thread = AST_PTHREADT_NULL; return 0; } } else { if (ast_pthread_create_background(&pvt->monitor_thread, NULL, do_monitor_headset, pvt) < 0) { pvt->monitor_thread = AST_PTHREADT_NULL; return 0; } } return 1; } static void *do_discovery(void *data) { struct adapter_pvt *adapter; struct mbl_pvt *pvt; while (!check_unloading()) { AST_RWLIST_RDLOCK(&adapters); AST_RWLIST_TRAVERSE(&adapters, adapter, entry) { if (!adapter->inuse) { AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { ast_mutex_lock(&pvt->lock); if (!adapter->inuse && !pvt->connected && !strcmp(adapter->id, pvt->adapter->id)) { if ((pvt->rfcomm_socket = rfcomm_connect(adapter->addr, pvt->addr, pvt->rfcomm_port)) > -1) { if (start_monitor(pvt)) { pvt->connected = 1; adapter->inuse = 1; manager_event(EVENT_FLAG_SYSTEM, "MobileStatus", "Status: Connect\r\nDevice: %s\r\n", pvt->id); ast_verb(3, "Bluetooth Device %s has connected, initializing...\n", pvt->id); } } } ast_mutex_unlock(&pvt->lock); } AST_RWLIST_UNLOCK(&devices); } } AST_RWLIST_UNLOCK(&adapters); /* Go to sleep (only if we are not unloading) */ if (!check_unloading()) sleep(discovery_interval); } return NULL; } /*! * \brief Service new and existing SCO connections. * This thread accepts new sco connections and handles audio data. There is * one do_sco_listen thread for each adapter. */ static void *do_sco_listen(void *data) { struct adapter_pvt *adapter = (struct adapter_pvt *) data; while (!check_unloading()) { /* check for new sco connections */ if (ast_io_wait(adapter->accept_io, 0) == -1) { /* handle errors */ ast_log(LOG_ERROR, "ast_io_wait() failed for adapter %s\n", adapter->id); break; } /* handle audio data */ if (ast_io_wait(adapter->io, 1) == -1) { ast_log(LOG_ERROR, "ast_io_wait() failed for audio on adapter %s\n", adapter->id); break; } } return NULL; } /* Module */ /*! * \brief Load an adapter from the configuration file. * \param cfg the config to load the adapter from * \param cat the adapter to load * * This function loads the given adapter and starts the sco listener thread for * that adapter. * * \return NULL on error, a pointer to the adapter that was loaded on success */ static struct adapter_pvt *mbl_load_adapter(struct ast_config *cfg, const char *cat) { const char *id, *address; struct adapter_pvt *adapter; struct ast_variable *v; struct hci_dev_req dr; uint16_t vs; id = ast_variable_retrieve(cfg, cat, "id"); address = ast_variable_retrieve(cfg, cat, "address"); if (ast_strlen_zero(id) || ast_strlen_zero(address)) { ast_log(LOG_ERROR, "Skipping adapter. Missing id or address settings.\n"); goto e_return; } ast_debug(1, "Reading configuration for adapter %s %s.\n", id, address); if (!(adapter = ast_calloc(1, sizeof(*adapter)))) { ast_log(LOG_ERROR, "Skipping adapter %s. Error allocating memory.\n", id); goto e_return; } ast_copy_string(adapter->id, id, sizeof(adapter->id)); str2ba(address, &adapter->addr); /* attempt to connect to the adapter */ adapter->dev_id = hci_devid(address); adapter->hci_socket = hci_open_dev(adapter->dev_id); if (adapter->dev_id < 0 || adapter->hci_socket < 0) { ast_log(LOG_ERROR, "Skipping adapter %s. Unable to communicate with adapter.\n", adapter->id); goto e_free_adapter; } /* check voice setting */ hci_read_voice_setting(adapter->hci_socket, &vs, 1000); vs = htobs(vs); if (vs != 0x0060) { ast_log(LOG_ERROR, "Skipping adapter %s. Voice setting must be 0x0060 - see 'man hciconfig' for details.\n", adapter->id); goto e_hci_close_dev; } for (v = ast_variable_browse(cfg, cat); v; v = v->next) { if (!strcasecmp(v->name, "forcemaster")) { if (ast_true(v->value)) { dr.dev_id = adapter->dev_id; if (hci_strtolm("master", &dr.dev_opt)) { if (ioctl(adapter->hci_socket, HCISETLINKMODE, (unsigned long) &dr) < 0) { ast_log(LOG_WARNING, "Unable to set adapter %s link mode to MASTER. Ignoring 'forcemaster' option.\n", adapter->id); } } } } else if (!strcasecmp(v->name, "alignmentdetection")) { adapter->alignment_detection = ast_true(v->value); } } /* create io contexts */ if (!(adapter->accept_io = io_context_create())) { ast_log(LOG_ERROR, "Unable to create I/O context for audio connection listener\n"); goto e_hci_close_dev; } if (!(adapter->io = io_context_create())) { ast_log(LOG_ERROR, "Unable to create I/O context for audio connections\n"); goto e_destroy_accept_io; } /* bind the sco listener socket */ if (sco_bind(adapter) < 0) { ast_log(LOG_ERROR, "Skipping adapter %s. Error binding audio connection listerner socket.\n", adapter->id); goto e_destroy_io; } /* add the socket to the io context */ if (!(adapter->sco_id = ast_io_add(adapter->accept_io, adapter->sco_socket, sco_accept, AST_IO_IN, adapter))) { ast_log(LOG_ERROR, "Skipping adapter %s. Error adding listener socket to I/O context.\n", adapter->id); goto e_close_sco; } /* start the sco listener for this adapter */ if (ast_pthread_create_background(&adapter->sco_listener_thread, NULL, do_sco_listen, adapter)) { ast_log(LOG_ERROR, "Skipping adapter %s. Error creating audio connection listerner thread.\n", adapter->id); goto e_remove_sco; } /* add the adapter to our global list */ AST_RWLIST_WRLOCK(&adapters); AST_RWLIST_INSERT_HEAD(&adapters, adapter, entry); AST_RWLIST_UNLOCK(&adapters); ast_debug(1, "Loaded adapter %s %s.\n", adapter->id, address); return adapter; e_remove_sco: ast_io_remove(adapter->accept_io, adapter->sco_id); e_close_sco: close(adapter->sco_socket); e_destroy_io: io_context_destroy(adapter->io); e_destroy_accept_io: io_context_destroy(adapter->accept_io); e_hci_close_dev: hci_close_dev(adapter->hci_socket); e_free_adapter: ast_free(adapter); e_return: return NULL; } /*! * \brief Load a device from the configuration file. * \param cfg the config to load the device from * \param cat the device to load * \return NULL on error, a pointer to the device that was loaded on success */ static struct mbl_pvt *mbl_load_device(struct ast_config *cfg, const char *cat) { struct mbl_pvt *pvt; struct adapter_pvt *adapter; struct ast_variable *v; const char *address, *adapter_str, *port; ast_debug(1, "Reading configuration for device %s.\n", cat); adapter_str = ast_variable_retrieve(cfg, cat, "adapter"); if(ast_strlen_zero(adapter_str)) { ast_log(LOG_ERROR, "Skipping device %s. No adapter specified.\n", cat); goto e_return; } /* find the adapter */ AST_RWLIST_RDLOCK(&adapters); AST_RWLIST_TRAVERSE(&adapters, adapter, entry) { if (!strcmp(adapter->id, adapter_str)) break; } AST_RWLIST_UNLOCK(&adapters); if (!adapter) { ast_log(LOG_ERROR, "Skiping device %s. Unknown adapter '%s' specified.\n", cat, adapter_str); goto e_return; } address = ast_variable_retrieve(cfg, cat, "address"); port = ast_variable_retrieve(cfg, cat, "port"); if (ast_strlen_zero(port) || ast_strlen_zero(address)) { ast_log(LOG_ERROR, "Skipping device %s. Missing required port or address setting.\n", cat); goto e_return; } /* create and initialize our pvt structure */ if (!(pvt = ast_calloc(1, sizeof(*pvt)))) { ast_log(LOG_ERROR, "Skipping device %s. Error allocating memory.\n", cat); goto e_return; } ast_mutex_init(&pvt->lock); AST_LIST_HEAD_INIT_NOLOCK(&pvt->msg_queue); /* set some defaults */ pvt->type = MBL_TYPE_PHONE; ast_copy_string(pvt->context, "default", sizeof(pvt->context)); /* populate the pvt structure */ pvt->adapter = adapter; ast_copy_string(pvt->id, cat, sizeof(pvt->id)); str2ba(address, &pvt->addr); pvt->timeout = -1; pvt->rfcomm_socket = -1; pvt->rfcomm_port = atoi(port); pvt->sco_socket = -1; pvt->monitor_thread = AST_PTHREADT_NULL; pvt->ring_sched_id = -1; pvt->has_sms = 1; /* setup the smoother */ if (!(pvt->smoother = ast_smoother_new(DEVICE_FRAME_SIZE))) { ast_log(LOG_ERROR, "Skipping device %s. Error setting up frame smoother.\n", cat); goto e_free_pvt; } /* setup the dsp */ if (!(pvt->dsp = ast_dsp_new())) { ast_log(LOG_ERROR, "Skipping device %s. Error setting up dsp for dtmf detection.\n", cat); goto e_free_smoother; } /* setup the scheduler */ if (!(pvt->sched = ast_sched_context_create())) { ast_log(LOG_ERROR, "Unable to create scheduler context for headset device\n"); goto e_free_dsp; } ast_dsp_set_features(pvt->dsp, DSP_FEATURE_DIGIT_DETECT); ast_dsp_set_digitmode(pvt->dsp, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF); for (v = ast_variable_browse(cfg, cat); v; v = v->next) { if (!strcasecmp(v->name, "type")) { if (!strcasecmp(v->value, "headset")) pvt->type = MBL_TYPE_HEADSET; else pvt->type = MBL_TYPE_PHONE; } else if (!strcasecmp(v->name, "context")) { ast_copy_string(pvt->context, v->value, sizeof(pvt->context)); } else if (!strcasecmp(v->name, "group")) { /* group is set to 0 if invalid */ pvt->group = atoi(v->value); } else if (!strcasecmp(v->name, "sms")) { pvt->has_sms = ast_true(v->value); } else if (!strcasecmp(v->name, "nocallsetup")) { pvt->no_callsetup = ast_true(v->value); if (pvt->no_callsetup) ast_debug(1, "Setting nocallsetup mode for device %s.\n", pvt->id); } else if (!strcasecmp(v->name, "blackberry")) { pvt->blackberry = ast_true(v->value); pvt->has_sms = 0; } } if (pvt->type == MBL_TYPE_PHONE) { if (!(pvt->hfp = ast_calloc(1, sizeof(*pvt->hfp)))) { ast_log(LOG_ERROR, "Skipping device %s. Error allocating memory.\n", pvt->id); goto e_free_sched; } pvt->hfp->owner = pvt; pvt->hfp->rport = pvt->rfcomm_port; pvt->hfp->nocallsetup = pvt->no_callsetup; } else { pvt->has_sms = 0; } AST_RWLIST_WRLOCK(&devices); AST_RWLIST_INSERT_HEAD(&devices, pvt, entry); AST_RWLIST_UNLOCK(&devices); ast_debug(1, "Loaded device %s.\n", pvt->id); return pvt; e_free_sched: ast_sched_context_destroy(pvt->sched); e_free_dsp: ast_dsp_free(pvt->dsp); e_free_smoother: ast_smoother_free(pvt->smoother); e_free_pvt: ast_free(pvt); e_return: return NULL; } static int mbl_load_config(void) { struct ast_config *cfg; const char *cat; struct ast_variable *v; struct ast_flags config_flags = { 0 }; cfg = ast_config_load(MBL_CONFIG, config_flags); if (!cfg) { cfg = ast_config_load(MBL_CONFIG_OLD, config_flags); } if (!cfg) return -1; /* parse [general] section */ for (v = ast_variable_browse(cfg, "general"); v; v = v->next) { if (!strcasecmp(v->name, "interval")) { if (!sscanf(v->value, "%d", &discovery_interval)) { ast_log(LOG_NOTICE, "error parsing 'interval' in general section, using default value\n"); } } } /* load adapters */ for (cat = ast_category_browse(cfg, NULL); cat; cat = ast_category_browse(cfg, cat)) { if (!strcasecmp(cat, "adapter")) { mbl_load_adapter(cfg, cat); } } if (AST_RWLIST_EMPTY(&adapters)) { ast_log(LOG_ERROR, "***********************************************************************\n" "No adapters could be loaded from the configuration file.\n" "Please review mobile.conf. See sample for details.\n" "***********************************************************************\n" ); ast_config_destroy(cfg); return -1; } /* now load devices */ for (cat = ast_category_browse(cfg, NULL); cat; cat = ast_category_browse(cfg, cat)) { if (strcasecmp(cat, "general") && strcasecmp(cat, "adapter")) { mbl_load_device(cfg, cat); } } ast_config_destroy(cfg); return 0; } /*! * \brief Check if the module is unloading. * \retval 0 not unloading * \retval 1 unloading */ static inline int check_unloading() { int res; ast_mutex_lock(&unload_mutex); res = unloading_flag; ast_mutex_unlock(&unload_mutex); return res; } /*! * \brief Set the unloading flag. */ static inline void set_unloading() { ast_mutex_lock(&unload_mutex); unloading_flag = 1; ast_mutex_unlock(&unload_mutex); } static int unload_module(void) { struct mbl_pvt *pvt; struct adapter_pvt *adapter; /* First, take us out of the channel loop */ ast_channel_unregister(&mbl_tech); /* Unregister the CLI & APP */ ast_cli_unregister_multiple(mbl_cli, sizeof(mbl_cli) / sizeof(mbl_cli[0])); ast_unregister_application(app_mblstatus); ast_unregister_application(app_mblsendsms); /* signal everyone we are unloading */ set_unloading(); /* Kill the discovery thread */ if (discovery_thread != AST_PTHREADT_NULL) { pthread_kill(discovery_thread, SIGURG); pthread_join(discovery_thread, NULL); } /* stop the sco listener threads */ AST_RWLIST_WRLOCK(&adapters); AST_RWLIST_TRAVERSE(&adapters, adapter, entry) { pthread_kill(adapter->sco_listener_thread, SIGURG); pthread_join(adapter->sco_listener_thread, NULL); } AST_RWLIST_UNLOCK(&adapters); /* Destroy the device list */ AST_RWLIST_WRLOCK(&devices); while ((pvt = AST_RWLIST_REMOVE_HEAD(&devices, entry))) { if (pvt->monitor_thread != AST_PTHREADT_NULL) { pthread_kill(pvt->monitor_thread, SIGURG); pthread_join(pvt->monitor_thread, NULL); } close(pvt->sco_socket); close(pvt->rfcomm_socket); msg_queue_flush(pvt); if (pvt->hfp) { ast_free(pvt->hfp); } ast_smoother_free(pvt->smoother); ast_dsp_free(pvt->dsp); ast_sched_context_destroy(pvt->sched); ast_free(pvt); } AST_RWLIST_UNLOCK(&devices); /* Destroy the adapter list */ AST_RWLIST_WRLOCK(&adapters); while ((adapter = AST_RWLIST_REMOVE_HEAD(&adapters, entry))) { close(adapter->sco_socket); io_context_destroy(adapter->io); io_context_destroy(adapter->accept_io); hci_close_dev(adapter->hci_socket); ast_free(adapter); } AST_RWLIST_UNLOCK(&adapters); if (sdp_session) sdp_close(sdp_session); mbl_tech.capabilities = ast_format_cap_destroy(mbl_tech.capabilities); return 0; } static int load_module(void) { int dev_id, s; if (!(mbl_tech.capabilities = ast_format_cap_alloc())) { return AST_MODULE_LOAD_DECLINE; } ast_format_set(&prefformat, DEVICE_FRAME_FORMAT, 0); ast_format_cap_add(mbl_tech.capabilities, &prefformat); /* Check if we have Bluetooth, no point loading otherwise... */ dev_id = hci_get_route(NULL); s = hci_open_dev(dev_id); if (dev_id < 0 || s < 0) { ast_log(LOG_ERROR, "No Bluetooth devices found. Not loading module.\n"); return AST_MODULE_LOAD_DECLINE; } hci_close_dev(s); if (mbl_load_config()) { ast_log(LOG_ERROR, "Errors reading config file %s. Not loading module.\n", MBL_CONFIG); return AST_MODULE_LOAD_DECLINE; } sdp_session = sdp_register(); /* Spin the discovery thread */ if (ast_pthread_create_background(&discovery_thread, NULL, do_discovery, NULL) < 0) { ast_log(LOG_ERROR, "Unable to create discovery thread.\n"); goto e_cleanup; } /* register our channel type */ if (ast_channel_register(&mbl_tech)) { ast_log(LOG_ERROR, "Unable to register channel class %s\n", "Mobile"); goto e_cleanup; } ast_cli_register_multiple(mbl_cli, sizeof(mbl_cli) / sizeof(mbl_cli[0])); ast_register_application(app_mblstatus, mbl_status_exec, mblstatus_synopsis, mblstatus_desc); ast_register_application(app_mblsendsms, mbl_sendsms_exec, mblsendsms_synopsis, mblsendsms_desc); return AST_MODULE_LOAD_SUCCESS; e_cleanup: if (sdp_session) sdp_close(sdp_session); return AST_MODULE_LOAD_FAILURE; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Bluetooth Mobile Device Channel Driver", .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, ); asterisk-11.7.0/addons/app_mysql.c0000644000175000007640000004374112006037127016775 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2004, Constantine Filin and Christos Ricudis * * Christos Ricudis * Constantine Filin * * 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 mysqlclient no deprecated func_odbc ***/ #include "asterisk.h" #include #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 )\n" " Set the connection timeout, in seconds.\n" " MYSQL(Connect connid dhhost[:dbport] dbuser dbpass dbname [dbcharset])\n" " Connects to a database. Arguments contain standard MySQL parameters\n" " passed to function mysql_real_connect. Optional parameter dbcharset\n" " defaults to 'latin1'. Connection identifer returned 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 utf8) 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 "app_mysql.conf" #define MYSQL_CONFIG_OLD "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 const 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 = ast_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); AST_APP_ARG(dbcharset); ); MYSQL *mysql; int timeout; const char *ctimeout; unsigned int port = 0; char *port_str; 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, "%30d", &timeout) == 1) { mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&timeout); } if(args.dbcharset && strlen(args.dbcharset) > 2){ char set_names[255]; char statement[512]; snprintf(set_names, sizeof(set_names), "SET NAMES %s", args.dbcharset); mysql_real_escape_string(mysql, statement, set_names, sizeof(set_names)); mysql_options(mysql, MYSQL_INIT_COMMAND, set_names); mysql_options(mysql, MYSQL_SET_CHARSET_NAME, args.dbcharset); } if ((port_str = strchr(args.dbhost, ':'))) { *port_str++ = '\0'; if (sscanf(port_str, "%u", &port) != 1) { ast_log(LOG_WARNING, "Invalid port: '%s'\n", port_str); port = 0; } } if (!mysql_real_connect(mysql, args.dbhost, args.dbuser, args.dbpass, args.dbname, port, 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, "%30d", &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, "%30d", &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 = NULL; ast_channel_lock(chan); 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_channel_unlock(chan); } 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) { /* Backwards compatibility ftw */ cfg = ast_config_load(MYSQL_CONFIG_OLD, config_flags); } 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"); asterisk-11.7.0/addons/res_config_mysql.c0000644000175000007640000017004012117715535020335 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999-2005, Digium, Inc. * * Mark Spencer - Asterisk Author * Matthew Boehm - MySQL RealTime Driver Author * * 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 */ /*** MODULEINFO mysqlclient no extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 382943 $") #include #include #include #include #include "asterisk/channel.h" #include "asterisk/logger.h" #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/options.h" #include "asterisk/cli.h" #include "asterisk/utils.h" #include "asterisk/threadstorage.h" #include "asterisk/strings.h" #define RES_CONFIG_MYSQL_CONF "res_config_mysql.conf" #define RES_CONFIG_MYSQL_CONF_OLD "res_mysql.conf" #define READHANDLE 0 #define WRITEHANDLE 1 #define ESCAPE_STRING(buf, var) \ do { \ struct ast_str *semi = ast_str_thread_get(&scratch2_buf, strlen(var) * 3 + 1); \ const char *chunk = var; \ ast_str_reset(semi); \ for (; *chunk; chunk++) { \ if (strchr(";^", *chunk)) { \ ast_str_append(&semi, 0, "^%02hhX", *chunk); \ } else { \ ast_str_append(&semi, 0, "%c", *chunk); \ } \ } \ if (ast_str_strlen(semi) * 2 + 1 > ast_str_size(buf)) { \ ast_str_make_space(&(buf), ast_str_strlen(semi) * 2 + 1); \ } \ mysql_real_escape_string(&dbh->handle, ast_str_buffer(buf), ast_str_buffer(semi), ast_str_strlen(semi)); \ } while (0) AST_THREADSTORAGE(sql_buf); AST_THREADSTORAGE(sql2_buf); AST_THREADSTORAGE(find_buf); AST_THREADSTORAGE(scratch_buf); AST_THREADSTORAGE(scratch2_buf); AST_THREADSTORAGE(modify_buf); AST_THREADSTORAGE(modify2_buf); AST_THREADSTORAGE(modify3_buf); enum requirements { RQ_WARN, RQ_CREATECLOSE, RQ_CREATECHAR }; struct mysql_conn { AST_RWLIST_ENTRY(mysql_conn) list; ast_mutex_t lock; MYSQL handle; char host[50]; char name[50]; char user[50]; char pass[50]; char sock[50]; char charset[50]; int port; int connected; time_t connect_time; enum requirements requirements; char unique_name[0]; }; struct columns { char *name; char *type; char *dflt; char null; int len; AST_LIST_ENTRY(columns) list; }; struct tables { ast_mutex_t lock; AST_LIST_HEAD_NOLOCK(mysql_columns, columns) columns; AST_LIST_ENTRY(tables) list; struct mysql_conn *database; char name[0]; }; static AST_LIST_HEAD_STATIC(mysql_tables, tables); static AST_RWLIST_HEAD_STATIC(databases, mysql_conn); static int parse_config(int reload); static int mysql_reconnect(struct mysql_conn *conn); static char *handle_cli_realtime_mysql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *handle_cli_realtime_mysql_cache(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static int load_mysql_config(struct ast_config *config, const char *category, struct mysql_conn *conn); static int require_mysql(const char *database, const char *tablename, va_list ap); static int internal_require(const char *database, const char *table, ...) attribute_sentinel; static struct ast_cli_entry cli_realtime_mysql_status[] = { AST_CLI_DEFINE(handle_cli_realtime_mysql_status, "Shows connection information for the MySQL RealTime driver"), AST_CLI_DEFINE(handle_cli_realtime_mysql_cache, "Shows cached tables within the MySQL realtime driver"), }; static struct mysql_conn *find_database(const char *database, int for_write) { char *whichdb; const char *ptr; struct mysql_conn *cur; if ((ptr = strchr(database, '/'))) { /* Multiple databases encoded within string */ if (for_write) { whichdb = ast_strdupa(ptr + 1); } else { whichdb = ast_alloca(ptr - database + 1); strncpy(whichdb, database, ptr - database); whichdb[ptr - database] = '\0'; } } else { whichdb = ast_strdupa(database); } AST_RWLIST_RDLOCK(&databases); AST_RWLIST_TRAVERSE(&databases, cur, list) { if (!strcmp(cur->unique_name, whichdb)) { ast_mutex_lock(&cur->lock); break; } } AST_RWLIST_UNLOCK(&databases); return cur; } #define release_database(a) ast_mutex_unlock(&(a)->lock) static int internal_require(const char *database, const char *table, ...) { va_list ap; int res; va_start(ap, table); res = require_mysql(database, table, ap); va_end(ap); return res; } static void destroy_table(struct tables *table) { struct columns *column; ast_mutex_lock(&table->lock); while ((column = AST_LIST_REMOVE_HEAD(&table->columns, list))) { ast_free(column); } ast_mutex_unlock(&table->lock); ast_mutex_destroy(&table->lock); ast_free(table); } static struct tables *find_table(const char *database, const char *tablename) { struct columns *column; struct tables *table; struct ast_str *sql = ast_str_thread_get(&find_buf, 30); char *fname, *ftype, *flen, *fdflt, *fnull; struct mysql_conn *dbh; MYSQL_RES *result; MYSQL_ROW row; if (!(dbh = find_database(database, 1))) { return NULL; } AST_LIST_LOCK(&mysql_tables); AST_LIST_TRAVERSE(&mysql_tables, table, list) { if (!strcasecmp(table->name, tablename)) { ast_mutex_lock(&table->lock); AST_LIST_UNLOCK(&mysql_tables); release_database(dbh); return table; } } /* Not found, scan the table */ ast_str_set(&sql, 0, "DESC %s", tablename); if (!mysql_reconnect(dbh)) { release_database(dbh); AST_LIST_UNLOCK(&mysql_tables); return NULL; } if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_ERROR, "Failed to query database '%s', table '%s' columns: %s\n", database, tablename, mysql_error(&dbh->handle)); release_database(dbh); AST_LIST_UNLOCK(&mysql_tables); return NULL; } if (!(table = ast_calloc(1, sizeof(*table) + strlen(tablename) + 1))) { ast_log(LOG_ERROR, "Unable to allocate memory for new table structure\n"); release_database(dbh); AST_LIST_UNLOCK(&mysql_tables); return NULL; } strcpy(table->name, tablename); /* SAFE */ table->database = dbh; ast_mutex_init(&table->lock); AST_LIST_HEAD_INIT_NOLOCK(&table->columns); if ((result = mysql_store_result(&dbh->handle))) { while ((row = mysql_fetch_row(result))) { fname = row[0]; ftype = row[1]; fnull = row[2]; fdflt = row[4]; ast_verb(4, "Found column '%s' of type '%s'\n", fname, ftype); if (fdflt == NULL) { fdflt = ""; } if (!(column = ast_calloc(1, sizeof(*column) + strlen(fname) + strlen(ftype) + strlen(fdflt) + 3))) { ast_log(LOG_ERROR, "Unable to allocate column element %s for %s\n", fname, tablename); destroy_table(table); release_database(dbh); AST_LIST_UNLOCK(&mysql_tables); return NULL; } if ((flen = strchr(ftype, '('))) { sscanf(flen, "(%30d)", &column->len); } else { /* Columns like dates, times, and timestamps don't have a length */ column->len = -1; } column->name = (char *)column + sizeof(*column); column->type = (char *)column + sizeof(*column) + strlen(fname) + 1; column->dflt = (char *)column + sizeof(*column) + strlen(fname) + 1 + strlen(ftype) + 1; strcpy(column->name, fname); strcpy(column->type, ftype); strcpy(column->dflt, fdflt); column->null = (strcmp(fnull, "YES") == 0 ? 1 : 0); AST_LIST_INSERT_TAIL(&table->columns, column, list); } mysql_free_result(result); } AST_LIST_INSERT_TAIL(&mysql_tables, table, list); ast_mutex_lock(&table->lock); AST_LIST_UNLOCK(&mysql_tables); release_database(dbh); return table; } static void release_table(struct tables *table) { if (table) { ast_mutex_unlock(&table->lock); } } static struct columns *find_column(struct tables *table, const char *colname) { struct columns *column; AST_LIST_TRAVERSE(&table->columns, column, list) { if (strcmp(column->name, colname) == 0) { break; } } return column; } static char *decode_chunk(char *chunk) { char *orig = chunk; for (; *chunk; chunk++) { if (*chunk == '^' && strchr("0123456789ABCDEFabcdef", chunk[1]) && strchr("0123456789ABCDEFabcdef", chunk[2])) { sscanf(chunk + 1, "%02hhX", chunk); memmove(chunk + 1, chunk + 3, strlen(chunk + 3) + 1); } } return orig; } static struct ast_variable *realtime_mysql(const char *database, const char *table, va_list ap) { struct mysql_conn *dbh; MYSQL_RES *result; MYSQL_ROW row; MYSQL_FIELD *fields; int numFields, i; struct ast_str *sql = ast_str_thread_get(&sql_buf, 16); struct ast_str *buf = ast_str_thread_get(&scratch_buf, 16); char *stringp; char *chunk; char *op; const char *newparam, *newval; struct ast_variable *var=NULL, *prev=NULL; if (!(dbh = find_database(database, 0))) { ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: %s (check res_mysql.conf)\n", database); return NULL; } if (!table) { ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n"); release_database(dbh); return NULL; } /* Get the first parameter and first value in our list of passed paramater/value pairs */ if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *))) { ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n"); release_database(dbh); return NULL; } /* Must connect to the server before anything else, as the escape function requires the mysql handle. */ if (!mysql_reconnect(dbh)) { release_database(dbh); return NULL; } /* Create the first part of the query using the first parameter/value pairs we just extracted If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */ if (!strchr(newparam, ' ')) op = " ="; else op = ""; ESCAPE_STRING(buf, newval); ast_str_set(&sql, 0, "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, ast_str_buffer(buf)); while ((newparam = va_arg(ap, const char *))) { newval = va_arg(ap, const char *); if (!strchr(newparam, ' ')) op = " ="; else op = ""; ESCAPE_STRING(buf, newval); ast_str_append(&sql, 0, " AND %s%s '%s'", newparam, op, ast_str_buffer(buf)); } ast_debug(1, "MySQL RealTime: Retrieve SQL: %s\n", ast_str_buffer(sql)); /* Execution. */ if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database: %s\n", mysql_error(&dbh->handle)); release_database(dbh); return NULL; } if ((result = mysql_store_result(&dbh->handle))) { numFields = mysql_num_fields(result); fields = mysql_fetch_fields(result); while ((row = mysql_fetch_row(result))) { for (i = 0; i < numFields; i++) { /* Encode NULL values separately from blank values, for the Realtime API */ if (row[i] == NULL) { row[i] = ""; } else if (ast_strlen_zero(row[i])) { row[i] = " "; } for (stringp = row[i], chunk = strsep(&stringp, ";"); chunk; chunk = strsep(&stringp, ";")) { if (prev) { if ((prev->next = ast_variable_new(fields[i].name, decode_chunk(chunk), ""))) { prev = prev->next; } } else { prev = var = ast_variable_new(fields[i].name, decode_chunk(chunk), ""); } } } } } else { ast_debug(1, "MySQL RealTime: Could not find any rows in table %s.\n", table); } release_database(dbh); mysql_free_result(result); return var; } static struct ast_config *realtime_multi_mysql(const char *database, const char *table, va_list ap) { struct mysql_conn *dbh; MYSQL_RES *result; MYSQL_ROW row; MYSQL_FIELD *fields; int numFields, i; struct ast_str *sql = ast_str_thread_get(&sql_buf, 16); struct ast_str *buf = ast_str_thread_get(&scratch_buf, 16); const char *initfield = NULL; char *stringp; char *chunk; char *op; const char *newparam, *newval; struct ast_variable *var = NULL; struct ast_config *cfg = NULL; struct ast_category *cat = NULL; if (!(dbh = find_database(database, 0))) { ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: '%s' (check res_mysql.conf)\n", database); return NULL; } if (!table) { ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n"); release_database(dbh); return NULL; } if (!(cfg = ast_config_new())) { /* If I can't alloc memory at this point, why bother doing anything else? */ ast_log(LOG_WARNING, "Out of memory!\n"); release_database(dbh); return NULL; } /* Get the first parameter and first value in our list of passed paramater/value pairs */ if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *))) { ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n"); ast_config_destroy(cfg); release_database(dbh); return NULL; } initfield = ast_strdupa(newparam); if ((op = strchr(initfield, ' '))) { *op = '\0'; } /* Must connect to the server before anything else, as the escape function requires the mysql handle. */ if (!mysql_reconnect(dbh)) { release_database(dbh); ast_config_destroy(cfg); return NULL; } /* Create the first part of the query using the first parameter/value pairs we just extracted If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */ if (!strchr(newparam, ' ')) op = " ="; else op = ""; ESCAPE_STRING(buf, newval); ast_str_set(&sql, 0, "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, ast_str_buffer(buf)); while ((newparam = va_arg(ap, const char *))) { newval = va_arg(ap, const char *); if (!strchr(newparam, ' ')) op = " ="; else op = ""; ESCAPE_STRING(buf, newval); ast_str_append(&sql, 0, " AND %s%s '%s'", newparam, op, ast_str_buffer(buf)); } if (initfield) { ast_str_append(&sql, 0, " ORDER BY %s", initfield); } ast_debug(1, "MySQL RealTime: Retrieve SQL: %s\n", ast_str_buffer(sql)); /* Execution. */ if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database: %s\n", mysql_error(&dbh->handle)); release_database(dbh); ast_config_destroy(cfg); return NULL; } if ((result = mysql_store_result(&dbh->handle))) { numFields = mysql_num_fields(result); fields = mysql_fetch_fields(result); while ((row = mysql_fetch_row(result))) { var = NULL; cat = ast_category_new("", "", -1); if (!cat) { ast_log(LOG_WARNING, "Out of memory!\n"); continue; } for (i = 0; i < numFields; i++) { if (ast_strlen_zero(row[i])) continue; for (stringp = row[i], chunk = strsep(&stringp, ";"); chunk; chunk = strsep(&stringp, ";")) { if (chunk && !ast_strlen_zero(decode_chunk(ast_strip(chunk)))) { if (initfield && !strcmp(initfield, fields[i].name)) { ast_category_rename(cat, chunk); } var = ast_variable_new(fields[i].name, chunk, ""); ast_variable_append(cat, var); } } } ast_category_append(cfg, cat); } } else { ast_debug(1, "MySQL RealTime: Could not find any rows in table %s.\n", table); } release_database(dbh); mysql_free_result(result); return cfg; } static int update_mysql(const char *database, const char *tablename, const char *keyfield, const char *lookup, va_list ap) { struct mysql_conn *dbh; my_ulonglong numrows; const char *newparam, *newval; struct ast_str *sql = ast_str_thread_get(&sql_buf, 100), *buf = ast_str_thread_get(&scratch_buf, 100); struct tables *table; struct columns *column = NULL; if (!(dbh = find_database(database, 1))) { ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: '%s' (check res_mysql.conf)\n", database); return -1; } if (!tablename) { ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n"); release_database(dbh); return -1; } if (!(table = find_table(database, tablename))) { ast_log(LOG_ERROR, "Table '%s' does not exist!!\n", tablename); release_database(dbh); return -1; } if (!(column = find_column(table, keyfield))) { ast_log(LOG_ERROR, "MySQL RealTime: Updating on column '%s', but that column does not exist within the table '%s' (db '%s')!\n", keyfield, tablename, database); release_table(table); release_database(dbh); return -1; } /* Get the first parameter and first value in our list of passed paramater/value pairs */ if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *))) { ast_log(LOG_WARNING, "MySQL RealTime: Realtime update requires at least 1 parameter and 1 value to update.\n"); release_table(table); release_database(dbh); return -1; } /* Check that the column exists in the table */ if (!(column = find_column(table, newparam))) { ast_log(LOG_ERROR, "MySQL RealTime: Updating column '%s', but that column does not exist within the table '%s' (first pair MUST exist)!\n", newparam, tablename); release_table(table); release_database(dbh); return -1; } /* Must connect to the server before anything else, as the escape function requires the mysql handle. */ if (!mysql_reconnect(dbh)) { release_table(table); release_database(dbh); return -1; } /* Create the first part of the query using the first parameter/value pairs we just extracted If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */ ESCAPE_STRING(buf, newval); ast_str_set(&sql, 0, "UPDATE %s SET `%s` = '%s'", tablename, newparam, ast_str_buffer(buf)); /* If the column length isn't long enough, give a chance to lengthen it. */ if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) { internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL); } while ((newparam = va_arg(ap, const char *))) { newval = va_arg(ap, const char *); /* If the column is not within the table, then skip it */ if (!(column = find_column(table, newparam))) { ast_log(LOG_WARNING, "Attempted to update column '%s' in table '%s', but column does not exist!\n", newparam, tablename); continue; } ESCAPE_STRING(buf, newval); ast_str_append(&sql, 0, ", `%s` = '%s'", newparam, ast_str_buffer(buf)); /* If the column length isn't long enough, give a chance to lengthen it. */ if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) { internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL); } } ESCAPE_STRING(buf, lookup); ast_str_append(&sql, 0, " WHERE `%s` = '%s'", keyfield, ast_str_buffer(buf)); ast_debug(1, "MySQL RealTime: Update SQL: %s\n", ast_str_buffer(sql)); /* Execution. */ if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to update database: %s\n", mysql_error(&dbh->handle)); release_table(table); release_database(dbh); return -1; } numrows = mysql_affected_rows(&dbh->handle); release_table(table); release_database(dbh); ast_debug(1, "MySQL RealTime: Updated %llu rows on table: %s\n", numrows, tablename); /* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html * An integer greater than zero indicates the number of rows affected * Zero indicates that no records were updated * -1 indicates that the query returned an error (although, if the query failed, it should have been caught above.) */ return (int)numrows; } static int update2_mysql(const char *database, const char *tablename, va_list ap) { struct mysql_conn *dbh; my_ulonglong numrows; int first; const char *newparam, *newval; struct ast_str *sql = ast_str_thread_get(&sql_buf, 100), *buf = ast_str_thread_get(&scratch_buf, 100); struct ast_str *where = ast_str_thread_get(&sql2_buf, 100); struct tables *table; struct columns *column = NULL; if (!tablename) { ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n"); return -1; } if (!(dbh = find_database(database, 1))) { ast_log(LOG_ERROR, "Invalid database specified: %s\n", database); return -1; } if (!(table = find_table(database, tablename))) { ast_log(LOG_ERROR, "Table '%s' does not exist!!\n", tablename); release_database(dbh); return -1; } if (!sql || !buf || !where) { release_database(dbh); release_table(table); return -1; } ast_str_set(&sql, 0, "UPDATE %s SET", tablename); ast_str_set(&where, 0, "WHERE"); /* Must connect to the server before anything else, as the escape function requires the mysql handle. */ if (!mysql_reconnect(dbh)) { release_table(table); release_database(dbh); return -1; } first = 1; while ((newparam = va_arg(ap, const char *))) { if (!(column = find_column(table, newparam))) { ast_log(LOG_ERROR, "Updating on column '%s', but that column does not exist within the table '%s'!\n", newparam, tablename); release_table(table); release_database(dbh); return -1; } if (!(newval = va_arg(ap, const char *))) { ast_log(LOG_ERROR, "Invalid arguments: no value specified for column '%s' on '%s@%s'\n", newparam, tablename, database); release_table(table); release_database(dbh); return -1; } ESCAPE_STRING(buf, newval); ast_str_append(&where, 0, "%s `%s` = '%s'", first ? "" : " AND", newparam, ast_str_buffer(buf)); first = 0; /* If the column length isn't long enough, give a chance to lengthen it. */ if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) { internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL); } } first = 1; while ((newparam = va_arg(ap, const char *))) { if (!(newval = va_arg(ap, const char *))) { ast_log(LOG_ERROR, "Invalid arguments: no value specified for column '%s' on '%s@%s'\n", newparam, tablename, database); release_table(table); release_database(dbh); return -1; } /* If the column is not within the table, then skip it */ if (!(column = find_column(table, newparam))) { ast_log(LOG_WARNING, "Attempted to update column '%s' in table '%s', but column does not exist!\n", newparam, tablename); continue; } ESCAPE_STRING(buf, newval); ast_str_append(&sql, 0, "%s `%s` = '%s'", first ? "" : ",", newparam, ast_str_buffer(buf)); first = 0; /* If the column length isn't long enough, give a chance to lengthen it. */ if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) { internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL); } } release_table(table); ast_str_append(&sql, 0, " %s", ast_str_buffer(where)); ast_debug(1, "MySQL RealTime: Update SQL: %s\n", ast_str_buffer(sql)); /* Execution. */ if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to update database: %s\n", mysql_error(&dbh->handle)); release_table(table); release_database(dbh); return -1; } numrows = mysql_affected_rows(&dbh->handle); release_database(dbh); ast_debug(1, "MySQL RealTime: Updated %llu rows on table: %s\n", numrows, tablename); /* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html * An integer greater than zero indicates the number of rows affected * Zero indicates that no records were updated * -1 indicates that the query returned an error (although, if the query failed, it should have been caught above.) */ return (int)numrows; } static int store_mysql(const char *database, const char *table, va_list ap) { struct mysql_conn *dbh; my_ulonglong insertid; struct ast_str *sql = ast_str_thread_get(&sql_buf, 16); struct ast_str *sql2 = ast_str_thread_get(&sql2_buf, 16); struct ast_str *buf = ast_str_thread_get(&scratch_buf, 16); const char *newparam, *newval; if (!(dbh = find_database(database, 1))) { ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: '%s' (check res_mysql.conf)\n", database); return -1; } if (!table) { ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n"); release_database(dbh); return -1; } /* Get the first parameter and first value in our list of passed paramater/value pairs */ if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *))) { ast_log(LOG_WARNING, "MySQL RealTime: Realtime storage requires at least 1 parameter and 1 value to search on.\n"); release_database(dbh); return -1; } /* Must connect to the server before anything else, as the escape function requires the mysql handle. */ if (!mysql_reconnect(dbh)) { release_database(dbh); return -1; } /* Create the first part of the query using the first parameter/value pairs we just extracted If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */ ESCAPE_STRING(buf, newval); ast_str_set(&sql, 0, "INSERT INTO %s (`%s`", table, newparam); ast_str_set(&sql2, 0, ") VALUES ('%s'", ast_str_buffer(buf)); internal_require(database, table, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL); while ((newparam = va_arg(ap, const char *))) { if ((newval = va_arg(ap, const char *))) { ESCAPE_STRING(buf, newval); } else { ast_str_reset(buf); } if (internal_require(database, table, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL) == 0) { ast_str_append(&sql, 0, ", `%s`", newparam); ast_str_append(&sql2, 0, ", '%s'", ast_str_buffer(buf)); } } ast_str_append(&sql, 0, "%s)", ast_str_buffer(sql2)); ast_debug(1,"MySQL RealTime: Insert SQL: %s\n", ast_str_buffer(sql)); /* Execution. */ if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to insert into database: %s\n", mysql_error(&dbh->handle)); release_database(dbh); return -1; } /*!\note The return value is non-portable and may change in future versions. */ insertid = mysql_insert_id(&dbh->handle); release_database(dbh); ast_debug(1, "MySQL RealTime: row inserted on table: %s, id: %llu\n", table, insertid); /* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html * An integer greater than zero indicates the number of rows affected * Zero indicates that no records were updated * -1 indicates that the query returned an error (although, if the query failed, it should have been caught above.) */ return (int)insertid; } static int destroy_mysql(const char *database, const char *table, const char *keyfield, const char *lookup, va_list ap) { struct mysql_conn *dbh; my_ulonglong numrows; struct ast_str *sql = ast_str_thread_get(&sql_buf, 16); struct ast_str *buf = ast_str_thread_get(&scratch_buf, 16); const char *newparam, *newval; if (!(dbh = find_database(database, 1))) { ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: '%s' (check res_mysql.conf)\n", database); return -1; } if (!table) { ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n"); release_database(dbh); return -1; } /* Get the first parameter and first value in our list of passed paramater/value pairs */ /* newparam = va_arg(ap, const char *); newval = va_arg(ap, const char *);*/ if (ast_strlen_zero(keyfield) || ast_strlen_zero(lookup)) { ast_log(LOG_WARNING, "MySQL RealTime: Realtime destroying requires at least 1 parameter and 1 value to search on.\n"); release_database(dbh); return -1; } /* Must connect to the server before anything else, as the escape function requires the mysql handle. */ if (!mysql_reconnect(dbh)) { release_database(dbh); return -1; } /* Create the first part of the query using the first parameter/value pairs we just extracted If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */ ESCAPE_STRING(buf, lookup); ast_str_set(&sql, 0, "DELETE FROM %s WHERE `%s` = '%s'", table, keyfield, ast_str_buffer(buf)); while ((newparam = va_arg(ap, const char *))) { newval = va_arg(ap, const char *); ESCAPE_STRING(buf, newval); ast_str_append(&sql, 0, " AND `%s` = '%s'", newparam, ast_str_buffer(buf)); } ast_debug(1, "MySQL RealTime: Delete SQL: %s\n", ast_str_buffer(sql)); /* Execution. */ if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to delete from database: %s\n", mysql_error(&dbh->handle)); release_database(dbh); return -1; } numrows = mysql_affected_rows(&dbh->handle); release_database(dbh); ast_debug(1, "MySQL RealTime: Deleted %llu rows on table: %s\n", numrows, table); /* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html * An integer greater than zero indicates the number of rows affected * Zero indicates that no records were updated * -1 indicates that the query returned an error (although, if the query failed, it should have been caught above.) */ return (int)numrows; } static struct ast_config *config_mysql(const char *database, const char *table, const char *file, struct ast_config *cfg, struct ast_flags config_flags, const char *unused, const char *who_asked) { struct mysql_conn *dbh; MYSQL_RES *result; MYSQL_ROW row; my_ulonglong num_rows; struct ast_variable *new_v; struct ast_category *cur_cat = NULL; struct ast_str *sql = ast_str_thread_get(&sql_buf, 200); char last[80] = ""; int last_cat_metric = 0; ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); if (!file || !strcmp(file, RES_CONFIG_MYSQL_CONF)) { ast_log(LOG_WARNING, "MySQL RealTime: Cannot configure myself.\n"); return NULL; } if (!(dbh = find_database(database, 0))) { ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: '%s' (check res_mysql.conf)\n", database); return NULL; } ast_str_set(&sql, 0, "SELECT category, var_name, var_val, cat_metric FROM %s WHERE filename='%s' and commented=0 ORDER BY filename, category, cat_metric desc, var_metric asc, var_name, var_val, id", table, file); ast_debug(1, "MySQL RealTime: Static SQL: %s\n", ast_str_buffer(sql)); /* We now have our complete statement; Lets connect to the server and execute it. */ if (!mysql_reconnect(dbh)) { return NULL; } if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n"); ast_debug(1, "MySQL RealTime: Query: %s\n", ast_str_buffer(sql)); ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbh->handle)); release_database(dbh); return NULL; } if ((result = mysql_store_result(&dbh->handle))) { num_rows = mysql_num_rows(result); ast_debug(1, "MySQL RealTime: Found %llu rows.\n", num_rows); /* There might exist a better way to access the column names other than counting, * but I believe that would require another loop that we don't need. */ while ((row = mysql_fetch_row(result))) { if (!strcmp(row[1], "#include")) { if (!ast_config_internal_load(row[2], cfg, config_flags, "", who_asked)) { mysql_free_result(result); release_database(dbh); return NULL; } continue; } if (strcmp(last, row[0]) || last_cat_metric != atoi(row[3])) { if (!(cur_cat = ast_category_new(row[0], "", -1))) { ast_log(LOG_WARNING, "Out of memory!\n"); break; } strcpy(last, row[0]); last_cat_metric = atoi(row[3]); ast_category_append(cfg, cur_cat); } new_v = ast_variable_new(row[1], row[2], ""); if (cur_cat) ast_variable_append(cur_cat, new_v); } } else { ast_log(LOG_WARNING, "MySQL RealTime: Could not find config '%s' in database.\n", file); } mysql_free_result(result); release_database(dbh); return cfg; } static int unload_mysql(const char *database, const char *tablename) { struct tables *cur; AST_LIST_LOCK(&mysql_tables); AST_LIST_TRAVERSE_SAFE_BEGIN(&mysql_tables, cur, list) { if (strcmp(cur->name, tablename) == 0) { AST_LIST_REMOVE_CURRENT(list); destroy_table(cur); break; } } AST_LIST_TRAVERSE_SAFE_END AST_LIST_UNLOCK(&mysql_tables); return cur ? 0 : -1; } static int modify_mysql(const char *database, const char *tablename, struct columns *column, require_type type, int len) { /*!\note Cannot use ANY of the same scratch space as is used in other functions, as this one is interspersed. */ struct ast_str *sql = ast_str_thread_get(&modify_buf, 100), *escbuf = ast_str_thread_get(&modify2_buf, 100); struct ast_str *typestr = ast_str_thread_get(&modify3_buf, 30); int waschar = strncasecmp(column->type, "char", 4) == 0 ? 1 : 0; int wasvarchar = strncasecmp(column->type, "varchar", 7) == 0 ? 1 : 0; int res = 0; struct mysql_conn *dbh; if (!(dbh = find_database(database, 1))) { return -1; } do { if (type == RQ_CHAR || waschar || wasvarchar) { if (wasvarchar) { ast_str_set(&typestr, 0, "VARCHAR(%d)", len); } else { ast_str_set(&typestr, 0, "CHAR(%d)", len); } } else if (type == RQ_UINTEGER1) { ast_str_set(&typestr, 0, "tinyint(3) unsigned"); } else if (type == RQ_INTEGER1) { ast_str_set(&typestr, 0, "tinyint(4)"); } else if (type == RQ_UINTEGER2) { ast_str_set(&typestr, 0, "smallint(5) unsigned"); } else if (type == RQ_INTEGER2) { ast_str_set(&typestr, 0, "smallint(6)"); } else if (type == RQ_UINTEGER3) { ast_str_set(&typestr, 0, "mediumint(8) unsigned"); } else if (type == RQ_INTEGER3) { ast_str_set(&typestr, 0, "mediumint(8)"); } else if (type == RQ_UINTEGER4) { ast_str_set(&typestr, 0, "int(10) unsigned"); } else if (type == RQ_INTEGER4) { ast_str_set(&typestr, 0, "int(11)"); } else if (type == RQ_UINTEGER8) { ast_str_set(&typestr, 0, "bigint(19) unsigned"); } else if (type == RQ_INTEGER8) { ast_str_set(&typestr, 0, "bigint(20)"); } else if (type == RQ_DATETIME) { ast_str_set(&typestr, 0, "datetime"); } else if (type == RQ_DATE) { ast_str_set(&typestr, 0, "date"); } else if (type == RQ_FLOAT) { ast_str_set(&typestr, 0, "FLOAT(%d,2)", len); } else { ast_log(LOG_ERROR, "Unknown type (should NEVER happen)\n"); res = -1; break; } ast_str_set(&sql, 0, "ALTER TABLE %s MODIFY `%s` %s", tablename, column->name, ast_str_buffer(typestr)); if (!column->null) { ast_str_append(&sql, 0, " NOT NULL"); } if (!ast_strlen_zero(column->dflt)) { ESCAPE_STRING(escbuf, column->dflt); ast_str_append(&sql, 0, " DEFAULT '%s'", ast_str_buffer(escbuf)); } if (!mysql_reconnect(dbh)) { ast_log(LOG_ERROR, "Unable to add column: %s\n", ast_str_buffer(sql)); res = -1; break; } /* Execution. */ if (mysql_real_query(&dbh->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to modify database: %s\n", mysql_error(&dbh->handle)); ast_debug(1, "MySQL RealTime: Query: %s\n", ast_str_buffer(sql)); res = -1; } } while (0); release_database(dbh); return res; } #define PICK_WHICH_ALTER_ACTION(stringtype) \ if (table->database->requirements == RQ_WARN) { \ ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' may not be large enough for " \ "the required data length: %d (detected stringtype)\n", \ tablename, database, column->name, size); \ res = -1; \ } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) { \ table_altered = 1; \ } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) { \ table_altered = 1; \ } else { \ res = -1; \ } static int require_mysql(const char *database, const char *tablename, va_list ap) { struct columns *column; struct tables *table = find_table(database, tablename); char *elm; int type, size, res = 0, table_altered = 0; if (!table) { ast_log(LOG_WARNING, "Table %s not found in database. This table should exist if you're using realtime.\n", tablename); return -1; } while ((elm = va_arg(ap, char *))) { type = va_arg(ap, require_type); size = va_arg(ap, int); AST_LIST_TRAVERSE(&table->columns, column, list) { if (strcmp(column->name, elm) == 0) { /* Char can hold anything, as long as it is large enough */ if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) { if ((size > column->len) && column->len != -1) { if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Realtime table %s@%s: Column '%s' should be at least %d long, but is only %d long.\n", database, tablename, column->name, size, column->len); res = -1; } else if (modify_mysql(database, tablename, column, type, size) == 0) { table_altered = 1; } else { res = -1; } } } else if (strcasestr(column->type, "unsigned")) { if (!ast_rq_is_int(type)) { if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' cannot be type '%s' (need %s)\n", database, tablename, column->name, column->type, type == RQ_CHAR ? "char" : type == RQ_FLOAT ? "float" : type == RQ_DATETIME ? "datetime" : type == RQ_DATE ? "date" : "a rather stiff drink"); res = -1; } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) { table_altered = 1; } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) { table_altered = 1; } else { res = -1; } } else if (strncasecmp(column->type, "tinyint", 1) == 0) { if (type != RQ_UINTEGER1) { PICK_WHICH_ALTER_ACTION(unsigned tinyint) } } else if (strncasecmp(column->type, "smallint", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2) { PICK_WHICH_ALTER_ACTION(unsigned smallint) } } else if (strncasecmp(column->type, "mediumint", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2 && type != RQ_INTEGER2 && type != RQ_UINTEGER3) { PICK_WHICH_ALTER_ACTION(unsigned mediumint) } } else if (strncasecmp(column->type, "int", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2 && type != RQ_INTEGER2 && type != RQ_UINTEGER3 && type != RQ_INTEGER3 && type != RQ_UINTEGER4) { PICK_WHICH_ALTER_ACTION(unsigned int) } } else if (strncasecmp(column->type, "bigint", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2 && type != RQ_INTEGER2 && type != RQ_UINTEGER3 && type != RQ_INTEGER3 && type != RQ_UINTEGER4 && type != RQ_INTEGER4 && type != RQ_UINTEGER8) { PICK_WHICH_ALTER_ACTION(unsigned bigint) } } } else if (strcasestr(column->type, "int")) { if (!ast_rq_is_int(type)) { if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' cannot be type '%s' (need %s)\n", database, tablename, column->name, column->type, type == RQ_CHAR ? "char" : type == RQ_FLOAT ? "float" : type == RQ_DATETIME ? "datetime" : type == RQ_DATE ? "date" : "to get a life, rather than writing silly error messages"); res = -1; } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) { table_altered = 1; } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) { table_altered = 1; } else { res = -1; } } else if (strncasecmp(column->type, "tinyint", 1) == 0) { if (type != RQ_INTEGER1) { PICK_WHICH_ALTER_ACTION(tinyint) } } else if (strncasecmp(column->type, "smallint", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_INTEGER2) { PICK_WHICH_ALTER_ACTION(smallint) } } else if (strncasecmp(column->type, "mediumint", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2 && type != RQ_INTEGER2 && type != RQ_INTEGER3) { PICK_WHICH_ALTER_ACTION(mediumint) } } else if (strncasecmp(column->type, "int", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2 && type != RQ_INTEGER2 && type != RQ_UINTEGER3 && type != RQ_INTEGER3 && type != RQ_INTEGER4) { PICK_WHICH_ALTER_ACTION(int) } } else if (strncasecmp(column->type, "bigint", 1) == 0) { if (type != RQ_UINTEGER1 && type != RQ_INTEGER1 && type != RQ_UINTEGER2 && type != RQ_INTEGER2 && type != RQ_UINTEGER3 && type != RQ_INTEGER3 && type != RQ_UINTEGER4 && type != RQ_INTEGER4 && type != RQ_INTEGER8) { PICK_WHICH_ALTER_ACTION(bigint) } } } else if (strncmp(column->type, "float", 5) == 0 && !ast_rq_is_int(type) && type != RQ_FLOAT) { if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type); res = -1; } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) { table_altered = 1; } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) { table_altered = 1; } else { res = -1; } } else if ((strncmp(column->type, "datetime", 8) == 0 || strncmp(column->type, "timestamp", 9) == 0) && type != RQ_DATETIME) { if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type); res = -1; } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) { table_altered = 1; } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) { table_altered = 1; } else { res = -1; } } else if ((strncmp(column->type, "date", 4) == 0) && type != RQ_DATE) { if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Realtime table %s@%s: Column %s cannot be a %s\n", tablename, database, column->name, column->type); res = -1; } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) { table_altered = 1; } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) { table_altered = 1; } else { res = -1; } } else { /* Other, possibly unsupported types? */ if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Possibly unsupported column type '%s' on column '%s'\n", column->type, column->name); res = -1; } else if (table->database->requirements == RQ_CREATECLOSE && modify_mysql(database, tablename, column, type, size) == 0) { table_altered = 1; } else if (table->database->requirements == RQ_CREATECHAR && modify_mysql(database, tablename, column, RQ_CHAR, size) == 0) { table_altered = 1; } else { } } break; } } if (!column) { if (table->database->requirements == RQ_WARN) { ast_log(LOG_WARNING, "Table %s requires a column '%s' of size '%d', but no such column exists.\n", tablename, elm, size); } else { struct ast_str *sql = ast_str_thread_get(&modify_buf, 100), *fieldtype = ast_str_thread_get(&modify3_buf, 16); if (table->database->requirements == RQ_CREATECHAR || type == RQ_CHAR) { ast_str_set(&fieldtype, 0, "CHAR(%d)", size); } else if (type == RQ_UINTEGER1 || type == RQ_UINTEGER2 || type == RQ_UINTEGER3 || type == RQ_UINTEGER4 || type == RQ_UINTEGER8) { if (type == RQ_UINTEGER1) { ast_str_set(&fieldtype, 0, "TINYINT(3) UNSIGNED"); } else if (type == RQ_UINTEGER2) { ast_str_set(&fieldtype, 0, "SMALLINT(5) UNSIGNED"); } else if (type == RQ_UINTEGER3) { ast_str_set(&fieldtype, 0, "MEDIUMINT(8) UNSIGNED"); } else if (type == RQ_UINTEGER4) { ast_str_set(&fieldtype, 0, "INT(10) UNSIGNED"); } else if (type == RQ_UINTEGER8) { ast_str_set(&fieldtype, 0, "BIGINT(20) UNSIGNED"); } else { ast_log(LOG_WARNING, "Somebody should check this code for a rather large bug... it's about to squash Tokyo.\n"); continue; } } else if (ast_rq_is_int(type)) { if (type == RQ_INTEGER1) { ast_str_set(&fieldtype, 0, "TINYINT(3)"); } else if (type == RQ_INTEGER2) { ast_str_set(&fieldtype, 0, "SMALLINT(5)"); } else if (type == RQ_INTEGER3) { ast_str_set(&fieldtype, 0, "MEDIUMINT(8)"); } else if (type == RQ_INTEGER4) { ast_str_set(&fieldtype, 0, "INT(10)"); } else if (type == RQ_INTEGER8) { ast_str_set(&fieldtype, 0, "BIGINT(20)"); } else { ast_log(LOG_WARNING, "Somebody should check this code for a rather large bug... it's about to eat Cincinnati.\n"); continue; } } else if (type == RQ_FLOAT) { ast_str_set(&fieldtype, 0, "FLOAT"); } else if (type == RQ_DATE) { ast_str_set(&fieldtype, 0, "DATE"); } else if (type == RQ_DATETIME) { ast_str_set(&fieldtype, 0, "DATETIME"); } else { continue; } ast_str_set(&sql, 0, "ALTER TABLE %s ADD COLUMN %s %s", tablename, elm, ast_str_buffer(fieldtype)); ast_mutex_lock(&table->database->lock); if (!mysql_reconnect(table->database)) { ast_mutex_unlock(&table->database->lock); ast_log(LOG_ERROR, "Unable to add column: %s\n", ast_str_buffer(sql)); continue; } /* Execution. */ if (mysql_real_query(&table->database->handle, ast_str_buffer(sql), ast_str_strlen(sql))) { ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n"); ast_debug(1, "MySQL RealTime: Query: %s\n", ast_str_buffer(sql)); ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&table->database->handle)); } else { table_altered = 1; } } } } release_table(table); /* If we altered the table, we must refresh the cache */ if (table_altered) { unload_mysql(database, tablename); release_table(find_table(database, tablename)); } return res; } static struct ast_config_engine mysql_engine = { .name = "mysql", .load_func = config_mysql, .realtime_func = realtime_mysql, .realtime_multi_func = realtime_multi_mysql, .store_func = store_mysql, .destroy_func = destroy_mysql, .update_func = update_mysql, .update2_func = update2_mysql, .require_func = require_mysql, .unload_func = unload_mysql, }; static int load_module(void) { parse_config(0); ast_config_engine_register(&mysql_engine); ast_verb(2, "MySQL RealTime driver loaded.\n"); ast_cli_register_multiple(cli_realtime_mysql_status, sizeof(cli_realtime_mysql_status) / sizeof(struct ast_cli_entry)); return 0; } static int unload_module(void) { struct mysql_conn *cur; struct tables *table; ast_cli_unregister_multiple(cli_realtime_mysql_status, sizeof(cli_realtime_mysql_status) / sizeof(struct ast_cli_entry)); ast_config_engine_deregister(&mysql_engine); ast_verb(2, "MySQL RealTime unloaded.\n"); AST_RWLIST_WRLOCK(&databases); while ((cur = AST_RWLIST_REMOVE_HEAD(&databases, list))) { mysql_close(&cur->handle); ast_mutex_destroy(&cur->lock); ast_free(cur); } AST_RWLIST_UNLOCK(&databases); /* Destroy cached table info */ AST_LIST_LOCK(&mysql_tables); while ((table = AST_LIST_REMOVE_HEAD(&mysql_tables, list))) { destroy_table(table); } AST_LIST_UNLOCK(&mysql_tables); return 0; } static int reload(void) { parse_config(1); ast_verb(2, "MySQL RealTime reloaded.\n"); return 0; } static int parse_config(int reload) { struct ast_config *config = NULL; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; const char *catg; struct mysql_conn *cur; if ((config = ast_config_load(RES_CONFIG_MYSQL_CONF, config_flags)) == CONFIG_STATUS_FILEMISSING) { /* Support old config file name */ config = ast_config_load(RES_CONFIG_MYSQL_CONF_OLD, config_flags); } if (config == CONFIG_STATUS_FILEMISSING) { return 0; } else if (config == CONFIG_STATUS_FILEUNCHANGED) { return 0; } else if (config == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "Not %sloading " RES_CONFIG_MYSQL_CONF "\n", reload ? "re" : ""); } AST_RWLIST_WRLOCK(&databases); for (catg = ast_category_browse(config, NULL); catg; catg = ast_category_browse(config, catg)) { /* Does this category already exist? */ AST_RWLIST_TRAVERSE(&databases, cur, list) { if (!strcmp(cur->unique_name, catg)) { break; } } if (!cur) { if (!(cur = ast_calloc(1, sizeof(*cur) + strlen(catg) + 1))) { ast_log(LOG_WARNING, "Could not allocate space for MySQL database '%s'\n", catg); continue; } strcpy(cur->unique_name, catg); /* SAFE */ ast_mutex_init(&cur->lock); AST_RWLIST_INSERT_TAIL(&databases, cur, list); } load_mysql_config(config, catg, cur); } AST_RWLIST_UNLOCK(&databases); ast_config_destroy(config); return 0; } static int load_mysql_config(struct ast_config *config, const char *category, struct mysql_conn *conn) { const char *s; if (!(s = ast_variable_retrieve(config, category, "dbuser"))) { ast_log(LOG_WARNING, "MySQL RealTime: No database user found, using 'asterisk' as default.\n"); s = "asterisk"; } ast_copy_string(conn->user, s, sizeof(conn->user)); if (!(s = ast_variable_retrieve(config, category, "dbpass"))) { ast_log(LOG_WARNING, "MySQL RealTime: No database password found, using 'asterisk' as default.\n"); s = "asterisk"; } ast_copy_string(conn->pass, s, sizeof(conn->pass)); if (!(s = ast_variable_retrieve(config, category, "dbhost"))) { ast_log(LOG_WARNING, "MySQL RealTime: No database host found, using localhost via socket.\n"); s = ""; } ast_copy_string(conn->host, s, sizeof(conn->host)); if (!(s = ast_variable_retrieve(config, category, "dbname"))) { ast_log(LOG_WARNING, "MySQL RealTime: No database name found, using 'asterisk' as default.\n"); s = "asterisk"; } ast_copy_string(conn->name, s, sizeof(conn->name)); if (!(s = ast_variable_retrieve(config, category, "dbport"))) { ast_log(LOG_WARNING, "MySQL RealTime: No database port found, using 3306 as default.\n"); conn->port = 3306; } else conn->port = atoi(s); if (!(s = ast_variable_retrieve(config, category, "dbsock"))) { if (ast_strlen_zero(conn->host)) { char *paths[3] = { "/tmp/mysql.sock", "/var/lib/mysql/mysql.sock", "/var/run/mysqld/mysqld.sock" }; struct stat st; int i; for (i = 0; i < 3; i++) { if (!stat(paths[i], &st)) { ast_log(LOG_WARNING, "MySQL RealTime: No database socket found, using '%s' as default.\n", paths[i]); ast_copy_string(conn->sock, paths[i], sizeof(conn->sock)); } } if (i == 3) { ast_log(LOG_WARNING, "MySQL RealTime: No database socket found (and unable to detect a suitable path).\n"); return 0; } } } else ast_copy_string(conn->sock, s, sizeof(conn->sock)); if ((s = ast_variable_retrieve(config, category, "dbcharset"))) { ast_copy_string(conn->charset, s, sizeof(conn->charset)); } if (!(s = ast_variable_retrieve(config, category, "requirements"))) { ast_log(LOG_WARNING, "MySQL realtime: no requirements setting found, using 'warn' as default.\n"); conn->requirements = RQ_WARN; } else if (!strcasecmp(s, "createclose")) { conn->requirements = RQ_CREATECLOSE; } else if (!strcasecmp(s, "createchar")) { conn->requirements = RQ_CREATECHAR; } else if (!strcasecmp(s, "warn")) { conn->requirements = RQ_WARN; } else { ast_log(LOG_WARNING, "MySQL realtime: unrecognized requirements setting '%s', using 'warn'\n", s); conn->requirements = RQ_WARN; } if (!ast_strlen_zero(conn->host)) { ast_debug(1, "MySQL RealTime host: %s\n", conn->host); ast_debug(1, "MySQL RealTime port: %i\n", conn->port); } else ast_debug(1, "MySQL RealTime socket: %s\n", conn->sock); ast_debug(1, "MySQL RealTime database name: %s\n", conn->name); ast_debug(1, "MySQL RealTime user: %s\n", conn->user); ast_debug(1, "MySQL RealTime password: %s\n", conn->pass); if(conn->charset) ast_debug(1, "MySQL RealTime charset: %s\n", conn->charset); return 1; } static int mysql_reconnect(struct mysql_conn *conn) { #ifdef MYSQL_OPT_RECONNECT my_bool trueval = 1; #endif /* mutex lock should have been locked before calling this function. */ reconnect_tryagain: if ((!conn->connected) && (!ast_strlen_zero(conn->host) || conn->sock) && !ast_strlen_zero(conn->user) && !ast_strlen_zero(conn->name)) { if (!mysql_init(&conn->handle)) { ast_log(LOG_WARNING, "MySQL RealTime: Insufficient memory to allocate MySQL resource.\n"); conn->connected = 0; return 0; } if(conn->charset && strlen(conn->charset) > 2){ char set_names[255]; char statement[512]; snprintf(set_names, sizeof(set_names), "SET NAMES %s", conn->charset); mysql_real_escape_string(&conn->handle, statement, set_names, sizeof(set_names)); mysql_options(&conn->handle, MYSQL_INIT_COMMAND, set_names); mysql_options(&conn->handle, MYSQL_SET_CHARSET_NAME, conn->charset); } if (mysql_real_connect(&conn->handle, conn->host, conn->user, conn->pass, conn->name, conn->port, conn->sock, 0)) { #ifdef MYSQL_OPT_RECONNECT /* The default is no longer to automatically reconnect on failure, * (as of 5.0.3) so we have to set that option here. */ mysql_options(&conn->handle, MYSQL_OPT_RECONNECT, &trueval); #endif ast_debug(1, "MySQL RealTime: Successfully connected to database.\n"); conn->connected = 1; conn->connect_time = time(NULL); return 1; } else { ast_log(LOG_ERROR, "MySQL RealTime: Failed to connect database server %s on %s (err %d). Check debug for more info.\n", conn->name, !ast_strlen_zero(conn->host) ? conn->host : conn->sock, mysql_errno(&conn->handle)); ast_debug(1, "MySQL RealTime: Cannot Connect (%d): %s\n", mysql_errno(&conn->handle), mysql_error(&conn->handle)); conn->connected = 0; conn->connect_time = 0; return 0; } } else { /* MySQL likes to return an error, even if it reconnects successfully. * So the postman pings twice. */ if (mysql_ping(&conn->handle) != 0 && (usleep(1) + 2 > 0) && mysql_ping(&conn->handle) != 0) { conn->connected = 0; conn->connect_time = 0; ast_log(LOG_ERROR, "MySQL RealTime: Ping failed (%d). Trying an explicit reconnect.\n", mysql_errno(&conn->handle)); ast_debug(1, "MySQL RealTime: Server Error (%d): %s\n", mysql_errno(&conn->handle), mysql_error(&conn->handle)); goto reconnect_tryagain; } if (!conn->connected) { conn->connected = 1; conn->connect_time = time(NULL); } if (mysql_select_db(&conn->handle, conn->name) != 0) { ast_log(LOG_WARNING, "MySQL RealTime: Unable to select database: %s. Still Connected (%u) - %s.\n", conn->name, mysql_errno(&conn->handle), mysql_error(&conn->handle)); return 0; } ast_debug(1, "MySQL RealTime: Connection okay.\n"); return 1; } } static char *handle_cli_realtime_mysql_cache(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct tables *cur; int l, which; char *ret = NULL; switch (cmd) { case CLI_INIT: e->command = "realtime mysql cache"; e->usage = "Usage: realtime mysql cache [ ]\n" " Shows table cache for the MySQL RealTime driver\n"; return NULL; case CLI_GENERATE: if (a->argc < 4 || a->argc > 5) { return NULL; } l = strlen(a->word); which = 0; if (a->argc == 5) { AST_LIST_LOCK(&mysql_tables); AST_LIST_TRAVERSE(&mysql_tables, cur, list) { if (!strcasecmp(a->argv[3], cur->database->unique_name) && !strncasecmp(a->word, cur->name, l) && ++which > a->n) { ret = ast_strdup(cur->name); break; } } AST_LIST_UNLOCK(&mysql_tables); } else { struct mysql_conn *cur; AST_RWLIST_RDLOCK(&databases); AST_RWLIST_TRAVERSE(&databases, cur, list) { if (!strncasecmp(a->word, cur->unique_name, l) && ++which > a->n) { ret = ast_strdup(cur->unique_name); break; } } AST_RWLIST_UNLOCK(&databases); } return ret; } if (a->argc == 3) { /* List of tables */ AST_LIST_LOCK(&mysql_tables); AST_LIST_TRAVERSE(&mysql_tables, cur, list) { ast_cli(a->fd, "%20.20s %s\n", cur->database->unique_name, cur->name); } AST_LIST_UNLOCK(&mysql_tables); } else if (a->argc == 4) { int found = 0; /* List of tables */ AST_LIST_LOCK(&mysql_tables); AST_LIST_TRAVERSE(&mysql_tables, cur, list) { if (!strcasecmp(cur->database->unique_name, a->argv[3])) { ast_cli(a->fd, "%s\n", cur->name); found = 1; } } AST_LIST_UNLOCK(&mysql_tables); if (!found) { ast_cli(a->fd, "No tables cached within %s database\n", a->argv[3]); } } else if (a->argc == 5) { /* List of columns */ if ((cur = find_table(a->argv[3], a->argv[4]))) { struct columns *col; ast_cli(a->fd, "Columns for Table Cache '%s':\n", a->argv[3]); ast_cli(a->fd, "%-20.20s %-20.20s %-3.3s\n", "Name", "Type", "Len"); AST_LIST_TRAVERSE(&cur->columns, col, list) { ast_cli(a->fd, "%-20.20s %-20.20s %3d\n", col->name, col->type, col->len); } release_table(cur); } else { ast_cli(a->fd, "No such table '%s'\n", a->argv[3]); } } return CLI_SUCCESS; } static char *handle_cli_realtime_mysql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { char status[256], status2[100] = "", type[20]; char *ret = NULL; int ctime = 0, found = 0; struct mysql_conn *cur; int l = 0, which = 0; switch (cmd) { case CLI_INIT: e->command = "realtime mysql status"; e->usage = "Usage: realtime mysql status []\n" " Shows connection information for the MySQL RealTime driver\n"; return NULL; case CLI_GENERATE: if (a->argc == 4) { AST_RWLIST_RDLOCK(&databases); AST_RWLIST_TRAVERSE(&databases, cur, list) { if (!strncasecmp(a->word, cur->unique_name, l) && ++which > a->n) { ret = ast_strdup(cur->unique_name); break; } } AST_RWLIST_UNLOCK(&databases); } return ret; } if (a->argc != 3) return CLI_SHOWUSAGE; AST_RWLIST_RDLOCK(&databases); AST_RWLIST_TRAVERSE(&databases, cur, list) { if (a->argc == 3 || (a->argc == 4 && !strcasecmp(a->argv[3], cur->unique_name))) { found = 1; if (mysql_reconnect(cur)) { snprintf(type, sizeof(type), "connected to"); ctime = time(NULL) - cur->connect_time; } else { snprintf(type, sizeof(type), "configured for"); ctime = -1; } if (!ast_strlen_zero(cur->host)) { snprintf(status, sizeof(status), "%s %s %s@%s, port %d", cur->unique_name, type, cur->name, cur->host, cur->port); } else { snprintf(status, sizeof(status), "%s %s %s on socket file %s", cur->unique_name, type, cur->name, cur->sock); } if (!ast_strlen_zero(cur->user)) { snprintf(status2, sizeof(status2), " with username %s", cur->user); } else { status2[0] = '\0'; } if (ctime > 31536000) { ast_cli(a->fd, "%s%s for %.1f years.\n", status, status2, (double)ctime / 31536000.0); } else if (ctime > 86400 * 30) { ast_cli(a->fd, "%s%s for %d days.\n", status, status2, ctime / 86400); } else if (ctime > 86400) { ast_cli(a->fd, "%s%s for %d days, %d hours.\n", status, status2, ctime / 86400, (ctime % 86400) / 3600); } else if (ctime > 3600) { ast_cli(a->fd, "%s%s for %d hours, %d minutes.\n", status, status2, ctime / 3600, (ctime % 3600) / 60); } else if (ctime > 60) { ast_cli(a->fd, "%s%s for %d minutes.\n", status, status2, ctime / 60); } else if (ctime > -1) { ast_cli(a->fd, "%s%s for %d seconds.\n", status, status2, ctime); } else { ast_cli(a->fd, "%s%s.\n", status, status2); } } } AST_RWLIST_UNLOCK(&databases); if (!found) { ast_cli(a->fd, "No connections configured.\n"); } return CLI_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "MySQL RealTime Configuration Driver", .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_REALTIME_DRIVER, ); asterisk-11.7.0/addons/chan_ooh323.c0000644000175000007640000043710712152076254017007 0ustar sharkyjerryweb/* * 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. * *****************************************************************************/ /* Reworked version I, Nov-2009, by Alexandr Anikin, may@telecom-service.ru */ /*** MODULEINFO no extended ***/ #include "chan_ooh323.h" #include #define FORMAT_STRING_SIZE 512 /* Defaults */ #define DEFAULT_CONTEXT "default" #define DEFAULT_H323ID "Asterisk PBX" #define DEFAULT_LOGFILE "/var/log/asterisk/h323_log" #define DEFAULT_H323ACCNT "ast_h323" /* Flags */ #define H323_SILENCESUPPRESSION (1<<0) #define H323_GKROUTED (1<<1) #define H323_TUNNELING (1<<2) #define H323_FASTSTART (1<<3) #define H323_OUTGOING (1<<4) #define H323_ALREADYGONE (1<<5) #define H323_NEEDDESTROY (1<<6) #define H323_DISABLEGK (1<<7) #define H323_NEEDSTART (1<<8) #define MAXT30 240 #define T38TOAUDIOTIMEOUT 30 #define T38_DISABLED 0 #define T38_ENABLED 1 #define T38_FAXGW 1 #define FAXDETECT_CNG 1 #define FAXDETECT_T38 2 /* Channel description */ static const char type[] = "OOH323"; static const char tdesc[] = "Objective Systems H323 Channel Driver"; static const char config[] = "ooh323.conf"; struct ast_module *myself; static struct ast_jb_conf default_jbconf = { .flags = 0, .max_size = -1, .resync_threshold = -1, .impl = "" }; static struct ast_jb_conf global_jbconf; /* Channel Definition */ static struct ast_channel *ooh323_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause); static int ooh323_digit_begin(struct ast_channel *ast, char digit); static int ooh323_digit_end(struct ast_channel *ast, char digit, unsigned int duration); static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout); static int ooh323_hangup(struct ast_channel *ast); static int ooh323_answer(struct ast_channel *ast); static struct ast_frame *ooh323_read(struct ast_channel *ast); static int ooh323_write(struct ast_channel *ast, struct ast_frame *f); static int ooh323_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen); static int ooh323_queryoption(struct ast_channel *ast, int option, void *data, int *datalen); static int ooh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan); static int function_ooh323_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len); static int function_ooh323_write(struct ast_channel *chan, const char *cmd, char *data, const char *value); static enum ast_rtp_glue_result ooh323_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp); static enum ast_rtp_glue_result ooh323_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp); static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active); static void ooh323_get_codec(struct ast_channel *chan, struct ast_format_cap *result); void setup_rtp_remote(ooCallData *call, const char *remoteIp, int remotePort); static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan); static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl); static void print_codec_to_cli(int fd, struct ast_codec_pref *pref); struct ooh323_peer *find_friend(const char *name, int port); static struct ast_channel_tech ooh323_tech = { .type = type, .description = tdesc, .properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER, .requester = ooh323_request, .send_digit_begin = ooh323_digit_begin, .send_digit_end = ooh323_digit_end, .call = ooh323_call, .hangup = ooh323_hangup, .answer = ooh323_answer, .read = ooh323_read, .write = ooh323_write, .exception = ooh323_read, .indicate = ooh323_indicate, .fixup = ooh323_fixup, .send_html = 0, .queryoption = ooh323_queryoption, .bridge = ast_rtp_instance_bridge, /* XXX chan unlocked ? */ .early_bridge = ast_rtp_instance_early_bridge, .func_channel_read = function_ooh323_read, .func_channel_write = function_ooh323_write, }; static struct ast_rtp_glue ooh323_rtp = { .type = type, .get_rtp_info = ooh323_get_rtp_peer, .get_vrtp_info = ooh323_get_vrtp_peer, .update_peer = ooh323_set_rtp_peer, .get_codec = ooh323_get_codec, }; static struct ast_udptl_protocol ooh323_udptl = { .type = "H323", .get_udptl_info = ooh323_get_udptl_peer, .set_udptl_peer = ooh323_set_udptl_peer, }; struct ooh323_user; /* H.323 channel private structure */ static struct ooh323_pvt { ast_mutex_t lock; /* Channel private lock */ ast_cond_t rtpcond; /* RTP condition */ struct ast_rtp_instance *rtp; struct ast_sockaddr redirip; /* redir ip */ struct ast_rtp_instance *vrtp; /* Placeholder for now */ int t38support; /* T.38 mode - disable, transparent, faxgw */ int faxdetect; int faxdetected; int rtptimeout; struct ast_udptl *udptl; int faxmode; int t38_tx_enable; int t38_init; struct ast_sockaddr udptlredirip; time_t lastTxT38; int chmodepend; struct ast_channel *owner; /* Master Channel */ union { char *user; /* cooperating user/peer */ char *peer; } neighbor; time_t lastrtptx; time_t lastrtprx; unsigned int flags; unsigned int call_reference; char *callToken; char *username; char *host; char *callerid_name; char *callerid_num; char caller_h323id[AST_MAX_EXTENSION]; char caller_dialedDigits[AST_MAX_EXTENSION]; char caller_email[AST_MAX_EXTENSION]; char caller_url[256]; char callee_h323id[AST_MAX_EXTENSION]; char callee_dialedDigits[AST_MAX_EXTENSION]; char callee_email[AST_MAX_EXTENSION]; char callee_url[AST_MAX_EXTENSION]; int port; struct ast_format readformat; /* negotiated read format */ struct ast_format writeformat; /* negotiated write format */ struct ast_format_cap *cap; struct ast_codec_pref prefs; int dtmfmode; int dtmfcodec; char exten[AST_MAX_EXTENSION]; /* Requested extension */ char context[AST_MAX_EXTENSION]; /* Context where to start */ char accountcode[256]; /* Account code */ int nat; int amaflags; int progsent; /* progress is sent */ int alertsent; /* alerting is sent */ int directrtp; /* direct rtp */ int earlydirect; /* early direct rtp */ int g729onlyA; /* G.729 only A */ struct ast_dsp *vad; struct OOH323Regex *rtpmask; /* rtp ip regexp */ char rtpmaskstr[120]; int rtdrcount, rtdrinterval; /* roundtripdelayreq */ int faststart, h245tunneling; /* faststart & h245 tunneling */ struct ooh323_pvt *next; /* Next entity */ } *iflist = NULL; /* Protect the channel/interface list (ooh323_pvt) */ AST_MUTEX_DEFINE_STATIC(iflock); /* Profile of H.323 user registered with PBX*/ struct ooh323_user{ ast_mutex_t lock; char name[256]; char context[AST_MAX_EXTENSION]; int incominglimit; unsigned inUse; char accountcode[20]; int amaflags; struct ast_format_cap *cap; struct ast_codec_pref prefs; int dtmfmode; int dtmfcodec; int faxdetect; int t38support; int rtptimeout; int mUseIP; /* Use IP address or H323-ID to search user */ char mIP[4*8+7+2]; /* Max for IPv6 - 2 brackets, 8 4hex, 7 - : */ struct OOH323Regex *rtpmask; char rtpmaskstr[120]; int rtdrcount, rtdrinterval; int nat; int faststart, h245tunneling; int directrtp; int earlydirect; int g729onlyA; struct ooh323_user *next; }; /* Profile of valid asterisk peers */ struct ooh323_peer{ ast_mutex_t lock; char name[256]; unsigned outgoinglimit; unsigned outUse; struct ast_format_cap *cap; struct ast_codec_pref prefs; char accountcode[20]; int amaflags; int dtmfmode; int dtmfcodec; int faxdetect; int t38support; int mFriend; /* indicates defined as friend */ char ip[4*8+7+2]; /* Max for IPv6 - 2 brackets, 8 4hex, 7 - : */ int port; char *h323id; /* H323-ID alias, which asterisk will register with gk to reach this peer*/ char *email; /* Email alias, which asterisk will register with gk to reach this peer*/ char *url; /* url alias, which asterisk will register with gk to reach this peer*/ char *e164; /* e164 alias, which asterisk will register with gk to reach this peer*/ int rtptimeout; struct OOH323Regex *rtpmask; char rtpmaskstr[120]; int rtdrcount,rtdrinterval; int nat; int faststart, h245tunneling; int directrtp; int earlydirect; int g729onlyA; struct ooh323_peer *next; }; /* List of H.323 users known to PBX */ static struct ast_user_list { struct ooh323_user *users; ast_mutex_t lock; } userl; static struct ast_peer_list { struct ooh323_peer *peers; ast_mutex_t lock; } peerl; /* Mutex to protect H.323 reload process */ static int h323_reloading = 0; AST_MUTEX_DEFINE_STATIC(h323_reload_lock); /* Mutex to protect usage counter */ static int usecnt = 0; AST_MUTEX_DEFINE_STATIC(usecnt_lock); AST_MUTEX_DEFINE_STATIC(ooh323c_cmd_lock); static long callnumber = 0; AST_MUTEX_DEFINE_STATIC(ooh323c_cn_lock); /* stack callbacks */ int onAlerting(ooCallData *call); int onProgress(ooCallData *call); int onNewCallCreated(ooCallData *call); int onOutgoingCall(ooCallData *call); int onCallEstablished(ooCallData *call); int onCallCleared(ooCallData *call); void onModeChanged(ooCallData *call, int t38mode); extern OOH323EndPoint gH323ep; static char gLogFile[256] = DEFAULT_LOGFILE; static int gPort = 1720; static char gIP[2+8*4+7]; /* Max for IPv6 addr */ struct ast_sockaddr bindaddr; int v6mode = 0; static char gCallerID[AST_MAX_EXTENSION] = ""; static struct ooAliases *gAliasList; static struct ast_format_cap *gCap; static struct ast_codec_pref gPrefs; static int gDTMFMode = H323_DTMF_RFC2833; static int gDTMFCodec = 101; static int gFAXdetect = FAXDETECT_CNG; static int gT38Support = T38_FAXGW; static char gGatekeeper[100]; static enum RasGatekeeperMode gRasGkMode = RasNoGatekeeper; static int gIsGateway = 0; static int gFastStart = 1; static int gTunneling = 1; static int gBeMaster = 0; static int gMediaWaitForConnect = 0; static int gDirectRTP = 0; static int gEarlyDirect = 0; static int gTOS = 0; static int gRTPTimeout = 60; static int g729onlyA = 0; static char gAccountcode[80] = DEFAULT_H323ACCNT; static int gAMAFLAGS; static char gContext[AST_MAX_EXTENSION] = DEFAULT_CONTEXT; static int gIncomingLimit = 1024; static int gOutgoingLimit = 1024; OOBOOL gH323Debug = FALSE; static int gTRCLVL = OOTRCLVLERR; static int gRTDRCount = 0, gRTDRInterval = 0; static int gNat = FALSE; static int t35countrycode = 0; static int t35extensions = 0; static int manufacturer = 0; static char vendor[AST_MAX_EXTENSION] = ""; static char version[AST_MAX_EXTENSION] = ""; static struct ooh323_config { int mTCPPortStart; int mTCPPortEnd; } ooconfig; /** Asterisk RTP stuff*/ static struct ast_sched_context *sched; static struct io_context *io; /* Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical. */ AST_MUTEX_DEFINE_STATIC(monlock); /* This is the thread for the monitor which checks for input on the channels which are not currently in use. */ static pthread_t monitor_thread = AST_PTHREADT_NULL; static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state, const char *host, struct ast_format_cap *cap, const char *linkedid) { struct ast_channel *ch = NULL; struct ast_format tmpfmt; int features = 0; if (gH323Debug) { ast_verb(0, "--- ooh323_new - %s\n", host); } ast_format_clear(&tmpfmt); /* Don't hold a h323 pvt lock while we allocate a channel */ ast_mutex_unlock(&i->lock); ast_mutex_lock(&ooh323c_cn_lock); ch = ast_channel_alloc(1, state, i->callerid_num, i->callerid_name, i->accountcode, i->exten, i->context, linkedid, i->amaflags, "OOH323/%s-%ld", host, callnumber); callnumber++; ast_mutex_unlock(&ooh323c_cn_lock); ast_mutex_lock(&i->lock); if (ch) { ast_channel_lock(ch); ast_channel_tech_set(ch, &ooh323_tech); if (cap) ast_best_codec(cap, &tmpfmt); if (!tmpfmt.id) ast_codec_pref_index(&i->prefs, 0, &tmpfmt); ast_format_cap_add(ast_channel_nativeformats(ch), &tmpfmt); ast_format_copy(ast_channel_rawwriteformat(ch), &tmpfmt); ast_format_copy(ast_channel_rawreadformat(ch), &tmpfmt); ast_jb_configure(ch, &global_jbconf); if (state == AST_STATE_RING) ast_channel_rings_set(ch, 1); ast_channel_adsicpe_set(ch, AST_ADSI_UNAVAILABLE); ast_set_write_format(ch, &tmpfmt); ast_set_read_format(ch, &tmpfmt); ast_channel_tech_pvt_set(ch, i); i->owner = ch; ast_module_ref(myself); /* Allocate dsp for in-band DTMF support */ if ((i->dtmfmode & H323_DTMF_INBAND) || (i->faxdetect & FAXDETECT_CNG)) { i->vad = ast_dsp_new(); } /* inband DTMF*/ if (i->dtmfmode & H323_DTMF_INBAND) { features |= DSP_FEATURE_DIGIT_DETECT; if (i->dtmfmode & H323_DTMF_INBANDRELAX) { ast_dsp_set_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF); } } /* fax detection*/ if (i->faxdetect & FAXDETECT_CNG) { features |= DSP_FEATURE_FAX_DETECT; ast_dsp_set_faxmode(i->vad, DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED); } if (features) { ast_dsp_set_features(i->vad, features); } ast_mutex_lock(&usecnt_lock); usecnt++; ast_mutex_unlock(&usecnt_lock); /* Notify the module monitors that use count for resource has changed*/ ast_update_use_count(); ast_channel_context_set(ch, i->context); ast_channel_exten_set(ch, i->exten); ast_channel_priority_set(ch, 1); if(!ast_test_flag(i, H323_OUTGOING)) { if (!ast_strlen_zero(i->caller_h323id)) { pbx_builtin_setvar_helper(ch, "_CALLER_H323ID", i->caller_h323id); } if (!ast_strlen_zero(i->caller_dialedDigits)) { pbx_builtin_setvar_helper(ch, "_CALLER_H323DIALEDDIGITS", i->caller_dialedDigits); } if (!ast_strlen_zero(i->caller_email)) { pbx_builtin_setvar_helper(ch, "_CALLER_H323EMAIL", i->caller_email); } if (!ast_strlen_zero(i->caller_url)) { pbx_builtin_setvar_helper(ch, "_CALLER_H323URL", i->caller_url); } } if (!ast_strlen_zero(i->accountcode)) ast_channel_accountcode_set(ch, i->accountcode); if (i->amaflags) ast_channel_amaflags_set(ch, i->amaflags); ast_setstate(ch, state); if (state != AST_STATE_DOWN) { if (ast_pbx_start(ch)) { ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(ch)); ast_channel_unlock(ch); ast_hangup(ch); ch = NULL; } } if (ch) { manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate", "Channel: %s\r\nChanneltype: %s\r\n" "CallRef: %d\r\n", ast_channel_name(ch), "OOH323", i->call_reference); } } else ast_log(LOG_WARNING, "Unable to allocate channel structure\n"); if(ch) ast_channel_unlock(ch); if (gH323Debug) { ast_verb(0, "+++ h323_new\n"); } return ch; } static struct ooh323_pvt *ooh323_alloc(int callref, char *callToken) { struct ooh323_pvt *pvt = NULL; if (gH323Debug) { ast_verb(0, "--- ooh323_alloc\n"); } if (!(pvt = ast_calloc(1, sizeof(*pvt)))) { ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n"); return NULL; } if (!(pvt->cap = ast_format_cap_alloc_nolock())) { ast_free(pvt); ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n"); return NULL; } ast_mutex_init(&pvt->lock); ast_mutex_lock(&pvt->lock); pvt->faxmode = 0; pvt->chmodepend = 0; pvt->faxdetected = 0; pvt->faxdetect = gFAXdetect; pvt->t38support = gT38Support; pvt->rtptimeout = gRTPTimeout; pvt->nat = gNat; pvt->rtdrinterval = gRTDRInterval; pvt->rtdrcount = gRTDRCount; pvt->g729onlyA = g729onlyA; pvt->call_reference = callref; if (callToken) pvt->callToken = strdup(callToken); /* whether to use gk for this call */ if (gRasGkMode == RasNoGatekeeper) OO_SETFLAG(pvt->flags, H323_DISABLEGK); pvt->dtmfmode = gDTMFMode; pvt->dtmfcodec = gDTMFCodec; ast_copy_string(pvt->context, gContext, sizeof(pvt->context)); ast_copy_string(pvt->accountcode, gAccountcode, sizeof(pvt->accountcode)); pvt->amaflags = gAMAFLAGS; ast_format_cap_copy(pvt->cap, gCap); memcpy(&pvt->prefs, &gPrefs, sizeof(pvt->prefs)); ast_mutex_unlock(&pvt->lock); /* Add to interface list */ ast_mutex_lock(&iflock); pvt->next = iflist; iflist = pvt; ast_mutex_unlock(&iflock); if (gH323Debug) { ast_verb(0, "+++ ooh323_alloc\n"); } return pvt; } /* Possible data values - peername, exten/peername, exten@ip */ static struct ast_channel *ooh323_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause) { struct ast_channel *chan = NULL; struct ooh323_pvt *p = NULL; struct ooh323_peer *peer = NULL; char *dest = NULL; char *ext = NULL; char tmp[256]; char formats[FORMAT_STRING_SIZE]; int port = 0; if (gH323Debug) ast_verb(0, "--- ooh323_request - data %s format %s\n", data, ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,cap)); if (!(ast_format_cap_has_type(cap, AST_FORMAT_TYPE_AUDIO))) { ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,cap)); return NULL; } p = ooh323_alloc(0,0); /* Initial callRef is zero */ if (!p) { ast_log(LOG_WARNING, "Unable to build pvt data for '%s'\n", data); return NULL; } ast_mutex_lock(&p->lock); /* This is an outgoing call, since ooh323_request is called */ ast_set_flag(p, H323_OUTGOING); ast_copy_string(tmp, data, sizeof(tmp)); dest = strchr(tmp, '/'); if (dest) { *dest = '\0'; dest++; ext = dest; dest = tmp; } else if ((dest = strchr(tmp, '@'))) { *dest = '\0'; dest++; ext = tmp; } else { dest = tmp; ext = NULL; } #if 0 if ((sport = strchr(dest, ':'))) { *sport = '\0'; sport++; port = atoi(sport); } #endif if (dest) { peer = find_peer(dest, port); } else{ ast_mutex_lock(&iflock); ast_mutex_unlock(&p->lock); ooh323_destroy(p); ast_mutex_unlock(&iflock); ast_log(LOG_ERROR, "Destination format is not supported\n"); *cause = AST_CAUSE_INVALID_NUMBER_FORMAT; return NULL; } if (peer) { p->username = strdup(peer->name); p->host = strdup(peer->ip); p->port = peer->port; /* Disable gk as we are going to call a known peer*/ /* OO_SETFLAG(p->flags, H323_DISABLEGK); */ if (ext) ast_copy_string(p->exten, ext, sizeof(p->exten)); ast_format_cap_copy(p->cap, peer->cap); memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref)); p->g729onlyA = peer->g729onlyA; p->dtmfmode |= peer->dtmfmode; p->dtmfcodec = peer->dtmfcodec; p->faxdetect = peer->faxdetect; p->t38support = peer->t38support; p->rtptimeout = peer->rtptimeout; p->nat = peer->nat; p->faststart = peer->faststart; p->h245tunneling = peer->h245tunneling; p->directrtp = peer->directrtp; p->earlydirect = peer->earlydirect; if (peer->rtpmask && peer->rtpmaskstr[0]) { p->rtpmask = peer->rtpmask; ast_copy_string(p->rtpmaskstr, peer->rtpmaskstr, sizeof(p->rtpmaskstr)); } if (peer->rtdrinterval) { p->rtdrinterval = peer->rtdrinterval; p->rtdrcount = peer->rtdrcount; } ast_copy_string(p->accountcode, peer->accountcode, sizeof(p->accountcode)); p->amaflags = peer->amaflags; } else { if (gRasGkMode == RasNoGatekeeper) { /* no gk and no peer */ ast_log(LOG_ERROR, "Call to undefined peer %s", dest); ast_mutex_lock(&iflock); ast_mutex_unlock(&p->lock); ooh323_destroy(p); ast_mutex_unlock(&iflock); return NULL; } else if (gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered) { ast_log(LOG_ERROR, "Gatekeeper client is configured but not registered\n"); *cause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE; return NULL; } p->g729onlyA = g729onlyA; p->dtmfmode = gDTMFMode; p->dtmfcodec = gDTMFCodec; p->faxdetect = gFAXdetect; p->t38support = gT38Support; p->rtptimeout = gRTPTimeout; p->nat = gNat; ast_format_cap_copy(p->cap, gCap); p->rtdrinterval = gRTDRInterval; p->rtdrcount = gRTDRCount; p->faststart = gFastStart; p->h245tunneling = gTunneling; p->directrtp = gDirectRTP; p->earlydirect = gEarlyDirect; memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref)); p->username = strdup(dest); p->host = strdup(dest); if (port > 0) { p->port = port; } if (ext) { ast_copy_string(p->exten, ext, sizeof(p->exten)); } } chan = ooh323_new(p, AST_STATE_DOWN, p->username, cap, requestor ? ast_channel_linkedid(requestor) : NULL); ast_mutex_unlock(&p->lock); if (!chan) { ast_mutex_lock(&iflock); ooh323_destroy(p); ast_mutex_unlock(&iflock); } else { ast_mutex_lock(&p->lock); p->callToken = (char*)ast_calloc(1, AST_MAX_EXTENSION); if(!p->callToken) { ast_mutex_unlock(&p->lock); ast_mutex_lock(&iflock); ooh323_destroy(p); ast_mutex_unlock(&iflock); ast_log(LOG_ERROR, "Failed to allocate memory for callToken\n"); return NULL; } ast_mutex_unlock(&p->lock); ast_mutex_lock(&ooh323c_cmd_lock); ast_cond_init(&p->rtpcond, NULL); ooMakeCall(data, p->callToken, AST_MAX_EXTENSION, NULL); ast_mutex_lock(&p->lock); if (!p->rtp) { ast_cond_wait(&p->rtpcond, &p->lock); } ast_mutex_unlock(&p->lock); ast_cond_destroy(&p->rtpcond); ast_mutex_unlock(&ooh323c_cmd_lock); } restart_monitor(); if (gH323Debug) ast_verb(0, "+++ ooh323_request\n"); return chan; } static struct ooh323_pvt* find_call(ooCallData *call) { struct ooh323_pvt *p; if (gH323Debug) ast_verb(0, "--- find_call\n"); ast_mutex_lock(&iflock); for (p = iflist; p; p = p->next) { if (p->callToken && !strcmp(p->callToken, call->callToken)) { break; } } ast_mutex_unlock(&iflock); if (gH323Debug) ast_verb(0, "+++ find_call\n"); return p; } struct ooh323_user *find_user(const char * name, const char* ip) { struct ooh323_user *user; if (gH323Debug) ast_verb(0, "--- find_user: %s, %s\n",name,ip); ast_mutex_lock(&userl.lock); for (user = userl.users; user; user = user->next) { if (ip && user->mUseIP && !strcmp(user->mIP, ip)) { break; } if (name && !strcmp(user->name, name)) { break; } } ast_mutex_unlock(&userl.lock); if (gH323Debug) ast_verb(0, "+++ find_user\n"); return user; } struct ooh323_peer *find_friend(const char *name, int port) { struct ooh323_peer *peer; if (gH323Debug) ast_verb(0, "--- find_friend \"%s\"\n", name); ast_mutex_lock(&peerl.lock); for (peer = peerl.peers; peer; peer = peer->next) { if (gH323Debug) { ast_verb(0, " comparing with \"%s\"\n", peer->ip); } if (!strcmp(peer->ip, name)) { if (port <= 0 || (port > 0 && peer->port == port)) { break; } } } ast_mutex_unlock(&peerl.lock); if (gH323Debug) { if (peer) { ast_verb(0, " found matching friend\n"); } ast_verb(0, "+++ find_friend \"%s\"\n", name); } return peer; } struct ooh323_peer *find_peer(const char * name, int port) { struct ooh323_peer *peer; if (gH323Debug) ast_verb(0, "--- find_peer \"%s\"\n", name); ast_mutex_lock(&peerl.lock); for (peer = peerl.peers; peer; peer = peer->next) { if (gH323Debug) { ast_verb(0, " comparing with \"%s\"\n", peer->ip); } if (!strcasecmp(peer->name, name)) break; if (peer->h323id && !strcasecmp(peer->h323id, name)) break; if (peer->e164 && !strcasecmp(peer->e164, name)) break; /* if (!strcmp(peer->ip, name)) { if (port > 0 && peer->port == port) { break; } else if (port <= 0) { break; } } */ } ast_mutex_unlock(&peerl.lock); if (gH323Debug) { if (peer) { ast_verb(0, " found matching peer\n"); } ast_verb(0, "+++ find_peer \"%s\"\n", name); } return peer; } static int ooh323_digit_begin(struct ast_channel *chan, char digit) { char dtmf[2]; struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan); int res = 0; if (gH323Debug) ast_verb(0, "--- ooh323_digit_begin\n"); if (!p) { ast_log(LOG_ERROR, "No private structure for call\n"); return -1; } ast_mutex_lock(&p->lock); if (p->rtp && ((p->dtmfmode & H323_DTMF_RFC2833) || (p->dtmfmode & H323_DTMF_CISCO))) { ast_rtp_instance_dtmf_begin(p->rtp, digit); } else if (((p->dtmfmode & H323_DTMF_Q931) || (p->dtmfmode & H323_DTMF_H245ALPHANUMERIC) || (p->dtmfmode & H323_DTMF_H245SIGNAL))) { dtmf[0] = digit; dtmf[1] = '\0'; ooSendDTMFDigit(p->callToken, dtmf); } else if (p->dtmfmode & H323_DTMF_INBAND) { res = -1; // tell Asterisk to generate inband indications } ast_mutex_unlock(&p->lock); if (gH323Debug) { ast_verb(0, "+++ ooh323_digit_begin, res = %d\n", res); } return res; } static int ooh323_digit_end(struct ast_channel *chan, char digit, unsigned int duration) { struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan); int res = 0; if (gH323Debug) ast_verb(0, "--- ooh323_digit_end\n"); if (!p) { ast_log(LOG_ERROR, "No private structure for call\n"); return -1; } ast_mutex_lock(&p->lock); if (p->rtp && ((p->dtmfmode & H323_DTMF_RFC2833) || (p->dtmfmode & H323_DTMF_CISCO)) ) { ast_rtp_instance_dtmf_end(p->rtp, digit); } else if(p->dtmfmode & H323_DTMF_INBAND) { res = -1; // tell Asterisk to stop inband indications } ast_mutex_unlock(&p->lock); if (gH323Debug) { ast_verb(0, "+++ ooh323_digit_end, res = %d\n", res); } return res; } static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout) { struct ooh323_pvt *p = ast_channel_tech_pvt(ast); char destination[256]; int res=0, i; const char *val = NULL; ooCallOptions opts = { .fastStart = TRUE, .tunneling = TRUE, .disableGk = TRUE, .callMode = OO_CALLMODE_AUDIOCALL, .transfercap = 0 }; if (gH323Debug) ast_verb(0, "--- ooh323_call- %s\n", dest); if ((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) { ast_log(LOG_WARNING, "ooh323_call called on %s, neither down nor " "reserved\n", ast_channel_name(ast)); return -1; } ast_mutex_lock(&p->lock); ast_set_flag(p, H323_OUTGOING); if (ast_channel_connected(ast)->id.number.valid && ast_channel_connected(ast)->id.number.str) { free(p->callerid_num); p->callerid_num = strdup(ast_channel_connected(ast)->id.number.str); } if (ast_channel_connected(ast)->id.name.valid && ast_channel_connected(ast)->id.name.str) { free(p->callerid_name); p->callerid_name = strdup(ast_channel_connected(ast)->id.name.str); } else if (ast_channel_connected(ast)->id.number.valid && ast_channel_connected(ast)->id.number.str) { free(p->callerid_name); p->callerid_name = strdup(ast_channel_connected(ast)->id.number.str); } else { ast_channel_connected(ast)->id.name.valid = 1; free(ast_channel_connected(ast)->id.name.str); ast_channel_connected(ast)->id.name.str = strdup(gCallerID); free(p->callerid_name); p->callerid_name = strdup(ast_channel_connected(ast)->id.name.str); } /* Retrieve vars */ if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323ID"))) { ast_copy_string(p->caller_h323id, val, sizeof(p->caller_h323id)); } if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323DIALEDDIGITS"))) { ast_copy_string(p->caller_dialedDigits, val, sizeof(p->caller_dialedDigits)); if(!p->callerid_num) p->callerid_num = strdup(val); } if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323EMAIL"))) { ast_copy_string(p->caller_email, val, sizeof(p->caller_email)); } if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323URL"))) { ast_copy_string(p->caller_url, val, sizeof(p->caller_url)); } if (p->host && p->port != 0) snprintf(destination, sizeof(destination), "%s:%d", p->host, p->port); else if (p->host) snprintf(destination, sizeof(destination), "%s", p->host); else ast_copy_string(destination, dest, sizeof(destination)); destination[sizeof(destination)-1]='\0'; opts.transfercap = ast_channel_transfercapability(ast); opts.fastStart = p->faststart; opts.tunneling = p->h245tunneling; for (i=0;i<480 && !isRunning(p->callToken);i++) usleep(12000); if(OO_TESTFLAG(p->flags, H323_DISABLEGK)) { res = ooRunCall(destination, p->callToken, AST_MAX_EXTENSION, &opts); } else { res = ooRunCall(destination, p->callToken, AST_MAX_EXTENSION, NULL); } ast_mutex_unlock(&p->lock); if (res != OO_OK) { ast_log(LOG_ERROR, "Failed to make call\n"); return -1; /* ToDO: cleanup */ } if (gH323Debug) ast_verb(0, "+++ ooh323_call\n"); return 0; } static int ooh323_hangup(struct ast_channel *ast) { struct ooh323_pvt *p = ast_channel_tech_pvt(ast); int q931cause = AST_CAUSE_NORMAL_CLEARING; if (gH323Debug) ast_verb(0, "--- ooh323_hangup\n"); if (p) { ast_mutex_lock(&p->lock); if (ast_channel_hangupcause(ast)) { q931cause = ast_channel_hangupcause(ast); } else { const char *cause = pbx_builtin_getvar_helper(ast, "DIALSTATUS"); if (cause) { if (!strcmp(cause, "CONGESTION")) { q931cause = AST_CAUSE_NORMAL_CIRCUIT_CONGESTION; } else if (!strcmp(cause, "BUSY")) { q931cause = AST_CAUSE_USER_BUSY; } else if (!strcmp(cause, "CHANISUNVAIL")) { q931cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL; } else if (!strcmp(cause, "NOANSWER")) { q931cause = AST_CAUSE_NO_ANSWER; } else if (!strcmp(cause, "CANCEL")) { q931cause = AST_CAUSE_CALL_REJECTED; } } } if (gH323Debug) ast_verb(0, " hanging %s with cause: %d\n", p->username, q931cause); ast_channel_tech_pvt_set(ast, NULL); if (!ast_test_flag(p, H323_ALREADYGONE)) { ooHangCall(p->callToken, ooh323_convert_hangupcause_asteriskToH323(q931cause), q931cause); ast_set_flag(p, H323_ALREADYGONE); /* ast_mutex_unlock(&p->lock); */ } else ast_set_flag(p, H323_NEEDDESTROY); /* detach channel here */ if (p->owner) { ast_channel_tech_pvt_set(p->owner, NULL); p->owner = NULL; ast_module_unref(myself); } ast_mutex_unlock(&p->lock); ast_mutex_lock(&usecnt_lock); usecnt--; ast_mutex_unlock(&usecnt_lock); /* Notify the module monitors that use count for resource has changed */ ast_update_use_count(); } else { ast_debug(1, "No call to hangup\n" ); } if (gH323Debug) ast_verb(0, "+++ ooh323_hangup\n"); return 0; } static int ooh323_answer(struct ast_channel *ast) { struct ooh323_pvt *p = ast_channel_tech_pvt(ast); char *callToken = (char *)NULL; if (gH323Debug) ast_verb(0, "--- ooh323_answer\n"); if (p) { ast_mutex_lock(&p->lock); callToken = (p->callToken ? strdup(p->callToken) : NULL); if (ast_channel_state(ast) != AST_STATE_UP) { ast_channel_lock(ast); if (!p->alertsent) { if (gH323Debug) { ast_debug(1, "Sending forced ringback for %s, res = %d\n", callToken, ooManualRingback(callToken)); } else { ooManualRingback(callToken); } p->alertsent = 1; } ast_setstate(ast, AST_STATE_UP); if (option_debug) ast_debug(1, "ooh323_answer(%s)\n", ast_channel_name(ast)); ast_channel_unlock(ast); ooAnswerCall(p->callToken); } if (callToken) { free(callToken); } ast_mutex_unlock(&p->lock); } if (gH323Debug) ast_verb(0, "+++ ooh323_answer\n"); return 0; } static struct ast_frame *ooh323_read(struct ast_channel *ast) { struct ast_frame *fr; static struct ast_frame null_frame = { AST_FRAME_NULL, }; struct ooh323_pvt *p = ast_channel_tech_pvt(ast); if (!p) return &null_frame; ast_mutex_lock(&p->lock); if (p->rtp) fr = ooh323_rtp_read(ast, p); else fr = &null_frame; /* time(&p->lastrtprx); */ ast_mutex_unlock(&p->lock); return fr; } static int ooh323_write(struct ast_channel *ast, struct ast_frame *f) { struct ooh323_pvt *p = ast_channel_tech_pvt(ast); int res = 0; char buf[256]; if (p) { ast_mutex_lock(&p->lock); p->lastrtptx = time(NULL); if (f->frametype == AST_FRAME_MODEM) { ast_debug(1, "Send UDPTL %d/%d len %d for %s\n", f->frametype, f->subclass.integer, f->datalen, ast_channel_name(ast)); if (p->udptl) res = ast_udptl_write(p->udptl, f); ast_mutex_unlock(&p->lock); return res; } if (f->frametype == AST_FRAME_VOICE) { /* sending progress for first */ if (!ast_test_flag(p, H323_OUTGOING) && !p->progsent && p->callToken) { ooManualProgress(p->callToken); p->progsent = 1; } if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) { if (!(ast_format_cap_is_empty(ast_channel_nativeformats(ast)))) { ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n", ast_getformatname(&f->subclass.format), ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)), ast_getformatname(ast_channel_readformat(ast)), ast_getformatname(ast_channel_writeformat(ast))); ast_set_write_format(ast, &f->subclass.format); } else { /* ast_set_write_format(ast, f->subclass); ast->nativeformats = f->subclass; */ } ast_mutex_unlock(&p->lock); return 0; } if (p->rtp) res = ast_rtp_instance_write(p->rtp, f); ast_mutex_unlock(&p->lock); } else if (f->frametype == AST_FRAME_IMAGE) { ast_mutex_unlock(&p->lock); return 0; } else { ast_log(LOG_WARNING, "Can't send %d type frames with OOH323 write\n", f->frametype); ast_mutex_unlock(&p->lock); return 0; } } return res; } static int ooh323_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen) { struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(ast); char *callToken = (char *)NULL; int res = -1; if (!p) return -1; ast_mutex_lock(&p->lock); callToken = (p->callToken ? strdup(p->callToken) : NULL); ast_mutex_unlock(&p->lock); if (!callToken) { if (gH323Debug) ast_verb(0, " ooh323_indicate - No callToken\n"); return -1; } if (!ast_sockaddr_isnull(&p->redirip)) { res = 0; } if (gH323Debug) { ast_verb(0, "----- ooh323_indicate %d on call %s\n", condition, callToken); } ast_mutex_lock(&p->lock); switch (condition) { case AST_CONTROL_INCOMPLETE: /* While h323 does support overlapped dialing, this channel driver does not * at this time. Treat a response of Incomplete as if it were congestion. */ case AST_CONTROL_CONGESTION: if (!ast_test_flag(p, H323_ALREADYGONE)) { ooHangCall(callToken, OO_REASON_LOCAL_CONGESTED, AST_CAUSE_SWITCH_CONGESTION); } break; case AST_CONTROL_BUSY: if (!ast_test_flag(p, H323_ALREADYGONE)) { ooHangCall(callToken, OO_REASON_LOCAL_BUSY, AST_CAUSE_USER_BUSY); } break; case AST_CONTROL_HOLD: ast_moh_start(ast, data, NULL); break; case AST_CONTROL_UNHOLD: ast_moh_stop(ast); break; case AST_CONTROL_PROGRESS: if (ast_channel_state(ast) != AST_STATE_UP) { if (!p->progsent) { if (gH323Debug) { ast_debug(1, "Sending manual progress for %s, res = %d\n", callToken, ooManualProgress(callToken)); } else { ooManualProgress(callToken); } p->progsent = 1; } } break; case AST_CONTROL_RINGING: if (ast_channel_state(ast) == AST_STATE_RING || ast_channel_state(ast) == AST_STATE_RINGING) { if (!p->alertsent) { if (gH323Debug) { ast_debug(1, "Sending manual ringback for %s, res = %d\n", callToken, ooManualRingback(callToken)); } else { ooManualRingback(callToken); } p->alertsent = 1; } p->alertsent = 1; } break; case AST_CONTROL_SRCUPDATE: if (p->rtp) { ast_rtp_instance_update_source(p->rtp); } break; case AST_CONTROL_SRCCHANGE: if (p->rtp) { ast_rtp_instance_change_source(p->rtp); } break; case AST_CONTROL_CONNECTED_LINE: if (!ast_channel_connected(ast)->id.name.valid || ast_strlen_zero(ast_channel_connected(ast)->id.name.str)) { break; } if (gH323Debug) { ast_debug(1, "Sending connected line info for %s (%s)\n", callToken, ast_channel_connected(ast)->id.name.str); } ooSetANI(callToken, ast_channel_connected(ast)->id.name.str); break; case AST_CONTROL_T38_PARAMETERS: if (p->t38support != T38_ENABLED) { struct ast_control_t38_parameters parameters = { .request_response = 0 }; parameters.request_response = AST_T38_REFUSED; ast_queue_control_data(ast, AST_CONTROL_T38_PARAMETERS, ¶meters, sizeof(parameters)); break; } if (datalen != sizeof(struct ast_control_t38_parameters)) { ast_log(LOG_ERROR, "Invalid datalen for AST_CONTROL_T38. " "Expected %d, got %d\n", (int)sizeof(enum ast_control_t38), (int)datalen); } else { const struct ast_control_t38_parameters *parameters = data; struct ast_control_t38_parameters our_parameters; enum ast_control_t38 message = parameters->request_response; switch (message) { case AST_T38_NEGOTIATED: if (p->faxmode) { res = 0; break; } case AST_T38_REQUEST_NEGOTIATE: if (p->faxmode) { /* T.38 already negotiated */ our_parameters.request_response = AST_T38_NEGOTIATED; our_parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl); our_parameters.rate = AST_T38_RATE_14400; ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, &our_parameters, sizeof(our_parameters)); } else if (!p->chmodepend) { p->chmodepend = 1; ooRequestChangeMode(p->callToken, 1); res = 0; } break; case AST_T38_REQUEST_TERMINATE: if (!p->faxmode) { /* T.38 already terminated */ our_parameters.request_response = AST_T38_TERMINATED; ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, &our_parameters, sizeof(our_parameters)); } else if (!p->chmodepend) { p->chmodepend = 1; ooRequestChangeMode(p->callToken, 0); res = 0; } break; case AST_T38_REQUEST_PARMS: our_parameters.request_response = AST_T38_REQUEST_PARMS; our_parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl); our_parameters.rate = AST_T38_RATE_14400; ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, &our_parameters, sizeof(our_parameters)); res = AST_T38_REQUEST_PARMS; break; default: ; } } break; case AST_CONTROL_PROCEEDING: case -1: break; default: ast_log(LOG_WARNING, "Don't know how to indicate condition %d on %s\n", condition, callToken); } ast_mutex_unlock(&p->lock); if (gH323Debug) { ast_verb(0, "++++ ooh323_indicate %d on %s is %d\n", condition, callToken, res); } free(callToken); return res; } static int ooh323_queryoption(struct ast_channel *ast, int option, void *data, int *datalen) { struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(ast); int res = -1; enum ast_t38_state state = T38_STATE_UNAVAILABLE; char* cp; if (!p) return -1; ast_mutex_lock(&p->lock); if (gH323Debug) ast_verb(0, "----- ooh323_queryoption %d on channel %s\n", option, ast_channel_name(ast)); switch (option) { case AST_OPTION_T38_STATE: if (*datalen != sizeof(enum ast_t38_state)) { ast_log(LOG_ERROR, "Invalid datalen for AST_OPTION_T38_STATE option." " Expected %d, got %d\n", (int)sizeof(enum ast_t38_state), *datalen); break; } if (p->t38support != T38_DISABLED) { if (p->faxmode) { state = (p->chmodepend) ? T38_STATE_NEGOTIATING : T38_STATE_NEGOTIATED; } else { state = T38_STATE_UNKNOWN; } } *((enum ast_t38_state *) data) = state; res = 0; break; case AST_OPTION_DIGIT_DETECT: cp = (char *) data; *cp = p->vad ? 1 : 0; ast_debug(1, "Reporting digit detection %sabled on %s\n", *cp ? "en" : "dis", ast_channel_name(ast)); res = 0; break; default: ; } if (gH323Debug) ast_verb(0, "+++++ ooh323_queryoption %d on channel %s\n", option, ast_channel_name(ast)); ast_mutex_unlock(&p->lock); return res; } static int ooh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) { struct ooh323_pvt *p = ast_channel_tech_pvt(newchan); if (!p) return -1; if (gH323Debug) ast_verb(0, "--- ooh323c ooh323_fixup\n"); ast_mutex_lock(&p->lock); if (p->owner != oldchan) { ast_log(LOG_WARNING, "Old channel wasn't %p but was %p\n", oldchan, p->owner); ast_mutex_unlock(&p->lock); return -1; } if (p->owner == oldchan) { p->owner = newchan; } else { p->owner = oldchan; } ast_mutex_unlock(&p->lock); if (gH323Debug) ast_verb(0, "+++ ooh323c ooh323_fixup \n"); return 0; } void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txframes) { struct ooh323_pvt *p = NULL; char formats[FORMAT_STRING_SIZE]; if (gH323Debug) ast_verb(0, "--- ooh323_update_writeformat %s/%d\n", ast_getformatname(fmt), txframes); p = find_call(call); if (!p) { ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken); return; } ast_mutex_lock(&p->lock); ast_format_copy(&(p->writeformat), fmt); if (p->owner) { while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1,"Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } if (gH323Debug) ast_verb(0, "Writeformat before update %s/%s\n", ast_getformatname(ast_channel_writeformat(p->owner)), ast_getformatname_multiple(formats, sizeof(formats), ast_channel_nativeformats(p->owner))); if (txframes) ast_codec_pref_setsize(&p->prefs, fmt, txframes); ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs); if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) { ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, p->dtmfcodec, "audio", "telephone-event", 0); } if (p->dtmfmode & H323_DTMF_CISCO && p->dtmfcodec) { ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0); } ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt); ast_set_write_format(p->owner, ast_channel_writeformat(p->owner)); ast_set_read_format(p->owner, ast_channel_readformat(p->owner)); ast_channel_unlock(p->owner); } else ast_log(LOG_ERROR, "No owner found\n"); ast_mutex_unlock(&p->lock); if (gH323Debug) ast_verb(0, "+++ ooh323_update_writeformat\n"); } void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt) { struct ooh323_pvt *p = NULL; if (gH323Debug) ast_verb(0, "--- ooh323_update_readformat %s\n", ast_getformatname(fmt)); p = find_call(call); if (!p) { ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken); return; } ast_mutex_lock(&p->lock); ast_format_copy(&(p->readformat), fmt); if (p->owner) { while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1,"Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } if (gH323Debug) ast_verb(0, "Readformat before update %s\n", ast_getformatname(ast_channel_readformat(p->owner))); ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt); ast_set_read_format(p->owner, ast_channel_readformat(p->owner)); ast_channel_unlock(p->owner); } else ast_log(LOG_ERROR, "No owner found\n"); ast_mutex_unlock(&p->lock); if (gH323Debug) ast_verb(0, "+++ ooh323_update_readformat\n"); } int onAlerting(ooCallData *call) { struct ooh323_pvt *p = NULL; struct ast_channel *c = NULL; if (gH323Debug) ast_verb(0, "--- onAlerting %s\n", call->callToken); p = find_call(call); if(!p) { ast_log(LOG_ERROR, "No matching call found\n"); return -1; } ast_mutex_lock(&p->lock); if (!p->owner) { ast_mutex_unlock(&p->lock); ast_debug(1, "Channel has no owner\n"); return 0; } while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return 0; } c = p->owner; if (call->remoteDisplayName) { struct ast_party_connected_line connected; struct ast_set_party_connected_line update_connected; memset(&update_connected, 0, sizeof(update_connected)); update_connected.id.name = 1; ast_party_connected_line_init(&connected); connected.id.name.valid = 1; connected.id.name.str = (char *) call->remoteDisplayName; connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; ast_channel_queue_connected_line_update(c, &connected, &update_connected); } if (ast_channel_state(c) != AST_STATE_UP) ast_setstate(c, AST_STATE_RINGING); ast_queue_control(c, AST_CONTROL_RINGING); ast_channel_unlock(c); ast_mutex_unlock(&p->lock); if (gH323Debug) ast_verb(0, "+++ onAlerting %s\n", call->callToken); return OO_OK; } int onProgress(ooCallData *call) { struct ooh323_pvt *p = NULL; struct ast_channel *c = NULL; if (gH323Debug) ast_verb(0, "--- onProgress %s\n", call->callToken); p = find_call(call); if(!p) { ast_log(LOG_ERROR, "No matching call found\n"); return -1; } ast_mutex_lock(&p->lock); if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return 0; } while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return 0; } c = p->owner; if (call->remoteDisplayName) { struct ast_party_connected_line connected; struct ast_set_party_connected_line update_connected; memset(&update_connected, 0, sizeof(update_connected)); update_connected.id.name = 1; ast_party_connected_line_init(&connected); connected.id.name.valid = 1; connected.id.name.str = (char *) call->remoteDisplayName; connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; ast_channel_queue_connected_line_update(c, &connected, &update_connected); } if (ast_channel_state(c) != AST_STATE_UP) ast_setstate(c, AST_STATE_RINGING); ast_queue_control(c, AST_CONTROL_PROGRESS); ast_channel_unlock(c); ast_mutex_unlock(&p->lock); if (gH323Debug) ast_verb(0, "+++ onProgress %s\n", call->callToken); return OO_OK; } /** * Callback for sending digits from H.323 up to asterisk * */ int ooh323_onReceivedDigit(OOH323CallData *call, const char *digit) { struct ooh323_pvt *p = NULL; struct ast_frame f; int res; ast_debug(1, "Received Digit: %c\n", digit[0]); p = find_call(call); if (!p) { ast_log(LOG_ERROR, "Failed to find a matching call.\n"); return -1; } if (!p->owner) { ast_log(LOG_ERROR, "Channel has no owner\n"); return -1; } ast_mutex_lock(&p->lock); memset(&f, 0, sizeof(f)); f.frametype = AST_FRAME_DTMF; f.subclass.integer = digit[0]; f.datalen = 0; f.samples = 800; f.offset = 0; f.data.ptr = NULL; f.mallocd = 0; f.src = "SEND_DIGIT"; while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return 0; } res = ast_queue_frame(p->owner, &f); ast_channel_unlock(p->owner); ast_mutex_unlock(&p->lock); return res; } int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg) { struct ooh323_pvt *p = NULL; struct ooh323_user *user = NULL; struct ast_channel *c = NULL; ooAliases *alias = NULL; char *at = NULL; char number [OO_MAX_NUMBER_LENGTH]; if (gH323Debug) ast_verb(0, "--- ooh323_onReceivedSetup %s\n", call->callToken); if (!(p = ooh323_alloc(call->callReference, call->callToken))) { ast_log(LOG_ERROR, "Failed to create a new call.\n"); return -1; } ast_mutex_lock(&p->lock); ast_clear_flag(p, H323_OUTGOING); if (call->remoteDisplayName) { p->callerid_name = strdup(call->remoteDisplayName); } if (ooCallGetCallingPartyNumber(call, number, OO_MAX_NUMBER_LENGTH) == OO_OK) { p->callerid_num = strdup(number); } if (call->remoteAliases) { for (alias = call->remoteAliases; alias; alias = alias->next) { if (alias->type == T_H225AliasAddress_h323_ID) { if (!p->callerid_name) { p->callerid_name = strdup(alias->value); } ast_copy_string(p->caller_h323id, alias->value, sizeof(p->caller_h323id)); } else if(alias->type == T_H225AliasAddress_dialedDigits) { if(!p->callerid_num) p->callerid_num = strdup(alias->value); ast_copy_string(p->caller_dialedDigits, alias->value, sizeof(p->caller_dialedDigits)); } else if(alias->type == T_H225AliasAddress_email_ID) { ast_copy_string(p->caller_email, alias->value, sizeof(p->caller_email)); } else if(alias->type == T_H225AliasAddress_url_ID) { ast_copy_string(p->caller_url, alias->value, sizeof(p->caller_url)); } } } number[0] = '\0'; if(ooCallGetCalledPartyNumber(call, number, OO_MAX_NUMBER_LENGTH)== OO_OK) { ast_copy_string(p->exten, number, sizeof(p->exten)); } else { update_our_aliases(call, p); if (!ast_strlen_zero(p->callee_dialedDigits)) { ast_copy_string(p->exten, p->callee_dialedDigits, sizeof(p->exten)); } else if(!ast_strlen_zero(p->callee_h323id)) { ast_copy_string(p->exten, p->callee_h323id, sizeof(p->exten)); } else if(!ast_strlen_zero(p->callee_email)) { ast_copy_string(p->exten, p->callee_email, sizeof(p->exten)); if ((at = strchr(p->exten, '@'))) { *at = '\0'; } } } /* if no extension found, set to default 's' */ if (ast_strlen_zero(p->exten)) { p->exten[0]='s'; p->exten[1]='\0'; } user = find_user(p->callerid_name, call->remoteIP); if(user && (user->incominglimit == 0 || user->inUse < user->incominglimit)) { ast_mutex_lock(&user->lock); p->username = strdup(user->name); p->neighbor.user = user->mUseIP ? ast_strdup(user->mIP) : ast_strdup(user->name); ast_copy_string(p->context, user->context, sizeof(p->context)); ast_copy_string(p->accountcode, user->accountcode, sizeof(p->accountcode)); p->amaflags = user->amaflags; ast_format_cap_copy(p->cap, user->cap); p->g729onlyA = user->g729onlyA; memcpy(&p->prefs, &user->prefs, sizeof(struct ast_codec_pref)); p->dtmfmode |= user->dtmfmode; p->dtmfcodec = user->dtmfcodec; p->faxdetect = user->faxdetect; p->t38support = user->t38support; p->rtptimeout = user->rtptimeout; p->nat = user->nat; p->h245tunneling = user->h245tunneling; p->faststart = user->faststart; p->directrtp = user->directrtp; p->earlydirect = user->earlydirect; if (p->faststart) OO_SETFLAG(call->flags, OO_M_FASTSTART); else OO_CLRFLAG(call->flags, OO_M_FASTSTART); /* if we disable h245tun for this user then we clear flag */ /* in any other case we don't must touch this */ /* ie if we receive setup without h245tun but enabled we can't enable it per call */ if (!p->h245tunneling) OO_CLRFLAG(call->flags, OO_M_TUNNELING); if (user->rtpmask && user->rtpmaskstr[0]) { p->rtpmask = user->rtpmask; ast_copy_string(p->rtpmaskstr, user->rtpmaskstr, sizeof(p->rtpmaskstr)); } if (user->rtdrcount > 0 && user->rtdrinterval > 0) { p->rtdrcount = user->rtdrcount; p->rtdrinterval = user->rtdrinterval; } if (user->incominglimit) user->inUse++; ast_mutex_unlock(&user->lock); } else { if (!OO_TESTFLAG(p->flags,H323_DISABLEGK)) { p->username = strdup(call->remoteIP); p->directrtp = gDirectRTP; p->earlydirect = gEarlyDirect; } else { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Unacceptable ip %s\n", call->remoteIP); if (!user) { ooHangCall(call->callToken, ooh323_convert_hangupcause_asteriskToH323(AST_CAUSE_CALL_REJECTED), AST_CAUSE_CALL_REJECTED); call->callEndReason = OO_REASON_REMOTE_REJECTED; } else { ooHangCall(call->callToken, ooh323_convert_hangupcause_asteriskToH323(AST_CAUSE_NORMAL_CIRCUIT_CONGESTION), AST_CAUSE_NORMAL_CIRCUIT_CONGESTION); call->callEndReason = OO_REASON_REMOTE_REJECTED; } ast_set_flag(p, H323_NEEDDESTROY); return -1; } } ooh323c_set_capability_for_call(call, &p->prefs, p->cap, p->dtmfmode, p->dtmfcodec, p->t38support, p->g729onlyA); /* Incoming call */ c = ooh323_new(p, AST_STATE_RING, p->username, 0, NULL); if(!c) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Could not create ast_channel\n"); return -1; } if (!configure_local_rtp(p, call)) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Couldn't create rtp structure\n"); return -1; } ast_mutex_unlock(&p->lock); if (gH323Debug) ast_verb(0, "+++ ooh323_onReceivedSetup - Determined context %s, " "extension %s\n", p->context, p->exten); return OO_OK; } int onOutgoingCall(ooCallData *call) { struct ooh323_pvt *p = NULL; int i = 0; if (gH323Debug) ast_verb(0, "--- onOutgoingCall %lx: %s\n", (long unsigned int) call, call->callToken); if (!strcmp(call->callType, "outgoing")) { p = find_call(call); if (!p) { ast_log(LOG_ERROR, "Failed to find a matching call.\n"); return -1; } ast_mutex_lock(&p->lock); if (!ast_strlen_zero(p->callerid_name)) { ooCallSetCallerId(call, p->callerid_name); } if (!ast_strlen_zero(p->callerid_num)) { i = 0; while (*(p->callerid_num + i) != '\0') { if(!isdigit(*(p->callerid_num+i))) { break; } i++; } if(*(p->callerid_num+i) == '\0') ooCallSetCallingPartyNumber(call, p->callerid_num); else { if(!p->callerid_name) ooCallSetCallerId(call, p->callerid_num); } } if (!ast_strlen_zero(p->caller_h323id)) ooCallAddAliasH323ID(call, p->caller_h323id); if (!ast_strlen_zero(p->caller_dialedDigits)) { if (gH323Debug) { ast_verb(0, "Setting dialed digits %s\n", p->caller_dialedDigits); } ooCallAddAliasDialedDigits(call, p->caller_dialedDigits); } else if (!ast_strlen_zero(p->callerid_num)) { if (ooIsDailedDigit(p->callerid_num)) { if (gH323Debug) { ast_verb(0, "setting callid number %s\n", p->callerid_num); } ooCallAddAliasDialedDigits(call, p->callerid_num); } else if (ast_strlen_zero(p->caller_h323id)) { ooCallAddAliasH323ID(call, p->callerid_num); } } if (p->rtpmask && p->rtpmaskstr[0]) { call->rtpMask = p->rtpmask; ast_mutex_lock(&call->rtpMask->lock); call->rtpMask->inuse++; ast_mutex_unlock(&call->rtpMask->lock); ast_copy_string(call->rtpMaskStr, p->rtpmaskstr, sizeof(call->rtpMaskStr)); } if (!p->rtp && !configure_local_rtp(p, call)) { ast_mutex_unlock(&p->lock); return OO_FAILED; } ast_mutex_unlock(&p->lock); } if (gH323Debug) ast_verb(0, "+++ onOutgoingCall %s\n", call->callToken); return OO_OK; } int onNewCallCreated(ooCallData *call) { struct ooh323_pvt *p = NULL; int i = 0; if (gH323Debug) ast_verb(0, "--- onNewCallCreated %lx: %s\n", (long unsigned int) call, call->callToken); ast_mutex_lock(&call->Lock); if (ooh323c_start_call_thread(call)) { ast_log(LOG_ERROR,"Failed to create call thread.\n"); ast_mutex_unlock(&call->Lock); return -1; } if (!strcmp(call->callType, "outgoing")) { p = find_call(call); if (!p) { ast_log(LOG_ERROR, "Failed to find a matching call.\n"); ast_mutex_unlock(&call->Lock); return -1; } ast_mutex_lock(&p->lock); if (!ast_strlen_zero(p->callerid_name)) { ooCallSetCallerId(call, p->callerid_name); } if (!ast_strlen_zero(p->callerid_num)) { i = 0; while (*(p->callerid_num + i) != '\0') { if(!isdigit(*(p->callerid_num+i))) { break; } i++; } if(*(p->callerid_num+i) == '\0') ooCallSetCallingPartyNumber(call, p->callerid_num); else { if(ast_strlen_zero(p->callerid_name)) ooCallSetCallerId(call, p->callerid_num); } } if (!ast_strlen_zero(p->caller_h323id)) ooCallAddAliasH323ID(call, p->caller_h323id); if (!ast_strlen_zero(p->caller_dialedDigits)) { if (gH323Debug) { ast_verb(0, "Setting dialed digits %s\n", p->caller_dialedDigits); } ooCallAddAliasDialedDigits(call, p->caller_dialedDigits); } else if (!ast_strlen_zero(p->callerid_num)) { if (ooIsDailedDigit(p->callerid_num)) { if (gH323Debug) { ast_verb(0, "setting callid number %s\n", p->callerid_num); } ooCallAddAliasDialedDigits(call, p->callerid_num); } else if (ast_strlen_zero(p->caller_h323id)) { ooCallAddAliasH323ID(call, p->callerid_num); } } if (!ast_strlen_zero(p->exten)) { if (ooIsDailedDigit(p->exten)) { ooCallSetCalledPartyNumber(call, p->exten); ooCallAddRemoteAliasDialedDigits(call, p->exten); } else { ooCallAddRemoteAliasH323ID(call, p->exten); } } if (gH323Debug) { char prefsBuf[256]; ast_codec_pref_string(&p->prefs, prefsBuf, sizeof(prefsBuf)); ast_verb(0, " Outgoing call %s(%s) - Codec prefs - %s\n", p->username?p->username:"NULL", call->callToken, prefsBuf); } ooh323c_set_capability_for_call(call, &p->prefs, p->cap, p->dtmfmode, p->dtmfcodec, p->t38support, p->g729onlyA); configure_local_rtp(p, call); ast_cond_signal(&p->rtpcond); ast_mutex_unlock(&p->lock); } ast_mutex_unlock(&call->Lock); if (gH323Debug) ast_verb(0, "+++ onNewCallCreated %s\n", call->callToken); return OO_OK; } int onCallEstablished(ooCallData *call) { struct ooh323_pvt *p = NULL; if (gH323Debug) ast_verb(0, "--- onCallEstablished %s\n", call->callToken); if (!(p = find_call(call))) { ast_log(LOG_ERROR, "Failed to find a matching call.\n"); return -1; } if(ast_test_flag(p, H323_OUTGOING)) { ast_mutex_lock(&p->lock); if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return -1; } while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (p->owner) { struct ast_channel* c = p->owner; if (call->remoteDisplayName) { struct ast_party_connected_line connected; struct ast_set_party_connected_line update_connected; memset(&update_connected, 0, sizeof(update_connected)); update_connected.id.name = 1; ast_party_connected_line_init(&connected); connected.id.name.valid = 1; connected.id.name.str = (char *) call->remoteDisplayName; connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; ast_channel_queue_connected_line_update(c, &connected, &update_connected); } ast_queue_control(c, AST_CONTROL_ANSWER); ast_channel_unlock(p->owner); manager_event(EVENT_FLAG_SYSTEM,"ChannelUpdate","Channel: %s\r\nChanneltype: %s\r\n" "CallRef: %d\r\n", ast_channel_name(c), "OOH323", p->call_reference); } ast_mutex_unlock(&p->lock); } if (gH323Debug) ast_verb(0, "+++ onCallEstablished %s\n", call->callToken); return OO_OK; } int onCallCleared(ooCallData *call) { struct ooh323_pvt *p = NULL; int ownerLock = 0; if (gH323Debug) ast_verb(0, "--- onCallCleared %s \n", call->callToken); if ((p = find_call(call))) { ast_mutex_lock(&p->lock); while (p->owner) { if (ast_channel_trylock(p->owner)) { ooTrace(OOTRCLVLINFO, "Failed to grab lock, trying again\n"); ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } else { ownerLock = 1; break; } } if (ownerLock) { if (!ast_test_flag(p, H323_ALREADYGONE)) { ast_set_flag(p, H323_ALREADYGONE); ast_channel_hangupcause_set(p->owner, call->q931cause); ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV); ast_queue_hangup_with_cause(p->owner,call->q931cause); } } if(p->owner) { ast_channel_tech_pvt_set(p->owner, NULL); ast_channel_unlock(p->owner); p->owner = NULL; ast_module_unref(myself); } ast_set_flag(p, H323_NEEDDESTROY); ooh323c_stop_call_thread(call); ast_mutex_unlock(&p->lock); ast_mutex_lock(&usecnt_lock); usecnt--; ast_mutex_unlock(&usecnt_lock); } if (gH323Debug) ast_verb(0, "+++ onCallCleared\n"); return OO_OK; } /* static void ooh323_delete_user(struct ooh323_user *user) { struct ooh323_user *prev = NULL, *cur = NULL; if (gH323Debug) ast_verb(0, "--- ooh323_delete_user\n"); if (user) { cur = userl.users; ast_mutex_lock(&userl.lock); while (cur) { if (cur == user) break; prev = cur; cur = cur->next; } if (cur) { if (prev) prev->next = cur->next; else userl.users = cur->next; } ast_mutex_unlock(&userl.lock); free(user); } if (gH323Debug) ast_verb(0, "+++ ooh323_delete_user\n"); } */ void ooh323_delete_peer(struct ooh323_peer *peer) { struct ooh323_peer *prev = NULL, *cur = NULL; if (gH323Debug) ast_verb(0, "--- ooh323_delete_peer\n"); if (peer) { cur = peerl.peers; ast_mutex_lock(&peerl.lock); while(cur) { if(cur==peer) break; prev = cur; cur = cur->next; } if (cur) { if(prev) prev->next = cur->next; else peerl.peers = cur->next; } ast_mutex_unlock(&peerl.lock); if(peer->h323id) free(peer->h323id); if(peer->email) free(peer->email); if(peer->url) free(peer->url); if(peer->e164) free(peer->e164); peer->cap = ast_format_cap_destroy(peer->cap); free(peer); } if (gH323Debug) ast_verb(0, "+++ ooh323_delete_peer\n"); } static struct ooh323_user *build_user(const char *name, struct ast_variable *v) { struct ooh323_user *user = NULL; if (gH323Debug) ast_verb(0, "--- build_user\n"); user = ast_calloc(1,sizeof(struct ooh323_user)); if (user) { memset(user, 0, sizeof(struct ooh323_user)); if (!(user->cap = ast_format_cap_alloc())) { ast_free(user); return NULL; } ast_mutex_init(&user->lock); ast_copy_string(user->name, name, sizeof(user->name)); ast_format_cap_copy(user->cap, gCap); memcpy(&user->prefs, &gPrefs, sizeof(user->prefs)); user->rtptimeout = gRTPTimeout; user->nat = gNat; user->dtmfmode = gDTMFMode; user->dtmfcodec = gDTMFCodec; user->faxdetect = gFAXdetect; user->t38support = gT38Support; user->faststart = gFastStart; user->h245tunneling = gTunneling; user->directrtp = gDirectRTP; user->earlydirect = gEarlyDirect; user->g729onlyA = g729onlyA; /* set default context */ ast_copy_string(user->context, gContext, sizeof(user->context)); ast_copy_string(user->accountcode, gAccountcode, sizeof(user->accountcode)); user->amaflags = gAMAFLAGS; while (v) { if (!strcasecmp(v->name, "context")) { ast_copy_string(user->context, v->value, sizeof(user->context)); } else if (!strcasecmp(v->name, "incominglimit")) { user->incominglimit = atoi(v->value); if (user->incominglimit < 0) user->incominglimit = 0; } else if (!strcasecmp(v->name, "accountcode")) { ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode)); } else if (!strcasecmp(v->name, "roundtrip")) { sscanf(v->value, "%d,%d", &user->rtdrcount, &user->rtdrinterval); } else if (!strcasecmp(v->name, "faststart")) { user->faststart = ast_true(v->value); } else if (!strcasecmp(v->name, "h245tunneling")) { user->h245tunneling = ast_true(v->value); } else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) { user->directrtp = ast_true(v->value); user->earlydirect = ast_true(v->value); } else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) { user->earlydirect = ast_true(v->value); } else if (!strcasecmp(v->name, "g729onlyA")) { user->g729onlyA = ast_true(v->value); } else if (!strcasecmp(v->name, "nat")) { user->nat = ast_true(v->value); } else if (!strcasecmp(v->name, "rtptimeout")) { user->rtptimeout = atoi(v->value); if (user->rtptimeout < 0) user->rtptimeout = gRTPTimeout; } else if (!strcasecmp(v->name, "rtpmask")) { if ((user->rtpmask = ast_calloc(1, sizeof(struct OOH323Regex))) && (regcomp(&user->rtpmask->regex, v->value, REG_EXTENDED) == 0)) { ast_mutex_init(&user->rtpmask->lock); user->rtpmask->inuse = 1; ast_copy_string(user->rtpmaskstr, v->value, sizeof(user->rtpmaskstr)); } else user->rtpmask = NULL; } else if (!strcasecmp(v->name, "disallow")) { ast_parse_allow_disallow(&user->prefs, user->cap, v->value, 0); } else if (!strcasecmp(v->name, "allow")) { const char* tcodecs = v->value; if (!strcasecmp(v->value, "all")) { tcodecs = "ulaw,alaw,g729,g723,gsm"; } ast_parse_allow_disallow(&user->prefs, user->cap, tcodecs, 1); } else if (!strcasecmp(v->name, "amaflags")) { user->amaflags = ast_cdr_amaflags2int(v->value); } else if (!strcasecmp(v->name, "ip") || !strcasecmp(v->name, "host")) { struct ast_sockaddr p; if (!ast_parse_arg(v->value, PARSE_ADDR, &p)) { ast_copy_string(user->mIP, ast_sockaddr_stringify_addr(&p), sizeof(user->mIP)-1); } else { ast_copy_string(user->mIP, v->value, sizeof(user->mIP)-1); } user->mUseIP = 1; } else if (!strcasecmp(v->name, "dtmfmode")) { if (!strcasecmp(v->value, "rfc2833")) user->dtmfmode = H323_DTMF_RFC2833; if (!strcasecmp(v->value, "cisco")) user->dtmfmode = H323_DTMF_CISCO; else if (!strcasecmp(v->value, "q931keypad")) user->dtmfmode = H323_DTMF_Q931; else if (!strcasecmp(v->value, "h245alphanumeric")) user->dtmfmode = H323_DTMF_H245ALPHANUMERIC; else if (!strcasecmp(v->value, "h245signal")) user->dtmfmode = H323_DTMF_H245SIGNAL; else if (!strcasecmp(v->value, "inband")) user->dtmfmode = H323_DTMF_INBAND; } else if (!strcasecmp(v->name, "relaxdtmf")) { user->dtmfmode |= ast_true(v->value) ? H323_DTMF_INBANDRELAX : 0; } else if (!strcasecmp(v->name, "dtmfcodec") && atoi(v->value)) { user->dtmfcodec = atoi(v->value); } else if (!strcasecmp(v->name, "faxdetect")) { if (ast_true(v->value)) { user->faxdetect = FAXDETECT_CNG | FAXDETECT_T38; } else if (ast_false(v->value)) { user->faxdetect = 0; } else { char *buf = ast_strdupa(v->value); char *word, *next = buf; user->faxdetect = 0; while ((word = strsep(&next, ","))) { if (!strcasecmp(word, "cng")) { user->faxdetect |= FAXDETECT_CNG; } else if (!strcasecmp(word, "t38")) { user->faxdetect |= FAXDETECT_T38; } else { ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno); } } } } else if (!strcasecmp(v->name, "t38support")) { if (!strcasecmp(v->value, "disabled")) user->t38support = T38_DISABLED; if (!strcasecmp(v->value, "no")) user->t38support = T38_DISABLED; else if (!strcasecmp(v->value, "faxgw")) user->t38support = T38_FAXGW; else if (!strcasecmp(v->value, "yes")) user->t38support = T38_ENABLED; } v = v->next; } } if (gH323Debug) ast_verb(0, "+++ build_user\n"); return user; } static struct ooh323_peer *build_peer(const char *name, struct ast_variable *v, int friend_type) { struct ooh323_peer *peer = NULL; if (gH323Debug) ast_verb(0, "--- build_peer\n"); peer = ast_calloc(1, sizeof(*peer)); if (peer) { memset(peer, 0, sizeof(struct ooh323_peer)); if (!(peer->cap = ast_format_cap_alloc())) { ast_free(peer); return NULL; } ast_mutex_init(&peer->lock); ast_copy_string(peer->name, name, sizeof(peer->name)); ast_format_cap_copy(peer->cap, gCap); memcpy(&peer->prefs, &gPrefs, sizeof(peer->prefs)); peer->rtptimeout = gRTPTimeout; peer->nat = gNat; ast_copy_string(peer->accountcode, gAccountcode, sizeof(peer->accountcode)); peer->amaflags = gAMAFLAGS; peer->dtmfmode = gDTMFMode; peer->dtmfcodec = gDTMFCodec; peer->faxdetect = gFAXdetect; peer->t38support = gT38Support; peer->faststart = gFastStart; peer->h245tunneling = gTunneling; peer->directrtp = gDirectRTP; peer->earlydirect = gEarlyDirect; peer->g729onlyA = g729onlyA; peer->port = 1720; if (0 == friend_type) { peer->mFriend = 1; } while (v) { if (!strcasecmp(v->name, "h323id")) { if (!(peer->h323id = ast_strdup(v->value))) { ast_log(LOG_ERROR, "Could not allocate memory for h323id of " "peer %s\n", name); ooh323_delete_peer(peer); return NULL; } } else if (!strcasecmp(v->name, "e164")) { if (!(peer->e164 = ast_strdup(v->value))) { ast_log(LOG_ERROR, "Could not allocate memory for e164 of " "peer %s\n", name); ooh323_delete_peer(peer); return NULL; } } else if (!strcasecmp(v->name, "email")) { if (!(peer->email = ast_strdup(v->value))) { ast_log(LOG_ERROR, "Could not allocate memory for email of " "peer %s\n", name); ooh323_delete_peer(peer); return NULL; } } else if (!strcasecmp(v->name, "url")) { if (!(peer->url = ast_strdup(v->value))) { ast_log(LOG_ERROR, "Could not allocate memory for h323id of " "peer %s\n", name); ooh323_delete_peer(peer); return NULL; } } else if (!strcasecmp(v->name, "port")) { peer->port = atoi(v->value); } else if (!strcasecmp(v->name, "host") || !strcasecmp(v->name, "ip")) { struct ast_sockaddr p; if (!ast_parse_arg(v->value, PARSE_ADDR, &p)) { ast_copy_string(peer->ip, ast_sockaddr_stringify_host(&p), sizeof(peer->ip)); } else { ast_copy_string(peer->ip, v->value, sizeof(peer->ip)); } } else if (!strcasecmp(v->name, "outgoinglimit")) { peer->outgoinglimit = atoi(v->value); if (peer->outgoinglimit < 0) peer->outgoinglimit = 0; } else if (!strcasecmp(v->name, "accountcode")) { ast_copy_string(peer->accountcode, v->value, sizeof(peer->accountcode)); } else if (!strcasecmp(v->name, "faststart")) { peer->faststart = ast_true(v->value); } else if (!strcasecmp(v->name, "h245tunneling")) { peer->h245tunneling = ast_true(v->value); } else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) { peer->directrtp = ast_true(v->value); peer->earlydirect = ast_true(v->value); } else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) { peer->earlydirect = ast_true(v->value); } else if (!strcasecmp(v->name, "g729onlyA")) { peer->g729onlyA = ast_true(v->value); } else if (!strcasecmp(v->name, "nat")) { peer->nat = ast_true(v->value); } else if (!strcasecmp(v->name, "rtptimeout")) { peer->rtptimeout = atoi(v->value); if(peer->rtptimeout < 0) peer->rtptimeout = gRTPTimeout; } else if (!strcasecmp(v->name, "rtpmask")) { if ((peer->rtpmask = ast_calloc(1, sizeof(struct OOH323Regex))) && (regcomp(&peer->rtpmask->regex, v->value, REG_EXTENDED) == 0)) { ast_mutex_init(&peer->rtpmask->lock); peer->rtpmask->inuse = 1; ast_copy_string(peer->rtpmaskstr, v->value, sizeof(peer->rtpmaskstr)); } else peer->rtpmask = NULL; } else if (!strcasecmp(v->name, "disallow")) { ast_parse_allow_disallow(&peer->prefs, peer->cap, v->value, 0); } else if (!strcasecmp(v->name, "allow")) { const char* tcodecs = v->value; if (!strcasecmp(v->value, "all")) { tcodecs = "ulaw,alaw,g729,g723,gsm"; } ast_parse_allow_disallow(&peer->prefs, peer->cap, tcodecs, 1); } else if (!strcasecmp(v->name, "amaflags")) { peer->amaflags = ast_cdr_amaflags2int(v->value); } else if (!strcasecmp(v->name, "roundtrip")) { sscanf(v->value, "%d,%d", &peer->rtdrcount, &peer->rtdrinterval); } else if (!strcasecmp(v->name, "dtmfmode")) { if (!strcasecmp(v->value, "rfc2833")) peer->dtmfmode = H323_DTMF_RFC2833; if (!strcasecmp(v->value, "cisco")) peer->dtmfmode = H323_DTMF_CISCO; else if (!strcasecmp(v->value, "q931keypad")) peer->dtmfmode = H323_DTMF_Q931; else if (!strcasecmp(v->value, "h245alphanumeric")) peer->dtmfmode = H323_DTMF_H245ALPHANUMERIC; else if (!strcasecmp(v->value, "h245signal")) peer->dtmfmode = H323_DTMF_H245SIGNAL; else if (!strcasecmp(v->value, "inband")) peer->dtmfmode = H323_DTMF_INBAND; } else if (!strcasecmp(v->name, "relaxdtmf")) { peer->dtmfmode |= ast_true(v->value) ? H323_DTMF_INBANDRELAX : 0; } else if (!strcasecmp(v->name, "dtmfcodec") && atoi(v->value)) { peer->dtmfcodec = atoi(v->value); } else if (!strcasecmp(v->name, "faxdetect")) { if (ast_true(v->value)) { peer->faxdetect = FAXDETECT_CNG | FAXDETECT_T38; } else if (ast_false(v->value)) { peer->faxdetect = 0; } else { char *buf = ast_strdupa(v->value); char *word, *next = buf; peer->faxdetect = 0; while ((word = strsep(&next, ","))) { if (!strcasecmp(word, "cng")) { peer->faxdetect |= FAXDETECT_CNG; } else if (!strcasecmp(word, "t38")) { peer->faxdetect |= FAXDETECT_T38; } else { ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno); } } } } else if (!strcasecmp(v->name, "t38support")) { if (!strcasecmp(v->value, "disabled")) peer->t38support = T38_DISABLED; if (!strcasecmp(v->value, "no")) peer->t38support = T38_DISABLED; else if (!strcasecmp(v->value, "faxgw")) peer->t38support = T38_FAXGW; else if (!strcasecmp(v->value, "yes")) peer->t38support = T38_ENABLED; } v = v->next; } } if (gH323Debug) ast_verb(0, "+++ build_peer\n"); return peer; } static int ooh323_do_reload(void) { if (gH323Debug) { ast_verb(0, "--- ooh323_do_reload\n"); } /* Gatekeeper */ if (gH323ep.gkClient) { ooGkClientDestroy(); } reload_config(1); /* Gatekeeper */ if (gRasGkMode == RasUseSpecificGatekeeper || gRasGkMode == RasDiscoverGatekeeper) { ooGkClientInit(gRasGkMode, (gRasGkMode == RasUseSpecificGatekeeper) ? gGatekeeper : 0, 0); ooGkClientStart(gH323ep.gkClient); } if (gH323Debug) { ast_verb(0, "+++ ooh323_do_reload\n"); } return 0; } /*--- h323_reload: Force reload of module from cli ---*/ char *handle_cli_ooh323_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: e->command = "ooh323 reload"; e->usage = "Usage: ooh323 reload\n" " Reload OOH323 config.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 2) return CLI_SHOWUSAGE; if (gH323Debug) ast_verb(0, "--- ooh323_reload\n"); ast_mutex_lock(&h323_reload_lock); if (h323_reloading) { ast_verb(0, "Previous OOH323 reload not yet done\n"); } else { h323_reloading = 1; } ast_mutex_unlock(&h323_reload_lock); restart_monitor(); if (gH323Debug) ast_verb(0, "+++ ooh323_reload\n"); return 0; } int reload_config(int reload) { int format; struct ooAliases *pNewAlias = NULL, *cur, *prev; struct ast_config *cfg; struct ast_variable *v; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ooh323_user *user = NULL; struct ooh323_peer *peer = NULL; char *cat; const char *utype; struct ast_format tmpfmt; if (gH323Debug) ast_verb(0, "--- reload_config\n"); cfg = ast_config_load((char*)config, config_flags); /* We *must* have a config file otherwise stop immediately */ if (!cfg) { ast_log(LOG_NOTICE, "Unable to load config %s, OOH323 disabled\n", config); return 1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) return RESULT_SUCCESS; if (reload) { delete_users(); delete_peers(); if (gH323Debug) { ast_verb(0, " reload_config - Freeing up alias list\n"); } cur = gAliasList; while (cur) { prev = cur; cur = cur->next; free(prev->value); free(prev); } gAliasList = NULL; } /* Inintialize everything to default */ strcpy(gLogFile, DEFAULT_LOGFILE); gPort = 1720; gIP[0] = '\0'; strcpy(gCallerID, DEFAULT_H323ID); ast_format_cap_set(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0)); memset(&gPrefs, 0, sizeof(struct ast_codec_pref)); gDTMFMode = H323_DTMF_RFC2833; gDTMFCodec = 101; gFAXdetect = FAXDETECT_CNG; gT38Support = T38_FAXGW; gTRCLVL = OOTRCLVLERR; gRasGkMode = RasNoGatekeeper; gGatekeeper[0] = '\0'; gRTPTimeout = 60; gNat = FALSE; gRTDRInterval = 0; gRTDRCount = 0; strcpy(gAccountcode, DEFAULT_H323ACCNT); gFastStart = 1; gTunneling = 1; gTOS = 0; strcpy(gContext, DEFAULT_CONTEXT); gAliasList = NULL; gMediaWaitForConnect = 0; ooconfig.mTCPPortStart = 12030; ooconfig.mTCPPortEnd = 12230; memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); v = ast_variable_browse(cfg, "general"); while (v) { if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) { v = v->next; continue; } if (!strcasecmp(v->name, "port")) { gPort = (int)strtol(v->value, NULL, 10); } else if (!strcasecmp(v->name, "bindaddr")) { ast_copy_string(gIP, v->value, sizeof(gIP)); if (ast_parse_arg(v->value, PARSE_ADDR, &bindaddr)) { ast_log(LOG_WARNING, "Invalid address: %s\n", v->value); ast_config_destroy(cfg); return 1; } if (ast_sockaddr_is_ipv6(&bindaddr)) { v6mode = 1; } } else if (!strcasecmp(v->name, "h225portrange")) { char* endlimit = 0; char temp[512]; ast_copy_string(temp, v->value, sizeof(temp)); endlimit = strchr(temp, ','); if (endlimit) { *endlimit = '\0'; endlimit++; ooconfig.mTCPPortStart = atoi(temp); ooconfig.mTCPPortEnd = atoi(endlimit); } else { ast_log(LOG_ERROR, "h225portrange: Invalid format, separate port range with \",\"\n"); } } else if (!strcasecmp(v->name, "gateway")) { gIsGateway = ast_true(v->value); } else if (!strcasecmp(v->name, "faststart")) { gFastStart = ast_true(v->value); if (gFastStart) ooH323EpEnableFastStart(); else ooH323EpDisableFastStart(); } else if (!strcasecmp(v->name, "mediawaitforconnect")) { gMediaWaitForConnect = ast_true(v->value); if (gMediaWaitForConnect) ooH323EpEnableMediaWaitForConnect(); else ooH323EpDisableMediaWaitForConnect(); } else if (!strcasecmp(v->name, "h245tunneling")) { gTunneling = ast_true(v->value); if (gTunneling) ooH323EpEnableH245Tunneling(); else ooH323EpDisableH245Tunneling(); } else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) { gDirectRTP = ast_true(v->value); gEarlyDirect = ast_true(v->value); } else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) { gEarlyDirect = ast_true(v->value); } else if (!strcasecmp(v->name, "g729onlyA")) { g729onlyA = ast_true(v->value); } else if (!strcasecmp(v->name, "roundtrip")) { sscanf(v->value, "%d,%d", &gRTDRCount, &gRTDRInterval); } else if (!strcasecmp(v->name, "trybemaster")) { gBeMaster = ast_true(v->value); if (gBeMaster) ooH323EpTryBeMaster(1); else ooH323EpTryBeMaster(0); } else if (!strcasecmp(v->name, "h323id")) { pNewAlias = ast_calloc(1, sizeof(struct ooAliases)); if (!pNewAlias) { ast_log(LOG_ERROR, "Failed to allocate memory for h323id alias\n"); ast_config_destroy(cfg); return 1; } if (gAliasList == NULL) { /* first h323id - set as callerid if callerid is not set */ ast_copy_string(gCallerID, v->value, sizeof(gCallerID)); } pNewAlias->type = T_H225AliasAddress_h323_ID; pNewAlias->value = strdup(v->value); pNewAlias->next = gAliasList; gAliasList = pNewAlias; pNewAlias = NULL; } else if (!strcasecmp(v->name, "e164")) { pNewAlias = ast_calloc(1, sizeof(struct ooAliases)); if (!pNewAlias) { ast_log(LOG_ERROR, "Failed to allocate memory for e164 alias\n"); ast_config_destroy(cfg); return 1; } pNewAlias->type = T_H225AliasAddress_dialedDigits; pNewAlias->value = strdup(v->value); pNewAlias->next = gAliasList; gAliasList = pNewAlias; pNewAlias = NULL; } else if (!strcasecmp(v->name, "email")) { pNewAlias = ast_calloc(1, sizeof(struct ooAliases)); if (!pNewAlias) { ast_log(LOG_ERROR, "Failed to allocate memory for email alias\n"); ast_config_destroy(cfg); return 1; } pNewAlias->type = T_H225AliasAddress_email_ID; pNewAlias->value = strdup(v->value); pNewAlias->next = gAliasList; gAliasList = pNewAlias; pNewAlias = NULL; } else if (!strcasecmp(v->name, "t35country")) { t35countrycode = atoi(v->value); } else if (!strcasecmp(v->name, "t35extensions")) { t35extensions = atoi(v->value); } else if (!strcasecmp(v->name, "manufacturer")) { manufacturer = atoi(v->value); } else if (!strcasecmp(v->name, "vendorid")) { ast_copy_string(vendor, v->value, sizeof(vendor)); } else if (!strcasecmp(v->name, "versionid")) { ast_copy_string(version, v->value, sizeof(version)); } else if (!strcasecmp(v->name, "callerid")) { ast_copy_string(gCallerID, v->value, sizeof(gCallerID)); } else if (!strcasecmp(v->name, "incominglimit")) { gIncomingLimit = atoi(v->value); } else if (!strcasecmp(v->name, "outgoinglimit")) { gOutgoingLimit = atoi(v->value); } else if (!strcasecmp(v->name, "gatekeeper")) { if (!strcasecmp(v->value, "DISABLE")) { gRasGkMode = RasNoGatekeeper; } else if (!strcasecmp(v->value, "DISCOVER")) { gRasGkMode = RasDiscoverGatekeeper; } else { gRasGkMode = RasUseSpecificGatekeeper; ast_copy_string(gGatekeeper, v->value, sizeof(gGatekeeper)); } } else if (!strcasecmp(v->name, "logfile")) { ast_copy_string(gLogFile, v->value, sizeof(gLogFile)); } else if (!strcasecmp(v->name, "context")) { ast_copy_string(gContext, v->value, sizeof(gContext)); ast_verb(3, " == Setting default context to %s\n", gContext); } else if (!strcasecmp(v->name, "nat")) { gNat = ast_true(v->value); } else if (!strcasecmp(v->name, "rtptimeout")) { gRTPTimeout = atoi(v->value); if (gRTPTimeout <= 0) gRTPTimeout = 60; } else if (!strcasecmp(v->name, "tos")) { if (sscanf(v->value, "%30i", &format) == 1) gTOS = format & 0xff; else if (!strcasecmp(v->value, "lowdelay")) gTOS = IPTOS_LOWDELAY; else if (!strcasecmp(v->value, "throughput")) gTOS = IPTOS_THROUGHPUT; else if (!strcasecmp(v->value, "reliability")) gTOS = IPTOS_RELIABILITY; else if (!strcasecmp(v->value, "mincost")) gTOS = IPTOS_MINCOST; else if (!strcasecmp(v->value, "none")) gTOS = 0; else ast_log(LOG_WARNING, "Invalid tos value at line %d, should be " "'lowdelay', 'throughput', 'reliability', " "'mincost', or 'none'\n", v->lineno); } else if (!strcasecmp(v->name, "amaflags")) { gAMAFLAGS = ast_cdr_amaflags2int(v->value); } else if (!strcasecmp(v->name, "accountcode")) { ast_copy_string(gAccountcode, v->value, sizeof(gAccountcode)); } else if (!strcasecmp(v->name, "disallow")) { ast_parse_allow_disallow(&gPrefs, gCap, v->value, 0); } else if (!strcasecmp(v->name, "allow")) { const char* tcodecs = v->value; if (!strcasecmp(v->value, "all")) { tcodecs = "ulaw,alaw,g729,g723,gsm"; } ast_parse_allow_disallow(&gPrefs, gCap, tcodecs, 1); } else if (!strcasecmp(v->name, "dtmfmode")) { if (!strcasecmp(v->value, "inband")) gDTMFMode = H323_DTMF_INBAND; else if (!strcasecmp(v->value, "rfc2833")) gDTMFMode = H323_DTMF_RFC2833; else if (!strcasecmp(v->value, "cisco")) gDTMFMode = H323_DTMF_CISCO; else if (!strcasecmp(v->value, "q931keypad")) gDTMFMode = H323_DTMF_Q931; else if (!strcasecmp(v->value, "h245alphanumeric")) gDTMFMode = H323_DTMF_H245ALPHANUMERIC; else if (!strcasecmp(v->value, "h245signal")) gDTMFMode = H323_DTMF_H245SIGNAL; else { ast_log(LOG_WARNING, "Unknown dtmf mode '%s', using rfc2833\n", v->value); gDTMFMode = H323_DTMF_RFC2833; } } else if (!strcasecmp(v->name, "relaxdtmf")) { gDTMFMode |= ast_true(v->value) ? H323_DTMF_INBANDRELAX : 0; } else if (!strcasecmp(v->name, "dtmfcodec") && atoi(v->value)) { gDTMFCodec = atoi(v->value); } else if (!strcasecmp(v->name, "faxdetect")) { if (ast_true(v->value)) { gFAXdetect = FAXDETECT_CNG | FAXDETECT_T38; } else if (ast_false(v->value)) { gFAXdetect = 0; } else { char *buf = ast_strdupa(v->value); char *word, *next = buf; gFAXdetect = 0; while ((word = strsep(&next, ","))) { if (!strcasecmp(word, "cng")) { gFAXdetect |= FAXDETECT_CNG; } else if (!strcasecmp(word, "t38")) { gFAXdetect |= FAXDETECT_T38; } else { ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno); } } } } else if (!strcasecmp(v->name, "t38support")) { if (!strcasecmp(v->value, "disabled")) gT38Support = T38_DISABLED; if (!strcasecmp(v->value, "no")) gT38Support = T38_DISABLED; else if (!strcasecmp(v->value, "faxgw")) gT38Support = T38_FAXGW; else if (!strcasecmp(v->value, "yes")) gT38Support = T38_ENABLED; } else if (!strcasecmp(v->name, "tracelevel")) { gTRCLVL = atoi(v->value); ooH323EpSetTraceLevel(gTRCLVL); } v = v->next; } for (cat = ast_category_browse(cfg, NULL); cat; cat = ast_category_browse(cfg, cat)) { if (strcasecmp(cat, "general")) { int friend_type = 0; utype = ast_variable_retrieve(cfg, cat, "type"); if (utype) { friend_type = strcasecmp(utype, "friend"); if (!strcmp(utype, "user") || 0 == friend_type) { user = build_user(cat, ast_variable_browse(cfg, cat)); if (user) { ast_mutex_lock(&userl.lock); user->next = userl.users; userl.users = user; ast_mutex_unlock(&userl.lock); } else { ast_log(LOG_WARNING, "Failed to build user %s\n", cat); } } if (!strcasecmp(utype, "peer") || 0 == friend_type) { peer = build_peer(cat, ast_variable_browse(cfg, cat), friend_type); if (peer) { ast_mutex_lock(&peerl.lock); peer->next = peerl.peers; peerl.peers = peer; ast_mutex_unlock(&peerl.lock); } else { ast_log(LOG_WARNING, "Failed to build peer %s\n", cat); } } } } } ast_config_destroy(cfg); /* Determine ip address if neccessary */ if (ast_strlen_zero(gIP)) { ooGetLocalIPAddress(gIP); if (!strcmp(gIP, "127.0.0.1") || !strcmp(gIP, "::1")) { ast_log(LOG_NOTICE, "Failed to determine local ip address. Please " "specify it in ooh323.conf. OOH323 Disabled\n"); return 1; } } if (gH323Debug) ast_verb(0, "+++ reload_config\n"); return 0; } static char *handle_cli_ooh323_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { char ip_port[30]; struct ooh323_peer *prev = NULL, *peer = NULL; switch (cmd) { case CLI_INIT: e->command = "ooh323 show peer"; e->usage = "Usage: ooh323 show peer \n" " List details of specific OOH323 peer.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 4) return CLI_SHOWUSAGE; ast_mutex_lock(&peerl.lock); peer = peerl.peers; while (peer) { ast_mutex_lock(&peer->lock); if (!strcmp(peer->name, a->argv[3])) { break; } else { prev = peer; peer = peer->next; ast_mutex_unlock(&prev->lock); } } if (peer) { sprintf(ip_port, "%s:%d", peer->ip, peer->port); ast_cli(a->fd, "%-15.15s%s\n", "Name: ", peer->name); ast_cli(a->fd, "%s:%s,%s\n", "FastStart/H.245 Tunneling", peer->faststart?"yes":"no", peer->h245tunneling?"yes":"no"); ast_cli(a->fd, "%-15s%s\n", "DirectRTP", peer->directrtp ? "yes" : "no"); ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", peer->earlydirect ? "yes" : "no"); ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "("); print_codec_to_cli(a->fd, &peer->prefs); ast_cli(a->fd, ")\n"); ast_cli(a->fd, "%-15.15s", "DTMF Mode: "); if (peer->dtmfmode & H323_DTMF_CISCO) { ast_cli(a->fd, "%s\n", "cisco"); ast_cli(a->fd, "%-15.15s%d\n", "DTMF Codec: ", peer->dtmfcodec); } else if (peer->dtmfmode & H323_DTMF_RFC2833) { ast_cli(a->fd, "%s\n", "rfc2833"); ast_cli(a->fd, "%-15.15s%d\n", "DTMF Codec: ", peer->dtmfcodec); } else if (peer->dtmfmode & H323_DTMF_Q931) { ast_cli(a->fd, "%s\n", "q931keypad"); } else if (peer->dtmfmode & H323_DTMF_H245ALPHANUMERIC) { ast_cli(a->fd, "%s\n", "h245alphanumeric"); } else if (peer->dtmfmode & H323_DTMF_H245SIGNAL) { ast_cli(a->fd, "%s\n", "h245signal"); } else if (peer->dtmfmode & H323_DTMF_INBAND && peer->dtmfmode & H323_DTMF_INBANDRELAX) { ast_cli(a->fd, "%s\n", "inband-relaxed"); } else if (peer->dtmfmode & H323_DTMF_INBAND) { ast_cli(a->fd, "%s\n", "inband"); } else { ast_cli(a->fd, "%s\n", "unknown"); } ast_cli(a->fd,"%-15s", "T.38 Mode: "); if (peer->t38support == T38_DISABLED) { ast_cli(a->fd, "%s\n", "disabled"); } else if (peer->t38support == T38_FAXGW) { ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible"); } if (peer->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes"); } else if (peer->faxdetect & FAXDETECT_CNG) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Cng"); } else if (peer->faxdetect & FAXDETECT_T38) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "T.38"); } else { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No"); } ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", peer->accountcode); ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_cdr_flags2str(peer->amaflags)); ast_cli(a->fd, "%-15.15s%s\n", "IP:Port: ", ip_port); ast_cli(a->fd, "%-15.15s%d\n", "OutgoingLimit: ", peer->outgoinglimit); ast_cli(a->fd, "%-15.15s%d\n", "rtptimeout: ", peer->rtptimeout); ast_cli(a->fd, "%-15.15s%s\n", "nat: ", peer->nat?"yes":"no"); if (peer->rtpmaskstr[0]) { ast_cli(a->fd, "%-15.15s%s\n", "rtpmask: ", peer->rtpmaskstr); } if (peer->rtdrcount && peer->rtdrinterval) { ast_cli(a->fd, "%-15.15s%d,%d\n", "RoundTrip: ", peer->rtdrcount, peer->rtdrinterval); } ast_mutex_unlock(&peer->lock); } else { ast_cli(a->fd, "Peer %s not found\n", a->argv[3]); ast_cli(a->fd, "\n"); } ast_mutex_unlock(&peerl.lock); return CLI_SUCCESS; } static char *handle_cli_ooh323_show_peers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ooh323_peer *prev = NULL, *peer = NULL; char formats[FORMAT_STRING_SIZE]; char ip_port[30]; #define FORMAT "%-15.15s %-15.15s %-23.23s %-s\n" switch (cmd) { case CLI_INIT: e->command = "ooh323 show peers"; e->usage = "Usage: ooh323 show peers\n" " Lists all known OOH323 peers.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 3) return CLI_SHOWUSAGE; ast_cli(a->fd, FORMAT, "Name", "Accountcode", "ip:port", "Formats"); ast_mutex_lock(&peerl.lock); peer = peerl.peers; while (peer) { ast_mutex_lock(&peer->lock); snprintf(ip_port, sizeof(ip_port), "%s:%d", peer->ip, peer->port); ast_cli(a->fd, FORMAT, peer->name, peer->accountcode, ip_port, ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,peer->cap)); prev = peer; peer = peer->next; ast_mutex_unlock(&prev->lock); } ast_mutex_unlock(&peerl.lock); #undef FORMAT return CLI_SUCCESS; } /*! \brief Print codec list from preference to CLI/manager */ static void print_codec_to_cli(int fd, struct ast_codec_pref *pref) { int x; struct ast_format tmpfmt; for (x = 0; x < 32; x++) { ast_codec_pref_index(pref, x, &tmpfmt); if (!tmpfmt.id) break; ast_cli(fd, "%s", ast_getformatname(&tmpfmt)); ast_cli(fd, ":%d", pref->framing[x]); if (x < 31 && ast_codec_pref_index(pref, x + 1, &tmpfmt)) ast_cli(fd, ","); } if (!x) ast_cli(fd, "none"); } static char *handle_cli_ooh323_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ooh323_user *prev = NULL, *user = NULL; switch (cmd) { case CLI_INIT: e->command = "ooh323 show user"; e->usage = "Usage: ooh323 show user \n" " List details of specific OOH323 user.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 4) return CLI_SHOWUSAGE; ast_mutex_lock(&userl.lock); user = userl.users; while (user) { ast_mutex_lock(&user->lock); if (!strcmp(user->name, a->argv[3])) { break; } else { prev = user; user = user->next; ast_mutex_unlock(&prev->lock); } } if (user) { ast_cli(a->fd, "%-15.15s%s\n", "Name: ", user->name); ast_cli(a->fd, "%s:%s,%s\n", "FastStart/H.245 Tunneling", user->faststart?"yes":"no", user->h245tunneling?"yes":"no"); ast_cli(a->fd, "%-15s%s\n", "DirectRTP", user->directrtp ? "yes" : "no"); ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", user->earlydirect ? "yes" : "no"); ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "("); print_codec_to_cli(a->fd, &user->prefs); ast_cli(a->fd, ")\n"); ast_cli(a->fd, "%-15.15s", "DTMF Mode: "); if (user->dtmfmode & H323_DTMF_CISCO) { ast_cli(a->fd, "%s\n", "cisco"); ast_cli(a->fd, "%-15.15s%d\n", "DTMF Codec: ", user->dtmfcodec); } else if (user->dtmfmode & H323_DTMF_RFC2833) { ast_cli(a->fd, "%s\n", "rfc2833"); ast_cli(a->fd, "%-15.15s%d\n", "DTMF Codec: ", user->dtmfcodec); } else if (user->dtmfmode & H323_DTMF_Q931) { ast_cli(a->fd, "%s\n", "q931keypad"); } else if (user->dtmfmode & H323_DTMF_H245ALPHANUMERIC) { ast_cli(a->fd, "%s\n", "h245alphanumeric"); } else if (user->dtmfmode & H323_DTMF_H245SIGNAL) { ast_cli(a->fd, "%s\n", "h245signal"); } else if (user->dtmfmode & H323_DTMF_INBAND && user->dtmfmode & H323_DTMF_INBANDRELAX) { ast_cli(a->fd, "%s\n", "inband-relaxed"); } else if (user->dtmfmode & H323_DTMF_INBAND) { ast_cli(a->fd, "%s\n", "inband"); } else { ast_cli(a->fd, "%s\n", "unknown"); } ast_cli(a->fd,"%-15s", "T.38 Mode: "); if (user->t38support == T38_DISABLED) { ast_cli(a->fd, "%s\n", "disabled"); } else if (user->t38support == T38_FAXGW) { ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible"); } if (user->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes"); } else if (user->faxdetect & FAXDETECT_CNG) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Cng"); } else if (user->faxdetect & FAXDETECT_T38) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "T.38"); } else { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No"); } ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", user->accountcode); ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_cdr_flags2str(user->amaflags)); ast_cli(a->fd, "%-15.15s%s\n", "Context: ", user->context); ast_cli(a->fd, "%-15.15s%d\n", "IncomingLimit: ", user->incominglimit); ast_cli(a->fd, "%-15.15s%d\n", "InUse: ", user->inUse); ast_cli(a->fd, "%-15.15s%d\n", "rtptimeout: ", user->rtptimeout); ast_cli(a->fd, "%-15.15s%s\n", "nat: ", user->nat?"yes":"no"); if (user->rtpmaskstr[0]) { ast_cli(a->fd, "%-15.15s%s\n", "rtpmask: ", user->rtpmaskstr); } ast_mutex_unlock(&user->lock); if (user->rtdrcount && user->rtdrinterval) { ast_cli(a->fd, "%-15.15s%d,%d\n", "RoundTrip: ", user->rtdrcount, user->rtdrinterval); } } else { ast_cli(a->fd, "User %s not found\n", a->argv[3]); ast_cli(a->fd, "\n"); } ast_mutex_unlock(&userl.lock); return CLI_SUCCESS; } static char *handle_cli_ooh323_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ooh323_user *prev = NULL, *user = NULL; char formats[FORMAT_STRING_SIZE]; #define FORMAT1 "%-15.15s %-15.15s %-15.15s %-s\n" switch (cmd) { case CLI_INIT: e->command = "ooh323 show users"; e->usage = "Usage: ooh323 show users \n" " Lists all known OOH323 users.\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 3) return CLI_SHOWUSAGE; ast_cli(a->fd, FORMAT1, "Username", "Accountcode", "Context", "Formats"); ast_mutex_lock(&userl.lock); user = userl.users; while(user) { ast_mutex_lock(&user->lock); ast_cli(a->fd, FORMAT1, user->name, user->accountcode, user->context, ast_getformatname_multiple(formats, FORMAT_STRING_SIZE, user->cap)); prev = user; user = user->next; ast_mutex_unlock(&prev->lock); } ast_mutex_unlock(&userl.lock); #undef FORMAT1 return RESULT_SUCCESS; } static char *handle_cli_ooh323_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: e->command = "ooh323 set debug [off]"; e->usage = "Usage: ooh323 set debug [off]\n" " Enables/Disables debugging of OOH323 channel driver\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc < 3 || a->argc > 4) return CLI_SHOWUSAGE; if (a->argc == 4 && strcasecmp(a->argv[3], "off")) return CLI_SHOWUSAGE; gH323Debug = (a->argc == 4) ? FALSE : TRUE; ast_cli(a->fd, "OOH323 Debugging %s\n", gH323Debug ? "Enabled" : "Disabled"); return CLI_SUCCESS; } #if 0 static int ooh323_show_channels(int fd, int argc, char *argv[]) { return RESULT_SUCCESS; } #endif static char *handle_cli_ooh323_show_gk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { char value[FORMAT_STRING_SIZE]; switch (cmd) { case CLI_INIT: e->command = "ooh323 show gk"; e->usage = "Usage: ooh323 show gk\n" " Shows Gatekeeper connection state\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 3) return CLI_SHOWUSAGE; ast_cli(a->fd, "\nGateKeeper connection state:\n"); if (!gH323ep.gkClient) { ast_cli(a->fd, "No Gatekeeper is configured\n"); return CLI_SUCCESS; } if (gRasGkMode == RasNoGatekeeper) { snprintf(value, sizeof(value), "%s", "No Gatekeeper"); } else if (gRasGkMode == RasDiscoverGatekeeper) { snprintf(value, sizeof(value), "%s", "Discover"); } else { snprintf(value, sizeof(value), "%s", gGatekeeper); } ast_cli(a->fd, "%-20s%s\n", "Gatekeeper:", value); switch(gH323ep.gkClient->state) { case GkClientIdle: ast_cli(a->fd, "%-20s%s\n", "GK state:", "Idle"); break; case GkClientDiscovered: ast_cli(a->fd, "%-20s%s\n", "GK state:", "Discovered"); break; case GkClientRegistered: ast_cli(a->fd, "%-20s%s\n", "GK state:", "Registered"); break; case GkClientUnregistered: ast_cli(a->fd, "%-20s%s\n", "GK state:", "Unregistered"); break; case GkClientGkErr: ast_cli(a->fd, "%-20s%s\n", "GK state:", "Error"); break; case GkClientFailed: ast_cli(a->fd, "%-20s%s\n", "GK state:", "Failed"); break; default: break; } return CLI_SUCCESS; } static char *handle_cli_ooh323_show_config(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { char value[FORMAT_STRING_SIZE]; ooAliases *pAlias = NULL, *pAliasNext = NULL;; switch (cmd) { case CLI_INIT: e->command = "ooh323 show config"; e->usage = "Usage: ooh323 show config\n" " Shows global configuration of H.323 channel driver\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 3) return CLI_SHOWUSAGE; ast_cli(a->fd, "\nObjective Open H.323 Channel Driver's Config:\n"); snprintf(value, sizeof(value), "%s:%d", gIP, gPort); ast_cli(a->fd, "%-20s%s\n", "IP:Port: ", value); ast_cli(a->fd, "%-20s%d-%d\n", "H.225 port range: ", ooconfig.mTCPPortStart, ooconfig.mTCPPortEnd); ast_cli(a->fd, "%-20s%s\n", "FastStart", gFastStart?"yes":"no"); ast_cli(a->fd, "%-20s%s\n", "Tunneling", gTunneling?"yes":"no"); ast_cli(a->fd, "%-20s%s\n", "CallerId", gCallerID); ast_cli(a->fd, "%-20s%s\n", "MediaWaitForConnect", gMediaWaitForConnect?"yes":"no"); ast_cli(a->fd, "%-20s%s\n", "DirectRTP", gDirectRTP ? "yes" : "no"); ast_cli(a->fd, "%-20s%s\n", "EarlyDirectRTP", gEarlyDirect ? "yes" : "no"); #if (0) extern OOH323EndPoint gH323ep; ast_cli(a->fd, "%-20s%s\n", "FASTSTART", (OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART) != 0) ? "yes" : "no"); ast_cli(a->fd, "%-20s%s\n", "TUNNELING", (OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING) != 0) ? "yes" : "no"); ast_cli(a->fd, "%-20s%s\n", "MEDIAWAITFORCONN", (OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN) != 0) ? "yes" : "no"); #endif if (gRasGkMode == RasNoGatekeeper) { snprintf(value, sizeof(value), "%s", "No Gatekeeper"); } else if (gRasGkMode == RasDiscoverGatekeeper) { snprintf(value, sizeof(value), "%s", "Discover"); } else { snprintf(value, sizeof(value), "%s", gGatekeeper); } ast_cli(a->fd, "%-20s%s\n", "Gatekeeper:", value); ast_cli(a->fd, "%-20s%s\n", "H.323 LogFile:", gLogFile); ast_cli(a->fd, "%-20s%s\n", "Context:", gContext); ast_cli(a->fd, "%-20s%s\n", "Capability:", ast_getformatname_multiple(value,FORMAT_STRING_SIZE,gCap)); ast_cli(a->fd, "%-20s", "DTMF Mode: "); if (gDTMFMode & H323_DTMF_CISCO) { ast_cli(a->fd, "%s\n", "cisco"); ast_cli(a->fd, "%-20.15s%d\n", "DTMF Codec: ", gDTMFCodec); } else if (gDTMFMode & H323_DTMF_RFC2833) { ast_cli(a->fd, "%s\n", "rfc2833"); ast_cli(a->fd, "%-20.15s%d\n", "DTMF Codec: ", gDTMFCodec); } else if (gDTMFMode & H323_DTMF_Q931) { ast_cli(a->fd, "%s\n", "q931keypad"); } else if (gDTMFMode & H323_DTMF_H245ALPHANUMERIC) { ast_cli(a->fd, "%s\n", "h245alphanumeric"); } else if (gDTMFMode & H323_DTMF_H245SIGNAL) { ast_cli(a->fd, "%s\n", "h245signal"); } else if (gDTMFMode & H323_DTMF_INBAND && gDTMFMode & H323_DTMF_INBANDRELAX) { ast_cli(a->fd, "%s\n", "inband-relaxed"); } else if (gDTMFMode & H323_DTMF_INBAND) { ast_cli(a->fd, "%s\n", "inband"); } else { ast_cli(a->fd, "%s\n", "unknown"); } ast_cli(a->fd,"%-20s", "T.38 Mode: "); if (gT38Support == T38_DISABLED) { ast_cli(a->fd, "%s\n", "disabled"); } else if (gT38Support == T38_FAXGW) { ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible"); } if (gFAXdetect == (FAXDETECT_CNG | FAXDETECT_T38)) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes"); } else if (gFAXdetect & FAXDETECT_CNG) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Cng"); } else if (gFAXdetect & FAXDETECT_T38) { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "T.38"); } else { ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No"); } if (gRTDRCount && gRTDRInterval) { ast_cli(a->fd, "%-20.15s%d,%d\n", "RoundTrip: ", gRTDRCount, gRTDRInterval); } ast_cli(a->fd, "%-20s%ld\n", "Call counter: ", callnumber); ast_cli(a->fd, "%-20s%s\n", "AccountCode: ", gAccountcode); ast_cli(a->fd, "%-20s%s\n", "AMA flags: ", ast_cdr_flags2str(gAMAFLAGS)); pAlias = gAliasList; if(pAlias) { ast_cli(a->fd, "%-20s\n", "Aliases: "); } while (pAlias) { pAliasNext = pAlias->next; if (pAliasNext) { ast_cli(a->fd,"\t%-30s\t%-30s\n",pAlias->value, pAliasNext->value); pAlias = pAliasNext->next; } else { ast_cli(a->fd,"\t%-30s\n",pAlias->value); pAlias = pAlias->next; } } return CLI_SUCCESS; } static struct ast_cli_entry cli_ooh323[] = { AST_CLI_DEFINE(handle_cli_ooh323_set_debug, "Enable/Disable OOH323 debugging"), AST_CLI_DEFINE(handle_cli_ooh323_show_config, "Show details on global configuration of H.323 channel driver"), AST_CLI_DEFINE(handle_cli_ooh323_show_gk, "Show OOH323 Gatekeeper connection status"), AST_CLI_DEFINE(handle_cli_ooh323_show_peer, "Show details on specific OOH323 peer"), AST_CLI_DEFINE(handle_cli_ooh323_show_peers, "Show defined OOH323 peers"), AST_CLI_DEFINE(handle_cli_ooh323_show_user, "Show details on specific OOH323 user"), AST_CLI_DEFINE(handle_cli_ooh323_show_users, "Show defined OOH323 users"), AST_CLI_DEFINE(handle_cli_ooh323_reload, "reload ooh323 config") }; /*! \brief OOH323 Dialplan function - reads ooh323 settings */ static int function_ooh323_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct ooh323_pvt *p = ast_channel_tech_pvt(chan); ast_channel_lock(chan); if (!p) { ast_channel_unlock(chan); return -1; } if (strcmp(ast_channel_tech(chan)->type, "OOH323")) { ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", ast_channel_tech(chan)->type); ast_channel_unlock(chan); return -1; } ast_mutex_lock(&p->lock); if (!strcasecmp(data, "faxdetect")) { ast_copy_string(buf, p->faxdetect ? "1" : "0", len); } else if (!strcasecmp(data, "t38support")) { ast_copy_string(buf, p->t38support ? "1" : "0", len); } else if (!strcasecmp(data, "caller_h323id")) { ast_copy_string(buf, p->caller_h323id, len); } else if (!strcasecmp(data, "caller_dialeddigits")) { ast_copy_string(buf, p->caller_dialedDigits, len); } else if (!strcasecmp(data, "caller_email")) { ast_copy_string(buf, p->caller_email, len); } else if (!strcasecmp(data, "h323id_url")) { ast_copy_string(buf, p->caller_url, len); } else if (!strcasecmp(data, "callee_h323id")) { ast_copy_string(buf, p->callee_h323id, len); } else if (!strcasecmp(data, "callee_dialeddigits")) { ast_copy_string(buf, p->callee_dialedDigits, len); } else if (!strcasecmp(data, "callee_email")) { ast_copy_string(buf, p->callee_email, len); } else if (!strcasecmp(data, "callee_url")) { ast_copy_string(buf, p->callee_url, len); } ast_mutex_unlock(&p->lock); ast_channel_unlock(chan); return 0; } /*! \brief OOH323 Dialplan function - writes ooh323 settings */ static int function_ooh323_write(struct ast_channel *chan, const char *cmd, char *data, const char *value) { struct ooh323_pvt *p = ast_channel_tech_pvt(chan); int res = -1; ast_channel_lock(chan); if (!p) { ast_channel_unlock(chan); return -1; } if (strcmp(ast_channel_tech(chan)->type, "OOH323")) { ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", ast_channel_tech(chan)->type); ast_channel_unlock(chan); return -1; } ast_mutex_lock(&p->lock); if (!strcasecmp(data, "faxdetect")) { if (ast_true(value)) { p->faxdetect = 1; res = 0; } else if (ast_false(value)) { p->faxdetect = 0; res = 0; } else { char *buf = ast_strdupa(value); char *word, *next = buf; p->faxdetect = 0; res = 0; while ((word = strsep(&next, ","))) { if (!strcasecmp(word, "cng")) { p->faxdetect |= FAXDETECT_CNG; } else if (!strcasecmp(word, "t38")) { p->faxdetect |= FAXDETECT_T38; } else { ast_log(LOG_WARNING, "Unknown faxdetect mode '%s'.\n", word); res = -1; } } } } else if (!strcasecmp(data, "t38support")) { if (ast_true(value)) { p->t38support = 1; res = 0; } else { p->t38support = 0; res = 0; } } ast_mutex_unlock(&p->lock); ast_channel_unlock(chan); return res; } static int load_module(void) { struct ooAliases * pNewAlias = NULL; struct ooh323_peer *peer = NULL; struct ast_format tmpfmt; OOH225MsgCallbacks h225Callbacks = {0, 0, 0, 0}; OOH323CALLBACKS h323Callbacks = { .onNewCallCreated = onNewCallCreated, .onAlerting = onAlerting, .onProgress = onProgress, .onIncomingCall = NULL, .onOutgoingCall = onOutgoingCall, .onCallEstablished = onCallEstablished, .onCallCleared = onCallCleared, .openLogicalChannels = NULL, .onReceivedDTMF = ooh323_onReceivedDigit, .onModeChanged = onModeChanged, .onMediaChanged = (cb_OnMediaChanged) setup_rtp_remote, }; if (!(gCap = ast_format_cap_alloc())) { return 1; } if (!(ooh323_tech.capabilities = ast_format_cap_alloc())) { return 1; } ast_format_cap_add(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0)); ast_format_cap_add_all(ooh323_tech.capabilities); myself = ast_module_info->self; h225Callbacks.onReceivedSetup = &ooh323_onReceivedSetup; userl.users = NULL; ast_mutex_init(&userl.lock); peerl.peers = NULL; ast_mutex_init(&peerl.lock); #if 0 ast_register_atexit(&ast_ooh323c_exit); #endif if (!(sched = ast_sched_context_create())) { ast_log(LOG_WARNING, "Unable to create schedule context\n"); } if (!(io = io_context_create())) { ast_log(LOG_WARNING, "Unable to create I/O context\n"); } if (!reload_config(0)) { /* Make sure we can register our OOH323 channel type */ if (ast_channel_register(&ooh323_tech)) { ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); return 0; } ast_rtp_glue_register(&ooh323_rtp); ast_udptl_proto_register(&ooh323_udptl); ast_cli_register_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry)); /* fire up the H.323 Endpoint */ if (OO_OK != ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, gLogFile)) { ast_log(LOG_ERROR, "Failed to initialize OOH323 endpoint-" "OOH323 Disabled\n"); return 1; } if (gIsGateway) ooH323EpSetAsGateway(); ooH323EpSetVersionInfo(t35countrycode, t35extensions, manufacturer, vendor, version); ooH323EpDisableAutoAnswer(); ooH323EpSetH225MsgCallbacks(h225Callbacks); ooH323EpSetTraceLevel(gTRCLVL); ooH323EpSetLocalAddress(gIP, gPort); if (v6mode) { ast_debug(1, "OOH323 channel is in IP6 mode\n"); } ooH323EpSetCallerID(gCallerID); if(ooH323EpSetTCPPortRange(ooconfig.mTCPPortStart, ooconfig.mTCPPortEnd) == OO_FAILED) { ast_log(LOG_ERROR, "h225portrange: Failed to set range\n"); } /* Set aliases if any */ for (pNewAlias = gAliasList; pNewAlias; pNewAlias = pNewAlias->next) { switch (pNewAlias->type) { case T_H225AliasAddress_h323_ID: ooH323EpAddAliasH323ID(pNewAlias->value); break; case T_H225AliasAddress_dialedDigits: ooH323EpAddAliasDialedDigits(pNewAlias->value); break; case T_H225AliasAddress_email_ID: ooH323EpAddAliasEmailID(pNewAlias->value); break; default: ; } } ast_mutex_lock(&peerl.lock); peer = peerl.peers; while (peer) { if(peer->h323id) ooH323EpAddAliasH323ID(peer->h323id); if(peer->email) ooH323EpAddAliasEmailID(peer->email); if(peer->e164) ooH323EpAddAliasDialedDigits(peer->e164); if(peer->url) ooH323EpAddAliasURLID(peer->url); peer = peer->next; } ast_mutex_unlock(&peerl.lock); if (gMediaWaitForConnect) ooH323EpEnableMediaWaitForConnect(); else ooH323EpDisableMediaWaitForConnect(); /* Fast start and tunneling options */ if (gFastStart) ooH323EpEnableFastStart(); else ooH323EpDisableFastStart(); if (!gTunneling) ooH323EpDisableH245Tunneling(); if (gBeMaster) ooH323EpTryBeMaster(1); ooH323EpEnableManualRingback(); /* Gatekeeper */ if (gRasGkMode == RasUseSpecificGatekeeper) ooGkClientInit(gRasGkMode, gGatekeeper, 0); else if (gRasGkMode == RasDiscoverGatekeeper) ooGkClientInit(gRasGkMode, 0, 0); /* Register callbacks */ ooH323EpSetH323Callbacks(h323Callbacks); /* Add endpoint capabilities */ if (ooh323c_set_capability(&gPrefs, gCap, gDTMFMode, gDTMFCodec) < 0) { ast_log(LOG_ERROR, "Capabilities failure for OOH323. OOH323 Disabled.\n"); return 1; } /* Create H.323 listener */ if (ooCreateH323Listener() != OO_OK) { ast_log(LOG_ERROR, "OOH323 Listener Creation failure. " "OOH323 DISABLED\n"); ooH323EpDestroy(); return 1; } if (ooh323c_start_stack_thread() < 0) { ast_log(LOG_ERROR, "Failed to start OOH323 stack thread. " "OOH323 DISABLED\n"); ooH323EpDestroy(); return 1; } /* And start the monitor for the first time */ restart_monitor(); } return 0; } static void *do_monitor(void *data) { int res; int reloading; struct ooh323_pvt *h323 = NULL; time_t t; for (;;) { struct ooh323_pvt *h323_next; /* Check for a reload request */ ast_mutex_lock(&h323_reload_lock); reloading = h323_reloading; h323_reloading = 0; ast_mutex_unlock(&h323_reload_lock); if (reloading) { ast_verb(1, "Reloading H.323\n"); ooh323_do_reload(); } /* Check for interfaces needing to be killed */ ast_mutex_lock(&iflock); time(&t); h323 = iflist; while (h323) { h323_next = h323->next; if (h323->rtp && h323->rtptimeout && h323->lastrtptx && h323->lastrtptx + h323->rtptimeout < t) { ast_rtp_instance_sendcng(h323->rtp, 0); h323->lastrtptx = time(NULL); } if (h323->rtp && h323->owner && h323->rtptimeout && h323->lastrtprx && ast_sockaddr_isnull(&h323->redirip) && h323->lastrtprx + h323->rtptimeout < t) { if (!ast_channel_trylock(h323->owner)) { ast_softhangup_nolock(h323->owner, AST_SOFTHANGUP_DEV); ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n", ast_channel_name(h323->owner), (long) (t - h323->lastrtprx)); ast_channel_unlock(h323->owner); } } if (ast_test_flag(h323, H323_NEEDDESTROY)) { ooh323_destroy (h323); } /* else if (ast_test_flag(h323, H323_NEEDSTART) && h323->owner) { ast_channel_lock(h323->owner); if (ast_pbx_start(h323->owner)) { ast_log(LOG_WARNING, "Unable to start PBX on %s\n", h323->owner->name); ast_channel_unlock(h323->owner); ast_hangup(h323->owner); } ast_channel_unlock(h323->owner); ast_clear_flag(h323, H323_NEEDSTART); } */ h323 = h323_next; } ast_mutex_unlock(&iflock); pthread_testcancel(); /* Wait for sched or io */ res = ast_sched_wait(sched); if ((res < 0) || (res > 1000)) { res = 1000; } res = ast_io_wait(io, res); pthread_testcancel(); ast_mutex_lock(&monlock); if (res >= 0) { ast_sched_runq(sched); } ast_mutex_unlock(&monlock); } /* Never reached */ return NULL; } int restart_monitor(void) { pthread_attr_t attr; /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == AST_PTHREADT_STOP) return 0; if (ast_mutex_lock(&monlock)) { ast_log(LOG_WARNING, "Unable to lock monitor\n"); return -1; } if (monitor_thread == pthread_self()) { ast_mutex_unlock(&monlock); ast_log(LOG_WARNING, "Cannot kill myself\n"); return -1; } if (monitor_thread != AST_PTHREADT_NULL) { /* Wake up the thread */ pthread_kill(monitor_thread, SIGURG); } else { pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); /* Start a new monitor */ if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; } } ast_mutex_unlock(&monlock); return 0; } int ooh323_destroy(struct ooh323_pvt *p) { /* NOTE: Assumes iflock already acquired */ struct ooh323_pvt *prev = NULL, *cur = NULL; struct ooh323_user *user = NULL; if (gH323Debug) { ast_verb(0, "--- ooh323_destroy \n"); if (p) ast_verb(0, " Destroying %s\n", p->username); } cur = iflist; while (cur) { if (cur == p) { break; } prev = cur; cur = cur->next; } if (cur) { ast_mutex_lock(&cur->lock); if (prev) prev->next = cur->next; else iflist = cur->next; if (cur->callToken) { if (gH323Debug) ast_verb(0, " Destroying %s\n", cur->callToken); ast_free(cur->callToken); cur->callToken = 0; } if (cur->username) { free(cur->username); cur->username = 0; } if (cur->host) { free(cur->host); cur->host = 0; } if (cur->callerid_name) { free(cur->callerid_name); cur->callerid_name = 0; } if (cur->callerid_num) { free(cur->callerid_num); cur->callerid_num = 0; } if (cur->rtp) { ast_rtp_instance_destroy(cur->rtp); cur->rtp = NULL; } if (cur->udptl) { ast_udptl_destroy(cur->udptl); cur->udptl = NULL; } /* Unlink us from the owner if we have one */ if (cur->owner) { while(ast_channel_trylock(cur->owner)) { ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&cur->lock); } ast_debug(1, "Detaching from %s\n", ast_channel_name(cur->owner)); ast_channel_tech_pvt_set(cur->owner, NULL); ast_channel_unlock(cur->owner); cur->owner = NULL; ast_module_unref(myself); } if (cur->vad) { ast_dsp_free(cur->vad); cur->vad = NULL; } /* decrement user/peer count */ if(!ast_test_flag(cur, H323_OUTGOING)) { if (cur->neighbor.user) { user = find_user(p->callerid_name, cur->neighbor.user); if(user && user->inUse > 0) { ast_mutex_lock(&user->lock); user->inUse--; ast_mutex_unlock(&user->lock); } free(cur->neighbor.user); } } else { /* outgoing limit decrement here !!! */ } ast_mutex_unlock(&cur->lock); ast_mutex_destroy(&cur->lock); cur->cap = ast_format_cap_destroy(cur->cap); ast_free(cur); } if (gH323Debug) ast_verb(0, "+++ ooh323_destroy\n"); return 0; } int delete_peers() { struct ooh323_peer *cur = NULL, *prev = NULL; ast_mutex_lock(&peerl.lock); cur = peerl.peers; while (cur) { prev = cur; cur = cur->next; ast_mutex_destroy(&prev->lock); if(prev->h323id) free(prev->h323id); if(prev->email) free(prev->email); if(prev->url) free(prev->url); if(prev->e164) free(prev->e164); if(prev->rtpmask) { ast_mutex_lock(&prev->rtpmask->lock); prev->rtpmask->inuse--; ast_mutex_unlock(&prev->rtpmask->lock); if (prev->rtpmask->inuse == 0) { regfree(&prev->rtpmask->regex); ast_mutex_destroy(&prev->rtpmask->lock); free(prev->rtpmask); } } free(prev); if (cur == peerl.peers) { break; } } peerl.peers = NULL; ast_mutex_unlock(&peerl.lock); return 0; } int delete_users() { struct ooh323_user *cur = NULL, *prev = NULL; ast_mutex_lock(&userl.lock); cur = userl.users; while (cur) { prev = cur; cur = cur->next; ast_mutex_destroy(&prev->lock); if(prev->rtpmask) { ast_mutex_lock(&prev->rtpmask->lock); prev->rtpmask->inuse--; ast_mutex_unlock(&prev->rtpmask->lock); if (prev->rtpmask->inuse == 0) { regfree(&prev->rtpmask->regex); ast_mutex_destroy(&prev->rtpmask->lock); free(prev->rtpmask); } } prev->cap = ast_format_cap_destroy(prev->cap); free(prev); if (cur == userl.users) { break; } } userl.users = NULL; ast_mutex_unlock(&userl.lock); return 0; } static int unload_module(void) { struct ooh323_pvt *p; struct ooAliases *cur = NULL, *prev = NULL; if (gH323Debug) { ast_verb(0, "--- ooh323 unload_module \n"); } /* First, take us out of the channel loop */ ast_cli_unregister_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry)); ast_rtp_glue_unregister(&ooh323_rtp); ast_udptl_proto_unregister(&ooh323_udptl); ast_channel_unregister(&ooh323_tech); #if 0 ast_unregister_atexit(&ast_ooh323c_exit); #endif if (gH323Debug) { ast_verb(0, " unload_module - hanging up all interfaces\n"); } if (!ast_mutex_lock(&iflock)) { /* Hangup all interfaces if they have an owner */ p = iflist; while (p) { if (p->owner) { ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD); } p = p->next; } iflist = NULL; ast_mutex_unlock(&iflock); } else { ast_log(LOG_WARNING, "Unable to lock the interface list\n"); return -1; } if (gH323Debug) { ast_verb(0, " unload_module - stopping monitor thread\n"); } if (monitor_thread != AST_PTHREADT_NULL) { if (!ast_mutex_lock(&monlock)) { if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) { pthread_cancel(monitor_thread); pthread_kill(monitor_thread, SIGURG); pthread_join(monitor_thread, NULL); } monitor_thread = AST_PTHREADT_STOP; ast_mutex_unlock(&monlock); } else { ast_log(LOG_WARNING, "Unable to lock the monitor\n"); return -1; } } if (gH323Debug) { ast_verb(0, " unload_module - stopping stack thread\n"); } ooh323c_stop_stack_thread(); if (gH323Debug) { ast_verb(0, " unload_module - freeing up memory used by interfaces\n"); } if (!ast_mutex_lock(&iflock)) { struct ooh323_pvt *pl; /* Destroy all the interfaces and free their memory */ p = iflist; while (p) { pl = p; p = p->next; /* Free associated memory */ ooh323_destroy(pl); } iflist = NULL; ast_mutex_unlock(&iflock); } else { ast_log(LOG_WARNING, "Unable to lock the interface list\n"); return -1; } if (gH323Debug) { ast_verb(0, " unload_module - deleting users\n"); } delete_users(); if (gH323Debug) { ast_verb(0, " unload_module - deleting peers\n"); } delete_peers(); if (gH323Debug) { ast_verb(0, " unload_module - Freeing up alias list\n"); } cur = gAliasList; while (cur) { prev = cur; cur = cur->next; free(prev->value); free(prev); } gAliasList = NULL; if (gH323Debug) { ast_verb(0, " unload_module- destroying OOH323 endpoint \n"); } ooH323EpDestroy(); if (gH323Debug) { ast_verb(0, "+++ ooh323 unload_module \n"); } gCap = ast_format_cap_destroy(gCap); ooh323_tech.capabilities = ast_format_cap_destroy(ooh323_tech.capabilities); return 0; } static void ooh323_get_codec(struct ast_channel *chan, struct ast_format_cap *result) { struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan); if (gH323Debug) { ast_verb(0, "+++ ooh323 get_codec, %s\n", ast_channel_name(chan)); } if (p) { ast_format_cap_append(result, ast_format_cap_is_empty(ast_channel_nativeformats(chan)) ? (ast_format_cap_is_empty(p->cap) ? NULL : p->cap) : ast_channel_nativeformats(chan)); } if (gH323Debug) { ast_verb(0, "--- ooh323 get_codec, %s\n", ast_channel_name(chan)); } } static enum ast_rtp_glue_result ooh323_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp) { struct ooh323_pvt *p = NULL; enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL; struct ast_sockaddr tmp; if (gH323Debug) { ast_verb(0, "+++ ooh323 get_rtp_peer \n"); } if (!(p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan))) return AST_RTP_GLUE_RESULT_FORBID; if (!(p->rtp)) { return AST_RTP_GLUE_RESULT_FORBID; } *rtp = p->rtp ? ao2_ref(p->rtp, +1), p->rtp : NULL; /* there must be checking of directmedia setting */ if ((ast_channel_state(chan) != AST_STATE_UP && !p->earlydirect) || !p->directrtp) { res = AST_RTP_GLUE_RESULT_LOCAL; } else { res = AST_RTP_GLUE_RESULT_REMOTE; } if (ast_test_flag(&global_jbconf, AST_JB_FORCED)) { res = AST_RTP_GLUE_RESULT_FORBID; } ast_rtp_instance_get_remote_address(*rtp, &tmp); if (gH323Debug) { ast_verb(0, "ooh323_get_rtp_peer %s -> %s:%d, %d\n", ast_channel_name(chan), ast_sockaddr_stringify_addr(&tmp), ast_sockaddr_port(&tmp), res); } if (gH323Debug) { ast_verb(0, "--- ooh323 get_rtp_peer, res = %d\n", (int) res); } return res; } static enum ast_rtp_glue_result ooh323_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp) { struct ooh323_pvt *p = NULL; enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL; if (!(p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan))) return AST_RTP_GLUE_RESULT_FORBID; if (!(p->rtp)) { return AST_RTP_GLUE_RESULT_FORBID; } *rtp = p->vrtp ? ao2_ref(p->vrtp, +1), p->vrtp : NULL; /* there must check of supporting video per call */ res = AST_RTP_GLUE_RESULT_FORBID; return res; } int ooh323_update_capPrefsOrderForCall (ooCallData *call, struct ast_codec_pref *prefs) { int i = 0; struct ast_format tmpfmt; ast_codec_pref_index(prefs, i, &tmpfmt); ooResetCapPrefs(call); while (tmpfmt.id) { ooAppendCapToCapPrefs(call, ooh323_convertAsteriskCapToH323Cap(&tmpfmt)); ast_codec_pref_index(prefs, ++i, &tmpfmt); } return 0; } int ooh323_convertAsteriskCapToH323Cap(struct ast_format *format) { switch (format->id) { case AST_FORMAT_ULAW: return OO_G711ULAW64K; case AST_FORMAT_ALAW: return OO_G711ALAW64K; case AST_FORMAT_GSM: return OO_GSMFULLRATE; #ifdef AST_FORMAT_AMRNB case AST_FORMAT_AMRNB: return OO_AMRNB; #endif #ifdef AST_FORMAT_SPEEX case AST_FORMAT_SPEEX: return OO_SPEEX; #endif case AST_FORMAT_G729A: return OO_G729A; case AST_FORMAT_G726: return OO_G726; case AST_FORMAT_G726_AAL2: return OO_G726AAL2; case AST_FORMAT_G723_1: return OO_G7231; case AST_FORMAT_H263: return OO_H263VIDEO; default: ast_log(LOG_NOTICE, "Don't know how to deal with mode %s\n", ast_getformatname(format)); return -1; } } static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *cap, int nat_active) { /* XXX Deal with Video */ struct ooh323_pvt *p; int changed = 0; char *callToken = NULL; if (gH323Debug) { ast_verb(0, "--- ooh323_set_peer - %s\n", ast_channel_name(chan)); } if (ooh323_convertAsteriskCapToH323Cap(ast_channel_writeformat(chan)) < 0) { ast_log(LOG_WARNING, "Unknown format.\n"); return -1; } p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan); if (!p) { ast_log(LOG_ERROR, "No Private Structure, this is bad\n"); return -1; } ast_mutex_lock(&p->lock); if (rtp) { changed |= ast_rtp_instance_get_and_cmp_remote_address(rtp, &p->redirip); } else if (!ast_sockaddr_isnull(&p->redirip)) { changed = 1; memset(&p->redirip, 0, sizeof(p->redirip)); } callToken = (p->callToken ? strdup(p->callToken) : NULL); if (!callToken) { if (gH323Debug) { ast_verb(0, " set_rtp_peer - No callToken\n"); } ast_mutex_unlock(&p->lock); return -1; } if (changed) { if (!ast_sockaddr_isnull(&p->redirip)) { if (gH323Debug) { ast_verb(0, "ooh323_set_rtp_peer %s -> %s:%d\n", ast_channel_name(chan), ast_sockaddr_stringify_addr(&p->redirip), ast_sockaddr_port(&p->redirip)); } ooUpdateLogChannels(callToken, ast_sockaddr_stringify_addr(&p->redirip), ast_sockaddr_port(&p->redirip)); } else { if (gH323Debug) { ast_verb(0, "ooh323_set_rtp_peer return back to local\n"); } ooUpdateLogChannels(callToken, "0.0.0.0" , 0); } } ast_mutex_unlock(&p->lock); free(callToken); return 0; } int configure_local_rtp(struct ooh323_pvt *p, ooCallData *call) { char lhost[INET6_ADDRSTRLEN]; unsigned lport = 0; struct ast_sockaddr tmp; ooMediaInfo mediaInfo; int x; struct ast_format tmpfmt; ast_format_clear(&tmpfmt); if (gH323Debug) ast_verb(0, "--- configure_local_rtp\n"); memset(&mediaInfo, 0, sizeof(mediaInfo)); if (ast_parse_arg(call->localIP, PARSE_ADDR, &tmp)) { ast_sockaddr_copy(&tmp, &bindaddr); } if (!(p->rtp = ast_rtp_instance_new("asterisk", sched, &tmp, NULL))) { ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno)); return 0; } ast_rtp_instance_set_qos(p->rtp, gTOS, 0, "ooh323-rtp"); if (!(p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &tmp))) { ast_log(LOG_WARNING, "Unable to create UDPTL session: %s\n", strerror(errno)); return 0; } ast_udptl_set_far_max_datagram(p->udptl, 144); if (p->owner) { while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1,"Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return 0; } } else { ast_log(LOG_ERROR, "Channel has no owner\n"); return 0; } ast_channel_set_fd(p->owner, 0, ast_rtp_instance_fd(p->rtp, 0)); ast_channel_set_fd(p->owner, 1, ast_rtp_instance_fd(p->rtp, 1)); ast_channel_set_fd(p->owner, 5, ast_udptl_fd(p->udptl)); ast_channel_unlock(p->owner); if (p->rtp) { ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs); if (p->nat) { ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_NAT, 1); } if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) { ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF, 1); ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, p->dtmfcodec, "audio", "telephone-event", 0); } if (p->dtmfmode & H323_DTMF_CISCO && p->dtmfcodec) { ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF, 1); ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0); } /* figure out our local RTP port and tell the H.323 stack about it*/ ast_rtp_instance_get_local_address(p->rtp, &tmp); ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost)); lport = ast_sockaddr_port(&tmp); if (p->rtptimeout) { ast_rtp_instance_set_timeout(p->rtp, p->rtptimeout); } ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_RTCP, 1); } if (p->rtdrcount) { if (gH323Debug) ast_verb(0, "Setup RTDR info: %d, %d\n", p->rtdrinterval, p->rtdrcount); call->rtdrInterval = p->rtdrinterval; call->rtdrCount = p->rtdrcount; } ast_copy_string(mediaInfo.lMediaIP, lhost, sizeof(mediaInfo.lMediaIP)); mediaInfo.lMediaPort = lport; mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort + 1; for (x = 0; ast_codec_pref_index(&p->prefs, x, &tmpfmt); x++) { strcpy(mediaInfo.dir, "transmit"); mediaInfo.cap = ooh323_convertAsteriskCapToH323Cap(&tmpfmt); ooAddMediaInfo(call, mediaInfo); strcpy(mediaInfo.dir, "receive"); ooAddMediaInfo(call, mediaInfo); if (mediaInfo.cap == OO_G729A) { strcpy(mediaInfo.dir, "transmit"); mediaInfo.cap = OO_G729; ooAddMediaInfo(call, mediaInfo); strcpy(mediaInfo.dir, "receive"); ooAddMediaInfo(call, mediaInfo); strcpy(mediaInfo.dir, "transmit"); mediaInfo.cap = OO_G729B; ooAddMediaInfo(call, mediaInfo); strcpy(mediaInfo.dir, "receive"); ooAddMediaInfo(call, mediaInfo); } } if (p->udptl) { ast_udptl_get_us(p->udptl, &tmp); ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost)); lport = ast_sockaddr_port(&tmp); ast_copy_string(mediaInfo.lMediaIP, lhost, sizeof(mediaInfo.lMediaIP)); mediaInfo.lMediaPort = lport; mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort +1; mediaInfo.cap = OO_T38; strcpy(mediaInfo.dir, "transmit"); ooAddMediaInfo(call, mediaInfo); strcpy(mediaInfo.dir, "receive"); ooAddMediaInfo(call, mediaInfo); } if (gH323Debug) ast_verb(0, "+++ configure_local_rtp\n"); return 1; } void setup_rtp_remote(ooCallData *call, const char *remoteIp, int remotePort) { struct ooh323_pvt *p = NULL; struct ast_sockaddr tmp; if (gH323Debug) { ast_verb(0, "--- setup_rtp_remote %s:%d\n", remoteIp, remotePort); } if (!remoteIp || !remoteIp[0] || !remotePort) { if (gH323Debug) { ast_verb(0, "+++ setup_rtp_remote no data\n"); } return; } /* Find the call or allocate a private structure if call not found */ p = find_call(call); if (!p || !p->rtp) { ast_log(LOG_ERROR, "Something is wrong: rtp\n"); return; } ast_mutex_lock(&p->lock); ast_parse_arg(remoteIp, PARSE_ADDR, &tmp); ast_sockaddr_set_port(&tmp, remotePort); ast_rtp_instance_set_remote_address(p->rtp, &tmp); ast_mutex_unlock(&p->lock); if (gH323Debug) { ast_verb(0, "+++ setup_rtp_remote\n"); } return; } void setup_rtp_connection(ooCallData *call, const char *remoteIp, int remotePort) { struct ooh323_pvt *p = NULL; struct ast_sockaddr tmp; if (gH323Debug) ast_verb(0, "--- setup_rtp_connection %s:%d\n", remoteIp, remotePort); /* Find the call or allocate a private structure if call not found */ p = find_call(call); if (!p || !p->rtp) { ast_log(LOG_ERROR, "Something is wrong: rtp\n"); return; } ast_mutex_lock(&p->lock); ast_parse_arg(remoteIp, PARSE_ADDR, &tmp); ast_sockaddr_set_port(&tmp, remotePort); ast_rtp_instance_set_remote_address(p->rtp, &tmp); if (p->writeformat.id == AST_FORMAT_G726_AAL2) { ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, 2, "audio", "G726-32", AST_RTP_OPT_G726_NONSTANDARD); } ast_mutex_unlock(&p->lock); if(gH323Debug) ast_verb(0, "+++ setup_rtp_connection\n"); return; } void close_rtp_connection(ooCallData *call) { struct ooh323_pvt *p = NULL; if(gH323Debug) ast_verb(0, "--- close_rtp_connection\n"); p = find_call(call); if (!p) { ast_log(LOG_ERROR, "Couldn't find matching call to close rtp " "connection\n"); return; } ast_mutex_lock(&p->lock); if (p->rtp) { ast_rtp_instance_stop(p->rtp); } ast_mutex_unlock(&p->lock); if(gH323Debug) ast_verb(0, "+++ close_rtp_connection\n"); return; } /* udptl handling functions */ static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan) { struct ooh323_pvt *p; struct ast_udptl *udptl = NULL; p = ast_channel_tech_pvt(chan); if (!p) return NULL; ast_mutex_lock(&p->lock); if (p->udptl) udptl = p->udptl; ast_mutex_unlock(&p->lock); return udptl; } static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl) { struct ooh323_pvt *p; p = ast_channel_tech_pvt(chan); if (!p) return -1; ast_mutex_lock(&p->lock); if (udptl) { ast_udptl_get_peer(udptl, &p->udptlredirip); } else memset(&p->udptlredirip, 0, sizeof(p->udptlredirip)); ast_mutex_unlock(&p->lock); /* free(callToken); */ return 0; } void setup_udptl_connection(ooCallData *call, const char *remoteIp, int remotePort) { struct ooh323_pvt *p = NULL; struct ast_sockaddr them; if (gH323Debug) ast_verb(0, "--- setup_udptl_connection\n"); /* Find the call or allocate a private structure if call not found */ p = find_call(call); if (!p) { ast_log(LOG_ERROR, "Something is wrong: rtp\n"); return; } ast_mutex_lock(&p->lock); if (p->owner) { while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } } else { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } ast_parse_arg(remoteIp, PARSE_ADDR, &them); ast_sockaddr_set_port(&them, remotePort); ast_udptl_set_peer(p->udptl, &them); ast_udptl_set_tag(p->udptl, "%s", ast_channel_name(p->owner)); p->t38_tx_enable = 1; p->lastTxT38 = time(NULL); if (p->t38support == T38_ENABLED) { struct ast_control_t38_parameters parameters = { .request_response = 0 }; parameters.request_response = AST_T38_NEGOTIATED; parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl); parameters.rate = AST_T38_RATE_14400; ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, ¶meters, sizeof(parameters)); } if (gH323Debug) { ast_debug(1, "Receiving UDPTL %s:%d\n", ast_sockaddr_stringify_host(&them), ast_sockaddr_port(&them)); } ast_channel_unlock(p->owner); ast_mutex_unlock(&p->lock); if(gH323Debug) ast_verb(0, "+++ setup_udptl_connection\n"); return; } void close_udptl_connection(ooCallData *call) { struct ooh323_pvt *p = NULL; if(gH323Debug) ast_verb(0, "--- close_udptl_connection\n"); p = find_call(call); if (!p) { ast_log(LOG_ERROR, "Couldn't find matching call to close udptl " "connection\n"); return; } ast_mutex_lock(&p->lock); if (p->owner) { while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1, "Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } } else { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } p->t38_tx_enable = 0; if (p->t38support == T38_ENABLED) { struct ast_control_t38_parameters parameters = { .request_response = 0 }; parameters.request_response = AST_T38_TERMINATED; ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, ¶meters, sizeof(parameters)); } ast_channel_unlock(p->owner); ast_mutex_unlock(&p->lock); if(gH323Debug) ast_verb(0, "+++ close_udptl_connection\n"); return; } /* end of udptl handling */ int update_our_aliases(ooCallData *call, struct ooh323_pvt *p) { int updated = -1; ooAliases *psAlias = NULL; if (!call->ourAliases) return updated; for (psAlias = call->ourAliases; psAlias; psAlias = psAlias->next) { if (psAlias->type == T_H225AliasAddress_h323_ID) { ast_copy_string(p->callee_h323id, psAlias->value, sizeof(p->callee_h323id)); updated = 1; } if (psAlias->type == T_H225AliasAddress_dialedDigits) { ast_copy_string(p->callee_dialedDigits, psAlias->value, sizeof(p->callee_dialedDigits)); updated = 1; } if (psAlias->type == T_H225AliasAddress_url_ID) { ast_copy_string(p->callee_url, psAlias->value, sizeof(p->callee_url)); updated = 1; } if (psAlias->type == T_H225AliasAddress_email_ID) { ast_copy_string(p->callee_email, psAlias->value, sizeof(p->callee_email)); updated = 1; } } return updated; } struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p) { /* Retrieve audio/etc from channel. Assumes p->lock is already held. */ struct ast_frame *f; struct ast_frame *dfr = NULL; static struct ast_frame null_frame = { AST_FRAME_NULL, }; switch (ast_channel_fdno(ast)) { case 0: f = ast_rtp_instance_read(p->rtp, 0); /* RTP Audio */ p->lastrtprx = time(NULL); break; case 1: f = ast_rtp_instance_read(p->rtp, 1); /* RTCP Control Channel */ break; case 2: f = ast_rtp_instance_read(p->vrtp, 0); /* RTP Video */ p->lastrtprx = time(NULL); break; case 3: f = ast_rtp_instance_read(p->vrtp, 1); /* RTCP Control Channel for video */ break; case 5: f = ast_udptl_read(p->udptl); /* UDPTL t.38 data */ if (gH323Debug) { ast_debug(1, "Got UDPTL %d/%d len %d for %s\n", f->frametype, f->subclass.integer, f->datalen, ast_channel_name(ast)); } p->lastrtprx = time(NULL); break; default: f = &null_frame; } if (f && p->owner && !p->faxmode && (f->frametype == AST_FRAME_VOICE)) { /* We already hold the channel lock */ if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(p->owner), &f->subclass.format))) { ast_debug(1, "Oooh, voice format changed to %s\n", ast_getformatname(&f->subclass.format)); ast_format_cap_set(ast_channel_nativeformats(p->owner), &f->subclass.format); ast_set_read_format(p->owner, ast_channel_readformat(p->owner)); ast_set_write_format(p->owner, ast_channel_writeformat(p->owner)); } if (((p->dtmfmode & H323_DTMF_INBAND) || (p->faxdetect & FAXDETECT_CNG)) && p->vad && (f->subclass.format.id == AST_FORMAT_SLINEAR || f->subclass.format.id == AST_FORMAT_ALAW || f->subclass.format.id == AST_FORMAT_ULAW)) { dfr = ast_frdup(f); dfr = ast_dsp_process(p->owner, p->vad, dfr); } } else { return f; } /* process INBAND DTMF*/ if (dfr && (dfr->frametype == AST_FRAME_DTMF) && ((dfr->subclass.integer == 'f') || (dfr->subclass.integer == 'e'))) { ast_debug(1, "* Detected FAX Tone %s\n", (dfr->subclass.integer == 'e') ? "CED" : "CNG"); /* Switch to T.38 ON CED*/ if (!p->faxmode && !p->chmodepend && (dfr->subclass.integer == 'e') && (p->t38support != T38_DISABLED)) { if (gH323Debug) ast_verb(0, "request to change %s to t.38 because fax ced\n", p->callToken); p->chmodepend = 1; p->faxdetected = 1; ooRequestChangeMode(p->callToken, 1); } else if ((dfr->subclass.integer == 'f') && !p->faxdetected) { const char *target_context = S_OR(ast_channel_macrocontext(p->owner), ast_channel_context(p->owner)); if ((strcmp(ast_channel_exten(p->owner), "fax")) && (ast_exists_extension(p->owner, target_context, "fax", 1, S_COR(ast_channel_caller(p->owner)->id.number.valid, ast_channel_caller(p->owner)->id.number.str, NULL)))) { ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner)); pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", ast_channel_exten(p->owner)); if (ast_async_goto(p->owner, target_context, "fax", 1)) { ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context); } p->faxdetected = 1; if (dfr) { ast_frfree(dfr); } return &ast_null_frame; } } } else if (dfr && dfr->frametype == AST_FRAME_DTMF) { ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass.integer); ast_frfree(f); return dfr; } if (dfr) { ast_frfree(dfr); } return f; } void onModeChanged(ooCallData *call, int t38mode) { struct ooh323_pvt *p; p = find_call(call); if (!p) { ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken); return; } ast_mutex_lock(&p->lock); if (gH323Debug) ast_debug(1, "change mode to %d for %s\n", t38mode, call->callToken); if (t38mode == p->faxmode) { if (gH323Debug) ast_debug(1, "mode for %s is already %d\n", call->callToken, t38mode); p->chmodepend = 0; ast_mutex_unlock(&p->lock); return; } if (p->owner) { while (p->owner && ast_channel_trylock(p->owner)) { ast_debug(1,"Failed to grab lock, trying again\n"); DEADLOCK_AVOIDANCE(&p->lock); } if (!p->owner) { p->chmodepend = 0; ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } } else { p->chmodepend = 0; ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Channel has no owner\n"); return; } if (t38mode) { if (p->t38support == T38_ENABLED) { struct ast_control_t38_parameters parameters = { .request_response = 0 }; if ((p->faxdetect & FAXDETECT_T38) && !p->faxdetected) { const char *target_context; ast_debug(1, "* Detected T.38 Request\n"); target_context = S_OR(ast_channel_macrocontext(p->owner), ast_channel_context(p->owner)); if ((strcmp(ast_channel_exten(p->owner), "fax")) && (ast_exists_extension(p->owner, target_context, "fax", 1, S_COR(ast_channel_caller(p->owner)->id.number.valid, ast_channel_caller(p->owner)->id.number.str, NULL)))) { ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner)); pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", ast_channel_exten(p->owner)); if (ast_async_goto(p->owner, target_context, "fax", 1)) { ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context); } } p->faxdetected = 1; } /* AST_T38_CONTROL mode */ parameters.request_response = AST_T38_REQUEST_NEGOTIATE; if (call->T38FarMaxDatagram) { ast_udptl_set_far_max_datagram(p->udptl, call->T38FarMaxDatagram); } else { ast_udptl_set_far_max_datagram(p->udptl, 144); } if (call->T38Version) { parameters.version = call->T38Version; } parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl); parameters.rate = AST_T38_RATE_14400; ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, ¶meters, sizeof(parameters)); p->faxmode = 1; } } else { if (p->t38support == T38_ENABLED) { struct ast_control_t38_parameters parameters = { .request_response = 0 }; parameters.request_response = AST_T38_REQUEST_TERMINATE; parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl); parameters.rate = AST_T38_RATE_14400; ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, ¶meters, sizeof(parameters)); } p->faxmode = 0; p->faxdetected = 0; p->t38_init = 0; } p->chmodepend = 0; ast_channel_unlock(p->owner); ast_mutex_unlock(&p->lock); } int ooh323_convert_hangupcause_asteriskToH323(int cause) { switch (cause) { case AST_CAUSE_CALL_REJECTED: return OO_REASON_REMOTE_REJECTED; case AST_CAUSE_UNALLOCATED: return OO_REASON_NOUSER; case AST_CAUSE_BUSY: return OO_REASON_REMOTE_BUSY; case AST_CAUSE_BEARERCAPABILITY_NOTAVAIL: return OO_REASON_NOCOMMON_CAPABILITIES; case AST_CAUSE_CONGESTION: return OO_REASON_REMOTE_BUSY; case AST_CAUSE_NO_ANSWER: return OO_REASON_REMOTE_NOANSWER; case AST_CAUSE_NORMAL: return OO_REASON_REMOTE_CLEARED; case AST_CAUSE_FAILURE: default: return OO_REASON_UNKNOWN; } return 0; } int ooh323_convert_hangupcause_h323ToAsterisk(int cause) { switch (cause) { case OO_REASON_REMOTE_REJECTED: return AST_CAUSE_CALL_REJECTED; case OO_REASON_NOUSER: return AST_CAUSE_UNALLOCATED; case OO_REASON_REMOTE_BUSY: case OO_REASON_LOCAL_BUSY: return AST_CAUSE_BUSY; case OO_REASON_NOCOMMON_CAPABILITIES: /* No codecs approved */ return AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; case OO_REASON_REMOTE_CONGESTED: case OO_REASON_LOCAL_CONGESTED: return AST_CAUSE_CONGESTION; case OO_REASON_REMOTE_NOANSWER: return AST_CAUSE_NO_ANSWER; case OO_REASON_UNKNOWN: case OO_REASON_INVALIDMESSAGE: case OO_REASON_TRANSPORTFAILURE: return AST_CAUSE_FAILURE; case OO_REASON_REMOTE_CLEARED: return AST_CAUSE_NORMAL; default: return AST_CAUSE_NORMAL; } /* Never reached */ return 0; } #if 0 void ast_ooh323c_exit() { ooGkClientDestroy(); } #endif AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Objective Systems H323 Channel"); asterisk-11.7.0/addons/ooh323c/0000755000175000007640000000000012254071123015772 5ustar sharkyjerrywebasterisk-11.7.0/addons/ooh323c/COPYING0000644000175000007640000004313211222440006017022 0ustar sharkyjerryweb 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. Copyright (C) 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. , 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. asterisk-11.7.0/addons/ooh323c/src/0000755000175000007640000000000012254071123016561 5ustar sharkyjerrywebasterisk-11.7.0/addons/ooh323c/src/ooUtils.h0000644000175000007640000000313711222440006020366 0ustar sharkyjerryweb/* * 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 asterisk-11.7.0/addons/ooh323c/src/ootypes.h0000644000175000007640000002044711656547674020473 0ustar sharkyjerryweb/* * 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 *

ooH323c Stack Functions

* * The Objective Open H.323 for C (ooH323c) 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: *
    *
  • Stack command functions. These are high level functions used to * initiate common H.323 telephony operations (for example, to make a * call).
  • *
  • Gatekeeper functions. These are high level functions for * managing communications with a gatekeeper using RAS messages.
  • *
  • H.323 endpoint management functions. These are function for * used for managing the global H.323 endpoint.
  • *
  • Call management functions. These are functions used to manage * active calls within the stack.
  • *
  • Capability management functions. These functions are used for * negotiating capabilities between two different terminals.
  • *
  • H.225 and H.245 message handling functions. Functions for * creating and handling H.323 standard ASN.1 messages.
  • *
  • Q.931 functions. Functions for the execution of various * standard Q.931 operations.
  • *
  • TCP/IP and UDP socket communication functions. Low-level * functions for writing data to and receiving data from sockets.
  • *
*/ /** * @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.3m" #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; typedef enum OOMSAckStatus { OO_msAck_localSent, OO_msAck_remoteReceived } OOMSAckStatus; /** * 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 2+8*4+7 /** 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 OORequestModeAck 131 #define OORequestModeReject 132 #define OORequestMode 133 #define OORequestDelayResponse 134 #define OORequestDelayRequest 135 #define OOStatus 136 #define OO_MSGTYPE_MAX 136 /* 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) #define OO_RTD_TIMER (1<<8) /** 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 */ int transfercap; /* q931 cap */ }ooCallOptions; struct OOH323CallData; typedef struct ooTimerCallback{ struct OOH323CallData* call; ASN1UINT timerType; ASN1UINT channelNumber; } ooTimerCallback; /** * @} */ #endif asterisk-11.7.0/addons/ooh323c/src/ooh323.h0000644000175000007640000001441311353514761017763 0ustar sharkyjerryweb/* * 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); /** */ EXTERN int ooPopulatePrefixList(OOCTXT *pctxt, OOAliases *pAliases, H225_SeqOfH225SupportedPrefix *pPrefixList ); /** * 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, int pAliasType); /** * 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 asterisk-11.7.0/addons/ooh323c/src/context.c0000644000175000007640000001066311352772022020423 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "ooasn1.h" #include #include int initContext (OOCTXT* pctxt) { memset (pctxt, 0, sizeof(OOCTXT)); memHeapCreate (&pctxt->pTypeMemHeap); pctxt->pMsgMemHeap = pctxt->pTypeMemHeap; memHeapAddRef (&pctxt->pMsgMemHeap); ast_mutex_init(&pctxt->pLock); 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) { /* ast_mutex_lock(&pctxt->pLock); */ int stat = ASN_OK; ast_mutex_lock(&psrc->pLock); 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; ast_mutex_unlock(&psrc->pLock); /* ast_mutex_unlock(&pctxt->pLock); */ return stat; } void freeContext (OOCTXT* pctxt) { ASN1BOOL saveBuf; ast_mutex_lock(&pctxt->pLock); 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); ast_mutex_unlock(&pctxt->pLock); ast_mutex_destroy(&pctxt->pLock); } void copyContext (OOCTXT* pdest, OOCTXT* psrc) { /* ast_mutex_lock(&pdest->pLock); ast_mutex_lock(&psrc->pLock); */ memcpy (&pdest->buffer, &psrc->buffer, sizeof(ASN1BUFFER)); pdest->flags = psrc->flags; /* ast_mutex_unlock(&psrc->pLock); ast_mutex_unlock(&pdest->pLock); */ } void setCtxtFlag (OOCTXT* pctxt, ASN1USINT mask) { ast_mutex_lock(&pctxt->pLock); pctxt->flags |= mask; ast_mutex_unlock(&pctxt->pLock); } void clearCtxtFlag (OOCTXT* pctxt, ASN1USINT mask) { ast_mutex_lock(&pctxt->pLock); pctxt->flags &= ~mask; ast_mutex_unlock(&pctxt->pLock); } int setPERBufferUsingCtxt (OOCTXT* pTarget, OOCTXT* pSource) { int stat; ast_mutex_lock(&pTarget->pLock); ast_mutex_lock(&pSource->pLock); 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; } ast_mutex_unlock(&pSource->pLock); ast_mutex_unlock(&pTarget->pLock); return stat; } int setPERBuffer (OOCTXT* pctxt, ASN1OCTET* bufaddr, ASN1UINT bufsiz, ASN1BOOL aligned) { int stat; ast_mutex_lock(&pctxt->pLock); stat = initContextBuffer (pctxt, bufaddr, bufsiz); ast_mutex_unlock(&pctxt->pLock); if(stat != ASN_OK) return stat; return ASN_OK; } OOCTXT* newContext () { /* OOCTXT* pctxt = (OOCTXT*) ASN1CRTMALLOC0 (sizeof(OOCTXT)); */ OOCTXT* pctxt = (OOCTXT*) malloc (sizeof(OOCTXT)); if (pctxt) { if (initContext(pctxt) != ASN_OK) { /* ASN1CRTFREE0 (pctxt); */ free(pctxt); pctxt = 0; } pctxt->flags |= ASN1DYNCTXT; } return (pctxt); } asterisk-11.7.0/addons/ooh323c/src/errmgmt.c0000644000175000007640000001675511352772022020424 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include #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); */ char* tmpstr = (char*) malloc (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]); */ free ((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; } asterisk-11.7.0/addons/ooh323c/src/oochannels.h0000644000175000007640000001552611274375744021115 0ustar sharkyjerryweb/* * 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); EXTERN int ooMonitorCmdChannels(void); EXTERN int ooMonitorCallChannels(OOH323CallData *); /** * 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); EXTERN void ooStopMonitorCallChannels(OOH323CallData *); /** * 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 asterisk-11.7.0/addons/ooh323c/src/ooUtils.c0000644000175000007640000000223311352772022020367 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "ooUtils.h" #include 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; } asterisk-11.7.0/addons/ooh323c/src/ooCapability.c0000644000175000007640000031325011775107640021363 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "ooCapability.h" #include "ootrace.h" #include "ooCalls.h" #include "ooh323ep.h" #include "ooUtils.h" /** Global endpoint structure */ extern OOH323EndPoint gH323ep; static int giDynamicRTPPayloadType = 101; static int gcDynamicRTPPayloadType = 121; int ooCapabilityEnableDTMFRFC2833 (OOH323CallData *call, int dynamicRTPPayloadType) { if(!call) { gH323ep.dtmfmode |= OO_CAP_DTMF_RFC2833; OOTRACEINFO1("Enabled RFC2833 DTMF capability for end-point\n"); /*Dynamic RTP payload type range is from 96 - 127 */ if(dynamicRTPPayloadType >= 96 && dynamicRTPPayloadType <= 127) giDynamicRTPPayloadType = dynamicRTPPayloadType; } else{ call->dtmfmode |= OO_CAP_DTMF_RFC2833; OOTRACEINFO3("Enabled RFC2833 DTMF capability for (%s, %s) \n", call->callType, call->callToken); if(dynamicRTPPayloadType >= 96 && dynamicRTPPayloadType <= 127) call->dtmfcodec = dynamicRTPPayloadType; else call->dtmfcodec = giDynamicRTPPayloadType; } return OO_OK; } int ooCapabilityEnableDTMFCISCO (OOH323CallData *call, int dynamicRTPPayloadType) { if(!call) { gH323ep.dtmfmode |= OO_CAP_DTMF_CISCO; OOTRACEINFO1("Enabled RTP/CISCO DTMF capability for end-point\n"); /*Dynamic RTP payload type range is from 96 - 127 */ if(dynamicRTPPayloadType >= 96 && dynamicRTPPayloadType <= 127) gcDynamicRTPPayloadType = dynamicRTPPayloadType; else call->dtmfcodec = dynamicRTPPayloadType; } else{ call->dtmfmode |= OO_CAP_DTMF_CISCO; OOTRACEINFO3("Enabled RTP/CISCO DTMF capability for (%s, %s) \n", call->callType, call->callToken); if(dynamicRTPPayloadType >= 96 && dynamicRTPPayloadType <= 127) call->dtmfcodec = dynamicRTPPayloadType; else call->dtmfcodec = gcDynamicRTPPayloadType; } return OO_OK; } int ooCapabilityDisableDTMFRFC2833(OOH323CallData *call) { if(!call){ gH323ep.dtmfmode ^= OO_CAP_DTMF_RFC2833; OOTRACEINFO1("Disabled RFC2833 DTMF capability for end-point\n"); } else{ call->dtmfmode ^= OO_CAP_DTMF_RFC2833; OOTRACEINFO3("Disabled RFC2833 DTMF capability for (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityDisableDTMFCISCO(OOH323CallData *call) { if(!call){ gH323ep.dtmfmode ^= OO_CAP_DTMF_CISCO; OOTRACEINFO1("Disabled RTP/CISCO DTMF capability for end-point\n"); } else{ call->dtmfmode ^= OO_CAP_DTMF_CISCO; OOTRACEINFO3("Disabled RTP/CISCO DTMF capability for (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityEnableDTMFH245Alphanumeric(OOH323CallData *call) { if(!call){ gH323ep.dtmfmode |= OO_CAP_DTMF_H245_alphanumeric; OOTRACEINFO1("Dtmf mode set to H.245(alphanumeric) for endpoint\n"); } else { call->dtmfmode |= OO_CAP_DTMF_H245_alphanumeric; OOTRACEINFO3("Dtmf mode set to H.245(alphanumeric) for (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityDisableDTMFH245Alphanumeric(OOH323CallData *call) { if(!call){ gH323ep.dtmfmode ^= OO_CAP_DTMF_H245_alphanumeric; OOTRACEINFO1("Dtmf mode H.245(alphanumeric) disabled for endpoint\n"); } else { call->dtmfmode ^= OO_CAP_DTMF_H245_alphanumeric; OOTRACEINFO3("Dtmf mode H.245(alphanumeric) disabled for (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityEnableDTMFH245Signal(OOH323CallData *call) { if(!call){ gH323ep.dtmfmode |= OO_CAP_DTMF_H245_signal; OOTRACEINFO1("Dtmf mode set to H.245(signal) for endpoint\n"); } else { call->dtmfmode |= OO_CAP_DTMF_H245_signal; OOTRACEINFO3("Dtmf mode set to H.245(signal) for (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityDisableDTMFH245Signal(OOH323CallData *call) { if(!call){ gH323ep.dtmfmode ^= OO_CAP_DTMF_H245_signal; OOTRACEINFO1("Dtmf mode H.245(signal) disabled for endpoint\n"); } else { call->dtmfmode ^= OO_CAP_DTMF_H245_signal; OOTRACEINFO3("Dtmf mode H.245(signal) disabled for (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityEnableDTMFQ931Keypad(struct OOH323CallData *call) { if(!call){ gH323ep.dtmfmode |= OO_CAP_DTMF_Q931; OOTRACEINFO1("Dtmf mode set to Q.931(keypad) for the endpoint\n"); } else { call->dtmfmode |= OO_CAP_DTMF_Q931; OOTRACEINFO3("Dtmf mode set to Q.931(keypad) for the call (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityDisableDTMFQ931Keypad(struct OOH323CallData *call) { if(!call){ gH323ep.dtmfmode ^= OO_CAP_DTMF_Q931; OOTRACEINFO1("Dtmf mode Q.931(keypad) disabled for the endpoint\n"); } else { call->dtmfmode ^= OO_CAP_DTMF_Q931; OOTRACEINFO3("Dtmf mode Q.931(keypad) disabled for the call (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityAddH263VideoCapability(ooCallData *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) { int ret = OO_OK; if(sqcifMPI>0) { ret = ooCapabilityAddH263VideoCapability_helper(call, sqcifMPI, 0, 0, 0, 0, maxBitRate, dir, startReceiveChannel, startTransmitChannel, stopReceiveChannel, stopTransmitChannel, remote); if(ret != OO_OK) { OOTRACEERR1("Error: Failed to add H263 sqcifMPI capability\n"); return OO_FAILED; } } if(qcifMPI>0) { ret = ooCapabilityAddH263VideoCapability_helper(call, 0, qcifMPI, 0, 0, 0, maxBitRate, dir, startReceiveChannel, startTransmitChannel, stopReceiveChannel, stopTransmitChannel, remote); if(ret != OO_OK) { OOTRACEERR1("Error: Failed to add H263 qcifMPI capability\n"); return OO_FAILED; } } if(cifMPI>0) { ret = ooCapabilityAddH263VideoCapability_helper(call, 0, 0, cifMPI, 0, 0, maxBitRate, dir, startReceiveChannel, startTransmitChannel, stopReceiveChannel, stopTransmitChannel, remote); if(ret != OO_OK) { OOTRACEERR1("Error: Failed to add H263 cifMPI capability\n"); return OO_FAILED; } } if(cif4MPI>0) { ret = ooCapabilityAddH263VideoCapability_helper(call, 0, 0, 0, cif4MPI, 0, maxBitRate, dir, startReceiveChannel, startTransmitChannel, stopReceiveChannel, stopTransmitChannel, remote); if(ret != OO_OK) { OOTRACEERR1("Error: Failed to add H263 cif4MPI capability\n"); return OO_FAILED; } } if(cif16MPI>0) { ret = ooCapabilityAddH263VideoCapability_helper(call, dir, 0, 0, 0, 0, cif16MPI, maxBitRate, startReceiveChannel, startTransmitChannel, stopReceiveChannel, stopTransmitChannel, remote); if(ret != OO_OK) { OOTRACEERR1("Error: Failed to add H263 cif16MPI capability\n"); return OO_FAILED; } } return OO_OK; } int ooCapabilityAddH263VideoCapability_helper(ooCallData *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) { ooH323EpCapability *epCap = NULL, *cur=NULL; OOH263CapParams *params=NULL; OOCTXT *pctxt=NULL; char *pictureType = NULL; int cap = OO_H263VIDEO; if(!call) pctxt = &gH323ep.ctxt; else pctxt = call->pctxt; epCap = (ooH323EpCapability*)memAllocZ(pctxt, sizeof(ooH323EpCapability)); params = (OOH263CapParams*) memAllocZ(pctxt, sizeof(OOH263CapParams)); if(!epCap || !params) { OOTRACEERR1("Error:Memory - ooCapabilityAddH263Capability - epCap/params" ".\n"); return OO_FAILED; } if(sqcifMPI>0) { params->MPI = sqcifMPI; params->picFormat = OO_PICFORMAT_SQCIF; pictureType = "SQCIF"; } if(qcifMPI>0) { params->MPI = qcifMPI; params->picFormat = OO_PICFORMAT_QCIF; pictureType = "QCIF"; } if(cifMPI>0) { params->MPI = cifMPI; params->picFormat = OO_PICFORMAT_CIF; pictureType = "CIF"; } if(cif4MPI>0) { params->MPI = cif4MPI; params->picFormat = OO_PICFORMAT_CIF4; pictureType = "CIF4"; } if(cif16MPI>0) { params->MPI = cif16MPI; params->picFormat = OO_PICFORMAT_CIF16; pictureType = "CIF16"; } params->maxBitRate = maxBitRate; if(dir & OORXANDTX) { epCap->dir = OORX; epCap->dir |= OOTX; } else epCap->dir = dir; epCap->cap = OO_H263VIDEO; epCap->capType = OO_CAP_TYPE_VIDEO; epCap->params = (void*)params; epCap->startReceiveChannel = startReceiveChannel; epCap->startTransmitChannel = startTransmitChannel; epCap->stopReceiveChannel = stopReceiveChannel; epCap->stopTransmitChannel = stopTransmitChannel; epCap->next = NULL; if(!call) {/*Add as local capability */ OOTRACEDBGC2("Adding endpoint H263 video capability %s.\n", pictureType); if(!gH323ep.myCaps) gH323ep.myCaps = epCap; else{ cur = gH323ep.myCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(NULL, cap); gH323ep.noOfCaps++; } else{ if(remote) { /*Add as remote capability */ if(!call->remoteCaps) call->remoteCaps = epCap; else{ cur = call->remoteCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } else{ /*Add as our capability */ OOTRACEDBGC4("Adding call specific H263 video capability %s. " "(%s, %s)\n", pictureType, call->callType, call->callToken); if(!call->ourCaps){ call->ourCaps = epCap; ooResetCapPrefs(call); }else{ cur = call->ourCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(call, cap); } } return OO_OK; } /* Used for g711 ulaw/alaw, g728, g729 and g7231 */ int ooCapabilityAddSimpleCapability (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) { ooH323EpCapability *epCap = NULL, *cur=NULL; OOCapParams *params=NULL; OOCTXT *pctxt=NULL; if(!call) pctxt = &gH323ep.ctxt; else pctxt = call->pctxt; epCap = (ooH323EpCapability*)memAlloc(pctxt, sizeof(ooH323EpCapability)); params = (OOCapParams*) memAlloc(pctxt, sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR1("ERROR: Memory - ooCapabilityAddSimpleCapability - " "epCap/params\n"); return OO_FAILED; } params->txframes = txframes; params->rxframes = rxframes; /* Ignore silence suppression parameter unless cap is g7231 */ if(cap == OO_G7231) params->silenceSuppression = silenceSuppression; else params->silenceSuppression = FALSE; /* Set to false for g711 and g729*/ if(dir & OORXANDTX) { epCap->dir = OORX; epCap->dir |= OOTX; } else { epCap->dir = dir; } epCap->cap = cap; epCap->capType = OO_CAP_TYPE_AUDIO; epCap->params = (void*)params; epCap->startReceiveChannel = startReceiveChannel; epCap->startTransmitChannel = startTransmitChannel; epCap->stopReceiveChannel = stopReceiveChannel; epCap->stopTransmitChannel = stopTransmitChannel; epCap->next = NULL; if(!call) { /* Add as local capability */ OOTRACEDBGC2("Adding endpoint capability %s. \n", ooGetCapTypeText(epCap->cap)); if(!gH323ep.myCaps) { gH323ep.myCaps = epCap; } else{ cur = gH323ep.myCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(NULL, cap); gH323ep.noOfCaps++; } else{ if(remote) { /* Add as remote capability */ if(!call->remoteCaps) { call->remoteCaps = epCap; } else{ cur = call->remoteCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } else{ /* Add as our capability */ OOTRACEDBGC4("Adding call specific capability %s. (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); if(!call->ourCaps){ call->ourCaps = epCap; ooResetCapPrefs(call); } else{ cur = call->ourCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(call, cap); } } return OO_OK; } int epCapIsPreferred(OOH323CallData *call, ooH323EpCapability *epCap) { ooH323EpCapability *curCap = call->ourCaps; while (curCap) { if (curCap->capType == epCap->capType) { if (curCap->cap == epCap->cap) return 1; else return 0; } curCap = curCap->next; } return 0; } int ooCapabilityAddGSMCapability(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) { ooH323EpCapability *epCap = NULL, *cur=NULL; OOGSMCapParams *params=NULL; OOCTXT *pctxt = NULL; if(!call) pctxt = &gH323ep.ctxt; else pctxt = call->pctxt; epCap = (ooH323EpCapability*)memAlloc(pctxt, sizeof(ooH323EpCapability)); params = (OOGSMCapParams*) memAlloc(pctxt, sizeof(OOGSMCapParams)); if(!epCap || !params) { OOTRACEERR1("Error:Memory - ooCapabilityAddGSMCapability - " "epCap/params\n"); return OO_FAILED; } params->rxframes = framesPerPkt; params->txframes = framesPerPkt; params->comfortNoise = comfortNoise; params->scrambled = scrambled; if(dir & OORXANDTX) { epCap->dir = OORX; epCap->dir |= OOTX; } else epCap->dir = dir; epCap->cap = cap; epCap->capType = OO_CAP_TYPE_AUDIO; epCap->params = (void*)params; epCap->startReceiveChannel = startReceiveChannel; epCap->startTransmitChannel = startTransmitChannel; epCap->stopReceiveChannel = stopReceiveChannel; epCap->stopTransmitChannel = stopTransmitChannel; epCap->next = NULL; /* Add as local capability */ if(!call) { if(!gH323ep.myCaps) gH323ep.myCaps = epCap; else{ cur = gH323ep.myCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(NULL, cap); gH323ep.noOfCaps++; } else{ if(remote) { /*Add as remote capability */ if(!call->remoteCaps) call->remoteCaps = epCap; else{ cur = call->remoteCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } else{ OOTRACEDBGC4("Adding call specific capability %s. (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); /*Add as our capability */ if(!call->ourCaps){ call->ourCaps = epCap; ooResetCapPrefs(call); } else{ cur = call->ourCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(call, cap); } } return OO_OK; } /* Used for T38 */ int ooCapabilityAddT38Capability (OOH323CallData *call, int cap, int dir, cb_StartReceiveChannel startReceiveChannel, cb_StartTransmitChannel startTransmitChannel, cb_StopReceiveChannel stopReceiveChannel, cb_StopTransmitChannel stopTransmitChannel, OOBOOL remote) { ooH323EpCapability *epCap = NULL, *cur=NULL; OOCapParams *params=NULL; OOCTXT *pctxt=NULL; if(!call) pctxt = &gH323ep.ctxt; else pctxt = call->pctxt; epCap = (ooH323EpCapability*)memAllocZ(pctxt, sizeof(ooH323EpCapability)); params = (OOCapParams*) memAlloc(pctxt, sizeof(OOCapParams)); memset(params, 0 , sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR1("ERROR: Memory - ooCapabilityAddT38Capability - " "epCap/params\n"); return OO_FAILED; } if(dir & OORXANDTX) { epCap->dir = OORX; epCap->dir |= OOTX; } else { epCap->dir = dir; } epCap->cap = cap; epCap->capType = OO_CAP_TYPE_DATA; epCap->params = (void*)params; epCap->startReceiveChannel = startReceiveChannel; epCap->startTransmitChannel = startTransmitChannel; epCap->stopReceiveChannel = stopReceiveChannel; epCap->stopTransmitChannel = stopTransmitChannel; epCap->next = NULL; if(!call) { /* Add as local capability */ OOTRACEDBGC2("Adding endpoint capability %s. \n", ooGetCapTypeText(epCap->cap)); if(!gH323ep.myCaps) { gH323ep.myCaps = epCap; } else{ cur = gH323ep.myCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(NULL, cap); gH323ep.noOfCaps++; } else{ if(remote) { /* Add as remote capability */ if(!call->remoteCaps) { call->remoteCaps = epCap; } else{ cur = call->remoteCaps; while(cur->next) cur = cur->next; cur->next = epCap; } call->t38sides |= 2; } else{ /* Add as our capability */ OOTRACEDBGC4("Adding call specific capability %s. (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); if(!call->ourCaps){ call->ourCaps = epCap; ooResetCapPrefs(call); } else{ cur = call->ourCaps; while(cur->next) cur = cur->next; cur->next = epCap; } ooAppendCapToCapPrefs(call, cap); call->t38sides |= 1; } } return OO_OK; } struct H245VideoCapability* ooCapabilityCreateVideoCapability (ooH323EpCapability *epCap, OOCTXT *pctxt, int dir) { if(!epCap) { OOTRACEERR1("Error:Invalid capability parameter passed to " "ooCapabilityCreateVideoCapability.\n"); return NULL; } if(!(epCap->dir & dir)) { OOTRACEERR1("Error:Failed to create capability due to direction " "mismatch.\n"); return NULL; } switch(epCap->cap) { case OO_H263VIDEO: return ooCapabilityCreateH263VideoCapability(epCap, pctxt, dir); case OO_NONSTDVIDEO: case OO_H261VIDEO: case OO_H262VIDEO: case OO_IS11172VIDEO: case OO_GENERICVIDEO: case OO_EXTELEMVIDEO: default: OOTRACEERR2("ERROR: Don't know how to create video capability %s\n", ooGetCapTypeText(epCap->cap)); } return NULL; } struct H245AudioCapability* ooCapabilityCreateAudioCapability (ooH323EpCapability *epCap, OOCTXT *pctxt, int dir) { if(!epCap) { OOTRACEERR1("Error:Invalid capability parameter passed to " "ooCapabilityCreateAudioCapability.\n"); return NULL; } if(!(epCap->dir & dir)) { OOTRACEERR1("Error:Failed to create capability due to direction " "mismatch.\n"); return NULL; } switch(epCap->cap) { case OO_G711ALAW64K: case OO_G711ALAW56K: case OO_G711ULAW64K: case OO_G711ULAW56K: case OO_G728: case OO_G729: case OO_G729A: case OO_G729B: case OO_G7231: return ooCapabilityCreateSimpleCapability(epCap, pctxt, dir); case OO_G726: case OO_G726AAL2: case OO_AMRNB: case OO_SPEEX: return ooCapabilityCreateNonStandardCapability(epCap, pctxt, dir); case OO_GSMHALFRATE: case OO_GSMENHANCEDFULLRATE: case OO_GSMFULLRATE: return ooCapabilityCreateGSMFullRateCapability(epCap, pctxt, dir); default: OOTRACEERR2("ERROR: Don't know how to create audio capability %d\n", epCap->cap); } return NULL; } void* ooCapabilityCreateDTMFCapability(int cap, int dtmfcodec, OOCTXT *pctxt) { H245AudioTelephonyEventCapability *pATECap=NULL; H245DataApplicationCapability *pCSDTMFCap=NULL; H245UserInputCapability *userInput = NULL; char *events=NULL; switch(cap) { case OO_CAP_DTMF_RFC2833: pATECap = (H245AudioTelephonyEventCapability*)memAlloc(pctxt, sizeof(H245AudioTelephonyEventCapability)); if(!pATECap) { OOTRACEERR1("Error:Memory - ooCapabilityCreateDTMFCapability - pATECap\n"); return NULL; } memset(pATECap, 0, sizeof(H245AudioTelephonyEventCapability)); pATECap->dynamicRTPPayloadType = dtmfcodec; events = (char*)memAlloc(pctxt, strlen("0-16")+1); memset(events, 0, strlen("0-16")+1); if(!events) { OOTRACEERR1("Error:Memory - ooCapabilityCreateDTMFCapability - events\n"); memFreePtr(pctxt, pATECap); return NULL; } strncpy(events, "0-16", strlen("0-16")); pATECap->audioTelephoneEvent = events; return pATECap; case OO_CAP_DTMF_CISCO: pCSDTMFCap = (H245DataApplicationCapability*)memAlloc(pctxt, sizeof(H245DataApplicationCapability)); if(!pCSDTMFCap) { OOTRACEERR1("Error:Memory - ooCapabilityCreateDTMFCapability - pCSDTMFCap\n"); return NULL; } memset(pCSDTMFCap, 0, sizeof(H245DataApplicationCapability)); pCSDTMFCap->application.t = T_H245DataApplicationCapability_application_nonStandard; if ( (pCSDTMFCap->application.u.nonStandard = (H245NonStandardParameter *) memAllocZ(pctxt, sizeof(H245NonStandardParameter))) == NULL) { OOTRACEERR1("Error:Memory-ooCapabilityCreateDTMFCapability-H245NonStandardParameter\n"); memFreePtr(pctxt, pCSDTMFCap); return NULL; } pCSDTMFCap->application.u.nonStandard->nonStandardIdentifier.t=T_H245NonStandardIdentifier_h221NonStandard; pCSDTMFCap->application.u.nonStandard->nonStandardIdentifier.u.h221NonStandard = (H245NonStandardIdentifier_h221NonStandard *) memAllocZ(pctxt, sizeof(H245NonStandardIdentifier_h221NonStandard)); if (!pCSDTMFCap->application.u.nonStandard->nonStandardIdentifier.u.h221NonStandard) { OOTRACEERR1("Error:Memory-ooCapabilityCreateDTMFCapability-H245NonStandardParameter\n"); memFreePtr(pctxt, pCSDTMFCap); return NULL; } pCSDTMFCap->application.u.nonStandard->data.data = (unsigned char*)"RtpDtmfRelay"; pCSDTMFCap->application.u.nonStandard->data.numocts = sizeof("RtpDtmfRelay")-1; pCSDTMFCap->application.u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35CountryCode = 181; pCSDTMFCap->application.u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35Extension = 0; pCSDTMFCap->application.u.nonStandard->nonStandardIdentifier.u.h221NonStandard->manufacturerCode = 18; return pCSDTMFCap; case OO_CAP_DTMF_H245_alphanumeric: userInput = (H245UserInputCapability*)memAllocZ(pctxt, sizeof(H245UserInputCapability)); if(!userInput) { OOTRACEERR1("Error:Memory - ooCapabilityCreateDTMFCapability - " "userInput\n"); return NULL; } userInput->t = T_H245UserInputCapability_basicString; return userInput; case OO_CAP_DTMF_H245_signal: userInput = (H245UserInputCapability*)memAllocZ(pctxt, sizeof(H245UserInputCapability)); if(!userInput) { OOTRACEERR1("Error:Memory - ooCapabilityCreateDTMFCapability - " "userInput\n"); return NULL; } userInput->t = T_H245UserInputCapability_dtmf; return userInput; default: OOTRACEERR1("Error:unknown dtmf capability type\n"); } return NULL; } struct H245VideoCapability* ooCapabilityCreateH263VideoCapability (ooH323EpCapability *epCap, OOCTXT* pctxt, int dir) { H245VideoCapability *pVideo=NULL; OOH263CapParams *params=NULL; H245H263VideoCapability *pH263Cap=NULL; if(!epCap || !epCap->params) { OOTRACEERR1("Error:Invalid capability parameters to " "ooCapabilityCreateH263VideoCapability.\n"); return NULL; } params =(OOH263CapParams*)epCap->params; pVideo = (H245VideoCapability*)memAllocZ(pctxt, sizeof(H245VideoCapability)); pH263Cap = (H245H263VideoCapability*) memAllocZ(pctxt, sizeof(H245H263VideoCapability)); if(!pVideo || !pH263Cap) { OOTRACEERR1("ERROR:Memory - ooCapabilityCreateH263VideoCapability - " "pVideo/pH263Cap\n"); return NULL; } pVideo->t = T_H245VideoCapability_h263VideoCapability; pVideo->u.h263VideoCapability = pH263Cap; if(params->picFormat == OO_PICFORMAT_SQCIF) { pH263Cap->m.sqcifMPIPresent = TRUE; pH263Cap->sqcifMPI = params->MPI; } else if(params->picFormat == OO_PICFORMAT_QCIF) { pH263Cap->m.qcifMPIPresent = TRUE; pH263Cap->qcifMPI = params->MPI; } else if(params->picFormat == OO_PICFORMAT_CIF) { pH263Cap->m.cifMPIPresent = TRUE; pH263Cap->cifMPI = params->MPI; } else if(params->picFormat == OO_PICFORMAT_CIF4) { pH263Cap->m.cif4MPIPresent = TRUE; pH263Cap->cif4MPI = params->MPI; } else if(params->picFormat == OO_PICFORMAT_CIF16) { pH263Cap->m.cif16MPIPresent = TRUE; pH263Cap->cif16MPI = params->MPI; } pH263Cap->m.errorCompensationPresent = TRUE; pH263Cap->maxBitRate = params->maxBitRate; pH263Cap->unrestrictedVector = FALSE; pH263Cap->arithmeticCoding = FALSE; pH263Cap->advancedPrediction = FALSE; pH263Cap->pbFrames = FALSE; pH263Cap->temporalSpatialTradeOffCapability = FALSE; pH263Cap->hrd_B = 0; pH263Cap->bppMaxKb = 0; pH263Cap->slowSqcifMPI = FALSE; pH263Cap->slowQcifMPI = FALSE; pH263Cap->slowCifMPI = FALSE; pH263Cap->slowCif4MPI = FALSE; pH263Cap->slowCif16MPI = FALSE; pH263Cap->errorCompensation = FALSE; return pVideo; } struct H245AudioCapability* ooCapabilityCreateGSMFullRateCapability (ooH323EpCapability *epCap, OOCTXT* pctxt, int dir) { H245AudioCapability *pAudio=NULL; H245GSMAudioCapability *pGSMCap=NULL; if(!epCap || !epCap->params) { OOTRACEERR1("Error:Invalid capability parameters to " "ooCapabilityCreateGSMFullRateCapability.\n"); return NULL; } pAudio = (H245AudioCapability*)memAlloc(pctxt, sizeof(H245AudioCapability)); pGSMCap = (H245GSMAudioCapability*)memAlloc(pctxt, sizeof(H245GSMAudioCapability)); if(!pAudio || !pGSMCap) { OOTRACEERR1("ERROR:Memory - ooCapabilityCreateGSMFullRateCapability - " "pAudio/pGSMCap\n"); return NULL; } switch (epCap->cap) { case OO_GSMHALFRATE: pAudio->t = T_H245AudioCapability_gsmHalfRate; break; case OO_GSMENHANCEDFULLRATE: pAudio->t = T_H245AudioCapability_gsmEnhancedFullRate; break; default: pAudio->t = T_H245AudioCapability_gsmFullRate; } pAudio->u.gsmFullRate = pGSMCap; if(dir & OORX) pGSMCap->audioUnitSize = ((OOGSMCapParams*)epCap->params)->rxframes*OO_GSMFRAMESIZE; else pGSMCap->audioUnitSize = ((OOGSMCapParams*)epCap->params)->txframes*OO_GSMFRAMESIZE; pGSMCap->comfortNoise = ((OOGSMCapParams*)epCap->params)->comfortNoise; pGSMCap->scrambled = ((OOGSMCapParams*)epCap->params)->scrambled; return pAudio; } /* This is used for g711 ulaw/alaw, g728, g729, g729A, g7231*/ struct H245AudioCapability* ooCapabilityCreateSimpleCapability (ooH323EpCapability *epCap, OOCTXT* pctxt, int dir) { H245AudioCapability *pAudio=NULL; OOCapParams *params; if(!epCap || !epCap->params) { OOTRACEERR1("Error:Invalid capability parameters to " "ooCapabilityCreateSimpleCapability.\n"); return NULL; } params =(OOCapParams*)epCap->params; pAudio = (H245AudioCapability*)memAlloc(pctxt, sizeof(H245AudioCapability)); if(!pAudio) { OOTRACEERR1("ERROR:Memory - ooCapabilityCreateSimpleCapability - pAudio\n"); return NULL; } switch(epCap->cap) { case OO_G711ALAW64K: pAudio->t = T_H245AudioCapability_g711Alaw64k; if(dir & OORX) pAudio->u.g711Alaw64k = params->rxframes; else pAudio->u.g711Alaw64k = params->txframes; return pAudio; case OO_G711ALAW56K: pAudio->t = T_H245AudioCapability_g711Alaw56k; if(dir & OORX) pAudio->u.g711Alaw56k = params->rxframes; else pAudio->u.g711Alaw56k = params->txframes; return pAudio; case OO_G711ULAW64K: pAudio->t = T_H245AudioCapability_g711Ulaw64k; if(dir & OORX) pAudio->u.g711Ulaw64k = params->rxframes; else pAudio->u.g711Ulaw64k = params->txframes; return pAudio; case OO_G711ULAW56K: pAudio->t = T_H245AudioCapability_g711Ulaw56k; if(dir & OORX) pAudio->u.g711Ulaw56k = params->rxframes; else pAudio->u.g711Ulaw64k = params->txframes; return pAudio; case OO_G728: pAudio->t = T_H245AudioCapability_g728; if(dir & OORX) pAudio->u.g728 = params->rxframes; else pAudio->u.g728 = params->txframes; return pAudio; case OO_G729: pAudio->t = T_H245AudioCapability_g729; if(dir & OORX) pAudio->u.g729 = params->rxframes; else pAudio->u.g729 = params->txframes; return pAudio; case OO_G729A: pAudio->t = T_H245AudioCapability_g729AnnexA; if(dir & OORX) pAudio->u.g729AnnexA = params->rxframes; else pAudio->u.g729AnnexA = params->txframes; return pAudio; case OO_G729B: pAudio->t = T_H245AudioCapability_g729wAnnexB; if(dir & OORX) pAudio->u.g729AnnexA = params->rxframes; else pAudio->u.g729AnnexA = params->txframes; return pAudio; case OO_G7231: pAudio->t = T_H245AudioCapability_g7231; pAudio->u.g7231 = (H245AudioCapability_g7231*)memAlloc(pctxt, sizeof(H245AudioCapability_g7231)); if(!pAudio->u.g7231) { OOTRACEERR1("Error:Memory - ooCapabilityCreateSimpleCapability - g7231\n"); memFreePtr(pctxt, pAudio); return NULL; } pAudio->u.g7231->silenceSuppression = params->silenceSuppression; if(dir & OORX) pAudio->u.g7231->maxAl_sduAudioFrames = params->rxframes; else pAudio->u.g7231->maxAl_sduAudioFrames = params->txframes; return pAudio; default: OOTRACEERR2("ERROR: Don't know how to create audio capability %d\n", epCap->cap); } return NULL; } /* This is used for g726, AMRNB, Speex */ struct H245AudioCapability* ooCapabilityCreateNonStandardCapability (ooH323EpCapability *epCap, OOCTXT* pctxt, int dir) { H245AudioCapability *pAudio=NULL; if(!epCap || !epCap->params) { OOTRACEERR1("Error:Invalid capability parameters to " "ooCapabilityCreateSimpleCapability.\n"); return NULL; } pAudio = (H245AudioCapability*)memAlloc(pctxt, sizeof(H245AudioCapability)); if(!pAudio) { OOTRACEERR1("ERROR:Memory - ooCapabilityCreateSimpleCapability - pAudio\n"); return NULL; } switch(epCap->cap) { case OO_AMRNB: case OO_G726: case OO_G726AAL2: case OO_SPEEX: pAudio->t = T_H245AudioCapability_nonStandard; pAudio->u.nonStandard = (H245NonStandardParameter*)memAlloc(pctxt, sizeof(H245NonStandardParameter)); if(!pAudio->u.nonStandard) { OOTRACEERR1("Error:Memory - ooCapabilityCreateSimpleCapability - g726\n"); memFreePtr(pctxt, pAudio); return NULL; } pAudio->u.nonStandard->nonStandardIdentifier.t=T_H245NonStandardIdentifier_h221NonStandard; pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard = (H245NonStandardIdentifier_h221NonStandard *) memAlloc(pctxt, sizeof(H245NonStandardIdentifier_h221NonStandard)); if (!pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard) { OOTRACEERR2("Error:Memory - ooCapabilityCreateSimpleCapability - %d\n", epCap->cap); memFreePtr(pctxt, pAudio); return NULL; } pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35CountryCode = gH323ep.t35CountryCode; pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35Extension = gH323ep.t35Extension; pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->manufacturerCode = gH323ep.manufacturerCode; switch (epCap->cap) { case OO_G726: pAudio->u.nonStandard->data.data = (unsigned char*)"G.726-32k"; pAudio->u.nonStandard->data.numocts = sizeof("G.726-32k")-1; break; case OO_G726AAL2: pAudio->u.nonStandard->data.data = (unsigned char*)"G726r32"; pAudio->u.nonStandard->data.numocts = sizeof("G726r32")-1; /* Cisco G726 */ pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35CountryCode = 181; pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35Extension = 0; pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->manufacturerCode = 18; break; case OO_AMRNB: pAudio->u.nonStandard->data.data = (unsigned char*)"AMRNB"; pAudio->u.nonStandard->data.numocts = sizeof("AMRNB")-1; break; case OO_SPEEX: pAudio->u.nonStandard->data.data = (unsigned char*)"Speex"; pAudio->u.nonStandard->data.numocts = sizeof("Speex")-1; /* Equivalence OpenH323 SpeexNB */ pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35CountryCode = 9; pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35Extension = 0; pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->manufacturerCode = 61; break; } return pAudio; default: OOTRACEERR2("ERROR: Don't know how to create audio capability %d\n", epCap->cap); } return NULL; } /* Our t.38 params */ struct H245DataMode_application* ooCreateT38ApplicationData (OOCTXT* pctxt, H245DataMode_application *app) { app->t = T_H245DataApplicationCapability_application_t38fax; app->u.t38fax = (H245DataMode_application_t38fax *) memAlloc(pctxt, sizeof(H245DataMode_application_t38fax)); if (!app->u.t38fax) { OOTRACEERR1("Error:Memory - ooCreateT38AppData\n"); return NULL; } memset(app->u.t38fax, 0, sizeof(H245DataApplicationCapability_application_t38fax)); app->u.t38fax->t38FaxProtocol.t = T_H245DataProtocolCapability_udp; app->u.t38fax->t38FaxProfile.m.versionPresent = TRUE; app->u.t38fax->t38FaxProfile.version = 0; app->u.t38fax->t38FaxProfile.m.t38FaxRateManagementPresent = TRUE; app->u.t38fax->t38FaxProfile.t38FaxRateManagement.t = T_H245T38FaxRateManagement_transferredTCF; app->u.t38fax->t38FaxProfile.m.t38FaxUdpOptionsPresent = TRUE; app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.m.t38FaxMaxBufferPresent = TRUE; app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxMaxBuffer = 200; app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.m.t38FaxMaxDatagramPresent = TRUE; app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxMaxDatagram = 72; app->u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxUdpEC.t = T_H245T38FaxUdpOptions_t38FaxUdpEC_t38UDPRedundancy; return app; } /* This is used for T.38 */ struct H245DataApplicationCapability* ooCapabilityCreateT38Capability (ooH323EpCapability *epCap, OOCTXT* pctxt, int dir) { H245DataApplicationCapability *pT38=NULL; H245DataMode_application *pT38app; if(!epCap || !epCap->params) { OOTRACEERR1("Error:Invalid capability parameters to " "ooCapabilityCreateSimpleCapability.\n"); return NULL; } pT38 = (H245DataApplicationCapability*)memAlloc(pctxt, sizeof(H245DataApplicationCapability)); if(!pT38) { OOTRACEERR1("ERROR:Memory - ooCapabilityCreateT38Capability - pT38\n"); return NULL; } memset(pT38, 0, sizeof(H245DataApplicationCapability)); pT38app = (void *)&pT38->application; switch(epCap->cap) { case OO_T38: pT38->maxBitRate = 144; if (!ooCreateT38ApplicationData(pctxt, pT38app)) { OOTRACEERR2("Error:Memory - ooCapabilityCreateT38Capability - %d\n", epCap->cap); memFreePtr(pctxt, pT38); return NULL; } return pT38; default: OOTRACEERR2("ERROR: Don't know how to create T38 capability %d\n", epCap->cap); } return NULL; } /* Used for g711 ulaw/alaw, g728, g729, g729a, g7231 */ ASN1BOOL ooCapabilityCheckCompatibility_Simple (OOH323CallData *call, ooH323EpCapability* epCap, H245AudioCapability* audioCap, int dir) { int noofframes=0, cap; OOTRACEDBGC2("Comparing channel with codec type: %d\n", audioCap->t); switch(audioCap->t) { case T_H245AudioCapability_g711Ulaw56k: cap = OO_G711ULAW56K; noofframes = audioCap->u.g711Ulaw56k; break; case T_H245AudioCapability_g711Ulaw64k: cap = OO_G711ULAW64K; noofframes = audioCap->u.g711Ulaw64k; break; case T_H245AudioCapability_g711Alaw64k: cap = OO_G711ALAW64K; noofframes = audioCap->u.g711Alaw64k; break; case T_H245AudioCapability_g711Alaw56k: cap = OO_G711ALAW56K; noofframes = audioCap->u.g711Alaw56k; break; /*case T_H245AudioCapability_g726: cap = OO_G726; noofframes = audioCap->u.g726; break;*/ case T_H245AudioCapability_g728: cap = OO_G728; noofframes = audioCap->u.g728; break; case T_H245AudioCapability_g729: cap = OO_G729; noofframes = audioCap->u.g729; break; case T_H245AudioCapability_g729AnnexA: cap = OO_G729A; noofframes = audioCap->u.g729AnnexA; break; case T_H245AudioCapability_g729wAnnexB: cap = OO_G729B; noofframes = audioCap->u.g729wAnnexB; break; case T_H245AudioCapability_g7231: cap = OO_G7231; noofframes = audioCap->u.g7231->maxAl_sduAudioFrames; break; default: return FALSE; } OOTRACEDBGC3("Comparing codecs: current=%d, requested=%d\n", epCap->cap, cap); if(cap != epCap->cap) { return FALSE; } /* Can we receive this capability */ if(dir & OORX) { OOTRACEDBGC3("Comparing RX frame rate: channel's=%d, requested=%d\n", ((OOCapParams*)epCap->params)->rxframes, noofframes); if(((OOCapParams*)epCap->params)->rxframes >= noofframes) { return TRUE; } //else { // not supported, as already told other ep our max. receive rate // our ep can't receive more rate than it // return FALSE; //} } /* Can we transmit compatible stream */ if(dir & OOTX) { OOTRACEDBGC3("Comparing TX frame rate: channel's=%d, requested=%d\n", ((OOCapParams*)epCap->params)->txframes, noofframes); if(((OOCapParams*)epCap->params)->txframes <= noofframes) { return TRUE; } //else { // TODO: reduce our ep transmission rate, as peer EP has low receive // cap, than return TRUE //} } return FALSE; } /* Used for g726, AMRNB */ ASN1BOOL ooCapabilityCheckCompatibility_NonStandard (OOH323CallData *call, ooH323EpCapability* epCap, H245AudioCapability* audioCap, int dir) { int cap; OOTRACEDBGC2("Comparing channel with codec type: %d\n", audioCap->t); if (audioCap->t == T_H245AudioCapability_nonStandard && audioCap->u.nonStandard && audioCap->u.nonStandard->nonStandardIdentifier.t == T_H245NonStandardIdentifier_h221NonStandard) { switch (audioCap->u.nonStandard->data.numocts) { case sizeof("G.726-32k")-1: if (!strncmp((char *)audioCap->u.nonStandard->data.data, "G.726-32k", audioCap->u.nonStandard->data.numocts)) cap = OO_G726; else return FALSE; break; case sizeof("G726r32")-1: if (!strncmp((char *)audioCap->u.nonStandard->data.data, "G726r32", audioCap->u.nonStandard->data.numocts)) cap = OO_G726AAL2; else return FALSE; break; case sizeof("AMRNB")-1: /* case sizeof("Speex")-1 */ if (!strncmp((char *)audioCap->u.nonStandard->data.data, "AMRNB", audioCap->u.nonStandard->data.numocts)) cap = OO_AMRNB; else if (!strncmp((char *)audioCap->u.nonStandard->data.data, "Speex", audioCap->u.nonStandard->data.numocts)) cap = OO_SPEEX; else return FALSE; break; default: return FALSE; } } else return FALSE; OOTRACEDBGC3("Comparing codecs: current=%d, requested=%d\n", epCap->cap, cap); if(cap != epCap->cap) { return FALSE; } return TRUE; } OOBOOL ooCapabilityCheckCompatibility_GSM (OOH323CallData *call, ooH323EpCapability* epCap, H245AudioCapability* audioCap, int dir) { unsigned noofframes=0, cap; switch(audioCap->t) { case T_H245AudioCapability_gsmFullRate: cap = OO_GSMFULLRATE; noofframes = (audioCap->u.gsmFullRate->audioUnitSize)/OO_GSMFRAMESIZE; break; case T_H245AudioCapability_gsmHalfRate: cap = OO_GSMHALFRATE; noofframes = (audioCap->u.gsmHalfRate->audioUnitSize)/OO_GSMFRAMESIZE; break; case T_H245AudioCapability_gsmEnhancedFullRate: cap = OO_GSMENHANCEDFULLRATE; noofframes = (audioCap->u.gsmEnhancedFullRate->audioUnitSize)/OO_GSMFRAMESIZE; break; default: return FALSE; } if(cap != epCap->cap) { return FALSE; } /* can we receive this capability */ if(dir & OORX) { if(((OOGSMCapParams*)epCap->params)->rxframes >= noofframes) return TRUE; } /* Make sure we transmit compatible stream */ if(dir & OOTX) { if(((OOGSMCapParams*)epCap->params)->txframes > noofframes){ OOTRACEDBGA5("Reducing txframes for GSM from %d to %d to match " "receive capability of remote end.(%s, %s)\n", ((OOGSMCapParams*)epCap->params)->txframes, noofframes, call->callType, call->callToken); ((OOGSMCapParams*)epCap->params)->txframes = noofframes; } return TRUE; } return FALSE; } OOBOOL ooCapabilityCheckCompatibility_T38 (OOH323CallData *call, ooH323EpCapability* epCap, H245DataApplicationCapability* t38Cap, int dir) { unsigned cap = 0; switch(t38Cap->application.t) { case T_H245DataApplicationCapability_application_t38fax: cap = OO_T38; break; default: return FALSE; } if(cap != epCap->cap) { return FALSE; } return TRUE; } OOBOOL ooCapabilityCheckCompatibility_H263Video (struct OOH323CallData *call, ooH323EpCapability *epCap, H245VideoCapability *pVideoCap, int dir) { H245H263VideoCapability *pH263Cap = NULL; OOH263CapParams *params = epCap->params; if(!pVideoCap->u.h263VideoCapability) { OOTRACEERR3("Error:No H263 video capability present in video capability" "structure. (%s, %s)\n", call->callType, call->callToken); return FALSE; } pH263Cap = pVideoCap->u.h263VideoCapability; /* can we receive/transmit this capability */ if(OORX & dir) { if(pH263Cap->m.sqcifMPIPresent) { if(params->picFormat != OO_PICFORMAT_SQCIF) { return FALSE; } else{ if(pH263Cap->sqcifMPI >= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.qcifMPIPresent) { if(params->picFormat != OO_PICFORMAT_QCIF) { return FALSE; } else{ if(pH263Cap->qcifMPI >= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.cifMPIPresent) { if(params->picFormat != OO_PICFORMAT_CIF) { return FALSE; } else{ if(pH263Cap->cifMPI >= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.cif4MPIPresent) { if(params->picFormat != OO_PICFORMAT_CIF4) { return FALSE; } else{ if(pH263Cap->cif4MPI >= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.cif16MPIPresent) { if(params->picFormat != OO_PICFORMAT_CIF16) { return FALSE; } else{ if(pH263Cap->cif16MPI >= params->MPI) return TRUE; else return FALSE; } } } /* Can we transmit */ if(OOTX & dir) { if(pH263Cap->m.sqcifMPIPresent) { if(params->picFormat != OO_PICFORMAT_SQCIF) { return FALSE; } else{ if(pH263Cap->sqcifMPI <= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.qcifMPIPresent) { if(params->picFormat != OO_PICFORMAT_QCIF) { return FALSE; } else{ if(pH263Cap->qcifMPI <= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.cifMPIPresent) { if(params->picFormat != OO_PICFORMAT_CIF) { return FALSE; } else{ if(pH263Cap->cifMPI <= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.cif4MPIPresent) { if(params->picFormat != OO_PICFORMAT_CIF4) { return FALSE; } else{ if(pH263Cap->cif4MPI <= params->MPI) return TRUE; else return FALSE; } } if(pH263Cap->m.cif16MPIPresent) { if(params->picFormat != OO_PICFORMAT_CIF16) { return FALSE; } else{ if(pH263Cap->cif16MPI <= params->MPI) return TRUE; else return FALSE; } } } return FALSE; } OOBOOL ooCapabilityCheckCompatibility_Audio (OOH323CallData *call, ooH323EpCapability* epCap, H245AudioCapability* audioCap, int dir) { switch(audioCap->t) { case T_H245AudioCapability_g711Ulaw56k: case T_H245AudioCapability_g711Ulaw64k: case T_H245AudioCapability_g711Alaw64k: case T_H245AudioCapability_g711Alaw56k: /*case T_H245AudioCapability_g726:*/ case T_H245AudioCapability_g728: case T_H245AudioCapability_g729: case T_H245AudioCapability_g729AnnexA: case T_H245AudioCapability_g729wAnnexB: case T_H245AudioCapability_g7231: return ooCapabilityCheckCompatibility_Simple(call, epCap, audioCap, dir); case T_H245AudioCapability_nonStandard: return ooCapabilityCheckCompatibility_NonStandard(call, epCap, audioCap, dir); case T_H245AudioCapability_gsmHalfRate: case T_H245AudioCapability_gsmEnhancedFullRate: case T_H245AudioCapability_gsmFullRate: return ooCapabilityCheckCompatibility_GSM(call, epCap, audioCap, dir); default: return FALSE; } return FALSE; } OOBOOL ooCapabilityCheckCompatibility_Video (OOH323CallData *call, ooH323EpCapability* epCap, H245VideoCapability* videoCap, int dir) { switch(videoCap->t) { case T_H245VideoCapability_h263VideoCapability: return ooCapabilityCheckCompatibility_H263Video(call, epCap, videoCap, dir); default: OOTRACEDBGC3("ooCapabilityCheckCompatibility_Video - Unsupported video " "capability. (%s, %s)\n", call->callType, call->callToken); } return FALSE; } /* Note: In faststart if we sent transmit rate (x>y) and remote can receive only y, then we can't reduce our transmit rate */ OOBOOL ooCapabilityCheckCompatibility (struct OOH323CallData *call, ooH323EpCapability* epCap, H245DataType* dataType, int dir) { switch(dataType->t) { case T_H245DataType_audioData: if(epCap->capType == OO_CAP_TYPE_AUDIO) return ooCapabilityCheckCompatibility_Audio(call, epCap, dataType->u.audioData, dir); break; case T_H245DataType_videoData: if(epCap->capType == OO_CAP_TYPE_VIDEO) return ooCapabilityCheckCompatibility_Video(call, epCap, dataType->u.videoData, dir); break; case T_H245DataType_data: if(epCap->capType == OO_CAP_TYPE_DATA) return ooCapabilityCheckCompatibility_T38(call, epCap, dataType->u.data, dir); default: OOTRACEDBGC3("ooCapabilityCheckCompatibility - Unsupported " "capability. (%s, %s)\n", call->callType, call->callToken); } return FALSE; } #if 0 /** TODO: If txCap is local and number of txframes is greater than remote can receive, we should automatically decrease it. And logical channel cap should be the one where it should be decreased. The start logical channel will indicate the application that it is supposed to tx and a reduced rate. */ ASN1BOOL ooCheckCompatibility (OOH323CallData *call, ooH323EpCapability *txCap, ooH323EpCapability *rxCap) { if(txCap->cap != rxCap->cap) return FALSE; if(!(txCap->dir & OOTX)) return FALSE; if(!(rxCap->dir & OORX)) return FALSE; switch(txCap->cap) { case OO_G711ALAW64K: case OO_G711ALAW56K: case OO_G711ULAW64K: case OO_G711ULAW56K: case OO_G728: case OO_G729: case OO_G729A: case OO_G729B: case OO_G7231: if(((OOCapParams*)txCap->params)->txframes <= ((OOCapParams*)rxCap->params)->rxframes) return TRUE; else{ OOTRACEDBGA4("Simple caps %s are not compatible.(%s, %s)\n", ooGetCapTypeText(txCap->cap), call->callType, call->callToken); return FALSE; } case OO_GSMFULLRATE: case OO_GSMHALFRATE: case OO_GSMENHANCEDFULLRATE: if(((OOGSMCapParams*)txCap->params)->txframes <= ((OOGSMCapParams*)rxCap->params)->rxframes) return TRUE; else{ OOTRACEDBGA3("GSM caps are not compatible. (%s, %s)\n", call->callType, call->callToken); return FALSE; } default: OOTRACEWARN3("WARN: Unsupported capabilities being compared. (%s, %s)\n", call->callType, call->callToken); } return FALSE; } #endif ooH323EpCapability* ooIsAudioDataTypeGSMSupported (OOH323CallData *call, H245AudioCapability* audioCap, int dir) { unsigned framesPerPkt=0; int cap=0; ooH323EpCapability *cur = NULL, *epCap=NULL; OOGSMCapParams *params = NULL; switch(audioCap->t) { case T_H245AudioCapability_gsmFullRate: framesPerPkt = (audioCap->u.gsmFullRate->audioUnitSize)/OO_GSMFRAMESIZE; cap = OO_GSMFULLRATE; break; case T_H245AudioCapability_gsmHalfRate: framesPerPkt = (audioCap->u.gsmHalfRate->audioUnitSize)/OO_GSMFRAMESIZE; cap = OO_GSMHALFRATE; break; case T_H245AudioCapability_gsmEnhancedFullRate: framesPerPkt = (audioCap->u.gsmEnhancedFullRate->audioUnitSize)/OO_GSMFRAMESIZE; cap = OO_GSMENHANCEDFULLRATE; break; default: OOTRACEERR3("Error:Invalid GSM capability type.(%s, %s)\n", call->callType, call->callToken); return NULL; } OOTRACEDBGC4("Determined audio data type to be of type %d. Searching" " for matching capability.(%s, %s)\n", cap, call->callType, call->callToken); /* If we have call specific caps then we use them, otherwise we use general endpoint caps*/ if(call->ourCaps) cur = call->ourCaps; else cur = gH323ep.myCaps; while(cur) { OOTRACEDBGC4("Local cap being compared %d. (%s, %s)\n", cur->cap, call->callType, call->callToken); if(cur->cap == cap && (cur->dir & dir)) break; cur = cur->next; } if(!cur) return NULL; OOTRACEDBGC4("Found matching audio capability type %d. Comparing" " other parameters. (%s, %s)\n", cap, call->callType, call->callToken); /* can we receive this capability */ if(dir & OORX) { if(((OOGSMCapParams*)cur->params)->rxframes < framesPerPkt) return NULL; else{ epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params =(OOGSMCapParams*)memAlloc(call->pctxt,sizeof(OOGSMCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsAudioDataTypeGSMSupported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOGSMCapParams)); return epCap; } } /* Can we transmit compatible stream */ if(dir & OOTX) { epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params =(OOGSMCapParams*)memAlloc(call->pctxt,sizeof(OOGSMCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsAudioDataTypeGSMSupported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOGSMCapParams)); if(params->txframes > framesPerPkt) { OOTRACEINFO5("Reducing framesPerPkt for transmission of GSM " "capability from %d to %d to match receive capability of" " remote endpoint.(%s, %s)\n", params->txframes, framesPerPkt, call->callType, call->callToken); params->txframes = framesPerPkt; } return epCap; } return NULL; } /* used for g711 ulaw/alaw, g728, g729, g729a, g7231 */ ooH323EpCapability* ooIsAudioDataTypeSimpleSupported (OOH323CallData *call, H245AudioCapability* audioCap, int dir) { int cap, framesPerPkt=0; ooH323EpCapability *cur=NULL, *epCap=NULL; OOCapParams * params= NULL; /* Find similar capability */ switch(audioCap->t) { case T_H245AudioCapability_g711Alaw64k: framesPerPkt = audioCap->u.g711Alaw64k; cap = OO_G711ALAW64K; break; case T_H245AudioCapability_g711Alaw56k: framesPerPkt = audioCap->u.g711Alaw56k; cap = OO_G711ALAW56K; break; case T_H245AudioCapability_g711Ulaw56k: framesPerPkt = audioCap->u.g711Ulaw56k; cap = OO_G711ULAW56K; break; case T_H245AudioCapability_g711Ulaw64k: framesPerPkt = audioCap->u.g711Ulaw64k; cap = OO_G711ULAW64K; break; /* case T_H245AudioCapability_g726: framesPerPkt = audioCap->u.g726; cap = OO_G726; break; */ case T_H245AudioCapability_g728: framesPerPkt = audioCap->u.g728; cap = OO_G728; break; case T_H245AudioCapability_g729: framesPerPkt = audioCap->u.g729; cap = OO_G729; break; case T_H245AudioCapability_g729AnnexA: framesPerPkt = audioCap->u.g729AnnexA; cap = OO_G729A; break; case T_H245AudioCapability_g729wAnnexB: framesPerPkt = audioCap->u.g729wAnnexB; cap = OO_G729B; break; case T_H245AudioCapability_g7231: framesPerPkt = audioCap->u.g7231->maxAl_sduAudioFrames; cap = OO_G7231; break; default: return NULL; } OOTRACEDBGC4("Determined Simple audio data type to be of type %s. Searching" " for matching capability.(%s, %s)\n", ooGetCapTypeText(cap), call->callType, call->callToken); /* If we have call specific caps, we use them; otherwise use general endpoint caps */ if(call->ourCaps) cur = call->ourCaps; else cur = gH323ep.myCaps; while(cur) { OOTRACEDBGC4("Local cap being compared %s. (%s, %s)\n", ooGetCapTypeText(cur->cap),call->callType, call->callToken); if(cur->cap == cap && (cur->dir & dir)) break; cur = cur->next; } if(!cur) return NULL; OOTRACEDBGC4("Found matching simple audio capability type %s. Comparing" " other parameters. (%s, %s)\n", ooGetCapTypeText(cap), call->callType, call->callToken); /* can we receive this capability */ if(dir & OORX) { if(((OOCapParams*)cur->params)->rxframes < framesPerPkt) return NULL; if(((OOCapParams*)cur->params)->rxframes > framesPerPkt) ((OOCapParams*)cur->params)->rxframes = framesPerPkt; OOTRACEDBGC4("We can receive Simple capability %s. (%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params=(OOCapParams*)memAlloc(call->pctxt,sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsAudioDataTypeSimpleSupported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOCapParams)); OOTRACEDBGC4("Returning copy of matched receive capability %s. " "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } /* Can we transmit compatible stream */ if(dir & OOTX) { OOTRACEDBGC4("We can transmit Simple capability %s. (%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params =(OOCapParams*)memAlloc(call->pctxt,sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsAudioDataTypeSimpleSupported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOCapParams)); if(params->txframes > framesPerPkt) { OOTRACEINFO5("Reducing framesPerPkt for transmission of Simple " "capability from %d to %d to match receive capability of" " remote endpoint.(%s, %s)\n", params->txframes, framesPerPkt, call->callType, call->callToken); params->txframes = framesPerPkt; } OOTRACEDBGC4("Returning copy of matched transmit capability %s." "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } return NULL; } /* used for g726, AMRNB */ ooH323EpCapability* ooIsAudioDataTypeNonStandardSupported (OOH323CallData *call, H245AudioCapability* audioCap, int dir) { int cap; ooH323EpCapability *cur=NULL, *epCap=NULL; OOCapParams * params= NULL; if (audioCap->t == T_H245AudioCapability_nonStandard && audioCap->u.nonStandard && audioCap->u.nonStandard->nonStandardIdentifier.t == T_H245NonStandardIdentifier_h221NonStandard) { switch (audioCap->u.nonStandard->data.numocts) { case sizeof("G.726-32k")-1: if (!strncmp((char *)audioCap->u.nonStandard->data.data, "G.726-32k", audioCap->u.nonStandard->data.numocts)) cap = OO_G726; else return NULL; break; case sizeof("G726r32")-1: if (!strncmp((char *)audioCap->u.nonStandard->data.data, "G726r32", audioCap->u.nonStandard->data.numocts)) cap = OO_G726AAL2; else return NULL; break; case sizeof("AMRNB")-1: /* sizeof("Speex") */ if (!strncmp((char *)audioCap->u.nonStandard->data.data, "AMRNB", audioCap->u.nonStandard->data.numocts)) cap = OO_AMRNB; else if (!strncmp((char *)audioCap->u.nonStandard->data.data, "Speex", audioCap->u.nonStandard->data.numocts)) cap = OO_SPEEX; else return NULL; break; default: return NULL; } } else return NULL; OOTRACEDBGC4("Determined Simple audio data type to be of type %s. Searching" " for matching capability.(%s, %s)\n", ooGetCapTypeText(cap), call->callType, call->callToken); /* If we have call specific caps, we use them; otherwise use general endpoint caps */ if(call->ourCaps) cur = call->ourCaps; else cur = gH323ep.myCaps; while(cur) { OOTRACEDBGC4("Local cap being compared %s. (%s, %s)\n", ooGetCapTypeText(cur->cap),call->callType, call->callToken); if(cur->cap == cap && (cur->dir & dir)) break; cur = cur->next; } if(!cur) return NULL; OOTRACEDBGC4("Found matching simple audio capability type %s. Comparing" " other parameters. (%s, %s)\n", ooGetCapTypeText(cap), call->callType, call->callToken); /* can we receive this capability */ if(dir & OORX) { OOTRACEDBGC4("We can receive Simple capability %s. (%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params=(OOCapParams*)memAlloc(call->pctxt,sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsAudioDataTypeSimpleSupported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOCapParams)); OOTRACEDBGC4("Returning copy of matched receive capability %s. " "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } /* Can we transmit compatible stream */ if(dir & OOTX) { OOTRACEDBGC4("We can transmit Simple capability %s. (%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params =(OOCapParams*)memAlloc(call->pctxt,sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsAudioDataTypeSimpleSupported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOCapParams)); OOTRACEDBGC4("Returning copy of matched transmit capability %s." "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } return NULL; } ooH323EpCapability* ooIsAudioDataTypeSupported (OOH323CallData *call, H245AudioCapability* audioCap, int dir) { /* Find similar capability */ switch(audioCap->t) { case T_H245AudioCapability_g711Alaw64k: case T_H245AudioCapability_g711Alaw56k: case T_H245AudioCapability_g711Ulaw56k: case T_H245AudioCapability_g711Ulaw64k: /*case T_H245AudioCapability_g726:*/ case T_H245AudioCapability_g728: case T_H245AudioCapability_g729: case T_H245AudioCapability_g729AnnexA: case T_H245AudioCapability_g729wAnnexB: case T_H245AudioCapability_g7231: return ooIsAudioDataTypeSimpleSupported(call, audioCap, dir); case T_H245AudioCapability_nonStandard: return ooIsAudioDataTypeNonStandardSupported(call, audioCap, dir); case T_H245AudioCapability_gsmFullRate: case T_H245AudioCapability_gsmHalfRate: case T_H245AudioCapability_gsmEnhancedFullRate: return ooIsAudioDataTypeGSMSupported(call, audioCap, dir); default: return NULL; } } ooH323EpCapability* ooIsT38Supported (OOH323CallData *call, H245DataApplicationCapability* t38Cap, int dir) { int cap = 0; ooH323EpCapability *cur=NULL, *epCap=NULL; OOCapParams *params= NULL; /* Find similar capability */ switch(t38Cap->application.t) { case T_H245DataApplicationCapability_application_t38fax: cap = OO_T38; break; default: return NULL; } if(call->ourCaps) cur = call->ourCaps; else cur = gH323ep.myCaps; while(cur) { OOTRACEDBGC4("Local cap being compared %s. (%s, %s)\n", ooGetCapTypeText(cur->cap),call->callType, call->callToken); if(cur->cap == cap && (cur->dir & dir)) break; cur = cur->next; } if(!cur) return NULL; OOTRACEDBGC4("Found matching t38 capability type %s. Comparing" " other parameters. (%s, %s)\n", ooGetCapTypeText(cap), call->callType, call->callToken); /* can we receive this capability */ if(dir & OORX) { OOTRACEDBGC4("We can receive Simple capability %s. (%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); epCap = (ooH323EpCapability*)memAllocZ(call->pctxt, sizeof(ooH323EpCapability)); params=(OOCapParams*)memAlloc(call->pctxt,sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsT38Supported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOCapParams)); OOTRACEDBGC4("Returning copy of matched receive capability %s. " "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } /* Can we transmit compatible stream */ if(dir & OOTX) { OOTRACEDBGC4("We can transmit Simple capability %s. (%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params =(OOCapParams*)memAllocZ(call->pctxt,sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsAudioDataTypeSimpleSupported - " "epCap/params (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOCapParams)); OOTRACEDBGC4("Returning copy of matched transmit capability %s." "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } return NULL; } ooH323EpCapability* ooIsVideoDataTypeH263Supported (OOH323CallData *call, H245H263VideoCapability* pH263Cap, int dir, OOPictureFormat picFormat) { int cap; ooH323EpCapability *cur=NULL, *epCap=NULL; OOH263CapParams *params= NULL; char *pictureType=NULL; unsigned mpi=0; cap = OO_H263VIDEO; if(picFormat == OO_PICFORMAT_SQCIF && pH263Cap->m.sqcifMPIPresent) { pictureType = "SQCIF"; mpi = pH263Cap->sqcifMPI; } if(picFormat == OO_PICFORMAT_QCIF && pH263Cap->m.qcifMPIPresent) { pictureType = "QCIF"; mpi = pH263Cap->qcifMPI; } if(picFormat == OO_PICFORMAT_CIF && pH263Cap->m.cifMPIPresent) { pictureType = "CIF"; mpi = pH263Cap->cifMPI; } if(picFormat == OO_PICFORMAT_CIF4 && pH263Cap->m.cif4MPIPresent) { pictureType = "CIF4"; mpi = pH263Cap->cif4MPI; } if(picFormat == OO_PICFORMAT_CIF16 && pH263Cap->m.cif16MPIPresent) { pictureType = "CIF16"; mpi = pH263Cap->cif16MPI; } OOTRACEDBGA4("Looking for H263 video capability(%s). (%s, %s)\n", pictureType, call->callType, call->callToken); /* If we have call specific caps, we use them; otherwise use general endpoint caps */ if(call->ourCaps) cur = call->ourCaps; else cur = gH323ep.myCaps; while(cur) { OOTRACEDBGC4("Local cap being compared %s. (%s, %s)\n", ooGetCapTypeText(cur->cap),call->callType, call->callToken); if(cur->cap == cap && (cur->dir & dir)) { if(((OOH263CapParams*)cur->params)->picFormat == picFormat) break; } cur = cur->next; } if(!cur) return NULL; OOTRACEDBGC4("Found matching H.263 video capability type %s. Comparing" " other parameters. (%s, %s)\n", ooGetCapTypeText(cap), call->callType, call->callToken); if(dir & OORX) { if(mpi < ((OOH263CapParams*)cur->params)->MPI) return NULL; else{ epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params = (OOH263CapParams*) memAlloc(call->pctxt, sizeof(OOH263CapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsVideoDataTypeH263Supported - " "epCap/params. (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOH263CapParams)); OOTRACEDBGC4("Returning copy of matched receive capability %s. " "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } } if(dir & OOTX) { epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params = (OOH263CapParams*) memAlloc(call->pctxt, sizeof(OOH263CapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsVideoDataTypeH263Supported - " "epCap/params. (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOH263CapParams)); if(params->MPI < mpi) { OOTRACEINFO5("Increasing minimum picture interval for transmission of" " H263 video capability from %d to %d to match receive " "capability of remote endpoint.(%s, %s)\n", params->MPI, mpi, call->callType, call->callToken); params->MPI = mpi; } OOTRACEDBGC4("Returning copy of matched receive capability %s. " "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } return NULL; } ooH323EpCapability* ooIsVideoDataTypeSupported (OOH323CallData *call, H245VideoCapability* pVideoCap, int dir) { switch(pVideoCap->t) { case T_H245VideoCapability_h263VideoCapability: if(pVideoCap->u.h263VideoCapability->m.sqcifMPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_SQCIF); else if(pVideoCap->u.h263VideoCapability->m.qcifMPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_QCIF); else if(pVideoCap->u.h263VideoCapability->m.cifMPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_CIF); else if(pVideoCap->u.h263VideoCapability->m.cif4MPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_CIF4); else if(pVideoCap->u.h263VideoCapability->m.cif16MPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_CIF16); break; case T_H245VideoCapability_nonStandard: case T_H245VideoCapability_h261VideoCapability: case T_H245VideoCapability_h262VideoCapability: case T_H245VideoCapability_is11172VideoCapability: case T_H245VideoCapability_genericVideoCapability: case T_H245VideoCapability_extElem1: default: OOTRACEDBGA1("Unsupported video capability type in " "ooIsVideoDataTypeSupported\n"); return NULL; } return NULL; } ooH323EpCapability* ooIsDataTypeSupported (OOH323CallData *call, H245DataType *data, int dir) { OOTRACEDBGC3("Looking for data type support. (%s, %s)\n", call->callType, call->callToken); switch(data->t) { case T_H245DataType_nonStandard: OOTRACEDBGC3("NonStandard data type not supported.(%s, %s)\n", call->callType, call->callToken); return NULL; case T_H245DataType_nullData: OOTRACEDBGC3("Null data type not supported.(%s, %s)\n", call->callType, call->callToken); return NULL; case T_H245DataType_videoData: OOTRACEDBGC3("Looking for video dataType support. (%s, %s)\n", call->callType, call->callToken); return ooIsVideoDataTypeSupported(call, data->u.videoData, dir); case T_H245DataType_audioData: OOTRACEDBGC3("Looking for audio dataType support. (%s, %s)\n", call->callType, call->callToken); return ooIsAudioDataTypeSupported(call, data->u.audioData, dir); case T_H245DataType_data: OOTRACEDBGC3("Looking for application data dataType support.(%s, %s)\n", call->callType, call->callToken); return ooIsT38Supported(call, data->u.data, dir); case T_H245DataType_encryptionData: OOTRACEDBGC3("Encryption data type not supported.(%s, %s)\n", call->callType, call->callToken); return NULL; case T_H245DataType_h235Control: return NULL; case T_H245DataType_h235Media: return NULL; case T_H245DataType_multiplexedStream: return NULL; default: OOTRACEINFO3("Unknown data type (%s, %s)\n", call->callType, call->callToken); } return NULL; } int ooResetCapPrefs(OOH323CallData *call) { OOCapPrefs *capPrefs=NULL; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; memset(capPrefs, 0, sizeof(OOCapPrefs)); return OO_OK; } int ooRemoveCapFromCapPrefs(OOH323CallData *call, int cap) { int i=0, j=0; OOCapPrefs *capPrefs=NULL, oldPrefs; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; memcpy(&oldPrefs, capPrefs, sizeof(OOCapPrefs)); memset(capPrefs, 0, sizeof(OOCapPrefs)); for(i=0; iorder[j++] = oldPrefs.order[i]; } capPrefs->index = j; return OO_OK; } int ooAppendCapToCapPrefs(OOH323CallData *call, int cap) { OOCapPrefs *capPrefs=NULL; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; capPrefs->order[capPrefs->index++] = cap; return OO_OK; } int ooChangeCapPrefOrder(OOH323CallData *call, int cap, int pos) { int i=0, j=0; OOCapPrefs *capPrefs = NULL; /* Whether to change prefs for call or for endpoint as a whole */ if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; /* check whether cap exists, cap must exist */ for(i=0; iindex; i++) { if(capPrefs->order[i] == cap) break; } if(i == capPrefs->index) return OO_FAILED; if(i==pos) return OO_OK; /* No need to change */ /* Decrease Pref order */ if(i < pos) { for( ; iorder[i] = capPrefs->order[i+1]; capPrefs->order[i]=cap; return OO_OK; } /* Increase Pref order */ if(i>pos) { for(j=i; j>pos; j--) capPrefs->order[j] = capPrefs->order[j-1]; capPrefs->order[j] = cap; return OO_OK; } return OO_FAILED; } int ooPreppendCapToCapPrefs(OOH323CallData *call, int cap) { int i=0, j=0; OOCapPrefs *capPrefs=NULL, oldPrefs; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; memcpy(&oldPrefs, capPrefs, sizeof(OOCapPrefs)); capPrefs->order[j++] = cap; for(i=0; iorder[j++] = oldPrefs.order[i]; } capPrefs->index = j; return OO_OK; } int ooAddRemoteCapability(OOH323CallData *call, H245Capability *cap) { switch(cap->t) { case T_H245Capability_receiveAudioCapability: return ooAddRemoteAudioCapability(call, cap->u.receiveAudioCapability, OORX); case T_H245Capability_transmitAudioCapability: return ooAddRemoteAudioCapability(call, cap->u.transmitAudioCapability, OOTX); case T_H245Capability_receiveAndTransmitAudioCapability: return ooAddRemoteAudioCapability(call, cap->u.receiveAndTransmitAudioCapability, OORXTX); case T_H245Capability_receiveDataApplicationCapability: return ooAddRemoteDataApplicationCapability(call, cap->u.receiveDataApplicationCapability, OORX); case T_H245Capability_transmitDataApplicationCapability: return ooAddRemoteDataApplicationCapability(call, cap->u.transmitDataApplicationCapability, OOTX); case T_H245Capability_receiveAndTransmitDataApplicationCapability: return ooAddRemoteDataApplicationCapability(call, cap->u.receiveAndTransmitDataApplicationCapability, OORXTX); default: OOTRACEDBGA3("Unsupported cap type encountered. Ignoring. (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooAddRemoteDataApplicationCapability(OOH323CallData *call, H245DataApplicationCapability *dataCap, int dir) { switch(dataCap->application.t) { case T_H245DataApplicationCapability_application_t38fax: if (dataCap->application.u.t38fax->t38FaxProfile.m.t38FaxUdpOptionsPresent) { call->T38FarMaxDatagram = dataCap->application.u.t38fax->t38FaxProfile.t38FaxUdpOptions.t38FaxMaxDatagram; } if (dataCap->application.u.t38fax->t38FaxProfile.m.versionPresent) { call->T38Version = dataCap->application.u.t38fax->t38FaxProfile.version; } return ooCapabilityAddT38Capability(call, OO_T38, dir, NULL, NULL, NULL, NULL,TRUE); default: OOTRACEDBGA1("Unsupported data capability type\n"); } return OO_OK; } int ooAddRemoteAudioCapability(OOH323CallData *call, H245AudioCapability *audioCap, int dir) { int rxframes=0, txframes=0; switch(audioCap->t) { case T_H245AudioCapability_g711Alaw64k: if(dir&OOTX) txframes = audioCap->u.g711Alaw64k; else if(dir&OORX) rxframes = audioCap->u.g711Alaw64k; else{ txframes = audioCap->u.g711Alaw64k; rxframes = audioCap->u.g711Alaw64k; } return ooCapabilityAddSimpleCapability(call, OO_G711ALAW64K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL,TRUE); case T_H245AudioCapability_g711Alaw56k: if(dir&OOTX) txframes = audioCap->u.g711Alaw56k; else if(dir&OORX) rxframes = audioCap->u.g711Alaw56k; else{ txframes = audioCap->u.g711Alaw56k; rxframes = audioCap->u.g711Alaw56k; } return ooCapabilityAddSimpleCapability(call, OO_G711ALAW56K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g711Ulaw64k: if(dir&OOTX) txframes = audioCap->u.g711Ulaw64k; else if(dir&OORX) rxframes = audioCap->u.g711Ulaw64k; else{ txframes = audioCap->u.g711Ulaw64k; rxframes = audioCap->u.g711Ulaw64k; } return ooCapabilityAddSimpleCapability(call, OO_G711ULAW64K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g711Ulaw56k: if(dir&OOTX) txframes = audioCap->u.g711Ulaw56k; else if(dir&OORX) rxframes = audioCap->u.g711Ulaw56k; else{ txframes = audioCap->u.g711Ulaw56k; rxframes = audioCap->u.g711Ulaw56k; } return ooCapabilityAddSimpleCapability(call, OO_G711ULAW56K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); /* case T_H245AudioCapability_g726: if(dir&OOTX) txframes = audioCap->u.g726; else if(dir&OORX) rxframes = audioCap->u.g726; else{ txframes = audioCap->u.g726; rxframes = audioCap->u.g726; } return ooCapabilityAddSimpleCapability(call, OO_G726, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); */ case T_H245AudioCapability_nonStandard: if (audioCap->u.nonStandard && audioCap->u.nonStandard->nonStandardIdentifier.t == T_H245NonStandardIdentifier_h221NonStandard && audioCap->u.nonStandard->data.numocts == sizeof("G.726-32k")-1 && !strncmp((char *)audioCap->u.nonStandard->data.data, "G.726-32k", audioCap->u.nonStandard->data.numocts)) return ooCapabilityAddSimpleCapability(call, OO_G726, 20, 240, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); if (audioCap->u.nonStandard && audioCap->u.nonStandard->nonStandardIdentifier.t == T_H245NonStandardIdentifier_h221NonStandard && audioCap->u.nonStandard->data.numocts == sizeof("G726r32")-1 && !strncmp((char *)audioCap->u.nonStandard->data.data, "G726r32", audioCap->u.nonStandard->data.numocts)) return ooCapabilityAddSimpleCapability(call, OO_G726AAL2, 20, 240, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); if (audioCap->u.nonStandard && audioCap->u.nonStandard->nonStandardIdentifier.t == T_H245NonStandardIdentifier_h221NonStandard && audioCap->u.nonStandard->data.numocts == sizeof("AMRNB")-1 && !strncmp((char *)audioCap->u.nonStandard->data.data, "AMRNB", audioCap->u.nonStandard->data.numocts)) return ooCapabilityAddSimpleCapability(call, OO_AMRNB, 4, 4, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); if (audioCap->u.nonStandard && audioCap->u.nonStandard->nonStandardIdentifier.t == T_H245NonStandardIdentifier_h221NonStandard && audioCap->u.nonStandard->data.numocts == sizeof("Speex")-1 && !strncmp((char *)audioCap->u.nonStandard->data.data, "Speex", audioCap->u.nonStandard->data.numocts)) return ooCapabilityAddSimpleCapability(call, OO_SPEEX, 4, 4, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); break; case T_H245AudioCapability_g728: if(dir&OOTX) txframes = audioCap->u.g728; else if(dir&OORX) rxframes = audioCap->u.g728; else{ txframes = audioCap->u.g728; rxframes = audioCap->u.g728; } return ooCapabilityAddSimpleCapability(call, OO_G728, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g729: if(dir&OOTX) txframes = audioCap->u.g729; else if(dir&OORX) rxframes = audioCap->u.g729; else{ txframes = audioCap->u.g729; rxframes = audioCap->u.g729; } return ooCapabilityAddSimpleCapability(call, OO_G729, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g729AnnexA: if(dir&OOTX) txframes = audioCap->u.g729AnnexA; else if(dir&OORX) rxframes = audioCap->u.g729AnnexA; else{ txframes = audioCap->u.g729AnnexA; rxframes = audioCap->u.g729AnnexA; } return ooCapabilityAddSimpleCapability(call, OO_G729A, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g729wAnnexB: if(dir&OOTX) txframes = audioCap->u.g729wAnnexB; else if(dir&OORX) rxframes = audioCap->u.g729wAnnexB; else{ txframes = audioCap->u.g729wAnnexB; rxframes = audioCap->u.g729wAnnexB; } return ooCapabilityAddSimpleCapability(call, OO_G729B, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g7231: if(dir&OOTX) txframes = audioCap->u.g7231->maxAl_sduAudioFrames; else if(dir&OORX) rxframes = audioCap->u.g7231->maxAl_sduAudioFrames; else{ txframes = audioCap->u.g7231->maxAl_sduAudioFrames; rxframes = audioCap->u.g7231->maxAl_sduAudioFrames; } return ooCapabilityAddSimpleCapability(call, OO_G7231, txframes,rxframes, audioCap->u.g7231->silenceSuppression, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_gsmFullRate: return ooCapabilityAddGSMCapability(call, OO_GSMFULLRATE, (unsigned)(audioCap->u.gsmFullRate->audioUnitSize/OO_GSMFRAMESIZE), audioCap->u.gsmFullRate->comfortNoise, audioCap->u.gsmFullRate->scrambled, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_gsmHalfRate: return ooCapabilityAddGSMCapability(call, OO_GSMHALFRATE, (unsigned)(audioCap->u.gsmHalfRate->audioUnitSize/OO_GSMFRAMESIZE), audioCap->u.gsmHalfRate->comfortNoise, audioCap->u.gsmHalfRate->scrambled, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_gsmEnhancedFullRate: return ooCapabilityAddGSMCapability(call, OO_GSMENHANCEDFULLRATE, (unsigned)(audioCap->u.gsmEnhancedFullRate->audioUnitSize/OO_GSMFRAMESIZE), audioCap->u.gsmEnhancedFullRate->comfortNoise, audioCap->u.gsmEnhancedFullRate->scrambled, dir, NULL, NULL, NULL, NULL, TRUE); default: OOTRACEDBGA1("Unsupported audio capability type\n"); } return OO_OK; } int ooCapabilityUpdateJointCapabilities (OOH323CallData* call, H245Capability *cap) { ooH323EpCapability * epCap = NULL, *cur = NULL; OOTRACEDBGC3("checking whether we need to add cap to joint capabilities" "(%s, %s)\n", call->callType, call->callToken); switch(cap->t) { case T_H245Capability_receiveAudioCapability: epCap= ooIsAudioDataTypeSupported(call, cap->u.receiveAudioCapability, OOTX); break; case T_H245Capability_transmitAudioCapability: epCap = ooIsAudioDataTypeSupported(call, cap->u.transmitAudioCapability, OORX); break; case T_H245Capability_receiveAndTransmitAudioCapability: epCap = ooIsAudioDataTypeSupported(call, cap->u.receiveAudioCapability, OOTX); if (!epCap) epCap = ooIsAudioDataTypeSupported(call, cap->u.transmitAudioCapability, OORX); break; case T_H245Capability_receiveVideoCapability: return ooCapabilityUpdateJointCapabilitiesVideo(call, cap->u.receiveVideoCapability, OOTX); case T_H245Capability_transmitVideoCapability: return ooCapabilityUpdateJointCapabilitiesVideo(call, cap->u.transmitVideoCapability, OORX); case T_H245Capability_receiveDataApplicationCapability: epCap= ooIsT38Supported(call, cap->u.receiveDataApplicationCapability, OOTX); break; case T_H245Capability_transmitDataApplicationCapability: epCap = ooIsT38Supported(call, cap->u.transmitDataApplicationCapability, OORX); break; case T_H245Capability_receiveAndTransmitDataApplicationCapability: epCap = ooIsT38Supported(call, cap->u.receiveAndTransmitDataApplicationCapability, OOTX); if (!epCap) epCap = ooIsT38Supported(call, cap->u.receiveAndTransmitDataApplicationCapability, OORX); break; case T_H245Capability_receiveUserInputCapability: if((cap->u.receiveUserInputCapability->t == T_H245UserInputCapability_basicString) && (call->dtmfmode & OO_CAP_DTMF_H245_alphanumeric)) { call->jointDtmfMode |= OO_CAP_DTMF_H245_alphanumeric; return OO_OK; } else if((cap->u.receiveUserInputCapability->t == T_H245UserInputCapability_dtmf) && (call->dtmfmode & OO_CAP_DTMF_H245_signal)) { call->jointDtmfMode |= OO_CAP_DTMF_H245_signal; return OO_OK; } //break; default: OOTRACEDBGA3("Unsupported cap type encountered. Ignoring. (%s, %s)\n", call->callType, call->callToken); } if(epCap) { OOTRACEDBGC3("Adding cap to joint capabilities(%s, %s)\n",call->callType, call->callToken); /* Note:we add jointCaps in remote endpoints preference order.*/ if(!call->jointCaps) call->jointCaps = epCap; else { cur = call->jointCaps; while(cur->next) cur = cur->next; cur->next = epCap; } return OO_OK; } OOTRACEDBGC3("Not adding to joint capabilities. (%s, %s)\n", call->callType, call->callToken); return OO_OK; } int ooCapabilityUpdateJointCapabilitiesVideo (OOH323CallData *call, H245VideoCapability *videoCap, int dir) { switch(videoCap->t) { case T_H245VideoCapability_h263VideoCapability: return ooCapabilityUpdateJointCapabilitiesVideoH263(call, videoCap->u.h263VideoCapability, dir); default: OOTRACEDBGC3("ooCapabilityUpdateJointCapabilitiesVideo - Unsupported" "capability type. (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooCapabilityUpdateJointCapabilitiesVideoH263 (OOH323CallData *call, H245H263VideoCapability *pH263Cap, int dir) { ooH323EpCapability *epCap = NULL, *cur = NULL; if(pH263Cap->m.sqcifMPIPresent) { epCap = ooIsVideoDataTypeH263Supported(call, pH263Cap, dir, OO_PICFORMAT_SQCIF); if(epCap) { OOTRACEDBGC3("Adding H263-SQCIF to joint capabilities(%s, %s)\n", call->callType, call->callToken); /* Note:we add jointCaps in remote endpoints preference order.*/ if(!call->jointCaps) call->jointCaps = epCap; else { cur = call->jointCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } } epCap = NULL; if(pH263Cap->m.qcifMPIPresent) { epCap = ooIsVideoDataTypeH263Supported(call, pH263Cap, dir, OO_PICFORMAT_QCIF); if(epCap) { OOTRACEDBGC3("Adding H263-QCIF to joint capabilities(%s, %s)\n", call->callType, call->callToken); /* Note:we add jointCaps in remote endpoints preference order.*/ if(!call->jointCaps) call->jointCaps = epCap; else { cur = call->jointCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } } epCap = NULL; if(pH263Cap->m.cifMPIPresent) { epCap = ooIsVideoDataTypeH263Supported(call, pH263Cap, dir, OO_PICFORMAT_CIF); if(epCap) { OOTRACEDBGC3("Adding H263-CIF to joint capabilities(%s, %s)\n", call->callType, call->callToken); /* Note:we add jointCaps in remote endpoints preference order.*/ if(!call->jointCaps) call->jointCaps = epCap; else { cur = call->jointCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } } epCap = NULL; if(pH263Cap->m.cif4MPIPresent) { epCap = ooIsVideoDataTypeH263Supported(call, pH263Cap, dir, OO_PICFORMAT_CIF4); if(epCap) { OOTRACEDBGC3("Adding H263-CIF4 to joint capabilities(%s, %s)\n", call->callType, call->callToken); /* Note:we add jointCaps in remote endpoints preference order.*/ if(!call->jointCaps) call->jointCaps = epCap; else { cur = call->jointCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } } epCap = NULL; if(pH263Cap->m.cif16MPIPresent) { epCap = ooIsVideoDataTypeH263Supported(call, pH263Cap, dir, OO_PICFORMAT_CIF16); if(epCap) { OOTRACEDBGC3("Adding H263-CIF16 to joint capabilities(%s, %s)\n", call->callType, call->callToken); /* Note:we add jointCaps in remote endpoints preference order.*/ if(!call->jointCaps) call->jointCaps = epCap; else { cur = call->jointCaps; while(cur->next) cur = cur->next; cur->next = epCap; } } } return OO_OK; } const char* ooGetCapTypeText (OOCapabilities cap) { static const char *capTypes[]={ "unknown", "OO_G726", "OO_G711ALAW64K", "OO_G711ALAW56K", "OO_G711ULAW64K", "OO_G711ULAW56K", "OO_G72264K", "OO_G72256K", "OO_G72248K", "OO_G7231", "OO_G728", "OO_G729", "OO_G729ANNEXA", "OO_AMRNB", "OO_G726AAL2", "OO_G729WANNEXB", "OO_G729ANNEXAWANNEXB", "OO_G7231ANNEXC", "OO_GSMFULLRATE", "OO_GSMHALFRATE", "OO_GSMENHANCEDFULLRATE", "OO_GENERICAUDIO", "OO_G729EXTENSIONS", "OO_SPEEX", "OO_AUDIOTELEPHONYEVENT", "OO_AUDIOTONE", "OO_EXTELEM1", "OO_VIDEO_BASE", "OO_NONSTDVIDEO", "OO_H261VIDEO", "OO_H262VIDEO", "OO_H263VIDEO", "OO_IS11172VIDEO", /* mpeg */ "OO_GENERICVIDEO", "OO_EXTELEMVIDEO", "OO_T38" /* T.38 */ }; return ooUtilsGetText (cap, capTypes, OONUMBEROF(capTypes)); } asterisk-11.7.0/addons/ooh323c/src/h323/0000755000175000007640000000000012254071122017237 5ustar sharkyjerrywebasterisk-11.7.0/addons/ooh323c/src/h323/MULTIMEDIA-SYSTEM-CONTROL.h0000644000175000007640000164227011222440006023211 0ustar sharkyjerryweb/* * 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 MULTIMEDIA_SYSTEM_CONTROL_H #define MULTIMEDIA_SYSTEM_CONTROL_H #ifdef __cplusplus extern "C" { #endif #include #include #include "ooasn1.h" /**************************************************************/ /* */ /* NonStandardIdentifier_h221NonStandard */ /* */ /**************************************************************/ typedef struct EXTERN H245NonStandardIdentifier_h221NonStandard { ASN1UINT8 t35CountryCode; ASN1UINT8 t35Extension; ASN1USINT manufacturerCode; } H245NonStandardIdentifier_h221NonStandard; EXTERN int asn1PE_H245NonStandardIdentifier_h221NonStandard (OOCTXT* pctxt, H245NonStandardIdentifier_h221NonStandard* pvalue); EXTERN int asn1PD_H245NonStandardIdentifier_h221NonStandard (OOCTXT* pctxt, H245NonStandardIdentifier_h221NonStandard* pvalue); /**************************************************************/ /* */ /* NonStandardIdentifier */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NonStandardIdentifier_object 1 #define T_H245NonStandardIdentifier_h221NonStandard 2 typedef struct EXTERN H245NonStandardIdentifier { int t; union { /* t = 1 */ ASN1OBJID *object; /* t = 2 */ H245NonStandardIdentifier_h221NonStandard *h221NonStandard; } u; } H245NonStandardIdentifier; EXTERN int asn1PE_H245NonStandardIdentifier (OOCTXT* pctxt, H245NonStandardIdentifier* pvalue); EXTERN int asn1PD_H245NonStandardIdentifier (OOCTXT* pctxt, H245NonStandardIdentifier* pvalue); /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ typedef struct EXTERN H245NonStandardParameter { H245NonStandardIdentifier nonStandardIdentifier; ASN1DynOctStr data; } H245NonStandardParameter; EXTERN int asn1PE_H245NonStandardParameter (OOCTXT* pctxt, H245NonStandardParameter* pvalue); EXTERN int asn1PD_H245NonStandardParameter (OOCTXT* pctxt, H245NonStandardParameter* pvalue); /**************************************************************/ /* */ /* V42bis */ /* */ /**************************************************************/ typedef struct EXTERN H245V42bis { ASN1UINT numberOfCodewords; ASN1USINT maximumStringLength; } H245V42bis; EXTERN int asn1PE_H245V42bis (OOCTXT* pctxt, H245V42bis* pvalue); EXTERN int asn1PD_H245V42bis (OOCTXT* pctxt, H245V42bis* pvalue); /**************************************************************/ /* */ /* CompressionType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CompressionType_v42bis 1 #define T_H245CompressionType_extElem1 2 typedef struct EXTERN H245CompressionType { int t; union { /* t = 1 */ H245V42bis *v42bis; /* t = 2 */ } u; } H245CompressionType; EXTERN int asn1PE_H245CompressionType (OOCTXT* pctxt, H245CompressionType* pvalue); EXTERN int asn1PD_H245CompressionType (OOCTXT* pctxt, H245CompressionType* pvalue); /**************************************************************/ /* */ /* DataProtocolCapability_v76wCompression */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245DataProtocolCapability_v76wCompression_transmitCompression 1 #define T_H245DataProtocolCapability_v76wCompression_receiveCompression 2 #define T_H245DataProtocolCapability_v76wCompression_transmitAndReceiveCompression 3 #define T_H245DataProtocolCapability_v76wCompression_extElem1 4 typedef struct EXTERN H245DataProtocolCapability_v76wCompression { int t; union { /* t = 1 */ H245CompressionType *transmitCompression; /* t = 2 */ H245CompressionType *receiveCompression; /* t = 3 */ H245CompressionType *transmitAndReceiveCompression; /* t = 4 */ } u; } H245DataProtocolCapability_v76wCompression; EXTERN int asn1PE_H245DataProtocolCapability_v76wCompression (OOCTXT* pctxt, H245DataProtocolCapability_v76wCompression* pvalue); EXTERN int asn1PD_H245DataProtocolCapability_v76wCompression (OOCTXT* pctxt, H245DataProtocolCapability_v76wCompression* pvalue); /**************************************************************/ /* */ /* DataProtocolCapability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245DataProtocolCapability_nonStandard 1 #define T_H245DataProtocolCapability_v14buffered 2 #define T_H245DataProtocolCapability_v42lapm 3 #define T_H245DataProtocolCapability_hdlcFrameTunnelling 4 #define T_H245DataProtocolCapability_h310SeparateVCStack 5 #define T_H245DataProtocolCapability_h310SingleVCStack 6 #define T_H245DataProtocolCapability_transparent 7 #define T_H245DataProtocolCapability_segmentationAndReassembly 8 #define T_H245DataProtocolCapability_hdlcFrameTunnelingwSAR 9 #define T_H245DataProtocolCapability_v120 10 #define T_H245DataProtocolCapability_separateLANStack 11 #define T_H245DataProtocolCapability_v76wCompression 12 #define T_H245DataProtocolCapability_tcp 13 #define T_H245DataProtocolCapability_udp 14 #define T_H245DataProtocolCapability_extElem1 15 typedef struct EXTERN H245DataProtocolCapability { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ /* t = 10 */ /* t = 11 */ /* t = 12 */ H245DataProtocolCapability_v76wCompression *v76wCompression; /* t = 13 */ /* t = 14 */ /* t = 15 */ } u; } H245DataProtocolCapability; EXTERN int asn1PE_H245DataProtocolCapability (OOCTXT* pctxt, H245DataProtocolCapability* pvalue); EXTERN int asn1PD_H245DataProtocolCapability (OOCTXT* pctxt, H245DataProtocolCapability* pvalue); /**************************************************************/ /* */ /* T38FaxRateManagement */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245T38FaxRateManagement_localTCF 1 #define T_H245T38FaxRateManagement_transferredTCF 2 #define T_H245T38FaxRateManagement_extElem1 3 typedef struct EXTERN H245T38FaxRateManagement { int t; } H245T38FaxRateManagement; EXTERN int asn1PE_H245T38FaxRateManagement (OOCTXT* pctxt, H245T38FaxRateManagement* pvalue); EXTERN int asn1PD_H245T38FaxRateManagement (OOCTXT* pctxt, H245T38FaxRateManagement* pvalue); /**************************************************************/ /* */ /* T38FaxUdpOptions_t38FaxUdpEC */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245T38FaxUdpOptions_t38FaxUdpEC_t38UDPFEC 1 #define T_H245T38FaxUdpOptions_t38FaxUdpEC_t38UDPRedundancy 2 #define T_H245T38FaxUdpOptions_t38FaxUdpEC_extElem1 3 typedef struct EXTERN H245T38FaxUdpOptions_t38FaxUdpEC { int t; } H245T38FaxUdpOptions_t38FaxUdpEC; EXTERN int asn1PE_H245T38FaxUdpOptions_t38FaxUdpEC (OOCTXT* pctxt, H245T38FaxUdpOptions_t38FaxUdpEC* pvalue); EXTERN int asn1PD_H245T38FaxUdpOptions_t38FaxUdpEC (OOCTXT* pctxt, H245T38FaxUdpOptions_t38FaxUdpEC* pvalue); /**************************************************************/ /* */ /* T38FaxUdpOptions */ /* */ /**************************************************************/ typedef struct EXTERN H245T38FaxUdpOptions { struct { unsigned t38FaxMaxBufferPresent : 1; unsigned t38FaxMaxDatagramPresent : 1; } m; ASN1INT t38FaxMaxBuffer; ASN1INT t38FaxMaxDatagram; H245T38FaxUdpOptions_t38FaxUdpEC t38FaxUdpEC; } H245T38FaxUdpOptions; EXTERN int asn1PE_H245T38FaxUdpOptions (OOCTXT* pctxt, H245T38FaxUdpOptions* pvalue); EXTERN int asn1PD_H245T38FaxUdpOptions (OOCTXT* pctxt, H245T38FaxUdpOptions* pvalue); /**************************************************************/ /* */ /* T38FaxTcpOptions */ /* */ /**************************************************************/ typedef struct EXTERN H245T38FaxTcpOptions { ASN1BOOL t38TCPBidirectionalMode; } H245T38FaxTcpOptions; EXTERN int asn1PE_H245T38FaxTcpOptions (OOCTXT* pctxt, H245T38FaxTcpOptions* pvalue); EXTERN int asn1PD_H245T38FaxTcpOptions (OOCTXT* pctxt, H245T38FaxTcpOptions* pvalue); /**************************************************************/ /* */ /* T38FaxProfile */ /* */ /**************************************************************/ typedef struct EXTERN H245T38FaxProfile { struct { unsigned versionPresent : 1; unsigned t38FaxRateManagementPresent : 1; unsigned t38FaxUdpOptionsPresent : 1; unsigned t38FaxTcpOptionsPresent : 1; } m; ASN1BOOL fillBitRemoval; ASN1BOOL transcodingJBIG; ASN1BOOL transcodingMMR; ASN1UINT8 version; H245T38FaxRateManagement t38FaxRateManagement; H245T38FaxUdpOptions t38FaxUdpOptions; H245T38FaxTcpOptions t38FaxTcpOptions; } H245T38FaxProfile; EXTERN int asn1PE_H245T38FaxProfile (OOCTXT* pctxt, H245T38FaxProfile* pvalue); EXTERN int asn1PD_H245T38FaxProfile (OOCTXT* pctxt, H245T38FaxProfile* pvalue); /**************************************************************/ /* */ /* NonStandardMessage */ /* */ /**************************************************************/ typedef struct EXTERN H245NonStandardMessage { H245NonStandardParameter nonStandardData; } H245NonStandardMessage; EXTERN int asn1PE_H245NonStandardMessage (OOCTXT* pctxt, H245NonStandardMessage* pvalue); EXTERN int asn1PD_H245NonStandardMessage (OOCTXT* pctxt, H245NonStandardMessage* pvalue); /**************************************************************/ /* */ /* MasterSlaveDetermination */ /* */ /**************************************************************/ typedef struct EXTERN H245MasterSlaveDetermination { ASN1UINT8 terminalType; ASN1UINT statusDeterminationNumber; } H245MasterSlaveDetermination; EXTERN int asn1PE_H245MasterSlaveDetermination (OOCTXT* pctxt, H245MasterSlaveDetermination* pvalue); EXTERN int asn1PD_H245MasterSlaveDetermination (OOCTXT* pctxt, H245MasterSlaveDetermination* pvalue); /**************************************************************/ /* */ /* SequenceNumber */ /* */ /**************************************************************/ typedef ASN1UINT8 H245SequenceNumber; EXTERN int asn1PE_H245SequenceNumber (OOCTXT* pctxt, H245SequenceNumber value); EXTERN int asn1PD_H245SequenceNumber (OOCTXT* pctxt, H245SequenceNumber* pvalue); /**************************************************************/ /* */ /* VCCapability_aal1 */ /* */ /**************************************************************/ typedef struct EXTERN H245VCCapability_aal1 { ASN1BOOL nullClockRecovery; ASN1BOOL srtsClockRecovery; ASN1BOOL adaptiveClockRecovery; ASN1BOOL nullErrorCorrection; ASN1BOOL longInterleaver; ASN1BOOL shortInterleaver; ASN1BOOL errorCorrectionOnly; ASN1BOOL structuredDataTransfer; ASN1BOOL partiallyFilledCells; } H245VCCapability_aal1; EXTERN int asn1PE_H245VCCapability_aal1 (OOCTXT* pctxt, H245VCCapability_aal1* pvalue); EXTERN int asn1PD_H245VCCapability_aal1 (OOCTXT* pctxt, H245VCCapability_aal1* pvalue); /**************************************************************/ /* */ /* VCCapability_aal5 */ /* */ /**************************************************************/ typedef struct EXTERN H245VCCapability_aal5 { ASN1USINT forwardMaximumSDUSize; ASN1USINT backwardMaximumSDUSize; } H245VCCapability_aal5; EXTERN int asn1PE_H245VCCapability_aal5 (OOCTXT* pctxt, H245VCCapability_aal5* pvalue); EXTERN int asn1PD_H245VCCapability_aal5 (OOCTXT* pctxt, H245VCCapability_aal5* pvalue); /**************************************************************/ /* */ /* VCCapability_availableBitRates_type_rangeOfBitRates */ /* */ /**************************************************************/ typedef struct EXTERN H245VCCapability_availableBitRates_type_rangeOfBitRates { ASN1USINT lowerBitRate; ASN1USINT higherBitRate; } H245VCCapability_availableBitRates_type_rangeOfBitRates; EXTERN int asn1PE_H245VCCapability_availableBitRates_type_rangeOfBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates_type_rangeOfBitRates* pvalue); EXTERN int asn1PD_H245VCCapability_availableBitRates_type_rangeOfBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates_type_rangeOfBitRates* pvalue); /**************************************************************/ /* */ /* VCCapability_availableBitRates_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245VCCapability_availableBitRates_type_singleBitRate 1 #define T_H245VCCapability_availableBitRates_type_rangeOfBitRates 2 typedef struct EXTERN H245VCCapability_availableBitRates_type { int t; union { /* t = 1 */ ASN1USINT singleBitRate; /* t = 2 */ H245VCCapability_availableBitRates_type_rangeOfBitRates *rangeOfBitRates; } u; } H245VCCapability_availableBitRates_type; EXTERN int asn1PE_H245VCCapability_availableBitRates_type (OOCTXT* pctxt, H245VCCapability_availableBitRates_type* pvalue); EXTERN int asn1PD_H245VCCapability_availableBitRates_type (OOCTXT* pctxt, H245VCCapability_availableBitRates_type* pvalue); /**************************************************************/ /* */ /* VCCapability_availableBitRates */ /* */ /**************************************************************/ typedef struct EXTERN H245VCCapability_availableBitRates { H245VCCapability_availableBitRates_type type; } H245VCCapability_availableBitRates; EXTERN int asn1PE_H245VCCapability_availableBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates* pvalue); EXTERN int asn1PD_H245VCCapability_availableBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates* pvalue); /**************************************************************/ /* */ /* Q2931Address_address_nsapAddress */ /* */ /**************************************************************/ typedef struct EXTERN H245Q2931Address_address_nsapAddress { ASN1UINT numocts; ASN1OCTET data[20]; } H245Q2931Address_address_nsapAddress; EXTERN int asn1PE_H245Q2931Address_address_nsapAddress (OOCTXT* pctxt, H245Q2931Address_address_nsapAddress* pvalue); EXTERN int asn1PD_H245Q2931Address_address_nsapAddress (OOCTXT* pctxt, H245Q2931Address_address_nsapAddress* pvalue); /**************************************************************/ /* */ /* Q2931Address_address */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245Q2931Address_address_internationalNumber 1 #define T_H245Q2931Address_address_nsapAddress 2 #define T_H245Q2931Address_address_extElem1 3 typedef struct EXTERN H245Q2931Address_address { int t; union { /* t = 1 */ ASN1NumericString internationalNumber; /* t = 2 */ H245Q2931Address_address_nsapAddress *nsapAddress; /* t = 3 */ } u; } H245Q2931Address_address; EXTERN int asn1PE_H245Q2931Address_address (OOCTXT* pctxt, H245Q2931Address_address* pvalue); EXTERN int asn1PD_H245Q2931Address_address (OOCTXT* pctxt, H245Q2931Address_address* pvalue); /**************************************************************/ /* */ /* Q2931Address_subaddress */ /* */ /**************************************************************/ typedef struct EXTERN H245Q2931Address_subaddress { ASN1UINT numocts; ASN1OCTET data[20]; } H245Q2931Address_subaddress; EXTERN int asn1PE_H245Q2931Address_subaddress (OOCTXT* pctxt, H245Q2931Address_subaddress* pvalue); EXTERN int asn1PD_H245Q2931Address_subaddress (OOCTXT* pctxt, H245Q2931Address_subaddress* pvalue); /**************************************************************/ /* */ /* Q2931Address */ /* */ /**************************************************************/ typedef struct EXTERN H245Q2931Address { struct { unsigned subaddressPresent : 1; } m; H245Q2931Address_address address; H245Q2931Address_subaddress subaddress; } H245Q2931Address; EXTERN int asn1PE_H245Q2931Address (OOCTXT* pctxt, H245Q2931Address* pvalue); EXTERN int asn1PD_H245Q2931Address (OOCTXT* pctxt, H245Q2931Address* pvalue); /**************************************************************/ /* */ /* VCCapability_aal1ViaGateway_gatewayAddress */ /* */ /**************************************************************/ /* List of H245Q2931Address */ typedef DList H245VCCapability_aal1ViaGateway_gatewayAddress; EXTERN int asn1PE_H245VCCapability_aal1ViaGateway_gatewayAddress (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway_gatewayAddress* pvalue); EXTERN int asn1PD_H245VCCapability_aal1ViaGateway_gatewayAddress (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway_gatewayAddress* pvalue); /**************************************************************/ /* */ /* VCCapability_aal1ViaGateway */ /* */ /**************************************************************/ typedef struct EXTERN H245VCCapability_aal1ViaGateway { H245VCCapability_aal1ViaGateway_gatewayAddress gatewayAddress; ASN1BOOL nullClockRecovery; ASN1BOOL srtsClockRecovery; ASN1BOOL adaptiveClockRecovery; ASN1BOOL nullErrorCorrection; ASN1BOOL longInterleaver; ASN1BOOL shortInterleaver; ASN1BOOL errorCorrectionOnly; ASN1BOOL structuredDataTransfer; ASN1BOOL partiallyFilledCells; } H245VCCapability_aal1ViaGateway; EXTERN int asn1PE_H245VCCapability_aal1ViaGateway (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway* pvalue); EXTERN int asn1PD_H245VCCapability_aal1ViaGateway (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway* pvalue); /**************************************************************/ /* */ /* VCCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245VCCapability { struct { unsigned aal1Present : 1; unsigned aal5Present : 1; unsigned aal1ViaGatewayPresent : 1; } m; H245VCCapability_aal1 aal1; H245VCCapability_aal5 aal5; ASN1BOOL transportStream; ASN1BOOL programStream; H245VCCapability_availableBitRates availableBitRates; H245VCCapability_aal1ViaGateway aal1ViaGateway; } H245VCCapability; EXTERN int asn1PE_H245VCCapability (OOCTXT* pctxt, H245VCCapability* pvalue); EXTERN int asn1PD_H245VCCapability (OOCTXT* pctxt, H245VCCapability* pvalue); /**************************************************************/ /* */ /* _SetOfH245VCCapability */ /* */ /**************************************************************/ /* List of H245VCCapability */ typedef DList H245_SetOfH245VCCapability; EXTERN int asn1PE_H245_SetOfH245VCCapability (OOCTXT* pctxt, H245_SetOfH245VCCapability* pvalue); EXTERN int asn1PD_H245_SetOfH245VCCapability (OOCTXT* pctxt, H245_SetOfH245VCCapability* pvalue); /**************************************************************/ /* */ /* H222Capability */ /* */ /**************************************************************/ typedef struct EXTERN H245H222Capability { ASN1USINT numberOfVCs; H245_SetOfH245VCCapability vcCapability; } H245H222Capability; EXTERN int asn1PE_H245H222Capability (OOCTXT* pctxt, H245H222Capability* pvalue); EXTERN int asn1PD_H245H222Capability (OOCTXT* pctxt, H245H222Capability* pvalue); /**************************************************************/ /* */ /* H223Capability_h223MultiplexTableCapability_enhanced */ /* */ /**************************************************************/ typedef struct EXTERN H245H223Capability_h223MultiplexTableCapability_enhanced { ASN1UINT8 maximumNestingDepth; ASN1UINT8 maximumElementListSize; ASN1UINT8 maximumSubElementListSize; } H245H223Capability_h223MultiplexTableCapability_enhanced; EXTERN int asn1PE_H245H223Capability_h223MultiplexTableCapability_enhanced (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability_enhanced* pvalue); EXTERN int asn1PD_H245H223Capability_h223MultiplexTableCapability_enhanced (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability_enhanced* pvalue); /**************************************************************/ /* */ /* H223Capability_h223MultiplexTableCapability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223Capability_h223MultiplexTableCapability_basic 1 #define T_H245H223Capability_h223MultiplexTableCapability_enhanced 2 typedef struct EXTERN H245H223Capability_h223MultiplexTableCapability { int t; union { /* t = 1 */ /* t = 2 */ H245H223Capability_h223MultiplexTableCapability_enhanced *enhanced; } u; } H245H223Capability_h223MultiplexTableCapability; EXTERN int asn1PE_H245H223Capability_h223MultiplexTableCapability (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability* pvalue); EXTERN int asn1PD_H245H223Capability_h223MultiplexTableCapability (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability* pvalue); /**************************************************************/ /* */ /* H223Capability_mobileOperationTransmitCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H223Capability_mobileOperationTransmitCapability { ASN1BOOL modeChangeCapability; ASN1BOOL h223AnnexA; ASN1BOOL h223AnnexADoubleFlag; ASN1BOOL h223AnnexB; ASN1BOOL h223AnnexBwithHeader; } H245H223Capability_mobileOperationTransmitCapability; EXTERN int asn1PE_H245H223Capability_mobileOperationTransmitCapability (OOCTXT* pctxt, H245H223Capability_mobileOperationTransmitCapability* pvalue); EXTERN int asn1PD_H245H223Capability_mobileOperationTransmitCapability (OOCTXT* pctxt, H245H223Capability_mobileOperationTransmitCapability* pvalue); /**************************************************************/ /* */ /* H223AnnexCCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H223AnnexCCapability { struct { unsigned rsCodeCapabilityPresent : 1; } m; ASN1BOOL videoWithAL1M; ASN1BOOL videoWithAL2M; ASN1BOOL videoWithAL3M; ASN1BOOL audioWithAL1M; ASN1BOOL audioWithAL2M; ASN1BOOL audioWithAL3M; ASN1BOOL dataWithAL1M; ASN1BOOL dataWithAL2M; ASN1BOOL dataWithAL3M; ASN1BOOL alpduInterleaving; ASN1USINT maximumAL1MPDUSize; ASN1USINT maximumAL2MSDUSize; ASN1USINT maximumAL3MSDUSize; ASN1BOOL rsCodeCapability; } H245H223AnnexCCapability; EXTERN int asn1PE_H245H223AnnexCCapability (OOCTXT* pctxt, H245H223AnnexCCapability* pvalue); EXTERN int asn1PD_H245H223AnnexCCapability (OOCTXT* pctxt, H245H223AnnexCCapability* pvalue); /**************************************************************/ /* */ /* H223Capability_mobileMultilinkFrameCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H223Capability_mobileMultilinkFrameCapability { ASN1UINT8 maximumSampleSize; ASN1USINT maximumPayloadLength; } H245H223Capability_mobileMultilinkFrameCapability; EXTERN int asn1PE_H245H223Capability_mobileMultilinkFrameCapability (OOCTXT* pctxt, H245H223Capability_mobileMultilinkFrameCapability* pvalue); EXTERN int asn1PD_H245H223Capability_mobileMultilinkFrameCapability (OOCTXT* pctxt, H245H223Capability_mobileMultilinkFrameCapability* pvalue); /**************************************************************/ /* */ /* H223Capability */ /* */ /**************************************************************/ typedef struct EXTERN H245H223Capability { struct { unsigned maxMUXPDUSizeCapabilityPresent : 1; unsigned nsrpSupportPresent : 1; unsigned mobileOperationTransmitCapabilityPresent : 1; unsigned h223AnnexCCapabilityPresent : 1; unsigned bitRatePresent : 1; unsigned mobileMultilinkFrameCapabilityPresent : 1; } m; ASN1BOOL transportWithI_frames; ASN1BOOL videoWithAL1; ASN1BOOL videoWithAL2; ASN1BOOL videoWithAL3; ASN1BOOL audioWithAL1; ASN1BOOL audioWithAL2; ASN1BOOL audioWithAL3; ASN1BOOL dataWithAL1; ASN1BOOL dataWithAL2; ASN1BOOL dataWithAL3; ASN1USINT maximumAl2SDUSize; ASN1USINT maximumAl3SDUSize; ASN1USINT maximumDelayJitter; H245H223Capability_h223MultiplexTableCapability h223MultiplexTableCapability; ASN1BOOL maxMUXPDUSizeCapability; ASN1BOOL nsrpSupport; H245H223Capability_mobileOperationTransmitCapability mobileOperationTransmitCapability; H245H223AnnexCCapability h223AnnexCCapability; ASN1USINT bitRate; H245H223Capability_mobileMultilinkFrameCapability mobileMultilinkFrameCapability; } H245H223Capability; EXTERN int asn1PE_H245H223Capability (OOCTXT* pctxt, H245H223Capability* pvalue); EXTERN int asn1PD_H245H223Capability (OOCTXT* pctxt, H245H223Capability* pvalue); /**************************************************************/ /* */ /* V75Capability */ /* */ /**************************************************************/ typedef struct EXTERN H245V75Capability { ASN1BOOL audioHeader; } H245V75Capability; EXTERN int asn1PE_H245V75Capability (OOCTXT* pctxt, H245V75Capability* pvalue); EXTERN int asn1PD_H245V75Capability (OOCTXT* pctxt, H245V75Capability* pvalue); /**************************************************************/ /* */ /* V76Capability */ /* */ /**************************************************************/ typedef struct EXTERN H245V76Capability { ASN1BOOL suspendResumeCapabilitywAddress; ASN1BOOL suspendResumeCapabilitywoAddress; ASN1BOOL rejCapability; ASN1BOOL sREJCapability; ASN1BOOL mREJCapability; ASN1BOOL crc8bitCapability; ASN1BOOL crc16bitCapability; ASN1BOOL crc32bitCapability; ASN1BOOL uihCapability; ASN1USINT numOfDLCS; ASN1BOOL twoOctetAddressFieldCapability; ASN1BOOL loopBackTestCapability; ASN1USINT n401Capability; ASN1UINT8 maxWindowSizeCapability; H245V75Capability v75Capability; } H245V76Capability; EXTERN int asn1PE_H245V76Capability (OOCTXT* pctxt, H245V76Capability* pvalue); EXTERN int asn1PD_H245V76Capability (OOCTXT* pctxt, H245V76Capability* pvalue); /**************************************************************/ /* */ /* T84Profile_t84Restricted */ /* */ /**************************************************************/ typedef struct EXTERN H245T84Profile_t84Restricted { ASN1BOOL qcif; ASN1BOOL cif; ASN1BOOL ccir601Seq; ASN1BOOL ccir601Prog; ASN1BOOL hdtvSeq; ASN1BOOL hdtvProg; ASN1BOOL g3FacsMH200x100; ASN1BOOL g3FacsMH200x200; ASN1BOOL g4FacsMMR200x100; ASN1BOOL g4FacsMMR200x200; ASN1BOOL jbig200x200Seq; ASN1BOOL jbig200x200Prog; ASN1BOOL jbig300x300Seq; ASN1BOOL jbig300x300Prog; ASN1BOOL digPhotoLow; ASN1BOOL digPhotoMedSeq; ASN1BOOL digPhotoMedProg; ASN1BOOL digPhotoHighSeq; ASN1BOOL digPhotoHighProg; } H245T84Profile_t84Restricted; EXTERN int asn1PE_H245T84Profile_t84Restricted (OOCTXT* pctxt, H245T84Profile_t84Restricted* pvalue); EXTERN int asn1PD_H245T84Profile_t84Restricted (OOCTXT* pctxt, H245T84Profile_t84Restricted* pvalue); /**************************************************************/ /* */ /* T84Profile */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245T84Profile_t84Unrestricted 1 #define T_H245T84Profile_t84Restricted 2 typedef struct EXTERN H245T84Profile { int t; union { /* t = 1 */ /* t = 2 */ H245T84Profile_t84Restricted *t84Restricted; } u; } H245T84Profile; EXTERN int asn1PE_H245T84Profile (OOCTXT* pctxt, H245T84Profile* pvalue); EXTERN int asn1PD_H245T84Profile (OOCTXT* pctxt, H245T84Profile* pvalue); /**************************************************************/ /* */ /* DataApplicationCapability_application_t84 */ /* */ /**************************************************************/ typedef struct EXTERN H245DataApplicationCapability_application_t84 { H245DataProtocolCapability t84Protocol; H245T84Profile t84Profile; } H245DataApplicationCapability_application_t84; EXTERN int asn1PE_H245DataApplicationCapability_application_t84 (OOCTXT* pctxt, H245DataApplicationCapability_application_t84* pvalue); EXTERN int asn1PD_H245DataApplicationCapability_application_t84 (OOCTXT* pctxt, H245DataApplicationCapability_application_t84* pvalue); /**************************************************************/ /* */ /* DataApplicationCapability_application_nlpid */ /* */ /**************************************************************/ typedef struct EXTERN H245DataApplicationCapability_application_nlpid { H245DataProtocolCapability nlpidProtocol; ASN1DynOctStr nlpidData; } H245DataApplicationCapability_application_nlpid; EXTERN int asn1PE_H245DataApplicationCapability_application_nlpid (OOCTXT* pctxt, H245DataApplicationCapability_application_nlpid* pvalue); EXTERN int asn1PD_H245DataApplicationCapability_application_nlpid (OOCTXT* pctxt, H245DataApplicationCapability_application_nlpid* pvalue); /**************************************************************/ /* */ /* DataApplicationCapability_application_t38fax */ /* */ /**************************************************************/ typedef struct EXTERN H245DataApplicationCapability_application_t38fax { H245DataProtocolCapability t38FaxProtocol; H245T38FaxProfile t38FaxProfile; } H245DataApplicationCapability_application_t38fax; EXTERN int asn1PE_H245DataApplicationCapability_application_t38fax (OOCTXT* pctxt, H245DataApplicationCapability_application_t38fax* pvalue); EXTERN int asn1PD_H245DataApplicationCapability_application_t38fax (OOCTXT* pctxt, H245DataApplicationCapability_application_t38fax* pvalue); /**************************************************************/ /* */ /* CapabilityIdentifier_uuid */ /* */ /**************************************************************/ typedef struct EXTERN H245CapabilityIdentifier_uuid { ASN1UINT numocts; ASN1OCTET data[16]; } H245CapabilityIdentifier_uuid; EXTERN int asn1PE_H245CapabilityIdentifier_uuid (OOCTXT* pctxt, H245CapabilityIdentifier_uuid* pvalue); EXTERN int asn1PD_H245CapabilityIdentifier_uuid (OOCTXT* pctxt, H245CapabilityIdentifier_uuid* pvalue); /**************************************************************/ /* */ /* CapabilityIdentifier */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CapabilityIdentifier_standard 1 #define T_H245CapabilityIdentifier_h221NonStandard 2 #define T_H245CapabilityIdentifier_uuid 3 #define T_H245CapabilityIdentifier_domainBased 4 #define T_H245CapabilityIdentifier_extElem1 5 typedef struct EXTERN H245CapabilityIdentifier { int t; union { /* t = 1 */ ASN1OBJID *standard; /* t = 2 */ H245NonStandardParameter *h221NonStandard; /* t = 3 */ H245CapabilityIdentifier_uuid *uuid; /* t = 4 */ ASN1IA5String domainBased; /* t = 5 */ } u; } H245CapabilityIdentifier; EXTERN int asn1PE_H245CapabilityIdentifier (OOCTXT* pctxt, H245CapabilityIdentifier* pvalue); EXTERN int asn1PD_H245CapabilityIdentifier (OOCTXT* pctxt, H245CapabilityIdentifier* pvalue); /**************************************************************/ /* */ /* ParameterIdentifier_uuid */ /* */ /**************************************************************/ typedef struct EXTERN H245ParameterIdentifier_uuid { ASN1UINT numocts; ASN1OCTET data[16]; } H245ParameterIdentifier_uuid; EXTERN int asn1PE_H245ParameterIdentifier_uuid (OOCTXT* pctxt, H245ParameterIdentifier_uuid* pvalue); EXTERN int asn1PD_H245ParameterIdentifier_uuid (OOCTXT* pctxt, H245ParameterIdentifier_uuid* pvalue); /**************************************************************/ /* */ /* ParameterIdentifier */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ParameterIdentifier_standard 1 #define T_H245ParameterIdentifier_h221NonStandard 2 #define T_H245ParameterIdentifier_uuid 3 #define T_H245ParameterIdentifier_domainBased 4 #define T_H245ParameterIdentifier_extElem1 5 typedef struct EXTERN H245ParameterIdentifier { int t; union { /* t = 1 */ ASN1UINT8 standard; /* t = 2 */ H245NonStandardParameter *h221NonStandard; /* t = 3 */ H245ParameterIdentifier_uuid *uuid; /* t = 4 */ ASN1IA5String domainBased; /* t = 5 */ } u; } H245ParameterIdentifier; EXTERN int asn1PE_H245ParameterIdentifier (OOCTXT* pctxt, H245ParameterIdentifier* pvalue); EXTERN int asn1PD_H245ParameterIdentifier (OOCTXT* pctxt, H245ParameterIdentifier* pvalue); /**************************************************************/ /* */ /* ParameterValue */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ParameterValue_logical 1 #define T_H245ParameterValue_booleanArray 2 #define T_H245ParameterValue_unsignedMin 3 #define T_H245ParameterValue_unsignedMax 4 #define T_H245ParameterValue_unsigned32Min 5 #define T_H245ParameterValue_unsigned32Max 6 #define T_H245ParameterValue_octetString 7 #define T_H245ParameterValue_genericParameter 8 #define T_H245ParameterValue_extElem1 9 typedef struct EXTERN H245ParameterValue { int t; union { /* t = 1 */ /* t = 2 */ ASN1UINT8 booleanArray; /* t = 3 */ ASN1USINT unsignedMin; /* t = 4 */ ASN1USINT unsignedMax; /* t = 5 */ ASN1UINT unsigned32Min; /* t = 6 */ ASN1UINT unsigned32Max; /* t = 7 */ ASN1DynOctStr *octetString; /* t = 8 */ DList *genericParameter; /* t = 9 */ } u; } H245ParameterValue; EXTERN int asn1PE_H245ParameterValue (OOCTXT* pctxt, H245ParameterValue* pvalue); EXTERN int asn1PD_H245ParameterValue (OOCTXT* pctxt, H245ParameterValue* pvalue); /**************************************************************/ /* */ /* _SeqOfH245ParameterIdentifier */ /* */ /**************************************************************/ /* List of H245ParameterIdentifier */ typedef DList H245_SeqOfH245ParameterIdentifier; EXTERN int asn1PE_H245_SeqOfH245ParameterIdentifier (OOCTXT* pctxt, H245_SeqOfH245ParameterIdentifier* pvalue); EXTERN int asn1PD_H245_SeqOfH245ParameterIdentifier (OOCTXT* pctxt, H245_SeqOfH245ParameterIdentifier* pvalue); /**************************************************************/ /* */ /* GenericParameter */ /* */ /**************************************************************/ typedef struct EXTERN H245GenericParameter { struct { unsigned supersedesPresent : 1; } m; H245ParameterIdentifier parameterIdentifier; H245ParameterValue parameterValue; H245_SeqOfH245ParameterIdentifier supersedes; } H245GenericParameter; EXTERN int asn1PE_H245GenericParameter (OOCTXT* pctxt, H245GenericParameter* pvalue); EXTERN int asn1PD_H245GenericParameter (OOCTXT* pctxt, H245GenericParameter* pvalue); /**************************************************************/ /* */ /* _SeqOfH245GenericParameter */ /* */ /**************************************************************/ /* List of H245GenericParameter */ typedef DList H245_SeqOfH245GenericParameter; EXTERN int asn1PE_H245_SeqOfH245GenericParameter (OOCTXT* pctxt, H245_SeqOfH245GenericParameter* pvalue); EXTERN int asn1PD_H245_SeqOfH245GenericParameter (OOCTXT* pctxt, H245_SeqOfH245GenericParameter* pvalue); /**************************************************************/ /* */ /* GenericCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245GenericCapability { struct { unsigned maxBitRatePresent : 1; unsigned collapsingPresent : 1; unsigned nonCollapsingPresent : 1; unsigned nonCollapsingRawPresent : 1; unsigned transportPresent : 1; } m; H245CapabilityIdentifier capabilityIdentifier; ASN1UINT maxBitRate; H245_SeqOfH245GenericParameter collapsing; H245_SeqOfH245GenericParameter nonCollapsing; ASN1DynOctStr nonCollapsingRaw; H245DataProtocolCapability transport; } H245GenericCapability; EXTERN int asn1PE_H245GenericCapability (OOCTXT* pctxt, H245GenericCapability* pvalue); EXTERN int asn1PD_H245GenericCapability (OOCTXT* pctxt, H245GenericCapability* pvalue); /**************************************************************/ /* */ /* DataApplicationCapability_application */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245DataApplicationCapability_application_nonStandard 1 #define T_H245DataApplicationCapability_application_t120 2 #define T_H245DataApplicationCapability_application_dsm_cc 3 #define T_H245DataApplicationCapability_application_userData 4 #define T_H245DataApplicationCapability_application_t84 5 #define T_H245DataApplicationCapability_application_t434 6 #define T_H245DataApplicationCapability_application_h224 7 #define T_H245DataApplicationCapability_application_nlpid 8 #define T_H245DataApplicationCapability_application_dsvdControl 9 #define T_H245DataApplicationCapability_application_h222DataPartitioning 10 #define T_H245DataApplicationCapability_application_t30fax 11 #define T_H245DataApplicationCapability_application_t140 12 #define T_H245DataApplicationCapability_application_t38fax 13 #define T_H245DataApplicationCapability_application_genericDataCapability 14 #define T_H245DataApplicationCapability_application_extElem1 15 typedef struct EXTERN H245DataApplicationCapability_application { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245DataProtocolCapability *t120; /* t = 3 */ H245DataProtocolCapability *dsm_cc; /* t = 4 */ H245DataProtocolCapability *userData; /* t = 5 */ H245DataApplicationCapability_application_t84 *t84; /* t = 6 */ H245DataProtocolCapability *t434; /* t = 7 */ H245DataProtocolCapability *h224; /* t = 8 */ H245DataApplicationCapability_application_nlpid *nlpid; /* t = 9 */ /* t = 10 */ H245DataProtocolCapability *h222DataPartitioning; /* t = 11 */ H245DataProtocolCapability *t30fax; /* t = 12 */ H245DataProtocolCapability *t140; /* t = 13 */ H245DataApplicationCapability_application_t38fax *t38fax; /* t = 14 */ H245GenericCapability *genericDataCapability; /* t = 15 */ } u; } H245DataApplicationCapability_application; EXTERN int asn1PE_H245DataApplicationCapability_application (OOCTXT* pctxt, H245DataApplicationCapability_application* pvalue); EXTERN int asn1PD_H245DataApplicationCapability_application (OOCTXT* pctxt, H245DataApplicationCapability_application* pvalue); /**************************************************************/ /* */ /* DataApplicationCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245DataApplicationCapability { H245DataApplicationCapability_application application; ASN1UINT maxBitRate; } H245DataApplicationCapability; EXTERN int asn1PE_H245DataApplicationCapability (OOCTXT* pctxt, H245DataApplicationCapability* pvalue); EXTERN int asn1PD_H245DataApplicationCapability (OOCTXT* pctxt, H245DataApplicationCapability* pvalue); /**************************************************************/ /* */ /* _SeqOfH245DataApplicationCapability */ /* */ /**************************************************************/ /* List of H245DataApplicationCapability */ typedef DList H245_SeqOfH245DataApplicationCapability; EXTERN int asn1PE_H245_SeqOfH245DataApplicationCapability (OOCTXT* pctxt, H245_SeqOfH245DataApplicationCapability* pvalue); EXTERN int asn1PD_H245_SeqOfH245DataApplicationCapability (OOCTXT* pctxt, H245_SeqOfH245DataApplicationCapability* pvalue); /**************************************************************/ /* */ /* MediaDistributionCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245MediaDistributionCapability { struct { unsigned centralizedDataPresent : 1; unsigned distributedDataPresent : 1; } m; ASN1BOOL centralizedControl; ASN1BOOL distributedControl; ASN1BOOL centralizedAudio; ASN1BOOL distributedAudio; ASN1BOOL centralizedVideo; ASN1BOOL distributedVideo; H245_SeqOfH245DataApplicationCapability centralizedData; H245_SeqOfH245DataApplicationCapability distributedData; } H245MediaDistributionCapability; EXTERN int asn1PE_H245MediaDistributionCapability (OOCTXT* pctxt, H245MediaDistributionCapability* pvalue); EXTERN int asn1PD_H245MediaDistributionCapability (OOCTXT* pctxt, H245MediaDistributionCapability* pvalue); /**************************************************************/ /* */ /* _SeqOfH245MediaDistributionCapability */ /* */ /**************************************************************/ /* List of H245MediaDistributionCapability */ typedef DList H245_SeqOfH245MediaDistributionCapability; EXTERN int asn1PE_H245_SeqOfH245MediaDistributionCapability (OOCTXT* pctxt, H245_SeqOfH245MediaDistributionCapability* pvalue); EXTERN int asn1PD_H245_SeqOfH245MediaDistributionCapability (OOCTXT* pctxt, H245_SeqOfH245MediaDistributionCapability* pvalue); /**************************************************************/ /* */ /* MultipointCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245MultipointCapability { ASN1BOOL multicastCapability; ASN1BOOL multiUniCastConference; H245_SeqOfH245MediaDistributionCapability mediaDistributionCapability; } H245MultipointCapability; EXTERN int asn1PE_H245MultipointCapability (OOCTXT* pctxt, H245MultipointCapability* pvalue); EXTERN int asn1PD_H245MultipointCapability (OOCTXT* pctxt, H245MultipointCapability* pvalue); /**************************************************************/ /* */ /* H2250Capability_mcCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H2250Capability_mcCapability { ASN1BOOL centralizedConferenceMC; ASN1BOOL decentralizedConferenceMC; } H245H2250Capability_mcCapability; EXTERN int asn1PE_H245H2250Capability_mcCapability (OOCTXT* pctxt, H245H2250Capability_mcCapability* pvalue); EXTERN int asn1PD_H245H2250Capability_mcCapability (OOCTXT* pctxt, H245H2250Capability_mcCapability* pvalue); /**************************************************************/ /* */ /* RTPPayloadType_payloadDescriptor */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RTPPayloadType_payloadDescriptor_nonStandardIdentifier 1 #define T_H245RTPPayloadType_payloadDescriptor_rfc_number 2 #define T_H245RTPPayloadType_payloadDescriptor_oid 3 #define T_H245RTPPayloadType_payloadDescriptor_extElem1 4 typedef struct EXTERN H245RTPPayloadType_payloadDescriptor { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandardIdentifier; /* t = 2 */ ASN1INT rfc_number; /* t = 3 */ ASN1OBJID *oid; /* t = 4 */ } u; } H245RTPPayloadType_payloadDescriptor; EXTERN int asn1PE_H245RTPPayloadType_payloadDescriptor (OOCTXT* pctxt, H245RTPPayloadType_payloadDescriptor* pvalue); EXTERN int asn1PD_H245RTPPayloadType_payloadDescriptor (OOCTXT* pctxt, H245RTPPayloadType_payloadDescriptor* pvalue); /**************************************************************/ /* */ /* RTPPayloadType */ /* */ /**************************************************************/ typedef struct EXTERN H245RTPPayloadType { struct { unsigned payloadTypePresent : 1; } m; H245RTPPayloadType_payloadDescriptor payloadDescriptor; ASN1UINT8 payloadType; } H245RTPPayloadType; EXTERN int asn1PE_H245RTPPayloadType (OOCTXT* pctxt, H245RTPPayloadType* pvalue); EXTERN int asn1PD_H245RTPPayloadType (OOCTXT* pctxt, H245RTPPayloadType* pvalue); /**************************************************************/ /* */ /* MediaPacketizationCapability_rtpPayloadType */ /* */ /**************************************************************/ /* List of H245RTPPayloadType */ typedef DList H245MediaPacketizationCapability_rtpPayloadType; EXTERN int asn1PE_H245MediaPacketizationCapability_rtpPayloadType (OOCTXT* pctxt, H245MediaPacketizationCapability_rtpPayloadType* pvalue); EXTERN int asn1PD_H245MediaPacketizationCapability_rtpPayloadType (OOCTXT* pctxt, H245MediaPacketizationCapability_rtpPayloadType* pvalue); /**************************************************************/ /* */ /* MediaPacketizationCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245MediaPacketizationCapability { struct { unsigned rtpPayloadTypePresent : 1; } m; ASN1BOOL h261aVideoPacketization; H245MediaPacketizationCapability_rtpPayloadType rtpPayloadType; } H245MediaPacketizationCapability; EXTERN int asn1PE_H245MediaPacketizationCapability (OOCTXT* pctxt, H245MediaPacketizationCapability* pvalue); EXTERN int asn1PD_H245MediaPacketizationCapability (OOCTXT* pctxt, H245MediaPacketizationCapability* pvalue); /**************************************************************/ /* */ /* QOSMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245QOSMode_guaranteedQOS 1 #define T_H245QOSMode_controlledLoad 2 #define T_H245QOSMode_extElem1 3 typedef struct EXTERN H245QOSMode { int t; } H245QOSMode; EXTERN int asn1PE_H245QOSMode (OOCTXT* pctxt, H245QOSMode* pvalue); EXTERN int asn1PD_H245QOSMode (OOCTXT* pctxt, H245QOSMode* pvalue); /**************************************************************/ /* */ /* RSVPParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245RSVPParameters { struct { unsigned qosModePresent : 1; unsigned tokenRatePresent : 1; unsigned bucketSizePresent : 1; unsigned peakRatePresent : 1; unsigned minPolicedPresent : 1; unsigned maxPktSizePresent : 1; } m; H245QOSMode qosMode; ASN1UINT tokenRate; ASN1UINT bucketSize; ASN1UINT peakRate; ASN1UINT minPoliced; ASN1UINT maxPktSize; } H245RSVPParameters; EXTERN int asn1PE_H245RSVPParameters (OOCTXT* pctxt, H245RSVPParameters* pvalue); EXTERN int asn1PD_H245RSVPParameters (OOCTXT* pctxt, H245RSVPParameters* pvalue); /**************************************************************/ /* */ /* ATMParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245ATMParameters { ASN1USINT maxNTUSize; ASN1BOOL atmUBR; ASN1BOOL atmrtVBR; ASN1BOOL atmnrtVBR; ASN1BOOL atmABR; ASN1BOOL atmCBR; } H245ATMParameters; EXTERN int asn1PE_H245ATMParameters (OOCTXT* pctxt, H245ATMParameters* pvalue); EXTERN int asn1PD_H245ATMParameters (OOCTXT* pctxt, H245ATMParameters* pvalue); /**************************************************************/ /* */ /* QOSCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245QOSCapability { struct { unsigned nonStandardDataPresent : 1; unsigned rsvpParametersPresent : 1; unsigned atmParametersPresent : 1; } m; H245NonStandardParameter nonStandardData; H245RSVPParameters rsvpParameters; H245ATMParameters atmParameters; } H245QOSCapability; EXTERN int asn1PE_H245QOSCapability (OOCTXT* pctxt, H245QOSCapability* pvalue); EXTERN int asn1PD_H245QOSCapability (OOCTXT* pctxt, H245QOSCapability* pvalue); /**************************************************************/ /* */ /* TransportCapability_qOSCapabilities */ /* */ /**************************************************************/ /* List of H245QOSCapability */ typedef DList H245TransportCapability_qOSCapabilities; EXTERN int asn1PE_H245TransportCapability_qOSCapabilities (OOCTXT* pctxt, H245TransportCapability_qOSCapabilities* pvalue); EXTERN int asn1PD_H245TransportCapability_qOSCapabilities (OOCTXT* pctxt, H245TransportCapability_qOSCapabilities* pvalue); /**************************************************************/ /* */ /* MediaTransportType_atm_AAL5_compressed */ /* */ /**************************************************************/ typedef struct EXTERN H245MediaTransportType_atm_AAL5_compressed { ASN1BOOL variable_delta; } H245MediaTransportType_atm_AAL5_compressed; EXTERN int asn1PE_H245MediaTransportType_atm_AAL5_compressed (OOCTXT* pctxt, H245MediaTransportType_atm_AAL5_compressed* pvalue); EXTERN int asn1PD_H245MediaTransportType_atm_AAL5_compressed (OOCTXT* pctxt, H245MediaTransportType_atm_AAL5_compressed* pvalue); /**************************************************************/ /* */ /* MediaTransportType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MediaTransportType_ip_UDP 1 #define T_H245MediaTransportType_ip_TCP 2 #define T_H245MediaTransportType_atm_AAL5_UNIDIR 3 #define T_H245MediaTransportType_atm_AAL5_BIDIR 4 #define T_H245MediaTransportType_atm_AAL5_compressed 5 #define T_H245MediaTransportType_extElem1 6 typedef struct EXTERN H245MediaTransportType { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ H245MediaTransportType_atm_AAL5_compressed *atm_AAL5_compressed; /* t = 6 */ } u; } H245MediaTransportType; EXTERN int asn1PE_H245MediaTransportType (OOCTXT* pctxt, H245MediaTransportType* pvalue); EXTERN int asn1PD_H245MediaTransportType (OOCTXT* pctxt, H245MediaTransportType* pvalue); /**************************************************************/ /* */ /* MediaChannelCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245MediaChannelCapability { struct { unsigned mediaTransportPresent : 1; } m; H245MediaTransportType mediaTransport; } H245MediaChannelCapability; EXTERN int asn1PE_H245MediaChannelCapability (OOCTXT* pctxt, H245MediaChannelCapability* pvalue); EXTERN int asn1PD_H245MediaChannelCapability (OOCTXT* pctxt, H245MediaChannelCapability* pvalue); /**************************************************************/ /* */ /* TransportCapability_mediaChannelCapabilities */ /* */ /**************************************************************/ /* List of H245MediaChannelCapability */ typedef DList H245TransportCapability_mediaChannelCapabilities; EXTERN int asn1PE_H245TransportCapability_mediaChannelCapabilities (OOCTXT* pctxt, H245TransportCapability_mediaChannelCapabilities* pvalue); EXTERN int asn1PD_H245TransportCapability_mediaChannelCapabilities (OOCTXT* pctxt, H245TransportCapability_mediaChannelCapabilities* pvalue); /**************************************************************/ /* */ /* TransportCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245TransportCapability { struct { unsigned nonStandardPresent : 1; unsigned qOSCapabilitiesPresent : 1; unsigned mediaChannelCapabilitiesPresent : 1; } m; H245NonStandardParameter nonStandard; H245TransportCapability_qOSCapabilities qOSCapabilities; H245TransportCapability_mediaChannelCapabilities mediaChannelCapabilities; } H245TransportCapability; EXTERN int asn1PE_H245TransportCapability (OOCTXT* pctxt, H245TransportCapability* pvalue); EXTERN int asn1PD_H245TransportCapability (OOCTXT* pctxt, H245TransportCapability* pvalue); /**************************************************************/ /* */ /* RTPH263VideoRedundancyFrameMapping_frameSequence */ /* */ /**************************************************************/ typedef struct EXTERN H245RTPH263VideoRedundancyFrameMapping_frameSequence { ASN1UINT n; ASN1UINT8 elem[256]; } H245RTPH263VideoRedundancyFrameMapping_frameSequence; EXTERN int asn1PE_H245RTPH263VideoRedundancyFrameMapping_frameSequence (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping_frameSequence* pvalue); EXTERN int asn1PD_H245RTPH263VideoRedundancyFrameMapping_frameSequence (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping_frameSequence* pvalue); /**************************************************************/ /* */ /* RTPH263VideoRedundancyFrameMapping */ /* */ /**************************************************************/ typedef struct EXTERN H245RTPH263VideoRedundancyFrameMapping { ASN1UINT8 threadNumber; H245RTPH263VideoRedundancyFrameMapping_frameSequence frameSequence; } H245RTPH263VideoRedundancyFrameMapping; EXTERN int asn1PE_H245RTPH263VideoRedundancyFrameMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping* pvalue); EXTERN int asn1PD_H245RTPH263VideoRedundancyFrameMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping* pvalue); /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_frameToThreadMapping_cust */ /* */ /**************************************************************/ /* List of H245RTPH263VideoRedundancyFrameMapping */ typedef DList H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom; EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom* pvalue); EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom* pvalue); /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_frameToThreadMapping */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_roundrobin 1 #define T_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom 2 #define T_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_extElem1 3 typedef struct EXTERN H245RTPH263VideoRedundancyEncoding_frameToThreadMapping { int t; union { /* t = 1 */ /* t = 2 */ H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom *custom; /* t = 3 */ } u; } H245RTPH263VideoRedundancyEncoding_frameToThreadMapping; EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping* pvalue); EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping* pvalue); /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_containedThreads */ /* */ /**************************************************************/ typedef struct EXTERN H245RTPH263VideoRedundancyEncoding_containedThreads { ASN1UINT n; ASN1UINT8 elem[256]; } H245RTPH263VideoRedundancyEncoding_containedThreads; EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding_containedThreads (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_containedThreads* pvalue); EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding_containedThreads (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_containedThreads* pvalue); /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding */ /* */ /**************************************************************/ typedef struct EXTERN H245RTPH263VideoRedundancyEncoding { struct { unsigned containedThreadsPresent : 1; } m; ASN1UINT8 numberOfThreads; ASN1USINT framesBetweenSyncPoints; H245RTPH263VideoRedundancyEncoding_frameToThreadMapping frameToThreadMapping; H245RTPH263VideoRedundancyEncoding_containedThreads containedThreads; } H245RTPH263VideoRedundancyEncoding; EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding* pvalue); EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingMethod */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RedundancyEncodingMethod_nonStandard 1 #define T_H245RedundancyEncodingMethod_rtpAudioRedundancyEncoding 2 #define T_H245RedundancyEncodingMethod_rtpH263VideoRedundancyEncoding 3 #define T_H245RedundancyEncodingMethod_extElem1 4 typedef struct EXTERN H245RedundancyEncodingMethod { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ H245RTPH263VideoRedundancyEncoding *rtpH263VideoRedundancyEncoding; /* t = 4 */ } u; } H245RedundancyEncodingMethod; EXTERN int asn1PE_H245RedundancyEncodingMethod (OOCTXT* pctxt, H245RedundancyEncodingMethod* pvalue); EXTERN int asn1PD_H245RedundancyEncodingMethod (OOCTXT* pctxt, H245RedundancyEncodingMethod* pvalue); /**************************************************************/ /* */ /* CapabilityTableEntryNumber */ /* */ /**************************************************************/ typedef ASN1USINT H245CapabilityTableEntryNumber; EXTERN int asn1PE_H245CapabilityTableEntryNumber (OOCTXT* pctxt, H245CapabilityTableEntryNumber value); EXTERN int asn1PD_H245CapabilityTableEntryNumber (OOCTXT* pctxt, H245CapabilityTableEntryNumber* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingCapability_secondaryEncoding */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncodingCapability_secondaryEncoding { ASN1UINT n; H245CapabilityTableEntryNumber elem[256]; } H245RedundancyEncodingCapability_secondaryEncoding; EXTERN int asn1PE_H245RedundancyEncodingCapability_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingCapability_secondaryEncoding* pvalue); EXTERN int asn1PD_H245RedundancyEncodingCapability_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingCapability_secondaryEncoding* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncodingCapability { struct { unsigned secondaryEncodingPresent : 1; } m; H245RedundancyEncodingMethod redundancyEncodingMethod; H245CapabilityTableEntryNumber primaryEncoding; H245RedundancyEncodingCapability_secondaryEncoding secondaryEncoding; } H245RedundancyEncodingCapability; EXTERN int asn1PE_H245RedundancyEncodingCapability (OOCTXT* pctxt, H245RedundancyEncodingCapability* pvalue); EXTERN int asn1PD_H245RedundancyEncodingCapability (OOCTXT* pctxt, H245RedundancyEncodingCapability* pvalue); /**************************************************************/ /* */ /* H2250Capability_redundancyEncodingCapability */ /* */ /**************************************************************/ /* List of H245RedundancyEncodingCapability */ typedef DList H245H2250Capability_redundancyEncodingCapability; EXTERN int asn1PE_H245H2250Capability_redundancyEncodingCapability (OOCTXT* pctxt, H245H2250Capability_redundancyEncodingCapability* pvalue); EXTERN int asn1PD_H245H2250Capability_redundancyEncodingCapability (OOCTXT* pctxt, H245H2250Capability_redundancyEncodingCapability* pvalue); /**************************************************************/ /* */ /* H2250Capability */ /* */ /**************************************************************/ typedef struct EXTERN H245H2250Capability { struct { unsigned transportCapabilityPresent : 1; unsigned redundancyEncodingCapabilityPresent : 1; unsigned logicalChannelSwitchingCapabilityPresent : 1; unsigned t120DynamicPortCapabilityPresent : 1; } m; ASN1USINT maximumAudioDelayJitter; H245MultipointCapability receiveMultipointCapability; H245MultipointCapability transmitMultipointCapability; H245MultipointCapability receiveAndTransmitMultipointCapability; H245H2250Capability_mcCapability mcCapability; ASN1BOOL rtcpVideoControlCapability; H245MediaPacketizationCapability mediaPacketizationCapability; H245TransportCapability transportCapability; H245H2250Capability_redundancyEncodingCapability redundancyEncodingCapability; ASN1BOOL logicalChannelSwitchingCapability; ASN1BOOL t120DynamicPortCapability; } H245H2250Capability; EXTERN int asn1PE_H245H2250Capability (OOCTXT* pctxt, H245H2250Capability* pvalue); EXTERN int asn1PD_H245H2250Capability (OOCTXT* pctxt, H245H2250Capability* pvalue); /**************************************************************/ /* */ /* MultiplexCapability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultiplexCapability_nonStandard 1 #define T_H245MultiplexCapability_h222Capability 2 #define T_H245MultiplexCapability_h223Capability 3 #define T_H245MultiplexCapability_v76Capability 4 #define T_H245MultiplexCapability_h2250Capability 5 #define T_H245MultiplexCapability_genericMultiplexCapability 6 #define T_H245MultiplexCapability_extElem1 7 typedef struct EXTERN H245MultiplexCapability { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245H222Capability *h222Capability; /* t = 3 */ H245H223Capability *h223Capability; /* t = 4 */ H245V76Capability *v76Capability; /* t = 5 */ H245H2250Capability *h2250Capability; /* t = 6 */ H245GenericCapability *genericMultiplexCapability; /* t = 7 */ } u; } H245MultiplexCapability; EXTERN int asn1PE_H245MultiplexCapability (OOCTXT* pctxt, H245MultiplexCapability* pvalue); EXTERN int asn1PD_H245MultiplexCapability (OOCTXT* pctxt, H245MultiplexCapability* pvalue); /**************************************************************/ /* */ /* H261VideoCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H261VideoCapability { struct { unsigned qcifMPIPresent : 1; unsigned cifMPIPresent : 1; unsigned videoBadMBsCapPresent : 1; } m; ASN1UINT8 qcifMPI; ASN1UINT8 cifMPI; ASN1BOOL temporalSpatialTradeOffCapability; ASN1USINT maxBitRate; ASN1BOOL stillImageTransmission; ASN1BOOL videoBadMBsCap; } H245H261VideoCapability; EXTERN int asn1PE_H245H261VideoCapability (OOCTXT* pctxt, H245H261VideoCapability* pvalue); EXTERN int asn1PD_H245H261VideoCapability (OOCTXT* pctxt, H245H261VideoCapability* pvalue); /**************************************************************/ /* */ /* H262VideoCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H262VideoCapability { struct { unsigned videoBitRatePresent : 1; unsigned vbvBufferSizePresent : 1; unsigned samplesPerLinePresent : 1; unsigned linesPerFramePresent : 1; unsigned framesPerSecondPresent : 1; unsigned luminanceSampleRatePresent : 1; unsigned videoBadMBsCapPresent : 1; } m; ASN1BOOL profileAndLevel_SPatML; ASN1BOOL profileAndLevel_MPatLL; ASN1BOOL profileAndLevel_MPatML; ASN1BOOL profileAndLevel_MPatH_14; ASN1BOOL profileAndLevel_MPatHL; ASN1BOOL profileAndLevel_SNRatLL; ASN1BOOL profileAndLevel_SNRatML; ASN1BOOL profileAndLevel_SpatialatH_14; ASN1BOOL profileAndLevel_HPatML; ASN1BOOL profileAndLevel_HPatH_14; ASN1BOOL profileAndLevel_HPatHL; ASN1UINT videoBitRate; ASN1UINT vbvBufferSize; ASN1USINT samplesPerLine; ASN1USINT linesPerFrame; ASN1UINT8 framesPerSecond; ASN1UINT luminanceSampleRate; ASN1BOOL videoBadMBsCap; } H245H262VideoCapability; EXTERN int asn1PE_H245H262VideoCapability (OOCTXT* pctxt, H245H262VideoCapability* pvalue); EXTERN int asn1PD_H245H262VideoCapability (OOCTXT* pctxt, H245H262VideoCapability* pvalue); /**************************************************************/ /* */ /* TransparencyParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245TransparencyParameters { ASN1USINT presentationOrder; ASN1INT offset_x; ASN1INT offset_y; ASN1UINT8 scale_x; ASN1UINT8 scale_y; } H245TransparencyParameters; EXTERN int asn1PE_H245TransparencyParameters (OOCTXT* pctxt, H245TransparencyParameters* pvalue); EXTERN int asn1PD_H245TransparencyParameters (OOCTXT* pctxt, H245TransparencyParameters* pvalue); /**************************************************************/ /* */ /* RefPictureSelection_additionalPictureMemory */ /* */ /**************************************************************/ typedef struct EXTERN H245RefPictureSelection_additionalPictureMemory { struct { unsigned sqcifAdditionalPictureMemoryPresent : 1; unsigned qcifAdditionalPictureMemoryPresent : 1; unsigned cifAdditionalPictureMemoryPresent : 1; unsigned cif4AdditionalPictureMemoryPresent : 1; unsigned cif16AdditionalPictureMemoryPresent : 1; unsigned bigCpfAdditionalPictureMemoryPresent : 1; } m; ASN1USINT sqcifAdditionalPictureMemory; ASN1USINT qcifAdditionalPictureMemory; ASN1USINT cifAdditionalPictureMemory; ASN1USINT cif4AdditionalPictureMemory; ASN1USINT cif16AdditionalPictureMemory; ASN1USINT bigCpfAdditionalPictureMemory; } H245RefPictureSelection_additionalPictureMemory; EXTERN int asn1PE_H245RefPictureSelection_additionalPictureMemory (OOCTXT* pctxt, H245RefPictureSelection_additionalPictureMemory* pvalue); EXTERN int asn1PD_H245RefPictureSelection_additionalPictureMemory (OOCTXT* pctxt, H245RefPictureSelection_additionalPictureMemory* pvalue); /**************************************************************/ /* */ /* RefPictureSelection_videoBackChannelSend */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RefPictureSelection_videoBackChannelSend_none 1 #define T_H245RefPictureSelection_videoBackChannelSend_ackMessageOnly 2 #define T_H245RefPictureSelection_videoBackChannelSend_nackMessageOnly 3 #define T_H245RefPictureSelection_videoBackChannelSend_ackOrNackMessageOnly 4 #define T_H245RefPictureSelection_videoBackChannelSend_ackAndNackMessage 5 #define T_H245RefPictureSelection_videoBackChannelSend_extElem1 6 typedef struct EXTERN H245RefPictureSelection_videoBackChannelSend { int t; } H245RefPictureSelection_videoBackChannelSend; EXTERN int asn1PE_H245RefPictureSelection_videoBackChannelSend (OOCTXT* pctxt, H245RefPictureSelection_videoBackChannelSend* pvalue); EXTERN int asn1PD_H245RefPictureSelection_videoBackChannelSend (OOCTXT* pctxt, H245RefPictureSelection_videoBackChannelSend* pvalue); /**************************************************************/ /* */ /* RefPictureSelection_enhancedReferencePicSelect_subPictur */ /* */ /**************************************************************/ typedef struct EXTERN H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters { ASN1UINT8 mpuHorizMBs; ASN1UINT8 mpuVertMBs; ASN1UINT mpuTotalNumber; } H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters; EXTERN int asn1PE_H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters* pvalue); EXTERN int asn1PD_H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters* pvalue); /**************************************************************/ /* */ /* RefPictureSelection_enhancedReferencePicSelect */ /* */ /**************************************************************/ typedef struct EXTERN H245RefPictureSelection_enhancedReferencePicSelect { struct { unsigned subPictureRemovalParametersPresent : 1; } m; H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters subPictureRemovalParameters; } H245RefPictureSelection_enhancedReferencePicSelect; EXTERN int asn1PE_H245RefPictureSelection_enhancedReferencePicSelect (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect* pvalue); EXTERN int asn1PD_H245RefPictureSelection_enhancedReferencePicSelect (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect* pvalue); /**************************************************************/ /* */ /* RefPictureSelection */ /* */ /**************************************************************/ typedef struct EXTERN H245RefPictureSelection { struct { unsigned additionalPictureMemoryPresent : 1; unsigned enhancedReferencePicSelectPresent : 1; } m; H245RefPictureSelection_additionalPictureMemory additionalPictureMemory; ASN1BOOL videoMux; H245RefPictureSelection_videoBackChannelSend videoBackChannelSend; H245RefPictureSelection_enhancedReferencePicSelect enhancedReferencePicSelect; } H245RefPictureSelection; EXTERN int asn1PE_H245RefPictureSelection (OOCTXT* pctxt, H245RefPictureSelection* pvalue); EXTERN int asn1PD_H245RefPictureSelection (OOCTXT* pctxt, H245RefPictureSelection* pvalue); /**************************************************************/ /* */ /* CustomPictureClockFrequency */ /* */ /**************************************************************/ typedef struct EXTERN H245CustomPictureClockFrequency { struct { unsigned sqcifMPIPresent : 1; unsigned qcifMPIPresent : 1; unsigned cifMPIPresent : 1; unsigned cif4MPIPresent : 1; unsigned cif16MPIPresent : 1; } m; ASN1USINT clockConversionCode; ASN1UINT8 clockDivisor; ASN1USINT sqcifMPI; ASN1USINT qcifMPI; ASN1USINT cifMPI; ASN1USINT cif4MPI; ASN1USINT cif16MPI; } H245CustomPictureClockFrequency; EXTERN int asn1PE_H245CustomPictureClockFrequency (OOCTXT* pctxt, H245CustomPictureClockFrequency* pvalue); EXTERN int asn1PD_H245CustomPictureClockFrequency (OOCTXT* pctxt, H245CustomPictureClockFrequency* pvalue); /**************************************************************/ /* */ /* H263Options_customPictureClockFrequency */ /* */ /**************************************************************/ /* List of H245CustomPictureClockFrequency */ typedef DList H245H263Options_customPictureClockFrequency; EXTERN int asn1PE_H245H263Options_customPictureClockFrequency (OOCTXT* pctxt, H245H263Options_customPictureClockFrequency* pvalue); EXTERN int asn1PD_H245H263Options_customPictureClockFrequency (OOCTXT* pctxt, H245H263Options_customPictureClockFrequency* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat_mPI_customPCF_element */ /* */ /**************************************************************/ typedef struct EXTERN H245CustomPictureFormat_mPI_customPCF_element { ASN1USINT clockConversionCode; ASN1UINT8 clockDivisor; ASN1USINT customMPI; } H245CustomPictureFormat_mPI_customPCF_element; EXTERN int asn1PE_H245CustomPictureFormat_mPI_customPCF_element (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF_element* pvalue); EXTERN int asn1PD_H245CustomPictureFormat_mPI_customPCF_element (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF_element* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat_mPI_customPCF */ /* */ /**************************************************************/ /* List of H245CustomPictureFormat_mPI_customPCF_element */ typedef DList H245CustomPictureFormat_mPI_customPCF; EXTERN int asn1PE_H245CustomPictureFormat_mPI_customPCF (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF* pvalue); EXTERN int asn1PD_H245CustomPictureFormat_mPI_customPCF (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat_mPI */ /* */ /**************************************************************/ typedef struct EXTERN H245CustomPictureFormat_mPI { struct { unsigned standardMPIPresent : 1; unsigned customPCFPresent : 1; } m; ASN1UINT8 standardMPI; H245CustomPictureFormat_mPI_customPCF customPCF; } H245CustomPictureFormat_mPI; EXTERN int asn1PE_H245CustomPictureFormat_mPI (OOCTXT* pctxt, H245CustomPictureFormat_mPI* pvalue); EXTERN int asn1PD_H245CustomPictureFormat_mPI (OOCTXT* pctxt, H245CustomPictureFormat_mPI* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_pixelAspectCo */ /* */ /**************************************************************/ typedef struct EXTERN H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode { ASN1UINT n; ASN1UINT8 elem[14]; } H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode; EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode* pvalue); EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_extendedPAR_e */ /* */ /**************************************************************/ typedef struct EXTERN H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element { ASN1UINT8 width; ASN1UINT8 height; } H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element; EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element* pvalue); EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_extendedPAR */ /* */ /**************************************************************/ /* List of H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element */ typedef DList H245CustomPictureFormat_pixelAspectInformation_extendedPAR; EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation_extendedPAR (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR* pvalue); EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation_extendedPAR (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CustomPictureFormat_pixelAspectInformation_anyPixelAspectRatio 1 #define T_H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode 2 #define T_H245CustomPictureFormat_pixelAspectInformation_extendedPAR 3 #define T_H245CustomPictureFormat_pixelAspectInformation_extElem1 4 typedef struct EXTERN H245CustomPictureFormat_pixelAspectInformation { int t; union { /* t = 1 */ ASN1BOOL anyPixelAspectRatio; /* t = 2 */ H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode *pixelAspectCode; /* t = 3 */ H245CustomPictureFormat_pixelAspectInformation_extendedPAR *extendedPAR; /* t = 4 */ } u; } H245CustomPictureFormat_pixelAspectInformation; EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation* pvalue); EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation* pvalue); /**************************************************************/ /* */ /* CustomPictureFormat */ /* */ /**************************************************************/ typedef struct EXTERN H245CustomPictureFormat { ASN1USINT maxCustomPictureWidth; ASN1USINT maxCustomPictureHeight; ASN1USINT minCustomPictureWidth; ASN1USINT minCustomPictureHeight; H245CustomPictureFormat_mPI mPI; H245CustomPictureFormat_pixelAspectInformation pixelAspectInformation; } H245CustomPictureFormat; EXTERN int asn1PE_H245CustomPictureFormat (OOCTXT* pctxt, H245CustomPictureFormat* pvalue); EXTERN int asn1PD_H245CustomPictureFormat (OOCTXT* pctxt, H245CustomPictureFormat* pvalue); /**************************************************************/ /* */ /* H263Options_customPictureFormat */ /* */ /**************************************************************/ /* List of H245CustomPictureFormat */ typedef DList H245H263Options_customPictureFormat; EXTERN int asn1PE_H245H263Options_customPictureFormat (OOCTXT* pctxt, H245H263Options_customPictureFormat* pvalue); EXTERN int asn1PD_H245H263Options_customPictureFormat (OOCTXT* pctxt, H245H263Options_customPictureFormat* pvalue); /**************************************************************/ /* */ /* H263Version3Options */ /* */ /**************************************************************/ typedef struct EXTERN H245H263Version3Options { ASN1BOOL dataPartitionedSlices; ASN1BOOL fixedPointIDCT0; ASN1BOOL interlacedFields; ASN1BOOL currentPictureHeaderRepetition; ASN1BOOL previousPictureHeaderRepetition; ASN1BOOL nextPictureHeaderRepetition; ASN1BOOL pictureNumber; ASN1BOOL spareReferencePictures; } H245H263Version3Options; EXTERN int asn1PE_H245H263Version3Options (OOCTXT* pctxt, H245H263Version3Options* pvalue); EXTERN int asn1PD_H245H263Version3Options (OOCTXT* pctxt, H245H263Version3Options* pvalue); /**************************************************************/ /* */ /* H263ModeComboFlags */ /* */ /**************************************************************/ typedef struct EXTERN H245H263ModeComboFlags { struct { unsigned enhancedReferencePicSelectPresent : 1; unsigned h263Version3OptionsPresent : 1; } m; ASN1BOOL unrestrictedVector; ASN1BOOL arithmeticCoding; ASN1BOOL advancedPrediction; ASN1BOOL pbFrames; ASN1BOOL advancedIntraCodingMode; ASN1BOOL deblockingFilterMode; ASN1BOOL unlimitedMotionVectors; ASN1BOOL slicesInOrder_NonRect; ASN1BOOL slicesInOrder_Rect; ASN1BOOL slicesNoOrder_NonRect; ASN1BOOL slicesNoOrder_Rect; ASN1BOOL improvedPBFramesMode; ASN1BOOL referencePicSelect; ASN1BOOL dynamicPictureResizingByFour; ASN1BOOL dynamicPictureResizingSixteenthPel; ASN1BOOL dynamicWarpingHalfPel; ASN1BOOL dynamicWarpingSixteenthPel; ASN1BOOL reducedResolutionUpdate; ASN1BOOL independentSegmentDecoding; ASN1BOOL alternateInterVLCMode; ASN1BOOL modifiedQuantizationMode; ASN1BOOL enhancedReferencePicSelect; H245H263Version3Options h263Version3Options; } H245H263ModeComboFlags; EXTERN int asn1PE_H245H263ModeComboFlags (OOCTXT* pctxt, H245H263ModeComboFlags* pvalue); EXTERN int asn1PD_H245H263ModeComboFlags (OOCTXT* pctxt, H245H263ModeComboFlags* pvalue); /**************************************************************/ /* */ /* H263VideoModeCombos_h263VideoCoupledModes */ /* */ /**************************************************************/ /* List of H245H263ModeComboFlags */ typedef DList H245H263VideoModeCombos_h263VideoCoupledModes; EXTERN int asn1PE_H245H263VideoModeCombos_h263VideoCoupledModes (OOCTXT* pctxt, H245H263VideoModeCombos_h263VideoCoupledModes* pvalue); EXTERN int asn1PD_H245H263VideoModeCombos_h263VideoCoupledModes (OOCTXT* pctxt, H245H263VideoModeCombos_h263VideoCoupledModes* pvalue); /**************************************************************/ /* */ /* H263VideoModeCombos */ /* */ /**************************************************************/ typedef struct EXTERN H245H263VideoModeCombos { H245H263ModeComboFlags h263VideoUncoupledModes; H245H263VideoModeCombos_h263VideoCoupledModes h263VideoCoupledModes; } H245H263VideoModeCombos; EXTERN int asn1PE_H245H263VideoModeCombos (OOCTXT* pctxt, H245H263VideoModeCombos* pvalue); EXTERN int asn1PD_H245H263VideoModeCombos (OOCTXT* pctxt, H245H263VideoModeCombos* pvalue); /**************************************************************/ /* */ /* H263Options_modeCombos */ /* */ /**************************************************************/ /* List of H245H263VideoModeCombos */ typedef DList H245H263Options_modeCombos; EXTERN int asn1PE_H245H263Options_modeCombos (OOCTXT* pctxt, H245H263Options_modeCombos* pvalue); EXTERN int asn1PD_H245H263Options_modeCombos (OOCTXT* pctxt, H245H263Options_modeCombos* pvalue); /**************************************************************/ /* */ /* H263Options */ /* */ /**************************************************************/ typedef struct EXTERN H245H263Options { struct { unsigned transparencyParametersPresent : 1; unsigned refPictureSelectionPresent : 1; unsigned customPictureClockFrequencyPresent : 1; unsigned customPictureFormatPresent : 1; unsigned modeCombosPresent : 1; unsigned videoBadMBsCapPresent : 1; unsigned h263Version3OptionsPresent : 1; } m; ASN1BOOL advancedIntraCodingMode; ASN1BOOL deblockingFilterMode; ASN1BOOL improvedPBFramesMode; ASN1BOOL unlimitedMotionVectors; ASN1BOOL fullPictureFreeze; ASN1BOOL partialPictureFreezeAndRelease; ASN1BOOL resizingPartPicFreezeAndRelease; ASN1BOOL fullPictureSnapshot; ASN1BOOL partialPictureSnapshot; ASN1BOOL videoSegmentTagging; ASN1BOOL progressiveRefinement; ASN1BOOL dynamicPictureResizingByFour; ASN1BOOL dynamicPictureResizingSixteenthPel; ASN1BOOL dynamicWarpingHalfPel; ASN1BOOL dynamicWarpingSixteenthPel; ASN1BOOL independentSegmentDecoding; ASN1BOOL slicesInOrder_NonRect; ASN1BOOL slicesInOrder_Rect; ASN1BOOL slicesNoOrder_NonRect; ASN1BOOL slicesNoOrder_Rect; ASN1BOOL alternateInterVLCMode; ASN1BOOL modifiedQuantizationMode; ASN1BOOL reducedResolutionUpdate; H245TransparencyParameters transparencyParameters; ASN1BOOL separateVideoBackChannel; H245RefPictureSelection refPictureSelection; H245H263Options_customPictureClockFrequency customPictureClockFrequency; H245H263Options_customPictureFormat customPictureFormat; H245H263Options_modeCombos modeCombos; ASN1BOOL videoBadMBsCap; H245H263Version3Options h263Version3Options; } H245H263Options; EXTERN int asn1PE_H245H263Options (OOCTXT* pctxt, H245H263Options* pvalue); EXTERN int asn1PD_H245H263Options (OOCTXT* pctxt, H245H263Options* pvalue); /**************************************************************/ /* */ /* EnhancementOptions */ /* */ /**************************************************************/ typedef struct EXTERN H245EnhancementOptions { struct { unsigned sqcifMPIPresent : 1; unsigned qcifMPIPresent : 1; unsigned cifMPIPresent : 1; unsigned cif4MPIPresent : 1; unsigned cif16MPIPresent : 1; unsigned slowSqcifMPIPresent : 1; unsigned slowQcifMPIPresent : 1; unsigned slowCifMPIPresent : 1; unsigned slowCif4MPIPresent : 1; unsigned slowCif16MPIPresent : 1; unsigned h263OptionsPresent : 1; } m; ASN1UINT8 sqcifMPI; ASN1UINT8 qcifMPI; ASN1UINT8 cifMPI; ASN1UINT8 cif4MPI; ASN1UINT8 cif16MPI; ASN1UINT maxBitRate; ASN1BOOL unrestrictedVector; ASN1BOOL arithmeticCoding; ASN1BOOL temporalSpatialTradeOffCapability; ASN1USINT slowSqcifMPI; ASN1USINT slowQcifMPI; ASN1USINT slowCifMPI; ASN1USINT slowCif4MPI; ASN1USINT slowCif16MPI; ASN1BOOL errorCompensation; H245H263Options h263Options; } H245EnhancementOptions; EXTERN int asn1PE_H245EnhancementOptions (OOCTXT* pctxt, H245EnhancementOptions* pvalue); EXTERN int asn1PD_H245EnhancementOptions (OOCTXT* pctxt, H245EnhancementOptions* pvalue); /**************************************************************/ /* */ /* EnhancementLayerInfo_snrEnhancement */ /* */ /**************************************************************/ /* List of H245EnhancementOptions */ typedef DList H245EnhancementLayerInfo_snrEnhancement; EXTERN int asn1PE_H245EnhancementLayerInfo_snrEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_snrEnhancement* pvalue); EXTERN int asn1PD_H245EnhancementLayerInfo_snrEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_snrEnhancement* pvalue); /**************************************************************/ /* */ /* EnhancementLayerInfo_spatialEnhancement */ /* */ /**************************************************************/ /* List of H245EnhancementOptions */ typedef DList H245EnhancementLayerInfo_spatialEnhancement; EXTERN int asn1PE_H245EnhancementLayerInfo_spatialEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_spatialEnhancement* pvalue); EXTERN int asn1PD_H245EnhancementLayerInfo_spatialEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_spatialEnhancement* pvalue); /**************************************************************/ /* */ /* BEnhancementParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245BEnhancementParameters { H245EnhancementOptions enhancementOptions; ASN1UINT8 numberOfBPictures; } H245BEnhancementParameters; EXTERN int asn1PE_H245BEnhancementParameters (OOCTXT* pctxt, H245BEnhancementParameters* pvalue); EXTERN int asn1PD_H245BEnhancementParameters (OOCTXT* pctxt, H245BEnhancementParameters* pvalue); /**************************************************************/ /* */ /* EnhancementLayerInfo_bPictureEnhancement */ /* */ /**************************************************************/ /* List of H245BEnhancementParameters */ typedef DList H245EnhancementLayerInfo_bPictureEnhancement; EXTERN int asn1PE_H245EnhancementLayerInfo_bPictureEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_bPictureEnhancement* pvalue); EXTERN int asn1PD_H245EnhancementLayerInfo_bPictureEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_bPictureEnhancement* pvalue); /**************************************************************/ /* */ /* EnhancementLayerInfo */ /* */ /**************************************************************/ typedef struct EXTERN H245EnhancementLayerInfo { struct { unsigned snrEnhancementPresent : 1; unsigned spatialEnhancementPresent : 1; unsigned bPictureEnhancementPresent : 1; } m; ASN1BOOL baseBitRateConstrained; H245EnhancementLayerInfo_snrEnhancement snrEnhancement; H245EnhancementLayerInfo_spatialEnhancement spatialEnhancement; H245EnhancementLayerInfo_bPictureEnhancement bPictureEnhancement; } H245EnhancementLayerInfo; EXTERN int asn1PE_H245EnhancementLayerInfo (OOCTXT* pctxt, H245EnhancementLayerInfo* pvalue); EXTERN int asn1PD_H245EnhancementLayerInfo (OOCTXT* pctxt, H245EnhancementLayerInfo* pvalue); /**************************************************************/ /* */ /* H263VideoCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H263VideoCapability { struct { unsigned sqcifMPIPresent : 1; unsigned qcifMPIPresent : 1; unsigned cifMPIPresent : 1; unsigned cif4MPIPresent : 1; unsigned cif16MPIPresent : 1; unsigned hrd_BPresent : 1; unsigned bppMaxKbPresent : 1; unsigned slowSqcifMPIPresent : 1; unsigned slowQcifMPIPresent : 1; unsigned slowCifMPIPresent : 1; unsigned slowCif4MPIPresent : 1; unsigned slowCif16MPIPresent : 1; unsigned errorCompensationPresent : 1; unsigned enhancementLayerInfoPresent : 1; unsigned h263OptionsPresent : 1; } m; ASN1UINT8 sqcifMPI; ASN1UINT8 qcifMPI; ASN1UINT8 cifMPI; ASN1UINT8 cif4MPI; ASN1UINT8 cif16MPI; ASN1UINT maxBitRate; ASN1BOOL unrestrictedVector; ASN1BOOL arithmeticCoding; ASN1BOOL advancedPrediction; ASN1BOOL pbFrames; ASN1BOOL temporalSpatialTradeOffCapability; ASN1UINT hrd_B; ASN1USINT bppMaxKb; ASN1USINT slowSqcifMPI; ASN1USINT slowQcifMPI; ASN1USINT slowCifMPI; ASN1USINT slowCif4MPI; ASN1USINT slowCif16MPI; ASN1BOOL errorCompensation; H245EnhancementLayerInfo enhancementLayerInfo; H245H263Options h263Options; } H245H263VideoCapability; EXTERN int asn1PE_H245H263VideoCapability (OOCTXT* pctxt, H245H263VideoCapability* pvalue); EXTERN int asn1PD_H245H263VideoCapability (OOCTXT* pctxt, H245H263VideoCapability* pvalue); /**************************************************************/ /* */ /* IS11172VideoCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245IS11172VideoCapability { struct { unsigned videoBitRatePresent : 1; unsigned vbvBufferSizePresent : 1; unsigned samplesPerLinePresent : 1; unsigned linesPerFramePresent : 1; unsigned pictureRatePresent : 1; unsigned luminanceSampleRatePresent : 1; unsigned videoBadMBsCapPresent : 1; } m; ASN1BOOL constrainedBitstream; ASN1UINT videoBitRate; ASN1UINT vbvBufferSize; ASN1USINT samplesPerLine; ASN1USINT linesPerFrame; ASN1UINT8 pictureRate; ASN1UINT luminanceSampleRate; ASN1BOOL videoBadMBsCap; } H245IS11172VideoCapability; EXTERN int asn1PE_H245IS11172VideoCapability (OOCTXT* pctxt, H245IS11172VideoCapability* pvalue); EXTERN int asn1PD_H245IS11172VideoCapability (OOCTXT* pctxt, H245IS11172VideoCapability* pvalue); /**************************************************************/ /* */ /* VideoCapability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245VideoCapability_nonStandard 1 #define T_H245VideoCapability_h261VideoCapability 2 #define T_H245VideoCapability_h262VideoCapability 3 #define T_H245VideoCapability_h263VideoCapability 4 #define T_H245VideoCapability_is11172VideoCapability 5 #define T_H245VideoCapability_genericVideoCapability 6 #define T_H245VideoCapability_extElem1 7 typedef struct EXTERN H245VideoCapability { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245H261VideoCapability *h261VideoCapability; /* t = 3 */ H245H262VideoCapability *h262VideoCapability; /* t = 4 */ H245H263VideoCapability *h263VideoCapability; /* t = 5 */ H245IS11172VideoCapability *is11172VideoCapability; /* t = 6 */ H245GenericCapability *genericVideoCapability; /* t = 7 */ } u; } H245VideoCapability; EXTERN int asn1PE_H245VideoCapability (OOCTXT* pctxt, H245VideoCapability* pvalue); EXTERN int asn1PD_H245VideoCapability (OOCTXT* pctxt, H245VideoCapability* pvalue); /**************************************************************/ /* */ /* AudioCapability_g7231 */ /* */ /**************************************************************/ typedef struct EXTERN H245AudioCapability_g7231 { ASN1USINT maxAl_sduAudioFrames; ASN1BOOL silenceSuppression; } H245AudioCapability_g7231; EXTERN int asn1PE_H245AudioCapability_g7231 (OOCTXT* pctxt, H245AudioCapability_g7231* pvalue); EXTERN int asn1PD_H245AudioCapability_g7231 (OOCTXT* pctxt, H245AudioCapability_g7231* pvalue); /**************************************************************/ /* */ /* IS11172AudioCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245IS11172AudioCapability { ASN1BOOL audioLayer1; ASN1BOOL audioLayer2; ASN1BOOL audioLayer3; ASN1BOOL audioSampling32k; ASN1BOOL audioSampling44k1; ASN1BOOL audioSampling48k; ASN1BOOL singleChannel; ASN1BOOL twoChannels; ASN1USINT bitRate; } H245IS11172AudioCapability; EXTERN int asn1PE_H245IS11172AudioCapability (OOCTXT* pctxt, H245IS11172AudioCapability* pvalue); EXTERN int asn1PD_H245IS11172AudioCapability (OOCTXT* pctxt, H245IS11172AudioCapability* pvalue); /**************************************************************/ /* */ /* IS13818AudioCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245IS13818AudioCapability { ASN1BOOL audioLayer1; ASN1BOOL audioLayer2; ASN1BOOL audioLayer3; ASN1BOOL audioSampling16k; ASN1BOOL audioSampling22k05; ASN1BOOL audioSampling24k; ASN1BOOL audioSampling32k; ASN1BOOL audioSampling44k1; ASN1BOOL audioSampling48k; ASN1BOOL singleChannel; ASN1BOOL twoChannels; ASN1BOOL threeChannels2_1; ASN1BOOL threeChannels3_0; ASN1BOOL fourChannels2_0_2_0; ASN1BOOL fourChannels2_2; ASN1BOOL fourChannels3_1; ASN1BOOL fiveChannels3_0_2_0; ASN1BOOL fiveChannels3_2; ASN1BOOL lowFrequencyEnhancement; ASN1BOOL multilingual; ASN1USINT bitRate; } H245IS13818AudioCapability; EXTERN int asn1PE_H245IS13818AudioCapability (OOCTXT* pctxt, H245IS13818AudioCapability* pvalue); EXTERN int asn1PD_H245IS13818AudioCapability (OOCTXT* pctxt, H245IS13818AudioCapability* pvalue); /**************************************************************/ /* */ /* G7231AnnexCCapability_g723AnnexCAudioMode */ /* */ /**************************************************************/ typedef struct EXTERN H245G7231AnnexCCapability_g723AnnexCAudioMode { ASN1UINT8 highRateMode0; ASN1UINT8 highRateMode1; ASN1UINT8 lowRateMode0; ASN1UINT8 lowRateMode1; ASN1UINT8 sidMode0; ASN1UINT8 sidMode1; } H245G7231AnnexCCapability_g723AnnexCAudioMode; EXTERN int asn1PE_H245G7231AnnexCCapability_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCCapability_g723AnnexCAudioMode* pvalue); EXTERN int asn1PD_H245G7231AnnexCCapability_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCCapability_g723AnnexCAudioMode* pvalue); /**************************************************************/ /* */ /* G7231AnnexCCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245G7231AnnexCCapability { struct { unsigned g723AnnexCAudioModePresent : 1; } m; ASN1USINT maxAl_sduAudioFrames; ASN1BOOL silenceSuppression; H245G7231AnnexCCapability_g723AnnexCAudioMode g723AnnexCAudioMode; } H245G7231AnnexCCapability; EXTERN int asn1PE_H245G7231AnnexCCapability (OOCTXT* pctxt, H245G7231AnnexCCapability* pvalue); EXTERN int asn1PD_H245G7231AnnexCCapability (OOCTXT* pctxt, H245G7231AnnexCCapability* pvalue); /**************************************************************/ /* */ /* GSMAudioCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245GSMAudioCapability { ASN1USINT audioUnitSize; ASN1BOOL comfortNoise; ASN1BOOL scrambled; } H245GSMAudioCapability; EXTERN int asn1PE_H245GSMAudioCapability (OOCTXT* pctxt, H245GSMAudioCapability* pvalue); EXTERN int asn1PD_H245GSMAudioCapability (OOCTXT* pctxt, H245GSMAudioCapability* pvalue); /**************************************************************/ /* */ /* G729Extensions */ /* */ /**************************************************************/ typedef struct EXTERN H245G729Extensions { struct { unsigned audioUnitPresent : 1; } m; ASN1USINT audioUnit; ASN1BOOL annexA; ASN1BOOL annexB; ASN1BOOL annexD; ASN1BOOL annexE; ASN1BOOL annexF; ASN1BOOL annexG; ASN1BOOL annexH; } H245G729Extensions; EXTERN int asn1PE_H245G729Extensions (OOCTXT* pctxt, H245G729Extensions* pvalue); EXTERN int asn1PD_H245G729Extensions (OOCTXT* pctxt, H245G729Extensions* pvalue); /**************************************************************/ /* */ /* VBDCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245VBDCapability { struct H245AudioCapability *type; } H245VBDCapability; EXTERN int asn1PE_H245VBDCapability (OOCTXT* pctxt, H245VBDCapability* pvalue); EXTERN int asn1PD_H245VBDCapability (OOCTXT* pctxt, H245VBDCapability* pvalue); /**************************************************************/ /* */ /* NoPTAudioTelephonyEventCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245NoPTAudioTelephonyEventCapability { ASN1GeneralString audioTelephoneEvent; } H245NoPTAudioTelephonyEventCapability; EXTERN int asn1PE_H245NoPTAudioTelephonyEventCapability (OOCTXT* pctxt, H245NoPTAudioTelephonyEventCapability* pvalue); EXTERN int asn1PD_H245NoPTAudioTelephonyEventCapability (OOCTXT* pctxt, H245NoPTAudioTelephonyEventCapability* pvalue); /**************************************************************/ /* */ /* NoPTAudioToneCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245NoPTAudioToneCapability { ASN1OCTET __dummy__; } H245NoPTAudioToneCapability; EXTERN int asn1PE_H245NoPTAudioToneCapability (OOCTXT* pctxt, H245NoPTAudioToneCapability* pvalue); EXTERN int asn1PD_H245NoPTAudioToneCapability (OOCTXT* pctxt, H245NoPTAudioToneCapability* pvalue); /**************************************************************/ /* */ /* AudioCapability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245AudioCapability_nonStandard 1 #define T_H245AudioCapability_g711Alaw64k 2 #define T_H245AudioCapability_g711Alaw56k 3 #define T_H245AudioCapability_g711Ulaw64k 4 #define T_H245AudioCapability_g711Ulaw56k 5 #define T_H245AudioCapability_g722_64k 6 #define T_H245AudioCapability_g722_56k 7 #define T_H245AudioCapability_g722_48k 8 #define T_H245AudioCapability_g7231 9 #define T_H245AudioCapability_g728 10 #define T_H245AudioCapability_g729 11 #define T_H245AudioCapability_g729AnnexA 12 #define T_H245AudioCapability_is11172AudioCapability 13 #define T_H245AudioCapability_is13818AudioCapability 14 #define T_H245AudioCapability_g729wAnnexB 15 #define T_H245AudioCapability_g729AnnexAwAnnexB 16 #define T_H245AudioCapability_g7231AnnexCCapability 17 #define T_H245AudioCapability_gsmFullRate 18 #define T_H245AudioCapability_gsmHalfRate 19 #define T_H245AudioCapability_gsmEnhancedFullRate 20 #define T_H245AudioCapability_genericAudioCapability 21 #define T_H245AudioCapability_g729Extensions 22 #define T_H245AudioCapability_vbd 23 #define T_H245AudioCapability_audioTelephonyEvent 24 #define T_H245AudioCapability_audioTone 25 #define T_H245AudioCapability_extElem1 26 typedef struct EXTERN H245AudioCapability { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ ASN1USINT g711Alaw64k; /* t = 3 */ ASN1USINT g711Alaw56k; /* t = 4 */ ASN1USINT g711Ulaw64k; /* t = 5 */ ASN1USINT g711Ulaw56k; /* t = 6 */ ASN1USINT g722_64k; /* t = 7 */ ASN1USINT g722_56k; /* t = 8 */ ASN1USINT g722_48k; /* t = 9 */ H245AudioCapability_g7231 *g7231; /* t = 10 */ ASN1USINT g728; /* t = 11 */ ASN1USINT g729; /* t = 12 */ ASN1USINT g729AnnexA; /* t = 13 */ H245IS11172AudioCapability *is11172AudioCapability; /* t = 14 */ H245IS13818AudioCapability *is13818AudioCapability; /* t = 15 */ ASN1USINT g729wAnnexB; /* t = 16 */ ASN1USINT g729AnnexAwAnnexB; /* t = 17 */ H245G7231AnnexCCapability *g7231AnnexCCapability; /* t = 18 */ H245GSMAudioCapability *gsmFullRate; /* t = 19 */ H245GSMAudioCapability *gsmHalfRate; /* t = 20 */ H245GSMAudioCapability *gsmEnhancedFullRate; /* t = 21 */ H245GenericCapability *genericAudioCapability; /* t = 22 */ H245G729Extensions *g729Extensions; /* t = 23 */ H245VBDCapability *vbd; /* t = 24 */ H245NoPTAudioTelephonyEventCapability *audioTelephonyEvent; /* t = 25 */ H245NoPTAudioToneCapability *audioTone; /* t = 26 */ } u; } H245AudioCapability; EXTERN int asn1PE_H245AudioCapability (OOCTXT* pctxt, H245AudioCapability* pvalue); EXTERN int asn1PD_H245AudioCapability (OOCTXT* pctxt, H245AudioCapability* pvalue); /**************************************************************/ /* */ /* Capability_h233EncryptionReceiveCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245Capability_h233EncryptionReceiveCapability { ASN1UINT8 h233IVResponseTime; } H245Capability_h233EncryptionReceiveCapability; EXTERN int asn1PE_H245Capability_h233EncryptionReceiveCapability (OOCTXT* pctxt, H245Capability_h233EncryptionReceiveCapability* pvalue); EXTERN int asn1PD_H245Capability_h233EncryptionReceiveCapability (OOCTXT* pctxt, H245Capability_h233EncryptionReceiveCapability* pvalue); /**************************************************************/ /* */ /* _SeqOfH245NonStandardParameter */ /* */ /**************************************************************/ /* List of H245NonStandardParameter */ typedef DList H245_SeqOfH245NonStandardParameter; EXTERN int asn1PE_H245_SeqOfH245NonStandardParameter (OOCTXT* pctxt, H245_SeqOfH245NonStandardParameter* pvalue); EXTERN int asn1PD_H245_SeqOfH245NonStandardParameter (OOCTXT* pctxt, H245_SeqOfH245NonStandardParameter* pvalue); /**************************************************************/ /* */ /* ConferenceCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceCapability { struct { unsigned nonStandardDataPresent : 1; unsigned videoIndicateMixingCapabilityPresent : 1; unsigned multipointVisualizationCapabilityPresent : 1; } m; H245_SeqOfH245NonStandardParameter nonStandardData; ASN1BOOL chairControlCapability; ASN1BOOL videoIndicateMixingCapability; ASN1BOOL multipointVisualizationCapability; } H245ConferenceCapability; EXTERN int asn1PE_H245ConferenceCapability (OOCTXT* pctxt, H245ConferenceCapability* pvalue); EXTERN int asn1PD_H245ConferenceCapability (OOCTXT* pctxt, H245ConferenceCapability* pvalue); /**************************************************************/ /* */ /* MediaEncryptionAlgorithm */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MediaEncryptionAlgorithm_nonStandard 1 #define T_H245MediaEncryptionAlgorithm_algorithm 2 #define T_H245MediaEncryptionAlgorithm_extElem1 3 typedef struct EXTERN H245MediaEncryptionAlgorithm { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ ASN1OBJID *algorithm; /* t = 3 */ } u; } H245MediaEncryptionAlgorithm; EXTERN int asn1PE_H245MediaEncryptionAlgorithm (OOCTXT* pctxt, H245MediaEncryptionAlgorithm* pvalue); EXTERN int asn1PD_H245MediaEncryptionAlgorithm (OOCTXT* pctxt, H245MediaEncryptionAlgorithm* pvalue); /**************************************************************/ /* */ /* EncryptionCapability */ /* */ /**************************************************************/ /* List of H245MediaEncryptionAlgorithm */ typedef DList H245EncryptionCapability; EXTERN int asn1PE_H245EncryptionCapability (OOCTXT* pctxt, H245EncryptionCapability* pvalue); EXTERN int asn1PD_H245EncryptionCapability (OOCTXT* pctxt, H245EncryptionCapability* pvalue); /**************************************************************/ /* */ /* AuthenticationCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245AuthenticationCapability { struct { unsigned nonStandardPresent : 1; unsigned antiSpamAlgorithmPresent : 1; } m; H245NonStandardParameter nonStandard; ASN1OBJID antiSpamAlgorithm; } H245AuthenticationCapability; EXTERN int asn1PE_H245AuthenticationCapability (OOCTXT* pctxt, H245AuthenticationCapability* pvalue); EXTERN int asn1PD_H245AuthenticationCapability (OOCTXT* pctxt, H245AuthenticationCapability* pvalue); /**************************************************************/ /* */ /* IntegrityCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245IntegrityCapability { struct { unsigned nonStandardPresent : 1; } m; H245NonStandardParameter nonStandard; } H245IntegrityCapability; EXTERN int asn1PE_H245IntegrityCapability (OOCTXT* pctxt, H245IntegrityCapability* pvalue); EXTERN int asn1PD_H245IntegrityCapability (OOCTXT* pctxt, H245IntegrityCapability* pvalue); /**************************************************************/ /* */ /* EncryptionAuthenticationAndIntegrity */ /* */ /**************************************************************/ typedef struct EXTERN H245EncryptionAuthenticationAndIntegrity { struct { unsigned encryptionCapabilityPresent : 1; unsigned authenticationCapabilityPresent : 1; unsigned integrityCapabilityPresent : 1; } m; H245EncryptionCapability encryptionCapability; H245AuthenticationCapability authenticationCapability; H245IntegrityCapability integrityCapability; } H245EncryptionAuthenticationAndIntegrity; EXTERN int asn1PE_H245EncryptionAuthenticationAndIntegrity (OOCTXT* pctxt, H245EncryptionAuthenticationAndIntegrity* pvalue); EXTERN int asn1PD_H245EncryptionAuthenticationAndIntegrity (OOCTXT* pctxt, H245EncryptionAuthenticationAndIntegrity* pvalue); /**************************************************************/ /* */ /* H235SecurityCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245H235SecurityCapability { H245EncryptionAuthenticationAndIntegrity encryptionAuthenticationAndIntegrity; H245CapabilityTableEntryNumber mediaCapability; } H245H235SecurityCapability; EXTERN int asn1PE_H245H235SecurityCapability (OOCTXT* pctxt, H245H235SecurityCapability* pvalue); EXTERN int asn1PD_H245H235SecurityCapability (OOCTXT* pctxt, H245H235SecurityCapability* pvalue); /**************************************************************/ /* */ /* UserInputCapability_nonStandard */ /* */ /**************************************************************/ /* List of H245NonStandardParameter */ typedef DList H245UserInputCapability_nonStandard; EXTERN int asn1PE_H245UserInputCapability_nonStandard (OOCTXT* pctxt, H245UserInputCapability_nonStandard* pvalue); EXTERN int asn1PD_H245UserInputCapability_nonStandard (OOCTXT* pctxt, H245UserInputCapability_nonStandard* pvalue); /**************************************************************/ /* */ /* UserInputCapability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245UserInputCapability_nonStandard 1 #define T_H245UserInputCapability_basicString 2 #define T_H245UserInputCapability_iA5String 3 #define T_H245UserInputCapability_generalString 4 #define T_H245UserInputCapability_dtmf 5 #define T_H245UserInputCapability_hookflash 6 #define T_H245UserInputCapability_extendedAlphanumeric 7 #define T_H245UserInputCapability_extElem1 8 typedef struct EXTERN H245UserInputCapability { int t; union { /* t = 1 */ H245UserInputCapability_nonStandard *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ } u; } H245UserInputCapability; EXTERN int asn1PE_H245UserInputCapability (OOCTXT* pctxt, H245UserInputCapability* pvalue); EXTERN int asn1PD_H245UserInputCapability (OOCTXT* pctxt, H245UserInputCapability* pvalue); /**************************************************************/ /* */ /* MultiplexFormat */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultiplexFormat_nonStandard 1 #define T_H245MultiplexFormat_h222Capability 2 #define T_H245MultiplexFormat_h223Capability 3 #define T_H245MultiplexFormat_extElem1 4 typedef struct EXTERN H245MultiplexFormat { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245H222Capability *h222Capability; /* t = 3 */ H245H223Capability *h223Capability; /* t = 4 */ } u; } H245MultiplexFormat; EXTERN int asn1PE_H245MultiplexFormat (OOCTXT* pctxt, H245MultiplexFormat* pvalue); EXTERN int asn1PD_H245MultiplexFormat (OOCTXT* pctxt, H245MultiplexFormat* pvalue); /**************************************************************/ /* */ /* AlternativeCapabilitySet */ /* */ /**************************************************************/ typedef struct EXTERN H245AlternativeCapabilitySet { ASN1UINT n; H245CapabilityTableEntryNumber elem[256]; } H245AlternativeCapabilitySet; EXTERN int asn1PE_H245AlternativeCapabilitySet (OOCTXT* pctxt, H245AlternativeCapabilitySet* pvalue); EXTERN int asn1PD_H245AlternativeCapabilitySet (OOCTXT* pctxt, H245AlternativeCapabilitySet* pvalue); /**************************************************************/ /* */ /* MultiplexedStreamCapability_capabilityOnMuxStream */ /* */ /**************************************************************/ /* List of H245AlternativeCapabilitySet */ typedef DList H245MultiplexedStreamCapability_capabilityOnMuxStream; EXTERN int asn1PE_H245MultiplexedStreamCapability_capabilityOnMuxStream (OOCTXT* pctxt, H245MultiplexedStreamCapability_capabilityOnMuxStream* pvalue); EXTERN int asn1PD_H245MultiplexedStreamCapability_capabilityOnMuxStream (OOCTXT* pctxt, H245MultiplexedStreamCapability_capabilityOnMuxStream* pvalue); /**************************************************************/ /* */ /* MultiplexedStreamCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexedStreamCapability { struct { unsigned capabilityOnMuxStreamPresent : 1; } m; H245MultiplexFormat multiplexFormat; ASN1BOOL controlOnMuxStream; H245MultiplexedStreamCapability_capabilityOnMuxStream capabilityOnMuxStream; } H245MultiplexedStreamCapability; EXTERN int asn1PE_H245MultiplexedStreamCapability (OOCTXT* pctxt, H245MultiplexedStreamCapability* pvalue); EXTERN int asn1PD_H245MultiplexedStreamCapability (OOCTXT* pctxt, H245MultiplexedStreamCapability* pvalue); /**************************************************************/ /* */ /* AudioTelephonyEventCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245AudioTelephonyEventCapability { ASN1UINT8 dynamicRTPPayloadType; ASN1GeneralString audioTelephoneEvent; } H245AudioTelephonyEventCapability; EXTERN int asn1PE_H245AudioTelephonyEventCapability (OOCTXT* pctxt, H245AudioTelephonyEventCapability* pvalue); EXTERN int asn1PD_H245AudioTelephonyEventCapability (OOCTXT* pctxt, H245AudioTelephonyEventCapability* pvalue); /**************************************************************/ /* */ /* AudioToneCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245AudioToneCapability { ASN1UINT8 dynamicRTPPayloadType; } H245AudioToneCapability; EXTERN int asn1PE_H245AudioToneCapability (OOCTXT* pctxt, H245AudioToneCapability* pvalue); EXTERN int asn1PD_H245AudioToneCapability (OOCTXT* pctxt, H245AudioToneCapability* pvalue); /**************************************************************/ /* */ /* FECCapability_rfc2733_separateStream */ /* */ /**************************************************************/ typedef struct EXTERN H245FECCapability_rfc2733_separateStream { ASN1BOOL separatePort; ASN1BOOL samePort; } H245FECCapability_rfc2733_separateStream; EXTERN int asn1PE_H245FECCapability_rfc2733_separateStream (OOCTXT* pctxt, H245FECCapability_rfc2733_separateStream* pvalue); EXTERN int asn1PD_H245FECCapability_rfc2733_separateStream (OOCTXT* pctxt, H245FECCapability_rfc2733_separateStream* pvalue); /**************************************************************/ /* */ /* FECCapability_rfc2733 */ /* */ /**************************************************************/ typedef struct EXTERN H245FECCapability_rfc2733 { ASN1BOOL redundancyEncoding; H245FECCapability_rfc2733_separateStream separateStream; } H245FECCapability_rfc2733; EXTERN int asn1PE_H245FECCapability_rfc2733 (OOCTXT* pctxt, H245FECCapability_rfc2733* pvalue); EXTERN int asn1PD_H245FECCapability_rfc2733 (OOCTXT* pctxt, H245FECCapability_rfc2733* pvalue); /**************************************************************/ /* */ /* FECCapability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FECCapability_rfc2733 1 #define T_H245FECCapability_extElem1 2 typedef struct EXTERN H245FECCapability { int t; union { /* t = 1 */ H245FECCapability_rfc2733 *rfc2733; /* t = 2 */ } u; } H245FECCapability; EXTERN int asn1PE_H245FECCapability (OOCTXT* pctxt, H245FECCapability* pvalue); EXTERN int asn1PD_H245FECCapability (OOCTXT* pctxt, H245FECCapability* pvalue); /**************************************************************/ /* */ /* MultiplePayloadStreamCapability_capabilities */ /* */ /**************************************************************/ /* List of H245AlternativeCapabilitySet */ typedef DList H245MultiplePayloadStreamCapability_capabilities; EXTERN int asn1PE_H245MultiplePayloadStreamCapability_capabilities (OOCTXT* pctxt, H245MultiplePayloadStreamCapability_capabilities* pvalue); EXTERN int asn1PD_H245MultiplePayloadStreamCapability_capabilities (OOCTXT* pctxt, H245MultiplePayloadStreamCapability_capabilities* pvalue); /**************************************************************/ /* */ /* MultiplePayloadStreamCapability */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplePayloadStreamCapability { H245MultiplePayloadStreamCapability_capabilities capabilities; } H245MultiplePayloadStreamCapability; EXTERN int asn1PE_H245MultiplePayloadStreamCapability (OOCTXT* pctxt, H245MultiplePayloadStreamCapability* pvalue); EXTERN int asn1PD_H245MultiplePayloadStreamCapability (OOCTXT* pctxt, H245MultiplePayloadStreamCapability* pvalue); /**************************************************************/ /* */ /* Capability */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245Capability_nonStandard 1 #define T_H245Capability_receiveVideoCapability 2 #define T_H245Capability_transmitVideoCapability 3 #define T_H245Capability_receiveAndTransmitVideoCapability 4 #define T_H245Capability_receiveAudioCapability 5 #define T_H245Capability_transmitAudioCapability 6 #define T_H245Capability_receiveAndTransmitAudioCapability 7 #define T_H245Capability_receiveDataApplicationCapability 8 #define T_H245Capability_transmitDataApplicationCapability 9 #define T_H245Capability_receiveAndTransmitDataApplicationCapability 10 #define T_H245Capability_h233EncryptionTransmitCapability 11 #define T_H245Capability_h233EncryptionReceiveCapability 12 #define T_H245Capability_conferenceCapability 13 #define T_H245Capability_h235SecurityCapability 14 #define T_H245Capability_maxPendingReplacementFor 15 #define T_H245Capability_receiveUserInputCapability 16 #define T_H245Capability_transmitUserInputCapability 17 #define T_H245Capability_receiveAndTransmitUserInputCapability 18 #define T_H245Capability_genericControlCapability 19 #define T_H245Capability_receiveMultiplexedStreamCapability 20 #define T_H245Capability_transmitMultiplexedStreamCapability 21 #define T_H245Capability_receiveAndTransmitMultiplexedStreamCapability 22 #define T_H245Capability_receiveRTPAudioTelephonyEventCapability 23 #define T_H245Capability_receiveRTPAudioToneCapability 24 #define T_H245Capability_fecCapability 25 #define T_H245Capability_multiplePayloadStreamCapability 26 #define T_H245Capability_extElem1 27 typedef struct EXTERN H245Capability { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245VideoCapability *receiveVideoCapability; /* t = 3 */ H245VideoCapability *transmitVideoCapability; /* t = 4 */ H245VideoCapability *receiveAndTransmitVideoCapability; /* t = 5 */ H245AudioCapability *receiveAudioCapability; /* t = 6 */ H245AudioCapability *transmitAudioCapability; /* t = 7 */ H245AudioCapability *receiveAndTransmitAudioCapability; /* t = 8 */ H245DataApplicationCapability *receiveDataApplicationCapability; /* t = 9 */ H245DataApplicationCapability *transmitDataApplicationCapability; /* t = 10 */ H245DataApplicationCapability *receiveAndTransmitDataApplicationCapability; /* t = 11 */ ASN1BOOL h233EncryptionTransmitCapability; /* t = 12 */ H245Capability_h233EncryptionReceiveCapability *h233EncryptionReceiveCapability; /* t = 13 */ H245ConferenceCapability *conferenceCapability; /* t = 14 */ H245H235SecurityCapability *h235SecurityCapability; /* t = 15 */ ASN1UINT8 maxPendingReplacementFor; /* t = 16 */ H245UserInputCapability *receiveUserInputCapability; /* t = 17 */ H245UserInputCapability *transmitUserInputCapability; /* t = 18 */ H245UserInputCapability *receiveAndTransmitUserInputCapability; /* t = 19 */ H245GenericCapability *genericControlCapability; /* t = 20 */ H245MultiplexedStreamCapability *receiveMultiplexedStreamCapability; /* t = 21 */ H245MultiplexedStreamCapability *transmitMultiplexedStreamCapability; /* t = 22 */ H245MultiplexedStreamCapability *receiveAndTransmitMultiplexedStreamCapability; /* t = 23 */ H245AudioTelephonyEventCapability *receiveRTPAudioTelephonyEventCapability; /* t = 24 */ H245AudioToneCapability *receiveRTPAudioToneCapability; /* t = 25 */ H245FECCapability *fecCapability; /* t = 26 */ H245MultiplePayloadStreamCapability *multiplePayloadStreamCapability; /* t = 27 */ } u; } H245Capability; EXTERN int asn1PE_H245Capability (OOCTXT* pctxt, H245Capability* pvalue); EXTERN int asn1PD_H245Capability (OOCTXT* pctxt, H245Capability* pvalue); /**************************************************************/ /* */ /* CapabilityTableEntry */ /* */ /**************************************************************/ typedef struct EXTERN H245CapabilityTableEntry { struct { unsigned capabilityPresent : 1; } m; H245CapabilityTableEntryNumber capabilityTableEntryNumber; H245Capability capability; } H245CapabilityTableEntry; EXTERN int asn1PE_H245CapabilityTableEntry (OOCTXT* pctxt, H245CapabilityTableEntry* pvalue); EXTERN int asn1PD_H245CapabilityTableEntry (OOCTXT* pctxt, H245CapabilityTableEntry* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySet_capabilityTable */ /* */ /**************************************************************/ /* List of H245CapabilityTableEntry */ typedef DList H245TerminalCapabilitySet_capabilityTable; EXTERN int asn1PE_H245TerminalCapabilitySet_capabilityTable (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityTable* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySet_capabilityTable (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityTable* pvalue); /**************************************************************/ /* */ /* CapabilityDescriptorNumber */ /* */ /**************************************************************/ typedef ASN1UINT8 H245CapabilityDescriptorNumber; EXTERN int asn1PE_H245CapabilityDescriptorNumber (OOCTXT* pctxt, H245CapabilityDescriptorNumber value); EXTERN int asn1PD_H245CapabilityDescriptorNumber (OOCTXT* pctxt, H245CapabilityDescriptorNumber* pvalue); /**************************************************************/ /* */ /* CapabilityDescriptor_simultaneousCapabilities */ /* */ /**************************************************************/ /* List of H245AlternativeCapabilitySet */ typedef DList H245CapabilityDescriptor_simultaneousCapabilities; EXTERN int asn1PE_H245CapabilityDescriptor_simultaneousCapabilities (OOCTXT* pctxt, H245CapabilityDescriptor_simultaneousCapabilities* pvalue); EXTERN int asn1PD_H245CapabilityDescriptor_simultaneousCapabilities (OOCTXT* pctxt, H245CapabilityDescriptor_simultaneousCapabilities* pvalue); /**************************************************************/ /* */ /* CapabilityDescriptor */ /* */ /**************************************************************/ typedef struct EXTERN H245CapabilityDescriptor { struct { unsigned simultaneousCapabilitiesPresent : 1; } m; H245CapabilityDescriptorNumber capabilityDescriptorNumber; H245CapabilityDescriptor_simultaneousCapabilities simultaneousCapabilities; } H245CapabilityDescriptor; EXTERN int asn1PE_H245CapabilityDescriptor (OOCTXT* pctxt, H245CapabilityDescriptor* pvalue); EXTERN int asn1PD_H245CapabilityDescriptor (OOCTXT* pctxt, H245CapabilityDescriptor* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySet_capabilityDescriptors */ /* */ /**************************************************************/ /* List of H245CapabilityDescriptor */ typedef DList H245TerminalCapabilitySet_capabilityDescriptors; EXTERN int asn1PE_H245TerminalCapabilitySet_capabilityDescriptors (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityDescriptors* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySet_capabilityDescriptors (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityDescriptors* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySet */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalCapabilitySet { struct { unsigned multiplexCapabilityPresent : 1; unsigned capabilityTablePresent : 1; unsigned capabilityDescriptorsPresent : 1; } m; H245SequenceNumber sequenceNumber; ASN1OBJID protocolIdentifier; H245MultiplexCapability multiplexCapability; H245TerminalCapabilitySet_capabilityTable capabilityTable; H245TerminalCapabilitySet_capabilityDescriptors capabilityDescriptors; } H245TerminalCapabilitySet; EXTERN int asn1PE_H245TerminalCapabilitySet (OOCTXT* pctxt, H245TerminalCapabilitySet* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySet (OOCTXT* pctxt, H245TerminalCapabilitySet* pvalue); /**************************************************************/ /* */ /* LogicalChannelNumber */ /* */ /**************************************************************/ typedef ASN1USINT H245LogicalChannelNumber; EXTERN int asn1PE_H245LogicalChannelNumber (OOCTXT* pctxt, H245LogicalChannelNumber value); EXTERN int asn1PD_H245LogicalChannelNumber (OOCTXT* pctxt, H245LogicalChannelNumber* pvalue); /**************************************************************/ /* */ /* EncryptionMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245EncryptionMode_nonStandard 1 #define T_H245EncryptionMode_h233Encryption 2 #define T_H245EncryptionMode_extElem1 3 typedef struct EXTERN H245EncryptionMode { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ } u; } H245EncryptionMode; EXTERN int asn1PE_H245EncryptionMode (OOCTXT* pctxt, H245EncryptionMode* pvalue); EXTERN int asn1PD_H245EncryptionMode (OOCTXT* pctxt, H245EncryptionMode* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingElement */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncodingElement { struct { unsigned payloadTypePresent : 1; } m; struct H245DataType *dataType; ASN1UINT8 payloadType; } H245RedundancyEncodingElement; EXTERN int asn1PE_H245RedundancyEncodingElement (OOCTXT* pctxt, H245RedundancyEncodingElement* pvalue); EXTERN int asn1PD_H245RedundancyEncodingElement (OOCTXT* pctxt, H245RedundancyEncodingElement* pvalue); /**************************************************************/ /* */ /* _SeqOfH245RedundancyEncodingElement */ /* */ /**************************************************************/ /* List of H245RedundancyEncodingElement */ typedef DList H245_SeqOfH245RedundancyEncodingElement; EXTERN int asn1PE_H245_SeqOfH245RedundancyEncodingElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingElement* pvalue); EXTERN int asn1PD_H245_SeqOfH245RedundancyEncodingElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingElement* pvalue); /**************************************************************/ /* */ /* RedundancyEncoding_rtpRedundancyEncoding */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncoding_rtpRedundancyEncoding { struct { unsigned primaryPresent : 1; unsigned secondaryPresent : 1; } m; H245RedundancyEncodingElement primary; H245_SeqOfH245RedundancyEncodingElement secondary; } H245RedundancyEncoding_rtpRedundancyEncoding; EXTERN int asn1PE_H245RedundancyEncoding_rtpRedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding_rtpRedundancyEncoding* pvalue); EXTERN int asn1PD_H245RedundancyEncoding_rtpRedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding_rtpRedundancyEncoding* pvalue); /**************************************************************/ /* */ /* RedundancyEncoding */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncoding { struct { unsigned secondaryEncodingPresent : 1; unsigned rtpRedundancyEncodingPresent : 1; } m; H245RedundancyEncodingMethod redundancyEncodingMethod; struct H245DataType *secondaryEncoding; H245RedundancyEncoding_rtpRedundancyEncoding rtpRedundancyEncoding; } H245RedundancyEncoding; EXTERN int asn1PE_H245RedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding* pvalue); EXTERN int asn1PD_H245RedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding* pvalue); /**************************************************************/ /* */ /* MultiplePayloadStreamElement */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplePayloadStreamElement { struct { unsigned payloadTypePresent : 1; } m; struct H245DataType *dataType; ASN1UINT8 payloadType; } H245MultiplePayloadStreamElement; EXTERN int asn1PE_H245MultiplePayloadStreamElement (OOCTXT* pctxt, H245MultiplePayloadStreamElement* pvalue); EXTERN int asn1PD_H245MultiplePayloadStreamElement (OOCTXT* pctxt, H245MultiplePayloadStreamElement* pvalue); /**************************************************************/ /* */ /* _SeqOfH245MultiplePayloadStreamElement */ /* */ /**************************************************************/ /* List of H245MultiplePayloadStreamElement */ typedef DList H245_SeqOfH245MultiplePayloadStreamElement; EXTERN int asn1PE_H245_SeqOfH245MultiplePayloadStreamElement (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElement* pvalue); EXTERN int asn1PD_H245_SeqOfH245MultiplePayloadStreamElement (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElement* pvalue); /**************************************************************/ /* */ /* MultiplePayloadStream */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplePayloadStream { H245_SeqOfH245MultiplePayloadStreamElement elements; } H245MultiplePayloadStream; EXTERN int asn1PE_H245MultiplePayloadStream (OOCTXT* pctxt, H245MultiplePayloadStream* pvalue); EXTERN int asn1PD_H245MultiplePayloadStream (OOCTXT* pctxt, H245MultiplePayloadStream* pvalue); /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream_differentPort */ /* */ /**************************************************************/ typedef struct EXTERN H245FECData_rfc2733_mode_separateStream_differentPort { struct { unsigned protectedPayloadTypePresent : 1; } m; ASN1UINT8 protectedSessionID; ASN1UINT8 protectedPayloadType; } H245FECData_rfc2733_mode_separateStream_differentPort; EXTERN int asn1PE_H245FECData_rfc2733_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_differentPort* pvalue); EXTERN int asn1PD_H245FECData_rfc2733_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_differentPort* pvalue); /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream_samePort */ /* */ /**************************************************************/ typedef struct EXTERN H245FECData_rfc2733_mode_separateStream_samePort { ASN1UINT8 protectedPayloadType; } H245FECData_rfc2733_mode_separateStream_samePort; EXTERN int asn1PE_H245FECData_rfc2733_mode_separateStream_samePort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_samePort* pvalue); EXTERN int asn1PD_H245FECData_rfc2733_mode_separateStream_samePort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_samePort* pvalue); /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FECData_rfc2733_mode_separateStream_differentPort 1 #define T_H245FECData_rfc2733_mode_separateStream_samePort 2 #define T_H245FECData_rfc2733_mode_separateStream_extElem1 3 typedef struct EXTERN H245FECData_rfc2733_mode_separateStream { int t; union { /* t = 1 */ H245FECData_rfc2733_mode_separateStream_differentPort *differentPort; /* t = 2 */ H245FECData_rfc2733_mode_separateStream_samePort *samePort; /* t = 3 */ } u; } H245FECData_rfc2733_mode_separateStream; EXTERN int asn1PE_H245FECData_rfc2733_mode_separateStream (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream* pvalue); EXTERN int asn1PD_H245FECData_rfc2733_mode_separateStream (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream* pvalue); /**************************************************************/ /* */ /* FECData_rfc2733_mode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FECData_rfc2733_mode_redundancyEncoding 1 #define T_H245FECData_rfc2733_mode_separateStream 2 #define T_H245FECData_rfc2733_mode_extElem1 3 typedef struct EXTERN H245FECData_rfc2733_mode { int t; union { /* t = 1 */ /* t = 2 */ H245FECData_rfc2733_mode_separateStream *separateStream; /* t = 3 */ } u; } H245FECData_rfc2733_mode; EXTERN int asn1PE_H245FECData_rfc2733_mode (OOCTXT* pctxt, H245FECData_rfc2733_mode* pvalue); EXTERN int asn1PD_H245FECData_rfc2733_mode (OOCTXT* pctxt, H245FECData_rfc2733_mode* pvalue); /**************************************************************/ /* */ /* FECData_rfc2733 */ /* */ /**************************************************************/ typedef struct EXTERN H245FECData_rfc2733 { H245FECData_rfc2733_mode mode; } H245FECData_rfc2733; EXTERN int asn1PE_H245FECData_rfc2733 (OOCTXT* pctxt, H245FECData_rfc2733* pvalue); EXTERN int asn1PD_H245FECData_rfc2733 (OOCTXT* pctxt, H245FECData_rfc2733* pvalue); /**************************************************************/ /* */ /* FECData */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FECData_rfc2733 1 typedef struct EXTERN H245FECData { int t; union { /* t = 1 */ H245FECData_rfc2733 *rfc2733; } u; } H245FECData; EXTERN int asn1PE_H245FECData (OOCTXT* pctxt, H245FECData* pvalue); EXTERN int asn1PD_H245FECData (OOCTXT* pctxt, H245FECData* pvalue); /**************************************************************/ /* */ /* H235Media_mediaType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H235Media_mediaType_nonStandard 1 #define T_H245H235Media_mediaType_videoData 2 #define T_H245H235Media_mediaType_audioData 3 #define T_H245H235Media_mediaType_data 4 #define T_H245H235Media_mediaType_redundancyEncoding 5 #define T_H245H235Media_mediaType_multiplePayloadStream 6 #define T_H245H235Media_mediaType_fec 7 #define T_H245H235Media_mediaType_extElem1 8 typedef struct EXTERN H245H235Media_mediaType { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245VideoCapability *videoData; /* t = 3 */ H245AudioCapability *audioData; /* t = 4 */ H245DataApplicationCapability *data; /* t = 5 */ H245RedundancyEncoding *redundancyEncoding; /* t = 6 */ H245MultiplePayloadStream *multiplePayloadStream; /* t = 7 */ H245FECData *fec; /* t = 8 */ } u; } H245H235Media_mediaType; EXTERN int asn1PE_H245H235Media_mediaType (OOCTXT* pctxt, H245H235Media_mediaType* pvalue); EXTERN int asn1PD_H245H235Media_mediaType (OOCTXT* pctxt, H245H235Media_mediaType* pvalue); /**************************************************************/ /* */ /* H235Media */ /* */ /**************************************************************/ typedef struct EXTERN H245H235Media { H245EncryptionAuthenticationAndIntegrity encryptionAuthenticationAndIntegrity; H245H235Media_mediaType mediaType; } H245H235Media; EXTERN int asn1PE_H245H235Media (OOCTXT* pctxt, H245H235Media* pvalue); EXTERN int asn1PD_H245H235Media (OOCTXT* pctxt, H245H235Media* pvalue); /**************************************************************/ /* */ /* MultiplexedStreamParameter */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexedStreamParameter { H245MultiplexFormat multiplexFormat; ASN1BOOL controlOnMuxStream; } H245MultiplexedStreamParameter; EXTERN int asn1PE_H245MultiplexedStreamParameter (OOCTXT* pctxt, H245MultiplexedStreamParameter* pvalue); EXTERN int asn1PD_H245MultiplexedStreamParameter (OOCTXT* pctxt, H245MultiplexedStreamParameter* pvalue); /**************************************************************/ /* */ /* DataType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245DataType_nonStandard 1 #define T_H245DataType_nullData 2 #define T_H245DataType_videoData 3 #define T_H245DataType_audioData 4 #define T_H245DataType_data 5 #define T_H245DataType_encryptionData 6 #define T_H245DataType_h235Control 7 #define T_H245DataType_h235Media 8 #define T_H245DataType_multiplexedStream 9 #define T_H245DataType_redundancyEncoding 10 #define T_H245DataType_multiplePayloadStream 11 #define T_H245DataType_fec 12 #define T_H245DataType_extElem1 13 typedef struct EXTERN H245DataType { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ H245VideoCapability *videoData; /* t = 4 */ H245AudioCapability *audioData; /* t = 5 */ H245DataApplicationCapability *data; /* t = 6 */ H245EncryptionMode *encryptionData; /* t = 7 */ H245NonStandardParameter *h235Control; /* t = 8 */ H245H235Media *h235Media; /* t = 9 */ H245MultiplexedStreamParameter *multiplexedStream; /* t = 10 */ H245RedundancyEncoding *redundancyEncoding; /* t = 11 */ H245MultiplePayloadStream *multiplePayloadStream; /* t = 12 */ H245FECData *fec; /* t = 13 */ } u; } H245DataType; EXTERN int asn1PE_H245DataType (OOCTXT* pctxt, H245DataType* pvalue); EXTERN int asn1PD_H245DataType (OOCTXT* pctxt, H245DataType* pvalue); /**************************************************************/ /* */ /* H222LogicalChannelParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H222LogicalChannelParameters { struct { unsigned pcr_pidPresent : 1; unsigned programDescriptorsPresent : 1; unsigned streamDescriptorsPresent : 1; } m; ASN1USINT resourceID; ASN1USINT subChannelID; ASN1USINT pcr_pid; ASN1DynOctStr programDescriptors; ASN1DynOctStr streamDescriptors; } H245H222LogicalChannelParameters; EXTERN int asn1PE_H245H222LogicalChannelParameters (OOCTXT* pctxt, H245H222LogicalChannelParameters* pvalue); EXTERN int asn1PD_H245H222LogicalChannelParameters (OOCTXT* pctxt, H245H222LogicalChannelParameters* pvalue); /**************************************************************/ /* */ /* H223LogicalChannelParameters_adaptationLayerType_al3 */ /* */ /**************************************************************/ typedef struct EXTERN H245H223LogicalChannelParameters_adaptationLayerType_al3 { ASN1UINT8 controlFieldOctets; ASN1UINT sendBufferSize; } H245H223LogicalChannelParameters_adaptationLayerType_al3; EXTERN int asn1PE_H245H223LogicalChannelParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType_al3* pvalue); EXTERN int asn1PD_H245H223LogicalChannelParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType_al3* pvalue); /**************************************************************/ /* */ /* H223AL1MParameters_transferMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL1MParameters_transferMode_framed 1 #define T_H245H223AL1MParameters_transferMode_unframed 2 #define T_H245H223AL1MParameters_transferMode_extElem1 3 typedef struct EXTERN H245H223AL1MParameters_transferMode { int t; } H245H223AL1MParameters_transferMode; EXTERN int asn1PE_H245H223AL1MParameters_transferMode (OOCTXT* pctxt, H245H223AL1MParameters_transferMode* pvalue); EXTERN int asn1PD_H245H223AL1MParameters_transferMode (OOCTXT* pctxt, H245H223AL1MParameters_transferMode* pvalue); /**************************************************************/ /* */ /* H223AL1MParameters_headerFEC */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL1MParameters_headerFEC_sebch16_7 1 #define T_H245H223AL1MParameters_headerFEC_golay24_12 2 #define T_H245H223AL1MParameters_headerFEC_extElem1 3 typedef struct EXTERN H245H223AL1MParameters_headerFEC { int t; } H245H223AL1MParameters_headerFEC; EXTERN int asn1PE_H245H223AL1MParameters_headerFEC (OOCTXT* pctxt, H245H223AL1MParameters_headerFEC* pvalue); EXTERN int asn1PD_H245H223AL1MParameters_headerFEC (OOCTXT* pctxt, H245H223AL1MParameters_headerFEC* pvalue); /**************************************************************/ /* */ /* H223AL1MParameters_crcLength */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL1MParameters_crcLength_crc4bit 1 #define T_H245H223AL1MParameters_crcLength_crc12bit 2 #define T_H245H223AL1MParameters_crcLength_crc20bit 3 #define T_H245H223AL1MParameters_crcLength_crc28bit 4 #define T_H245H223AL1MParameters_crcLength_crc8bit 5 #define T_H245H223AL1MParameters_crcLength_crc16bit 6 #define T_H245H223AL1MParameters_crcLength_crc32bit 7 #define T_H245H223AL1MParameters_crcLength_crcNotUsed 8 #define T_H245H223AL1MParameters_crcLength_extElem1 9 typedef struct EXTERN H245H223AL1MParameters_crcLength { int t; } H245H223AL1MParameters_crcLength; EXTERN int asn1PE_H245H223AL1MParameters_crcLength (OOCTXT* pctxt, H245H223AL1MParameters_crcLength* pvalue); EXTERN int asn1PD_H245H223AL1MParameters_crcLength (OOCTXT* pctxt, H245H223AL1MParameters_crcLength* pvalue); /**************************************************************/ /* */ /* H223AnnexCArqParameters_numberOfRetransmissions */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AnnexCArqParameters_numberOfRetransmissions_finite 1 #define T_H245H223AnnexCArqParameters_numberOfRetransmissions_infinite 2 #define T_H245H223AnnexCArqParameters_numberOfRetransmissions_extElem1 3 typedef struct EXTERN H245H223AnnexCArqParameters_numberOfRetransmissions { int t; union { /* t = 1 */ ASN1UINT8 finite; /* t = 2 */ /* t = 3 */ } u; } H245H223AnnexCArqParameters_numberOfRetransmissions; EXTERN int asn1PE_H245H223AnnexCArqParameters_numberOfRetransmissions (OOCTXT* pctxt, H245H223AnnexCArqParameters_numberOfRetransmissions* pvalue); EXTERN int asn1PD_H245H223AnnexCArqParameters_numberOfRetransmissions (OOCTXT* pctxt, H245H223AnnexCArqParameters_numberOfRetransmissions* pvalue); /**************************************************************/ /* */ /* H223AnnexCArqParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H223AnnexCArqParameters { H245H223AnnexCArqParameters_numberOfRetransmissions numberOfRetransmissions; ASN1UINT sendBufferSize; } H245H223AnnexCArqParameters; EXTERN int asn1PE_H245H223AnnexCArqParameters (OOCTXT* pctxt, H245H223AnnexCArqParameters* pvalue); EXTERN int asn1PD_H245H223AnnexCArqParameters (OOCTXT* pctxt, H245H223AnnexCArqParameters* pvalue); /**************************************************************/ /* */ /* H223AL1MParameters_arqType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL1MParameters_arqType_noArq 1 #define T_H245H223AL1MParameters_arqType_typeIArq 2 #define T_H245H223AL1MParameters_arqType_typeIIArq 3 #define T_H245H223AL1MParameters_arqType_extElem1 4 typedef struct EXTERN H245H223AL1MParameters_arqType { int t; union { /* t = 1 */ /* t = 2 */ H245H223AnnexCArqParameters *typeIArq; /* t = 3 */ H245H223AnnexCArqParameters *typeIIArq; /* t = 4 */ } u; } H245H223AL1MParameters_arqType; EXTERN int asn1PE_H245H223AL1MParameters_arqType (OOCTXT* pctxt, H245H223AL1MParameters_arqType* pvalue); EXTERN int asn1PD_H245H223AL1MParameters_arqType (OOCTXT* pctxt, H245H223AL1MParameters_arqType* pvalue); /**************************************************************/ /* */ /* H223AL1MParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H223AL1MParameters { struct { unsigned rsCodeCorrectionPresent : 1; } m; H245H223AL1MParameters_transferMode transferMode; H245H223AL1MParameters_headerFEC headerFEC; H245H223AL1MParameters_crcLength crcLength; ASN1UINT8 rcpcCodeRate; H245H223AL1MParameters_arqType arqType; ASN1BOOL alpduInterleaving; ASN1BOOL alsduSplitting; ASN1UINT8 rsCodeCorrection; } H245H223AL1MParameters; EXTERN int asn1PE_H245H223AL1MParameters (OOCTXT* pctxt, H245H223AL1MParameters* pvalue); EXTERN int asn1PD_H245H223AL1MParameters (OOCTXT* pctxt, H245H223AL1MParameters* pvalue); /**************************************************************/ /* */ /* H223AL2MParameters_headerFEC */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL2MParameters_headerFEC_sebch16_5 1 #define T_H245H223AL2MParameters_headerFEC_golay24_12 2 #define T_H245H223AL2MParameters_headerFEC_extElem1 3 typedef struct EXTERN H245H223AL2MParameters_headerFEC { int t; } H245H223AL2MParameters_headerFEC; EXTERN int asn1PE_H245H223AL2MParameters_headerFEC (OOCTXT* pctxt, H245H223AL2MParameters_headerFEC* pvalue); EXTERN int asn1PD_H245H223AL2MParameters_headerFEC (OOCTXT* pctxt, H245H223AL2MParameters_headerFEC* pvalue); /**************************************************************/ /* */ /* H223AL2MParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H223AL2MParameters { H245H223AL2MParameters_headerFEC headerFEC; ASN1BOOL alpduInterleaving; } H245H223AL2MParameters; EXTERN int asn1PE_H245H223AL2MParameters (OOCTXT* pctxt, H245H223AL2MParameters* pvalue); EXTERN int asn1PD_H245H223AL2MParameters (OOCTXT* pctxt, H245H223AL2MParameters* pvalue); /**************************************************************/ /* */ /* H223AL3MParameters_headerFormat */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL3MParameters_headerFormat_sebch16_7 1 #define T_H245H223AL3MParameters_headerFormat_golay24_12 2 #define T_H245H223AL3MParameters_headerFormat_extElem1 3 typedef struct EXTERN H245H223AL3MParameters_headerFormat { int t; } H245H223AL3MParameters_headerFormat; EXTERN int asn1PE_H245H223AL3MParameters_headerFormat (OOCTXT* pctxt, H245H223AL3MParameters_headerFormat* pvalue); EXTERN int asn1PD_H245H223AL3MParameters_headerFormat (OOCTXT* pctxt, H245H223AL3MParameters_headerFormat* pvalue); /**************************************************************/ /* */ /* H223AL3MParameters_crcLength */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL3MParameters_crcLength_crc4bit 1 #define T_H245H223AL3MParameters_crcLength_crc12bit 2 #define T_H245H223AL3MParameters_crcLength_crc20bit 3 #define T_H245H223AL3MParameters_crcLength_crc28bit 4 #define T_H245H223AL3MParameters_crcLength_crc8bit 5 #define T_H245H223AL3MParameters_crcLength_crc16bit 6 #define T_H245H223AL3MParameters_crcLength_crc32bit 7 #define T_H245H223AL3MParameters_crcLength_crcNotUsed 8 #define T_H245H223AL3MParameters_crcLength_extElem1 9 typedef struct EXTERN H245H223AL3MParameters_crcLength { int t; } H245H223AL3MParameters_crcLength; EXTERN int asn1PE_H245H223AL3MParameters_crcLength (OOCTXT* pctxt, H245H223AL3MParameters_crcLength* pvalue); EXTERN int asn1PD_H245H223AL3MParameters_crcLength (OOCTXT* pctxt, H245H223AL3MParameters_crcLength* pvalue); /**************************************************************/ /* */ /* H223AL3MParameters_arqType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223AL3MParameters_arqType_noArq 1 #define T_H245H223AL3MParameters_arqType_typeIArq 2 #define T_H245H223AL3MParameters_arqType_typeIIArq 3 #define T_H245H223AL3MParameters_arqType_extElem1 4 typedef struct EXTERN H245H223AL3MParameters_arqType { int t; union { /* t = 1 */ /* t = 2 */ H245H223AnnexCArqParameters *typeIArq; /* t = 3 */ H245H223AnnexCArqParameters *typeIIArq; /* t = 4 */ } u; } H245H223AL3MParameters_arqType; EXTERN int asn1PE_H245H223AL3MParameters_arqType (OOCTXT* pctxt, H245H223AL3MParameters_arqType* pvalue); EXTERN int asn1PD_H245H223AL3MParameters_arqType (OOCTXT* pctxt, H245H223AL3MParameters_arqType* pvalue); /**************************************************************/ /* */ /* H223AL3MParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H223AL3MParameters { struct { unsigned rsCodeCorrectionPresent : 1; } m; H245H223AL3MParameters_headerFormat headerFormat; H245H223AL3MParameters_crcLength crcLength; ASN1UINT8 rcpcCodeRate; H245H223AL3MParameters_arqType arqType; ASN1BOOL alpduInterleaving; ASN1UINT8 rsCodeCorrection; } H245H223AL3MParameters; EXTERN int asn1PE_H245H223AL3MParameters (OOCTXT* pctxt, H245H223AL3MParameters* pvalue); EXTERN int asn1PD_H245H223AL3MParameters (OOCTXT* pctxt, H245H223AL3MParameters* pvalue); /**************************************************************/ /* */ /* H223LogicalChannelParameters_adaptationLayerType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223LogicalChannelParameters_adaptationLayerType_nonStandard 1 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al1Framed 2 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al1NotFramed 3 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al2WithoutSequenceNumbers 4 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al2WithSequenceNumbers 5 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al3 6 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al1M 7 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al2M 8 #define T_H245H223LogicalChannelParameters_adaptationLayerType_al3M 9 #define T_H245H223LogicalChannelParameters_adaptationLayerType_extElem1 10 typedef struct EXTERN H245H223LogicalChannelParameters_adaptationLayerType { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ H245H223LogicalChannelParameters_adaptationLayerType_al3 *al3; /* t = 7 */ H245H223AL1MParameters *al1M; /* t = 8 */ H245H223AL2MParameters *al2M; /* t = 9 */ H245H223AL3MParameters *al3M; /* t = 10 */ } u; } H245H223LogicalChannelParameters_adaptationLayerType; EXTERN int asn1PE_H245H223LogicalChannelParameters_adaptationLayerType (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType* pvalue); EXTERN int asn1PD_H245H223LogicalChannelParameters_adaptationLayerType (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType* pvalue); /**************************************************************/ /* */ /* H223LogicalChannelParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H223LogicalChannelParameters { H245H223LogicalChannelParameters_adaptationLayerType adaptationLayerType; ASN1BOOL segmentableFlag; } H245H223LogicalChannelParameters; EXTERN int asn1PE_H245H223LogicalChannelParameters (OOCTXT* pctxt, H245H223LogicalChannelParameters* pvalue); EXTERN int asn1PD_H245H223LogicalChannelParameters (OOCTXT* pctxt, H245H223LogicalChannelParameters* pvalue); /**************************************************************/ /* */ /* CRCLength */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CRCLength_crc8bit 1 #define T_H245CRCLength_crc16bit 2 #define T_H245CRCLength_crc32bit 3 #define T_H245CRCLength_extElem1 4 typedef struct EXTERN H245CRCLength { int t; } H245CRCLength; EXTERN int asn1PE_H245CRCLength (OOCTXT* pctxt, H245CRCLength* pvalue); EXTERN int asn1PD_H245CRCLength (OOCTXT* pctxt, H245CRCLength* pvalue); /**************************************************************/ /* */ /* V76HDLCParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245V76HDLCParameters { H245CRCLength crcLength; ASN1USINT n401; ASN1BOOL loopbackTestProcedure; } H245V76HDLCParameters; EXTERN int asn1PE_H245V76HDLCParameters (OOCTXT* pctxt, H245V76HDLCParameters* pvalue); EXTERN int asn1PD_H245V76HDLCParameters (OOCTXT* pctxt, H245V76HDLCParameters* pvalue); /**************************************************************/ /* */ /* V76LogicalChannelParameters_suspendResume */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245V76LogicalChannelParameters_suspendResume_noSuspendResume 1 #define T_H245V76LogicalChannelParameters_suspendResume_suspendResumewAddress 2 #define T_H245V76LogicalChannelParameters_suspendResume_suspendResumewoAddress 3 #define T_H245V76LogicalChannelParameters_suspendResume_extElem1 4 typedef struct EXTERN H245V76LogicalChannelParameters_suspendResume { int t; } H245V76LogicalChannelParameters_suspendResume; EXTERN int asn1PE_H245V76LogicalChannelParameters_suspendResume (OOCTXT* pctxt, H245V76LogicalChannelParameters_suspendResume* pvalue); EXTERN int asn1PD_H245V76LogicalChannelParameters_suspendResume (OOCTXT* pctxt, H245V76LogicalChannelParameters_suspendResume* pvalue); /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode_eRM_recovery */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245V76LogicalChannelParameters_mode_eRM_recovery_rej 1 #define T_H245V76LogicalChannelParameters_mode_eRM_recovery_sREJ 2 #define T_H245V76LogicalChannelParameters_mode_eRM_recovery_mSREJ 3 #define T_H245V76LogicalChannelParameters_mode_eRM_recovery_extElem1 4 typedef struct EXTERN H245V76LogicalChannelParameters_mode_eRM_recovery { int t; } H245V76LogicalChannelParameters_mode_eRM_recovery; EXTERN int asn1PE_H245V76LogicalChannelParameters_mode_eRM_recovery (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM_recovery* pvalue); EXTERN int asn1PD_H245V76LogicalChannelParameters_mode_eRM_recovery (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM_recovery* pvalue); /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode_eRM */ /* */ /**************************************************************/ typedef struct EXTERN H245V76LogicalChannelParameters_mode_eRM { ASN1UINT8 windowSize; H245V76LogicalChannelParameters_mode_eRM_recovery recovery; } H245V76LogicalChannelParameters_mode_eRM; EXTERN int asn1PE_H245V76LogicalChannelParameters_mode_eRM (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM* pvalue); EXTERN int asn1PD_H245V76LogicalChannelParameters_mode_eRM (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM* pvalue); /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245V76LogicalChannelParameters_mode_eRM 1 #define T_H245V76LogicalChannelParameters_mode_uNERM 2 #define T_H245V76LogicalChannelParameters_mode_extElem1 3 typedef struct EXTERN H245V76LogicalChannelParameters_mode { int t; union { /* t = 1 */ H245V76LogicalChannelParameters_mode_eRM *eRM; /* t = 2 */ /* t = 3 */ } u; } H245V76LogicalChannelParameters_mode; EXTERN int asn1PE_H245V76LogicalChannelParameters_mode (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode* pvalue); EXTERN int asn1PD_H245V76LogicalChannelParameters_mode (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode* pvalue); /**************************************************************/ /* */ /* V75Parameters */ /* */ /**************************************************************/ typedef struct EXTERN H245V75Parameters { ASN1BOOL audioHeaderPresent; } H245V75Parameters; EXTERN int asn1PE_H245V75Parameters (OOCTXT* pctxt, H245V75Parameters* pvalue); EXTERN int asn1PD_H245V75Parameters (OOCTXT* pctxt, H245V75Parameters* pvalue); /**************************************************************/ /* */ /* V76LogicalChannelParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245V76LogicalChannelParameters { H245V76HDLCParameters hdlcParameters; H245V76LogicalChannelParameters_suspendResume suspendResume; ASN1BOOL uIH; H245V76LogicalChannelParameters_mode mode; H245V75Parameters v75Parameters; } H245V76LogicalChannelParameters; EXTERN int asn1PE_H245V76LogicalChannelParameters (OOCTXT* pctxt, H245V76LogicalChannelParameters* pvalue); EXTERN int asn1PD_H245V76LogicalChannelParameters (OOCTXT* pctxt, H245V76LogicalChannelParameters* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPAddress_network */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPAddress_network { ASN1UINT numocts; ASN1OCTET data[4]; } H245UnicastAddress_iPAddress_network; EXTERN int asn1PE_H245UnicastAddress_iPAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPAddress_network* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPAddress_network* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPAddress */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPAddress { H245UnicastAddress_iPAddress_network network; ASN1USINT tsapIdentifier; } H245UnicastAddress_iPAddress; EXTERN int asn1PE_H245UnicastAddress_iPAddress (OOCTXT* pctxt, H245UnicastAddress_iPAddress* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPAddress (OOCTXT* pctxt, H245UnicastAddress_iPAddress* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_node */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPXAddress_node { ASN1UINT numocts; ASN1OCTET data[6]; } H245UnicastAddress_iPXAddress_node; EXTERN int asn1PE_H245UnicastAddress_iPXAddress_node (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_node* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPXAddress_node (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_node* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_netnum */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPXAddress_netnum { ASN1UINT numocts; ASN1OCTET data[4]; } H245UnicastAddress_iPXAddress_netnum; EXTERN int asn1PE_H245UnicastAddress_iPXAddress_netnum (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_netnum* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPXAddress_netnum (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_netnum* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_tsapIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPXAddress_tsapIdentifier { ASN1UINT numocts; ASN1OCTET data[2]; } H245UnicastAddress_iPXAddress_tsapIdentifier; EXTERN int asn1PE_H245UnicastAddress_iPXAddress_tsapIdentifier (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_tsapIdentifier* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPXAddress_tsapIdentifier (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_tsapIdentifier* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPXAddress */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPXAddress { H245UnicastAddress_iPXAddress_node node; H245UnicastAddress_iPXAddress_netnum netnum; H245UnicastAddress_iPXAddress_tsapIdentifier tsapIdentifier; } H245UnicastAddress_iPXAddress; EXTERN int asn1PE_H245UnicastAddress_iPXAddress (OOCTXT* pctxt, H245UnicastAddress_iPXAddress* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPXAddress (OOCTXT* pctxt, H245UnicastAddress_iPXAddress* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iP6Address_network */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iP6Address_network { ASN1UINT numocts; ASN1OCTET data[16]; } H245UnicastAddress_iP6Address_network; EXTERN int asn1PE_H245UnicastAddress_iP6Address_network (OOCTXT* pctxt, H245UnicastAddress_iP6Address_network* pvalue); EXTERN int asn1PD_H245UnicastAddress_iP6Address_network (OOCTXT* pctxt, H245UnicastAddress_iP6Address_network* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iP6Address */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iP6Address { H245UnicastAddress_iP6Address_network network; ASN1USINT tsapIdentifier; } H245UnicastAddress_iP6Address; EXTERN int asn1PE_H245UnicastAddress_iP6Address (OOCTXT* pctxt, H245UnicastAddress_iP6Address* pvalue); EXTERN int asn1PD_H245UnicastAddress_iP6Address (OOCTXT* pctxt, H245UnicastAddress_iP6Address* pvalue); /**************************************************************/ /* */ /* UnicastAddress_netBios */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_netBios { ASN1UINT numocts; ASN1OCTET data[16]; } H245UnicastAddress_netBios; EXTERN int asn1PE_H245UnicastAddress_netBios (OOCTXT* pctxt, H245UnicastAddress_netBios* pvalue); EXTERN int asn1PD_H245UnicastAddress_netBios (OOCTXT* pctxt, H245UnicastAddress_netBios* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_routing */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245UnicastAddress_iPSourceRouteAddress_routing_strict 1 #define T_H245UnicastAddress_iPSourceRouteAddress_routing_loose 2 typedef struct EXTERN H245UnicastAddress_iPSourceRouteAddress_routing { int t; } H245UnicastAddress_iPSourceRouteAddress_routing; EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress_routing (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_routing* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress_routing (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_routing* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_network */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPSourceRouteAddress_network { ASN1UINT numocts; ASN1OCTET data[4]; } H245UnicastAddress_iPSourceRouteAddress_network; EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_network* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_network* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_route_element */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPSourceRouteAddress_route_element { ASN1UINT numocts; ASN1OCTET data[4]; } H245UnicastAddress_iPSourceRouteAddress_route_element; EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_route_element* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_route_element* pvalue); /**************************************************************/ /* */ /* _SeqOfH245UnicastAddress_iPSourceRouteAddress_route_elem */ /* */ /**************************************************************/ typedef struct EXTERN H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element { ASN1UINT n; H245UnicastAddress_iPSourceRouteAddress_route_element *elem; } H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element; EXTERN int asn1PE_H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element* pvalue); EXTERN int asn1PD_H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element* pvalue); /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_iPSourceRouteAddress { H245UnicastAddress_iPSourceRouteAddress_routing routing; H245UnicastAddress_iPSourceRouteAddress_network network; ASN1USINT tsapIdentifier; H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element route; } H245UnicastAddress_iPSourceRouteAddress; EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress* pvalue); EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress* pvalue); /**************************************************************/ /* */ /* UnicastAddress_nsap */ /* */ /**************************************************************/ typedef struct EXTERN H245UnicastAddress_nsap { ASN1UINT numocts; ASN1OCTET data[20]; } H245UnicastAddress_nsap; EXTERN int asn1PE_H245UnicastAddress_nsap (OOCTXT* pctxt, H245UnicastAddress_nsap* pvalue); EXTERN int asn1PD_H245UnicastAddress_nsap (OOCTXT* pctxt, H245UnicastAddress_nsap* pvalue); /**************************************************************/ /* */ /* UnicastAddress */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245UnicastAddress_iPAddress 1 #define T_H245UnicastAddress_iPXAddress 2 #define T_H245UnicastAddress_iP6Address 3 #define T_H245UnicastAddress_netBios 4 #define T_H245UnicastAddress_iPSourceRouteAddress 5 #define T_H245UnicastAddress_nsap 6 #define T_H245UnicastAddress_nonStandardAddress 7 #define T_H245UnicastAddress_extElem1 8 typedef struct EXTERN H245UnicastAddress { int t; union { /* t = 1 */ H245UnicastAddress_iPAddress *iPAddress; /* t = 2 */ H245UnicastAddress_iPXAddress *iPXAddress; /* t = 3 */ H245UnicastAddress_iP6Address *iP6Address; /* t = 4 */ H245UnicastAddress_netBios *netBios; /* t = 5 */ H245UnicastAddress_iPSourceRouteAddress *iPSourceRouteAddress; /* t = 6 */ H245UnicastAddress_nsap *nsap; /* t = 7 */ H245NonStandardParameter *nonStandardAddress; /* t = 8 */ } u; } H245UnicastAddress; EXTERN int asn1PE_H245UnicastAddress (OOCTXT* pctxt, H245UnicastAddress* pvalue); EXTERN int asn1PD_H245UnicastAddress (OOCTXT* pctxt, H245UnicastAddress* pvalue); /**************************************************************/ /* */ /* MulticastAddress_iPAddress_network */ /* */ /**************************************************************/ typedef struct EXTERN H245MulticastAddress_iPAddress_network { ASN1UINT numocts; ASN1OCTET data[4]; } H245MulticastAddress_iPAddress_network; EXTERN int asn1PE_H245MulticastAddress_iPAddress_network (OOCTXT* pctxt, H245MulticastAddress_iPAddress_network* pvalue); EXTERN int asn1PD_H245MulticastAddress_iPAddress_network (OOCTXT* pctxt, H245MulticastAddress_iPAddress_network* pvalue); /**************************************************************/ /* */ /* MulticastAddress_iPAddress */ /* */ /**************************************************************/ typedef struct EXTERN H245MulticastAddress_iPAddress { H245MulticastAddress_iPAddress_network network; ASN1USINT tsapIdentifier; } H245MulticastAddress_iPAddress; EXTERN int asn1PE_H245MulticastAddress_iPAddress (OOCTXT* pctxt, H245MulticastAddress_iPAddress* pvalue); EXTERN int asn1PD_H245MulticastAddress_iPAddress (OOCTXT* pctxt, H245MulticastAddress_iPAddress* pvalue); /**************************************************************/ /* */ /* MulticastAddress_iP6Address_network */ /* */ /**************************************************************/ typedef struct EXTERN H245MulticastAddress_iP6Address_network { ASN1UINT numocts; ASN1OCTET data[16]; } H245MulticastAddress_iP6Address_network; EXTERN int asn1PE_H245MulticastAddress_iP6Address_network (OOCTXT* pctxt, H245MulticastAddress_iP6Address_network* pvalue); EXTERN int asn1PD_H245MulticastAddress_iP6Address_network (OOCTXT* pctxt, H245MulticastAddress_iP6Address_network* pvalue); /**************************************************************/ /* */ /* MulticastAddress_iP6Address */ /* */ /**************************************************************/ typedef struct EXTERN H245MulticastAddress_iP6Address { H245MulticastAddress_iP6Address_network network; ASN1USINT tsapIdentifier; } H245MulticastAddress_iP6Address; EXTERN int asn1PE_H245MulticastAddress_iP6Address (OOCTXT* pctxt, H245MulticastAddress_iP6Address* pvalue); EXTERN int asn1PD_H245MulticastAddress_iP6Address (OOCTXT* pctxt, H245MulticastAddress_iP6Address* pvalue); /**************************************************************/ /* */ /* MulticastAddress_nsap */ /* */ /**************************************************************/ typedef struct EXTERN H245MulticastAddress_nsap { ASN1UINT numocts; ASN1OCTET data[20]; } H245MulticastAddress_nsap; EXTERN int asn1PE_H245MulticastAddress_nsap (OOCTXT* pctxt, H245MulticastAddress_nsap* pvalue); EXTERN int asn1PD_H245MulticastAddress_nsap (OOCTXT* pctxt, H245MulticastAddress_nsap* pvalue); /**************************************************************/ /* */ /* MulticastAddress */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MulticastAddress_iPAddress 1 #define T_H245MulticastAddress_iP6Address 2 #define T_H245MulticastAddress_nsap 3 #define T_H245MulticastAddress_nonStandardAddress 4 #define T_H245MulticastAddress_extElem1 5 typedef struct EXTERN H245MulticastAddress { int t; union { /* t = 1 */ H245MulticastAddress_iPAddress *iPAddress; /* t = 2 */ H245MulticastAddress_iP6Address *iP6Address; /* t = 3 */ H245MulticastAddress_nsap *nsap; /* t = 4 */ H245NonStandardParameter *nonStandardAddress; /* t = 5 */ } u; } H245MulticastAddress; EXTERN int asn1PE_H245MulticastAddress (OOCTXT* pctxt, H245MulticastAddress* pvalue); EXTERN int asn1PD_H245MulticastAddress (OOCTXT* pctxt, H245MulticastAddress* pvalue); /**************************************************************/ /* */ /* TransportAddress */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245TransportAddress_unicastAddress 1 #define T_H245TransportAddress_multicastAddress 2 #define T_H245TransportAddress_extElem1 3 typedef struct EXTERN H245TransportAddress { int t; union { /* t = 1 */ H245UnicastAddress *unicastAddress; /* t = 2 */ H245MulticastAddress *multicastAddress; /* t = 3 */ } u; } H245TransportAddress; EXTERN int asn1PE_H245TransportAddress (OOCTXT* pctxt, H245TransportAddress* pvalue); EXTERN int asn1PD_H245TransportAddress (OOCTXT* pctxt, H245TransportAddress* pvalue); /**************************************************************/ /* */ /* McuNumber */ /* */ /**************************************************************/ typedef ASN1UINT8 H245McuNumber; EXTERN int asn1PE_H245McuNumber (OOCTXT* pctxt, H245McuNumber value); EXTERN int asn1PD_H245McuNumber (OOCTXT* pctxt, H245McuNumber* pvalue); /**************************************************************/ /* */ /* TerminalNumber */ /* */ /**************************************************************/ typedef ASN1UINT8 H245TerminalNumber; EXTERN int asn1PE_H245TerminalNumber (OOCTXT* pctxt, H245TerminalNumber value); EXTERN int asn1PD_H245TerminalNumber (OOCTXT* pctxt, H245TerminalNumber* pvalue); /**************************************************************/ /* */ /* TerminalLabel */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalLabel { H245McuNumber mcuNumber; H245TerminalNumber terminalNumber; } H245TerminalLabel; EXTERN int asn1PE_H245TerminalLabel (OOCTXT* pctxt, H245TerminalLabel* pvalue); EXTERN int asn1PD_H245TerminalLabel (OOCTXT* pctxt, H245TerminalLabel* pvalue); /**************************************************************/ /* */ /* H2250LogicalChannelParameters_mediaPacketization */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H2250LogicalChannelParameters_mediaPacketization_h261aVideoPacketization 1 #define T_H245H2250LogicalChannelParameters_mediaPacketization_rtpPayloadType 2 #define T_H245H2250LogicalChannelParameters_mediaPacketization_extElem1 3 typedef struct EXTERN H245H2250LogicalChannelParameters_mediaPacketization { int t; union { /* t = 1 */ /* t = 2 */ H245RTPPayloadType *rtpPayloadType; /* t = 3 */ } u; } H245H2250LogicalChannelParameters_mediaPacketization; EXTERN int asn1PE_H245H2250LogicalChannelParameters_mediaPacketization (OOCTXT* pctxt, H245H2250LogicalChannelParameters_mediaPacketization* pvalue); EXTERN int asn1PD_H245H2250LogicalChannelParameters_mediaPacketization (OOCTXT* pctxt, H245H2250LogicalChannelParameters_mediaPacketization* pvalue); /**************************************************************/ /* */ /* H2250LogicalChannelParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H2250LogicalChannelParameters { struct { unsigned nonStandardPresent : 1; unsigned associatedSessionIDPresent : 1; unsigned mediaChannelPresent : 1; unsigned mediaGuaranteedDeliveryPresent : 1; unsigned mediaControlChannelPresent : 1; unsigned mediaControlGuaranteedDeliveryPresent : 1; unsigned silenceSuppressionPresent : 1; unsigned destinationPresent : 1; unsigned dynamicRTPPayloadTypePresent : 1; unsigned mediaPacketizationPresent : 1; unsigned transportCapabilityPresent : 1; unsigned redundancyEncodingPresent : 1; unsigned sourcePresent : 1; } m; H245_SeqOfH245NonStandardParameter nonStandard; ASN1UINT8 sessionID; ASN1UINT8 associatedSessionID; H245TransportAddress mediaChannel; ASN1BOOL mediaGuaranteedDelivery; H245TransportAddress mediaControlChannel; ASN1BOOL mediaControlGuaranteedDelivery; ASN1BOOL silenceSuppression; H245TerminalLabel destination; ASN1UINT8 dynamicRTPPayloadType; H245H2250LogicalChannelParameters_mediaPacketization mediaPacketization; H245TransportCapability transportCapability; H245RedundancyEncoding redundancyEncoding; H245TerminalLabel source; } H245H2250LogicalChannelParameters; EXTERN int asn1PE_H245H2250LogicalChannelParameters (OOCTXT* pctxt, H245H2250LogicalChannelParameters* pvalue); EXTERN int asn1PD_H245H2250LogicalChannelParameters (OOCTXT* pctxt, H245H2250LogicalChannelParameters* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannel_forwardLogicalChannelParameters_multi */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h222LogicalChannelParameters 1 #define T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h223LogicalChannelParameters 2 #define T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_v76LogicalChannelParameters 3 #define T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters 4 #define T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_none 5 #define T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_extElem1 6 typedef struct EXTERN H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters { int t; union { /* t = 1 */ H245H222LogicalChannelParameters *h222LogicalChannelParameters; /* t = 2 */ H245H223LogicalChannelParameters *h223LogicalChannelParameters; /* t = 3 */ H245V76LogicalChannelParameters *v76LogicalChannelParameters; /* t = 4 */ H245H2250LogicalChannelParameters *h2250LogicalChannelParameters; /* t = 5 */ /* t = 6 */ } u; } H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters; EXTERN int asn1PE_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters* pvalue); EXTERN int asn1PD_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannel_forwardLogicalChannelParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245OpenLogicalChannel_forwardLogicalChannelParameters { struct { unsigned portNumberPresent : 1; unsigned forwardLogicalChannelDependencyPresent : 1; unsigned replacementForPresent : 1; } m; ASN1USINT portNumber; H245DataType dataType; H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters multiplexParameters; H245LogicalChannelNumber forwardLogicalChannelDependency; H245LogicalChannelNumber replacementFor; } H245OpenLogicalChannel_forwardLogicalChannelParameters; EXTERN int asn1PE_H245OpenLogicalChannel_forwardLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters* pvalue); EXTERN int asn1PD_H245OpenLogicalChannel_forwardLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannel_reverseLogicalChannelParameters_multi */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h223LogicalChannelParameters 1 #define T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_v76LogicalChannelParameters 2 #define T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters 3 #define T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_extElem1 4 typedef struct EXTERN H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters { int t; union { /* t = 1 */ H245H223LogicalChannelParameters *h223LogicalChannelParameters; /* t = 2 */ H245V76LogicalChannelParameters *v76LogicalChannelParameters; /* t = 3 */ H245H2250LogicalChannelParameters *h2250LogicalChannelParameters; /* t = 4 */ } u; } H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters; EXTERN int asn1PE_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters* pvalue); EXTERN int asn1PD_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannel_reverseLogicalChannelParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245OpenLogicalChannel_reverseLogicalChannelParameters { struct { unsigned multiplexParametersPresent : 1; unsigned reverseLogicalChannelDependencyPresent : 1; unsigned replacementForPresent : 1; } m; H245DataType dataType; H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters multiplexParameters; H245LogicalChannelNumber reverseLogicalChannelDependency; H245LogicalChannelNumber replacementFor; } H245OpenLogicalChannel_reverseLogicalChannelParameters; EXTERN int asn1PE_H245OpenLogicalChannel_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters* pvalue); EXTERN int asn1PD_H245OpenLogicalChannel_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters* pvalue); /**************************************************************/ /* */ /* NetworkAccessParameters_distribution */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NetworkAccessParameters_distribution_unicast 1 #define T_H245NetworkAccessParameters_distribution_multicast 2 #define T_H245NetworkAccessParameters_distribution_extElem1 3 typedef struct EXTERN H245NetworkAccessParameters_distribution { int t; } H245NetworkAccessParameters_distribution; EXTERN int asn1PE_H245NetworkAccessParameters_distribution (OOCTXT* pctxt, H245NetworkAccessParameters_distribution* pvalue); EXTERN int asn1PD_H245NetworkAccessParameters_distribution (OOCTXT* pctxt, H245NetworkAccessParameters_distribution* pvalue); /**************************************************************/ /* */ /* NetworkAccessParameters_networkAddress */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NetworkAccessParameters_networkAddress_q2931Address 1 #define T_H245NetworkAccessParameters_networkAddress_e164Address 2 #define T_H245NetworkAccessParameters_networkAddress_localAreaAddress 3 #define T_H245NetworkAccessParameters_networkAddress_extElem1 4 typedef struct EXTERN H245NetworkAccessParameters_networkAddress { int t; union { /* t = 1 */ H245Q2931Address *q2931Address; /* t = 2 */ ASN1IA5String e164Address; /* t = 3 */ H245TransportAddress *localAreaAddress; /* t = 4 */ } u; } H245NetworkAccessParameters_networkAddress; EXTERN int asn1PE_H245NetworkAccessParameters_networkAddress (OOCTXT* pctxt, H245NetworkAccessParameters_networkAddress* pvalue); EXTERN int asn1PD_H245NetworkAccessParameters_networkAddress (OOCTXT* pctxt, H245NetworkAccessParameters_networkAddress* pvalue); /**************************************************************/ /* */ /* NetworkAccessParameters_externalReference */ /* */ /**************************************************************/ typedef struct EXTERN H245NetworkAccessParameters_externalReference { ASN1UINT numocts; ASN1OCTET data[255]; } H245NetworkAccessParameters_externalReference; EXTERN int asn1PE_H245NetworkAccessParameters_externalReference (OOCTXT* pctxt, H245NetworkAccessParameters_externalReference* pvalue); EXTERN int asn1PD_H245NetworkAccessParameters_externalReference (OOCTXT* pctxt, H245NetworkAccessParameters_externalReference* pvalue); /**************************************************************/ /* */ /* NetworkAccessParameters_t120SetupProcedure */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NetworkAccessParameters_t120SetupProcedure_originateCall 1 #define T_H245NetworkAccessParameters_t120SetupProcedure_waitForCall 2 #define T_H245NetworkAccessParameters_t120SetupProcedure_issueQuery 3 #define T_H245NetworkAccessParameters_t120SetupProcedure_extElem1 4 typedef struct EXTERN H245NetworkAccessParameters_t120SetupProcedure { int t; } H245NetworkAccessParameters_t120SetupProcedure; EXTERN int asn1PE_H245NetworkAccessParameters_t120SetupProcedure (OOCTXT* pctxt, H245NetworkAccessParameters_t120SetupProcedure* pvalue); EXTERN int asn1PD_H245NetworkAccessParameters_t120SetupProcedure (OOCTXT* pctxt, H245NetworkAccessParameters_t120SetupProcedure* pvalue); /**************************************************************/ /* */ /* NetworkAccessParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245NetworkAccessParameters { struct { unsigned distributionPresent : 1; unsigned externalReferencePresent : 1; unsigned t120SetupProcedurePresent : 1; } m; H245NetworkAccessParameters_distribution distribution; H245NetworkAccessParameters_networkAddress networkAddress; ASN1BOOL associateConference; H245NetworkAccessParameters_externalReference externalReference; H245NetworkAccessParameters_t120SetupProcedure t120SetupProcedure; } H245NetworkAccessParameters; EXTERN int asn1PE_H245NetworkAccessParameters (OOCTXT* pctxt, H245NetworkAccessParameters* pvalue); EXTERN int asn1PD_H245NetworkAccessParameters (OOCTXT* pctxt, H245NetworkAccessParameters* pvalue); /**************************************************************/ /* */ /* EscrowData_escrowValue */ /* */ /**************************************************************/ typedef struct EXTERN H245EscrowData_escrowValue { ASN1UINT numbits; ASN1OCTET data[8192]; } H245EscrowData_escrowValue; EXTERN int asn1PE_H245EscrowData_escrowValue (OOCTXT* pctxt, H245EscrowData_escrowValue* pvalue); EXTERN int asn1PD_H245EscrowData_escrowValue (OOCTXT* pctxt, H245EscrowData_escrowValue* pvalue); /**************************************************************/ /* */ /* EscrowData */ /* */ /**************************************************************/ typedef struct EXTERN H245EscrowData { ASN1OBJID escrowID; H245EscrowData_escrowValue escrowValue; } H245EscrowData; EXTERN int asn1PE_H245EscrowData (OOCTXT* pctxt, H245EscrowData* pvalue); EXTERN int asn1PD_H245EscrowData (OOCTXT* pctxt, H245EscrowData* pvalue); /**************************************************************/ /* */ /* EncryptionSync_escrowentry */ /* */ /**************************************************************/ /* List of H245EscrowData */ typedef DList H245EncryptionSync_escrowentry; EXTERN int asn1PE_H245EncryptionSync_escrowentry (OOCTXT* pctxt, H245EncryptionSync_escrowentry* pvalue); EXTERN int asn1PD_H245EncryptionSync_escrowentry (OOCTXT* pctxt, H245EncryptionSync_escrowentry* pvalue); /**************************************************************/ /* */ /* EncryptionSync */ /* */ /**************************************************************/ typedef struct EXTERN H245EncryptionSync { struct { unsigned nonStandardPresent : 1; unsigned escrowentryPresent : 1; } m; H245NonStandardParameter nonStandard; ASN1UINT8 synchFlag; ASN1DynOctStr h235Key; H245EncryptionSync_escrowentry escrowentry; } H245EncryptionSync; EXTERN int asn1PE_H245EncryptionSync (OOCTXT* pctxt, H245EncryptionSync* pvalue); EXTERN int asn1PD_H245EncryptionSync (OOCTXT* pctxt, H245EncryptionSync* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannel */ /* */ /**************************************************************/ typedef struct EXTERN H245OpenLogicalChannel { struct { unsigned reverseLogicalChannelParametersPresent : 1; unsigned separateStackPresent : 1; unsigned encryptionSyncPresent : 1; } m; H245LogicalChannelNumber forwardLogicalChannelNumber; H245OpenLogicalChannel_forwardLogicalChannelParameters forwardLogicalChannelParameters; H245OpenLogicalChannel_reverseLogicalChannelParameters reverseLogicalChannelParameters; H245NetworkAccessParameters separateStack; H245EncryptionSync encryptionSync; } H245OpenLogicalChannel; EXTERN int asn1PE_H245OpenLogicalChannel (OOCTXT* pctxt, H245OpenLogicalChannel* pvalue); EXTERN int asn1PD_H245OpenLogicalChannel (OOCTXT* pctxt, H245OpenLogicalChannel* pvalue); /**************************************************************/ /* */ /* CloseLogicalChannel_source */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CloseLogicalChannel_source_user 1 #define T_H245CloseLogicalChannel_source_lcse 2 typedef struct EXTERN H245CloseLogicalChannel_source { int t; } H245CloseLogicalChannel_source; EXTERN int asn1PE_H245CloseLogicalChannel_source (OOCTXT* pctxt, H245CloseLogicalChannel_source* pvalue); EXTERN int asn1PD_H245CloseLogicalChannel_source (OOCTXT* pctxt, H245CloseLogicalChannel_source* pvalue); /**************************************************************/ /* */ /* CloseLogicalChannel_reason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CloseLogicalChannel_reason_unknown 1 #define T_H245CloseLogicalChannel_reason_reopen 2 #define T_H245CloseLogicalChannel_reason_reservationFailure 3 #define T_H245CloseLogicalChannel_reason_extElem1 4 typedef struct EXTERN H245CloseLogicalChannel_reason { int t; } H245CloseLogicalChannel_reason; EXTERN int asn1PE_H245CloseLogicalChannel_reason (OOCTXT* pctxt, H245CloseLogicalChannel_reason* pvalue); EXTERN int asn1PD_H245CloseLogicalChannel_reason (OOCTXT* pctxt, H245CloseLogicalChannel_reason* pvalue); /**************************************************************/ /* */ /* CloseLogicalChannel */ /* */ /**************************************************************/ typedef struct EXTERN H245CloseLogicalChannel { struct { unsigned reasonPresent : 1; } m; H245LogicalChannelNumber forwardLogicalChannelNumber; H245CloseLogicalChannel_source source; H245CloseLogicalChannel_reason reason; } H245CloseLogicalChannel; EXTERN int asn1PE_H245CloseLogicalChannel (OOCTXT* pctxt, H245CloseLogicalChannel* pvalue); EXTERN int asn1PD_H245CloseLogicalChannel (OOCTXT* pctxt, H245CloseLogicalChannel* pvalue); /**************************************************************/ /* */ /* RequestChannelClose_reason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RequestChannelClose_reason_unknown 1 #define T_H245RequestChannelClose_reason_normal 2 #define T_H245RequestChannelClose_reason_reopen 3 #define T_H245RequestChannelClose_reason_reservationFailure 4 #define T_H245RequestChannelClose_reason_extElem1 5 typedef struct EXTERN H245RequestChannelClose_reason { int t; } H245RequestChannelClose_reason; EXTERN int asn1PE_H245RequestChannelClose_reason (OOCTXT* pctxt, H245RequestChannelClose_reason* pvalue); EXTERN int asn1PD_H245RequestChannelClose_reason (OOCTXT* pctxt, H245RequestChannelClose_reason* pvalue); /**************************************************************/ /* */ /* RequestChannelClose */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestChannelClose { struct { unsigned qosCapabilityPresent : 1; unsigned reasonPresent : 1; } m; H245LogicalChannelNumber forwardLogicalChannelNumber; H245QOSCapability qosCapability; H245RequestChannelClose_reason reason; } H245RequestChannelClose; EXTERN int asn1PE_H245RequestChannelClose (OOCTXT* pctxt, H245RequestChannelClose* pvalue); EXTERN int asn1PD_H245RequestChannelClose (OOCTXT* pctxt, H245RequestChannelClose* pvalue); /**************************************************************/ /* */ /* MultiplexTableEntryNumber */ /* */ /**************************************************************/ typedef ASN1UINT8 H245MultiplexTableEntryNumber; EXTERN int asn1PE_H245MultiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexTableEntryNumber value); EXTERN int asn1PD_H245MultiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexTableEntryNumber* pvalue); /**************************************************************/ /* */ /* MultiplexElement_type_subElementList */ /* */ /**************************************************************/ /* List of H245MultiplexElement */ typedef DList H245MultiplexElement_type_subElementList; EXTERN int asn1PE_H245MultiplexElement_type_subElementList (OOCTXT* pctxt, H245MultiplexElement_type_subElementList* pvalue); EXTERN int asn1PD_H245MultiplexElement_type_subElementList (OOCTXT* pctxt, H245MultiplexElement_type_subElementList* pvalue); /**************************************************************/ /* */ /* MultiplexElement_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultiplexElement_type_logicalChannelNumber 1 #define T_H245MultiplexElement_type_subElementList 2 typedef struct EXTERN H245MultiplexElement_type { int t; union { /* t = 1 */ ASN1USINT logicalChannelNumber; /* t = 2 */ H245MultiplexElement_type_subElementList *subElementList; } u; } H245MultiplexElement_type; EXTERN int asn1PE_H245MultiplexElement_type (OOCTXT* pctxt, H245MultiplexElement_type* pvalue); EXTERN int asn1PD_H245MultiplexElement_type (OOCTXT* pctxt, H245MultiplexElement_type* pvalue); /**************************************************************/ /* */ /* MultiplexElement_repeatCount */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultiplexElement_repeatCount_finite 1 #define T_H245MultiplexElement_repeatCount_untilClosingFlag 2 typedef struct EXTERN H245MultiplexElement_repeatCount { int t; union { /* t = 1 */ ASN1USINT finite; /* t = 2 */ } u; } H245MultiplexElement_repeatCount; EXTERN int asn1PE_H245MultiplexElement_repeatCount (OOCTXT* pctxt, H245MultiplexElement_repeatCount* pvalue); EXTERN int asn1PD_H245MultiplexElement_repeatCount (OOCTXT* pctxt, H245MultiplexElement_repeatCount* pvalue); /**************************************************************/ /* */ /* MultiplexElement */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexElement { H245MultiplexElement_type type; H245MultiplexElement_repeatCount repeatCount; } H245MultiplexElement; EXTERN int asn1PE_H245MultiplexElement (OOCTXT* pctxt, H245MultiplexElement* pvalue); EXTERN int asn1PD_H245MultiplexElement (OOCTXT* pctxt, H245MultiplexElement* pvalue); /**************************************************************/ /* */ /* MultiplexEntryDescriptor_elementList */ /* */ /**************************************************************/ /* List of H245MultiplexElement */ typedef DList H245MultiplexEntryDescriptor_elementList; EXTERN int asn1PE_H245MultiplexEntryDescriptor_elementList (OOCTXT* pctxt, H245MultiplexEntryDescriptor_elementList* pvalue); EXTERN int asn1PD_H245MultiplexEntryDescriptor_elementList (OOCTXT* pctxt, H245MultiplexEntryDescriptor_elementList* pvalue); /**************************************************************/ /* */ /* MultiplexEntryDescriptor */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntryDescriptor { struct { unsigned elementListPresent : 1; } m; H245MultiplexTableEntryNumber multiplexTableEntryNumber; H245MultiplexEntryDescriptor_elementList elementList; } H245MultiplexEntryDescriptor; EXTERN int asn1PE_H245MultiplexEntryDescriptor (OOCTXT* pctxt, H245MultiplexEntryDescriptor* pvalue); EXTERN int asn1PD_H245MultiplexEntryDescriptor (OOCTXT* pctxt, H245MultiplexEntryDescriptor* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySend_multiplexEntryDescriptors */ /* */ /**************************************************************/ /* List of H245MultiplexEntryDescriptor */ typedef DList H245MultiplexEntrySend_multiplexEntryDescriptors; EXTERN int asn1PE_H245MultiplexEntrySend_multiplexEntryDescriptors (OOCTXT* pctxt, H245MultiplexEntrySend_multiplexEntryDescriptors* pvalue); EXTERN int asn1PD_H245MultiplexEntrySend_multiplexEntryDescriptors (OOCTXT* pctxt, H245MultiplexEntrySend_multiplexEntryDescriptors* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySend */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntrySend { H245SequenceNumber sequenceNumber; H245MultiplexEntrySend_multiplexEntryDescriptors multiplexEntryDescriptors; } H245MultiplexEntrySend; EXTERN int asn1PE_H245MultiplexEntrySend (OOCTXT* pctxt, H245MultiplexEntrySend* pvalue); EXTERN int asn1PD_H245MultiplexEntrySend (OOCTXT* pctxt, H245MultiplexEntrySend* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntry_entryNumbers */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntry_entryNumbers { ASN1UINT n; H245MultiplexTableEntryNumber elem[15]; } H245RequestMultiplexEntry_entryNumbers; EXTERN int asn1PE_H245RequestMultiplexEntry_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntry_entryNumbers* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntry_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntry_entryNumbers* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntry */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntry { H245RequestMultiplexEntry_entryNumbers entryNumbers; } H245RequestMultiplexEntry; EXTERN int asn1PE_H245RequestMultiplexEntry (OOCTXT* pctxt, H245RequestMultiplexEntry* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntry (OOCTXT* pctxt, H245RequestMultiplexEntry* pvalue); /**************************************************************/ /* */ /* H261VideoMode_resolution */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H261VideoMode_resolution_qcif 1 #define T_H245H261VideoMode_resolution_cif 2 typedef struct EXTERN H245H261VideoMode_resolution { int t; } H245H261VideoMode_resolution; EXTERN int asn1PE_H245H261VideoMode_resolution (OOCTXT* pctxt, H245H261VideoMode_resolution* pvalue); EXTERN int asn1PD_H245H261VideoMode_resolution (OOCTXT* pctxt, H245H261VideoMode_resolution* pvalue); /**************************************************************/ /* */ /* H261VideoMode */ /* */ /**************************************************************/ typedef struct EXTERN H245H261VideoMode { H245H261VideoMode_resolution resolution; ASN1USINT bitRate; ASN1BOOL stillImageTransmission; } H245H261VideoMode; EXTERN int asn1PE_H245H261VideoMode (OOCTXT* pctxt, H245H261VideoMode* pvalue); EXTERN int asn1PD_H245H261VideoMode (OOCTXT* pctxt, H245H261VideoMode* pvalue); /**************************************************************/ /* */ /* H262VideoMode_profileAndLevel */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_SPatML 1 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_MPatLL 2 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_MPatML 3 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_MPatH_14 4 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_MPatHL 5 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_SNRatLL 6 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_SNRatML 7 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_SpatialatH_14 8 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_HPatML 9 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_HPatH_14 10 #define T_H245H262VideoMode_profileAndLevel_profileAndLevel_HPatHL 11 #define T_H245H262VideoMode_profileAndLevel_extElem1 12 typedef struct EXTERN H245H262VideoMode_profileAndLevel { int t; } H245H262VideoMode_profileAndLevel; EXTERN int asn1PE_H245H262VideoMode_profileAndLevel (OOCTXT* pctxt, H245H262VideoMode_profileAndLevel* pvalue); EXTERN int asn1PD_H245H262VideoMode_profileAndLevel (OOCTXT* pctxt, H245H262VideoMode_profileAndLevel* pvalue); /**************************************************************/ /* */ /* H262VideoMode */ /* */ /**************************************************************/ typedef struct EXTERN H245H262VideoMode { struct { unsigned videoBitRatePresent : 1; unsigned vbvBufferSizePresent : 1; unsigned samplesPerLinePresent : 1; unsigned linesPerFramePresent : 1; unsigned framesPerSecondPresent : 1; unsigned luminanceSampleRatePresent : 1; } m; H245H262VideoMode_profileAndLevel profileAndLevel; ASN1UINT videoBitRate; ASN1UINT vbvBufferSize; ASN1USINT samplesPerLine; ASN1USINT linesPerFrame; ASN1UINT8 framesPerSecond; ASN1UINT luminanceSampleRate; } H245H262VideoMode; EXTERN int asn1PE_H245H262VideoMode (OOCTXT* pctxt, H245H262VideoMode* pvalue); EXTERN int asn1PD_H245H262VideoMode (OOCTXT* pctxt, H245H262VideoMode* pvalue); /**************************************************************/ /* */ /* H263VideoMode_resolution */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H263VideoMode_resolution_sqcif 1 #define T_H245H263VideoMode_resolution_qcif 2 #define T_H245H263VideoMode_resolution_cif 3 #define T_H245H263VideoMode_resolution_cif4 4 #define T_H245H263VideoMode_resolution_cif16 5 #define T_H245H263VideoMode_resolution_custom 6 #define T_H245H263VideoMode_resolution_extElem1 7 typedef struct EXTERN H245H263VideoMode_resolution { int t; } H245H263VideoMode_resolution; EXTERN int asn1PE_H245H263VideoMode_resolution (OOCTXT* pctxt, H245H263VideoMode_resolution* pvalue); EXTERN int asn1PD_H245H263VideoMode_resolution (OOCTXT* pctxt, H245H263VideoMode_resolution* pvalue); /**************************************************************/ /* */ /* H263VideoMode */ /* */ /**************************************************************/ typedef struct EXTERN H245H263VideoMode { struct { unsigned errorCompensationPresent : 1; unsigned enhancementLayerInfoPresent : 1; unsigned h263OptionsPresent : 1; } m; H245H263VideoMode_resolution resolution; ASN1USINT bitRate; ASN1BOOL unrestrictedVector; ASN1BOOL arithmeticCoding; ASN1BOOL advancedPrediction; ASN1BOOL pbFrames; ASN1BOOL errorCompensation; H245EnhancementLayerInfo enhancementLayerInfo; H245H263Options h263Options; } H245H263VideoMode; EXTERN int asn1PE_H245H263VideoMode (OOCTXT* pctxt, H245H263VideoMode* pvalue); EXTERN int asn1PD_H245H263VideoMode (OOCTXT* pctxt, H245H263VideoMode* pvalue); /**************************************************************/ /* */ /* IS11172VideoMode */ /* */ /**************************************************************/ typedef struct EXTERN H245IS11172VideoMode { struct { unsigned videoBitRatePresent : 1; unsigned vbvBufferSizePresent : 1; unsigned samplesPerLinePresent : 1; unsigned linesPerFramePresent : 1; unsigned pictureRatePresent : 1; unsigned luminanceSampleRatePresent : 1; } m; ASN1BOOL constrainedBitstream; ASN1UINT videoBitRate; ASN1UINT vbvBufferSize; ASN1USINT samplesPerLine; ASN1USINT linesPerFrame; ASN1UINT8 pictureRate; ASN1UINT luminanceSampleRate; } H245IS11172VideoMode; EXTERN int asn1PE_H245IS11172VideoMode (OOCTXT* pctxt, H245IS11172VideoMode* pvalue); EXTERN int asn1PD_H245IS11172VideoMode (OOCTXT* pctxt, H245IS11172VideoMode* pvalue); /**************************************************************/ /* */ /* VideoMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245VideoMode_nonStandard 1 #define T_H245VideoMode_h261VideoMode 2 #define T_H245VideoMode_h262VideoMode 3 #define T_H245VideoMode_h263VideoMode 4 #define T_H245VideoMode_is11172VideoMode 5 #define T_H245VideoMode_genericVideoMode 6 #define T_H245VideoMode_extElem1 7 typedef struct EXTERN H245VideoMode { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245H261VideoMode *h261VideoMode; /* t = 3 */ H245H262VideoMode *h262VideoMode; /* t = 4 */ H245H263VideoMode *h263VideoMode; /* t = 5 */ H245IS11172VideoMode *is11172VideoMode; /* t = 6 */ H245GenericCapability *genericVideoMode; /* t = 7 */ } u; } H245VideoMode; EXTERN int asn1PE_H245VideoMode (OOCTXT* pctxt, H245VideoMode* pvalue); EXTERN int asn1PD_H245VideoMode (OOCTXT* pctxt, H245VideoMode* pvalue); /**************************************************************/ /* */ /* AudioMode_g7231 */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245AudioMode_g7231_noSilenceSuppressionLowRate 1 #define T_H245AudioMode_g7231_noSilenceSuppressionHighRate 2 #define T_H245AudioMode_g7231_silenceSuppressionLowRate 3 #define T_H245AudioMode_g7231_silenceSuppressionHighRate 4 typedef struct EXTERN H245AudioMode_g7231 { int t; } H245AudioMode_g7231; EXTERN int asn1PE_H245AudioMode_g7231 (OOCTXT* pctxt, H245AudioMode_g7231* pvalue); EXTERN int asn1PD_H245AudioMode_g7231 (OOCTXT* pctxt, H245AudioMode_g7231* pvalue); /**************************************************************/ /* */ /* IS11172AudioMode_audioLayer */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245IS11172AudioMode_audioLayer_audioLayer1 1 #define T_H245IS11172AudioMode_audioLayer_audioLayer2 2 #define T_H245IS11172AudioMode_audioLayer_audioLayer3 3 typedef struct EXTERN H245IS11172AudioMode_audioLayer { int t; } H245IS11172AudioMode_audioLayer; EXTERN int asn1PE_H245IS11172AudioMode_audioLayer (OOCTXT* pctxt, H245IS11172AudioMode_audioLayer* pvalue); EXTERN int asn1PD_H245IS11172AudioMode_audioLayer (OOCTXT* pctxt, H245IS11172AudioMode_audioLayer* pvalue); /**************************************************************/ /* */ /* IS11172AudioMode_audioSampling */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245IS11172AudioMode_audioSampling_audioSampling32k 1 #define T_H245IS11172AudioMode_audioSampling_audioSampling44k1 2 #define T_H245IS11172AudioMode_audioSampling_audioSampling48k 3 typedef struct EXTERN H245IS11172AudioMode_audioSampling { int t; } H245IS11172AudioMode_audioSampling; EXTERN int asn1PE_H245IS11172AudioMode_audioSampling (OOCTXT* pctxt, H245IS11172AudioMode_audioSampling* pvalue); EXTERN int asn1PD_H245IS11172AudioMode_audioSampling (OOCTXT* pctxt, H245IS11172AudioMode_audioSampling* pvalue); /**************************************************************/ /* */ /* IS11172AudioMode_multichannelType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245IS11172AudioMode_multichannelType_singleChannel 1 #define T_H245IS11172AudioMode_multichannelType_twoChannelStereo 2 #define T_H245IS11172AudioMode_multichannelType_twoChannelDual 3 typedef struct EXTERN H245IS11172AudioMode_multichannelType { int t; } H245IS11172AudioMode_multichannelType; EXTERN int asn1PE_H245IS11172AudioMode_multichannelType (OOCTXT* pctxt, H245IS11172AudioMode_multichannelType* pvalue); EXTERN int asn1PD_H245IS11172AudioMode_multichannelType (OOCTXT* pctxt, H245IS11172AudioMode_multichannelType* pvalue); /**************************************************************/ /* */ /* IS11172AudioMode */ /* */ /**************************************************************/ typedef struct EXTERN H245IS11172AudioMode { H245IS11172AudioMode_audioLayer audioLayer; H245IS11172AudioMode_audioSampling audioSampling; H245IS11172AudioMode_multichannelType multichannelType; ASN1USINT bitRate; } H245IS11172AudioMode; EXTERN int asn1PE_H245IS11172AudioMode (OOCTXT* pctxt, H245IS11172AudioMode* pvalue); EXTERN int asn1PD_H245IS11172AudioMode (OOCTXT* pctxt, H245IS11172AudioMode* pvalue); /**************************************************************/ /* */ /* IS13818AudioMode_audioLayer */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245IS13818AudioMode_audioLayer_audioLayer1 1 #define T_H245IS13818AudioMode_audioLayer_audioLayer2 2 #define T_H245IS13818AudioMode_audioLayer_audioLayer3 3 typedef struct EXTERN H245IS13818AudioMode_audioLayer { int t; } H245IS13818AudioMode_audioLayer; EXTERN int asn1PE_H245IS13818AudioMode_audioLayer (OOCTXT* pctxt, H245IS13818AudioMode_audioLayer* pvalue); EXTERN int asn1PD_H245IS13818AudioMode_audioLayer (OOCTXT* pctxt, H245IS13818AudioMode_audioLayer* pvalue); /**************************************************************/ /* */ /* IS13818AudioMode_audioSampling */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245IS13818AudioMode_audioSampling_audioSampling16k 1 #define T_H245IS13818AudioMode_audioSampling_audioSampling22k05 2 #define T_H245IS13818AudioMode_audioSampling_audioSampling24k 3 #define T_H245IS13818AudioMode_audioSampling_audioSampling32k 4 #define T_H245IS13818AudioMode_audioSampling_audioSampling44k1 5 #define T_H245IS13818AudioMode_audioSampling_audioSampling48k 6 typedef struct EXTERN H245IS13818AudioMode_audioSampling { int t; } H245IS13818AudioMode_audioSampling; EXTERN int asn1PE_H245IS13818AudioMode_audioSampling (OOCTXT* pctxt, H245IS13818AudioMode_audioSampling* pvalue); EXTERN int asn1PD_H245IS13818AudioMode_audioSampling (OOCTXT* pctxt, H245IS13818AudioMode_audioSampling* pvalue); /**************************************************************/ /* */ /* IS13818AudioMode_multichannelType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245IS13818AudioMode_multichannelType_singleChannel 1 #define T_H245IS13818AudioMode_multichannelType_twoChannelStereo 2 #define T_H245IS13818AudioMode_multichannelType_twoChannelDual 3 #define T_H245IS13818AudioMode_multichannelType_threeChannels2_1 4 #define T_H245IS13818AudioMode_multichannelType_threeChannels3_0 5 #define T_H245IS13818AudioMode_multichannelType_fourChannels2_0_2_0 6 #define T_H245IS13818AudioMode_multichannelType_fourChannels2_2 7 #define T_H245IS13818AudioMode_multichannelType_fourChannels3_1 8 #define T_H245IS13818AudioMode_multichannelType_fiveChannels3_0_2_0 9 #define T_H245IS13818AudioMode_multichannelType_fiveChannels3_2 10 typedef struct EXTERN H245IS13818AudioMode_multichannelType { int t; } H245IS13818AudioMode_multichannelType; EXTERN int asn1PE_H245IS13818AudioMode_multichannelType (OOCTXT* pctxt, H245IS13818AudioMode_multichannelType* pvalue); EXTERN int asn1PD_H245IS13818AudioMode_multichannelType (OOCTXT* pctxt, H245IS13818AudioMode_multichannelType* pvalue); /**************************************************************/ /* */ /* IS13818AudioMode */ /* */ /**************************************************************/ typedef struct EXTERN H245IS13818AudioMode { H245IS13818AudioMode_audioLayer audioLayer; H245IS13818AudioMode_audioSampling audioSampling; H245IS13818AudioMode_multichannelType multichannelType; ASN1BOOL lowFrequencyEnhancement; ASN1BOOL multilingual; ASN1USINT bitRate; } H245IS13818AudioMode; EXTERN int asn1PE_H245IS13818AudioMode (OOCTXT* pctxt, H245IS13818AudioMode* pvalue); EXTERN int asn1PD_H245IS13818AudioMode (OOCTXT* pctxt, H245IS13818AudioMode* pvalue); /**************************************************************/ /* */ /* G7231AnnexCMode_g723AnnexCAudioMode */ /* */ /**************************************************************/ typedef struct EXTERN H245G7231AnnexCMode_g723AnnexCAudioMode { ASN1UINT8 highRateMode0; ASN1UINT8 highRateMode1; ASN1UINT8 lowRateMode0; ASN1UINT8 lowRateMode1; ASN1UINT8 sidMode0; ASN1UINT8 sidMode1; } H245G7231AnnexCMode_g723AnnexCAudioMode; EXTERN int asn1PE_H245G7231AnnexCMode_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCMode_g723AnnexCAudioMode* pvalue); EXTERN int asn1PD_H245G7231AnnexCMode_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCMode_g723AnnexCAudioMode* pvalue); /**************************************************************/ /* */ /* G7231AnnexCMode */ /* */ /**************************************************************/ typedef struct EXTERN H245G7231AnnexCMode { ASN1USINT maxAl_sduAudioFrames; ASN1BOOL silenceSuppression; H245G7231AnnexCMode_g723AnnexCAudioMode g723AnnexCAudioMode; } H245G7231AnnexCMode; EXTERN int asn1PE_H245G7231AnnexCMode (OOCTXT* pctxt, H245G7231AnnexCMode* pvalue); EXTERN int asn1PD_H245G7231AnnexCMode (OOCTXT* pctxt, H245G7231AnnexCMode* pvalue); /**************************************************************/ /* */ /* VBDMode */ /* */ /**************************************************************/ typedef struct EXTERN H245VBDMode { struct H245AudioMode *type; } H245VBDMode; EXTERN int asn1PE_H245VBDMode (OOCTXT* pctxt, H245VBDMode* pvalue); EXTERN int asn1PD_H245VBDMode (OOCTXT* pctxt, H245VBDMode* pvalue); /**************************************************************/ /* */ /* AudioMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245AudioMode_nonStandard 1 #define T_H245AudioMode_g711Alaw64k 2 #define T_H245AudioMode_g711Alaw56k 3 #define T_H245AudioMode_g711Ulaw64k 4 #define T_H245AudioMode_g711Ulaw56k 5 #define T_H245AudioMode_g722_64k 6 #define T_H245AudioMode_g722_56k 7 #define T_H245AudioMode_g722_48k 8 #define T_H245AudioMode_g728 9 #define T_H245AudioMode_g729 10 #define T_H245AudioMode_g729AnnexA 11 #define T_H245AudioMode_g7231 12 #define T_H245AudioMode_is11172AudioMode 13 #define T_H245AudioMode_is13818AudioMode 14 #define T_H245AudioMode_g729wAnnexB 15 #define T_H245AudioMode_g729AnnexAwAnnexB 16 #define T_H245AudioMode_g7231AnnexCMode 17 #define T_H245AudioMode_gsmFullRate 18 #define T_H245AudioMode_gsmHalfRate 19 #define T_H245AudioMode_gsmEnhancedFullRate 20 #define T_H245AudioMode_genericAudioMode 21 #define T_H245AudioMode_g729Extensions 22 #define T_H245AudioMode_vbd 23 #define T_H245AudioMode_extElem1 24 typedef struct EXTERN H245AudioMode { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ /* t = 10 */ /* t = 11 */ /* t = 12 */ H245AudioMode_g7231 *g7231; /* t = 13 */ H245IS11172AudioMode *is11172AudioMode; /* t = 14 */ H245IS13818AudioMode *is13818AudioMode; /* t = 15 */ ASN1USINT g729wAnnexB; /* t = 16 */ ASN1USINT g729AnnexAwAnnexB; /* t = 17 */ H245G7231AnnexCMode *g7231AnnexCMode; /* t = 18 */ H245GSMAudioCapability *gsmFullRate; /* t = 19 */ H245GSMAudioCapability *gsmHalfRate; /* t = 20 */ H245GSMAudioCapability *gsmEnhancedFullRate; /* t = 21 */ H245GenericCapability *genericAudioMode; /* t = 22 */ H245G729Extensions *g729Extensions; /* t = 23 */ H245VBDMode *vbd; /* t = 24 */ } u; } H245AudioMode; EXTERN int asn1PE_H245AudioMode (OOCTXT* pctxt, H245AudioMode* pvalue); EXTERN int asn1PD_H245AudioMode (OOCTXT* pctxt, H245AudioMode* pvalue); /**************************************************************/ /* */ /* DataMode_application_nlpid */ /* */ /**************************************************************/ typedef struct EXTERN H245DataMode_application_nlpid { H245DataProtocolCapability nlpidProtocol; ASN1DynOctStr nlpidData; } H245DataMode_application_nlpid; EXTERN int asn1PE_H245DataMode_application_nlpid (OOCTXT* pctxt, H245DataMode_application_nlpid* pvalue); EXTERN int asn1PD_H245DataMode_application_nlpid (OOCTXT* pctxt, H245DataMode_application_nlpid* pvalue); /**************************************************************/ /* */ /* DataMode_application_t38fax */ /* */ /**************************************************************/ typedef struct EXTERN H245DataMode_application_t38fax { H245DataProtocolCapability t38FaxProtocol; H245T38FaxProfile t38FaxProfile; } H245DataMode_application_t38fax; EXTERN int asn1PE_H245DataMode_application_t38fax (OOCTXT* pctxt, H245DataMode_application_t38fax* pvalue); EXTERN int asn1PD_H245DataMode_application_t38fax (OOCTXT* pctxt, H245DataMode_application_t38fax* pvalue); /**************************************************************/ /* */ /* DataMode_application */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245DataMode_application_nonStandard 1 #define T_H245DataMode_application_t120 2 #define T_H245DataMode_application_dsm_cc 3 #define T_H245DataMode_application_userData 4 #define T_H245DataMode_application_t84 5 #define T_H245DataMode_application_t434 6 #define T_H245DataMode_application_h224 7 #define T_H245DataMode_application_nlpid 8 #define T_H245DataMode_application_dsvdControl 9 #define T_H245DataMode_application_h222DataPartitioning 10 #define T_H245DataMode_application_t30fax 11 #define T_H245DataMode_application_t140 12 #define T_H245DataMode_application_t38fax 13 #define T_H245DataMode_application_genericDataMode 14 #define T_H245DataMode_application_extElem1 15 typedef struct EXTERN H245DataMode_application { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245DataProtocolCapability *t120; /* t = 3 */ H245DataProtocolCapability *dsm_cc; /* t = 4 */ H245DataProtocolCapability *userData; /* t = 5 */ H245DataProtocolCapability *t84; /* t = 6 */ H245DataProtocolCapability *t434; /* t = 7 */ H245DataProtocolCapability *h224; /* t = 8 */ H245DataMode_application_nlpid *nlpid; /* t = 9 */ /* t = 10 */ H245DataProtocolCapability *h222DataPartitioning; /* t = 11 */ H245DataProtocolCapability *t30fax; /* t = 12 */ H245DataProtocolCapability *t140; /* t = 13 */ H245DataMode_application_t38fax *t38fax; /* t = 14 */ H245GenericCapability *genericDataMode; /* t = 15 */ } u; } H245DataMode_application; EXTERN int asn1PE_H245DataMode_application (OOCTXT* pctxt, H245DataMode_application* pvalue); EXTERN int asn1PD_H245DataMode_application (OOCTXT* pctxt, H245DataMode_application* pvalue); /**************************************************************/ /* */ /* DataMode */ /* */ /**************************************************************/ typedef struct EXTERN H245DataMode { H245DataMode_application application; ASN1UINT bitRate; } H245DataMode; EXTERN int asn1PE_H245DataMode (OOCTXT* pctxt, H245DataMode* pvalue); EXTERN int asn1PD_H245DataMode (OOCTXT* pctxt, H245DataMode* pvalue); /**************************************************************/ /* */ /* H235Mode_mediaMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H235Mode_mediaMode_nonStandard 1 #define T_H245H235Mode_mediaMode_videoMode 2 #define T_H245H235Mode_mediaMode_audioMode 3 #define T_H245H235Mode_mediaMode_dataMode 4 #define T_H245H235Mode_mediaMode_extElem1 5 typedef struct EXTERN H245H235Mode_mediaMode { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245VideoMode *videoMode; /* t = 3 */ H245AudioMode *audioMode; /* t = 4 */ H245DataMode *dataMode; /* t = 5 */ } u; } H245H235Mode_mediaMode; EXTERN int asn1PE_H245H235Mode_mediaMode (OOCTXT* pctxt, H245H235Mode_mediaMode* pvalue); EXTERN int asn1PD_H245H235Mode_mediaMode (OOCTXT* pctxt, H245H235Mode_mediaMode* pvalue); /**************************************************************/ /* */ /* H235Mode */ /* */ /**************************************************************/ typedef struct EXTERN H245H235Mode { H245EncryptionAuthenticationAndIntegrity encryptionAuthenticationAndIntegrity; H245H235Mode_mediaMode mediaMode; } H245H235Mode; EXTERN int asn1PE_H245H235Mode (OOCTXT* pctxt, H245H235Mode* pvalue); EXTERN int asn1PD_H245H235Mode (OOCTXT* pctxt, H245H235Mode* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingDTModeElement_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RedundancyEncodingDTModeElement_type_nonStandard 1 #define T_H245RedundancyEncodingDTModeElement_type_videoMode 2 #define T_H245RedundancyEncodingDTModeElement_type_audioMode 3 #define T_H245RedundancyEncodingDTModeElement_type_dataMode 4 #define T_H245RedundancyEncodingDTModeElement_type_encryptionMode 5 #define T_H245RedundancyEncodingDTModeElement_type_h235Mode 6 #define T_H245RedundancyEncodingDTModeElement_type_extElem1 7 typedef struct EXTERN H245RedundancyEncodingDTModeElement_type { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245VideoMode *videoMode; /* t = 3 */ H245AudioMode *audioMode; /* t = 4 */ H245DataMode *dataMode; /* t = 5 */ H245EncryptionMode *encryptionMode; /* t = 6 */ H245H235Mode *h235Mode; /* t = 7 */ } u; } H245RedundancyEncodingDTModeElement_type; EXTERN int asn1PE_H245RedundancyEncodingDTModeElement_type (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement_type* pvalue); EXTERN int asn1PD_H245RedundancyEncodingDTModeElement_type (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement_type* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingDTModeElement */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncodingDTModeElement { H245RedundancyEncodingDTModeElement_type type; } H245RedundancyEncodingDTModeElement; EXTERN int asn1PE_H245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement* pvalue); EXTERN int asn1PD_H245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement* pvalue); /**************************************************************/ /* */ /* _SeqOfH245RedundancyEncodingDTModeElement */ /* */ /**************************************************************/ /* List of H245RedundancyEncodingDTModeElement */ typedef DList H245_SeqOfH245RedundancyEncodingDTModeElement; EXTERN int asn1PE_H245_SeqOfH245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingDTModeElement* pvalue); EXTERN int asn1PD_H245_SeqOfH245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingDTModeElement* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingDTMode */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncodingDTMode { H245RedundancyEncodingMethod redundancyEncodingMethod; H245RedundancyEncodingDTModeElement primary; H245_SeqOfH245RedundancyEncodingDTModeElement secondary; } H245RedundancyEncodingDTMode; EXTERN int asn1PE_H245RedundancyEncodingDTMode (OOCTXT* pctxt, H245RedundancyEncodingDTMode* pvalue); EXTERN int asn1PD_H245RedundancyEncodingDTMode (OOCTXT* pctxt, H245RedundancyEncodingDTMode* pvalue); /**************************************************************/ /* */ /* MultiplePayloadStreamElementMode */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplePayloadStreamElementMode { struct H245ModeElementType *type; } H245MultiplePayloadStreamElementMode; EXTERN int asn1PE_H245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245MultiplePayloadStreamElementMode* pvalue); EXTERN int asn1PD_H245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245MultiplePayloadStreamElementMode* pvalue); /**************************************************************/ /* */ /* _SeqOfH245MultiplePayloadStreamElementMode */ /* */ /**************************************************************/ /* List of H245MultiplePayloadStreamElementMode */ typedef DList H245_SeqOfH245MultiplePayloadStreamElementMode; EXTERN int asn1PE_H245_SeqOfH245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElementMode* pvalue); EXTERN int asn1PD_H245_SeqOfH245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElementMode* pvalue); /**************************************************************/ /* */ /* MultiplePayloadStreamMode */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplePayloadStreamMode { H245_SeqOfH245MultiplePayloadStreamElementMode elements; } H245MultiplePayloadStreamMode; EXTERN int asn1PE_H245MultiplePayloadStreamMode (OOCTXT* pctxt, H245MultiplePayloadStreamMode* pvalue); EXTERN int asn1PD_H245MultiplePayloadStreamMode (OOCTXT* pctxt, H245MultiplePayloadStreamMode* pvalue); /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream_differentPort */ /* */ /**************************************************************/ typedef struct EXTERN H245FECMode_rfc2733Mode_mode_separateStream_differentPort { struct { unsigned protectedPayloadTypePresent : 1; } m; ASN1UINT8 protectedSessionID; ASN1UINT8 protectedPayloadType; } H245FECMode_rfc2733Mode_mode_separateStream_differentPort; EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_differentPort* pvalue); EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_differentPort* pvalue); /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream_samePort */ /* */ /**************************************************************/ typedef struct EXTERN H245FECMode_rfc2733Mode_mode_separateStream_samePort { struct H245ModeElementType *protectedType; } H245FECMode_rfc2733Mode_mode_separateStream_samePort; EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode_separateStream_samePort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_samePort* pvalue); EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode_separateStream_samePort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_samePort* pvalue); /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FECMode_rfc2733Mode_mode_separateStream_differentPort 1 #define T_H245FECMode_rfc2733Mode_mode_separateStream_samePort 2 #define T_H245FECMode_rfc2733Mode_mode_separateStream_extElem1 3 typedef struct EXTERN H245FECMode_rfc2733Mode_mode_separateStream { int t; union { /* t = 1 */ H245FECMode_rfc2733Mode_mode_separateStream_differentPort *differentPort; /* t = 2 */ H245FECMode_rfc2733Mode_mode_separateStream_samePort *samePort; /* t = 3 */ } u; } H245FECMode_rfc2733Mode_mode_separateStream; EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode_separateStream (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream* pvalue); EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode_separateStream (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream* pvalue); /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FECMode_rfc2733Mode_mode_redundancyEncoding 1 #define T_H245FECMode_rfc2733Mode_mode_separateStream 2 #define T_H245FECMode_rfc2733Mode_mode_extElem1 3 typedef struct EXTERN H245FECMode_rfc2733Mode_mode { int t; union { /* t = 1 */ /* t = 2 */ H245FECMode_rfc2733Mode_mode_separateStream *separateStream; /* t = 3 */ } u; } H245FECMode_rfc2733Mode_mode; EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode* pvalue); EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode* pvalue); /**************************************************************/ /* */ /* FECMode_rfc2733Mode */ /* */ /**************************************************************/ typedef struct EXTERN H245FECMode_rfc2733Mode { H245FECMode_rfc2733Mode_mode mode; } H245FECMode_rfc2733Mode; EXTERN int asn1PE_H245FECMode_rfc2733Mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode* pvalue); EXTERN int asn1PD_H245FECMode_rfc2733Mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode* pvalue); /**************************************************************/ /* */ /* FECMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FECMode_rfc2733Mode 1 #define T_H245FECMode_extElem1 2 typedef struct EXTERN H245FECMode { int t; union { /* t = 1 */ H245FECMode_rfc2733Mode *rfc2733Mode; /* t = 2 */ } u; } H245FECMode; EXTERN int asn1PE_H245FECMode (OOCTXT* pctxt, H245FECMode* pvalue); EXTERN int asn1PD_H245FECMode (OOCTXT* pctxt, H245FECMode* pvalue); /**************************************************************/ /* */ /* ModeElementType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ModeElementType_nonStandard 1 #define T_H245ModeElementType_videoMode 2 #define T_H245ModeElementType_audioMode 3 #define T_H245ModeElementType_dataMode 4 #define T_H245ModeElementType_encryptionMode 5 #define T_H245ModeElementType_h235Mode 6 #define T_H245ModeElementType_multiplexedStreamMode 7 #define T_H245ModeElementType_redundancyEncodingDTMode 8 #define T_H245ModeElementType_multiplePayloadStreamMode 9 #define T_H245ModeElementType_fecMode 10 #define T_H245ModeElementType_extElem1 11 typedef struct EXTERN H245ModeElementType { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245VideoMode *videoMode; /* t = 3 */ H245AudioMode *audioMode; /* t = 4 */ H245DataMode *dataMode; /* t = 5 */ H245EncryptionMode *encryptionMode; /* t = 6 */ H245H235Mode *h235Mode; /* t = 7 */ H245MultiplexedStreamParameter *multiplexedStreamMode; /* t = 8 */ H245RedundancyEncodingDTMode *redundancyEncodingDTMode; /* t = 9 */ H245MultiplePayloadStreamMode *multiplePayloadStreamMode; /* t = 10 */ H245FECMode *fecMode; /* t = 11 */ } u; } H245ModeElementType; EXTERN int asn1PE_H245ModeElementType (OOCTXT* pctxt, H245ModeElementType* pvalue); EXTERN int asn1PD_H245ModeElementType (OOCTXT* pctxt, H245ModeElementType* pvalue); /**************************************************************/ /* */ /* H223ModeParameters_adaptationLayerType_al3 */ /* */ /**************************************************************/ typedef struct EXTERN H245H223ModeParameters_adaptationLayerType_al3 { ASN1UINT8 controlFieldOctets; ASN1UINT sendBufferSize; } H245H223ModeParameters_adaptationLayerType_al3; EXTERN int asn1PE_H245H223ModeParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType_al3* pvalue); EXTERN int asn1PD_H245H223ModeParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType_al3* pvalue); /**************************************************************/ /* */ /* H223ModeParameters_adaptationLayerType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223ModeParameters_adaptationLayerType_nonStandard 1 #define T_H245H223ModeParameters_adaptationLayerType_al1Framed 2 #define T_H245H223ModeParameters_adaptationLayerType_al1NotFramed 3 #define T_H245H223ModeParameters_adaptationLayerType_al2WithoutSequenceNumbers 4 #define T_H245H223ModeParameters_adaptationLayerType_al2WithSequenceNumbers 5 #define T_H245H223ModeParameters_adaptationLayerType_al3 6 #define T_H245H223ModeParameters_adaptationLayerType_al1M 7 #define T_H245H223ModeParameters_adaptationLayerType_al2M 8 #define T_H245H223ModeParameters_adaptationLayerType_al3M 9 #define T_H245H223ModeParameters_adaptationLayerType_extElem1 10 typedef struct EXTERN H245H223ModeParameters_adaptationLayerType { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ H245H223ModeParameters_adaptationLayerType_al3 *al3; /* t = 7 */ H245H223AL1MParameters *al1M; /* t = 8 */ H245H223AL2MParameters *al2M; /* t = 9 */ H245H223AL3MParameters *al3M; /* t = 10 */ } u; } H245H223ModeParameters_adaptationLayerType; EXTERN int asn1PE_H245H223ModeParameters_adaptationLayerType (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType* pvalue); EXTERN int asn1PD_H245H223ModeParameters_adaptationLayerType (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType* pvalue); /**************************************************************/ /* */ /* H223ModeParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H223ModeParameters { H245H223ModeParameters_adaptationLayerType adaptationLayerType; ASN1BOOL segmentableFlag; } H245H223ModeParameters; EXTERN int asn1PE_H245H223ModeParameters (OOCTXT* pctxt, H245H223ModeParameters* pvalue); EXTERN int asn1PD_H245H223ModeParameters (OOCTXT* pctxt, H245H223ModeParameters* pvalue); /**************************************************************/ /* */ /* V76ModeParameters */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245V76ModeParameters_suspendResumewAddress 1 #define T_H245V76ModeParameters_suspendResumewoAddress 2 #define T_H245V76ModeParameters_extElem1 3 typedef struct EXTERN H245V76ModeParameters { int t; } H245V76ModeParameters; EXTERN int asn1PE_H245V76ModeParameters (OOCTXT* pctxt, H245V76ModeParameters* pvalue); EXTERN int asn1PD_H245V76ModeParameters (OOCTXT* pctxt, H245V76ModeParameters* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingMode_secondaryEncoding */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RedundancyEncodingMode_secondaryEncoding_nonStandard 1 #define T_H245RedundancyEncodingMode_secondaryEncoding_audioData 2 #define T_H245RedundancyEncodingMode_secondaryEncoding_extElem1 3 typedef struct EXTERN H245RedundancyEncodingMode_secondaryEncoding { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ H245AudioMode *audioData; /* t = 3 */ } u; } H245RedundancyEncodingMode_secondaryEncoding; EXTERN int asn1PE_H245RedundancyEncodingMode_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingMode_secondaryEncoding* pvalue); EXTERN int asn1PD_H245RedundancyEncodingMode_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingMode_secondaryEncoding* pvalue); /**************************************************************/ /* */ /* RedundancyEncodingMode */ /* */ /**************************************************************/ typedef struct EXTERN H245RedundancyEncodingMode { struct { unsigned secondaryEncodingPresent : 1; } m; H245RedundancyEncodingMethod redundancyEncodingMethod; H245RedundancyEncodingMode_secondaryEncoding secondaryEncoding; } H245RedundancyEncodingMode; EXTERN int asn1PE_H245RedundancyEncodingMode (OOCTXT* pctxt, H245RedundancyEncodingMode* pvalue); EXTERN int asn1PD_H245RedundancyEncodingMode (OOCTXT* pctxt, H245RedundancyEncodingMode* pvalue); /**************************************************************/ /* */ /* H2250ModeParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H2250ModeParameters { struct { unsigned redundancyEncodingModePresent : 1; } m; H245RedundancyEncodingMode redundancyEncodingMode; } H245H2250ModeParameters; EXTERN int asn1PE_H245H2250ModeParameters (OOCTXT* pctxt, H245H2250ModeParameters* pvalue); EXTERN int asn1PD_H245H2250ModeParameters (OOCTXT* pctxt, H245H2250ModeParameters* pvalue); /**************************************************************/ /* */ /* MultiplexedStreamModeParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexedStreamModeParameters { H245LogicalChannelNumber logicalChannelNumber; } H245MultiplexedStreamModeParameters; EXTERN int asn1PE_H245MultiplexedStreamModeParameters (OOCTXT* pctxt, H245MultiplexedStreamModeParameters* pvalue); EXTERN int asn1PD_H245MultiplexedStreamModeParameters (OOCTXT* pctxt, H245MultiplexedStreamModeParameters* pvalue); /**************************************************************/ /* */ /* ModeElement */ /* */ /**************************************************************/ typedef struct EXTERN H245ModeElement { struct { unsigned h223ModeParametersPresent : 1; unsigned v76ModeParametersPresent : 1; unsigned h2250ModeParametersPresent : 1; unsigned genericModeParametersPresent : 1; unsigned multiplexedStreamModeParametersPresent : 1; } m; H245ModeElementType type; H245H223ModeParameters h223ModeParameters; H245V76ModeParameters v76ModeParameters; H245H2250ModeParameters h2250ModeParameters; H245GenericCapability genericModeParameters; H245MultiplexedStreamModeParameters multiplexedStreamModeParameters; } H245ModeElement; EXTERN int asn1PE_H245ModeElement (OOCTXT* pctxt, H245ModeElement* pvalue); EXTERN int asn1PD_H245ModeElement (OOCTXT* pctxt, H245ModeElement* pvalue); /**************************************************************/ /* */ /* ModeDescription */ /* */ /**************************************************************/ /* List of H245ModeElement */ typedef DList H245ModeDescription; EXTERN int asn1PE_H245ModeDescription (OOCTXT* pctxt, H245ModeDescription* pvalue); EXTERN int asn1PD_H245ModeDescription (OOCTXT* pctxt, H245ModeDescription* pvalue); /**************************************************************/ /* */ /* RequestMode_requestedModes */ /* */ /**************************************************************/ /* List of H245ModeDescription */ typedef DList H245RequestMode_requestedModes; EXTERN int asn1PE_H245RequestMode_requestedModes (OOCTXT* pctxt, H245RequestMode_requestedModes* pvalue); EXTERN int asn1PD_H245RequestMode_requestedModes (OOCTXT* pctxt, H245RequestMode_requestedModes* pvalue); /**************************************************************/ /* */ /* RequestMode */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMode { H245SequenceNumber sequenceNumber; H245RequestMode_requestedModes requestedModes; } H245RequestMode; EXTERN int asn1PE_H245RequestMode (OOCTXT* pctxt, H245RequestMode* pvalue); EXTERN int asn1PD_H245RequestMode (OOCTXT* pctxt, H245RequestMode* pvalue); /**************************************************************/ /* */ /* RoundTripDelayRequest */ /* */ /**************************************************************/ typedef struct EXTERN H245RoundTripDelayRequest { H245SequenceNumber sequenceNumber; } H245RoundTripDelayRequest; EXTERN int asn1PE_H245RoundTripDelayRequest (OOCTXT* pctxt, H245RoundTripDelayRequest* pvalue); EXTERN int asn1PD_H245RoundTripDelayRequest (OOCTXT* pctxt, H245RoundTripDelayRequest* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopRequest_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MaintenanceLoopRequest_type_systemLoop 1 #define T_H245MaintenanceLoopRequest_type_mediaLoop 2 #define T_H245MaintenanceLoopRequest_type_logicalChannelLoop 3 #define T_H245MaintenanceLoopRequest_type_extElem1 4 typedef struct EXTERN H245MaintenanceLoopRequest_type { int t; union { /* t = 1 */ /* t = 2 */ H245LogicalChannelNumber mediaLoop; /* t = 3 */ H245LogicalChannelNumber logicalChannelLoop; /* t = 4 */ } u; } H245MaintenanceLoopRequest_type; EXTERN int asn1PE_H245MaintenanceLoopRequest_type (OOCTXT* pctxt, H245MaintenanceLoopRequest_type* pvalue); EXTERN int asn1PD_H245MaintenanceLoopRequest_type (OOCTXT* pctxt, H245MaintenanceLoopRequest_type* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopRequest */ /* */ /**************************************************************/ typedef struct EXTERN H245MaintenanceLoopRequest { H245MaintenanceLoopRequest_type type; } H245MaintenanceLoopRequest; EXTERN int asn1PE_H245MaintenanceLoopRequest (OOCTXT* pctxt, H245MaintenanceLoopRequest* pvalue); EXTERN int asn1PD_H245MaintenanceLoopRequest (OOCTXT* pctxt, H245MaintenanceLoopRequest* pvalue); /**************************************************************/ /* */ /* CommunicationModeRequest */ /* */ /**************************************************************/ typedef struct EXTERN H245CommunicationModeRequest { ASN1OCTET __dummy__; } H245CommunicationModeRequest; EXTERN int asn1PE_H245CommunicationModeRequest (OOCTXT* pctxt, H245CommunicationModeRequest* pvalue); EXTERN int asn1PD_H245CommunicationModeRequest (OOCTXT* pctxt, H245CommunicationModeRequest* pvalue); /**************************************************************/ /* */ /* Criteria */ /* */ /**************************************************************/ typedef struct EXTERN H245Criteria { ASN1OBJID field; ASN1DynOctStr value; } H245Criteria; EXTERN int asn1PE_H245Criteria (OOCTXT* pctxt, H245Criteria* pvalue); EXTERN int asn1PD_H245Criteria (OOCTXT* pctxt, H245Criteria* pvalue); /**************************************************************/ /* */ /* CertSelectionCriteria */ /* */ /**************************************************************/ /* List of H245Criteria */ typedef DList H245CertSelectionCriteria; EXTERN int asn1PE_H245CertSelectionCriteria (OOCTXT* pctxt, H245CertSelectionCriteria* pvalue); EXTERN int asn1PD_H245CertSelectionCriteria (OOCTXT* pctxt, H245CertSelectionCriteria* pvalue); /**************************************************************/ /* */ /* ConferenceRequest_requestTerminalCertificate */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceRequest_requestTerminalCertificate { struct { unsigned terminalLabelPresent : 1; unsigned certSelectionCriteriaPresent : 1; unsigned sRandomPresent : 1; } m; H245TerminalLabel terminalLabel; H245CertSelectionCriteria certSelectionCriteria; ASN1UINT sRandom; } H245ConferenceRequest_requestTerminalCertificate; EXTERN int asn1PE_H245ConferenceRequest_requestTerminalCertificate (OOCTXT* pctxt, H245ConferenceRequest_requestTerminalCertificate* pvalue); EXTERN int asn1PD_H245ConferenceRequest_requestTerminalCertificate (OOCTXT* pctxt, H245ConferenceRequest_requestTerminalCertificate* pvalue); /**************************************************************/ /* */ /* RemoteMCRequest */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RemoteMCRequest_masterActivate 1 #define T_H245RemoteMCRequest_slaveActivate 2 #define T_H245RemoteMCRequest_deActivate 3 #define T_H245RemoteMCRequest_extElem1 4 typedef struct EXTERN H245RemoteMCRequest { int t; } H245RemoteMCRequest; EXTERN int asn1PE_H245RemoteMCRequest (OOCTXT* pctxt, H245RemoteMCRequest* pvalue); EXTERN int asn1PD_H245RemoteMCRequest (OOCTXT* pctxt, H245RemoteMCRequest* pvalue); /**************************************************************/ /* */ /* ConferenceRequest */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceRequest_terminalListRequest 1 #define T_H245ConferenceRequest_makeMeChair 2 #define T_H245ConferenceRequest_cancelMakeMeChair 3 #define T_H245ConferenceRequest_dropTerminal 4 #define T_H245ConferenceRequest_requestTerminalID 5 #define T_H245ConferenceRequest_enterH243Password 6 #define T_H245ConferenceRequest_enterH243TerminalID 7 #define T_H245ConferenceRequest_enterH243ConferenceID 8 #define T_H245ConferenceRequest_enterExtensionAddress 9 #define T_H245ConferenceRequest_requestChairTokenOwner 10 #define T_H245ConferenceRequest_requestTerminalCertificate 11 #define T_H245ConferenceRequest_broadcastMyLogicalChannel 12 #define T_H245ConferenceRequest_makeTerminalBroadcaster 13 #define T_H245ConferenceRequest_sendThisSource 14 #define T_H245ConferenceRequest_requestAllTerminalIDs 15 #define T_H245ConferenceRequest_remoteMCRequest 16 #define T_H245ConferenceRequest_extElem1 17 typedef struct EXTERN H245ConferenceRequest { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ H245TerminalLabel *dropTerminal; /* t = 5 */ H245TerminalLabel *requestTerminalID; /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ /* t = 10 */ /* t = 11 */ H245ConferenceRequest_requestTerminalCertificate *requestTerminalCertificate; /* t = 12 */ H245LogicalChannelNumber broadcastMyLogicalChannel; /* t = 13 */ H245TerminalLabel *makeTerminalBroadcaster; /* t = 14 */ H245TerminalLabel *sendThisSource; /* t = 15 */ /* t = 16 */ H245RemoteMCRequest *remoteMCRequest; /* t = 17 */ } u; } H245ConferenceRequest; EXTERN int asn1PE_H245ConferenceRequest (OOCTXT* pctxt, H245ConferenceRequest* pvalue); EXTERN int asn1PD_H245ConferenceRequest (OOCTXT* pctxt, H245ConferenceRequest* pvalue); /**************************************************************/ /* */ /* MultilinkRequest_callInformation */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkRequest_callInformation { ASN1USINT maxNumberOfAdditionalConnections; } H245MultilinkRequest_callInformation; EXTERN int asn1PE_H245MultilinkRequest_callInformation (OOCTXT* pctxt, H245MultilinkRequest_callInformation* pvalue); EXTERN int asn1PD_H245MultilinkRequest_callInformation (OOCTXT* pctxt, H245MultilinkRequest_callInformation* pvalue); /**************************************************************/ /* */ /* DialingInformationNetworkType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245DialingInformationNetworkType_nonStandard 1 #define T_H245DialingInformationNetworkType_n_isdn 2 #define T_H245DialingInformationNetworkType_gstn 3 #define T_H245DialingInformationNetworkType_mobile 4 #define T_H245DialingInformationNetworkType_extElem1 5 typedef struct EXTERN H245DialingInformationNetworkType { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ } u; } H245DialingInformationNetworkType; EXTERN int asn1PE_H245DialingInformationNetworkType (OOCTXT* pctxt, H245DialingInformationNetworkType* pvalue); EXTERN int asn1PD_H245DialingInformationNetworkType (OOCTXT* pctxt, H245DialingInformationNetworkType* pvalue); /**************************************************************/ /* */ /* DialingInformationNumber_networkType */ /* */ /**************************************************************/ /* List of H245DialingInformationNetworkType */ typedef DList H245DialingInformationNumber_networkType; EXTERN int asn1PE_H245DialingInformationNumber_networkType (OOCTXT* pctxt, H245DialingInformationNumber_networkType* pvalue); EXTERN int asn1PD_H245DialingInformationNumber_networkType (OOCTXT* pctxt, H245DialingInformationNumber_networkType* pvalue); /**************************************************************/ /* */ /* DialingInformationNumber */ /* */ /**************************************************************/ typedef struct EXTERN H245DialingInformationNumber { struct { unsigned subAddressPresent : 1; } m; ASN1NumericString networkAddress; ASN1IA5String subAddress; H245DialingInformationNumber_networkType networkType; } H245DialingInformationNumber; EXTERN int asn1PE_H245DialingInformationNumber (OOCTXT* pctxt, H245DialingInformationNumber* pvalue); EXTERN int asn1PD_H245DialingInformationNumber (OOCTXT* pctxt, H245DialingInformationNumber* pvalue); /**************************************************************/ /* */ /* DialingInformation_differential */ /* */ /**************************************************************/ /* List of H245DialingInformationNumber */ typedef DList H245DialingInformation_differential; EXTERN int asn1PE_H245DialingInformation_differential (OOCTXT* pctxt, H245DialingInformation_differential* pvalue); EXTERN int asn1PD_H245DialingInformation_differential (OOCTXT* pctxt, H245DialingInformation_differential* pvalue); /**************************************************************/ /* */ /* DialingInformation */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245DialingInformation_nonStandard 1 #define T_H245DialingInformation_differential 2 #define T_H245DialingInformation_infoNotAvailable 3 #define T_H245DialingInformation_extElem1 4 typedef struct EXTERN H245DialingInformation { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245DialingInformation_differential *differential; /* t = 3 */ ASN1USINT infoNotAvailable; /* t = 4 */ } u; } H245DialingInformation; EXTERN int asn1PE_H245DialingInformation (OOCTXT* pctxt, H245DialingInformation* pvalue); EXTERN int asn1PD_H245DialingInformation (OOCTXT* pctxt, H245DialingInformation* pvalue); /**************************************************************/ /* */ /* MultilinkRequest_addConnection */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkRequest_addConnection { H245SequenceNumber sequenceNumber; H245DialingInformation dialingInformation; } H245MultilinkRequest_addConnection; EXTERN int asn1PE_H245MultilinkRequest_addConnection (OOCTXT* pctxt, H245MultilinkRequest_addConnection* pvalue); EXTERN int asn1PD_H245MultilinkRequest_addConnection (OOCTXT* pctxt, H245MultilinkRequest_addConnection* pvalue); /**************************************************************/ /* */ /* ConnectionIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H245ConnectionIdentifier { ASN1UINT channelTag; ASN1UINT sequenceNumber; } H245ConnectionIdentifier; EXTERN int asn1PE_H245ConnectionIdentifier (OOCTXT* pctxt, H245ConnectionIdentifier* pvalue); EXTERN int asn1PD_H245ConnectionIdentifier (OOCTXT* pctxt, H245ConnectionIdentifier* pvalue); /**************************************************************/ /* */ /* MultilinkRequest_removeConnection */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkRequest_removeConnection { H245ConnectionIdentifier connectionIdentifier; } H245MultilinkRequest_removeConnection; EXTERN int asn1PE_H245MultilinkRequest_removeConnection (OOCTXT* pctxt, H245MultilinkRequest_removeConnection* pvalue); EXTERN int asn1PD_H245MultilinkRequest_removeConnection (OOCTXT* pctxt, H245MultilinkRequest_removeConnection* pvalue); /**************************************************************/ /* */ /* MultilinkRequest_maximumHeaderInterval_requestType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultilinkRequest_maximumHeaderInterval_requestType_currentIntervalInformation 1 #define T_H245MultilinkRequest_maximumHeaderInterval_requestType_requestedInterval 2 #define T_H245MultilinkRequest_maximumHeaderInterval_requestType_extElem1 3 typedef struct EXTERN H245MultilinkRequest_maximumHeaderInterval_requestType { int t; union { /* t = 1 */ /* t = 2 */ ASN1USINT requestedInterval; /* t = 3 */ } u; } H245MultilinkRequest_maximumHeaderInterval_requestType; EXTERN int asn1PE_H245MultilinkRequest_maximumHeaderInterval_requestType (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval_requestType* pvalue); EXTERN int asn1PD_H245MultilinkRequest_maximumHeaderInterval_requestType (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval_requestType* pvalue); /**************************************************************/ /* */ /* MultilinkRequest_maximumHeaderInterval */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkRequest_maximumHeaderInterval { H245MultilinkRequest_maximumHeaderInterval_requestType requestType; } H245MultilinkRequest_maximumHeaderInterval; EXTERN int asn1PE_H245MultilinkRequest_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval* pvalue); EXTERN int asn1PD_H245MultilinkRequest_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval* pvalue); /**************************************************************/ /* */ /* MultilinkRequest */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultilinkRequest_nonStandard 1 #define T_H245MultilinkRequest_callInformation 2 #define T_H245MultilinkRequest_addConnection 3 #define T_H245MultilinkRequest_removeConnection 4 #define T_H245MultilinkRequest_maximumHeaderInterval 5 #define T_H245MultilinkRequest_extElem1 6 typedef struct EXTERN H245MultilinkRequest { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245MultilinkRequest_callInformation *callInformation; /* t = 3 */ H245MultilinkRequest_addConnection *addConnection; /* t = 4 */ H245MultilinkRequest_removeConnection *removeConnection; /* t = 5 */ H245MultilinkRequest_maximumHeaderInterval *maximumHeaderInterval; /* t = 6 */ } u; } H245MultilinkRequest; EXTERN int asn1PE_H245MultilinkRequest (OOCTXT* pctxt, H245MultilinkRequest* pvalue); EXTERN int asn1PD_H245MultilinkRequest (OOCTXT* pctxt, H245MultilinkRequest* pvalue); /**************************************************************/ /* */ /* MaximumBitRate */ /* */ /**************************************************************/ typedef ASN1UINT H245MaximumBitRate; EXTERN int asn1PE_H245MaximumBitRate (OOCTXT* pctxt, H245MaximumBitRate value); EXTERN int asn1PD_H245MaximumBitRate (OOCTXT* pctxt, H245MaximumBitRate* pvalue); /**************************************************************/ /* */ /* LogicalChannelRateRequest */ /* */ /**************************************************************/ typedef struct EXTERN H245LogicalChannelRateRequest { H245SequenceNumber sequenceNumber; H245LogicalChannelNumber logicalChannelNumber; H245MaximumBitRate maximumBitRate; } H245LogicalChannelRateRequest; EXTERN int asn1PE_H245LogicalChannelRateRequest (OOCTXT* pctxt, H245LogicalChannelRateRequest* pvalue); EXTERN int asn1PD_H245LogicalChannelRateRequest (OOCTXT* pctxt, H245LogicalChannelRateRequest* pvalue); /**************************************************************/ /* */ /* RequestMessage */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RequestMessage_nonStandard 1 #define T_H245RequestMessage_masterSlaveDetermination 2 #define T_H245RequestMessage_terminalCapabilitySet 3 #define T_H245RequestMessage_openLogicalChannel 4 #define T_H245RequestMessage_closeLogicalChannel 5 #define T_H245RequestMessage_requestChannelClose 6 #define T_H245RequestMessage_multiplexEntrySend 7 #define T_H245RequestMessage_requestMultiplexEntry 8 #define T_H245RequestMessage_requestMode 9 #define T_H245RequestMessage_roundTripDelayRequest 10 #define T_H245RequestMessage_maintenanceLoopRequest 11 #define T_H245RequestMessage_communicationModeRequest 12 #define T_H245RequestMessage_conferenceRequest 13 #define T_H245RequestMessage_multilinkRequest 14 #define T_H245RequestMessage_logicalChannelRateRequest 15 #define T_H245RequestMessage_extElem1 16 typedef struct EXTERN H245RequestMessage { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245MasterSlaveDetermination *masterSlaveDetermination; /* t = 3 */ H245TerminalCapabilitySet *terminalCapabilitySet; /* t = 4 */ H245OpenLogicalChannel *openLogicalChannel; /* t = 5 */ H245CloseLogicalChannel *closeLogicalChannel; /* t = 6 */ H245RequestChannelClose *requestChannelClose; /* t = 7 */ H245MultiplexEntrySend *multiplexEntrySend; /* t = 8 */ H245RequestMultiplexEntry *requestMultiplexEntry; /* t = 9 */ H245RequestMode *requestMode; /* t = 10 */ H245RoundTripDelayRequest *roundTripDelayRequest; /* t = 11 */ H245MaintenanceLoopRequest *maintenanceLoopRequest; /* t = 12 */ H245CommunicationModeRequest *communicationModeRequest; /* t = 13 */ H245ConferenceRequest *conferenceRequest; /* t = 14 */ H245MultilinkRequest *multilinkRequest; /* t = 15 */ H245LogicalChannelRateRequest *logicalChannelRateRequest; /* t = 16 */ } u; } H245RequestMessage; EXTERN int asn1PE_H245RequestMessage (OOCTXT* pctxt, H245RequestMessage* pvalue); EXTERN int asn1PD_H245RequestMessage (OOCTXT* pctxt, H245RequestMessage* pvalue); /**************************************************************/ /* */ /* MasterSlaveDeterminationAck_decision */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MasterSlaveDeterminationAck_decision_master 1 #define T_H245MasterSlaveDeterminationAck_decision_slave 2 typedef struct EXTERN H245MasterSlaveDeterminationAck_decision { int t; } H245MasterSlaveDeterminationAck_decision; EXTERN int asn1PE_H245MasterSlaveDeterminationAck_decision (OOCTXT* pctxt, H245MasterSlaveDeterminationAck_decision* pvalue); EXTERN int asn1PD_H245MasterSlaveDeterminationAck_decision (OOCTXT* pctxt, H245MasterSlaveDeterminationAck_decision* pvalue); /**************************************************************/ /* */ /* MasterSlaveDeterminationAck */ /* */ /**************************************************************/ typedef struct EXTERN H245MasterSlaveDeterminationAck { H245MasterSlaveDeterminationAck_decision decision; } H245MasterSlaveDeterminationAck; EXTERN int asn1PE_H245MasterSlaveDeterminationAck (OOCTXT* pctxt, H245MasterSlaveDeterminationAck* pvalue); EXTERN int asn1PD_H245MasterSlaveDeterminationAck (OOCTXT* pctxt, H245MasterSlaveDeterminationAck* pvalue); /**************************************************************/ /* */ /* MasterSlaveDeterminationReject_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MasterSlaveDeterminationReject_cause_identicalNumbers 1 #define T_H245MasterSlaveDeterminationReject_cause_extElem1 2 typedef struct EXTERN H245MasterSlaveDeterminationReject_cause { int t; } H245MasterSlaveDeterminationReject_cause; EXTERN int asn1PE_H245MasterSlaveDeterminationReject_cause (OOCTXT* pctxt, H245MasterSlaveDeterminationReject_cause* pvalue); EXTERN int asn1PD_H245MasterSlaveDeterminationReject_cause (OOCTXT* pctxt, H245MasterSlaveDeterminationReject_cause* pvalue); /**************************************************************/ /* */ /* MasterSlaveDeterminationReject */ /* */ /**************************************************************/ typedef struct EXTERN H245MasterSlaveDeterminationReject { H245MasterSlaveDeterminationReject_cause cause; } H245MasterSlaveDeterminationReject; EXTERN int asn1PE_H245MasterSlaveDeterminationReject (OOCTXT* pctxt, H245MasterSlaveDeterminationReject* pvalue); EXTERN int asn1PD_H245MasterSlaveDeterminationReject (OOCTXT* pctxt, H245MasterSlaveDeterminationReject* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySetAck */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalCapabilitySetAck { H245SequenceNumber sequenceNumber; } H245TerminalCapabilitySetAck; EXTERN int asn1PE_H245TerminalCapabilitySetAck (OOCTXT* pctxt, H245TerminalCapabilitySetAck* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySetAck (OOCTXT* pctxt, H245TerminalCapabilitySetAck* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySetReject_cause_tableEntryCapacityExce */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded_highestEntryNumberProcessed 1 #define T_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded_noneProcessed 2 typedef struct EXTERN H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded { int t; union { /* t = 1 */ H245CapabilityTableEntryNumber highestEntryNumberProcessed; /* t = 2 */ } u; } H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded; EXTERN int asn1PE_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySetReject_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245TerminalCapabilitySetReject_cause_unspecified 1 #define T_H245TerminalCapabilitySetReject_cause_undefinedTableEntryUsed 2 #define T_H245TerminalCapabilitySetReject_cause_descriptorCapacityExceeded 3 #define T_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded 4 #define T_H245TerminalCapabilitySetReject_cause_extElem1 5 typedef struct EXTERN H245TerminalCapabilitySetReject_cause { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded *tableEntryCapacityExceeded; /* t = 5 */ } u; } H245TerminalCapabilitySetReject_cause; EXTERN int asn1PE_H245TerminalCapabilitySetReject_cause (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySetReject_cause (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySetReject */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalCapabilitySetReject { H245SequenceNumber sequenceNumber; H245TerminalCapabilitySetReject_cause cause; } H245TerminalCapabilitySetReject; EXTERN int asn1PE_H245TerminalCapabilitySetReject (OOCTXT* pctxt, H245TerminalCapabilitySetReject* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySetReject (OOCTXT* pctxt, H245TerminalCapabilitySetReject* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannelAck_reverseLogicalChannelParameters_mu */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters_h222LogicalChannelParameters 1 #define T_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters 2 #define T_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters_extElem1 3 typedef struct EXTERN H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters { int t; union { /* t = 1 */ H245H222LogicalChannelParameters *h222LogicalChannelParameters; /* t = 2 */ H245H2250LogicalChannelParameters *h2250LogicalChannelParameters; /* t = 3 */ } u; } H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters; EXTERN int asn1PE_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters* pvalue); EXTERN int asn1PD_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannelAck_reverseLogicalChannelParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245OpenLogicalChannelAck_reverseLogicalChannelParameters { struct { unsigned portNumberPresent : 1; unsigned multiplexParametersPresent : 1; unsigned replacementForPresent : 1; } m; H245LogicalChannelNumber reverseLogicalChannelNumber; ASN1USINT portNumber; H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters multiplexParameters; H245LogicalChannelNumber replacementFor; } H245OpenLogicalChannelAck_reverseLogicalChannelParameters; EXTERN int asn1PE_H245OpenLogicalChannelAck_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters* pvalue); EXTERN int asn1PD_H245OpenLogicalChannelAck_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters* pvalue); /**************************************************************/ /* */ /* H2250LogicalChannelAckParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245H2250LogicalChannelAckParameters { struct { unsigned nonStandardPresent : 1; unsigned sessionIDPresent : 1; unsigned mediaChannelPresent : 1; unsigned mediaControlChannelPresent : 1; unsigned dynamicRTPPayloadTypePresent : 1; unsigned flowControlToZeroPresent : 1; unsigned portNumberPresent : 1; } m; H245_SeqOfH245NonStandardParameter nonStandard; ASN1UINT8 sessionID; H245TransportAddress mediaChannel; H245TransportAddress mediaControlChannel; ASN1UINT8 dynamicRTPPayloadType; ASN1BOOL flowControlToZero; ASN1USINT portNumber; } H245H2250LogicalChannelAckParameters; EXTERN int asn1PE_H245H2250LogicalChannelAckParameters (OOCTXT* pctxt, H245H2250LogicalChannelAckParameters* pvalue); EXTERN int asn1PD_H245H2250LogicalChannelAckParameters (OOCTXT* pctxt, H245H2250LogicalChannelAckParameters* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannelAck_forwardMultiplexAckParameters */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245OpenLogicalChannelAck_forwardMultiplexAckParameters_h2250LogicalChannelAckParameters 1 #define T_H245OpenLogicalChannelAck_forwardMultiplexAckParameters_extElem1 2 typedef struct EXTERN H245OpenLogicalChannelAck_forwardMultiplexAckParameters { int t; union { /* t = 1 */ H245H2250LogicalChannelAckParameters *h2250LogicalChannelAckParameters; /* t = 2 */ } u; } H245OpenLogicalChannelAck_forwardMultiplexAckParameters; EXTERN int asn1PE_H245OpenLogicalChannelAck_forwardMultiplexAckParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_forwardMultiplexAckParameters* pvalue); EXTERN int asn1PD_H245OpenLogicalChannelAck_forwardMultiplexAckParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_forwardMultiplexAckParameters* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannelAck */ /* */ /**************************************************************/ typedef struct EXTERN H245OpenLogicalChannelAck { struct { unsigned reverseLogicalChannelParametersPresent : 1; unsigned separateStackPresent : 1; unsigned forwardMultiplexAckParametersPresent : 1; unsigned encryptionSyncPresent : 1; } m; H245LogicalChannelNumber forwardLogicalChannelNumber; H245OpenLogicalChannelAck_reverseLogicalChannelParameters reverseLogicalChannelParameters; H245NetworkAccessParameters separateStack; H245OpenLogicalChannelAck_forwardMultiplexAckParameters forwardMultiplexAckParameters; H245EncryptionSync encryptionSync; } H245OpenLogicalChannelAck; EXTERN int asn1PE_H245OpenLogicalChannelAck (OOCTXT* pctxt, H245OpenLogicalChannelAck* pvalue); EXTERN int asn1PD_H245OpenLogicalChannelAck (OOCTXT* pctxt, H245OpenLogicalChannelAck* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannelReject_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245OpenLogicalChannelReject_cause_unspecified 1 #define T_H245OpenLogicalChannelReject_cause_unsuitableReverseParameters 2 #define T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported 3 #define T_H245OpenLogicalChannelReject_cause_dataTypeNotAvailable 4 #define T_H245OpenLogicalChannelReject_cause_unknownDataType 5 #define T_H245OpenLogicalChannelReject_cause_dataTypeALCombinationNotSupported 6 #define T_H245OpenLogicalChannelReject_cause_multicastChannelNotAllowed 7 #define T_H245OpenLogicalChannelReject_cause_insufficientBandwidth 8 #define T_H245OpenLogicalChannelReject_cause_separateStackEstablishmentFailed 9 #define T_H245OpenLogicalChannelReject_cause_invalidSessionID 10 #define T_H245OpenLogicalChannelReject_cause_masterSlaveConflict 11 #define T_H245OpenLogicalChannelReject_cause_waitForCommunicationMode 12 #define T_H245OpenLogicalChannelReject_cause_invalidDependentChannel 13 #define T_H245OpenLogicalChannelReject_cause_replacementForRejected 14 #define T_H245OpenLogicalChannelReject_cause_extElem1 15 typedef struct EXTERN H245OpenLogicalChannelReject_cause { int t; } H245OpenLogicalChannelReject_cause; EXTERN int asn1PE_H245OpenLogicalChannelReject_cause (OOCTXT* pctxt, H245OpenLogicalChannelReject_cause* pvalue); EXTERN int asn1PD_H245OpenLogicalChannelReject_cause (OOCTXT* pctxt, H245OpenLogicalChannelReject_cause* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannelReject */ /* */ /**************************************************************/ typedef struct EXTERN H245OpenLogicalChannelReject { H245LogicalChannelNumber forwardLogicalChannelNumber; H245OpenLogicalChannelReject_cause cause; } H245OpenLogicalChannelReject; EXTERN int asn1PE_H245OpenLogicalChannelReject (OOCTXT* pctxt, H245OpenLogicalChannelReject* pvalue); EXTERN int asn1PD_H245OpenLogicalChannelReject (OOCTXT* pctxt, H245OpenLogicalChannelReject* pvalue); /**************************************************************/ /* */ /* CloseLogicalChannelAck */ /* */ /**************************************************************/ typedef struct EXTERN H245CloseLogicalChannelAck { H245LogicalChannelNumber forwardLogicalChannelNumber; } H245CloseLogicalChannelAck; EXTERN int asn1PE_H245CloseLogicalChannelAck (OOCTXT* pctxt, H245CloseLogicalChannelAck* pvalue); EXTERN int asn1PD_H245CloseLogicalChannelAck (OOCTXT* pctxt, H245CloseLogicalChannelAck* pvalue); /**************************************************************/ /* */ /* RequestChannelCloseAck */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestChannelCloseAck { H245LogicalChannelNumber forwardLogicalChannelNumber; } H245RequestChannelCloseAck; EXTERN int asn1PE_H245RequestChannelCloseAck (OOCTXT* pctxt, H245RequestChannelCloseAck* pvalue); EXTERN int asn1PD_H245RequestChannelCloseAck (OOCTXT* pctxt, H245RequestChannelCloseAck* pvalue); /**************************************************************/ /* */ /* RequestChannelCloseReject_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RequestChannelCloseReject_cause_unspecified 1 #define T_H245RequestChannelCloseReject_cause_extElem1 2 typedef struct EXTERN H245RequestChannelCloseReject_cause { int t; } H245RequestChannelCloseReject_cause; EXTERN int asn1PE_H245RequestChannelCloseReject_cause (OOCTXT* pctxt, H245RequestChannelCloseReject_cause* pvalue); EXTERN int asn1PD_H245RequestChannelCloseReject_cause (OOCTXT* pctxt, H245RequestChannelCloseReject_cause* pvalue); /**************************************************************/ /* */ /* RequestChannelCloseReject */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestChannelCloseReject { H245LogicalChannelNumber forwardLogicalChannelNumber; H245RequestChannelCloseReject_cause cause; } H245RequestChannelCloseReject; EXTERN int asn1PE_H245RequestChannelCloseReject (OOCTXT* pctxt, H245RequestChannelCloseReject* pvalue); EXTERN int asn1PD_H245RequestChannelCloseReject (OOCTXT* pctxt, H245RequestChannelCloseReject* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySendAck_multiplexTableEntryNumber */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntrySendAck_multiplexTableEntryNumber { ASN1UINT n; H245MultiplexTableEntryNumber elem[15]; } H245MultiplexEntrySendAck_multiplexTableEntryNumber; EXTERN int asn1PE_H245MultiplexEntrySendAck_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendAck_multiplexTableEntryNumber* pvalue); EXTERN int asn1PD_H245MultiplexEntrySendAck_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendAck_multiplexTableEntryNumber* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySendAck */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntrySendAck { H245SequenceNumber sequenceNumber; H245MultiplexEntrySendAck_multiplexTableEntryNumber multiplexTableEntryNumber; } H245MultiplexEntrySendAck; EXTERN int asn1PE_H245MultiplexEntrySendAck (OOCTXT* pctxt, H245MultiplexEntrySendAck* pvalue); EXTERN int asn1PD_H245MultiplexEntrySendAck (OOCTXT* pctxt, H245MultiplexEntrySendAck* pvalue); /**************************************************************/ /* */ /* MultiplexEntryRejectionDescriptions_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultiplexEntryRejectionDescriptions_cause_unspecifiedCause 1 #define T_H245MultiplexEntryRejectionDescriptions_cause_descriptorTooComplex 2 #define T_H245MultiplexEntryRejectionDescriptions_cause_extElem1 3 typedef struct EXTERN H245MultiplexEntryRejectionDescriptions_cause { int t; } H245MultiplexEntryRejectionDescriptions_cause; EXTERN int asn1PE_H245MultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions_cause* pvalue); EXTERN int asn1PD_H245MultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions_cause* pvalue); /**************************************************************/ /* */ /* MultiplexEntryRejectionDescriptions */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntryRejectionDescriptions { H245MultiplexTableEntryNumber multiplexTableEntryNumber; H245MultiplexEntryRejectionDescriptions_cause cause; } H245MultiplexEntryRejectionDescriptions; EXTERN int asn1PE_H245MultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions* pvalue); EXTERN int asn1PD_H245MultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySendReject_rejectionDescriptions */ /* */ /**************************************************************/ /* List of H245MultiplexEntryRejectionDescriptions */ typedef DList H245MultiplexEntrySendReject_rejectionDescriptions; EXTERN int asn1PE_H245MultiplexEntrySendReject_rejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntrySendReject_rejectionDescriptions* pvalue); EXTERN int asn1PD_H245MultiplexEntrySendReject_rejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntrySendReject_rejectionDescriptions* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySendReject */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntrySendReject { H245SequenceNumber sequenceNumber; H245MultiplexEntrySendReject_rejectionDescriptions rejectionDescriptions; } H245MultiplexEntrySendReject; EXTERN int asn1PE_H245MultiplexEntrySendReject (OOCTXT* pctxt, H245MultiplexEntrySendReject* pvalue); EXTERN int asn1PD_H245MultiplexEntrySendReject (OOCTXT* pctxt, H245MultiplexEntrySendReject* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryAck_entryNumbers */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntryAck_entryNumbers { ASN1UINT n; H245MultiplexTableEntryNumber elem[15]; } H245RequestMultiplexEntryAck_entryNumbers; EXTERN int asn1PE_H245RequestMultiplexEntryAck_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryAck_entryNumbers* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryAck_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryAck_entryNumbers* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryAck */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntryAck { H245RequestMultiplexEntryAck_entryNumbers entryNumbers; } H245RequestMultiplexEntryAck; EXTERN int asn1PE_H245RequestMultiplexEntryAck (OOCTXT* pctxt, H245RequestMultiplexEntryAck* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryAck (OOCTXT* pctxt, H245RequestMultiplexEntryAck* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryReject_entryNumbers */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntryReject_entryNumbers { ASN1UINT n; H245MultiplexTableEntryNumber elem[15]; } H245RequestMultiplexEntryReject_entryNumbers; EXTERN int asn1PE_H245RequestMultiplexEntryReject_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryReject_entryNumbers* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryReject_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryReject_entryNumbers* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryRejectionDescriptions_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RequestMultiplexEntryRejectionDescriptions_cause_unspecifiedCause 1 #define T_H245RequestMultiplexEntryRejectionDescriptions_cause_extElem1 2 typedef struct EXTERN H245RequestMultiplexEntryRejectionDescriptions_cause { int t; } H245RequestMultiplexEntryRejectionDescriptions_cause; EXTERN int asn1PE_H245RequestMultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions_cause* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions_cause* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryRejectionDescriptions */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntryRejectionDescriptions { H245MultiplexTableEntryNumber multiplexTableEntryNumber; H245RequestMultiplexEntryRejectionDescriptions_cause cause; } H245RequestMultiplexEntryRejectionDescriptions; EXTERN int asn1PE_H245RequestMultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryReject_rejectionDescriptions */ /* */ /**************************************************************/ /* List of H245RequestMultiplexEntryRejectionDescriptions */ typedef DList H245RequestMultiplexEntryReject_rejectionDescriptions; EXTERN int asn1PE_H245RequestMultiplexEntryReject_rejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryReject_rejectionDescriptions* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryReject_rejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryReject_rejectionDescriptions* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryReject */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntryReject { H245RequestMultiplexEntryReject_entryNumbers entryNumbers; H245RequestMultiplexEntryReject_rejectionDescriptions rejectionDescriptions; } H245RequestMultiplexEntryReject; EXTERN int asn1PE_H245RequestMultiplexEntryReject (OOCTXT* pctxt, H245RequestMultiplexEntryReject* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryReject (OOCTXT* pctxt, H245RequestMultiplexEntryReject* pvalue); /**************************************************************/ /* */ /* RequestModeAck_response */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RequestModeAck_response_willTransmitMostPreferredMode 1 #define T_H245RequestModeAck_response_willTransmitLessPreferredMode 2 #define T_H245RequestModeAck_response_extElem1 3 typedef struct EXTERN H245RequestModeAck_response { int t; } H245RequestModeAck_response; EXTERN int asn1PE_H245RequestModeAck_response (OOCTXT* pctxt, H245RequestModeAck_response* pvalue); EXTERN int asn1PD_H245RequestModeAck_response (OOCTXT* pctxt, H245RequestModeAck_response* pvalue); /**************************************************************/ /* */ /* RequestModeAck */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestModeAck { H245SequenceNumber sequenceNumber; H245RequestModeAck_response response; } H245RequestModeAck; EXTERN int asn1PE_H245RequestModeAck (OOCTXT* pctxt, H245RequestModeAck* pvalue); EXTERN int asn1PD_H245RequestModeAck (OOCTXT* pctxt, H245RequestModeAck* pvalue); /**************************************************************/ /* */ /* RequestModeReject_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RequestModeReject_cause_modeUnavailable 1 #define T_H245RequestModeReject_cause_multipointConstraint 2 #define T_H245RequestModeReject_cause_requestDenied 3 #define T_H245RequestModeReject_cause_extElem1 4 typedef struct EXTERN H245RequestModeReject_cause { int t; } H245RequestModeReject_cause; EXTERN int asn1PE_H245RequestModeReject_cause (OOCTXT* pctxt, H245RequestModeReject_cause* pvalue); EXTERN int asn1PD_H245RequestModeReject_cause (OOCTXT* pctxt, H245RequestModeReject_cause* pvalue); /**************************************************************/ /* */ /* RequestModeReject */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestModeReject { H245SequenceNumber sequenceNumber; H245RequestModeReject_cause cause; } H245RequestModeReject; EXTERN int asn1PE_H245RequestModeReject (OOCTXT* pctxt, H245RequestModeReject* pvalue); EXTERN int asn1PD_H245RequestModeReject (OOCTXT* pctxt, H245RequestModeReject* pvalue); /**************************************************************/ /* */ /* RoundTripDelayResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245RoundTripDelayResponse { H245SequenceNumber sequenceNumber; } H245RoundTripDelayResponse; EXTERN int asn1PE_H245RoundTripDelayResponse (OOCTXT* pctxt, H245RoundTripDelayResponse* pvalue); EXTERN int asn1PD_H245RoundTripDelayResponse (OOCTXT* pctxt, H245RoundTripDelayResponse* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopAck_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MaintenanceLoopAck_type_systemLoop 1 #define T_H245MaintenanceLoopAck_type_mediaLoop 2 #define T_H245MaintenanceLoopAck_type_logicalChannelLoop 3 #define T_H245MaintenanceLoopAck_type_extElem1 4 typedef struct EXTERN H245MaintenanceLoopAck_type { int t; union { /* t = 1 */ /* t = 2 */ H245LogicalChannelNumber mediaLoop; /* t = 3 */ H245LogicalChannelNumber logicalChannelLoop; /* t = 4 */ } u; } H245MaintenanceLoopAck_type; EXTERN int asn1PE_H245MaintenanceLoopAck_type (OOCTXT* pctxt, H245MaintenanceLoopAck_type* pvalue); EXTERN int asn1PD_H245MaintenanceLoopAck_type (OOCTXT* pctxt, H245MaintenanceLoopAck_type* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopAck */ /* */ /**************************************************************/ typedef struct EXTERN H245MaintenanceLoopAck { H245MaintenanceLoopAck_type type; } H245MaintenanceLoopAck; EXTERN int asn1PE_H245MaintenanceLoopAck (OOCTXT* pctxt, H245MaintenanceLoopAck* pvalue); EXTERN int asn1PD_H245MaintenanceLoopAck (OOCTXT* pctxt, H245MaintenanceLoopAck* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopReject_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MaintenanceLoopReject_type_systemLoop 1 #define T_H245MaintenanceLoopReject_type_mediaLoop 2 #define T_H245MaintenanceLoopReject_type_logicalChannelLoop 3 #define T_H245MaintenanceLoopReject_type_extElem1 4 typedef struct EXTERN H245MaintenanceLoopReject_type { int t; union { /* t = 1 */ /* t = 2 */ H245LogicalChannelNumber mediaLoop; /* t = 3 */ H245LogicalChannelNumber logicalChannelLoop; /* t = 4 */ } u; } H245MaintenanceLoopReject_type; EXTERN int asn1PE_H245MaintenanceLoopReject_type (OOCTXT* pctxt, H245MaintenanceLoopReject_type* pvalue); EXTERN int asn1PD_H245MaintenanceLoopReject_type (OOCTXT* pctxt, H245MaintenanceLoopReject_type* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopReject_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MaintenanceLoopReject_cause_canNotPerformLoop 1 #define T_H245MaintenanceLoopReject_cause_extElem1 2 typedef struct EXTERN H245MaintenanceLoopReject_cause { int t; } H245MaintenanceLoopReject_cause; EXTERN int asn1PE_H245MaintenanceLoopReject_cause (OOCTXT* pctxt, H245MaintenanceLoopReject_cause* pvalue); EXTERN int asn1PD_H245MaintenanceLoopReject_cause (OOCTXT* pctxt, H245MaintenanceLoopReject_cause* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopReject */ /* */ /**************************************************************/ typedef struct EXTERN H245MaintenanceLoopReject { H245MaintenanceLoopReject_type type; H245MaintenanceLoopReject_cause cause; } H245MaintenanceLoopReject; EXTERN int asn1PE_H245MaintenanceLoopReject (OOCTXT* pctxt, H245MaintenanceLoopReject* pvalue); EXTERN int asn1PD_H245MaintenanceLoopReject (OOCTXT* pctxt, H245MaintenanceLoopReject* pvalue); /**************************************************************/ /* */ /* CommunicationModeTableEntry_dataType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CommunicationModeTableEntry_dataType_videoData 1 #define T_H245CommunicationModeTableEntry_dataType_audioData 2 #define T_H245CommunicationModeTableEntry_dataType_data 3 #define T_H245CommunicationModeTableEntry_dataType_extElem1 4 typedef struct EXTERN H245CommunicationModeTableEntry_dataType { int t; union { /* t = 1 */ H245VideoCapability *videoData; /* t = 2 */ H245AudioCapability *audioData; /* t = 3 */ H245DataApplicationCapability *data; /* t = 4 */ } u; } H245CommunicationModeTableEntry_dataType; EXTERN int asn1PE_H245CommunicationModeTableEntry_dataType (OOCTXT* pctxt, H245CommunicationModeTableEntry_dataType* pvalue); EXTERN int asn1PD_H245CommunicationModeTableEntry_dataType (OOCTXT* pctxt, H245CommunicationModeTableEntry_dataType* pvalue); /**************************************************************/ /* */ /* CommunicationModeTableEntry */ /* */ /**************************************************************/ typedef struct EXTERN H245CommunicationModeTableEntry { struct { unsigned nonStandardPresent : 1; unsigned associatedSessionIDPresent : 1; unsigned terminalLabelPresent : 1; unsigned mediaChannelPresent : 1; unsigned mediaGuaranteedDeliveryPresent : 1; unsigned mediaControlChannelPresent : 1; unsigned mediaControlGuaranteedDeliveryPresent : 1; unsigned redundancyEncodingPresent : 1; unsigned sessionDependencyPresent : 1; unsigned destinationPresent : 1; } m; H245_SeqOfH245NonStandardParameter nonStandard; ASN1UINT8 sessionID; ASN1UINT8 associatedSessionID; H245TerminalLabel terminalLabel; ASN1BMPString sessionDescription; H245CommunicationModeTableEntry_dataType dataType; H245TransportAddress mediaChannel; ASN1BOOL mediaGuaranteedDelivery; H245TransportAddress mediaControlChannel; ASN1BOOL mediaControlGuaranteedDelivery; H245RedundancyEncoding redundancyEncoding; ASN1UINT8 sessionDependency; H245TerminalLabel destination; } H245CommunicationModeTableEntry; EXTERN int asn1PE_H245CommunicationModeTableEntry (OOCTXT* pctxt, H245CommunicationModeTableEntry* pvalue); EXTERN int asn1PD_H245CommunicationModeTableEntry (OOCTXT* pctxt, H245CommunicationModeTableEntry* pvalue); /**************************************************************/ /* */ /* CommunicationModeResponse_communicationModeTable */ /* */ /**************************************************************/ /* List of H245CommunicationModeTableEntry */ typedef DList H245CommunicationModeResponse_communicationModeTable; EXTERN int asn1PE_H245CommunicationModeResponse_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeResponse_communicationModeTable* pvalue); EXTERN int asn1PD_H245CommunicationModeResponse_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeResponse_communicationModeTable* pvalue); /**************************************************************/ /* */ /* CommunicationModeResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CommunicationModeResponse_communicationModeTable 1 #define T_H245CommunicationModeResponse_extElem1 2 typedef struct EXTERN H245CommunicationModeResponse { int t; union { /* t = 1 */ H245CommunicationModeResponse_communicationModeTable *communicationModeTable; /* t = 2 */ } u; } H245CommunicationModeResponse; EXTERN int asn1PE_H245CommunicationModeResponse (OOCTXT* pctxt, H245CommunicationModeResponse* pvalue); EXTERN int asn1PD_H245CommunicationModeResponse (OOCTXT* pctxt, H245CommunicationModeResponse* pvalue); /**************************************************************/ /* */ /* TerminalID */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalID { ASN1UINT numocts; ASN1OCTET data[128]; } H245TerminalID; EXTERN int asn1PE_H245TerminalID (OOCTXT* pctxt, H245TerminalID* pvalue); EXTERN int asn1PD_H245TerminalID (OOCTXT* pctxt, H245TerminalID* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_mCTerminalIDResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceResponse_mCTerminalIDResponse { H245TerminalLabel terminalLabel; H245TerminalID terminalID; } H245ConferenceResponse_mCTerminalIDResponse; EXTERN int asn1PE_H245ConferenceResponse_mCTerminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_mCTerminalIDResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_mCTerminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_mCTerminalIDResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_terminalIDResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceResponse_terminalIDResponse { H245TerminalLabel terminalLabel; H245TerminalID terminalID; } H245ConferenceResponse_terminalIDResponse; EXTERN int asn1PE_H245ConferenceResponse_terminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalIDResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_terminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalIDResponse* pvalue); /**************************************************************/ /* */ /* ConferenceID */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceID { ASN1UINT numocts; ASN1OCTET data[32]; } H245ConferenceID; EXTERN int asn1PE_H245ConferenceID (OOCTXT* pctxt, H245ConferenceID* pvalue); EXTERN int asn1PD_H245ConferenceID (OOCTXT* pctxt, H245ConferenceID* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_conferenceIDResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceResponse_conferenceIDResponse { H245TerminalLabel terminalLabel; H245ConferenceID conferenceID; } H245ConferenceResponse_conferenceIDResponse; EXTERN int asn1PE_H245ConferenceResponse_conferenceIDResponse (OOCTXT* pctxt, H245ConferenceResponse_conferenceIDResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_conferenceIDResponse (OOCTXT* pctxt, H245ConferenceResponse_conferenceIDResponse* pvalue); /**************************************************************/ /* */ /* Password */ /* */ /**************************************************************/ typedef struct EXTERN H245Password { ASN1UINT numocts; ASN1OCTET data[32]; } H245Password; EXTERN int asn1PE_H245Password (OOCTXT* pctxt, H245Password* pvalue); EXTERN int asn1PD_H245Password (OOCTXT* pctxt, H245Password* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_passwordResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceResponse_passwordResponse { H245TerminalLabel terminalLabel; H245Password password; } H245ConferenceResponse_passwordResponse; EXTERN int asn1PE_H245ConferenceResponse_passwordResponse (OOCTXT* pctxt, H245ConferenceResponse_passwordResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_passwordResponse (OOCTXT* pctxt, H245ConferenceResponse_passwordResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_terminalListResponse */ /* */ /**************************************************************/ /* List of H245TerminalLabel */ typedef DList H245ConferenceResponse_terminalListResponse; EXTERN int asn1PE_H245ConferenceResponse_terminalListResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalListResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_terminalListResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalListResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_makeMeChairResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceResponse_makeMeChairResponse_grantedChairToken 1 #define T_H245ConferenceResponse_makeMeChairResponse_deniedChairToken 2 #define T_H245ConferenceResponse_makeMeChairResponse_extElem1 3 typedef struct EXTERN H245ConferenceResponse_makeMeChairResponse { int t; } H245ConferenceResponse_makeMeChairResponse; EXTERN int asn1PE_H245ConferenceResponse_makeMeChairResponse (OOCTXT* pctxt, H245ConferenceResponse_makeMeChairResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_makeMeChairResponse (OOCTXT* pctxt, H245ConferenceResponse_makeMeChairResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_extensionAddressResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceResponse_extensionAddressResponse { H245TerminalID extensionAddress; } H245ConferenceResponse_extensionAddressResponse; EXTERN int asn1PE_H245ConferenceResponse_extensionAddressResponse (OOCTXT* pctxt, H245ConferenceResponse_extensionAddressResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_extensionAddressResponse (OOCTXT* pctxt, H245ConferenceResponse_extensionAddressResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_chairTokenOwnerResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceResponse_chairTokenOwnerResponse { H245TerminalLabel terminalLabel; H245TerminalID terminalID; } H245ConferenceResponse_chairTokenOwnerResponse; EXTERN int asn1PE_H245ConferenceResponse_chairTokenOwnerResponse (OOCTXT* pctxt, H245ConferenceResponse_chairTokenOwnerResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_chairTokenOwnerResponse (OOCTXT* pctxt, H245ConferenceResponse_chairTokenOwnerResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_terminalCertificateResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245ConferenceResponse_terminalCertificateResponse { struct { unsigned terminalLabelPresent : 1; unsigned certificateResponsePresent : 1; } m; H245TerminalLabel terminalLabel; ASN1DynOctStr certificateResponse; } H245ConferenceResponse_terminalCertificateResponse; EXTERN int asn1PE_H245ConferenceResponse_terminalCertificateResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalCertificateResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_terminalCertificateResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalCertificateResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_broadcastMyLogicalChannelResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceResponse_broadcastMyLogicalChannelResponse_grantedBroadcastMyLogicalChannel 1 #define T_H245ConferenceResponse_broadcastMyLogicalChannelResponse_deniedBroadcastMyLogicalChannel 2 #define T_H245ConferenceResponse_broadcastMyLogicalChannelResponse_extElem1 3 typedef struct EXTERN H245ConferenceResponse_broadcastMyLogicalChannelResponse { int t; } H245ConferenceResponse_broadcastMyLogicalChannelResponse; EXTERN int asn1PE_H245ConferenceResponse_broadcastMyLogicalChannelResponse (OOCTXT* pctxt, H245ConferenceResponse_broadcastMyLogicalChannelResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_broadcastMyLogicalChannelResponse (OOCTXT* pctxt, H245ConferenceResponse_broadcastMyLogicalChannelResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_makeTerminalBroadcasterResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceResponse_makeTerminalBroadcasterResponse_grantedMakeTerminalBroadcaster 1 #define T_H245ConferenceResponse_makeTerminalBroadcasterResponse_deniedMakeTerminalBroadcaster 2 #define T_H245ConferenceResponse_makeTerminalBroadcasterResponse_extElem1 3 typedef struct EXTERN H245ConferenceResponse_makeTerminalBroadcasterResponse { int t; } H245ConferenceResponse_makeTerminalBroadcasterResponse; EXTERN int asn1PE_H245ConferenceResponse_makeTerminalBroadcasterResponse (OOCTXT* pctxt, H245ConferenceResponse_makeTerminalBroadcasterResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_makeTerminalBroadcasterResponse (OOCTXT* pctxt, H245ConferenceResponse_makeTerminalBroadcasterResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse_sendThisSourceResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceResponse_sendThisSourceResponse_grantedSendThisSource 1 #define T_H245ConferenceResponse_sendThisSourceResponse_deniedSendThisSource 2 #define T_H245ConferenceResponse_sendThisSourceResponse_extElem1 3 typedef struct EXTERN H245ConferenceResponse_sendThisSourceResponse { int t; } H245ConferenceResponse_sendThisSourceResponse; EXTERN int asn1PE_H245ConferenceResponse_sendThisSourceResponse (OOCTXT* pctxt, H245ConferenceResponse_sendThisSourceResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse_sendThisSourceResponse (OOCTXT* pctxt, H245ConferenceResponse_sendThisSourceResponse* pvalue); /**************************************************************/ /* */ /* TerminalInformation */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalInformation { H245TerminalLabel terminalLabel; H245TerminalID terminalID; } H245TerminalInformation; EXTERN int asn1PE_H245TerminalInformation (OOCTXT* pctxt, H245TerminalInformation* pvalue); EXTERN int asn1PD_H245TerminalInformation (OOCTXT* pctxt, H245TerminalInformation* pvalue); /**************************************************************/ /* */ /* _SeqOfH245TerminalInformation */ /* */ /**************************************************************/ /* List of H245TerminalInformation */ typedef DList H245_SeqOfH245TerminalInformation; EXTERN int asn1PE_H245_SeqOfH245TerminalInformation (OOCTXT* pctxt, H245_SeqOfH245TerminalInformation* pvalue); EXTERN int asn1PD_H245_SeqOfH245TerminalInformation (OOCTXT* pctxt, H245_SeqOfH245TerminalInformation* pvalue); /**************************************************************/ /* */ /* RequestAllTerminalIDsResponse */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestAllTerminalIDsResponse { H245_SeqOfH245TerminalInformation terminalInformation; } H245RequestAllTerminalIDsResponse; EXTERN int asn1PE_H245RequestAllTerminalIDsResponse (OOCTXT* pctxt, H245RequestAllTerminalIDsResponse* pvalue); EXTERN int asn1PD_H245RequestAllTerminalIDsResponse (OOCTXT* pctxt, H245RequestAllTerminalIDsResponse* pvalue); /**************************************************************/ /* */ /* RemoteMCResponse_reject */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RemoteMCResponse_reject_unspecified 1 #define T_H245RemoteMCResponse_reject_functionNotSupported 2 #define T_H245RemoteMCResponse_reject_extElem1 3 typedef struct EXTERN H245RemoteMCResponse_reject { int t; } H245RemoteMCResponse_reject; EXTERN int asn1PE_H245RemoteMCResponse_reject (OOCTXT* pctxt, H245RemoteMCResponse_reject* pvalue); EXTERN int asn1PD_H245RemoteMCResponse_reject (OOCTXT* pctxt, H245RemoteMCResponse_reject* pvalue); /**************************************************************/ /* */ /* RemoteMCResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245RemoteMCResponse_accept 1 #define T_H245RemoteMCResponse_reject 2 #define T_H245RemoteMCResponse_extElem1 3 typedef struct EXTERN H245RemoteMCResponse { int t; union { /* t = 1 */ /* t = 2 */ H245RemoteMCResponse_reject *reject; /* t = 3 */ } u; } H245RemoteMCResponse; EXTERN int asn1PE_H245RemoteMCResponse (OOCTXT* pctxt, H245RemoteMCResponse* pvalue); EXTERN int asn1PD_H245RemoteMCResponse (OOCTXT* pctxt, H245RemoteMCResponse* pvalue); /**************************************************************/ /* */ /* ConferenceResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceResponse_mCTerminalIDResponse 1 #define T_H245ConferenceResponse_terminalIDResponse 2 #define T_H245ConferenceResponse_conferenceIDResponse 3 #define T_H245ConferenceResponse_passwordResponse 4 #define T_H245ConferenceResponse_terminalListResponse 5 #define T_H245ConferenceResponse_videoCommandReject 6 #define T_H245ConferenceResponse_terminalDropReject 7 #define T_H245ConferenceResponse_makeMeChairResponse 8 #define T_H245ConferenceResponse_extensionAddressResponse 9 #define T_H245ConferenceResponse_chairTokenOwnerResponse 10 #define T_H245ConferenceResponse_terminalCertificateResponse 11 #define T_H245ConferenceResponse_broadcastMyLogicalChannelResponse 12 #define T_H245ConferenceResponse_makeTerminalBroadcasterResponse 13 #define T_H245ConferenceResponse_sendThisSourceResponse 14 #define T_H245ConferenceResponse_requestAllTerminalIDsResponse 15 #define T_H245ConferenceResponse_remoteMCResponse 16 #define T_H245ConferenceResponse_extElem1 17 typedef struct EXTERN H245ConferenceResponse { int t; union { /* t = 1 */ H245ConferenceResponse_mCTerminalIDResponse *mCTerminalIDResponse; /* t = 2 */ H245ConferenceResponse_terminalIDResponse *terminalIDResponse; /* t = 3 */ H245ConferenceResponse_conferenceIDResponse *conferenceIDResponse; /* t = 4 */ H245ConferenceResponse_passwordResponse *passwordResponse; /* t = 5 */ H245ConferenceResponse_terminalListResponse *terminalListResponse; /* t = 6 */ /* t = 7 */ /* t = 8 */ H245ConferenceResponse_makeMeChairResponse *makeMeChairResponse; /* t = 9 */ H245ConferenceResponse_extensionAddressResponse *extensionAddressResponse; /* t = 10 */ H245ConferenceResponse_chairTokenOwnerResponse *chairTokenOwnerResponse; /* t = 11 */ H245ConferenceResponse_terminalCertificateResponse *terminalCertificateResponse; /* t = 12 */ H245ConferenceResponse_broadcastMyLogicalChannelResponse *broadcastMyLogicalChannelResponse; /* t = 13 */ H245ConferenceResponse_makeTerminalBroadcasterResponse *makeTerminalBroadcasterResponse; /* t = 14 */ H245ConferenceResponse_sendThisSourceResponse *sendThisSourceResponse; /* t = 15 */ H245RequestAllTerminalIDsResponse *requestAllTerminalIDsResponse; /* t = 16 */ H245RemoteMCResponse *remoteMCResponse; /* t = 17 */ } u; } H245ConferenceResponse; EXTERN int asn1PE_H245ConferenceResponse (OOCTXT* pctxt, H245ConferenceResponse* pvalue); EXTERN int asn1PD_H245ConferenceResponse (OOCTXT* pctxt, H245ConferenceResponse* pvalue); /**************************************************************/ /* */ /* MultilinkResponse_callInformation */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkResponse_callInformation { H245DialingInformation dialingInformation; ASN1UINT callAssociationNumber; } H245MultilinkResponse_callInformation; EXTERN int asn1PE_H245MultilinkResponse_callInformation (OOCTXT* pctxt, H245MultilinkResponse_callInformation* pvalue); EXTERN int asn1PD_H245MultilinkResponse_callInformation (OOCTXT* pctxt, H245MultilinkResponse_callInformation* pvalue); /**************************************************************/ /* */ /* MultilinkResponse_addConnection_responseCode_rejected */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultilinkResponse_addConnection_responseCode_rejected_connectionsNotAvailable 1 #define T_H245MultilinkResponse_addConnection_responseCode_rejected_userRejected 2 #define T_H245MultilinkResponse_addConnection_responseCode_rejected_extElem1 3 typedef struct EXTERN H245MultilinkResponse_addConnection_responseCode_rejected { int t; } H245MultilinkResponse_addConnection_responseCode_rejected; EXTERN int asn1PE_H245MultilinkResponse_addConnection_responseCode_rejected (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode_rejected* pvalue); EXTERN int asn1PD_H245MultilinkResponse_addConnection_responseCode_rejected (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode_rejected* pvalue); /**************************************************************/ /* */ /* MultilinkResponse_addConnection_responseCode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultilinkResponse_addConnection_responseCode_accepted 1 #define T_H245MultilinkResponse_addConnection_responseCode_rejected 2 #define T_H245MultilinkResponse_addConnection_responseCode_extElem1 3 typedef struct EXTERN H245MultilinkResponse_addConnection_responseCode { int t; union { /* t = 1 */ /* t = 2 */ H245MultilinkResponse_addConnection_responseCode_rejected *rejected; /* t = 3 */ } u; } H245MultilinkResponse_addConnection_responseCode; EXTERN int asn1PE_H245MultilinkResponse_addConnection_responseCode (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode* pvalue); EXTERN int asn1PD_H245MultilinkResponse_addConnection_responseCode (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode* pvalue); /**************************************************************/ /* */ /* MultilinkResponse_addConnection */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkResponse_addConnection { H245SequenceNumber sequenceNumber; H245MultilinkResponse_addConnection_responseCode responseCode; } H245MultilinkResponse_addConnection; EXTERN int asn1PE_H245MultilinkResponse_addConnection (OOCTXT* pctxt, H245MultilinkResponse_addConnection* pvalue); EXTERN int asn1PD_H245MultilinkResponse_addConnection (OOCTXT* pctxt, H245MultilinkResponse_addConnection* pvalue); /**************************************************************/ /* */ /* MultilinkResponse_removeConnection */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkResponse_removeConnection { H245ConnectionIdentifier connectionIdentifier; } H245MultilinkResponse_removeConnection; EXTERN int asn1PE_H245MultilinkResponse_removeConnection (OOCTXT* pctxt, H245MultilinkResponse_removeConnection* pvalue); EXTERN int asn1PD_H245MultilinkResponse_removeConnection (OOCTXT* pctxt, H245MultilinkResponse_removeConnection* pvalue); /**************************************************************/ /* */ /* MultilinkResponse_maximumHeaderInterval */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkResponse_maximumHeaderInterval { ASN1USINT currentInterval; } H245MultilinkResponse_maximumHeaderInterval; EXTERN int asn1PE_H245MultilinkResponse_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkResponse_maximumHeaderInterval* pvalue); EXTERN int asn1PD_H245MultilinkResponse_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkResponse_maximumHeaderInterval* pvalue); /**************************************************************/ /* */ /* MultilinkResponse */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultilinkResponse_nonStandard 1 #define T_H245MultilinkResponse_callInformation 2 #define T_H245MultilinkResponse_addConnection 3 #define T_H245MultilinkResponse_removeConnection 4 #define T_H245MultilinkResponse_maximumHeaderInterval 5 #define T_H245MultilinkResponse_extElem1 6 typedef struct EXTERN H245MultilinkResponse { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245MultilinkResponse_callInformation *callInformation; /* t = 3 */ H245MultilinkResponse_addConnection *addConnection; /* t = 4 */ H245MultilinkResponse_removeConnection *removeConnection; /* t = 5 */ H245MultilinkResponse_maximumHeaderInterval *maximumHeaderInterval; /* t = 6 */ } u; } H245MultilinkResponse; EXTERN int asn1PE_H245MultilinkResponse (OOCTXT* pctxt, H245MultilinkResponse* pvalue); EXTERN int asn1PD_H245MultilinkResponse (OOCTXT* pctxt, H245MultilinkResponse* pvalue); /**************************************************************/ /* */ /* LogicalChannelRateAcknowledge */ /* */ /**************************************************************/ typedef struct EXTERN H245LogicalChannelRateAcknowledge { H245SequenceNumber sequenceNumber; H245LogicalChannelNumber logicalChannelNumber; H245MaximumBitRate maximumBitRate; } H245LogicalChannelRateAcknowledge; EXTERN int asn1PE_H245LogicalChannelRateAcknowledge (OOCTXT* pctxt, H245LogicalChannelRateAcknowledge* pvalue); EXTERN int asn1PD_H245LogicalChannelRateAcknowledge (OOCTXT* pctxt, H245LogicalChannelRateAcknowledge* pvalue); /**************************************************************/ /* */ /* LogicalChannelRateRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245LogicalChannelRateRejectReason_undefinedReason 1 #define T_H245LogicalChannelRateRejectReason_insufficientResources 2 #define T_H245LogicalChannelRateRejectReason_extElem1 3 typedef struct EXTERN H245LogicalChannelRateRejectReason { int t; } H245LogicalChannelRateRejectReason; EXTERN int asn1PE_H245LogicalChannelRateRejectReason (OOCTXT* pctxt, H245LogicalChannelRateRejectReason* pvalue); EXTERN int asn1PD_H245LogicalChannelRateRejectReason (OOCTXT* pctxt, H245LogicalChannelRateRejectReason* pvalue); /**************************************************************/ /* */ /* LogicalChannelRateReject */ /* */ /**************************************************************/ typedef struct EXTERN H245LogicalChannelRateReject { struct { unsigned currentMaximumBitRatePresent : 1; } m; H245SequenceNumber sequenceNumber; H245LogicalChannelNumber logicalChannelNumber; H245LogicalChannelRateRejectReason rejectReason; H245MaximumBitRate currentMaximumBitRate; } H245LogicalChannelRateReject; EXTERN int asn1PE_H245LogicalChannelRateReject (OOCTXT* pctxt, H245LogicalChannelRateReject* pvalue); EXTERN int asn1PD_H245LogicalChannelRateReject (OOCTXT* pctxt, H245LogicalChannelRateReject* pvalue); /**************************************************************/ /* */ /* ResponseMessage */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ResponseMessage_nonStandard 1 #define T_H245ResponseMessage_masterSlaveDeterminationAck 2 #define T_H245ResponseMessage_masterSlaveDeterminationReject 3 #define T_H245ResponseMessage_terminalCapabilitySetAck 4 #define T_H245ResponseMessage_terminalCapabilitySetReject 5 #define T_H245ResponseMessage_openLogicalChannelAck 6 #define T_H245ResponseMessage_openLogicalChannelReject 7 #define T_H245ResponseMessage_closeLogicalChannelAck 8 #define T_H245ResponseMessage_requestChannelCloseAck 9 #define T_H245ResponseMessage_requestChannelCloseReject 10 #define T_H245ResponseMessage_multiplexEntrySendAck 11 #define T_H245ResponseMessage_multiplexEntrySendReject 12 #define T_H245ResponseMessage_requestMultiplexEntryAck 13 #define T_H245ResponseMessage_requestMultiplexEntryReject 14 #define T_H245ResponseMessage_requestModeAck 15 #define T_H245ResponseMessage_requestModeReject 16 #define T_H245ResponseMessage_roundTripDelayResponse 17 #define T_H245ResponseMessage_maintenanceLoopAck 18 #define T_H245ResponseMessage_maintenanceLoopReject 19 #define T_H245ResponseMessage_communicationModeResponse 20 #define T_H245ResponseMessage_conferenceResponse 21 #define T_H245ResponseMessage_multilinkResponse 22 #define T_H245ResponseMessage_logicalChannelRateAcknowledge 23 #define T_H245ResponseMessage_logicalChannelRateReject 24 #define T_H245ResponseMessage_extElem1 25 typedef struct EXTERN H245ResponseMessage { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245MasterSlaveDeterminationAck *masterSlaveDeterminationAck; /* t = 3 */ H245MasterSlaveDeterminationReject *masterSlaveDeterminationReject; /* t = 4 */ H245TerminalCapabilitySetAck *terminalCapabilitySetAck; /* t = 5 */ H245TerminalCapabilitySetReject *terminalCapabilitySetReject; /* t = 6 */ H245OpenLogicalChannelAck *openLogicalChannelAck; /* t = 7 */ H245OpenLogicalChannelReject *openLogicalChannelReject; /* t = 8 */ H245CloseLogicalChannelAck *closeLogicalChannelAck; /* t = 9 */ H245RequestChannelCloseAck *requestChannelCloseAck; /* t = 10 */ H245RequestChannelCloseReject *requestChannelCloseReject; /* t = 11 */ H245MultiplexEntrySendAck *multiplexEntrySendAck; /* t = 12 */ H245MultiplexEntrySendReject *multiplexEntrySendReject; /* t = 13 */ H245RequestMultiplexEntryAck *requestMultiplexEntryAck; /* t = 14 */ H245RequestMultiplexEntryReject *requestMultiplexEntryReject; /* t = 15 */ H245RequestModeAck *requestModeAck; /* t = 16 */ H245RequestModeReject *requestModeReject; /* t = 17 */ H245RoundTripDelayResponse *roundTripDelayResponse; /* t = 18 */ H245MaintenanceLoopAck *maintenanceLoopAck; /* t = 19 */ H245MaintenanceLoopReject *maintenanceLoopReject; /* t = 20 */ H245CommunicationModeResponse *communicationModeResponse; /* t = 21 */ H245ConferenceResponse *conferenceResponse; /* t = 22 */ H245MultilinkResponse *multilinkResponse; /* t = 23 */ H245LogicalChannelRateAcknowledge *logicalChannelRateAcknowledge; /* t = 24 */ H245LogicalChannelRateReject *logicalChannelRateReject; /* t = 25 */ } u; } H245ResponseMessage; EXTERN int asn1PE_H245ResponseMessage (OOCTXT* pctxt, H245ResponseMessage* pvalue); EXTERN int asn1PD_H245ResponseMessage (OOCTXT* pctxt, H245ResponseMessage* pvalue); /**************************************************************/ /* */ /* MaintenanceLoopOffCommand */ /* */ /**************************************************************/ typedef struct EXTERN H245MaintenanceLoopOffCommand { ASN1OCTET __dummy__; } H245MaintenanceLoopOffCommand; EXTERN int asn1PE_H245MaintenanceLoopOffCommand (OOCTXT* pctxt, H245MaintenanceLoopOffCommand* pvalue); EXTERN int asn1PD_H245MaintenanceLoopOffCommand (OOCTXT* pctxt, H245MaintenanceLoopOffCommand* pvalue); /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest_capabilityTabl */ /* */ /**************************************************************/ typedef struct EXTERN H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers { ASN1UINT n; H245CapabilityTableEntryNumber *elem; } H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers; EXTERN int asn1PE_H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers* pvalue); EXTERN int asn1PD_H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers* pvalue); /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest_capabilityDesc */ /* */ /**************************************************************/ typedef struct EXTERN H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers { ASN1UINT n; H245CapabilityDescriptorNumber elem[256]; } H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers; EXTERN int asn1PE_H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers* pvalue); EXTERN int asn1PD_H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers* pvalue); /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest */ /* */ /**************************************************************/ typedef struct EXTERN H245SendTerminalCapabilitySet_specificRequest { struct { unsigned capabilityTableEntryNumbersPresent : 1; unsigned capabilityDescriptorNumbersPresent : 1; } m; ASN1BOOL multiplexCapability; H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers capabilityTableEntryNumbers; H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers capabilityDescriptorNumbers; } H245SendTerminalCapabilitySet_specificRequest; EXTERN int asn1PE_H245SendTerminalCapabilitySet_specificRequest (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest* pvalue); EXTERN int asn1PD_H245SendTerminalCapabilitySet_specificRequest (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest* pvalue); /**************************************************************/ /* */ /* SendTerminalCapabilitySet */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245SendTerminalCapabilitySet_specificRequest 1 #define T_H245SendTerminalCapabilitySet_genericRequest 2 #define T_H245SendTerminalCapabilitySet_extElem1 3 typedef struct EXTERN H245SendTerminalCapabilitySet { int t; union { /* t = 1 */ H245SendTerminalCapabilitySet_specificRequest *specificRequest; /* t = 2 */ /* t = 3 */ } u; } H245SendTerminalCapabilitySet; EXTERN int asn1PE_H245SendTerminalCapabilitySet (OOCTXT* pctxt, H245SendTerminalCapabilitySet* pvalue); EXTERN int asn1PD_H245SendTerminalCapabilitySet (OOCTXT* pctxt, H245SendTerminalCapabilitySet* pvalue); /**************************************************************/ /* */ /* EncryptionCommand_encryptionAlgorithmID */ /* */ /**************************************************************/ typedef struct EXTERN H245EncryptionCommand_encryptionAlgorithmID { H245SequenceNumber h233AlgorithmIdentifier; H245NonStandardParameter associatedAlgorithm; } H245EncryptionCommand_encryptionAlgorithmID; EXTERN int asn1PE_H245EncryptionCommand_encryptionAlgorithmID (OOCTXT* pctxt, H245EncryptionCommand_encryptionAlgorithmID* pvalue); EXTERN int asn1PD_H245EncryptionCommand_encryptionAlgorithmID (OOCTXT* pctxt, H245EncryptionCommand_encryptionAlgorithmID* pvalue); /**************************************************************/ /* */ /* EncryptionCommand */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245EncryptionCommand_encryptionSE 1 #define T_H245EncryptionCommand_encryptionIVRequest 2 #define T_H245EncryptionCommand_encryptionAlgorithmID 3 #define T_H245EncryptionCommand_extElem1 4 typedef struct EXTERN H245EncryptionCommand { int t; union { /* t = 1 */ ASN1DynOctStr *encryptionSE; /* t = 2 */ /* t = 3 */ H245EncryptionCommand_encryptionAlgorithmID *encryptionAlgorithmID; /* t = 4 */ } u; } H245EncryptionCommand; EXTERN int asn1PE_H245EncryptionCommand (OOCTXT* pctxt, H245EncryptionCommand* pvalue); EXTERN int asn1PD_H245EncryptionCommand (OOCTXT* pctxt, H245EncryptionCommand* pvalue); /**************************************************************/ /* */ /* FlowControlCommand_scope */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FlowControlCommand_scope_logicalChannelNumber 1 #define T_H245FlowControlCommand_scope_resourceID 2 #define T_H245FlowControlCommand_scope_wholeMultiplex 3 typedef struct EXTERN H245FlowControlCommand_scope { int t; union { /* t = 1 */ H245LogicalChannelNumber logicalChannelNumber; /* t = 2 */ ASN1USINT resourceID; /* t = 3 */ } u; } H245FlowControlCommand_scope; EXTERN int asn1PE_H245FlowControlCommand_scope (OOCTXT* pctxt, H245FlowControlCommand_scope* pvalue); EXTERN int asn1PD_H245FlowControlCommand_scope (OOCTXT* pctxt, H245FlowControlCommand_scope* pvalue); /**************************************************************/ /* */ /* FlowControlCommand_restriction */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FlowControlCommand_restriction_maximumBitRate 1 #define T_H245FlowControlCommand_restriction_noRestriction 2 typedef struct EXTERN H245FlowControlCommand_restriction { int t; union { /* t = 1 */ ASN1UINT maximumBitRate; /* t = 2 */ } u; } H245FlowControlCommand_restriction; EXTERN int asn1PE_H245FlowControlCommand_restriction (OOCTXT* pctxt, H245FlowControlCommand_restriction* pvalue); EXTERN int asn1PD_H245FlowControlCommand_restriction (OOCTXT* pctxt, H245FlowControlCommand_restriction* pvalue); /**************************************************************/ /* */ /* FlowControlCommand */ /* */ /**************************************************************/ typedef struct EXTERN H245FlowControlCommand { H245FlowControlCommand_scope scope; H245FlowControlCommand_restriction restriction; } H245FlowControlCommand; EXTERN int asn1PE_H245FlowControlCommand (OOCTXT* pctxt, H245FlowControlCommand* pvalue); EXTERN int asn1PD_H245FlowControlCommand (OOCTXT* pctxt, H245FlowControlCommand* pvalue); /**************************************************************/ /* */ /* EndSessionCommand_gstnOptions */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245EndSessionCommand_gstnOptions_telephonyMode 1 #define T_H245EndSessionCommand_gstnOptions_v8bis 2 #define T_H245EndSessionCommand_gstnOptions_v34DSVD 3 #define T_H245EndSessionCommand_gstnOptions_v34DuplexFAX 4 #define T_H245EndSessionCommand_gstnOptions_v34H324 5 #define T_H245EndSessionCommand_gstnOptions_extElem1 6 typedef struct EXTERN H245EndSessionCommand_gstnOptions { int t; } H245EndSessionCommand_gstnOptions; EXTERN int asn1PE_H245EndSessionCommand_gstnOptions (OOCTXT* pctxt, H245EndSessionCommand_gstnOptions* pvalue); EXTERN int asn1PD_H245EndSessionCommand_gstnOptions (OOCTXT* pctxt, H245EndSessionCommand_gstnOptions* pvalue); /**************************************************************/ /* */ /* EndSessionCommand_isdnOptions */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245EndSessionCommand_isdnOptions_telephonyMode 1 #define T_H245EndSessionCommand_isdnOptions_v140 2 #define T_H245EndSessionCommand_isdnOptions_terminalOnHold 3 #define T_H245EndSessionCommand_isdnOptions_extElem1 4 typedef struct EXTERN H245EndSessionCommand_isdnOptions { int t; } H245EndSessionCommand_isdnOptions; EXTERN int asn1PE_H245EndSessionCommand_isdnOptions (OOCTXT* pctxt, H245EndSessionCommand_isdnOptions* pvalue); EXTERN int asn1PD_H245EndSessionCommand_isdnOptions (OOCTXT* pctxt, H245EndSessionCommand_isdnOptions* pvalue); /**************************************************************/ /* */ /* EndSessionCommand */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245EndSessionCommand_nonStandard 1 #define T_H245EndSessionCommand_disconnect 2 #define T_H245EndSessionCommand_gstnOptions 3 #define T_H245EndSessionCommand_isdnOptions 4 #define T_H245EndSessionCommand_extElem1 5 typedef struct EXTERN H245EndSessionCommand { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ H245EndSessionCommand_gstnOptions *gstnOptions; /* t = 4 */ H245EndSessionCommand_isdnOptions *isdnOptions; /* t = 5 */ } u; } H245EndSessionCommand; EXTERN int asn1PE_H245EndSessionCommand (OOCTXT* pctxt, H245EndSessionCommand* pvalue); EXTERN int asn1PD_H245EndSessionCommand (OOCTXT* pctxt, H245EndSessionCommand* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoFastUpdateGOB */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousCommand_type_videoFastUpdateGOB { ASN1UINT8 firstGOB; ASN1UINT8 numberOfGOBs; } H245MiscellaneousCommand_type_videoFastUpdateGOB; EXTERN int asn1PE_H245MiscellaneousCommand_type_videoFastUpdateGOB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateGOB* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand_type_videoFastUpdateGOB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateGOB* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoFastUpdateMB */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousCommand_type_videoFastUpdateMB { struct { unsigned firstGOBPresent : 1; unsigned firstMBPresent : 1; } m; ASN1UINT8 firstGOB; ASN1USINT firstMB; ASN1USINT numberOfMBs; } H245MiscellaneousCommand_type_videoFastUpdateMB; EXTERN int asn1PE_H245MiscellaneousCommand_type_videoFastUpdateMB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateMB* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand_type_videoFastUpdateMB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateMB* pvalue); /**************************************************************/ /* */ /* KeyProtectionMethod */ /* */ /**************************************************************/ typedef struct EXTERN H245KeyProtectionMethod { ASN1BOOL secureChannel; ASN1BOOL sharedSecret; ASN1BOOL certProtectedKey; } H245KeyProtectionMethod; EXTERN int asn1PE_H245KeyProtectionMethod (OOCTXT* pctxt, H245KeyProtectionMethod* pvalue); EXTERN int asn1PD_H245KeyProtectionMethod (OOCTXT* pctxt, H245KeyProtectionMethod* pvalue); /**************************************************************/ /* */ /* EncryptionUpdateRequest */ /* */ /**************************************************************/ typedef struct EXTERN H245EncryptionUpdateRequest { struct { unsigned keyProtectionMethodPresent : 1; } m; H245KeyProtectionMethod keyProtectionMethod; } H245EncryptionUpdateRequest; EXTERN int asn1PE_H245EncryptionUpdateRequest (OOCTXT* pctxt, H245EncryptionUpdateRequest* pvalue); EXTERN int asn1PD_H245EncryptionUpdateRequest (OOCTXT* pctxt, H245EncryptionUpdateRequest* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand_type_progressiveRefinementStart_rep */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount_doOneProgression 1 #define T_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount_doContinuousProgressions 2 #define T_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount_doOneIndependentProgression 3 #define T_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount_doContinuousIndependentProgressions 4 #define T_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount_extElem1 5 typedef struct EXTERN H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount { int t; } H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount; EXTERN int asn1PE_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand_type_progressiveRefinementStart */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousCommand_type_progressiveRefinementStart { H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount repeatCount; } H245MiscellaneousCommand_type_progressiveRefinementStart; EXTERN int asn1PE_H245MiscellaneousCommand_type_progressiveRefinementStart (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand_type_progressiveRefinementStart (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoBadMBs */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousCommand_type_videoBadMBs { ASN1USINT firstMB; ASN1USINT numberOfMBs; ASN1USINT temporalReference; } H245MiscellaneousCommand_type_videoBadMBs; EXTERN int asn1PE_H245MiscellaneousCommand_type_videoBadMBs (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoBadMBs* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand_type_videoBadMBs (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoBadMBs* pvalue); /**************************************************************/ /* */ /* PictureReference */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245PictureReference_pictureNumber 1 #define T_H245PictureReference_longTermPictureIndex 2 #define T_H245PictureReference_extElem1 3 typedef struct EXTERN H245PictureReference { int t; union { /* t = 1 */ ASN1USINT pictureNumber; /* t = 2 */ ASN1UINT8 longTermPictureIndex; /* t = 3 */ } u; } H245PictureReference; EXTERN int asn1PE_H245PictureReference (OOCTXT* pctxt, H245PictureReference* pvalue); EXTERN int asn1PD_H245PictureReference (OOCTXT* pctxt, H245PictureReference* pvalue); /**************************************************************/ /* */ /* _SeqOfH245PictureReference */ /* */ /**************************************************************/ /* List of H245PictureReference */ typedef DList H245_SeqOfH245PictureReference; EXTERN int asn1PE_H245_SeqOfH245PictureReference (OOCTXT* pctxt, H245_SeqOfH245PictureReference* pvalue); EXTERN int asn1PD_H245_SeqOfH245PictureReference (OOCTXT* pctxt, H245_SeqOfH245PictureReference* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand_type_lostPartialPicture */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousCommand_type_lostPartialPicture { H245PictureReference pictureReference; ASN1USINT firstMB; ASN1USINT numberOfMBs; } H245MiscellaneousCommand_type_lostPartialPicture; EXTERN int asn1PE_H245MiscellaneousCommand_type_lostPartialPicture (OOCTXT* pctxt, H245MiscellaneousCommand_type_lostPartialPicture* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand_type_lostPartialPicture (OOCTXT* pctxt, H245MiscellaneousCommand_type_lostPartialPicture* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MiscellaneousCommand_type_equaliseDelay 1 #define T_H245MiscellaneousCommand_type_zeroDelay 2 #define T_H245MiscellaneousCommand_type_multipointModeCommand 3 #define T_H245MiscellaneousCommand_type_cancelMultipointModeCommand 4 #define T_H245MiscellaneousCommand_type_videoFreezePicture 5 #define T_H245MiscellaneousCommand_type_videoFastUpdatePicture 6 #define T_H245MiscellaneousCommand_type_videoFastUpdateGOB 7 #define T_H245MiscellaneousCommand_type_videoTemporalSpatialTradeOff 8 #define T_H245MiscellaneousCommand_type_videoSendSyncEveryGOB 9 #define T_H245MiscellaneousCommand_type_videoSendSyncEveryGOBCancel 10 #define T_H245MiscellaneousCommand_type_videoFastUpdateMB 11 #define T_H245MiscellaneousCommand_type_maxH223MUXPDUsize 12 #define T_H245MiscellaneousCommand_type_encryptionUpdate 13 #define T_H245MiscellaneousCommand_type_encryptionUpdateRequest 14 #define T_H245MiscellaneousCommand_type_switchReceiveMediaOff 15 #define T_H245MiscellaneousCommand_type_switchReceiveMediaOn 16 #define T_H245MiscellaneousCommand_type_progressiveRefinementStart 17 #define T_H245MiscellaneousCommand_type_progressiveRefinementAbortOne 18 #define T_H245MiscellaneousCommand_type_progressiveRefinementAbortContinuous 19 #define T_H245MiscellaneousCommand_type_videoBadMBs 20 #define T_H245MiscellaneousCommand_type_lostPicture 21 #define T_H245MiscellaneousCommand_type_lostPartialPicture 22 #define T_H245MiscellaneousCommand_type_recoveryReferencePicture 23 #define T_H245MiscellaneousCommand_type_extElem1 24 typedef struct EXTERN H245MiscellaneousCommand_type { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ H245MiscellaneousCommand_type_videoFastUpdateGOB *videoFastUpdateGOB; /* t = 8 */ ASN1UINT8 videoTemporalSpatialTradeOff; /* t = 9 */ /* t = 10 */ /* t = 11 */ H245MiscellaneousCommand_type_videoFastUpdateMB *videoFastUpdateMB; /* t = 12 */ ASN1USINT maxH223MUXPDUsize; /* t = 13 */ H245EncryptionSync *encryptionUpdate; /* t = 14 */ H245EncryptionUpdateRequest *encryptionUpdateRequest; /* t = 15 */ /* t = 16 */ /* t = 17 */ H245MiscellaneousCommand_type_progressiveRefinementStart *progressiveRefinementStart; /* t = 18 */ /* t = 19 */ /* t = 20 */ H245MiscellaneousCommand_type_videoBadMBs *videoBadMBs; /* t = 21 */ H245_SeqOfH245PictureReference *lostPicture; /* t = 22 */ H245MiscellaneousCommand_type_lostPartialPicture *lostPartialPicture; /* t = 23 */ H245_SeqOfH245PictureReference *recoveryReferencePicture; /* t = 24 */ } u; } H245MiscellaneousCommand_type; EXTERN int asn1PE_H245MiscellaneousCommand_type (OOCTXT* pctxt, H245MiscellaneousCommand_type* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand_type (OOCTXT* pctxt, H245MiscellaneousCommand_type* pvalue); /**************************************************************/ /* */ /* MiscellaneousCommand */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousCommand { H245LogicalChannelNumber logicalChannelNumber; H245MiscellaneousCommand_type type; } H245MiscellaneousCommand; EXTERN int asn1PE_H245MiscellaneousCommand (OOCTXT* pctxt, H245MiscellaneousCommand* pvalue); EXTERN int asn1PD_H245MiscellaneousCommand (OOCTXT* pctxt, H245MiscellaneousCommand* pvalue); /**************************************************************/ /* */ /* CommunicationModeCommand_communicationModeTable */ /* */ /**************************************************************/ /* List of H245CommunicationModeTableEntry */ typedef DList H245CommunicationModeCommand_communicationModeTable; EXTERN int asn1PE_H245CommunicationModeCommand_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeCommand_communicationModeTable* pvalue); EXTERN int asn1PD_H245CommunicationModeCommand_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeCommand_communicationModeTable* pvalue); /**************************************************************/ /* */ /* CommunicationModeCommand */ /* */ /**************************************************************/ typedef struct EXTERN H245CommunicationModeCommand { H245CommunicationModeCommand_communicationModeTable communicationModeTable; } H245CommunicationModeCommand; EXTERN int asn1PE_H245CommunicationModeCommand (OOCTXT* pctxt, H245CommunicationModeCommand* pvalue); EXTERN int asn1PD_H245CommunicationModeCommand (OOCTXT* pctxt, H245CommunicationModeCommand* pvalue); /**************************************************************/ /* */ /* SubstituteConferenceIDCommand_conferenceIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H245SubstituteConferenceIDCommand_conferenceIdentifier { ASN1UINT numocts; ASN1OCTET data[16]; } H245SubstituteConferenceIDCommand_conferenceIdentifier; EXTERN int asn1PE_H245SubstituteConferenceIDCommand_conferenceIdentifier (OOCTXT* pctxt, H245SubstituteConferenceIDCommand_conferenceIdentifier* pvalue); EXTERN int asn1PD_H245SubstituteConferenceIDCommand_conferenceIdentifier (OOCTXT* pctxt, H245SubstituteConferenceIDCommand_conferenceIdentifier* pvalue); /**************************************************************/ /* */ /* SubstituteConferenceIDCommand */ /* */ /**************************************************************/ typedef struct EXTERN H245SubstituteConferenceIDCommand { H245SubstituteConferenceIDCommand_conferenceIdentifier conferenceIdentifier; } H245SubstituteConferenceIDCommand; EXTERN int asn1PE_H245SubstituteConferenceIDCommand (OOCTXT* pctxt, H245SubstituteConferenceIDCommand* pvalue); EXTERN int asn1PD_H245SubstituteConferenceIDCommand (OOCTXT* pctxt, H245SubstituteConferenceIDCommand* pvalue); /**************************************************************/ /* */ /* ConferenceCommand */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceCommand_broadcastMyLogicalChannel 1 #define T_H245ConferenceCommand_cancelBroadcastMyLogicalChannel 2 #define T_H245ConferenceCommand_makeTerminalBroadcaster 3 #define T_H245ConferenceCommand_cancelMakeTerminalBroadcaster 4 #define T_H245ConferenceCommand_sendThisSource 5 #define T_H245ConferenceCommand_cancelSendThisSource 6 #define T_H245ConferenceCommand_dropConference 7 #define T_H245ConferenceCommand_substituteConferenceIDCommand 8 #define T_H245ConferenceCommand_extElem1 9 typedef struct EXTERN H245ConferenceCommand { int t; union { /* t = 1 */ H245LogicalChannelNumber broadcastMyLogicalChannel; /* t = 2 */ H245LogicalChannelNumber cancelBroadcastMyLogicalChannel; /* t = 3 */ H245TerminalLabel *makeTerminalBroadcaster; /* t = 4 */ /* t = 5 */ H245TerminalLabel *sendThisSource; /* t = 6 */ /* t = 7 */ /* t = 8 */ H245SubstituteConferenceIDCommand *substituteConferenceIDCommand; /* t = 9 */ } u; } H245ConferenceCommand; EXTERN int asn1PE_H245ConferenceCommand (OOCTXT* pctxt, H245ConferenceCommand* pvalue); EXTERN int asn1PD_H245ConferenceCommand (OOCTXT* pctxt, H245ConferenceCommand* pvalue); /**************************************************************/ /* */ /* H223MultiplexReconfiguration_h223ModeChange */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223MultiplexReconfiguration_h223ModeChange_toLevel0 1 #define T_H245H223MultiplexReconfiguration_h223ModeChange_toLevel1 2 #define T_H245H223MultiplexReconfiguration_h223ModeChange_toLevel2 3 #define T_H245H223MultiplexReconfiguration_h223ModeChange_toLevel2withOptionalHeader 4 #define T_H245H223MultiplexReconfiguration_h223ModeChange_extElem1 5 typedef struct EXTERN H245H223MultiplexReconfiguration_h223ModeChange { int t; } H245H223MultiplexReconfiguration_h223ModeChange; EXTERN int asn1PE_H245H223MultiplexReconfiguration_h223ModeChange (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223ModeChange* pvalue); EXTERN int asn1PD_H245H223MultiplexReconfiguration_h223ModeChange (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223ModeChange* pvalue); /**************************************************************/ /* */ /* H223MultiplexReconfiguration_h223AnnexADoubleFlag */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag_start 1 #define T_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag_stop 2 #define T_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag_extElem1 3 typedef struct EXTERN H245H223MultiplexReconfiguration_h223AnnexADoubleFlag { int t; } H245H223MultiplexReconfiguration_h223AnnexADoubleFlag; EXTERN int asn1PE_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223AnnexADoubleFlag* pvalue); EXTERN int asn1PD_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223AnnexADoubleFlag* pvalue); /**************************************************************/ /* */ /* H223MultiplexReconfiguration */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245H223MultiplexReconfiguration_h223ModeChange 1 #define T_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag 2 #define T_H245H223MultiplexReconfiguration_extElem1 3 typedef struct EXTERN H245H223MultiplexReconfiguration { int t; union { /* t = 1 */ H245H223MultiplexReconfiguration_h223ModeChange *h223ModeChange; /* t = 2 */ H245H223MultiplexReconfiguration_h223AnnexADoubleFlag *h223AnnexADoubleFlag; /* t = 3 */ } u; } H245H223MultiplexReconfiguration; EXTERN int asn1PE_H245H223MultiplexReconfiguration (OOCTXT* pctxt, H245H223MultiplexReconfiguration* pvalue); EXTERN int asn1PD_H245H223MultiplexReconfiguration (OOCTXT* pctxt, H245H223MultiplexReconfiguration* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1_clockRecovery */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCCommand_aal_aal1_clockRecovery_nullClockRecovery 1 #define T_H245NewATMVCCommand_aal_aal1_clockRecovery_srtsClockRecovery 2 #define T_H245NewATMVCCommand_aal_aal1_clockRecovery_adaptiveClockRecovery 3 #define T_H245NewATMVCCommand_aal_aal1_clockRecovery_extElem1 4 typedef struct EXTERN H245NewATMVCCommand_aal_aal1_clockRecovery { int t; } H245NewATMVCCommand_aal_aal1_clockRecovery; EXTERN int asn1PE_H245NewATMVCCommand_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_clockRecovery* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_clockRecovery* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1_errorCorrection */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCCommand_aal_aal1_errorCorrection_nullErrorCorrection 1 #define T_H245NewATMVCCommand_aal_aal1_errorCorrection_longInterleaver 2 #define T_H245NewATMVCCommand_aal_aal1_errorCorrection_shortInterleaver 3 #define T_H245NewATMVCCommand_aal_aal1_errorCorrection_errorCorrectionOnly 4 #define T_H245NewATMVCCommand_aal_aal1_errorCorrection_extElem1 5 typedef struct EXTERN H245NewATMVCCommand_aal_aal1_errorCorrection { int t; } H245NewATMVCCommand_aal_aal1_errorCorrection; EXTERN int asn1PE_H245NewATMVCCommand_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_errorCorrection* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_errorCorrection* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1 */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCCommand_aal_aal1 { H245NewATMVCCommand_aal_aal1_clockRecovery clockRecovery; H245NewATMVCCommand_aal_aal1_errorCorrection errorCorrection; ASN1BOOL structuredDataTransfer; ASN1BOOL partiallyFilledCells; } H245NewATMVCCommand_aal_aal1; EXTERN int asn1PE_H245NewATMVCCommand_aal_aal1 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_aal_aal1 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal5 */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCCommand_aal_aal5 { ASN1USINT forwardMaximumSDUSize; ASN1USINT backwardMaximumSDUSize; } H245NewATMVCCommand_aal_aal5; EXTERN int asn1PE_H245NewATMVCCommand_aal_aal5 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal5* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_aal_aal5 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal5* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_aal */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCCommand_aal_aal1 1 #define T_H245NewATMVCCommand_aal_aal5 2 #define T_H245NewATMVCCommand_aal_extElem1 3 typedef struct EXTERN H245NewATMVCCommand_aal { int t; union { /* t = 1 */ H245NewATMVCCommand_aal_aal1 *aal1; /* t = 2 */ H245NewATMVCCommand_aal_aal5 *aal5; /* t = 3 */ } u; } H245NewATMVCCommand_aal; EXTERN int asn1PE_H245NewATMVCCommand_aal (OOCTXT* pctxt, H245NewATMVCCommand_aal* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_aal (OOCTXT* pctxt, H245NewATMVCCommand_aal* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_multiplex */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCCommand_multiplex_noMultiplex 1 #define T_H245NewATMVCCommand_multiplex_transportStream 2 #define T_H245NewATMVCCommand_multiplex_programStream 3 #define T_H245NewATMVCCommand_multiplex_extElem1 4 typedef struct EXTERN H245NewATMVCCommand_multiplex { int t; } H245NewATMVCCommand_multiplex; EXTERN int asn1PE_H245NewATMVCCommand_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_multiplex* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_multiplex* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_reverseParameters_multiplex */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCCommand_reverseParameters_multiplex_noMultiplex 1 #define T_H245NewATMVCCommand_reverseParameters_multiplex_transportStream 2 #define T_H245NewATMVCCommand_reverseParameters_multiplex_programStream 3 #define T_H245NewATMVCCommand_reverseParameters_multiplex_extElem1 4 typedef struct EXTERN H245NewATMVCCommand_reverseParameters_multiplex { int t; } H245NewATMVCCommand_reverseParameters_multiplex; EXTERN int asn1PE_H245NewATMVCCommand_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters_multiplex* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters_multiplex* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand_reverseParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCCommand_reverseParameters { ASN1USINT bitRate; ASN1BOOL bitRateLockedToPCRClock; ASN1BOOL bitRateLockedToNetworkClock; H245NewATMVCCommand_reverseParameters_multiplex multiplex; } H245NewATMVCCommand_reverseParameters; EXTERN int asn1PE_H245NewATMVCCommand_reverseParameters (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters* pvalue); EXTERN int asn1PD_H245NewATMVCCommand_reverseParameters (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters* pvalue); /**************************************************************/ /* */ /* NewATMVCCommand */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCCommand { ASN1USINT resourceID; ASN1USINT bitRate; ASN1BOOL bitRateLockedToPCRClock; ASN1BOOL bitRateLockedToNetworkClock; H245NewATMVCCommand_aal aal; H245NewATMVCCommand_multiplex multiplex; H245NewATMVCCommand_reverseParameters reverseParameters; } H245NewATMVCCommand; EXTERN int asn1PE_H245NewATMVCCommand (OOCTXT* pctxt, H245NewATMVCCommand* pvalue); EXTERN int asn1PD_H245NewATMVCCommand (OOCTXT* pctxt, H245NewATMVCCommand* pvalue); /**************************************************************/ /* */ /* MobileMultilinkReconfigurationCommand_status */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MobileMultilinkReconfigurationCommand_status_synchronized_ 1 #define T_H245MobileMultilinkReconfigurationCommand_status_reconfiguration 2 #define T_H245MobileMultilinkReconfigurationCommand_status_extElem1 3 typedef struct EXTERN H245MobileMultilinkReconfigurationCommand_status { int t; } H245MobileMultilinkReconfigurationCommand_status; EXTERN int asn1PE_H245MobileMultilinkReconfigurationCommand_status (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand_status* pvalue); EXTERN int asn1PD_H245MobileMultilinkReconfigurationCommand_status (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand_status* pvalue); /**************************************************************/ /* */ /* MobileMultilinkReconfigurationCommand */ /* */ /**************************************************************/ typedef struct EXTERN H245MobileMultilinkReconfigurationCommand { ASN1UINT8 sampleSize; ASN1UINT8 samplesPerFrame; H245MobileMultilinkReconfigurationCommand_status status; } H245MobileMultilinkReconfigurationCommand; EXTERN int asn1PE_H245MobileMultilinkReconfigurationCommand (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand* pvalue); EXTERN int asn1PD_H245MobileMultilinkReconfigurationCommand (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand* pvalue); /**************************************************************/ /* */ /* CommandMessage */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245CommandMessage_nonStandard 1 #define T_H245CommandMessage_maintenanceLoopOffCommand 2 #define T_H245CommandMessage_sendTerminalCapabilitySet 3 #define T_H245CommandMessage_encryptionCommand 4 #define T_H245CommandMessage_flowControlCommand 5 #define T_H245CommandMessage_endSessionCommand 6 #define T_H245CommandMessage_miscellaneousCommand 7 #define T_H245CommandMessage_communicationModeCommand 8 #define T_H245CommandMessage_conferenceCommand 9 #define T_H245CommandMessage_h223MultiplexReconfiguration 10 #define T_H245CommandMessage_newATMVCCommand 11 #define T_H245CommandMessage_mobileMultilinkReconfigurationCommand 12 #define T_H245CommandMessage_extElem1 13 typedef struct EXTERN H245CommandMessage { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245MaintenanceLoopOffCommand *maintenanceLoopOffCommand; /* t = 3 */ H245SendTerminalCapabilitySet *sendTerminalCapabilitySet; /* t = 4 */ H245EncryptionCommand *encryptionCommand; /* t = 5 */ H245FlowControlCommand *flowControlCommand; /* t = 6 */ H245EndSessionCommand *endSessionCommand; /* t = 7 */ H245MiscellaneousCommand *miscellaneousCommand; /* t = 8 */ H245CommunicationModeCommand *communicationModeCommand; /* t = 9 */ H245ConferenceCommand *conferenceCommand; /* t = 10 */ H245H223MultiplexReconfiguration *h223MultiplexReconfiguration; /* t = 11 */ H245NewATMVCCommand *newATMVCCommand; /* t = 12 */ H245MobileMultilinkReconfigurationCommand *mobileMultilinkReconfigurationCommand; /* t = 13 */ } u; } H245CommandMessage; EXTERN int asn1PE_H245CommandMessage (OOCTXT* pctxt, H245CommandMessage* pvalue); EXTERN int asn1PD_H245CommandMessage (OOCTXT* pctxt, H245CommandMessage* pvalue); /**************************************************************/ /* */ /* FunctionNotUnderstood */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FunctionNotUnderstood_request 1 #define T_H245FunctionNotUnderstood_response 2 #define T_H245FunctionNotUnderstood_command 3 typedef struct EXTERN H245FunctionNotUnderstood { int t; union { /* t = 1 */ H245RequestMessage *request; /* t = 2 */ H245ResponseMessage *response; /* t = 3 */ H245CommandMessage *command; } u; } H245FunctionNotUnderstood; EXTERN int asn1PE_H245FunctionNotUnderstood (OOCTXT* pctxt, H245FunctionNotUnderstood* pvalue); EXTERN int asn1PD_H245FunctionNotUnderstood (OOCTXT* pctxt, H245FunctionNotUnderstood* pvalue); /**************************************************************/ /* */ /* MasterSlaveDeterminationRelease */ /* */ /**************************************************************/ typedef struct EXTERN H245MasterSlaveDeterminationRelease { ASN1OCTET __dummy__; } H245MasterSlaveDeterminationRelease; EXTERN int asn1PE_H245MasterSlaveDeterminationRelease (OOCTXT* pctxt, H245MasterSlaveDeterminationRelease* pvalue); EXTERN int asn1PD_H245MasterSlaveDeterminationRelease (OOCTXT* pctxt, H245MasterSlaveDeterminationRelease* pvalue); /**************************************************************/ /* */ /* TerminalCapabilitySetRelease */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalCapabilitySetRelease { ASN1OCTET __dummy__; } H245TerminalCapabilitySetRelease; EXTERN int asn1PE_H245TerminalCapabilitySetRelease (OOCTXT* pctxt, H245TerminalCapabilitySetRelease* pvalue); EXTERN int asn1PD_H245TerminalCapabilitySetRelease (OOCTXT* pctxt, H245TerminalCapabilitySetRelease* pvalue); /**************************************************************/ /* */ /* OpenLogicalChannelConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H245OpenLogicalChannelConfirm { H245LogicalChannelNumber forwardLogicalChannelNumber; } H245OpenLogicalChannelConfirm; EXTERN int asn1PE_H245OpenLogicalChannelConfirm (OOCTXT* pctxt, H245OpenLogicalChannelConfirm* pvalue); EXTERN int asn1PD_H245OpenLogicalChannelConfirm (OOCTXT* pctxt, H245OpenLogicalChannelConfirm* pvalue); /**************************************************************/ /* */ /* RequestChannelCloseRelease */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestChannelCloseRelease { H245LogicalChannelNumber forwardLogicalChannelNumber; } H245RequestChannelCloseRelease; EXTERN int asn1PE_H245RequestChannelCloseRelease (OOCTXT* pctxt, H245RequestChannelCloseRelease* pvalue); EXTERN int asn1PD_H245RequestChannelCloseRelease (OOCTXT* pctxt, H245RequestChannelCloseRelease* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySendRelease_multiplexTableEntryNumber */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntrySendRelease_multiplexTableEntryNumber { ASN1UINT n; H245MultiplexTableEntryNumber elem[15]; } H245MultiplexEntrySendRelease_multiplexTableEntryNumber; EXTERN int asn1PE_H245MultiplexEntrySendRelease_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendRelease_multiplexTableEntryNumber* pvalue); EXTERN int asn1PD_H245MultiplexEntrySendRelease_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendRelease_multiplexTableEntryNumber* pvalue); /**************************************************************/ /* */ /* MultiplexEntrySendRelease */ /* */ /**************************************************************/ typedef struct EXTERN H245MultiplexEntrySendRelease { H245MultiplexEntrySendRelease_multiplexTableEntryNumber multiplexTableEntryNumber; } H245MultiplexEntrySendRelease; EXTERN int asn1PE_H245MultiplexEntrySendRelease (OOCTXT* pctxt, H245MultiplexEntrySendRelease* pvalue); EXTERN int asn1PD_H245MultiplexEntrySendRelease (OOCTXT* pctxt, H245MultiplexEntrySendRelease* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryRelease_entryNumbers */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntryRelease_entryNumbers { ASN1UINT n; H245MultiplexTableEntryNumber elem[15]; } H245RequestMultiplexEntryRelease_entryNumbers; EXTERN int asn1PE_H245RequestMultiplexEntryRelease_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryRelease_entryNumbers* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryRelease_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryRelease_entryNumbers* pvalue); /**************************************************************/ /* */ /* RequestMultiplexEntryRelease */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestMultiplexEntryRelease { H245RequestMultiplexEntryRelease_entryNumbers entryNumbers; } H245RequestMultiplexEntryRelease; EXTERN int asn1PE_H245RequestMultiplexEntryRelease (OOCTXT* pctxt, H245RequestMultiplexEntryRelease* pvalue); EXTERN int asn1PD_H245RequestMultiplexEntryRelease (OOCTXT* pctxt, H245RequestMultiplexEntryRelease* pvalue); /**************************************************************/ /* */ /* RequestModeRelease */ /* */ /**************************************************************/ typedef struct EXTERN H245RequestModeRelease { ASN1OCTET __dummy__; } H245RequestModeRelease; EXTERN int asn1PE_H245RequestModeRelease (OOCTXT* pctxt, H245RequestModeRelease* pvalue); EXTERN int asn1PD_H245RequestModeRelease (OOCTXT* pctxt, H245RequestModeRelease* pvalue); /**************************************************************/ /* */ /* MiscellaneousIndication_type_videoNotDecodedMBs */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousIndication_type_videoNotDecodedMBs { ASN1USINT firstMB; ASN1USINT numberOfMBs; ASN1UINT8 temporalReference; } H245MiscellaneousIndication_type_videoNotDecodedMBs; EXTERN int asn1PE_H245MiscellaneousIndication_type_videoNotDecodedMBs (OOCTXT* pctxt, H245MiscellaneousIndication_type_videoNotDecodedMBs* pvalue); EXTERN int asn1PD_H245MiscellaneousIndication_type_videoNotDecodedMBs (OOCTXT* pctxt, H245MiscellaneousIndication_type_videoNotDecodedMBs* pvalue); /**************************************************************/ /* */ /* MiscellaneousIndication_type */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MiscellaneousIndication_type_logicalChannelActive 1 #define T_H245MiscellaneousIndication_type_logicalChannelInactive 2 #define T_H245MiscellaneousIndication_type_multipointConference 3 #define T_H245MiscellaneousIndication_type_cancelMultipointConference 4 #define T_H245MiscellaneousIndication_type_multipointZeroComm 5 #define T_H245MiscellaneousIndication_type_cancelMultipointZeroComm 6 #define T_H245MiscellaneousIndication_type_multipointSecondaryStatus 7 #define T_H245MiscellaneousIndication_type_cancelMultipointSecondaryStatus 8 #define T_H245MiscellaneousIndication_type_videoIndicateReadyToActivate 9 #define T_H245MiscellaneousIndication_type_videoTemporalSpatialTradeOff 10 #define T_H245MiscellaneousIndication_type_videoNotDecodedMBs 11 #define T_H245MiscellaneousIndication_type_transportCapability 12 #define T_H245MiscellaneousIndication_type_extElem1 13 typedef struct EXTERN H245MiscellaneousIndication_type { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ /* t = 10 */ ASN1UINT8 videoTemporalSpatialTradeOff; /* t = 11 */ H245MiscellaneousIndication_type_videoNotDecodedMBs *videoNotDecodedMBs; /* t = 12 */ H245TransportCapability *transportCapability; /* t = 13 */ } u; } H245MiscellaneousIndication_type; EXTERN int asn1PE_H245MiscellaneousIndication_type (OOCTXT* pctxt, H245MiscellaneousIndication_type* pvalue); EXTERN int asn1PD_H245MiscellaneousIndication_type (OOCTXT* pctxt, H245MiscellaneousIndication_type* pvalue); /**************************************************************/ /* */ /* MiscellaneousIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245MiscellaneousIndication { H245LogicalChannelNumber logicalChannelNumber; H245MiscellaneousIndication_type type; } H245MiscellaneousIndication; EXTERN int asn1PE_H245MiscellaneousIndication (OOCTXT* pctxt, H245MiscellaneousIndication* pvalue); EXTERN int asn1PD_H245MiscellaneousIndication (OOCTXT* pctxt, H245MiscellaneousIndication* pvalue); /**************************************************************/ /* */ /* JitterIndication_scope */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245JitterIndication_scope_logicalChannelNumber 1 #define T_H245JitterIndication_scope_resourceID 2 #define T_H245JitterIndication_scope_wholeMultiplex 3 typedef struct EXTERN H245JitterIndication_scope { int t; union { /* t = 1 */ H245LogicalChannelNumber logicalChannelNumber; /* t = 2 */ ASN1USINT resourceID; /* t = 3 */ } u; } H245JitterIndication_scope; EXTERN int asn1PE_H245JitterIndication_scope (OOCTXT* pctxt, H245JitterIndication_scope* pvalue); EXTERN int asn1PD_H245JitterIndication_scope (OOCTXT* pctxt, H245JitterIndication_scope* pvalue); /**************************************************************/ /* */ /* JitterIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245JitterIndication { struct { unsigned skippedFrameCountPresent : 1; unsigned additionalDecoderBufferPresent : 1; } m; H245JitterIndication_scope scope; ASN1UINT8 estimatedReceivedJitterMantissa; ASN1UINT8 estimatedReceivedJitterExponent; ASN1UINT8 skippedFrameCount; ASN1UINT additionalDecoderBuffer; } H245JitterIndication; EXTERN int asn1PE_H245JitterIndication (OOCTXT* pctxt, H245JitterIndication* pvalue); EXTERN int asn1PD_H245JitterIndication (OOCTXT* pctxt, H245JitterIndication* pvalue); /**************************************************************/ /* */ /* H223SkewIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245H223SkewIndication { H245LogicalChannelNumber logicalChannelNumber1; H245LogicalChannelNumber logicalChannelNumber2; ASN1USINT skew; } H245H223SkewIndication; EXTERN int asn1PE_H245H223SkewIndication (OOCTXT* pctxt, H245H223SkewIndication* pvalue); EXTERN int asn1PD_H245H223SkewIndication (OOCTXT* pctxt, H245H223SkewIndication* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1_clockRecovery */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCIndication_aal_aal1_clockRecovery_nullClockRecovery 1 #define T_H245NewATMVCIndication_aal_aal1_clockRecovery_srtsClockRecovery 2 #define T_H245NewATMVCIndication_aal_aal1_clockRecovery_adaptiveClockRecovery 3 #define T_H245NewATMVCIndication_aal_aal1_clockRecovery_extElem1 4 typedef struct EXTERN H245NewATMVCIndication_aal_aal1_clockRecovery { int t; } H245NewATMVCIndication_aal_aal1_clockRecovery; EXTERN int asn1PE_H245NewATMVCIndication_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_clockRecovery* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_clockRecovery* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1_errorCorrection */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCIndication_aal_aal1_errorCorrection_nullErrorCorrection 1 #define T_H245NewATMVCIndication_aal_aal1_errorCorrection_longInterleaver 2 #define T_H245NewATMVCIndication_aal_aal1_errorCorrection_shortInterleaver 3 #define T_H245NewATMVCIndication_aal_aal1_errorCorrection_errorCorrectionOnly 4 #define T_H245NewATMVCIndication_aal_aal1_errorCorrection_extElem1 5 typedef struct EXTERN H245NewATMVCIndication_aal_aal1_errorCorrection { int t; } H245NewATMVCIndication_aal_aal1_errorCorrection; EXTERN int asn1PE_H245NewATMVCIndication_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_errorCorrection* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_errorCorrection* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1 */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCIndication_aal_aal1 { H245NewATMVCIndication_aal_aal1_clockRecovery clockRecovery; H245NewATMVCIndication_aal_aal1_errorCorrection errorCorrection; ASN1BOOL structuredDataTransfer; ASN1BOOL partiallyFilledCells; } H245NewATMVCIndication_aal_aal1; EXTERN int asn1PE_H245NewATMVCIndication_aal_aal1 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_aal_aal1 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal5 */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCIndication_aal_aal5 { ASN1USINT forwardMaximumSDUSize; ASN1USINT backwardMaximumSDUSize; } H245NewATMVCIndication_aal_aal5; EXTERN int asn1PE_H245NewATMVCIndication_aal_aal5 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal5* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_aal_aal5 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal5* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_aal */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCIndication_aal_aal1 1 #define T_H245NewATMVCIndication_aal_aal5 2 #define T_H245NewATMVCIndication_aal_extElem1 3 typedef struct EXTERN H245NewATMVCIndication_aal { int t; union { /* t = 1 */ H245NewATMVCIndication_aal_aal1 *aal1; /* t = 2 */ H245NewATMVCIndication_aal_aal5 *aal5; /* t = 3 */ } u; } H245NewATMVCIndication_aal; EXTERN int asn1PE_H245NewATMVCIndication_aal (OOCTXT* pctxt, H245NewATMVCIndication_aal* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_aal (OOCTXT* pctxt, H245NewATMVCIndication_aal* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_multiplex */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCIndication_multiplex_noMultiplex 1 #define T_H245NewATMVCIndication_multiplex_transportStream 2 #define T_H245NewATMVCIndication_multiplex_programStream 3 #define T_H245NewATMVCIndication_multiplex_extElem1 4 typedef struct EXTERN H245NewATMVCIndication_multiplex { int t; } H245NewATMVCIndication_multiplex; EXTERN int asn1PE_H245NewATMVCIndication_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_multiplex* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_multiplex* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_reverseParameters_multiplex */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245NewATMVCIndication_reverseParameters_multiplex_noMultiplex 1 #define T_H245NewATMVCIndication_reverseParameters_multiplex_transportStream 2 #define T_H245NewATMVCIndication_reverseParameters_multiplex_programStream 3 #define T_H245NewATMVCIndication_reverseParameters_multiplex_extElem1 4 typedef struct EXTERN H245NewATMVCIndication_reverseParameters_multiplex { int t; } H245NewATMVCIndication_reverseParameters_multiplex; EXTERN int asn1PE_H245NewATMVCIndication_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters_multiplex* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters_multiplex* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication_reverseParameters */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCIndication_reverseParameters { ASN1USINT bitRate; ASN1BOOL bitRateLockedToPCRClock; ASN1BOOL bitRateLockedToNetworkClock; H245NewATMVCIndication_reverseParameters_multiplex multiplex; } H245NewATMVCIndication_reverseParameters; EXTERN int asn1PE_H245NewATMVCIndication_reverseParameters (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters* pvalue); EXTERN int asn1PD_H245NewATMVCIndication_reverseParameters (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters* pvalue); /**************************************************************/ /* */ /* NewATMVCIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245NewATMVCIndication { struct { unsigned reverseParametersPresent : 1; } m; ASN1USINT resourceID; ASN1USINT bitRate; ASN1BOOL bitRateLockedToPCRClock; ASN1BOOL bitRateLockedToNetworkClock; H245NewATMVCIndication_aal aal; H245NewATMVCIndication_multiplex multiplex; H245NewATMVCIndication_reverseParameters reverseParameters; } H245NewATMVCIndication; EXTERN int asn1PE_H245NewATMVCIndication (OOCTXT* pctxt, H245NewATMVCIndication* pvalue); EXTERN int asn1PD_H245NewATMVCIndication (OOCTXT* pctxt, H245NewATMVCIndication* pvalue); /**************************************************************/ /* */ /* UserInputIndication_userInputSupportIndication */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245UserInputIndication_userInputSupportIndication_nonStandard 1 #define T_H245UserInputIndication_userInputSupportIndication_basicString 2 #define T_H245UserInputIndication_userInputSupportIndication_iA5String 3 #define T_H245UserInputIndication_userInputSupportIndication_generalString 4 #define T_H245UserInputIndication_userInputSupportIndication_extElem1 5 typedef struct EXTERN H245UserInputIndication_userInputSupportIndication { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ } u; } H245UserInputIndication_userInputSupportIndication; EXTERN int asn1PE_H245UserInputIndication_userInputSupportIndication (OOCTXT* pctxt, H245UserInputIndication_userInputSupportIndication* pvalue); EXTERN int asn1PD_H245UserInputIndication_userInputSupportIndication (OOCTXT* pctxt, H245UserInputIndication_userInputSupportIndication* pvalue); /**************************************************************/ /* */ /* UserInputIndication_signal_rtp */ /* */ /**************************************************************/ typedef struct EXTERN H245UserInputIndication_signal_rtp { struct { unsigned timestampPresent : 1; unsigned expirationTimePresent : 1; } m; ASN1UINT timestamp; ASN1UINT expirationTime; H245LogicalChannelNumber logicalChannelNumber; } H245UserInputIndication_signal_rtp; EXTERN int asn1PE_H245UserInputIndication_signal_rtp (OOCTXT* pctxt, H245UserInputIndication_signal_rtp* pvalue); EXTERN int asn1PD_H245UserInputIndication_signal_rtp (OOCTXT* pctxt, H245UserInputIndication_signal_rtp* pvalue); /**************************************************************/ /* */ /* UserInputIndication_signal */ /* */ /**************************************************************/ typedef struct EXTERN H245UserInputIndication_signal { struct { unsigned durationPresent : 1; unsigned rtpPresent : 1; unsigned rtpPayloadIndicationPresent : 1; } m; ASN1IA5String signalType; ASN1USINT duration; H245UserInputIndication_signal_rtp rtp; } H245UserInputIndication_signal; EXTERN int asn1PE_H245UserInputIndication_signal (OOCTXT* pctxt, H245UserInputIndication_signal* pvalue); EXTERN int asn1PD_H245UserInputIndication_signal (OOCTXT* pctxt, H245UserInputIndication_signal* pvalue); /**************************************************************/ /* */ /* UserInputIndication_signalUpdate_rtp */ /* */ /**************************************************************/ typedef struct EXTERN H245UserInputIndication_signalUpdate_rtp { H245LogicalChannelNumber logicalChannelNumber; } H245UserInputIndication_signalUpdate_rtp; EXTERN int asn1PE_H245UserInputIndication_signalUpdate_rtp (OOCTXT* pctxt, H245UserInputIndication_signalUpdate_rtp* pvalue); EXTERN int asn1PD_H245UserInputIndication_signalUpdate_rtp (OOCTXT* pctxt, H245UserInputIndication_signalUpdate_rtp* pvalue); /**************************************************************/ /* */ /* UserInputIndication_signalUpdate */ /* */ /**************************************************************/ typedef struct EXTERN H245UserInputIndication_signalUpdate { struct { unsigned rtpPresent : 1; } m; ASN1USINT duration; H245UserInputIndication_signalUpdate_rtp rtp; } H245UserInputIndication_signalUpdate; EXTERN int asn1PE_H245UserInputIndication_signalUpdate (OOCTXT* pctxt, H245UserInputIndication_signalUpdate* pvalue); EXTERN int asn1PD_H245UserInputIndication_signalUpdate (OOCTXT* pctxt, H245UserInputIndication_signalUpdate* pvalue); /**************************************************************/ /* */ /* UserInputIndication_extendedAlphanumeric */ /* */ /**************************************************************/ typedef struct EXTERN H245UserInputIndication_extendedAlphanumeric { struct { unsigned rtpPayloadIndicationPresent : 1; } m; ASN1GeneralString alphanumeric; } H245UserInputIndication_extendedAlphanumeric; EXTERN int asn1PE_H245UserInputIndication_extendedAlphanumeric (OOCTXT* pctxt, H245UserInputIndication_extendedAlphanumeric* pvalue); EXTERN int asn1PD_H245UserInputIndication_extendedAlphanumeric (OOCTXT* pctxt, H245UserInputIndication_extendedAlphanumeric* pvalue); /**************************************************************/ /* */ /* UserInputIndication */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245UserInputIndication_nonStandard 1 #define T_H245UserInputIndication_alphanumeric 2 #define T_H245UserInputIndication_userInputSupportIndication 3 #define T_H245UserInputIndication_signal 4 #define T_H245UserInputIndication_signalUpdate 5 #define T_H245UserInputIndication_extendedAlphanumeric 6 #define T_H245UserInputIndication_extElem1 7 typedef struct EXTERN H245UserInputIndication { int t; union { /* t = 1 */ H245NonStandardParameter *nonStandard; /* t = 2 */ ASN1GeneralString alphanumeric; /* t = 3 */ H245UserInputIndication_userInputSupportIndication *userInputSupportIndication; /* t = 4 */ H245UserInputIndication_signal *signal; /* t = 5 */ H245UserInputIndication_signalUpdate *signalUpdate; /* t = 6 */ H245UserInputIndication_extendedAlphanumeric *extendedAlphanumeric; /* t = 7 */ } u; } H245UserInputIndication; EXTERN int asn1PE_H245UserInputIndication (OOCTXT* pctxt, H245UserInputIndication* pvalue); EXTERN int asn1PD_H245UserInputIndication (OOCTXT* pctxt, H245UserInputIndication* pvalue); /**************************************************************/ /* */ /* H2250MaximumSkewIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245H2250MaximumSkewIndication { H245LogicalChannelNumber logicalChannelNumber1; H245LogicalChannelNumber logicalChannelNumber2; ASN1USINT maximumSkew; } H245H2250MaximumSkewIndication; EXTERN int asn1PE_H245H2250MaximumSkewIndication (OOCTXT* pctxt, H245H2250MaximumSkewIndication* pvalue); EXTERN int asn1PD_H245H2250MaximumSkewIndication (OOCTXT* pctxt, H245H2250MaximumSkewIndication* pvalue); /**************************************************************/ /* */ /* MCLocationIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245MCLocationIndication { H245TransportAddress signalAddress; } H245MCLocationIndication; EXTERN int asn1PE_H245MCLocationIndication (OOCTXT* pctxt, H245MCLocationIndication* pvalue); EXTERN int asn1PD_H245MCLocationIndication (OOCTXT* pctxt, H245MCLocationIndication* pvalue); /**************************************************************/ /* */ /* TerminalYouAreSeeingInSubPictureNumber */ /* */ /**************************************************************/ typedef struct EXTERN H245TerminalYouAreSeeingInSubPictureNumber { H245TerminalNumber terminalNumber; ASN1UINT8 subPictureNumber; } H245TerminalYouAreSeeingInSubPictureNumber; EXTERN int asn1PE_H245TerminalYouAreSeeingInSubPictureNumber (OOCTXT* pctxt, H245TerminalYouAreSeeingInSubPictureNumber* pvalue); EXTERN int asn1PD_H245TerminalYouAreSeeingInSubPictureNumber (OOCTXT* pctxt, H245TerminalYouAreSeeingInSubPictureNumber* pvalue); /**************************************************************/ /* */ /* VideoIndicateCompose */ /* */ /**************************************************************/ typedef struct EXTERN H245VideoIndicateCompose { ASN1UINT8 compositionNumber; } H245VideoIndicateCompose; EXTERN int asn1PE_H245VideoIndicateCompose (OOCTXT* pctxt, H245VideoIndicateCompose* pvalue); EXTERN int asn1PD_H245VideoIndicateCompose (OOCTXT* pctxt, H245VideoIndicateCompose* pvalue); /**************************************************************/ /* */ /* ConferenceIndication */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245ConferenceIndication_sbeNumber 1 #define T_H245ConferenceIndication_terminalNumberAssign 2 #define T_H245ConferenceIndication_terminalJoinedConference 3 #define T_H245ConferenceIndication_terminalLeftConference 4 #define T_H245ConferenceIndication_seenByAtLeastOneOther 5 #define T_H245ConferenceIndication_cancelSeenByAtLeastOneOther 6 #define T_H245ConferenceIndication_seenByAll 7 #define T_H245ConferenceIndication_cancelSeenByAll 8 #define T_H245ConferenceIndication_terminalYouAreSeeing 9 #define T_H245ConferenceIndication_requestForFloor 10 #define T_H245ConferenceIndication_withdrawChairToken 11 #define T_H245ConferenceIndication_floorRequested 12 #define T_H245ConferenceIndication_terminalYouAreSeeingInSubPictureNumber 13 #define T_H245ConferenceIndication_videoIndicateCompose 14 #define T_H245ConferenceIndication_extElem1 15 typedef struct EXTERN H245ConferenceIndication { int t; union { /* t = 1 */ ASN1UINT8 sbeNumber; /* t = 2 */ H245TerminalLabel *terminalNumberAssign; /* t = 3 */ H245TerminalLabel *terminalJoinedConference; /* t = 4 */ H245TerminalLabel *terminalLeftConference; /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ H245TerminalLabel *terminalYouAreSeeing; /* t = 10 */ /* t = 11 */ /* t = 12 */ H245TerminalLabel *floorRequested; /* t = 13 */ H245TerminalYouAreSeeingInSubPictureNumber *terminalYouAreSeeingInSubPictureNumber; /* t = 14 */ H245VideoIndicateCompose *videoIndicateCompose; /* t = 15 */ } u; } H245ConferenceIndication; EXTERN int asn1PE_H245ConferenceIndication (OOCTXT* pctxt, H245ConferenceIndication* pvalue); EXTERN int asn1PD_H245ConferenceIndication (OOCTXT* pctxt, H245ConferenceIndication* pvalue); /**************************************************************/ /* */ /* VendorIdentification_productNumber */ /* */ /**************************************************************/ typedef struct EXTERN H245VendorIdentification_productNumber { ASN1UINT numocts; ASN1OCTET data[256]; } H245VendorIdentification_productNumber; EXTERN int asn1PE_H245VendorIdentification_productNumber (OOCTXT* pctxt, H245VendorIdentification_productNumber* pvalue); EXTERN int asn1PD_H245VendorIdentification_productNumber (OOCTXT* pctxt, H245VendorIdentification_productNumber* pvalue); /**************************************************************/ /* */ /* VendorIdentification_versionNumber */ /* */ /**************************************************************/ typedef struct EXTERN H245VendorIdentification_versionNumber { ASN1UINT numocts; ASN1OCTET data[256]; } H245VendorIdentification_versionNumber; EXTERN int asn1PE_H245VendorIdentification_versionNumber (OOCTXT* pctxt, H245VendorIdentification_versionNumber* pvalue); EXTERN int asn1PD_H245VendorIdentification_versionNumber (OOCTXT* pctxt, H245VendorIdentification_versionNumber* pvalue); /**************************************************************/ /* */ /* VendorIdentification */ /* */ /**************************************************************/ typedef struct EXTERN H245VendorIdentification { struct { unsigned productNumberPresent : 1; unsigned versionNumberPresent : 1; } m; H245NonStandardIdentifier vendor; H245VendorIdentification_productNumber productNumber; H245VendorIdentification_versionNumber versionNumber; } H245VendorIdentification; EXTERN int asn1PE_H245VendorIdentification (OOCTXT* pctxt, H245VendorIdentification* pvalue); EXTERN int asn1PD_H245VendorIdentification (OOCTXT* pctxt, H245VendorIdentification* pvalue); /**************************************************************/ /* */ /* FunctionNotSupported_cause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FunctionNotSupported_cause_syntaxError 1 #define T_H245FunctionNotSupported_cause_semanticError 2 #define T_H245FunctionNotSupported_cause_unknownFunction 3 #define T_H245FunctionNotSupported_cause_extElem1 4 typedef struct EXTERN H245FunctionNotSupported_cause { int t; } H245FunctionNotSupported_cause; EXTERN int asn1PE_H245FunctionNotSupported_cause (OOCTXT* pctxt, H245FunctionNotSupported_cause* pvalue); EXTERN int asn1PD_H245FunctionNotSupported_cause (OOCTXT* pctxt, H245FunctionNotSupported_cause* pvalue); /**************************************************************/ /* */ /* FunctionNotSupported */ /* */ /**************************************************************/ typedef struct EXTERN H245FunctionNotSupported { struct { unsigned returnedFunctionPresent : 1; } m; H245FunctionNotSupported_cause cause; ASN1DynOctStr returnedFunction; } H245FunctionNotSupported; EXTERN int asn1PE_H245FunctionNotSupported (OOCTXT* pctxt, H245FunctionNotSupported* pvalue); EXTERN int asn1PD_H245FunctionNotSupported (OOCTXT* pctxt, H245FunctionNotSupported* pvalue); /**************************************************************/ /* */ /* MultilinkIndication_crcDesired */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkIndication_crcDesired { ASN1OCTET __dummy__; } H245MultilinkIndication_crcDesired; EXTERN int asn1PE_H245MultilinkIndication_crcDesired (OOCTXT* pctxt, H245MultilinkIndication_crcDesired* pvalue); EXTERN int asn1PD_H245MultilinkIndication_crcDesired (OOCTXT* pctxt, H245MultilinkIndication_crcDesired* pvalue); /**************************************************************/ /* */ /* MultilinkIndication_excessiveError */ /* */ /**************************************************************/ typedef struct EXTERN H245MultilinkIndication_excessiveError { H245ConnectionIdentifier connectionIdentifier; } H245MultilinkIndication_excessiveError; EXTERN int asn1PE_H245MultilinkIndication_excessiveError (OOCTXT* pctxt, H245MultilinkIndication_excessiveError* pvalue); EXTERN int asn1PD_H245MultilinkIndication_excessiveError (OOCTXT* pctxt, H245MultilinkIndication_excessiveError* pvalue); /**************************************************************/ /* */ /* MultilinkIndication */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultilinkIndication_nonStandard 1 #define T_H245MultilinkIndication_crcDesired 2 #define T_H245MultilinkIndication_excessiveError 3 #define T_H245MultilinkIndication_extElem1 4 typedef struct EXTERN H245MultilinkIndication { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245MultilinkIndication_crcDesired *crcDesired; /* t = 3 */ H245MultilinkIndication_excessiveError *excessiveError; /* t = 4 */ } u; } H245MultilinkIndication; EXTERN int asn1PE_H245MultilinkIndication (OOCTXT* pctxt, H245MultilinkIndication* pvalue); EXTERN int asn1PD_H245MultilinkIndication (OOCTXT* pctxt, H245MultilinkIndication* pvalue); /**************************************************************/ /* */ /* LogicalChannelRateRelease */ /* */ /**************************************************************/ typedef struct EXTERN H245LogicalChannelRateRelease { ASN1OCTET __dummy__; } H245LogicalChannelRateRelease; EXTERN int asn1PE_H245LogicalChannelRateRelease (OOCTXT* pctxt, H245LogicalChannelRateRelease* pvalue); EXTERN int asn1PD_H245LogicalChannelRateRelease (OOCTXT* pctxt, H245LogicalChannelRateRelease* pvalue); /**************************************************************/ /* */ /* FlowControlIndication_scope */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FlowControlIndication_scope_logicalChannelNumber 1 #define T_H245FlowControlIndication_scope_resourceID 2 #define T_H245FlowControlIndication_scope_wholeMultiplex 3 typedef struct EXTERN H245FlowControlIndication_scope { int t; union { /* t = 1 */ H245LogicalChannelNumber logicalChannelNumber; /* t = 2 */ ASN1USINT resourceID; /* t = 3 */ } u; } H245FlowControlIndication_scope; EXTERN int asn1PE_H245FlowControlIndication_scope (OOCTXT* pctxt, H245FlowControlIndication_scope* pvalue); EXTERN int asn1PD_H245FlowControlIndication_scope (OOCTXT* pctxt, H245FlowControlIndication_scope* pvalue); /**************************************************************/ /* */ /* FlowControlIndication_restriction */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245FlowControlIndication_restriction_maximumBitRate 1 #define T_H245FlowControlIndication_restriction_noRestriction 2 typedef struct EXTERN H245FlowControlIndication_restriction { int t; union { /* t = 1 */ ASN1UINT maximumBitRate; /* t = 2 */ } u; } H245FlowControlIndication_restriction; EXTERN int asn1PE_H245FlowControlIndication_restriction (OOCTXT* pctxt, H245FlowControlIndication_restriction* pvalue); EXTERN int asn1PD_H245FlowControlIndication_restriction (OOCTXT* pctxt, H245FlowControlIndication_restriction* pvalue); /**************************************************************/ /* */ /* FlowControlIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245FlowControlIndication { H245FlowControlIndication_scope scope; H245FlowControlIndication_restriction restriction; } H245FlowControlIndication; EXTERN int asn1PE_H245FlowControlIndication (OOCTXT* pctxt, H245FlowControlIndication* pvalue); EXTERN int asn1PD_H245FlowControlIndication (OOCTXT* pctxt, H245FlowControlIndication* pvalue); /**************************************************************/ /* */ /* MobileMultilinkReconfigurationIndication */ /* */ /**************************************************************/ typedef struct EXTERN H245MobileMultilinkReconfigurationIndication { ASN1UINT8 sampleSize; ASN1UINT8 samplesPerFrame; } H245MobileMultilinkReconfigurationIndication; EXTERN int asn1PE_H245MobileMultilinkReconfigurationIndication (OOCTXT* pctxt, H245MobileMultilinkReconfigurationIndication* pvalue); EXTERN int asn1PD_H245MobileMultilinkReconfigurationIndication (OOCTXT* pctxt, H245MobileMultilinkReconfigurationIndication* pvalue); /**************************************************************/ /* */ /* IndicationMessage */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245IndicationMessage_nonStandard 1 #define T_H245IndicationMessage_functionNotUnderstood 2 #define T_H245IndicationMessage_masterSlaveDeterminationRelease 3 #define T_H245IndicationMessage_terminalCapabilitySetRelease 4 #define T_H245IndicationMessage_openLogicalChannelConfirm 5 #define T_H245IndicationMessage_requestChannelCloseRelease 6 #define T_H245IndicationMessage_multiplexEntrySendRelease 7 #define T_H245IndicationMessage_requestMultiplexEntryRelease 8 #define T_H245IndicationMessage_requestModeRelease 9 #define T_H245IndicationMessage_miscellaneousIndication 10 #define T_H245IndicationMessage_jitterIndication 11 #define T_H245IndicationMessage_h223SkewIndication 12 #define T_H245IndicationMessage_newATMVCIndication 13 #define T_H245IndicationMessage_userInput 14 #define T_H245IndicationMessage_h2250MaximumSkewIndication 15 #define T_H245IndicationMessage_mcLocationIndication 16 #define T_H245IndicationMessage_conferenceIndication 17 #define T_H245IndicationMessage_vendorIdentification 18 #define T_H245IndicationMessage_functionNotSupported 19 #define T_H245IndicationMessage_multilinkIndication 20 #define T_H245IndicationMessage_logicalChannelRateRelease 21 #define T_H245IndicationMessage_flowControlIndication 22 #define T_H245IndicationMessage_mobileMultilinkReconfigurationIndication 23 #define T_H245IndicationMessage_extElem1 24 typedef struct EXTERN H245IndicationMessage { int t; union { /* t = 1 */ H245NonStandardMessage *nonStandard; /* t = 2 */ H245FunctionNotUnderstood *functionNotUnderstood; /* t = 3 */ H245MasterSlaveDeterminationRelease *masterSlaveDeterminationRelease; /* t = 4 */ H245TerminalCapabilitySetRelease *terminalCapabilitySetRelease; /* t = 5 */ H245OpenLogicalChannelConfirm *openLogicalChannelConfirm; /* t = 6 */ H245RequestChannelCloseRelease *requestChannelCloseRelease; /* t = 7 */ H245MultiplexEntrySendRelease *multiplexEntrySendRelease; /* t = 8 */ H245RequestMultiplexEntryRelease *requestMultiplexEntryRelease; /* t = 9 */ H245RequestModeRelease *requestModeRelease; /* t = 10 */ H245MiscellaneousIndication *miscellaneousIndication; /* t = 11 */ H245JitterIndication *jitterIndication; /* t = 12 */ H245H223SkewIndication *h223SkewIndication; /* t = 13 */ H245NewATMVCIndication *newATMVCIndication; /* t = 14 */ H245UserInputIndication *userInput; /* t = 15 */ H245H2250MaximumSkewIndication *h2250MaximumSkewIndication; /* t = 16 */ H245MCLocationIndication *mcLocationIndication; /* t = 17 */ H245ConferenceIndication *conferenceIndication; /* t = 18 */ H245VendorIdentification *vendorIdentification; /* t = 19 */ H245FunctionNotSupported *functionNotSupported; /* t = 20 */ H245MultilinkIndication *multilinkIndication; /* t = 21 */ H245LogicalChannelRateRelease *logicalChannelRateRelease; /* t = 22 */ H245FlowControlIndication *flowControlIndication; /* t = 23 */ H245MobileMultilinkReconfigurationIndication *mobileMultilinkReconfigurationIndication; /* t = 24 */ } u; } H245IndicationMessage; EXTERN int asn1PE_H245IndicationMessage (OOCTXT* pctxt, H245IndicationMessage* pvalue); EXTERN int asn1PD_H245IndicationMessage (OOCTXT* pctxt, H245IndicationMessage* pvalue); /**************************************************************/ /* */ /* MultimediaSystemControlMessage */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H245MultimediaSystemControlMessage_request 1 #define T_H245MultimediaSystemControlMessage_response 2 #define T_H245MultimediaSystemControlMessage_command 3 #define T_H245MultimediaSystemControlMessage_indication 4 #define T_H245MultimediaSystemControlMessage_extElem1 5 typedef struct EXTERN H245MultimediaSystemControlMessage { int t; union { /* t = 1 */ H245RequestMessage *request; /* t = 2 */ H245ResponseMessage *response; /* t = 3 */ H245CommandMessage *command; /* t = 4 */ H245IndicationMessage *indication; /* t = 5 */ } u; } H245MultimediaSystemControlMessage; EXTERN int asn1PE_H245MultimediaSystemControlMessage (OOCTXT* pctxt, H245MultimediaSystemControlMessage* pvalue); EXTERN int asn1PD_H245MultimediaSystemControlMessage (OOCTXT* pctxt, H245MultimediaSystemControlMessage* pvalue); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/h323/H323-MESSAGESEnc.c0000644000175000007640000256575211750517252021714 0ustar sharkyjerryweb/* * 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" /**************************************************************/ /* */ /* ScreeningIndicator */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ScreeningIndicator (OOCTXT* pctxt, H225ScreeningIndicator value) { int stat = ASN_OK; ASN1UINT ui; ASN1BOOL extbit; extbit = 0; switch (value) { case userProvidedNotScreened: ui = 0; break; case userProvidedVerifiedAndPassed: ui = 1; break; case userProvidedVerifiedAndFailed: ui = 2; break; case networkProvided: ui = 3; break; default: ui = value; extbit = 1; } /* extension bit */ encodeBit (pctxt, extbit); if (extbit) { stat = encodeSmallNonNegWholeNumber (pctxt, ui); } else { stat = encodeConsUnsigned (pctxt, ui, 0, 3); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NumberDigits */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_NumberDigits_CharSet; EXTERN int asn1PE_H225NumberDigits (OOCTXT* pctxt, H225NumberDigits value) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeConstrainedStringEx (pctxt, value, gs_H323_MESSAGES_NumberDigits_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TBCD_STRING */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_TBCD_STRING_CharSet; EXTERN int asn1PE_H225TBCD_STRING (OOCTXT* pctxt, H225TBCD_STRING value) { int stat = ASN_OK; stat = encodeConstrainedStringEx (pctxt, value, gs_H323_MESSAGES_TBCD_STRING_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* GloballyUniqueID */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GloballyUniqueID (OOCTXT* pctxt, H225GloballyUniqueID* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ConferenceIdentifier (OOCTXT* pctxt, H225ConferenceIdentifier* pvalue) { int stat = ASN_OK; stat = asn1PE_H225GloballyUniqueID (pctxt, pvalue); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestSeqNum */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RequestSeqNum (OOCTXT* pctxt, H225RequestSeqNum value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 1U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* GatekeeperIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatekeeperIdentifier (OOCTXT* pctxt, H225GatekeeperIdentifier value) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBMPString (pctxt, value, 0); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* BandWidth */ /* */ /**************************************************************/ EXTERN int asn1PE_H225BandWidth (OOCTXT* pctxt, H225BandWidth value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CallReferenceValue */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallReferenceValue (OOCTXT* pctxt, H225CallReferenceValue value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EndpointIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225EndpointIdentifier (OOCTXT* pctxt, H225EndpointIdentifier value) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBMPString (pctxt, value, 0); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ProtocolIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ProtocolIdentifier (OOCTXT* pctxt, H225ProtocolIdentifier* value) { int stat = ASN_OK; stat = encodeObjectIdentifier (pctxt, value); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TimeToLive */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TimeToLive (OOCTXT* pctxt, H225TimeToLive value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H248PackagesDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H248PackagesDescriptor (OOCTXT* pctxt, H225H248PackagesDescriptor value) { int stat = ASN_OK; stat = encodeOctetString (pctxt, value.numocts, value.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H248SignalsDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H248SignalsDescriptor (OOCTXT* pctxt, H225H248SignalsDescriptor value) { int stat = ASN_OK; stat = encodeOctetString (pctxt, value.numocts, value.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* GenericIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GenericIdentifier (OOCTXT* pctxt, H225GenericIdentifier* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* standard */ case 1: if ( (pvalue->u.standard >= 0 && pvalue->u.standard <= 16383) ) { extbit = 0; } else extbit = 1; /* extension bit */ encodeBit (pctxt, extbit); if (extbit) { stat = encodeUnconsInteger (pctxt, pvalue->u.standard); if (stat != ASN_OK) return stat; } else { stat = encodeConsInteger (pctxt, pvalue->u.standard, 0, 16383); if (stat != ASN_OK) return stat; } break; /* oid */ case 2: stat = encodeObjectIdentifier (pctxt, pvalue->u.oid); if (stat != ASN_OK) return stat; break; /* nonStandard */ case 3: stat = asn1PE_H225GloballyUniqueID (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipAddress_ip */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipAddress_ip (OOCTXT* pctxt, H225TransportAddress_ipAddress_ip* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipAddress (OOCTXT* pctxt, H225TransportAddress_ipAddress* pvalue) { int stat = ASN_OK; /* encode ip */ stat = asn1PE_H225TransportAddress_ipAddress_ip (pctxt, &pvalue->ip); if (stat != ASN_OK) return stat; /* encode port */ stat = encodeConsUnsigned (pctxt, pvalue->port, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_ip */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipSourceRoute_ip (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_ip* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_route_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_route_element* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TransportAddress_ipSourceRoute_route_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225_SeqOfH225TransportAddress_ipSourceRoute_route_element* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H225TransportAddress_ipSourceRoute_route_element (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_routing */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipSourceRoute_routing (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_routing* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* strict */ case 1: /* NULL */ break; /* loose */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipSourceRoute (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode ip */ stat = asn1PE_H225TransportAddress_ipSourceRoute_ip (pctxt, &pvalue->ip); if (stat != ASN_OK) return stat; /* encode port */ stat = encodeConsUnsigned (pctxt, pvalue->port, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode route */ stat = asn1PE_H225_SeqOfH225TransportAddress_ipSourceRoute_route_element (pctxt, &pvalue->route); if (stat != ASN_OK) return stat; /* encode routing */ stat = asn1PE_H225TransportAddress_ipSourceRoute_routing (pctxt, &pvalue->routing); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress_node */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipxAddress_node (OOCTXT* pctxt, H225TransportAddress_ipxAddress_node* pvalue) { static Asn1SizeCnst lsize1 = { 0, 6, 6, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress_netnum */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipxAddress_netnum (OOCTXT* pctxt, H225TransportAddress_ipxAddress_netnum* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress_port */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipxAddress_port (OOCTXT* pctxt, H225TransportAddress_ipxAddress_port* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 2, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ipxAddress (OOCTXT* pctxt, H225TransportAddress_ipxAddress* pvalue) { int stat = ASN_OK; /* encode node */ stat = asn1PE_H225TransportAddress_ipxAddress_node (pctxt, &pvalue->node); if (stat != ASN_OK) return stat; /* encode netnum */ stat = asn1PE_H225TransportAddress_ipxAddress_netnum (pctxt, &pvalue->netnum); if (stat != ASN_OK) return stat; /* encode port */ stat = asn1PE_H225TransportAddress_ipxAddress_port (pctxt, &pvalue->port); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ip6Address_ip */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ip6Address_ip (OOCTXT* pctxt, H225TransportAddress_ip6Address_ip* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_ip6Address */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_ip6Address (OOCTXT* pctxt, H225TransportAddress_ip6Address* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode ip */ stat = asn1PE_H225TransportAddress_ip6Address_ip (pctxt, &pvalue->ip); if (stat != ASN_OK) return stat; /* encode port */ stat = encodeConsUnsigned (pctxt, pvalue->port, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_netBios */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_netBios (OOCTXT* pctxt, H225TransportAddress_netBios* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress_nsap */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress_nsap (OOCTXT* pctxt, H225TransportAddress_nsap* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H221NonStandard */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H221NonStandard (OOCTXT* pctxt, H225H221NonStandard* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode t35CountryCode */ stat = encodeConsUnsigned (pctxt, pvalue->t35CountryCode, 0U, 255U); if (stat != ASN_OK) return stat; /* encode t35Extension */ stat = encodeConsUnsigned (pctxt, pvalue->t35Extension, 0U, 255U); if (stat != ASN_OK) return stat; /* encode manufacturerCode */ stat = encodeConsUnsigned (pctxt, pvalue->manufacturerCode, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NonStandardIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225NonStandardIdentifier (OOCTXT* pctxt, H225NonStandardIdentifier* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* object */ case 1: stat = encodeObjectIdentifier (pctxt, pvalue->u.object); if (stat != ASN_OK) return stat; break; /* h221NonStandard */ case 2: stat = asn1PE_H225H221NonStandard (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H225NonStandardParameter (OOCTXT* pctxt, H225NonStandardParameter* pvalue) { int stat = ASN_OK; /* encode nonStandardIdentifier */ stat = asn1PE_H225NonStandardIdentifier (pctxt, &pvalue->nonStandardIdentifier); if (stat != ASN_OK) return stat; /* encode data */ stat = encodeOctetString (pctxt, pvalue->data.numocts, pvalue->data.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TransportAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportAddress (OOCTXT* pctxt, H225TransportAddress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 7); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 6); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* ipAddress */ case 1: stat = asn1PE_H225TransportAddress_ipAddress (pctxt, pvalue->u.ipAddress); if (stat != ASN_OK) return stat; break; /* ipSourceRoute */ case 2: stat = asn1PE_H225TransportAddress_ipSourceRoute (pctxt, pvalue->u.ipSourceRoute); if (stat != ASN_OK) return stat; break; /* ipxAddress */ case 3: stat = asn1PE_H225TransportAddress_ipxAddress (pctxt, pvalue->u.ipxAddress); if (stat != ASN_OK) return stat; break; /* ip6Address */ case 4: stat = asn1PE_H225TransportAddress_ip6Address (pctxt, pvalue->u.ip6Address); if (stat != ASN_OK) return stat; break; /* netBios */ case 5: stat = asn1PE_H225TransportAddress_netBios (pctxt, pvalue->u.netBios); if (stat != ASN_OK) return stat; break; /* nsap */ case 6: stat = asn1PE_H225TransportAddress_nsap (pctxt, pvalue->u.nsap); if (stat != ASN_OK) return stat; break; /* nonStandardAddress */ case 7: stat = asn1PE_H225NonStandardParameter (pctxt, pvalue->u.nonStandardAddress); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 8); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* PublicTypeOfNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H225PublicTypeOfNumber (OOCTXT* pctxt, H225PublicTypeOfNumber* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unknown */ case 1: /* NULL */ break; /* internationalNumber */ case 2: /* NULL */ break; /* nationalNumber */ case 3: /* NULL */ break; /* networkSpecificNumber */ case 4: /* NULL */ break; /* subscriberNumber */ case 5: /* NULL */ break; /* abbreviatedNumber */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* PublicPartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H225PublicPartyNumber (OOCTXT* pctxt, H225PublicPartyNumber* pvalue) { int stat = ASN_OK; /* encode publicTypeOfNumber */ stat = asn1PE_H225PublicTypeOfNumber (pctxt, &pvalue->publicTypeOfNumber); if (stat != ASN_OK) return stat; /* encode publicNumberDigits */ stat = asn1PE_H225NumberDigits (pctxt, pvalue->publicNumberDigits); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* PrivateTypeOfNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H225PrivateTypeOfNumber (OOCTXT* pctxt, H225PrivateTypeOfNumber* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unknown */ case 1: /* NULL */ break; /* level2RegionalNumber */ case 2: /* NULL */ break; /* level1RegionalNumber */ case 3: /* NULL */ break; /* pISNSpecificNumber */ case 4: /* NULL */ break; /* localNumber */ case 5: /* NULL */ break; /* abbreviatedNumber */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* PrivatePartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H225PrivatePartyNumber (OOCTXT* pctxt, H225PrivatePartyNumber* pvalue) { int stat = ASN_OK; /* encode privateTypeOfNumber */ stat = asn1PE_H225PrivateTypeOfNumber (pctxt, &pvalue->privateTypeOfNumber); if (stat != ASN_OK) return stat; /* encode privateNumberDigits */ stat = asn1PE_H225NumberDigits (pctxt, pvalue->privateNumberDigits); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* PartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H225PartyNumber (OOCTXT* pctxt, H225PartyNumber* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* e164Number */ case 1: stat = asn1PE_H225PublicPartyNumber (pctxt, pvalue->u.e164Number); if (stat != ASN_OK) return stat; break; /* dataPartyNumber */ case 2: stat = asn1PE_H225NumberDigits (pctxt, pvalue->u.dataPartyNumber); if (stat != ASN_OK) return stat; break; /* telexPartyNumber */ case 3: stat = asn1PE_H225NumberDigits (pctxt, pvalue->u.telexPartyNumber); if (stat != ASN_OK) return stat; break; /* privateNumber */ case 4: stat = asn1PE_H225PrivatePartyNumber (pctxt, pvalue->u.privateNumber); if (stat != ASN_OK) return stat; break; /* nationalStandardPartyNumber */ case 5: stat = asn1PE_H225NumberDigits (pctxt, pvalue->u.nationalStandardPartyNumber); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_system_id */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_system_id_sid_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_system_id_mid_CharSet; EXTERN int asn1PE_H225ANSI_41_UIM_system_id (OOCTXT* pctxt, H225ANSI_41_UIM_system_id* pvalue) { static Asn1SizeCnst sid_lsize1 = { 0, 1, 4, 0 }; static Asn1SizeCnst mid_lsize1 = { 0, 1, 4, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* sid */ case 1: addSizeConstraint (pctxt, &sid_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.sid, gs_H323_MESSAGES_ANSI_41_UIM_system_id_sid_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; break; /* mid */ case 2: addSizeConstraint (pctxt, &mid_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.mid, gs_H323_MESSAGES_ANSI_41_UIM_system_id_mid_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_systemMyTypeCode */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ANSI_41_UIM_systemMyTypeCode (OOCTXT* pctxt, H225ANSI_41_UIM_systemMyTypeCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_systemAccessType */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ANSI_41_UIM_systemAccessType (OOCTXT* pctxt, H225ANSI_41_UIM_systemAccessType* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_qualificationInformationCode */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ANSI_41_UIM_qualificationInformationCode (OOCTXT* pctxt, H225ANSI_41_UIM_qualificationInformationCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_imsi_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_min_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_mdn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_msisdn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_esn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_mscid_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_sesn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_soc_CharSet; EXTERN int asn1PE_H225ANSI_41_UIM (OOCTXT* pctxt, H225ANSI_41_UIM* pvalue) { static Asn1SizeCnst imsi_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst min_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst mdn_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst msisdn_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst esn_lsize1 = { 0, 16, 16, 0 }; static Asn1SizeCnst mscid_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst sesn_lsize1 = { 0, 16, 16, 0 }; static Asn1SizeCnst soc_lsize1 = { 0, 3, 16, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.imsiPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.minPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mdnPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.msisdnPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.esnPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mscidPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.systemMyTypeCodePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.systemAccessTypePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qualificationInformationCodePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sesnPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.socPresent); /* encode imsi */ if (pvalue->m.imsiPresent) { addSizeConstraint (pctxt, &imsi_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->imsi, gs_H323_MESSAGES_ANSI_41_UIM_imsi_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode min */ if (pvalue->m.minPresent) { addSizeConstraint (pctxt, &min_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->min, gs_H323_MESSAGES_ANSI_41_UIM_min_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode mdn */ if (pvalue->m.mdnPresent) { addSizeConstraint (pctxt, &mdn_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->mdn, gs_H323_MESSAGES_ANSI_41_UIM_mdn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode msisdn */ if (pvalue->m.msisdnPresent) { addSizeConstraint (pctxt, &msisdn_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->msisdn, gs_H323_MESSAGES_ANSI_41_UIM_msisdn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode esn */ if (pvalue->m.esnPresent) { addSizeConstraint (pctxt, &esn_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->esn, gs_H323_MESSAGES_ANSI_41_UIM_esn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode mscid */ if (pvalue->m.mscidPresent) { addSizeConstraint (pctxt, &mscid_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->mscid, gs_H323_MESSAGES_ANSI_41_UIM_mscid_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode system_id */ stat = asn1PE_H225ANSI_41_UIM_system_id (pctxt, &pvalue->system_id); if (stat != ASN_OK) return stat; /* encode systemMyTypeCode */ if (pvalue->m.systemMyTypeCodePresent) { stat = asn1PE_H225ANSI_41_UIM_systemMyTypeCode (pctxt, &pvalue->systemMyTypeCode); if (stat != ASN_OK) return stat; } /* encode systemAccessType */ if (pvalue->m.systemAccessTypePresent) { stat = asn1PE_H225ANSI_41_UIM_systemAccessType (pctxt, &pvalue->systemAccessType); if (stat != ASN_OK) return stat; } /* encode qualificationInformationCode */ if (pvalue->m.qualificationInformationCodePresent) { stat = asn1PE_H225ANSI_41_UIM_qualificationInformationCode (pctxt, &pvalue->qualificationInformationCode); if (stat != ASN_OK) return stat; } /* encode sesn */ if (pvalue->m.sesnPresent) { addSizeConstraint (pctxt, &sesn_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->sesn, gs_H323_MESSAGES_ANSI_41_UIM_sesn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode soc */ if (pvalue->m.socPresent) { addSizeConstraint (pctxt, &soc_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->soc, gs_H323_MESSAGES_ANSI_41_UIM_soc_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* GSM_UIM_tmsi */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GSM_UIM_tmsi (OOCTXT* pctxt, H225GSM_UIM_tmsi* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* GSM_UIM */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_imsi_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_msisdn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_imei_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_hplmn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_vplmn_CharSet; EXTERN int asn1PE_H225GSM_UIM (OOCTXT* pctxt, H225GSM_UIM* pvalue) { static Asn1SizeCnst imsi_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst msisdn_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst imei_lsize1 = { 0, 15, 16, 0 }; static Asn1SizeCnst hplmn_lsize1 = { 0, 1, 4, 0 }; static Asn1SizeCnst vplmn_lsize1 = { 0, 1, 4, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.imsiPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tmsiPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.msisdnPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.imeiPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.hplmnPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.vplmnPresent); /* encode imsi */ if (pvalue->m.imsiPresent) { addSizeConstraint (pctxt, &imsi_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->imsi, gs_H323_MESSAGES_GSM_UIM_imsi_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode tmsi */ if (pvalue->m.tmsiPresent) { stat = asn1PE_H225GSM_UIM_tmsi (pctxt, &pvalue->tmsi); if (stat != ASN_OK) return stat; } /* encode msisdn */ if (pvalue->m.msisdnPresent) { addSizeConstraint (pctxt, &msisdn_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->msisdn, gs_H323_MESSAGES_GSM_UIM_msisdn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode imei */ if (pvalue->m.imeiPresent) { addSizeConstraint (pctxt, &imei_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->imei, gs_H323_MESSAGES_GSM_UIM_imei_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode hplmn */ if (pvalue->m.hplmnPresent) { addSizeConstraint (pctxt, &hplmn_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->hplmn, gs_H323_MESSAGES_GSM_UIM_hplmn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } /* encode vplmn */ if (pvalue->m.vplmnPresent) { addSizeConstraint (pctxt, &vplmn_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->vplmn, gs_H323_MESSAGES_GSM_UIM_vplmn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MobileUIM */ /* */ /**************************************************************/ EXTERN int asn1PE_H225MobileUIM (OOCTXT* pctxt, H225MobileUIM* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* ansi_41_uim */ case 1: stat = asn1PE_H225ANSI_41_UIM (pctxt, pvalue->u.ansi_41_uim); if (stat != ASN_OK) return stat; break; /* gsm_uim */ case 2: stat = asn1PE_H225GSM_UIM (pctxt, pvalue->u.gsm_uim); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* AliasAddress */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_AliasAddress_dialedDigits_CharSet; EXTERN int asn1PE_H225AliasAddress (OOCTXT* pctxt, H225AliasAddress* pvalue) { static Asn1SizeCnst dialedDigits_lsize1 = { 0, 1, 128, 0 }; static Asn1SizeCnst h323_ID_lsize1 = { 0, 1, 256, 0 }; static Asn1SizeCnst url_ID_lsize1 = { 0, 1, 512, 0 }; static Asn1SizeCnst email_ID_lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* dialedDigits */ case 1: addSizeConstraint (pctxt, &dialedDigits_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.dialedDigits, gs_H323_MESSAGES_AliasAddress_dialedDigits_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; break; /* h323_ID */ case 2: addSizeConstraint (pctxt, &h323_ID_lsize1); stat = encodeBMPString (pctxt, pvalue->u.h323_ID, 0); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* url_ID */ case 3: addSizeConstraint (&lctxt, &url_ID_lsize1); stat = encodeConstrainedStringEx (&lctxt, pvalue->u.url_ID, 0, 8, 7, 7); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* transportID */ case 4: stat = asn1PE_H225TransportAddress (&lctxt, pvalue->u.transportID); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* email_ID */ case 5: addSizeConstraint (&lctxt, &email_ID_lsize1); stat = encodeConstrainedStringEx (&lctxt, pvalue->u.email_ID, 0, 8, 7, 7); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* partyNumber */ case 6: stat = asn1PE_H225PartyNumber (&lctxt, pvalue->u.partyNumber); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* mobileUIM */ case 7: stat = asn1PE_H225MobileUIM (&lctxt, pvalue->u.mobileUIM); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* Content_compound */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Content_compound (OOCTXT* pctxt, H225Content_compound* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H225EnumeratedParameter (pctxt, (H225EnumeratedParameter*)((H225EnumeratedParameter*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* Content_nested */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Content_nested (OOCTXT* pctxt, H225Content_nested* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H225GenericData (pctxt, (H225GenericData*)((H225GenericData*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* Content */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Content (OOCTXT* pctxt, H225Content* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 12); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 11); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* raw */ case 1: stat = encodeOctetString (pctxt, pvalue->u.raw->numocts, pvalue->u.raw->data); if (stat != ASN_OK) return stat; break; /* text */ case 2: stat = encodeConstrainedStringEx (pctxt, pvalue->u.text, 0, 8, 7, 7); if (stat != ASN_OK) return stat; break; /* unicode */ case 3: stat = encodeBMPString (pctxt, pvalue->u.unicode, 0); if (stat != ASN_OK) return stat; break; /* bool_ */ case 4: stat = encodeBit (pctxt, (ASN1BOOL)pvalue->u.bool_); if (stat != ASN_OK) return stat; break; /* number8 */ case 5: stat = encodeConsUnsigned (pctxt, pvalue->u.number8, 0U, 255U); if (stat != ASN_OK) return stat; break; /* number16 */ case 6: stat = encodeConsUnsigned (pctxt, pvalue->u.number16, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* number32 */ case 7: stat = encodeConsUnsigned (pctxt, pvalue->u.number32, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; break; /* id */ case 8: stat = asn1PE_H225GenericIdentifier (pctxt, pvalue->u.id); if (stat != ASN_OK) return stat; break; /* alias */ case 9: stat = asn1PE_H225AliasAddress (pctxt, pvalue->u.alias); if (stat != ASN_OK) return stat; break; /* transport */ case 10: stat = asn1PE_H225TransportAddress (pctxt, pvalue->u.transport); if (stat != ASN_OK) return stat; break; /* compound */ case 11: stat = asn1PE_H225Content_compound (pctxt, pvalue->u.compound); if (stat != ASN_OK) return stat; break; /* nested */ case 12: stat = asn1PE_H225Content_nested (pctxt, pvalue->u.nested); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 13); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* EnumeratedParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H225EnumeratedParameter (OOCTXT* pctxt, H225EnumeratedParameter* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.contentPresent); /* encode id */ stat = asn1PE_H225GenericIdentifier (pctxt, &pvalue->id); if (stat != ASN_OK) return stat; /* encode content */ if (pvalue->m.contentPresent) { stat = asn1PE_H225Content (pctxt, &pvalue->content); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* GenericData_parameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GenericData_parameters (OOCTXT* pctxt, H225GenericData_parameters* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H225EnumeratedParameter (pctxt, ((H225EnumeratedParameter*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* GenericData */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GenericData (OOCTXT* pctxt, H225GenericData* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.parametersPresent); /* encode id */ stat = asn1PE_H225GenericIdentifier (pctxt, &pvalue->id); if (stat != ASN_OK) return stat; /* encode parameters */ if (pvalue->m.parametersPresent) { stat = asn1PE_H225GenericData_parameters (pctxt, &pvalue->parameters); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FeatureDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H225FeatureDescriptor (OOCTXT* pctxt, H225FeatureDescriptor* pvalue) { int stat = ASN_OK; stat = asn1PE_H225GenericData (pctxt, pvalue); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FastStartToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H225FastStartToken (OOCTXT* pctxt, H225FastStartToken* pvalue) { int stat = ASN_OK; stat = asn1PE_H235ClearToken (pctxt, pvalue); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncodedFastStartToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H225EncodedFastStartToken (OOCTXT* pctxt, H225EncodedFastStartToken value) { int stat = ASN_OK; stat = encodeOpenType (pctxt, value.numocts, value.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H323_UserInformation_user_data_user_information */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UserInformation_user_data_user_information (OOCTXT* pctxt, H225H323_UserInformation_user_data_user_information* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 131, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EndpointType_set */ /* */ /**************************************************************/ EXTERN int asn1PE_H225EndpointType_set (OOCTXT* pctxt, H225EndpointType_set* pvalue) { static Asn1SizeCnst lsize1 = { 0, 32, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VendorIdentifier_productId */ /* */ /**************************************************************/ EXTERN int asn1PE_H225VendorIdentifier_productId (OOCTXT* pctxt, H225VendorIdentifier_productId* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VendorIdentifier_versionId */ /* */ /**************************************************************/ EXTERN int asn1PE_H225VendorIdentifier_versionId (OOCTXT* pctxt, H225VendorIdentifier_versionId* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CicInfo_cic_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CicInfo_cic_element (OOCTXT* pctxt, H225CicInfo_cic_element* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CicInfo_pointCode */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CicInfo_pointCode (OOCTXT* pctxt, H225CicInfo_pointCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 5, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CarrierInfo_carrierIdentificationCode */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CarrierInfo_carrierIdentificationCode (OOCTXT* pctxt, H225CarrierInfo_carrierIdentificationCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 3, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CallTerminationCause_releaseCompleteCauseIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallTerminationCause_releaseCompleteCauseIE (OOCTXT* pctxt, H225CallTerminationCause_releaseCompleteCauseIE* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AliasAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225AliasAddress (OOCTXT* pctxt, H225_SeqOfH225AliasAddress* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225AliasAddress (pctxt, ((H225AliasAddress*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* VendorIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225VendorIdentifier (OOCTXT* pctxt, H225VendorIdentifier* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.enterpriseNumberPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.productIdPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.versionIdPresent); /* encode vendor */ stat = asn1PE_H225H221NonStandard (pctxt, &pvalue->vendor); if (stat != ASN_OK) return stat; /* encode productId */ if (pvalue->m.productIdPresent) { stat = asn1PE_H225VendorIdentifier_productId (pctxt, &pvalue->productId); if (stat != ASN_OK) return stat; } /* encode versionId */ if (pvalue->m.versionIdPresent) { stat = asn1PE_H225VendorIdentifier_versionId (pctxt, &pvalue->versionId); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.enterpriseNumberPresent); /* encode extension elements */ if (pvalue->m.enterpriseNumberPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeObjectIdentifier (&lctxt, &pvalue->enterpriseNumber); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* GatekeeperInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatekeeperInfo (OOCTXT* pctxt, H225GatekeeperInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* DataRate */ /* */ /**************************************************************/ EXTERN int asn1PE_H225DataRate (OOCTXT* pctxt, H225DataRate* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.channelMultiplierPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode channelRate */ stat = asn1PE_H225BandWidth (pctxt, pvalue->channelRate); if (stat != ASN_OK) return stat; /* encode channelMultiplier */ if (pvalue->m.channelMultiplierPresent) { stat = encodeConsUnsigned (pctxt, pvalue->channelMultiplier, 1U, 256U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225DataRate */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225DataRate (OOCTXT* pctxt, H225_SeqOfH225DataRate* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225DataRate (pctxt, ((H225DataRate*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* SupportedPrefix */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SupportedPrefix (OOCTXT* pctxt, H225SupportedPrefix* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode prefix */ stat = asn1PE_H225AliasAddress (pctxt, &pvalue->prefix); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH225SupportedPrefix */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225SupportedPrefix (OOCTXT* pctxt, H225_SeqOfH225SupportedPrefix* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225SupportedPrefix (pctxt, ((H225SupportedPrefix*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* H310Caps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H310Caps (OOCTXT* pctxt, H225H310Caps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H320Caps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H320Caps (OOCTXT* pctxt, H225H320Caps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H321Caps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H321Caps (OOCTXT* pctxt, H225H321Caps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H322Caps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H322Caps (OOCTXT* pctxt, H225H322Caps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H323Caps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323Caps (OOCTXT* pctxt, H225H323Caps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H324Caps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H324Caps (OOCTXT* pctxt, H225H324Caps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* VoiceCaps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225VoiceCaps (OOCTXT* pctxt, H225VoiceCaps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* T120OnlyCaps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225T120OnlyCaps (OOCTXT* pctxt, H225T120OnlyCaps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.dataRatesSupportedPresent || pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode extension elements */ if (pvalue->m.dataRatesSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225DataRate (&lctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* NonStandardProtocol */ /* */ /**************************************************************/ EXTERN int asn1PE_H225NonStandardProtocol (OOCTXT* pctxt, H225NonStandardProtocol* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode dataRatesSupported */ if (pvalue->m.dataRatesSupportedPresent) { stat = asn1PE_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; } /* encode supportedPrefixes */ stat = asn1PE_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* T38FaxAnnexbOnlyCaps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225T38FaxAnnexbOnlyCaps (OOCTXT* pctxt, H225T38FaxAnnexbOnlyCaps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode dataRatesSupported */ if (pvalue->m.dataRatesSupportedPresent) { stat = asn1PE_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; } /* encode supportedPrefixes */ stat = asn1PE_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; /* encode t38FaxProtocol */ stat = asn1PE_H245DataProtocolCapability (pctxt, &pvalue->t38FaxProtocol); if (stat != ASN_OK) return stat; /* encode t38FaxProfile */ stat = asn1PE_H245T38FaxProfile (pctxt, &pvalue->t38FaxProfile); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* SIPCaps */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SIPCaps (OOCTXT* pctxt, H225SIPCaps* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataRatesSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode dataRatesSupported */ if (pvalue->m.dataRatesSupportedPresent) { stat = asn1PE_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; } /* encode supportedPrefixes */ if (pvalue->m.supportedPrefixesPresent) { stat = asn1PE_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* SupportedProtocols */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SupportedProtocols (OOCTXT* pctxt, H225SupportedProtocols* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 9); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 8); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandardData */ case 1: stat = asn1PE_H225NonStandardParameter (pctxt, pvalue->u.nonStandardData); if (stat != ASN_OK) return stat; break; /* h310 */ case 2: stat = asn1PE_H225H310Caps (pctxt, pvalue->u.h310); if (stat != ASN_OK) return stat; break; /* h320 */ case 3: stat = asn1PE_H225H320Caps (pctxt, pvalue->u.h320); if (stat != ASN_OK) return stat; break; /* h321 */ case 4: stat = asn1PE_H225H321Caps (pctxt, pvalue->u.h321); if (stat != ASN_OK) return stat; break; /* h322 */ case 5: stat = asn1PE_H225H322Caps (pctxt, pvalue->u.h322); if (stat != ASN_OK) return stat; break; /* h323 */ case 6: stat = asn1PE_H225H323Caps (pctxt, pvalue->u.h323); if (stat != ASN_OK) return stat; break; /* h324 */ case 7: stat = asn1PE_H225H324Caps (pctxt, pvalue->u.h324); if (stat != ASN_OK) return stat; break; /* voice */ case 8: stat = asn1PE_H225VoiceCaps (pctxt, pvalue->u.voice); if (stat != ASN_OK) return stat; break; /* t120_only */ case 9: stat = asn1PE_H225T120OnlyCaps (pctxt, pvalue->u.t120_only); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 10); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* nonStandardProtocol */ case 10: stat = asn1PE_H225NonStandardProtocol (&lctxt, pvalue->u.nonStandardProtocol); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* t38FaxAnnexbOnly */ case 11: stat = asn1PE_H225T38FaxAnnexbOnlyCaps (&lctxt, pvalue->u.t38FaxAnnexbOnly); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* sip */ case 12: stat = asn1PE_H225SIPCaps (&lctxt, pvalue->u.sip); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225SupportedProtocols */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225SupportedProtocols (OOCTXT* pctxt, H225_SeqOfH225SupportedProtocols* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225SupportedProtocols (pctxt, ((H225SupportedProtocols*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* GatewayInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatewayInfo (OOCTXT* pctxt, H225GatewayInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.protocolPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode protocol */ if (pvalue->m.protocolPresent) { stat = asn1PE_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->protocol); if (stat != ASN_OK) return stat; } /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* McuInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225McuInfo (OOCTXT* pctxt, H225McuInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.protocolPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.protocolPresent); /* encode extension elements */ if (pvalue->m.protocolPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedProtocols (&lctxt, &pvalue->protocol); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* TerminalInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TerminalInfo (OOCTXT* pctxt, H225TerminalInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TunnelledProtocolAlternateIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TunnelledProtocolAlternateIdentifier (OOCTXT* pctxt, H225TunnelledProtocolAlternateIdentifier* pvalue) { static Asn1SizeCnst protocolType_lsize1 = { 0, 1, 64, 0 }; static Asn1SizeCnst protocolVariant_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.protocolVariantPresent); /* encode protocolType */ addSizeConstraint (pctxt, &protocolType_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->protocolType, 0, 8, 7, 7); if (stat != ASN_OK) return stat; /* encode protocolVariant */ if (pvalue->m.protocolVariantPresent) { addSizeConstraint (pctxt, &protocolVariant_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->protocolVariant, 0, 8, 7, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TunnelledProtocol_id */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TunnelledProtocol_id (OOCTXT* pctxt, H225TunnelledProtocol_id* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* tunnelledProtocolObjectID */ case 1: stat = encodeObjectIdentifier (pctxt, pvalue->u.tunnelledProtocolObjectID); if (stat != ASN_OK) return stat; break; /* tunnelledProtocolAlternateID */ case 2: stat = asn1PE_H225TunnelledProtocolAlternateIdentifier (pctxt, pvalue->u.tunnelledProtocolAlternateID); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TunnelledProtocol */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TunnelledProtocol (OOCTXT* pctxt, H225TunnelledProtocol* pvalue) { static Asn1SizeCnst subIdentifier_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.subIdentifierPresent); /* encode id */ stat = asn1PE_H225TunnelledProtocol_id (pctxt, &pvalue->id); if (stat != ASN_OK) return stat; /* encode subIdentifier */ if (pvalue->m.subIdentifierPresent) { addSizeConstraint (pctxt, &subIdentifier_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->subIdentifier, 0, 8, 7, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TunnelledProtocol */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225TunnelledProtocol (OOCTXT* pctxt, H225_SeqOfH225TunnelledProtocol* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225TunnelledProtocol (pctxt, ((H225TunnelledProtocol*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* EndpointType */ /* */ /**************************************************************/ EXTERN int asn1PE_H225EndpointType (OOCTXT* pctxt, H225EndpointType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.setPresent || pvalue->m.supportedTunnelledProtocolsPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.vendorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatewayPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mcuPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode vendor */ if (pvalue->m.vendorPresent) { stat = asn1PE_H225VendorIdentifier (pctxt, &pvalue->vendor); if (stat != ASN_OK) return stat; } /* encode gatekeeper */ if (pvalue->m.gatekeeperPresent) { stat = asn1PE_H225GatekeeperInfo (pctxt, &pvalue->gatekeeper); if (stat != ASN_OK) return stat; } /* encode gateway */ if (pvalue->m.gatewayPresent) { stat = asn1PE_H225GatewayInfo (pctxt, &pvalue->gateway); if (stat != ASN_OK) return stat; } /* encode mcu */ if (pvalue->m.mcuPresent) { stat = asn1PE_H225McuInfo (pctxt, &pvalue->mcu); if (stat != ASN_OK) return stat; } /* encode terminal */ if (pvalue->m.terminalPresent) { stat = asn1PE_H225TerminalInfo (pctxt, &pvalue->terminal); if (stat != ASN_OK) return stat; } /* encode mc */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->mc); if (stat != ASN_OK) return stat; /* encode undefinedNode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->undefinedNode); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.setPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedTunnelledProtocolsPresent); /* encode extension elements */ if (pvalue->m.setPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225EndpointType_set (&lctxt, &pvalue->set); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedTunnelledProtocolsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225TunnelledProtocol (&lctxt, &pvalue->supportedTunnelledProtocols); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CallReferenceValue */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225CallReferenceValue (OOCTXT* pctxt, H225_SeqOfH225CallReferenceValue* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H225CallReferenceValue (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_conferenceGoal */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Setup_UUIE_conferenceGoal (OOCTXT* pctxt, H225Setup_UUIE_conferenceGoal* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* create */ case 1: /* NULL */ break; /* join */ case 2: /* NULL */ break; /* invite */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* capability_negotiation */ case 4: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* callIndependentSupplementaryService */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* Q954Details */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Q954Details (OOCTXT* pctxt, H225Q954Details* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode conferenceCalling */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->conferenceCalling); if (stat != ASN_OK) return stat; /* encode threePartyService */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->threePartyService); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* QseriesOptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H225QseriesOptions (OOCTXT* pctxt, H225QseriesOptions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode q932Full */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->q932Full); if (stat != ASN_OK) return stat; /* encode q951Full */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->q951Full); if (stat != ASN_OK) return stat; /* encode q952Full */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->q952Full); if (stat != ASN_OK) return stat; /* encode q953Full */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->q953Full); if (stat != ASN_OK) return stat; /* encode q955Full */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->q955Full); if (stat != ASN_OK) return stat; /* encode q956Full */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->q956Full); if (stat != ASN_OK) return stat; /* encode q957Full */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->q957Full); if (stat != ASN_OK) return stat; /* encode q954Info */ stat = asn1PE_H225Q954Details (pctxt, &pvalue->q954Info); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CallType */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallType (OOCTXT* pctxt, H225CallType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* pointToPoint */ case 1: /* NULL */ break; /* oneToN */ case 2: /* NULL */ break; /* nToOne */ case 3: /* NULL */ break; /* nToN */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* CallIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallIdentifier (OOCTXT* pctxt, H225CallIdentifier* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode guid */ stat = asn1PE_H225GloballyUniqueID (pctxt, &pvalue->guid); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* SecurityServiceMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SecurityServiceMode (OOCTXT* pctxt, H225SecurityServiceMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* none */ case 2: /* NULL */ break; /* default_ */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* SecurityCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SecurityCapabilities (OOCTXT* pctxt, H225SecurityCapabilities* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } /* encode encryption */ stat = asn1PE_H225SecurityServiceMode (pctxt, &pvalue->encryption); if (stat != ASN_OK) return stat; /* encode authenticaton */ stat = asn1PE_H225SecurityServiceMode (pctxt, &pvalue->authenticaton); if (stat != ASN_OK) return stat; /* encode integrity */ stat = asn1PE_H225SecurityServiceMode (pctxt, &pvalue->integrity); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H245Security */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H245Security (OOCTXT* pctxt, H225H245Security* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* noSecurity */ case 2: /* NULL */ break; /* tls */ case 3: stat = asn1PE_H225SecurityCapabilities (pctxt, pvalue->u.tls); if (stat != ASN_OK) return stat; break; /* ipsec */ case 4: stat = asn1PE_H225SecurityCapabilities (pctxt, pvalue->u.ipsec); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225H245Security */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225H245Security (OOCTXT* pctxt, H225_SeqOfH225H245Security* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225H245Security (pctxt, ((H225H245Security*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ClearToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225ClearToken (OOCTXT* pctxt, H225_SeqOfH225ClearToken* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H235ClearToken (pctxt, ((H235ClearToken*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoEPPwdHash */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CryptoH323Token_cryptoEPPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPPwdHash* pvalue) { int stat = ASN_OK; /* encode alias */ stat = asn1PE_H225AliasAddress (pctxt, &pvalue->alias); if (stat != ASN_OK) return stat; /* encode timeStamp */ stat = asn1PE_H235TimeStamp (pctxt, pvalue->timeStamp); if (stat != ASN_OK) return stat; /* encode token */ stat = asn1PE_H235HASHED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoGKPwdHash */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CryptoH323Token_cryptoGKPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKPwdHash* pvalue) { int stat = ASN_OK; /* encode gatekeeperId */ stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperId); if (stat != ASN_OK) return stat; /* encode timeStamp */ stat = asn1PE_H235TimeStamp (pctxt, pvalue->timeStamp); if (stat != ASN_OK) return stat; /* encode token */ stat = asn1PE_H235HASHED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoEPCert */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CryptoH323Token_cryptoEPCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPCert* pvalue) { int stat = ASN_OK; /* encode toBeSigned */ stat = asn1PE_H235EncodedPwdCertToken (pctxt, pvalue->toBeSigned); if (stat != ASN_OK) return stat; /* encode algorithmOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; /* encode paramS */ stat = asn1PE_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; /* encode signature */ stat = encodeBitString (pctxt, pvalue->signature.numbits, pvalue->signature.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoGKCert */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CryptoH323Token_cryptoGKCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKCert* pvalue) { int stat = ASN_OK; /* encode toBeSigned */ stat = asn1PE_H235EncodedPwdCertToken (pctxt, pvalue->toBeSigned); if (stat != ASN_OK) return stat; /* encode algorithmOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; /* encode paramS */ stat = asn1PE_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; /* encode signature */ stat = encodeBitString (pctxt, pvalue->signature.numbits, pvalue->signature.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoFastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CryptoH323Token_cryptoFastStart (OOCTXT* pctxt, H225CryptoH323Token_cryptoFastStart* pvalue) { int stat = ASN_OK; /* encode toBeSigned */ stat = asn1PE_H225EncodedFastStartToken (pctxt, pvalue->toBeSigned); if (stat != ASN_OK) return stat; /* encode algorithmOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; /* encode paramS */ stat = asn1PE_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; /* encode signature */ stat = encodeBitString (pctxt, pvalue->signature.numbits, pvalue->signature.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoH323Token */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CryptoH323Token (OOCTXT* pctxt, H225CryptoH323Token* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 8); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 7); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* cryptoEPPwdHash */ case 1: stat = asn1PE_H225CryptoH323Token_cryptoEPPwdHash (pctxt, pvalue->u.cryptoEPPwdHash); if (stat != ASN_OK) return stat; break; /* cryptoGKPwdHash */ case 2: stat = asn1PE_H225CryptoH323Token_cryptoGKPwdHash (pctxt, pvalue->u.cryptoGKPwdHash); if (stat != ASN_OK) return stat; break; /* cryptoEPPwdEncr */ case 3: stat = asn1PE_H235ENCRYPTED (pctxt, pvalue->u.cryptoEPPwdEncr); if (stat != ASN_OK) return stat; break; /* cryptoGKPwdEncr */ case 4: stat = asn1PE_H235ENCRYPTED (pctxt, pvalue->u.cryptoGKPwdEncr); if (stat != ASN_OK) return stat; break; /* cryptoEPCert */ case 5: stat = asn1PE_H225CryptoH323Token_cryptoEPCert (pctxt, pvalue->u.cryptoEPCert); if (stat != ASN_OK) return stat; break; /* cryptoGKCert */ case 6: stat = asn1PE_H225CryptoH323Token_cryptoGKCert (pctxt, pvalue->u.cryptoGKCert); if (stat != ASN_OK) return stat; break; /* cryptoFastStart */ case 7: stat = asn1PE_H225CryptoH323Token_cryptoFastStart (pctxt, pvalue->u.cryptoFastStart); if (stat != ASN_OK) return stat; break; /* nestedcryptoToken */ case 8: stat = asn1PE_H235CryptoToken (pctxt, pvalue->u.nestedcryptoToken); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 9); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CryptoH323Token */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225CryptoH323Token (OOCTXT* pctxt, H225_SeqOfH225CryptoH323Token* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225CryptoH323Token (pctxt, ((H225CryptoH323Token*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Setup_UUIE_fastStart (OOCTXT* pctxt, H225Setup_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ScnConnectionType */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ScnConnectionType (OOCTXT* pctxt, H225ScnConnectionType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 7); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 6); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unknown */ case 1: /* NULL */ break; /* bChannel */ case 2: /* NULL */ break; /* hybrid2x64 */ case 3: /* NULL */ break; /* hybrid384 */ case 4: /* NULL */ break; /* hybrid1536 */ case 5: /* NULL */ break; /* hybrid1920 */ case 6: /* NULL */ break; /* multirate */ case 7: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 8); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ScnConnectionAggregation */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ScnConnectionAggregation (OOCTXT* pctxt, H225ScnConnectionAggregation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* auto_ */ case 1: /* NULL */ break; /* none */ case 2: /* NULL */ break; /* h221 */ case 3: /* NULL */ break; /* bonded_mode1 */ case 4: /* NULL */ break; /* bonded_mode2 */ case 5: /* NULL */ break; /* bonded_mode3 */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_connectionParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Setup_UUIE_connectionParameters (OOCTXT* pctxt, H225Setup_UUIE_connectionParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode connectionType */ stat = asn1PE_H225ScnConnectionType (pctxt, &pvalue->connectionType); if (stat != ASN_OK) return stat; /* encode numberOfScnConnections */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfScnConnections, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode connectionAggregation */ stat = asn1PE_H225ScnConnectionAggregation (pctxt, &pvalue->connectionAggregation); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_language */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Setup_UUIE_language (OOCTXT* pctxt, H225Setup_UUIE_language* pvalue) { static Asn1SizeCnst element_lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { addSizeConstraint (pctxt, &element_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->elem[xx1], 0, 8, 7, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* PresentationIndicator */ /* */ /**************************************************************/ EXTERN int asn1PE_H225PresentationIndicator (OOCTXT* pctxt, H225PresentationIndicator* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* presentationAllowed */ case 1: /* NULL */ break; /* presentationRestricted */ case 2: /* NULL */ break; /* addressNotAvailable */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* CallCreditServiceControl_billingMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallCreditServiceControl_billingMode (OOCTXT* pctxt, H225CallCreditServiceControl_billingMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* credit */ case 1: /* NULL */ break; /* debit */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* CallCreditServiceControl_callStartingPoint */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallCreditServiceControl_callStartingPoint (OOCTXT* pctxt, H225CallCreditServiceControl_callStartingPoint* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* alerting */ case 1: /* NULL */ break; /* connect */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* CallCreditServiceControl */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallCreditServiceControl (OOCTXT* pctxt, H225CallCreditServiceControl* pvalue) { static Asn1SizeCnst amountString_lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.amountStringPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.billingModePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callDurationLimitPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.enforceCallDurationLimitPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callStartingPointPresent); /* encode amountString */ if (pvalue->m.amountStringPresent) { addSizeConstraint (pctxt, &amountString_lsize1); stat = encodeBMPString (pctxt, pvalue->amountString, 0); if (stat != ASN_OK) return stat; } /* encode billingMode */ if (pvalue->m.billingModePresent) { stat = asn1PE_H225CallCreditServiceControl_billingMode (pctxt, &pvalue->billingMode); if (stat != ASN_OK) return stat; } /* encode callDurationLimit */ if (pvalue->m.callDurationLimitPresent) { stat = encodeConsUnsigned (pctxt, pvalue->callDurationLimit, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode enforceCallDurationLimit */ if (pvalue->m.enforceCallDurationLimitPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->enforceCallDurationLimit); if (stat != ASN_OK) return stat; } /* encode callStartingPoint */ if (pvalue->m.callStartingPointPresent) { stat = asn1PE_H225CallCreditServiceControl_callStartingPoint (pctxt, &pvalue->callStartingPoint); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ServiceControlDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ServiceControlDescriptor (OOCTXT* pctxt, H225ServiceControlDescriptor* pvalue) { static Asn1SizeCnst url_lsize1 = { 0, 0, 512, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* url */ case 1: addSizeConstraint (pctxt, &url_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.url, 0, 8, 7, 7); if (stat != ASN_OK) return stat; break; /* signal */ case 2: stat = asn1PE_H225H248SignalsDescriptor (pctxt, *pvalue->u.signal); if (stat != ASN_OK) return stat; break; /* nonStandard */ case 3: stat = asn1PE_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* callCreditServiceControl */ case 4: stat = asn1PE_H225CallCreditServiceControl (pctxt, pvalue->u.callCreditServiceControl); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ServiceControlSession_reason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ServiceControlSession_reason (OOCTXT* pctxt, H225ServiceControlSession_reason* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* open */ case 1: /* NULL */ break; /* refresh */ case 2: /* NULL */ break; /* close */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ServiceControlSession */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ServiceControlSession (OOCTXT* pctxt, H225ServiceControlSession* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.contentsPresent); /* encode sessionId */ stat = encodeConsUnsigned (pctxt, pvalue->sessionId, 0U, 255U); if (stat != ASN_OK) return stat; /* encode contents */ if (pvalue->m.contentsPresent) { stat = asn1PE_H225ServiceControlDescriptor (pctxt, &pvalue->contents); if (stat != ASN_OK) return stat; } /* encode reason */ stat = asn1PE_H225ServiceControlSession_reason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ServiceControlSession */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225ServiceControlSession (OOCTXT* pctxt, H225_SeqOfH225ServiceControlSession* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225ServiceControlSession (pctxt, ((H225ServiceControlSession*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* CarrierInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CarrierInfo (OOCTXT* pctxt, H225CarrierInfo* pvalue) { static Asn1SizeCnst carrierName_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.carrierIdentificationCodePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.carrierNamePresent); /* encode carrierIdentificationCode */ if (pvalue->m.carrierIdentificationCodePresent) { stat = asn1PE_H225CarrierInfo_carrierIdentificationCode (pctxt, &pvalue->carrierIdentificationCode); if (stat != ASN_OK) return stat; } /* encode carrierName */ if (pvalue->m.carrierNamePresent) { addSizeConstraint (pctxt, &carrierName_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->carrierName, 0, 8, 7, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CallsAvailable */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallsAvailable (OOCTXT* pctxt, H225CallsAvailable* pvalue) { static Asn1SizeCnst group_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.carrierPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.groupPresent); /* encode calls */ stat = encodeConsUnsigned (pctxt, pvalue->calls, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; /* encode group */ if (pvalue->m.groupPresent) { addSizeConstraint (pctxt, &group_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->group, 0, 8, 7, 7); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.carrierPresent); /* encode extension elements */ if (pvalue->m.carrierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CarrierInfo (&lctxt, &pvalue->carrier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CallsAvailable */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225CallsAvailable (OOCTXT* pctxt, H225_SeqOfH225CallsAvailable* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225CallsAvailable (pctxt, ((H225CallsAvailable*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* CallCapacityInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallCapacityInfo (OOCTXT* pctxt, H225CallCapacityInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.sipGwCallsAvailablePresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.voiceGwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h310GwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h320GwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h321GwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h322GwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h323GwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h324GwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.t120OnlyGwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.t38FaxAnnexbOnlyGwCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalCallsAvailablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mcuCallsAvailablePresent); /* encode voiceGwCallsAvailable */ if (pvalue->m.voiceGwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->voiceGwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode h310GwCallsAvailable */ if (pvalue->m.h310GwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h310GwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode h320GwCallsAvailable */ if (pvalue->m.h320GwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h320GwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode h321GwCallsAvailable */ if (pvalue->m.h321GwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h321GwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode h322GwCallsAvailable */ if (pvalue->m.h322GwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h322GwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode h323GwCallsAvailable */ if (pvalue->m.h323GwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h323GwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode h324GwCallsAvailable */ if (pvalue->m.h324GwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h324GwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode t120OnlyGwCallsAvailable */ if (pvalue->m.t120OnlyGwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->t120OnlyGwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode t38FaxAnnexbOnlyGwCallsAvailable */ if (pvalue->m.t38FaxAnnexbOnlyGwCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->t38FaxAnnexbOnlyGwCallsAvailable); if (stat != ASN_OK) return stat; } /* encode terminalCallsAvailable */ if (pvalue->m.terminalCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->terminalCallsAvailable); if (stat != ASN_OK) return stat; } /* encode mcuCallsAvailable */ if (pvalue->m.mcuCallsAvailablePresent) { stat = asn1PE_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->mcuCallsAvailable); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.sipGwCallsAvailablePresent); /* encode extension elements */ if (pvalue->m.sipGwCallsAvailablePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CallsAvailable (&lctxt, &pvalue->sipGwCallsAvailable); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* CallCapacity */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallCapacity (OOCTXT* pctxt, H225CallCapacity* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maximumCallCapacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.currentCallCapacityPresent); /* encode maximumCallCapacity */ if (pvalue->m.maximumCallCapacityPresent) { stat = asn1PE_H225CallCapacityInfo (pctxt, &pvalue->maximumCallCapacity); if (stat != ASN_OK) return stat; } /* encode currentCallCapacity */ if (pvalue->m.currentCallCapacityPresent) { stat = asn1PE_H225CallCapacityInfo (pctxt, &pvalue->currentCallCapacity); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CicInfo_cic_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225CicInfo_cic_element (OOCTXT* pctxt, H225_SeqOfH225CicInfo_cic_element* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H225CicInfo_cic_element (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CicInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CicInfo (OOCTXT* pctxt, H225CicInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode cic */ stat = asn1PE_H225_SeqOfH225CicInfo_cic_element (pctxt, &pvalue->cic); if (stat != ASN_OK) return stat; /* encode pointCode */ stat = asn1PE_H225CicInfo_pointCode (pctxt, &pvalue->pointCode); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* GroupID_member */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GroupID_member (OOCTXT* pctxt, H225GroupID_member* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeConsUnsigned (pctxt, pvalue->elem[xx1], 0U, 65535U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* GroupID */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GroupID (OOCTXT* pctxt, H225GroupID* pvalue) { static Asn1SizeCnst group_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.memberPresent); /* encode member */ if (pvalue->m.memberPresent) { stat = asn1PE_H225GroupID_member (pctxt, &pvalue->member); if (stat != ASN_OK) return stat; } /* encode group */ addSizeConstraint (pctxt, &group_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->group, 0, 8, 7, 7); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CircuitIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CircuitIdentifier (OOCTXT* pctxt, H225CircuitIdentifier* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.carrierPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cicPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.groupPresent); /* encode cic */ if (pvalue->m.cicPresent) { stat = asn1PE_H225CicInfo (pctxt, &pvalue->cic); if (stat != ASN_OK) return stat; } /* encode group */ if (pvalue->m.groupPresent) { stat = asn1PE_H225GroupID (pctxt, &pvalue->group); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.carrierPresent); /* encode extension elements */ if (pvalue->m.carrierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CarrierInfo (&lctxt, &pvalue->carrier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225GenericData */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225GenericData (OOCTXT* pctxt, H225_SeqOfH225GenericData* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225GenericData (pctxt, ((H225GenericData*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* CircuitInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CircuitInfo (OOCTXT* pctxt, H225CircuitInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sourceCircuitIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationCircuitIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode sourceCircuitID */ if (pvalue->m.sourceCircuitIDPresent) { stat = asn1PE_H225CircuitIdentifier (pctxt, &pvalue->sourceCircuitID); if (stat != ASN_OK) return stat; } /* encode destinationCircuitID */ if (pvalue->m.destinationCircuitIDPresent) { stat = asn1PE_H225CircuitIdentifier (pctxt, &pvalue->destinationCircuitID); if (stat != ASN_OK) return stat; } /* encode genericData */ if (pvalue->m.genericDataPresent) { stat = asn1PE_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225FeatureDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225FeatureDescriptor (OOCTXT* pctxt, H225_SeqOfH225FeatureDescriptor* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225FeatureDescriptor (pctxt, ((H225FeatureDescriptor*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_parallelH245Control */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Setup_UUIE_parallelH245Control (OOCTXT* pctxt, H225Setup_UUIE_parallelH245Control* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ExtendedAliasAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ExtendedAliasAddress (OOCTXT* pctxt, H225ExtendedAliasAddress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.presentationIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.screeningIndicatorPresent); /* encode address */ stat = asn1PE_H225AliasAddress (pctxt, &pvalue->address); if (stat != ASN_OK) return stat; /* encode presentationIndicator */ if (pvalue->m.presentationIndicatorPresent) { stat = asn1PE_H225PresentationIndicator (pctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return stat; } /* encode screeningIndicator */ if (pvalue->m.screeningIndicatorPresent) { stat = asn1PE_H225ScreeningIndicator (pctxt, pvalue->screeningIndicator); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ExtendedAliasAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225ExtendedAliasAddress (OOCTXT* pctxt, H225_SeqOfH225ExtendedAliasAddress* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225ExtendedAliasAddress (pctxt, ((H225ExtendedAliasAddress*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Setup_UUIE (OOCTXT* pctxt, H225Setup_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.sourceCallSignalAddressPresent || pvalue->m.remoteExtensionAddressPresent || pvalue->m.callIdentifierPresent || pvalue->m.h245SecurityCapabilityPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.fastStartPresent || pvalue->m.mediaWaitForConnectPresent || pvalue->m.canOverlapSendPresent || pvalue->m.endpointIdentifierPresent || pvalue->m.multipleCallsPresent || pvalue->m.maintainConnectionPresent || pvalue->m.connectionParametersPresent || pvalue->m.languagePresent || pvalue->m.presentationIndicatorPresent || pvalue->m.screeningIndicatorPresent || pvalue->m.serviceControlPresent || pvalue->m.symmetricOperationRequiredPresent || pvalue->m.capacityPresent || pvalue->m.circuitInfoPresent || pvalue->m.desiredProtocolsPresent || pvalue->m.neededFeaturesPresent || pvalue->m.desiredFeaturesPresent || pvalue->m.supportedFeaturesPresent || pvalue->m.parallelH245ControlPresent || pvalue->m.additionalSourceAddressesPresent || pvalue->m.hopCountPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245AddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sourceAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destCallSignalAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destExtraCallInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destExtraCRVPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callServicesPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode h245Address */ if (pvalue->m.h245AddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; } /* encode sourceAddress */ if (pvalue->m.sourceAddressPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->sourceAddress); if (stat != ASN_OK) return stat; } /* encode sourceInfo */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->sourceInfo); if (stat != ASN_OK) return stat; /* encode destinationAddress */ if (pvalue->m.destinationAddressPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationAddress); if (stat != ASN_OK) return stat; } /* encode destCallSignalAddress */ if (pvalue->m.destCallSignalAddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->destCallSignalAddress); if (stat != ASN_OK) return stat; } /* encode destExtraCallInfo */ if (pvalue->m.destExtraCallInfoPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; } /* encode destExtraCRV */ if (pvalue->m.destExtraCRVPresent) { stat = asn1PE_H225_SeqOfH225CallReferenceValue (pctxt, &pvalue->destExtraCRV); if (stat != ASN_OK) return stat; } /* encode activeMC */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->activeMC); if (stat != ASN_OK) return stat; /* encode conferenceID */ stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; /* encode conferenceGoal */ stat = asn1PE_H225Setup_UUIE_conferenceGoal (pctxt, &pvalue->conferenceGoal); if (stat != ASN_OK) return stat; /* encode callServices */ if (pvalue->m.callServicesPresent) { stat = asn1PE_H225QseriesOptions (pctxt, &pvalue->callServices); if (stat != ASN_OK) return stat; } /* encode callType */ stat = asn1PE_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 26); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.sourceCallSignalAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.remoteExtensionAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245SecurityCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastStartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaWaitForConnectPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.canOverlapSendPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.connectionParametersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.languagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.presentationIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.screeningIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.symmetricOperationRequiredPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.desiredProtocolsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.neededFeaturesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.desiredFeaturesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedFeaturesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.parallelH245ControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.additionalSourceAddressesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.hopCountPresent); /* encode extension elements */ if (pvalue->m.sourceCallSignalAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TransportAddress (&lctxt, &pvalue->sourceCallSignalAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.remoteExtensionAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AliasAddress (&lctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245SecurityCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225H245Security (&lctxt, &pvalue->h245SecurityCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastStartPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Setup_UUIE_fastStart (&lctxt, &pvalue->fastStart); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.mediaWaitForConnectPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->mediaWaitForConnect); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.canOverlapSendPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->canOverlapSend); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.endpointIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225EndpointIdentifier (&lctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.connectionParametersPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Setup_UUIE_connectionParameters (&lctxt, &pvalue->connectionParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.languagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Setup_UUIE_language (&lctxt, &pvalue->language); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.presentationIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225PresentationIndicator (&lctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.screeningIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ScreeningIndicator (&lctxt, pvalue->screeningIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.symmetricOperationRequiredPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.desiredProtocolsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedProtocols (&lctxt, &pvalue->desiredProtocols); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.neededFeaturesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225FeatureDescriptor (&lctxt, &pvalue->neededFeatures); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.desiredFeaturesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225FeatureDescriptor (&lctxt, &pvalue->desiredFeatures); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedFeaturesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225FeatureDescriptor (&lctxt, &pvalue->supportedFeatures); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.parallelH245ControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Setup_UUIE_parallelH245Control (&lctxt, &pvalue->parallelH245Control); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.additionalSourceAddressesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ExtendedAliasAddress (&lctxt, &pvalue->additionalSourceAddresses); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.hopCountPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->hopCount, 1U, 31U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* CallProceeding_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallProceeding_UUIE_fastStart (OOCTXT* pctxt, H225CallProceeding_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FeatureSet */ /* */ /**************************************************************/ EXTERN int asn1PE_H225FeatureSet (OOCTXT* pctxt, H225FeatureSet* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.neededFeaturesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.desiredFeaturesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedFeaturesPresent); /* encode replacementFeatureSet */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->replacementFeatureSet); if (stat != ASN_OK) return stat; /* encode neededFeatures */ if (pvalue->m.neededFeaturesPresent) { stat = asn1PE_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->neededFeatures); if (stat != ASN_OK) return stat; } /* encode desiredFeatures */ if (pvalue->m.desiredFeaturesPresent) { stat = asn1PE_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->desiredFeatures); if (stat != ASN_OK) return stat; } /* encode supportedFeatures */ if (pvalue->m.supportedFeaturesPresent) { stat = asn1PE_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->supportedFeatures); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CallProceeding_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallProceeding_UUIE (OOCTXT* pctxt, H225CallProceeding_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.h245SecurityModePresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.fastStartPresent || pvalue->m.multipleCallsPresent || pvalue->m.maintainConnectionPresent || pvalue->m.fastConnectRefusedPresent || pvalue->m.featureSetPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245AddressPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode destinationInfo */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; /* encode h245Address */ if (pvalue->m.h245AddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 8); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245SecurityModePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastStartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastConnectRefusedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245SecurityModePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225H245Security (&lctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastStartPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallProceeding_UUIE_fastStart (&lctxt, &pvalue->fastStart); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastConnectRefusedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* Connect_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Connect_UUIE_fastStart (OOCTXT* pctxt, H225Connect_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Connect_UUIE_language */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Connect_UUIE_language (OOCTXT* pctxt, H225Connect_UUIE_language* pvalue) { static Asn1SizeCnst element_lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { addSizeConstraint (pctxt, &element_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->elem[xx1], 0, 8, 7, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Connect_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Connect_UUIE (OOCTXT* pctxt, H225Connect_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.h245SecurityModePresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.fastStartPresent || pvalue->m.multipleCallsPresent || pvalue->m.maintainConnectionPresent || pvalue->m.languagePresent || pvalue->m.connectedAddressPresent || pvalue->m.presentationIndicatorPresent || pvalue->m.screeningIndicatorPresent || pvalue->m.fastConnectRefusedPresent || pvalue->m.serviceControlPresent || pvalue->m.capacityPresent || pvalue->m.featureSetPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245AddressPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode h245Address */ if (pvalue->m.h245AddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; } /* encode destinationInfo */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; /* encode conferenceID */ stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 14); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245SecurityModePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastStartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.languagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.connectedAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.presentationIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.screeningIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastConnectRefusedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245SecurityModePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225H245Security (&lctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastStartPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Connect_UUIE_fastStart (&lctxt, &pvalue->fastStart); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.languagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Connect_UUIE_language (&lctxt, &pvalue->language); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.connectedAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->connectedAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.presentationIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225PresentationIndicator (&lctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.screeningIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ScreeningIndicator (&lctxt, pvalue->screeningIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastConnectRefusedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* Alerting_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Alerting_UUIE_fastStart (OOCTXT* pctxt, H225Alerting_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Alerting_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Alerting_UUIE (OOCTXT* pctxt, H225Alerting_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.h245SecurityModePresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.fastStartPresent || pvalue->m.multipleCallsPresent || pvalue->m.maintainConnectionPresent || pvalue->m.alertingAddressPresent || pvalue->m.presentationIndicatorPresent || pvalue->m.screeningIndicatorPresent || pvalue->m.fastConnectRefusedPresent || pvalue->m.serviceControlPresent || pvalue->m.capacityPresent || pvalue->m.featureSetPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245AddressPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode destinationInfo */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; /* encode h245Address */ if (pvalue->m.h245AddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 13); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245SecurityModePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastStartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alertingAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.presentationIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.screeningIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastConnectRefusedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245SecurityModePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225H245Security (&lctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastStartPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Alerting_UUIE_fastStart (&lctxt, &pvalue->fastStart); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alertingAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->alertingAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.presentationIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225PresentationIndicator (&lctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.screeningIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ScreeningIndicator (&lctxt, pvalue->screeningIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastConnectRefusedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* Information_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Information_UUIE_fastStart (OOCTXT* pctxt, H225Information_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Information_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Information_UUIE (OOCTXT* pctxt, H225Information_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.fastStartPresent || pvalue->m.fastConnectRefusedPresent || pvalue->m.circuitInfoPresent); encodeBit (pctxt, extbit); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 5); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastStartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastConnectRefusedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastStartPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Information_UUIE_fastStart (&lctxt, &pvalue->fastStart); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastConnectRefusedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* SecurityErrors */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SecurityErrors (OOCTXT* pctxt, H225SecurityErrors* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 16); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 15); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* securityWrongSyncTime */ case 1: /* NULL */ break; /* securityReplay */ case 2: /* NULL */ break; /* securityWrongGeneralID */ case 3: /* NULL */ break; /* securityWrongSendersID */ case 4: /* NULL */ break; /* securityIntegrityFailed */ case 5: /* NULL */ break; /* securityWrongOID */ case 6: /* NULL */ break; /* securityDHmismatch */ case 7: /* NULL */ break; /* securityCertificateExpired */ case 8: /* NULL */ break; /* securityCertificateDateInvalid */ case 9: /* NULL */ break; /* securityCertificateRevoked */ case 10: /* NULL */ break; /* securityCertificateNotReadable */ case 11: /* NULL */ break; /* securityCertificateSignatureInvalid */ case 12: /* NULL */ break; /* securityCertificateMissing */ case 13: /* NULL */ break; /* securityCertificateIncomplete */ case 14: /* NULL */ break; /* securityUnsupportedCertificateAlgOID */ case 15: /* NULL */ break; /* securityUnknownCA */ case 16: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 17); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ReleaseCompleteReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ReleaseCompleteReason (OOCTXT* pctxt, H225ReleaseCompleteReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 12); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 11); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noBandwidth */ case 1: /* NULL */ break; /* gatekeeperResources */ case 2: /* NULL */ break; /* unreachableDestination */ case 3: /* NULL */ break; /* destinationRejection */ case 4: /* NULL */ break; /* invalidRevision */ case 5: /* NULL */ break; /* noPermission */ case 6: /* NULL */ break; /* unreachableGatekeeper */ case 7: /* NULL */ break; /* gatewayResources */ case 8: /* NULL */ break; /* badFormatAddress */ case 9: /* NULL */ break; /* adaptiveBusy */ case 10: /* NULL */ break; /* inConf */ case 11: /* NULL */ break; /* undefinedReason */ case 12: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 13); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* facilityCallDeflection */ case 13: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityDenied */ case 14: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* calledPartyNotRegistered */ case 15: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* callerNotRegistered */ case 16: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* newConnectionNeeded */ case 17: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* nonStandardReason */ case 18: stat = asn1PE_H225NonStandardParameter (&lctxt, pvalue->u.nonStandardReason); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* replaceWithConferenceInvite */ case 19: stat = asn1PE_H225ConferenceIdentifier (&lctxt, pvalue->u.replaceWithConferenceInvite); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericDataReason */ case 20: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* neededFeatureNotSupported */ case 21: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* tunnelledSignallingRejected */ case 22: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* invalidCID */ case 23: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 24: stat = asn1PE_H225SecurityErrors (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* hopCountExceeded */ case 25: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* ReleaseComplete_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ReleaseComplete_UUIE (OOCTXT* pctxt, H225ReleaseComplete_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.busyAddressPresent || pvalue->m.presentationIndicatorPresent || pvalue->m.screeningIndicatorPresent || pvalue->m.capacityPresent || pvalue->m.serviceControlPresent || pvalue->m.featureSetPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.reasonPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode reason */ if (pvalue->m.reasonPresent) { stat = asn1PE_H225ReleaseCompleteReason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 8); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.busyAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.presentationIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.screeningIndicatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.busyAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->busyAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.presentationIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225PresentationIndicator (&lctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.screeningIndicatorPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ScreeningIndicator (&lctxt, pvalue->screeningIndicator); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* FacilityReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225FacilityReason (OOCTXT* pctxt, H225FacilityReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* routeCallToGatekeeper */ case 1: /* NULL */ break; /* callForwarded */ case 2: /* NULL */ break; /* routeCallToMC */ case 3: /* NULL */ break; /* undefinedReason */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* conferenceListChoice */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* startH245 */ case 6: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* noH245 */ case 7: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* newTokens */ case 8: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* featureSetUpdate */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* forwardedElements */ case 10: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* transportedInformation */ case 11: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* ConferenceList */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ConferenceList (OOCTXT* pctxt, H225ConferenceList* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.conferenceIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.conferenceAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode conferenceID */ if (pvalue->m.conferenceIDPresent) { stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; } /* encode conferenceAlias */ if (pvalue->m.conferenceAliasPresent) { stat = asn1PE_H225AliasAddress (pctxt, &pvalue->conferenceAlias); if (stat != ASN_OK) return stat; } /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ConferenceList */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225ConferenceList (OOCTXT* pctxt, H225_SeqOfH225ConferenceList* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225ConferenceList (pctxt, ((H225ConferenceList*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* Facility_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Facility_UUIE_fastStart (OOCTXT* pctxt, H225Facility_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Facility_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Facility_UUIE (OOCTXT* pctxt, H225Facility_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.destExtraCallInfoPresent || pvalue->m.remoteExtensionAddressPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.conferencesPresent || pvalue->m.h245AddressPresent || pvalue->m.fastStartPresent || pvalue->m.multipleCallsPresent || pvalue->m.maintainConnectionPresent || pvalue->m.fastConnectRefusedPresent || pvalue->m.serviceControlPresent || pvalue->m.circuitInfoPresent || pvalue->m.featureSetPresent || pvalue->m.destinationInfoPresent || pvalue->m.h245SecurityModePresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternativeAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternativeAliasAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.conferenceIDPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode alternativeAddress */ if (pvalue->m.alternativeAddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->alternativeAddress); if (stat != ASN_OK) return stat; } /* encode alternativeAliasAddress */ if (pvalue->m.alternativeAliasAddressPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->alternativeAliasAddress); if (stat != ASN_OK) return stat; } /* encode conferenceID */ if (pvalue->m.conferenceIDPresent) { stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; } /* encode reason */ stat = asn1PE_H225FacilityReason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 15); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destExtraCallInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.remoteExtensionAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.conferencesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245AddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastStartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastConnectRefusedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245SecurityModePresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destExtraCallInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.remoteExtensionAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AliasAddress (&lctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.conferencesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ConferenceList (&lctxt, &pvalue->conferences); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245AddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TransportAddress (&lctxt, &pvalue->h245Address); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastStartPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225Facility_UUIE_fastStart (&lctxt, &pvalue->fastStart); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastConnectRefusedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destinationInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225EndpointType (&lctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245SecurityModePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225H245Security (&lctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* Progress_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Progress_UUIE_fastStart (OOCTXT* pctxt, H225Progress_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Progress_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Progress_UUIE (OOCTXT* pctxt, H225Progress_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.multipleCallsPresent || pvalue->m.maintainConnectionPresent || pvalue->m.fastConnectRefusedPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245AddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245SecurityModePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastStartPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode destinationInfo */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; /* encode h245Address */ if (pvalue->m.h245AddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; } /* encode callIdentifier */ stat = asn1PE_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; /* encode h245SecurityMode */ if (pvalue->m.h245SecurityModePresent) { stat = asn1PE_H225H245Security (pctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode fastStart */ if (pvalue->m.fastStartPresent) { stat = asn1PE_H225Progress_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 2); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.fastConnectRefusedPresent); /* encode extension elements */ if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.fastConnectRefusedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* Status_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Status_UUIE (OOCTXT* pctxt, H225Status_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode callIdentifier */ stat = asn1PE_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* StatusInquiry_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225StatusInquiry_UUIE (OOCTXT* pctxt, H225StatusInquiry_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode callIdentifier */ stat = asn1PE_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* SetupAcknowledge_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SetupAcknowledge_UUIE (OOCTXT* pctxt, H225SetupAcknowledge_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode callIdentifier */ stat = asn1PE_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Notify_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Notify_UUIE (OOCTXT* pctxt, H225Notify_UUIE* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode callIdentifier */ stat = asn1PE_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_h323_message_body */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UU_PDU_h323_message_body (OOCTXT* pctxt, H225H323_UU_PDU_h323_message_body* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 7); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 6); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* setup */ case 1: stat = asn1PE_H225Setup_UUIE (pctxt, pvalue->u.setup); if (stat != ASN_OK) return stat; break; /* callProceeding */ case 2: stat = asn1PE_H225CallProceeding_UUIE (pctxt, pvalue->u.callProceeding); if (stat != ASN_OK) return stat; break; /* connect */ case 3: stat = asn1PE_H225Connect_UUIE (pctxt, pvalue->u.connect); if (stat != ASN_OK) return stat; break; /* alerting */ case 4: stat = asn1PE_H225Alerting_UUIE (pctxt, pvalue->u.alerting); if (stat != ASN_OK) return stat; break; /* information */ case 5: stat = asn1PE_H225Information_UUIE (pctxt, pvalue->u.information); if (stat != ASN_OK) return stat; break; /* releaseComplete */ case 6: stat = asn1PE_H225ReleaseComplete_UUIE (pctxt, pvalue->u.releaseComplete); if (stat != ASN_OK) return stat; break; /* facility */ case 7: stat = asn1PE_H225Facility_UUIE (pctxt, pvalue->u.facility); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 8); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* progress */ case 8: stat = asn1PE_H225Progress_UUIE (&lctxt, pvalue->u.progress); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* empty */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* status */ case 10: stat = asn1PE_H225Status_UUIE (&lctxt, pvalue->u.status); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* statusInquiry */ case 11: stat = asn1PE_H225StatusInquiry_UUIE (&lctxt, pvalue->u.statusInquiry); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* setupAcknowledge */ case 12: stat = asn1PE_H225SetupAcknowledge_UUIE (&lctxt, pvalue->u.setupAcknowledge); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* notify */ case 13: stat = asn1PE_H225Notify_UUIE (&lctxt, pvalue->u.notify); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_h4501SupplementaryService */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UU_PDU_h4501SupplementaryService (OOCTXT* pctxt, H225H323_UU_PDU_h4501SupplementaryService* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_h245Control */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UU_PDU_h245Control (OOCTXT* pctxt, H225H323_UU_PDU_h245Control* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225NonStandardParameter (OOCTXT* pctxt, H225_SeqOfH225NonStandardParameter* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225NonStandardParameter (pctxt, ((H225NonStandardParameter*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* CallLinkage */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallLinkage (OOCTXT* pctxt, H225CallLinkage* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.globalCallIdPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.threadIdPresent); /* encode globalCallId */ if (pvalue->m.globalCallIdPresent) { stat = asn1PE_H225GloballyUniqueID (pctxt, &pvalue->globalCallId); if (stat != ASN_OK) return stat; } /* encode threadId */ if (pvalue->m.threadIdPresent) { stat = asn1PE_H225GloballyUniqueID (pctxt, &pvalue->threadId); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_tunnelledSignallingMessage_messageContent */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UU_PDU_tunnelledSignallingMessage_messageContent (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage_messageContent* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeOctetString (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_tunnelledSignallingMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UU_PDU_tunnelledSignallingMessage (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tunnellingRequiredPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode tunnelledProtocolID */ stat = asn1PE_H225TunnelledProtocol (pctxt, &pvalue->tunnelledProtocolID); if (stat != ASN_OK) return stat; /* encode messageContent */ stat = asn1PE_H225H323_UU_PDU_tunnelledSignallingMessage_messageContent (pctxt, &pvalue->messageContent); if (stat != ASN_OK) return stat; /* encode tunnellingRequired */ if (pvalue->m.tunnellingRequiredPresent) { /* NULL */ } /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* StimulusControl */ /* */ /**************************************************************/ EXTERN int asn1PE_H225StimulusControl (OOCTXT* pctxt, H225StimulusControl* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.isTextPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h248MessagePresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } /* encode isText */ if (pvalue->m.isTextPresent) { /* NULL */ } /* encode h248Message */ if (pvalue->m.h248MessagePresent) { stat = encodeOctetString (pctxt, pvalue->h248Message.numocts, pvalue->h248Message.data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UU_PDU (OOCTXT* pctxt, H225H323_UU_PDU* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.h4501SupplementaryServicePresent || pvalue->m.h245TunnelingPresent || pvalue->m.h245ControlPresent || pvalue->m.nonStandardControlPresent || pvalue->m.callLinkagePresent || pvalue->m.tunnelledSignallingMessagePresent || pvalue->m.provisionalRespToH245TunnelingPresent || pvalue->m.stimulusControlPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode h323_message_body */ stat = asn1PE_H225H323_UU_PDU_h323_message_body (pctxt, &pvalue->h323_message_body); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 8); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.h4501SupplementaryServicePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245TunnelingPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h245ControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callLinkagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tunnelledSignallingMessagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.provisionalRespToH245TunnelingPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.stimulusControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.h4501SupplementaryServicePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225H323_UU_PDU_h4501SupplementaryService (&lctxt, &pvalue->h4501SupplementaryService); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245TunnelingPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->h245Tunneling); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h245ControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225H323_UU_PDU_h245Control (&lctxt, &pvalue->h245Control); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.nonStandardControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225NonStandardParameter (&lctxt, &pvalue->nonStandardControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callLinkagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallLinkage (&lctxt, &pvalue->callLinkage); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tunnelledSignallingMessagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225H323_UU_PDU_tunnelledSignallingMessage (&lctxt, &pvalue->tunnelledSignallingMessage); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.provisionalRespToH245TunnelingPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.stimulusControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225StimulusControl (&lctxt, &pvalue->stimulusControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H323_UserInformation_user_data */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UserInformation_user_data (OOCTXT* pctxt, H225H323_UserInformation_user_data* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode protocol_discriminator */ stat = encodeConsUnsigned (pctxt, pvalue->protocol_discriminator, 0U, 255U); if (stat != ASN_OK) return stat; /* encode user_information */ stat = asn1PE_H225H323_UserInformation_user_data_user_information (pctxt, &pvalue->user_information); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H323_UserInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H225H323_UserInformation (OOCTXT* pctxt, H225H323_UserInformation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.user_dataPresent); /* encode h323_uu_pdu */ stat = asn1PE_H225H323_UU_PDU (pctxt, &pvalue->h323_uu_pdu); if (stat != ASN_OK) return stat; /* encode user_data */ if (pvalue->m.user_dataPresent) { stat = asn1PE_H225H323_UserInformation_user_data (pctxt, &pvalue->user_data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* AddressPattern_range */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AddressPattern_range (OOCTXT* pctxt, H225AddressPattern_range* pvalue) { int stat = ASN_OK; /* encode startOfRange */ stat = asn1PE_H225PartyNumber (pctxt, &pvalue->startOfRange); if (stat != ASN_OK) return stat; /* encode endOfRange */ stat = asn1PE_H225PartyNumber (pctxt, &pvalue->endOfRange); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* AddressPattern */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AddressPattern (OOCTXT* pctxt, H225AddressPattern* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* wildcard */ case 1: stat = asn1PE_H225AliasAddress (pctxt, pvalue->u.wildcard); if (stat != ASN_OK) return stat; break; /* range */ case 2: stat = asn1PE_H225AddressPattern_range (pctxt, pvalue->u.range); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TransportAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225TransportAddress (OOCTXT* pctxt, H225_SeqOfH225TransportAddress* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225TransportAddress (pctxt, ((H225TransportAddress*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* AlternateTransportAddresses */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AlternateTransportAddresses (OOCTXT* pctxt, H225AlternateTransportAddresses* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.sctpPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.annexEPresent); /* encode annexE */ if (pvalue->m.annexEPresent) { stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->annexE); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.sctpPresent); /* encode extension elements */ if (pvalue->m.sctpPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225TransportAddress (&lctxt, &pvalue->sctp); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* Endpoint */ /* */ /**************************************************************/ EXTERN int asn1PE_H225Endpoint (OOCTXT* pctxt, H225Endpoint* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.alternateTransportAddressesPresent || pvalue->m.circuitInfoPresent || pvalue->m.featureSetPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.aliasAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callSignalAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.rasAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointTypePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.priorityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.remoteExtensionAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destExtraCallInfoPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode aliasAddress */ if (pvalue->m.aliasAddressPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->aliasAddress); if (stat != ASN_OK) return stat; } /* encode callSignalAddress */ if (pvalue->m.callSignalAddressPresent) { stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; } /* encode rasAddress */ if (pvalue->m.rasAddressPresent) { stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; } /* encode endpointType */ if (pvalue->m.endpointTypePresent) { stat = asn1PE_H225EndpointType (pctxt, &pvalue->endpointType); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode priority */ if (pvalue->m.priorityPresent) { stat = encodeConsUnsigned (pctxt, pvalue->priority, 0U, 127U); if (stat != ASN_OK) return stat; } /* encode remoteExtensionAddress */ if (pvalue->m.remoteExtensionAddressPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return stat; } /* encode destExtraCallInfo */ if (pvalue->m.destExtraCallInfoPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 2); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateTransportAddressesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); /* encode extension elements */ if (pvalue->m.alternateTransportAddressesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AlternateTransportAddresses (&lctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UseSpecifiedTransport */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UseSpecifiedTransport (OOCTXT* pctxt, H225UseSpecifiedTransport* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* tcp */ case 1: /* NULL */ break; /* annexE */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* sctp */ case 3: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* AlternateGK */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AlternateGK (OOCTXT* pctxt, H225AlternateGK* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); /* encode rasAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; /* encode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; } /* encode needToRegister */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->needToRegister); if (stat != ASN_OK) return stat; /* encode priority */ stat = encodeConsUnsigned (pctxt, pvalue->priority, 0U, 127U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AlternateGK */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225AlternateGK (OOCTXT* pctxt, H225_SeqOfH225AlternateGK* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225AlternateGK (pctxt, ((H225AlternateGK*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* AltGKInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AltGKInfo (OOCTXT* pctxt, H225AltGKInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode alternateGatekeeper */ stat = asn1PE_H225_SeqOfH225AlternateGK (pctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return stat; /* encode altGKisPermanent */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->altGKisPermanent); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* SecurityErrors2 */ /* */ /**************************************************************/ EXTERN int asn1PE_H225SecurityErrors2 (OOCTXT* pctxt, H225SecurityErrors2* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* securityWrongSyncTime */ case 1: /* NULL */ break; /* securityReplay */ case 2: /* NULL */ break; /* securityWrongGeneralID */ case 3: /* NULL */ break; /* securityWrongSendersID */ case 4: /* NULL */ break; /* securityIntegrityFailed */ case 5: /* NULL */ break; /* securityWrongOID */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* EncryptIntAlg */ /* */ /**************************************************************/ EXTERN int asn1PE_H225EncryptIntAlg (OOCTXT* pctxt, H225EncryptIntAlg* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* isoAlgorithm */ case 2: stat = encodeObjectIdentifier (pctxt, pvalue->u.isoAlgorithm); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NonIsoIntegrityMechanism */ /* */ /**************************************************************/ EXTERN int asn1PE_H225NonIsoIntegrityMechanism (OOCTXT* pctxt, H225NonIsoIntegrityMechanism* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* hMAC_MD5 */ case 1: /* NULL */ break; /* hMAC_iso10118_2_s */ case 2: stat = asn1PE_H225EncryptIntAlg (pctxt, pvalue->u.hMAC_iso10118_2_s); if (stat != ASN_OK) return stat; break; /* hMAC_iso10118_2_l */ case 3: stat = asn1PE_H225EncryptIntAlg (pctxt, pvalue->u.hMAC_iso10118_2_l); if (stat != ASN_OK) return stat; break; /* hMAC_iso10118_3 */ case 4: stat = encodeObjectIdentifier (pctxt, pvalue->u.hMAC_iso10118_3); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* IntegrityMechanism */ /* */ /**************************************************************/ EXTERN int asn1PE_H225IntegrityMechanism (OOCTXT* pctxt, H225IntegrityMechanism* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* digSig */ case 2: /* NULL */ break; /* iso9797 */ case 3: stat = encodeObjectIdentifier (pctxt, pvalue->u.iso9797); if (stat != ASN_OK) return stat; break; /* nonIsoIM */ case 4: stat = asn1PE_H225NonIsoIntegrityMechanism (pctxt, pvalue->u.nonIsoIM); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ICV */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ICV (OOCTXT* pctxt, H225ICV* pvalue) { int stat = ASN_OK; /* encode algorithmOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; /* encode icv */ stat = encodeBitString (pctxt, pvalue->icv.numbits, pvalue->icv.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CapacityReportingCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CapacityReportingCapability (OOCTXT* pctxt, H225CapacityReportingCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode canReportCallCapacity */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->canReportCallCapacity); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CapacityReportingSpecification_when */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CapacityReportingSpecification_when (OOCTXT* pctxt, H225CapacityReportingSpecification_when* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callStartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callEndPresent); /* encode callStart */ if (pvalue->m.callStartPresent) { /* NULL */ } /* encode callEnd */ if (pvalue->m.callEndPresent) { /* NULL */ } return (stat); } /**************************************************************/ /* */ /* CapacityReportingSpecification */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CapacityReportingSpecification (OOCTXT* pctxt, H225CapacityReportingSpecification* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode when */ stat = asn1PE_H225CapacityReportingSpecification_when (pctxt, &pvalue->when); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RasUsageInfoTypes */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RasUsageInfoTypes (OOCTXT* pctxt, H225RasUsageInfoTypes* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.startTimePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endTimePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminationCausePresent); /* encode nonStandardUsageTypes */ stat = asn1PE_H225_SeqOfH225NonStandardParameter (pctxt, &pvalue->nonStandardUsageTypes); if (stat != ASN_OK) return stat; /* encode startTime */ if (pvalue->m.startTimePresent) { /* NULL */ } /* encode endTime */ if (pvalue->m.endTimePresent) { /* NULL */ } /* encode terminationCause */ if (pvalue->m.terminationCausePresent) { /* NULL */ } return (stat); } /**************************************************************/ /* */ /* RasUsageSpecification_when */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RasUsageSpecification_when (OOCTXT* pctxt, H225RasUsageSpecification_when* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.startPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.inIrrPresent); /* encode start */ if (pvalue->m.startPresent) { /* NULL */ } /* encode end */ if (pvalue->m.endPresent) { /* NULL */ } /* encode inIrr */ if (pvalue->m.inIrrPresent) { /* NULL */ } return (stat); } /**************************************************************/ /* */ /* RasUsageSpecification_callStartingPoint */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RasUsageSpecification_callStartingPoint (OOCTXT* pctxt, H225RasUsageSpecification_callStartingPoint* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alertingPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.connectPresent); /* encode alerting */ if (pvalue->m.alertingPresent) { /* NULL */ } /* encode connect */ if (pvalue->m.connectPresent) { /* NULL */ } return (stat); } /**************************************************************/ /* */ /* RasUsageSpecification */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RasUsageSpecification (OOCTXT* pctxt, H225RasUsageSpecification* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callStartingPointPresent); /* encode when */ stat = asn1PE_H225RasUsageSpecification_when (pctxt, &pvalue->when); if (stat != ASN_OK) return stat; /* encode callStartingPoint */ if (pvalue->m.callStartingPointPresent) { stat = asn1PE_H225RasUsageSpecification_callStartingPoint (pctxt, &pvalue->callStartingPoint); if (stat != ASN_OK) return stat; } /* encode required */ stat = asn1PE_H225RasUsageInfoTypes (pctxt, &pvalue->required); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RasUsageInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RasUsageInformation (OOCTXT* pctxt, H225RasUsageInformation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alertingTimePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.connectTimePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endTimePresent); /* encode nonStandardUsageFields */ stat = asn1PE_H225_SeqOfH225NonStandardParameter (pctxt, &pvalue->nonStandardUsageFields); if (stat != ASN_OK) return stat; /* encode alertingTime */ if (pvalue->m.alertingTimePresent) { stat = asn1PE_H235TimeStamp (pctxt, pvalue->alertingTime); if (stat != ASN_OK) return stat; } /* encode connectTime */ if (pvalue->m.connectTimePresent) { stat = asn1PE_H235TimeStamp (pctxt, pvalue->connectTime); if (stat != ASN_OK) return stat; } /* encode endTime */ if (pvalue->m.endTimePresent) { stat = asn1PE_H235TimeStamp (pctxt, pvalue->endTime); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CallTerminationCause */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallTerminationCause (OOCTXT* pctxt, H225CallTerminationCause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* releaseCompleteReason */ case 1: stat = asn1PE_H225ReleaseCompleteReason (pctxt, pvalue->u.releaseCompleteReason); if (stat != ASN_OK) return stat; break; /* releaseCompleteCauseIE */ case 2: stat = asn1PE_H225CallTerminationCause_releaseCompleteCauseIE (pctxt, pvalue->u.releaseCompleteCauseIE); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TransportChannelInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportChannelInfo (OOCTXT* pctxt, H225TransportChannelInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sendAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.recvAddressPresent); /* encode sendAddress */ if (pvalue->m.sendAddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->sendAddress); if (stat != ASN_OK) return stat; } /* encode recvAddress */ if (pvalue->m.recvAddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->recvAddress); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* BandwidthDetails */ /* */ /**************************************************************/ EXTERN int asn1PE_H225BandwidthDetails (OOCTXT* pctxt, H225BandwidthDetails* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sender */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->sender); if (stat != ASN_OK) return stat; /* encode multicast */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->multicast); if (stat != ASN_OK) return stat; /* encode bandwidth */ stat = asn1PE_H225BandWidth (pctxt, pvalue->bandwidth); if (stat != ASN_OK) return stat; /* encode rtcpAddresses */ stat = asn1PE_H225TransportChannelInfo (pctxt, &pvalue->rtcpAddresses); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CallCreditCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallCreditCapability (OOCTXT* pctxt, H225CallCreditCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.canDisplayAmountStringPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.canEnforceDurationLimitPresent); /* encode canDisplayAmountString */ if (pvalue->m.canDisplayAmountStringPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->canDisplayAmountString); if (stat != ASN_OK) return stat; } /* encode canEnforceDurationLimit */ if (pvalue->m.canEnforceDurationLimitPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->canEnforceDurationLimit); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RTPSession_associatedSessionIds */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RTPSession_associatedSessionIds (OOCTXT* pctxt, H225RTPSession_associatedSessionIds* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeConsUnsigned (pctxt, pvalue->elem[xx1], 1U, 255U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RTPSession */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RTPSession (OOCTXT* pctxt, H225RTPSession* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.multicastPresent || pvalue->m.bandwidthPresent); encodeBit (pctxt, extbit); /* encode rtpAddress */ stat = asn1PE_H225TransportChannelInfo (pctxt, &pvalue->rtpAddress); if (stat != ASN_OK) return stat; /* encode rtcpAddress */ stat = asn1PE_H225TransportChannelInfo (pctxt, &pvalue->rtcpAddress); if (stat != ASN_OK) return stat; /* encode cname */ stat = encodeConstrainedStringEx (pctxt, pvalue->cname, 0, 8, 7, 7); if (stat != ASN_OK) return stat; /* encode ssrc */ stat = encodeConsUnsigned (pctxt, pvalue->ssrc, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; /* encode sessionId */ stat = encodeConsUnsigned (pctxt, pvalue->sessionId, 1U, 255U); if (stat != ASN_OK) return stat; /* encode associatedSessionIds */ stat = asn1PE_H225RTPSession_associatedSessionIds (pctxt, &pvalue->associatedSessionIds); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.multicastPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bandwidthPresent); /* encode extension elements */ if (pvalue->m.multicastPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.bandwidthPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225BandWidth (&lctxt, pvalue->bandwidth); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225Endpoint */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225Endpoint (OOCTXT* pctxt, H225_SeqOfH225Endpoint* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225Endpoint (pctxt, ((H225Endpoint*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AuthenticationMechanism */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225AuthenticationMechanism (OOCTXT* pctxt, H225_SeqOfH225AuthenticationMechanism* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H235AuthenticationMechanism (pctxt, ((H235AuthenticationMechanism*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* GatekeeperRequest_algorithmOIDs */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatekeeperRequest_algorithmOIDs (OOCTXT* pctxt, H225GatekeeperRequest_algorithmOIDs* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeObjectIdentifier (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225IntegrityMechanism */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225IntegrityMechanism (OOCTXT* pctxt, H225_SeqOfH225IntegrityMechanism* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225IntegrityMechanism (pctxt, ((H225IntegrityMechanism*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* GatekeeperRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatekeeperRequest (OOCTXT* pctxt, H225GatekeeperRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.alternateEndpointsPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.authenticationCapabilityPresent || pvalue->m.algorithmOIDsPresent || pvalue->m.integrityPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.supportsAltGKPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callServicesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointAliasPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode rasAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; /* encode endpointType */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->endpointType); if (stat != ASN_OK) return stat; /* encode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; } /* encode callServices */ if (pvalue->m.callServicesPresent) { stat = asn1PE_H225QseriesOptions (pctxt, &pvalue->callServices); if (stat != ASN_OK) return stat; } /* encode endpointAlias */ if (pvalue->m.endpointAliasPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->endpointAlias); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 9); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateEndpointsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.authenticationCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.algorithmOIDsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportsAltGKPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.alternateEndpointsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225Endpoint (&lctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.authenticationCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AuthenticationMechanism (&lctxt, &pvalue->authenticationCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.algorithmOIDsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225GatekeeperRequest_algorithmOIDs (&lctxt, &pvalue->algorithmOIDs); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225IntegrityMechanism (&lctxt, &pvalue->integrity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportsAltGKPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* GatekeeperConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatekeeperConfirm (OOCTXT* pctxt, H225GatekeeperConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.alternateGatekeeperPresent || pvalue->m.authenticationModePresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.algorithmOIDPresent || pvalue->m.integrityPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; } /* encode rasAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 8); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateGatekeeperPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.authenticationModePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.algorithmOIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.alternateGatekeeperPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AlternateGK (&lctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.authenticationModePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H235AuthenticationMechanism (&lctxt, &pvalue->authenticationMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.algorithmOIDPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeObjectIdentifier (&lctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225IntegrityMechanism (&lctxt, &pvalue->integrity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* GatekeeperRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatekeeperRejectReason (OOCTXT* pctxt, H225GatekeeperRejectReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* resourceUnavailable */ case 1: /* NULL */ break; /* terminalExcluded */ case 2: /* NULL */ break; /* invalidRevision */ case 3: /* NULL */ break; /* undefinedReason */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* securityDenial */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericDataReason */ case 6: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* neededFeatureNotSupported */ case 7: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 8: stat = asn1PE_H225SecurityErrors (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* GatekeeperReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H225GatekeeperReject (OOCTXT* pctxt, H225GatekeeperReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.altGKInfoPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; } /* encode rejectReason */ stat = asn1PE_H225GatekeeperRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 5); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.altGKInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AltGKInfo (&lctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AddressPattern */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225AddressPattern (OOCTXT* pctxt, H225_SeqOfH225AddressPattern* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225AddressPattern (pctxt, ((H225AddressPattern*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225H248PackagesDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225H248PackagesDescriptor (OOCTXT* pctxt, H225_SeqOfH225H248PackagesDescriptor* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H225H248PackagesDescriptor (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RegistrationRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RegistrationRequest (OOCTXT* pctxt, H225RegistrationRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.alternateEndpointsPresent || pvalue->m.timeToLivePresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.keepAlivePresent || pvalue->m.endpointIdentifierPresent || pvalue->m.willSupplyUUIEsPresent || pvalue->m.maintainConnectionPresent || pvalue->m.alternateTransportAddressesPresent || pvalue->m.additiveRegistrationPresent || pvalue->m.terminalAliasPatternPresent || pvalue->m.supportsAltGKPresent || pvalue->m.usageReportingCapabilityPresent || pvalue->m.multipleCallsPresent || pvalue->m.supportedH248PackagesPresent || pvalue->m.callCreditCapabilityPresent || pvalue->m.capacityReportingCapabilityPresent || pvalue->m.capacityPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent || pvalue->m.restartPresent || pvalue->m.supportsACFSequencesPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode discoveryComplete */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->discoveryComplete); if (stat != ASN_OK) return stat; /* encode callSignalAddress */ stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; /* encode rasAddress */ stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; /* encode terminalType */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->terminalType); if (stat != ASN_OK) return stat; /* encode terminalAlias */ if (pvalue->m.terminalAliasPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->terminalAlias); if (stat != ASN_OK) return stat; } /* encode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; } /* encode endpointVendor */ stat = asn1PE_H225VendorIdentifier (pctxt, &pvalue->endpointVendor); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 22); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateEndpointsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.timeToLivePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.keepAlivePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.willSupplyUUIEsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateTransportAddressesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.additiveRegistrationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalAliasPatternPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportsAltGKPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageReportingCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedH248PackagesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callCreditCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityReportingCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.restartPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportsACFSequencesPresent); /* encode extension elements */ if (pvalue->m.alternateEndpointsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225Endpoint (&lctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.timeToLivePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TimeToLive (&lctxt, pvalue->timeToLive); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.keepAlivePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->keepAlive); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.endpointIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225EndpointIdentifier (&lctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.willSupplyUUIEsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->willSupplyUUIEs); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alternateTransportAddressesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AlternateTransportAddresses (&lctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.additiveRegistrationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.terminalAliasPatternPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AddressPattern (&lctxt, &pvalue->terminalAliasPattern); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportsAltGKPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageReportingCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225RasUsageInfoTypes (&lctxt, &pvalue->usageReportingCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedH248PackagesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225H248PackagesDescriptor (&lctxt, &pvalue->supportedH248Packages); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callCreditCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCreditCapability (&lctxt, &pvalue->callCreditCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityReportingCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CapacityReportingCapability (&lctxt, &pvalue->capacityReportingCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.restartPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportsACFSequencesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* RegistrationConfirm_preGrantedARQ */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RegistrationConfirm_preGrantedARQ (OOCTXT* pctxt, H225RegistrationConfirm_preGrantedARQ* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.irrFrequencyInCallPresent || pvalue->m.totalBandwidthRestrictionPresent || pvalue->m.alternateTransportAddressesPresent || pvalue->m.useSpecifiedTransportPresent); encodeBit (pctxt, extbit); /* encode makeCall */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->makeCall); if (stat != ASN_OK) return stat; /* encode useGKCallSignalAddressToMakeCall */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->useGKCallSignalAddressToMakeCall); if (stat != ASN_OK) return stat; /* encode answerCall */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->answerCall); if (stat != ASN_OK) return stat; /* encode useGKCallSignalAddressToAnswer */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->useGKCallSignalAddressToAnswer); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 3); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.irrFrequencyInCallPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.totalBandwidthRestrictionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateTransportAddressesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.useSpecifiedTransportPresent); /* encode extension elements */ if (pvalue->m.irrFrequencyInCallPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->irrFrequencyInCall, 1U, 65535U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.totalBandwidthRestrictionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225BandWidth (&lctxt, pvalue->totalBandwidthRestriction); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alternateTransportAddressesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AlternateTransportAddresses (&lctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.useSpecifiedTransportPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225UseSpecifiedTransport (&lctxt, &pvalue->useSpecifiedTransport); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225RasUsageSpecification */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225RasUsageSpecification (OOCTXT* pctxt, H225_SeqOfH225RasUsageSpecification* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225RasUsageSpecification (pctxt, ((H225RasUsageSpecification*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* RegistrationConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RegistrationConfirm (OOCTXT* pctxt, H225RegistrationConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.alternateGatekeeperPresent || pvalue->m.timeToLivePresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.willRespondToIRRPresent || pvalue->m.preGrantedARQPresent || pvalue->m.maintainConnectionPresent || pvalue->m.serviceControlPresent || pvalue->m.supportsAdditiveRegistrationPresent || pvalue->m.terminalAliasPatternPresent || pvalue->m.supportedPrefixesPresent || pvalue->m.usageSpecPresent || pvalue->m.featureServerAliasPresent || pvalue->m.capacityReportingSpecPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode callSignalAddress */ stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; /* encode terminalAlias */ if (pvalue->m.terminalAliasPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->terminalAlias); if (stat != ASN_OK) return stat; } /* encode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; } /* encode endpointIdentifier */ stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 16); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateGatekeeperPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.timeToLivePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.willRespondToIRRPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.preGrantedARQPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maintainConnectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportsAdditiveRegistrationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalAliasPatternPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageSpecPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureServerAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityReportingSpecPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.alternateGatekeeperPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AlternateGK (&lctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.timeToLivePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TimeToLive (&lctxt, pvalue->timeToLive); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.willRespondToIRRPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->willRespondToIRR); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.preGrantedARQPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225RegistrationConfirm_preGrantedARQ (&lctxt, &pvalue->preGrantedARQ); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.maintainConnectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maintainConnection); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportsAdditiveRegistrationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.terminalAliasPatternPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AddressPattern (&lctxt, &pvalue->terminalAliasPattern); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageSpecPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225RasUsageSpecification (&lctxt, &pvalue->usageSpec); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureServerAliasPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AliasAddress (&lctxt, &pvalue->featureServerAlias); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityReportingSpecPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CapacityReportingSpecification (&lctxt, &pvalue->capacityReportingSpec); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* RegistrationRejectReason_invalidTerminalAliases */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RegistrationRejectReason_invalidTerminalAliases (OOCTXT* pctxt, H225RegistrationRejectReason_invalidTerminalAliases* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalAliasPatternPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); /* encode terminalAlias */ if (pvalue->m.terminalAliasPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->terminalAlias); if (stat != ASN_OK) return stat; } /* encode terminalAliasPattern */ if (pvalue->m.terminalAliasPatternPresent) { stat = asn1PE_H225_SeqOfH225AddressPattern (pctxt, &pvalue->terminalAliasPattern); if (stat != ASN_OK) return stat; } /* encode supportedPrefixes */ if (pvalue->m.supportedPrefixesPresent) { stat = asn1PE_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RegistrationRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RegistrationRejectReason (OOCTXT* pctxt, H225RegistrationRejectReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 8); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 7); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* discoveryRequired */ case 1: /* NULL */ break; /* invalidRevision */ case 2: /* NULL */ break; /* invalidCallSignalAddress */ case 3: /* NULL */ break; /* invalidRASAddress */ case 4: /* NULL */ break; /* duplicateAlias */ case 5: stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, pvalue->u.duplicateAlias); if (stat != ASN_OK) return stat; break; /* invalidTerminalType */ case 6: /* NULL */ break; /* undefinedReason */ case 7: /* NULL */ break; /* transportNotSupported */ case 8: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 9); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* transportQOSNotSupported */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* resourceUnavailable */ case 10: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* invalidAlias */ case 11: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityDenial */ case 12: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* fullRegistrationRequired */ case 13: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* additiveRegistrationNotSupported */ case 14: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* invalidTerminalAliases */ case 15: stat = asn1PE_H225RegistrationRejectReason_invalidTerminalAliases (&lctxt, pvalue->u.invalidTerminalAliases); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericDataReason */ case 16: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* neededFeatureNotSupported */ case 17: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 18: stat = asn1PE_H225SecurityErrors (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* RegistrationReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RegistrationReject (OOCTXT* pctxt, H225RegistrationReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.altGKInfoPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode rejectReason */ stat = asn1PE_H225RegistrationRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; /* encode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { stat = asn1PE_H225GatekeeperIdentifier (pctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 5); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.altGKInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AltGKInfo (&lctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UnregRequestReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UnregRequestReason (OOCTXT* pctxt, H225UnregRequestReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* reregistrationRequired */ case 1: /* NULL */ break; /* ttlExpired */ case 2: /* NULL */ break; /* securityDenial */ case 3: /* NULL */ break; /* undefinedReason */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* maintenance */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 6: stat = asn1PE_H225SecurityErrors2 (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* UnregistrationRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UnregistrationRequest (OOCTXT* pctxt, H225UnregistrationRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.alternateEndpointsPresent || pvalue->m.gatekeeperIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.reasonPresent || pvalue->m.endpointAliasPatternPresent || pvalue->m.supportedPrefixesPresent || pvalue->m.alternateGatekeeperPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointIdentifierPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode callSignalAddress */ stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; /* encode endpointAlias */ if (pvalue->m.endpointAliasPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->endpointAlias); if (stat != ASN_OK) return stat; } /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode endpointIdentifier */ if (pvalue->m.endpointIdentifierPresent) { stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 9); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateEndpointsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.reasonPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointAliasPatternPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedPrefixesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateGatekeeperPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.alternateEndpointsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225Endpoint (&lctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.gatekeeperIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225GatekeeperIdentifier (&lctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.reasonPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225UnregRequestReason (&lctxt, &pvalue->reason); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.endpointAliasPatternPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AddressPattern (&lctxt, &pvalue->endpointAliasPattern); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedPrefixesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedPrefix (&lctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alternateGatekeeperPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AlternateGK (&lctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UnregistrationConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UnregistrationConfirm (OOCTXT* pctxt, H225UnregistrationConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 3); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UnregRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UnregRejectReason (OOCTXT* pctxt, H225UnregRejectReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* notCurrentlyRegistered */ case 1: /* NULL */ break; /* callInProgress */ case 2: /* NULL */ break; /* undefinedReason */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* permissionDenied */ case 4: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityDenial */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 6: stat = asn1PE_H225SecurityErrors2 (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* UnregistrationReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UnregistrationReject (OOCTXT* pctxt, H225UnregistrationReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.altGKInfoPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode rejectReason */ stat = asn1PE_H225UnregRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 4); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.altGKInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AltGKInfo (&lctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* CallModel */ /* */ /**************************************************************/ EXTERN int asn1PE_H225CallModel (OOCTXT* pctxt, H225CallModel* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* direct */ case 1: /* NULL */ break; /* gatekeeperRouted */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TransportQOS */ /* */ /**************************************************************/ EXTERN int asn1PE_H225TransportQOS (OOCTXT* pctxt, H225TransportQOS* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* endpointControlled */ case 1: /* NULL */ break; /* gatekeeperControlled */ case 2: /* NULL */ break; /* noControl */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* AdmissionRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AdmissionRequest (OOCTXT* pctxt, H225AdmissionRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.canMapAliasPresent || pvalue->m.callIdentifierPresent || pvalue->m.srcAlternativesPresent || pvalue->m.destAlternativesPresent || pvalue->m.gatekeeperIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.transportQOSPresent || pvalue->m.willSupplyUUIEsPresent || pvalue->m.callLinkagePresent || pvalue->m.gatewayDataRatePresent || pvalue->m.capacityPresent || pvalue->m.circuitInfoPresent || pvalue->m.desiredProtocolsPresent || pvalue->m.desiredTunnelledProtocolPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent || pvalue->m.canMapSrcAliasPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callModelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destCallSignalAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destExtraCallInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.srcCallSignalAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callServicesPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode callType */ stat = asn1PE_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; /* encode callModel */ if (pvalue->m.callModelPresent) { stat = asn1PE_H225CallModel (pctxt, &pvalue->callModel); if (stat != ASN_OK) return stat; } /* encode endpointIdentifier */ stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; /* encode destinationInfo */ if (pvalue->m.destinationInfoPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; } /* encode destCallSignalAddress */ if (pvalue->m.destCallSignalAddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->destCallSignalAddress); if (stat != ASN_OK) return stat; } /* encode destExtraCallInfo */ if (pvalue->m.destExtraCallInfoPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; } /* encode srcInfo */ stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->srcInfo); if (stat != ASN_OK) return stat; /* encode srcCallSignalAddress */ if (pvalue->m.srcCallSignalAddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->srcCallSignalAddress); if (stat != ASN_OK) return stat; } /* encode bandWidth */ stat = asn1PE_H225BandWidth (pctxt, pvalue->bandWidth); if (stat != ASN_OK) return stat; /* encode callReferenceValue */ stat = asn1PE_H225CallReferenceValue (pctxt, pvalue->callReferenceValue); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode callServices */ if (pvalue->m.callServicesPresent) { stat = asn1PE_H225QseriesOptions (pctxt, &pvalue->callServices); if (stat != ASN_OK) return stat; } /* encode conferenceID */ stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; /* encode activeMC */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->activeMC); if (stat != ASN_OK) return stat; /* encode answerCall */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->answerCall); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 18); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.canMapAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.srcAlternativesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destAlternativesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.transportQOSPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.willSupplyUUIEsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callLinkagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatewayDataRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.desiredProtocolsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.desiredTunnelledProtocolPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.canMapSrcAliasPresent); /* encode extension elements */ if (pvalue->m.canMapAliasPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->canMapAlias); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.srcAlternativesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225Endpoint (&lctxt, &pvalue->srcAlternatives); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destAlternativesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225Endpoint (&lctxt, &pvalue->destAlternatives); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.gatekeeperIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225GatekeeperIdentifier (&lctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.transportQOSPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TransportQOS (&lctxt, &pvalue->transportQOS); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.willSupplyUUIEsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->willSupplyUUIEs); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callLinkagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallLinkage (&lctxt, &pvalue->callLinkage); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.gatewayDataRatePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225DataRate (&lctxt, &pvalue->gatewayDataRate); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.desiredProtocolsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedProtocols (&lctxt, &pvalue->desiredProtocols); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.desiredTunnelledProtocolPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TunnelledProtocol (&lctxt, &pvalue->desiredTunnelledProtocol); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.canMapSrcAliasPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->canMapSrcAlias); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UUIEsRequested */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UUIEsRequested (OOCTXT* pctxt, H225UUIEsRequested* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.statusPresent || pvalue->m.statusInquiryPresent || pvalue->m.setupAcknowledgePresent || pvalue->m.notifyPresent); encodeBit (pctxt, extbit); /* encode setup */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->setup); if (stat != ASN_OK) return stat; /* encode callProceeding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->callProceeding); if (stat != ASN_OK) return stat; /* encode connect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->connect); if (stat != ASN_OK) return stat; /* encode alerting */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alerting); if (stat != ASN_OK) return stat; /* encode information */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->information); if (stat != ASN_OK) return stat; /* encode releaseComplete */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->releaseComplete); if (stat != ASN_OK) return stat; /* encode facility */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->facility); if (stat != ASN_OK) return stat; /* encode progress */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->progress); if (stat != ASN_OK) return stat; /* encode empty */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->empty); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 3); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.statusPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.statusInquiryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.setupAcknowledgePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.notifyPresent); /* encode extension elements */ if (pvalue->m.statusPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->status); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.statusInquiryPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->statusInquiry); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.setupAcknowledgePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->setupAcknowledge); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.notifyPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->notify); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* AdmissionConfirm_language */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AdmissionConfirm_language (OOCTXT* pctxt, H225AdmissionConfirm_language* pvalue) { static Asn1SizeCnst element_lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { addSizeConstraint (pctxt, &element_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->elem[xx1], 0, 8, 7, 7); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* AdmissionConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AdmissionConfirm (OOCTXT* pctxt, H225AdmissionConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.destinationInfoPresent || pvalue->m.destExtraCallInfoPresent || pvalue->m.destinationTypePresent || pvalue->m.remoteExtensionAddressPresent || pvalue->m.alternateEndpointsPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.transportQOSPresent || pvalue->m.willRespondToIRRPresent || pvalue->m.uuiesRequestedPresent || pvalue->m.languagePresent || pvalue->m.alternateTransportAddressesPresent || pvalue->m.useSpecifiedTransportPresent || pvalue->m.circuitInfoPresent || pvalue->m.usageSpecPresent || pvalue->m.supportedProtocolsPresent || pvalue->m.serviceControlPresent || pvalue->m.multipleCallsPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent || pvalue->m.modifiedSrcInfoPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.irrFrequencyPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode bandWidth */ stat = asn1PE_H225BandWidth (pctxt, pvalue->bandWidth); if (stat != ASN_OK) return stat; /* encode callModel */ stat = asn1PE_H225CallModel (pctxt, &pvalue->callModel); if (stat != ASN_OK) return stat; /* encode destCallSignalAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->destCallSignalAddress); if (stat != ASN_OK) return stat; /* encode irrFrequency */ if (pvalue->m.irrFrequencyPresent) { stat = encodeConsUnsigned (pctxt, pvalue->irrFrequency, 1U, 65535U); if (stat != ASN_OK) return stat; } /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 21); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destExtraCallInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationTypePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.remoteExtensionAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateEndpointsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.transportQOSPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.willRespondToIRRPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.uuiesRequestedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.languagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateTransportAddressesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.useSpecifiedTransportPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageSpecPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedProtocolsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.modifiedSrcInfoPresent); /* encode extension elements */ if (pvalue->m.destinationInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destExtraCallInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destinationTypePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225EndpointType (&lctxt, &pvalue->destinationType); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.remoteExtensionAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alternateEndpointsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225Endpoint (&lctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.transportQOSPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TransportQOS (&lctxt, &pvalue->transportQOS); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.willRespondToIRRPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->willRespondToIRR); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.uuiesRequestedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225UUIEsRequested (&lctxt, &pvalue->uuiesRequested); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.languagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AdmissionConfirm_language (&lctxt, &pvalue->language); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alternateTransportAddressesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AlternateTransportAddresses (&lctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.useSpecifiedTransportPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225UseSpecifiedTransport (&lctxt, &pvalue->useSpecifiedTransport); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageSpecPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225RasUsageSpecification (&lctxt, &pvalue->usageSpec); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedProtocolsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedProtocols (&lctxt, &pvalue->supportedProtocols); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.modifiedSrcInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->modifiedSrcInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225PartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225PartyNumber (OOCTXT* pctxt, H225_SeqOfH225PartyNumber* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225PartyNumber (pctxt, ((H225PartyNumber*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* AdmissionRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AdmissionRejectReason (OOCTXT* pctxt, H225AdmissionRejectReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 8); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 7); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* calledPartyNotRegistered */ case 1: /* NULL */ break; /* invalidPermission */ case 2: /* NULL */ break; /* requestDenied */ case 3: /* NULL */ break; /* undefinedReason */ case 4: /* NULL */ break; /* callerNotRegistered */ case 5: /* NULL */ break; /* routeCallToGatekeeper */ case 6: /* NULL */ break; /* invalidEndpointIdentifier */ case 7: /* NULL */ break; /* resourceUnavailable */ case 8: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 9); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* securityDenial */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* qosControlNotSupported */ case 10: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* incompleteAddress */ case 11: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* aliasesInconsistent */ case 12: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* routeCallToSCN */ case 13: stat = asn1PE_H225_SeqOfH225PartyNumber (&lctxt, pvalue->u.routeCallToSCN); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* exceedsCallCapacity */ case 14: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* collectDestination */ case 15: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* collectPIN */ case 16: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericDataReason */ case 17: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* neededFeatureNotSupported */ case 18: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityErrors */ case 19: stat = asn1PE_H225SecurityErrors2 (&lctxt, pvalue->u.securityErrors); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityDHmismatch */ case 20: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* noRouteToDestination */ case 21: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* unallocatedNumber */ case 22: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* AdmissionReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H225AdmissionReject (OOCTXT* pctxt, H225AdmissionReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.altGKInfoPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.callSignalAddressPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.serviceControlPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode rejectReason */ stat = asn1PE_H225AdmissionRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 7); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callSignalAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.altGKInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AltGKInfo (&lctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callSignalAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225TransportAddress (&lctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225BandwidthDetails */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225BandwidthDetails (OOCTXT* pctxt, H225_SeqOfH225BandwidthDetails* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225BandwidthDetails (pctxt, ((H225BandwidthDetails*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* BandwidthRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225BandwidthRequest (OOCTXT* pctxt, H225BandwidthRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.gatekeeperIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.answeredCallPresent || pvalue->m.callLinkagePresent || pvalue->m.capacityPresent || pvalue->m.usageInformationPresent || pvalue->m.bandwidthDetailsPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callTypePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode endpointIdentifier */ stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; /* encode conferenceID */ stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; /* encode callReferenceValue */ stat = asn1PE_H225CallReferenceValue (pctxt, pvalue->callReferenceValue); if (stat != ASN_OK) return stat; /* encode callType */ if (pvalue->m.callTypePresent) { stat = asn1PE_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; } /* encode bandWidth */ stat = asn1PE_H225BandWidth (pctxt, pvalue->bandWidth); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 10); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.answeredCallPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callLinkagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageInformationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bandwidthDetailsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.gatekeeperIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225GatekeeperIdentifier (&lctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.answeredCallPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->answeredCall); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callLinkagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallLinkage (&lctxt, &pvalue->callLinkage); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageInformationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225RasUsageInformation (&lctxt, &pvalue->usageInformation); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.bandwidthDetailsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225BandwidthDetails (&lctxt, &pvalue->bandwidthDetails); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* BandwidthConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225BandwidthConfirm (OOCTXT* pctxt, H225BandwidthConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.capacityPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode bandWidth */ stat = asn1PE_H225BandWidth (pctxt, pvalue->bandWidth); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 4); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* BandRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225BandRejectReason (OOCTXT* pctxt, H225BandRejectReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* notBound */ case 1: /* NULL */ break; /* invalidConferenceID */ case 2: /* NULL */ break; /* invalidPermission */ case 3: /* NULL */ break; /* insufficientResources */ case 4: /* NULL */ break; /* invalidRevision */ case 5: /* NULL */ break; /* undefinedReason */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* securityDenial */ case 7: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 8: stat = asn1PE_H225SecurityErrors2 (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* BandwidthReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H225BandwidthReject (OOCTXT* pctxt, H225BandwidthReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.altGKInfoPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode rejectReason */ stat = asn1PE_H225BandRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; /* encode allowedBandWidth */ stat = asn1PE_H225BandWidth (pctxt, pvalue->allowedBandWidth); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 4); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.altGKInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AltGKInfo (&lctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* DisengageReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225DisengageReason (OOCTXT* pctxt, H225DisengageReason* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* forcedDrop */ case 1: /* NULL */ break; /* normalDrop */ case 2: /* NULL */ break; /* undefinedReason */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* DisengageRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225DisengageRequest (OOCTXT* pctxt, H225DisengageRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.gatekeeperIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.answeredCallPresent || pvalue->m.callLinkagePresent || pvalue->m.capacityPresent || pvalue->m.circuitInfoPresent || pvalue->m.usageInformationPresent || pvalue->m.terminationCausePresent || pvalue->m.serviceControlPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode endpointIdentifier */ stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; /* encode conferenceID */ stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; /* encode callReferenceValue */ stat = asn1PE_H225CallReferenceValue (pctxt, pvalue->callReferenceValue); if (stat != ASN_OK) return stat; /* encode disengageReason */ stat = asn1PE_H225DisengageReason (pctxt, &pvalue->disengageReason); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 12); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.answeredCallPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callLinkagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageInformationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminationCausePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.gatekeeperIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225GatekeeperIdentifier (&lctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.answeredCallPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->answeredCall); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callLinkagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallLinkage (&lctxt, &pvalue->callLinkage); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageInformationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225RasUsageInformation (&lctxt, &pvalue->usageInformation); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.terminationCausePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallTerminationCause (&lctxt, &pvalue->terminationCause); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* DisengageConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225DisengageConfirm (OOCTXT* pctxt, H225DisengageConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.capacityPresent || pvalue->m.circuitInfoPresent || pvalue->m.usageInformationPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 6); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageInformationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageInformationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225RasUsageInformation (&lctxt, &pvalue->usageInformation); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* DisengageRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225DisengageRejectReason (OOCTXT* pctxt, H225DisengageRejectReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* notRegistered */ case 1: /* NULL */ break; /* requestToDropOther */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* securityDenial */ case 3: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 4: stat = asn1PE_H225SecurityErrors2 (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* DisengageReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H225DisengageReject (OOCTXT* pctxt, H225DisengageReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.altGKInfoPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode rejectReason */ stat = asn1PE_H225DisengageRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 4); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.altGKInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AltGKInfo (&lctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* LocationRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225LocationRequest (OOCTXT* pctxt, H225LocationRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.sourceInfoPresent || pvalue->m.canMapAliasPresent || pvalue->m.gatekeeperIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.desiredProtocolsPresent || pvalue->m.desiredTunnelledProtocolPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent || pvalue->m.hopCountPresent || pvalue->m.circuitInfoPresent || pvalue->m.callIdentifierPresent || pvalue->m.bandWidthPresent || pvalue->m.sourceEndpointInfoPresent || pvalue->m.canMapSrcAliasPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode endpointIdentifier */ if (pvalue->m.endpointIdentifierPresent) { stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; } /* encode destinationInfo */ stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode replyAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->replyAddress); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 15); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.sourceInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.canMapAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.gatekeeperIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.desiredProtocolsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.desiredTunnelledProtocolPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.hopCountPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bandWidthPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sourceEndpointInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.canMapSrcAliasPresent); /* encode extension elements */ if (pvalue->m.sourceInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->sourceInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.canMapAliasPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->canMapAlias); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.gatekeeperIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225GatekeeperIdentifier (&lctxt, pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.desiredProtocolsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedProtocols (&lctxt, &pvalue->desiredProtocols); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.desiredTunnelledProtocolPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225TunnelledProtocol (&lctxt, &pvalue->desiredTunnelledProtocol); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.hopCountPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->hopCount, 1U, 255U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.bandWidthPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225BandWidth (&lctxt, pvalue->bandWidth); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.sourceEndpointInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->sourceEndpointInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.canMapSrcAliasPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->canMapSrcAlias); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* LocationConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225LocationConfirm (OOCTXT* pctxt, H225LocationConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.destinationInfoPresent || pvalue->m.destExtraCallInfoPresent || pvalue->m.destinationTypePresent || pvalue->m.remoteExtensionAddressPresent || pvalue->m.alternateEndpointsPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.alternateTransportAddressesPresent || pvalue->m.supportedProtocolsPresent || pvalue->m.multipleCallsPresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent || pvalue->m.circuitInfoPresent || pvalue->m.serviceControlPresent || pvalue->m.modifiedSrcInfoPresent || pvalue->m.bandWidthPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode callSignalAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; /* encode rasAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 16); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destExtraCallInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationTypePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.remoteExtensionAddressPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateEndpointsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.alternateTransportAddressesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supportedProtocolsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipleCallsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.modifiedSrcInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bandWidthPresent); /* encode extension elements */ if (pvalue->m.destinationInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destExtraCallInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destinationTypePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225EndpointType (&lctxt, &pvalue->destinationType); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.remoteExtensionAddressPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alternateEndpointsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225Endpoint (&lctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.alternateTransportAddressesPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AlternateTransportAddresses (&lctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.supportedProtocolsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225SupportedProtocols (&lctxt, &pvalue->supportedProtocols); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipleCallsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipleCalls); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.modifiedSrcInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225AliasAddress (&lctxt, &pvalue->modifiedSrcInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.bandWidthPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225BandWidth (&lctxt, pvalue->bandWidth); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* LocationRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225LocationRejectReason (OOCTXT* pctxt, H225LocationRejectReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* notRegistered */ case 1: /* NULL */ break; /* invalidPermission */ case 2: /* NULL */ break; /* requestDenied */ case 3: /* NULL */ break; /* undefinedReason */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* securityDenial */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* aliasesInconsistent */ case 6: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* routeCalltoSCN */ case 7: stat = asn1PE_H225_SeqOfH225PartyNumber (&lctxt, pvalue->u.routeCalltoSCN); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* resourceUnavailable */ case 8: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericDataReason */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* neededFeatureNotSupported */ case 10: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* hopCountExceeded */ case 11: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* incompleteAddress */ case 12: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityError */ case 13: stat = asn1PE_H225SecurityErrors2 (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* securityDHmismatch */ case 14: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* noRouteToDestination */ case 15: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* unallocatedNumber */ case 16: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* LocationReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H225LocationReject (OOCTXT* pctxt, H225LocationReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.altGKInfoPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent || pvalue->m.serviceControlPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode rejectReason */ stat = asn1PE_H225LocationRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 6); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.serviceControlPresent); /* encode extension elements */ if (pvalue->m.altGKInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225AltGKInfo (&lctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.serviceControlPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ServiceControlSession (&lctxt, &pvalue->serviceControl); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* InfoRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequest (OOCTXT* pctxt, H225InfoRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.uuiesRequestedPresent || pvalue->m.callLinkagePresent || pvalue->m.usageInfoRequestedPresent || pvalue->m.segmentedResponseSupportedPresent || pvalue->m.nextSegmentRequestedPresent || pvalue->m.capacityInfoRequestedPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.replyAddressPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode callReferenceValue */ stat = asn1PE_H225CallReferenceValue (pctxt, pvalue->callReferenceValue); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode replyAddress */ if (pvalue->m.replyAddressPresent) { stat = asn1PE_H225TransportAddress (pctxt, &pvalue->replyAddress); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 10); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.uuiesRequestedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callLinkagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageInfoRequestedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.segmentedResponseSupportedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nextSegmentRequestedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityInfoRequestedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.uuiesRequestedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225UUIEsRequested (&lctxt, &pvalue->uuiesRequested); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callLinkagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallLinkage (&lctxt, &pvalue->callLinkage); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageInfoRequestedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225RasUsageInfoTypes (&lctxt, &pvalue->usageInfoRequested); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.segmentedResponseSupportedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.nextSegmentRequestedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->nextSegmentRequested, 0U, 65535U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityInfoRequestedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225RTPSession */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225RTPSession (OOCTXT* pctxt, H225_SeqOfH225RTPSession* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225RTPSession (pctxt, ((H225RTPSession*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TransportChannelInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225TransportChannelInfo (OOCTXT* pctxt, H225_SeqOfH225TransportChannelInfo* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225TransportChannelInfo (pctxt, ((H225TransportChannelInfo*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ConferenceIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225ConferenceIdentifier (OOCTXT* pctxt, H225_SeqOfH225ConferenceIdentifier* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponse_perCallInfo_element_pdu_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue) { int stat = ASN_OK; /* encode h323pdu */ stat = asn1PE_H225H323_UU_PDU (pctxt, &pvalue->h323pdu); if (stat != ASN_OK) return stat; /* encode sent */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->sent); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_el */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225InfoRequestResponse_perCallInfo_element_pdu_element (pctxt, ((H225InfoRequestResponse_perCallInfo_element_pdu_element*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponse_perCallInfo_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.callIdentifierPresent || pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.substituteConfIDsPresent || pvalue->m.pduPresent || pvalue->m.callLinkagePresent || pvalue->m.usageInformationPresent || pvalue->m.circuitInfoPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.originatorPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.audioPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.dataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode callReferenceValue */ stat = asn1PE_H225CallReferenceValue (pctxt, pvalue->callReferenceValue); if (stat != ASN_OK) return stat; /* encode conferenceID */ stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; /* encode originator */ if (pvalue->m.originatorPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->originator); if (stat != ASN_OK) return stat; } /* encode audio */ if (pvalue->m.audioPresent) { stat = asn1PE_H225_SeqOfH225RTPSession (pctxt, &pvalue->audio); if (stat != ASN_OK) return stat; } /* encode video */ if (pvalue->m.videoPresent) { stat = asn1PE_H225_SeqOfH225RTPSession (pctxt, &pvalue->video); if (stat != ASN_OK) return stat; } /* encode data */ if (pvalue->m.dataPresent) { stat = asn1PE_H225_SeqOfH225TransportChannelInfo (pctxt, &pvalue->data); if (stat != ASN_OK) return stat; } /* encode h245 */ stat = asn1PE_H225TransportChannelInfo (pctxt, &pvalue->h245); if (stat != ASN_OK) return stat; /* encode callSignaling */ stat = asn1PE_H225TransportChannelInfo (pctxt, &pvalue->callSignaling); if (stat != ASN_OK) return stat; /* encode callType */ stat = asn1PE_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; /* encode bandWidth */ stat = asn1PE_H225BandWidth (pctxt, pvalue->bandWidth); if (stat != ASN_OK) return stat; /* encode callModel */ stat = asn1PE_H225CallModel (pctxt, &pvalue->callModel); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 7); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.callIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.substituteConfIDsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.pduPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callLinkagePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.usageInformationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.circuitInfoPresent); /* encode extension elements */ if (pvalue->m.callIdentifierPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallIdentifier (&lctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.substituteConfIDsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ConferenceIdentifier (&lctxt, &pvalue->substituteConfIDs); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.pduPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element (&lctxt, &pvalue->pdu); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.callLinkagePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallLinkage (&lctxt, &pvalue->callLinkage); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.usageInformationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225RasUsageInformation (&lctxt, &pvalue->usageInformation); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.circuitInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CircuitInfo (&lctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225InfoRequestResponse_perCallInfo_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225InfoRequestResponse_perCallInfo_element (pctxt, ((H225InfoRequestResponse_perCallInfo_element*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponseStatus */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequestResponseStatus (OOCTXT* pctxt, H225InfoRequestResponseStatus* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* complete */ case 1: /* NULL */ break; /* incomplete */ case 2: /* NULL */ break; /* segment */ case 3: stat = encodeConsUnsigned (pctxt, pvalue->u.segment, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* invalidCall */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequestResponse (OOCTXT* pctxt, H225InfoRequestResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.needResponsePresent || pvalue->m.capacityPresent || pvalue->m.irrStatusPresent || pvalue->m.unsolicitedPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointAliasPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.perCallInfoPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode endpointType */ stat = asn1PE_H225EndpointType (pctxt, &pvalue->endpointType); if (stat != ASN_OK) return stat; /* encode endpointIdentifier */ stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; /* encode rasAddress */ stat = asn1PE_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; /* encode callSignalAddress */ stat = asn1PE_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; /* encode endpointAlias */ if (pvalue->m.endpointAliasPresent) { stat = asn1PE_H225_SeqOfH225AliasAddress (pctxt, &pvalue->endpointAlias); if (stat != ASN_OK) return stat; } /* encode perCallInfo */ if (pvalue->m.perCallInfoPresent) { stat = asn1PE_H225_SeqOfH225InfoRequestResponse_perCallInfo_element (pctxt, &pvalue->perCallInfo); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 7); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.needResponsePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.irrStatusPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.unsolicitedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.needResponsePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->needResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.irrStatusPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225InfoRequestResponseStatus (&lctxt, &pvalue->irrStatus); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.unsolicitedPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->unsolicited); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* NonStandardMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H225NonStandardMessage (OOCTXT* pctxt, H225NonStandardMessage* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.featureSetPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode nonStandardData */ stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 4); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.featureSetPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225FeatureSet (&lctxt, &pvalue->featureSet); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UnknownMessageResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H225UnknownMessageResponse (OOCTXT* pctxt, H225UnknownMessageResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.tokensPresent || pvalue->m.cryptoTokensPresent || pvalue->m.integrityCheckValuePresent || pvalue->m.messageNotUnderstoodPresent); encodeBit (pctxt, extbit); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 3); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.messageNotUnderstoodPresent); /* encode extension elements */ if (pvalue->m.tokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225ClearToken (&lctxt, &pvalue->tokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.cryptoTokensPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225CryptoH323Token (&lctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.integrityCheckValuePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225ICV (&lctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.messageNotUnderstoodPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOctetString (&lctxt, pvalue->messageNotUnderstood.numocts, pvalue->messageNotUnderstood.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* RequestInProgress */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RequestInProgress (OOCTXT* pctxt, H225RequestInProgress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { stat = asn1PE_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; } /* encode delay */ stat = encodeConsUnsigned (pctxt, pvalue->delay, 1U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ResourcesAvailableIndicate */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ResourcesAvailableIndicate (OOCTXT* pctxt, H225ResourcesAvailableIndicate* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.capacityPresent || pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode endpointIdentifier */ stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; /* encode protocols */ stat = asn1PE_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->protocols); if (stat != ASN_OK) return stat; /* encode almostOutOfResources */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->almostOutOfResources); if (stat != ASN_OK) return stat; /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { stat = asn1PE_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.capacityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.capacityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225CallCapacity (&lctxt, &pvalue->capacity); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* ResourcesAvailableConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ResourcesAvailableConfirm (OOCTXT* pctxt, H225ResourcesAvailableConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.genericDataPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = asn1PE_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { stat = asn1PE_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode extension elements */ if (pvalue->m.genericDataPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H225_SeqOfH225GenericData (&lctxt, &pvalue->genericData); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* InfoRequestAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequestAck (OOCTXT* pctxt, H225InfoRequestAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { stat = asn1PE_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* InfoRequestNakReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequestNakReason (OOCTXT* pctxt, H225InfoRequestNakReason* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* notRegistered */ case 1: /* NULL */ break; /* securityDenial */ case 2: /* NULL */ break; /* undefinedReason */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* securityError */ case 4: stat = asn1PE_H225SecurityErrors2 (&lctxt, pvalue->u.securityError); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* InfoRequestNak */ /* */ /**************************************************************/ EXTERN int asn1PE_H225InfoRequestNak (OOCTXT* pctxt, H225InfoRequestNak* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.altGKInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode nakReason */ stat = asn1PE_H225InfoRequestNakReason (pctxt, &pvalue->nakReason); if (stat != ASN_OK) return stat; /* encode altGKInfo */ if (pvalue->m.altGKInfoPresent) { stat = asn1PE_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { stat = asn1PE_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ServiceControlIndication_callSpecific */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ServiceControlIndication_callSpecific (OOCTXT* pctxt, H225ServiceControlIndication_callSpecific* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode callIdentifier */ stat = asn1PE_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; /* encode conferenceID */ stat = asn1PE_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; /* encode answeredCall */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->answeredCall); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ServiceControlIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ServiceControlIndication (OOCTXT* pctxt, H225ServiceControlIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.endpointIdentifierPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.callSpecificPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode serviceControl */ stat = asn1PE_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; /* encode endpointIdentifier */ if (pvalue->m.endpointIdentifierPresent) { stat = asn1PE_H225EndpointIdentifier (pctxt, pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; } /* encode callSpecific */ if (pvalue->m.callSpecificPresent) { stat = asn1PE_H225ServiceControlIndication_callSpecific (pctxt, &pvalue->callSpecific); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { stat = asn1PE_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; } /* encode featureSet */ if (pvalue->m.featureSetPresent) { stat = asn1PE_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; } /* encode genericData */ if (pvalue->m.genericDataPresent) { stat = asn1PE_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ServiceControlResponse_result */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ServiceControlResponse_result (OOCTXT* pctxt, H225ServiceControlResponse_result* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* started */ case 1: /* NULL */ break; /* failed */ case 2: /* NULL */ break; /* stopped */ case 3: /* NULL */ break; /* notAvailable */ case 4: /* NULL */ break; /* neededFeatureNotSupported */ case 5: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ServiceControlResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H225ServiceControlResponse (OOCTXT* pctxt, H225ServiceControlResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.resultPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cryptoTokensPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCheckValuePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.featureSetPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericDataPresent); /* encode requestSeqNum */ stat = asn1PE_H225RequestSeqNum (pctxt, pvalue->requestSeqNum); if (stat != ASN_OK) return stat; /* encode result */ if (pvalue->m.resultPresent) { stat = asn1PE_H225ServiceControlResponse_result (pctxt, &pvalue->result); if (stat != ASN_OK) return stat; } /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode tokens */ if (pvalue->m.tokensPresent) { stat = asn1PE_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; } /* encode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { stat = asn1PE_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; } /* encode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { stat = asn1PE_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; } /* encode featureSet */ if (pvalue->m.featureSetPresent) { stat = asn1PE_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; } /* encode genericData */ if (pvalue->m.genericDataPresent) { stat = asn1PE_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AdmissionConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H225_SeqOfH225AdmissionConfirm (OOCTXT* pctxt, H225_SeqOfH225AdmissionConfirm* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H225AdmissionConfirm (pctxt, ((H225AdmissionConfirm*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* RasMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H225RasMessage (OOCTXT* pctxt, H225RasMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 25); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 24); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* gatekeeperRequest */ case 1: stat = asn1PE_H225GatekeeperRequest (pctxt, pvalue->u.gatekeeperRequest); if (stat != ASN_OK) return stat; break; /* gatekeeperConfirm */ case 2: stat = asn1PE_H225GatekeeperConfirm (pctxt, pvalue->u.gatekeeperConfirm); if (stat != ASN_OK) return stat; break; /* gatekeeperReject */ case 3: stat = asn1PE_H225GatekeeperReject (pctxt, pvalue->u.gatekeeperReject); if (stat != ASN_OK) return stat; break; /* registrationRequest */ case 4: stat = asn1PE_H225RegistrationRequest (pctxt, pvalue->u.registrationRequest); if (stat != ASN_OK) return stat; break; /* registrationConfirm */ case 5: stat = asn1PE_H225RegistrationConfirm (pctxt, pvalue->u.registrationConfirm); if (stat != ASN_OK) return stat; break; /* registrationReject */ case 6: stat = asn1PE_H225RegistrationReject (pctxt, pvalue->u.registrationReject); if (stat != ASN_OK) return stat; break; /* unregistrationRequest */ case 7: stat = asn1PE_H225UnregistrationRequest (pctxt, pvalue->u.unregistrationRequest); if (stat != ASN_OK) return stat; break; /* unregistrationConfirm */ case 8: stat = asn1PE_H225UnregistrationConfirm (pctxt, pvalue->u.unregistrationConfirm); if (stat != ASN_OK) return stat; break; /* unregistrationReject */ case 9: stat = asn1PE_H225UnregistrationReject (pctxt, pvalue->u.unregistrationReject); if (stat != ASN_OK) return stat; break; /* admissionRequest */ case 10: stat = asn1PE_H225AdmissionRequest (pctxt, pvalue->u.admissionRequest); if (stat != ASN_OK) return stat; break; /* admissionConfirm */ case 11: stat = asn1PE_H225AdmissionConfirm (pctxt, pvalue->u.admissionConfirm); if (stat != ASN_OK) return stat; break; /* admissionReject */ case 12: stat = asn1PE_H225AdmissionReject (pctxt, pvalue->u.admissionReject); if (stat != ASN_OK) return stat; break; /* bandwidthRequest */ case 13: stat = asn1PE_H225BandwidthRequest (pctxt, pvalue->u.bandwidthRequest); if (stat != ASN_OK) return stat; break; /* bandwidthConfirm */ case 14: stat = asn1PE_H225BandwidthConfirm (pctxt, pvalue->u.bandwidthConfirm); if (stat != ASN_OK) return stat; break; /* bandwidthReject */ case 15: stat = asn1PE_H225BandwidthReject (pctxt, pvalue->u.bandwidthReject); if (stat != ASN_OK) return stat; break; /* disengageRequest */ case 16: stat = asn1PE_H225DisengageRequest (pctxt, pvalue->u.disengageRequest); if (stat != ASN_OK) return stat; break; /* disengageConfirm */ case 17: stat = asn1PE_H225DisengageConfirm (pctxt, pvalue->u.disengageConfirm); if (stat != ASN_OK) return stat; break; /* disengageReject */ case 18: stat = asn1PE_H225DisengageReject (pctxt, pvalue->u.disengageReject); if (stat != ASN_OK) return stat; break; /* locationRequest */ case 19: stat = asn1PE_H225LocationRequest (pctxt, pvalue->u.locationRequest); if (stat != ASN_OK) return stat; break; /* locationConfirm */ case 20: stat = asn1PE_H225LocationConfirm (pctxt, pvalue->u.locationConfirm); if (stat != ASN_OK) return stat; break; /* locationReject */ case 21: stat = asn1PE_H225LocationReject (pctxt, pvalue->u.locationReject); if (stat != ASN_OK) return stat; break; /* infoRequest */ case 22: stat = asn1PE_H225InfoRequest (pctxt, pvalue->u.infoRequest); if (stat != ASN_OK) return stat; break; /* infoRequestResponse */ case 23: stat = asn1PE_H225InfoRequestResponse (pctxt, pvalue->u.infoRequestResponse); if (stat != ASN_OK) return stat; break; /* nonStandardMessage */ case 24: stat = asn1PE_H225NonStandardMessage (pctxt, pvalue->u.nonStandardMessage); if (stat != ASN_OK) return stat; break; /* unknownMessageResponse */ case 25: stat = asn1PE_H225UnknownMessageResponse (pctxt, pvalue->u.unknownMessageResponse); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 26); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* requestInProgress */ case 26: stat = asn1PE_H225RequestInProgress (&lctxt, pvalue->u.requestInProgress); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* resourcesAvailableIndicate */ case 27: stat = asn1PE_H225ResourcesAvailableIndicate (&lctxt, pvalue->u.resourcesAvailableIndicate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* resourcesAvailableConfirm */ case 28: stat = asn1PE_H225ResourcesAvailableConfirm (&lctxt, pvalue->u.resourcesAvailableConfirm); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* infoRequestAck */ case 29: stat = asn1PE_H225InfoRequestAck (&lctxt, pvalue->u.infoRequestAck); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* infoRequestNak */ case 30: stat = asn1PE_H225InfoRequestNak (&lctxt, pvalue->u.infoRequestNak); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* serviceControlIndication */ case 31: stat = asn1PE_H225ServiceControlIndication (&lctxt, pvalue->u.serviceControlIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* serviceControlResponse */ case 32: stat = asn1PE_H225ServiceControlResponse (&lctxt, pvalue->u.serviceControlResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* admissionConfirmSequence */ case 33: stat = asn1PE_H225_SeqOfH225AdmissionConfirm (&lctxt, pvalue->u.admissionConfirmSequence); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } asterisk-11.7.0/addons/ooh323c/src/h323/H323-MESSAGES.h0000644000175000007640000100502611750517252021251 0ustar sharkyjerryweb/* * 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 H323_MESSAGES_H #define H323_MESSAGES_H #ifdef __cplusplus extern "C" { #endif #include #include #include "ooasn1.h" #include "H235-SECURITY-MESSAGES.h" #include "MULTIMEDIA-SYSTEM-CONTROL.h" /**************************************************************/ /* */ /* ScreeningIndicator */ /* */ /**************************************************************/ typedef enum { userProvidedNotScreened = 0, userProvidedVerifiedAndPassed = 1, userProvidedVerifiedAndFailed = 2, networkProvided = 3 } H225ScreeningIndicator_Root; typedef ASN1UINT H225ScreeningIndicator; EXTERN int asn1PE_H225ScreeningIndicator (OOCTXT* pctxt, H225ScreeningIndicator value); EXTERN int asn1PD_H225ScreeningIndicator (OOCTXT* pctxt, H225ScreeningIndicator* pvalue); /**************************************************************/ /* */ /* NumberDigits */ /* */ /**************************************************************/ typedef ASN1IA5String H225NumberDigits; EXTERN int asn1PE_H225NumberDigits (OOCTXT* pctxt, H225NumberDigits value); EXTERN int asn1PD_H225NumberDigits (OOCTXT* pctxt, H225NumberDigits* pvalue); /**************************************************************/ /* */ /* TBCD_STRING */ /* */ /**************************************************************/ typedef ASN1IA5String H225TBCD_STRING; EXTERN int asn1PE_H225TBCD_STRING (OOCTXT* pctxt, H225TBCD_STRING value); EXTERN int asn1PD_H225TBCD_STRING (OOCTXT* pctxt, H225TBCD_STRING* pvalue); /**************************************************************/ /* */ /* GloballyUniqueID */ /* */ /**************************************************************/ typedef struct EXTERN H225GloballyUniqueID { ASN1UINT numocts; ASN1OCTET data[16]; } H225GloballyUniqueID; EXTERN int asn1PE_H225GloballyUniqueID (OOCTXT* pctxt, H225GloballyUniqueID* pvalue); EXTERN int asn1PD_H225GloballyUniqueID (OOCTXT* pctxt, H225GloballyUniqueID* pvalue); /**************************************************************/ /* */ /* ConferenceIdentifier */ /* */ /**************************************************************/ typedef H225GloballyUniqueID H225ConferenceIdentifier; EXTERN int asn1PE_H225ConferenceIdentifier (OOCTXT* pctxt, H225ConferenceIdentifier* pvalue); EXTERN int asn1PD_H225ConferenceIdentifier (OOCTXT* pctxt, H225ConferenceIdentifier* pvalue); /**************************************************************/ /* */ /* RequestSeqNum */ /* */ /**************************************************************/ typedef ASN1USINT H225RequestSeqNum; EXTERN int asn1PE_H225RequestSeqNum (OOCTXT* pctxt, H225RequestSeqNum value); EXTERN int asn1PD_H225RequestSeqNum (OOCTXT* pctxt, H225RequestSeqNum* pvalue); /**************************************************************/ /* */ /* GatekeeperIdentifier */ /* */ /**************************************************************/ typedef ASN1BMPString H225GatekeeperIdentifier; EXTERN int asn1PE_H225GatekeeperIdentifier (OOCTXT* pctxt, H225GatekeeperIdentifier value); EXTERN int asn1PD_H225GatekeeperIdentifier (OOCTXT* pctxt, H225GatekeeperIdentifier* pvalue); /**************************************************************/ /* */ /* BandWidth */ /* */ /**************************************************************/ typedef ASN1UINT H225BandWidth; EXTERN int asn1PE_H225BandWidth (OOCTXT* pctxt, H225BandWidth value); EXTERN int asn1PD_H225BandWidth (OOCTXT* pctxt, H225BandWidth* pvalue); /**************************************************************/ /* */ /* CallReferenceValue */ /* */ /**************************************************************/ typedef ASN1USINT H225CallReferenceValue; EXTERN int asn1PE_H225CallReferenceValue (OOCTXT* pctxt, H225CallReferenceValue value); EXTERN int asn1PD_H225CallReferenceValue (OOCTXT* pctxt, H225CallReferenceValue* pvalue); /**************************************************************/ /* */ /* EndpointIdentifier */ /* */ /**************************************************************/ typedef ASN1BMPString H225EndpointIdentifier; EXTERN int asn1PE_H225EndpointIdentifier (OOCTXT* pctxt, H225EndpointIdentifier value); EXTERN int asn1PD_H225EndpointIdentifier (OOCTXT* pctxt, H225EndpointIdentifier* pvalue); /**************************************************************/ /* */ /* ProtocolIdentifier */ /* */ /**************************************************************/ typedef ASN1OBJID H225ProtocolIdentifier; EXTERN int asn1PE_H225ProtocolIdentifier (OOCTXT* pctxt, H225ProtocolIdentifier* value); EXTERN int asn1PD_H225ProtocolIdentifier (OOCTXT* pctxt, H225ProtocolIdentifier* pvalue); /**************************************************************/ /* */ /* TimeToLive */ /* */ /**************************************************************/ typedef ASN1UINT H225TimeToLive; EXTERN int asn1PE_H225TimeToLive (OOCTXT* pctxt, H225TimeToLive value); EXTERN int asn1PD_H225TimeToLive (OOCTXT* pctxt, H225TimeToLive* pvalue); /**************************************************************/ /* */ /* H248PackagesDescriptor */ /* */ /**************************************************************/ typedef ASN1DynOctStr H225H248PackagesDescriptor; EXTERN int asn1PE_H225H248PackagesDescriptor (OOCTXT* pctxt, H225H248PackagesDescriptor value); EXTERN int asn1PD_H225H248PackagesDescriptor (OOCTXT* pctxt, H225H248PackagesDescriptor* pvalue); /**************************************************************/ /* */ /* H248SignalsDescriptor */ /* */ /**************************************************************/ typedef ASN1DynOctStr H225H248SignalsDescriptor; EXTERN int asn1PE_H225H248SignalsDescriptor (OOCTXT* pctxt, H225H248SignalsDescriptor value); EXTERN int asn1PD_H225H248SignalsDescriptor (OOCTXT* pctxt, H225H248SignalsDescriptor* pvalue); /**************************************************************/ /* */ /* GenericIdentifier */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225GenericIdentifier_standard 1 #define T_H225GenericIdentifier_oid 2 #define T_H225GenericIdentifier_nonStandard 3 #define T_H225GenericIdentifier_extElem1 4 typedef struct EXTERN H225GenericIdentifier { int t; union { /* t = 1 */ ASN1INT standard; /* t = 2 */ ASN1OBJID *oid; /* t = 3 */ H225GloballyUniqueID *nonStandard; /* t = 4 */ } u; } H225GenericIdentifier; EXTERN int asn1PE_H225GenericIdentifier (OOCTXT* pctxt, H225GenericIdentifier* pvalue); EXTERN int asn1PD_H225GenericIdentifier (OOCTXT* pctxt, H225GenericIdentifier* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipAddress_ip */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipAddress_ip { ASN1UINT numocts; ASN1OCTET data[4]; } H225TransportAddress_ipAddress_ip; EXTERN int asn1PE_H225TransportAddress_ipAddress_ip (OOCTXT* pctxt, H225TransportAddress_ipAddress_ip* pvalue); EXTERN int asn1PD_H225TransportAddress_ipAddress_ip (OOCTXT* pctxt, H225TransportAddress_ipAddress_ip* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipAddress */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipAddress { H225TransportAddress_ipAddress_ip ip; ASN1USINT port; } H225TransportAddress_ipAddress; EXTERN int asn1PE_H225TransportAddress_ipAddress (OOCTXT* pctxt, H225TransportAddress_ipAddress* pvalue); EXTERN int asn1PD_H225TransportAddress_ipAddress (OOCTXT* pctxt, H225TransportAddress_ipAddress* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_ip */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipSourceRoute_ip { ASN1UINT numocts; ASN1OCTET data[4]; } H225TransportAddress_ipSourceRoute_ip; EXTERN int asn1PE_H225TransportAddress_ipSourceRoute_ip (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_ip* pvalue); EXTERN int asn1PD_H225TransportAddress_ipSourceRoute_ip (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_ip* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_route_element */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipSourceRoute_route_element { ASN1UINT numocts; ASN1OCTET data[4]; } H225TransportAddress_ipSourceRoute_route_element; EXTERN int asn1PE_H225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_route_element* pvalue); EXTERN int asn1PD_H225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_route_element* pvalue); /**************************************************************/ /* */ /* _SeqOfH225TransportAddress_ipSourceRoute_route_element */ /* */ /**************************************************************/ typedef struct EXTERN H225_SeqOfH225TransportAddress_ipSourceRoute_route_element { ASN1UINT n; H225TransportAddress_ipSourceRoute_route_element *elem; } H225_SeqOfH225TransportAddress_ipSourceRoute_route_element; EXTERN int asn1PE_H225_SeqOfH225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225_SeqOfH225TransportAddress_ipSourceRoute_route_element* pvalue); EXTERN int asn1PD_H225_SeqOfH225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225_SeqOfH225TransportAddress_ipSourceRoute_route_element* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_routing */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225TransportAddress_ipSourceRoute_routing_strict 1 #define T_H225TransportAddress_ipSourceRoute_routing_loose 2 #define T_H225TransportAddress_ipSourceRoute_routing_extElem1 3 typedef struct EXTERN H225TransportAddress_ipSourceRoute_routing { int t; } H225TransportAddress_ipSourceRoute_routing; EXTERN int asn1PE_H225TransportAddress_ipSourceRoute_routing (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_routing* pvalue); EXTERN int asn1PD_H225TransportAddress_ipSourceRoute_routing (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_routing* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipSourceRoute { H225TransportAddress_ipSourceRoute_ip ip; ASN1USINT port; H225_SeqOfH225TransportAddress_ipSourceRoute_route_element route; H225TransportAddress_ipSourceRoute_routing routing; } H225TransportAddress_ipSourceRoute; EXTERN int asn1PE_H225TransportAddress_ipSourceRoute (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute* pvalue); EXTERN int asn1PD_H225TransportAddress_ipSourceRoute (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipxAddress_node */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipxAddress_node { ASN1UINT numocts; ASN1OCTET data[6]; } H225TransportAddress_ipxAddress_node; EXTERN int asn1PE_H225TransportAddress_ipxAddress_node (OOCTXT* pctxt, H225TransportAddress_ipxAddress_node* pvalue); EXTERN int asn1PD_H225TransportAddress_ipxAddress_node (OOCTXT* pctxt, H225TransportAddress_ipxAddress_node* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipxAddress_netnum */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipxAddress_netnum { ASN1UINT numocts; ASN1OCTET data[4]; } H225TransportAddress_ipxAddress_netnum; EXTERN int asn1PE_H225TransportAddress_ipxAddress_netnum (OOCTXT* pctxt, H225TransportAddress_ipxAddress_netnum* pvalue); EXTERN int asn1PD_H225TransportAddress_ipxAddress_netnum (OOCTXT* pctxt, H225TransportAddress_ipxAddress_netnum* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipxAddress_port */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipxAddress_port { ASN1UINT numocts; ASN1OCTET data[2]; } H225TransportAddress_ipxAddress_port; EXTERN int asn1PE_H225TransportAddress_ipxAddress_port (OOCTXT* pctxt, H225TransportAddress_ipxAddress_port* pvalue); EXTERN int asn1PD_H225TransportAddress_ipxAddress_port (OOCTXT* pctxt, H225TransportAddress_ipxAddress_port* pvalue); /**************************************************************/ /* */ /* TransportAddress_ipxAddress */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ipxAddress { H225TransportAddress_ipxAddress_node node; H225TransportAddress_ipxAddress_netnum netnum; H225TransportAddress_ipxAddress_port port; } H225TransportAddress_ipxAddress; EXTERN int asn1PE_H225TransportAddress_ipxAddress (OOCTXT* pctxt, H225TransportAddress_ipxAddress* pvalue); EXTERN int asn1PD_H225TransportAddress_ipxAddress (OOCTXT* pctxt, H225TransportAddress_ipxAddress* pvalue); /**************************************************************/ /* */ /* TransportAddress_ip6Address_ip */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ip6Address_ip { ASN1UINT numocts; ASN1OCTET data[16]; } H225TransportAddress_ip6Address_ip; EXTERN int asn1PE_H225TransportAddress_ip6Address_ip (OOCTXT* pctxt, H225TransportAddress_ip6Address_ip* pvalue); EXTERN int asn1PD_H225TransportAddress_ip6Address_ip (OOCTXT* pctxt, H225TransportAddress_ip6Address_ip* pvalue); /**************************************************************/ /* */ /* TransportAddress_ip6Address */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_ip6Address { H225TransportAddress_ip6Address_ip ip; ASN1USINT port; } H225TransportAddress_ip6Address; EXTERN int asn1PE_H225TransportAddress_ip6Address (OOCTXT* pctxt, H225TransportAddress_ip6Address* pvalue); EXTERN int asn1PD_H225TransportAddress_ip6Address (OOCTXT* pctxt, H225TransportAddress_ip6Address* pvalue); /**************************************************************/ /* */ /* TransportAddress_netBios */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_netBios { ASN1UINT numocts; ASN1OCTET data[16]; } H225TransportAddress_netBios; EXTERN int asn1PE_H225TransportAddress_netBios (OOCTXT* pctxt, H225TransportAddress_netBios* pvalue); EXTERN int asn1PD_H225TransportAddress_netBios (OOCTXT* pctxt, H225TransportAddress_netBios* pvalue); /**************************************************************/ /* */ /* TransportAddress_nsap */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportAddress_nsap { ASN1UINT numocts; ASN1OCTET data[20]; } H225TransportAddress_nsap; EXTERN int asn1PE_H225TransportAddress_nsap (OOCTXT* pctxt, H225TransportAddress_nsap* pvalue); EXTERN int asn1PD_H225TransportAddress_nsap (OOCTXT* pctxt, H225TransportAddress_nsap* pvalue); /**************************************************************/ /* */ /* H221NonStandard */ /* */ /**************************************************************/ typedef struct EXTERN H225H221NonStandard { ASN1UINT8 t35CountryCode; ASN1UINT8 t35Extension; ASN1USINT manufacturerCode; } H225H221NonStandard; EXTERN int asn1PE_H225H221NonStandard (OOCTXT* pctxt, H225H221NonStandard* pvalue); EXTERN int asn1PD_H225H221NonStandard (OOCTXT* pctxt, H225H221NonStandard* pvalue); /**************************************************************/ /* */ /* NonStandardIdentifier */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225NonStandardIdentifier_object 1 #define T_H225NonStandardIdentifier_h221NonStandard 2 #define T_H225NonStandardIdentifier_extElem1 3 typedef struct EXTERN H225NonStandardIdentifier { int t; union { /* t = 1 */ ASN1OBJID *object; /* t = 2 */ H225H221NonStandard *h221NonStandard; /* t = 3 */ } u; } H225NonStandardIdentifier; EXTERN int asn1PE_H225NonStandardIdentifier (OOCTXT* pctxt, H225NonStandardIdentifier* pvalue); EXTERN int asn1PD_H225NonStandardIdentifier (OOCTXT* pctxt, H225NonStandardIdentifier* pvalue); /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ typedef struct EXTERN H225NonStandardParameter { H225NonStandardIdentifier nonStandardIdentifier; ASN1DynOctStr data; } H225NonStandardParameter; EXTERN int asn1PE_H225NonStandardParameter (OOCTXT* pctxt, H225NonStandardParameter* pvalue); EXTERN int asn1PD_H225NonStandardParameter (OOCTXT* pctxt, H225NonStandardParameter* pvalue); /**************************************************************/ /* */ /* TransportAddress */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225TransportAddress_ipAddress 1 #define T_H225TransportAddress_ipSourceRoute 2 #define T_H225TransportAddress_ipxAddress 3 #define T_H225TransportAddress_ip6Address 4 #define T_H225TransportAddress_netBios 5 #define T_H225TransportAddress_nsap 6 #define T_H225TransportAddress_nonStandardAddress 7 #define T_H225TransportAddress_extElem1 8 typedef struct EXTERN H225TransportAddress { int t; union { /* t = 1 */ H225TransportAddress_ipAddress *ipAddress; /* t = 2 */ H225TransportAddress_ipSourceRoute *ipSourceRoute; /* t = 3 */ H225TransportAddress_ipxAddress *ipxAddress; /* t = 4 */ H225TransportAddress_ip6Address *ip6Address; /* t = 5 */ H225TransportAddress_netBios *netBios; /* t = 6 */ H225TransportAddress_nsap *nsap; /* t = 7 */ H225NonStandardParameter *nonStandardAddress; /* t = 8 */ } u; } H225TransportAddress; EXTERN int asn1PE_H225TransportAddress (OOCTXT* pctxt, H225TransportAddress* pvalue); EXTERN int asn1PD_H225TransportAddress (OOCTXT* pctxt, H225TransportAddress* pvalue); /**************************************************************/ /* */ /* PublicTypeOfNumber */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225PublicTypeOfNumber_unknown 1 #define T_H225PublicTypeOfNumber_internationalNumber 2 #define T_H225PublicTypeOfNumber_nationalNumber 3 #define T_H225PublicTypeOfNumber_networkSpecificNumber 4 #define T_H225PublicTypeOfNumber_subscriberNumber 5 #define T_H225PublicTypeOfNumber_abbreviatedNumber 6 #define T_H225PublicTypeOfNumber_extElem1 7 typedef struct EXTERN H225PublicTypeOfNumber { int t; } H225PublicTypeOfNumber; EXTERN int asn1PE_H225PublicTypeOfNumber (OOCTXT* pctxt, H225PublicTypeOfNumber* pvalue); EXTERN int asn1PD_H225PublicTypeOfNumber (OOCTXT* pctxt, H225PublicTypeOfNumber* pvalue); /**************************************************************/ /* */ /* PublicPartyNumber */ /* */ /**************************************************************/ typedef struct EXTERN H225PublicPartyNumber { H225PublicTypeOfNumber publicTypeOfNumber; H225NumberDigits publicNumberDigits; } H225PublicPartyNumber; EXTERN int asn1PE_H225PublicPartyNumber (OOCTXT* pctxt, H225PublicPartyNumber* pvalue); EXTERN int asn1PD_H225PublicPartyNumber (OOCTXT* pctxt, H225PublicPartyNumber* pvalue); /**************************************************************/ /* */ /* PrivateTypeOfNumber */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225PrivateTypeOfNumber_unknown 1 #define T_H225PrivateTypeOfNumber_level2RegionalNumber 2 #define T_H225PrivateTypeOfNumber_level1RegionalNumber 3 #define T_H225PrivateTypeOfNumber_pISNSpecificNumber 4 #define T_H225PrivateTypeOfNumber_localNumber 5 #define T_H225PrivateTypeOfNumber_abbreviatedNumber 6 #define T_H225PrivateTypeOfNumber_extElem1 7 typedef struct EXTERN H225PrivateTypeOfNumber { int t; } H225PrivateTypeOfNumber; EXTERN int asn1PE_H225PrivateTypeOfNumber (OOCTXT* pctxt, H225PrivateTypeOfNumber* pvalue); EXTERN int asn1PD_H225PrivateTypeOfNumber (OOCTXT* pctxt, H225PrivateTypeOfNumber* pvalue); /**************************************************************/ /* */ /* PrivatePartyNumber */ /* */ /**************************************************************/ typedef struct EXTERN H225PrivatePartyNumber { H225PrivateTypeOfNumber privateTypeOfNumber; H225NumberDigits privateNumberDigits; } H225PrivatePartyNumber; EXTERN int asn1PE_H225PrivatePartyNumber (OOCTXT* pctxt, H225PrivatePartyNumber* pvalue); EXTERN int asn1PD_H225PrivatePartyNumber (OOCTXT* pctxt, H225PrivatePartyNumber* pvalue); /**************************************************************/ /* */ /* PartyNumber */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225PartyNumber_e164Number 1 #define T_H225PartyNumber_dataPartyNumber 2 #define T_H225PartyNumber_telexPartyNumber 3 #define T_H225PartyNumber_privateNumber 4 #define T_H225PartyNumber_nationalStandardPartyNumber 5 #define T_H225PartyNumber_extElem1 6 typedef struct EXTERN H225PartyNumber { int t; union { /* t = 1 */ H225PublicPartyNumber *e164Number; /* t = 2 */ H225NumberDigits dataPartyNumber; /* t = 3 */ H225NumberDigits telexPartyNumber; /* t = 4 */ H225PrivatePartyNumber *privateNumber; /* t = 5 */ H225NumberDigits nationalStandardPartyNumber; /* t = 6 */ } u; } H225PartyNumber; EXTERN int asn1PE_H225PartyNumber (OOCTXT* pctxt, H225PartyNumber* pvalue); EXTERN int asn1PD_H225PartyNumber (OOCTXT* pctxt, H225PartyNumber* pvalue); /**************************************************************/ /* */ /* ANSI_41_UIM_system_id */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225ANSI_41_UIM_system_id_sid 1 #define T_H225ANSI_41_UIM_system_id_mid 2 #define T_H225ANSI_41_UIM_system_id_extElem1 3 typedef struct EXTERN H225ANSI_41_UIM_system_id { int t; union { /* t = 1 */ ASN1IA5String sid; /* t = 2 */ ASN1IA5String mid; /* t = 3 */ } u; } H225ANSI_41_UIM_system_id; EXTERN int asn1PE_H225ANSI_41_UIM_system_id (OOCTXT* pctxt, H225ANSI_41_UIM_system_id* pvalue); EXTERN int asn1PD_H225ANSI_41_UIM_system_id (OOCTXT* pctxt, H225ANSI_41_UIM_system_id* pvalue); /**************************************************************/ /* */ /* ANSI_41_UIM_systemMyTypeCode */ /* */ /**************************************************************/ typedef struct EXTERN H225ANSI_41_UIM_systemMyTypeCode { ASN1UINT numocts; ASN1OCTET data[1]; } H225ANSI_41_UIM_systemMyTypeCode; EXTERN int asn1PE_H225ANSI_41_UIM_systemMyTypeCode (OOCTXT* pctxt, H225ANSI_41_UIM_systemMyTypeCode* pvalue); EXTERN int asn1PD_H225ANSI_41_UIM_systemMyTypeCode (OOCTXT* pctxt, H225ANSI_41_UIM_systemMyTypeCode* pvalue); /**************************************************************/ /* */ /* ANSI_41_UIM_systemAccessType */ /* */ /**************************************************************/ typedef struct EXTERN H225ANSI_41_UIM_systemAccessType { ASN1UINT numocts; ASN1OCTET data[1]; } H225ANSI_41_UIM_systemAccessType; EXTERN int asn1PE_H225ANSI_41_UIM_systemAccessType (OOCTXT* pctxt, H225ANSI_41_UIM_systemAccessType* pvalue); EXTERN int asn1PD_H225ANSI_41_UIM_systemAccessType (OOCTXT* pctxt, H225ANSI_41_UIM_systemAccessType* pvalue); /**************************************************************/ /* */ /* ANSI_41_UIM_qualificationInformationCode */ /* */ /**************************************************************/ typedef struct EXTERN H225ANSI_41_UIM_qualificationInformationCode { ASN1UINT numocts; ASN1OCTET data[1]; } H225ANSI_41_UIM_qualificationInformationCode; EXTERN int asn1PE_H225ANSI_41_UIM_qualificationInformationCode (OOCTXT* pctxt, H225ANSI_41_UIM_qualificationInformationCode* pvalue); EXTERN int asn1PD_H225ANSI_41_UIM_qualificationInformationCode (OOCTXT* pctxt, H225ANSI_41_UIM_qualificationInformationCode* pvalue); /**************************************************************/ /* */ /* ANSI_41_UIM */ /* */ /**************************************************************/ typedef struct EXTERN H225ANSI_41_UIM { struct { unsigned imsiPresent : 1; unsigned minPresent : 1; unsigned mdnPresent : 1; unsigned msisdnPresent : 1; unsigned esnPresent : 1; unsigned mscidPresent : 1; unsigned systemMyTypeCodePresent : 1; unsigned systemAccessTypePresent : 1; unsigned qualificationInformationCodePresent : 1; unsigned sesnPresent : 1; unsigned socPresent : 1; } m; ASN1IA5String imsi; ASN1IA5String min; ASN1IA5String mdn; ASN1IA5String msisdn; ASN1IA5String esn; ASN1IA5String mscid; H225ANSI_41_UIM_system_id system_id; H225ANSI_41_UIM_systemMyTypeCode systemMyTypeCode; H225ANSI_41_UIM_systemAccessType systemAccessType; H225ANSI_41_UIM_qualificationInformationCode qualificationInformationCode; ASN1IA5String sesn; ASN1IA5String soc; } H225ANSI_41_UIM; EXTERN int asn1PE_H225ANSI_41_UIM (OOCTXT* pctxt, H225ANSI_41_UIM* pvalue); EXTERN int asn1PD_H225ANSI_41_UIM (OOCTXT* pctxt, H225ANSI_41_UIM* pvalue); /**************************************************************/ /* */ /* GSM_UIM_tmsi */ /* */ /**************************************************************/ typedef struct EXTERN H225GSM_UIM_tmsi { ASN1UINT numocts; ASN1OCTET data[4]; } H225GSM_UIM_tmsi; EXTERN int asn1PE_H225GSM_UIM_tmsi (OOCTXT* pctxt, H225GSM_UIM_tmsi* pvalue); EXTERN int asn1PD_H225GSM_UIM_tmsi (OOCTXT* pctxt, H225GSM_UIM_tmsi* pvalue); /**************************************************************/ /* */ /* GSM_UIM */ /* */ /**************************************************************/ typedef struct EXTERN H225GSM_UIM { struct { unsigned imsiPresent : 1; unsigned tmsiPresent : 1; unsigned msisdnPresent : 1; unsigned imeiPresent : 1; unsigned hplmnPresent : 1; unsigned vplmnPresent : 1; } m; ASN1IA5String imsi; H225GSM_UIM_tmsi tmsi; ASN1IA5String msisdn; ASN1IA5String imei; ASN1IA5String hplmn; ASN1IA5String vplmn; } H225GSM_UIM; EXTERN int asn1PE_H225GSM_UIM (OOCTXT* pctxt, H225GSM_UIM* pvalue); EXTERN int asn1PD_H225GSM_UIM (OOCTXT* pctxt, H225GSM_UIM* pvalue); /**************************************************************/ /* */ /* MobileUIM */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225MobileUIM_ansi_41_uim 1 #define T_H225MobileUIM_gsm_uim 2 #define T_H225MobileUIM_extElem1 3 typedef struct EXTERN H225MobileUIM { int t; union { /* t = 1 */ H225ANSI_41_UIM *ansi_41_uim; /* t = 2 */ H225GSM_UIM *gsm_uim; /* t = 3 */ } u; } H225MobileUIM; EXTERN int asn1PE_H225MobileUIM (OOCTXT* pctxt, H225MobileUIM* pvalue); EXTERN int asn1PD_H225MobileUIM (OOCTXT* pctxt, H225MobileUIM* pvalue); /**************************************************************/ /* */ /* AliasAddress */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225AliasAddress_dialedDigits 1 #define T_H225AliasAddress_h323_ID 2 #define T_H225AliasAddress_url_ID 3 #define T_H225AliasAddress_transportID 4 #define T_H225AliasAddress_email_ID 5 #define T_H225AliasAddress_partyNumber 6 #define T_H225AliasAddress_mobileUIM 7 #define T_H225AliasAddress_extElem1 8 typedef struct EXTERN H225AliasAddress { int t; union { /* t = 1 */ ASN1IA5String dialedDigits; /* t = 2 */ ASN1BMPString h323_ID; /* t = 3 */ ASN1IA5String url_ID; /* t = 4 */ H225TransportAddress *transportID; /* t = 5 */ ASN1IA5String email_ID; /* t = 6 */ H225PartyNumber *partyNumber; /* t = 7 */ H225MobileUIM *mobileUIM; /* t = 8 */ } u; } H225AliasAddress; EXTERN int asn1PE_H225AliasAddress (OOCTXT* pctxt, H225AliasAddress* pvalue); EXTERN int asn1PD_H225AliasAddress (OOCTXT* pctxt, H225AliasAddress* pvalue); /**************************************************************/ /* */ /* Content_compound */ /* */ /**************************************************************/ /* List of H225EnumeratedParameter */ typedef DList H225Content_compound; EXTERN int asn1PE_H225Content_compound (OOCTXT* pctxt, H225Content_compound* pvalue); EXTERN int asn1PD_H225Content_compound (OOCTXT* pctxt, H225Content_compound* pvalue); /**************************************************************/ /* */ /* Content_nested */ /* */ /**************************************************************/ /* List of H225GenericData */ typedef DList H225Content_nested; EXTERN int asn1PE_H225Content_nested (OOCTXT* pctxt, H225Content_nested* pvalue); EXTERN int asn1PD_H225Content_nested (OOCTXT* pctxt, H225Content_nested* pvalue); /**************************************************************/ /* */ /* Content */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225Content_raw 1 #define T_H225Content_text 2 #define T_H225Content_unicode 3 #define T_H225Content_bool_ 4 #define T_H225Content_number8 5 #define T_H225Content_number16 6 #define T_H225Content_number32 7 #define T_H225Content_id 8 #define T_H225Content_alias 9 #define T_H225Content_transport 10 #define T_H225Content_compound 11 #define T_H225Content_nested 12 #define T_H225Content_extElem1 13 typedef struct EXTERN H225Content { int t; union { /* t = 1 */ ASN1DynOctStr *raw; /* t = 2 */ ASN1IA5String text; /* t = 3 */ ASN1BMPString unicode; /* t = 4 */ ASN1BOOL bool_; /* t = 5 */ ASN1UINT8 number8; /* t = 6 */ ASN1USINT number16; /* t = 7 */ ASN1UINT number32; /* t = 8 */ H225GenericIdentifier *id; /* t = 9 */ H225AliasAddress *alias; /* t = 10 */ H225TransportAddress *transport; /* t = 11 */ H225Content_compound *compound; /* t = 12 */ H225Content_nested *nested; /* t = 13 */ } u; } H225Content; EXTERN int asn1PE_H225Content (OOCTXT* pctxt, H225Content* pvalue); EXTERN int asn1PD_H225Content (OOCTXT* pctxt, H225Content* pvalue); /**************************************************************/ /* */ /* EnumeratedParameter */ /* */ /**************************************************************/ typedef struct EXTERN H225EnumeratedParameter { struct { unsigned contentPresent : 1; } m; H225GenericIdentifier id; H225Content content; } H225EnumeratedParameter; EXTERN int asn1PE_H225EnumeratedParameter (OOCTXT* pctxt, H225EnumeratedParameter* pvalue); EXTERN int asn1PD_H225EnumeratedParameter (OOCTXT* pctxt, H225EnumeratedParameter* pvalue); /**************************************************************/ /* */ /* GenericData_parameters */ /* */ /**************************************************************/ /* List of H225EnumeratedParameter */ typedef DList H225GenericData_parameters; EXTERN int asn1PE_H225GenericData_parameters (OOCTXT* pctxt, H225GenericData_parameters* pvalue); EXTERN int asn1PD_H225GenericData_parameters (OOCTXT* pctxt, H225GenericData_parameters* pvalue); /**************************************************************/ /* */ /* GenericData */ /* */ /**************************************************************/ typedef struct EXTERN H225GenericData { struct { unsigned parametersPresent : 1; } m; H225GenericIdentifier id; H225GenericData_parameters parameters; } H225GenericData; EXTERN int asn1PE_H225GenericData (OOCTXT* pctxt, H225GenericData* pvalue); EXTERN int asn1PD_H225GenericData (OOCTXT* pctxt, H225GenericData* pvalue); /**************************************************************/ /* */ /* FeatureDescriptor */ /* */ /**************************************************************/ typedef H225GenericData H225FeatureDescriptor; EXTERN int asn1PE_H225FeatureDescriptor (OOCTXT* pctxt, H225FeatureDescriptor* pvalue); EXTERN int asn1PD_H225FeatureDescriptor (OOCTXT* pctxt, H225FeatureDescriptor* pvalue); /**************************************************************/ /* */ /* FastStartToken */ /* */ /**************************************************************/ typedef H235ClearToken H225FastStartToken; EXTERN int asn1PE_H225FastStartToken (OOCTXT* pctxt, H225FastStartToken* pvalue); EXTERN int asn1PD_H225FastStartToken (OOCTXT* pctxt, H225FastStartToken* pvalue); /**************************************************************/ /* */ /* EncodedFastStartToken */ /* */ /**************************************************************/ typedef ASN1OpenType H225EncodedFastStartToken; EXTERN int asn1PE_H225EncodedFastStartToken (OOCTXT* pctxt, H225EncodedFastStartToken value); EXTERN int asn1PD_H225EncodedFastStartToken (OOCTXT* pctxt, H225EncodedFastStartToken* pvalue); /**************************************************************/ /* */ /* H323_UserInformation_user_data_user_information */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UserInformation_user_data_user_information { ASN1UINT numocts; ASN1OCTET data[131]; } H225H323_UserInformation_user_data_user_information; EXTERN int asn1PE_H225H323_UserInformation_user_data_user_information (OOCTXT* pctxt, H225H323_UserInformation_user_data_user_information* pvalue); EXTERN int asn1PD_H225H323_UserInformation_user_data_user_information (OOCTXT* pctxt, H225H323_UserInformation_user_data_user_information* pvalue); /**************************************************************/ /* */ /* EndpointType_set */ /* */ /**************************************************************/ typedef struct EXTERN H225EndpointType_set { ASN1UINT numbits; ASN1OCTET data[4]; } H225EndpointType_set; EXTERN int asn1PE_H225EndpointType_set (OOCTXT* pctxt, H225EndpointType_set* pvalue); EXTERN int asn1PD_H225EndpointType_set (OOCTXT* pctxt, H225EndpointType_set* pvalue); /**************************************************************/ /* */ /* VendorIdentifier_productId */ /* */ /**************************************************************/ typedef struct EXTERN H225VendorIdentifier_productId { ASN1UINT numocts; ASN1OCTET data[256]; } H225VendorIdentifier_productId; EXTERN int asn1PE_H225VendorIdentifier_productId (OOCTXT* pctxt, H225VendorIdentifier_productId* pvalue); EXTERN int asn1PD_H225VendorIdentifier_productId (OOCTXT* pctxt, H225VendorIdentifier_productId* pvalue); /**************************************************************/ /* */ /* VendorIdentifier_versionId */ /* */ /**************************************************************/ typedef struct EXTERN H225VendorIdentifier_versionId { ASN1UINT numocts; ASN1OCTET data[256]; } H225VendorIdentifier_versionId; EXTERN int asn1PE_H225VendorIdentifier_versionId (OOCTXT* pctxt, H225VendorIdentifier_versionId* pvalue); EXTERN int asn1PD_H225VendorIdentifier_versionId (OOCTXT* pctxt, H225VendorIdentifier_versionId* pvalue); /**************************************************************/ /* */ /* CicInfo_cic_element */ /* */ /**************************************************************/ typedef struct EXTERN H225CicInfo_cic_element { ASN1UINT numocts; ASN1OCTET data[4]; } H225CicInfo_cic_element; EXTERN int asn1PE_H225CicInfo_cic_element (OOCTXT* pctxt, H225CicInfo_cic_element* pvalue); EXTERN int asn1PD_H225CicInfo_cic_element (OOCTXT* pctxt, H225CicInfo_cic_element* pvalue); /**************************************************************/ /* */ /* CicInfo_pointCode */ /* */ /**************************************************************/ typedef struct EXTERN H225CicInfo_pointCode { ASN1UINT numocts; ASN1OCTET data[5]; } H225CicInfo_pointCode; EXTERN int asn1PE_H225CicInfo_pointCode (OOCTXT* pctxt, H225CicInfo_pointCode* pvalue); EXTERN int asn1PD_H225CicInfo_pointCode (OOCTXT* pctxt, H225CicInfo_pointCode* pvalue); /**************************************************************/ /* */ /* CarrierInfo_carrierIdentificationCode */ /* */ /**************************************************************/ typedef struct EXTERN H225CarrierInfo_carrierIdentificationCode { ASN1UINT numocts; ASN1OCTET data[4]; } H225CarrierInfo_carrierIdentificationCode; EXTERN int asn1PE_H225CarrierInfo_carrierIdentificationCode (OOCTXT* pctxt, H225CarrierInfo_carrierIdentificationCode* pvalue); EXTERN int asn1PD_H225CarrierInfo_carrierIdentificationCode (OOCTXT* pctxt, H225CarrierInfo_carrierIdentificationCode* pvalue); /**************************************************************/ /* */ /* CallTerminationCause_releaseCompleteCauseIE */ /* */ /**************************************************************/ typedef struct EXTERN H225CallTerminationCause_releaseCompleteCauseIE { ASN1UINT numocts; ASN1OCTET data[32]; } H225CallTerminationCause_releaseCompleteCauseIE; EXTERN int asn1PE_H225CallTerminationCause_releaseCompleteCauseIE (OOCTXT* pctxt, H225CallTerminationCause_releaseCompleteCauseIE* pvalue); EXTERN int asn1PD_H225CallTerminationCause_releaseCompleteCauseIE (OOCTXT* pctxt, H225CallTerminationCause_releaseCompleteCauseIE* pvalue); /**************************************************************/ /* */ /* _SeqOfH225AliasAddress */ /* */ /**************************************************************/ /* List of H225AliasAddress */ typedef DList H225_SeqOfH225AliasAddress; EXTERN int asn1PE_H225_SeqOfH225AliasAddress (OOCTXT* pctxt, H225_SeqOfH225AliasAddress* pvalue); EXTERN int asn1PD_H225_SeqOfH225AliasAddress (OOCTXT* pctxt, H225_SeqOfH225AliasAddress* pvalue); /**************************************************************/ /* */ /* VendorIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H225VendorIdentifier { struct { unsigned productIdPresent : 1; unsigned versionIdPresent : 1; unsigned enterpriseNumberPresent : 1; } m; H225H221NonStandard vendor; H225VendorIdentifier_productId productId; H225VendorIdentifier_versionId versionId; ASN1OBJID enterpriseNumber; } H225VendorIdentifier; EXTERN int asn1PE_H225VendorIdentifier (OOCTXT* pctxt, H225VendorIdentifier* pvalue); EXTERN int asn1PD_H225VendorIdentifier (OOCTXT* pctxt, H225VendorIdentifier* pvalue); /**************************************************************/ /* */ /* GatekeeperInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225GatekeeperInfo { struct { unsigned nonStandardDataPresent : 1; } m; H225NonStandardParameter nonStandardData; } H225GatekeeperInfo; EXTERN int asn1PE_H225GatekeeperInfo (OOCTXT* pctxt, H225GatekeeperInfo* pvalue); EXTERN int asn1PD_H225GatekeeperInfo (OOCTXT* pctxt, H225GatekeeperInfo* pvalue); /**************************************************************/ /* */ /* DataRate */ /* */ /**************************************************************/ typedef struct EXTERN H225DataRate { struct { unsigned nonStandardDataPresent : 1; unsigned channelMultiplierPresent : 1; } m; H225NonStandardParameter nonStandardData; H225BandWidth channelRate; ASN1USINT channelMultiplier; } H225DataRate; EXTERN int asn1PE_H225DataRate (OOCTXT* pctxt, H225DataRate* pvalue); EXTERN int asn1PD_H225DataRate (OOCTXT* pctxt, H225DataRate* pvalue); /**************************************************************/ /* */ /* _SeqOfH225DataRate */ /* */ /**************************************************************/ /* List of H225DataRate */ typedef DList H225_SeqOfH225DataRate; EXTERN int asn1PE_H225_SeqOfH225DataRate (OOCTXT* pctxt, H225_SeqOfH225DataRate* pvalue); EXTERN int asn1PD_H225_SeqOfH225DataRate (OOCTXT* pctxt, H225_SeqOfH225DataRate* pvalue); /**************************************************************/ /* */ /* SupportedPrefix */ /* */ /**************************************************************/ typedef struct EXTERN H225SupportedPrefix { struct { unsigned nonStandardDataPresent : 1; } m; H225NonStandardParameter nonStandardData; H225AliasAddress prefix; } H225SupportedPrefix; EXTERN int asn1PE_H225SupportedPrefix (OOCTXT* pctxt, H225SupportedPrefix* pvalue); EXTERN int asn1PD_H225SupportedPrefix (OOCTXT* pctxt, H225SupportedPrefix* pvalue); /**************************************************************/ /* */ /* _SeqOfH225SupportedPrefix */ /* */ /**************************************************************/ /* List of H225SupportedPrefix */ typedef DList H225_SeqOfH225SupportedPrefix; EXTERN int asn1PE_H225_SeqOfH225SupportedPrefix (OOCTXT* pctxt, H225_SeqOfH225SupportedPrefix* pvalue); EXTERN int asn1PD_H225_SeqOfH225SupportedPrefix (OOCTXT* pctxt, H225_SeqOfH225SupportedPrefix* pvalue); /**************************************************************/ /* */ /* H310Caps */ /* */ /**************************************************************/ typedef struct EXTERN H225H310Caps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225H310Caps; EXTERN int asn1PE_H225H310Caps (OOCTXT* pctxt, H225H310Caps* pvalue); EXTERN int asn1PD_H225H310Caps (OOCTXT* pctxt, H225H310Caps* pvalue); /**************************************************************/ /* */ /* H320Caps */ /* */ /**************************************************************/ typedef struct EXTERN H225H320Caps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225H320Caps; EXTERN int asn1PE_H225H320Caps (OOCTXT* pctxt, H225H320Caps* pvalue); EXTERN int asn1PD_H225H320Caps (OOCTXT* pctxt, H225H320Caps* pvalue); /**************************************************************/ /* */ /* H321Caps */ /* */ /**************************************************************/ typedef struct EXTERN H225H321Caps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225H321Caps; EXTERN int asn1PE_H225H321Caps (OOCTXT* pctxt, H225H321Caps* pvalue); EXTERN int asn1PD_H225H321Caps (OOCTXT* pctxt, H225H321Caps* pvalue); /**************************************************************/ /* */ /* H322Caps */ /* */ /**************************************************************/ typedef struct EXTERN H225H322Caps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225H322Caps; EXTERN int asn1PE_H225H322Caps (OOCTXT* pctxt, H225H322Caps* pvalue); EXTERN int asn1PD_H225H322Caps (OOCTXT* pctxt, H225H322Caps* pvalue); /**************************************************************/ /* */ /* H323Caps */ /* */ /**************************************************************/ typedef struct EXTERN H225H323Caps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225H323Caps; EXTERN int asn1PE_H225H323Caps (OOCTXT* pctxt, H225H323Caps* pvalue); EXTERN int asn1PD_H225H323Caps (OOCTXT* pctxt, H225H323Caps* pvalue); /**************************************************************/ /* */ /* H324Caps */ /* */ /**************************************************************/ typedef struct EXTERN H225H324Caps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225H324Caps; EXTERN int asn1PE_H225H324Caps (OOCTXT* pctxt, H225H324Caps* pvalue); EXTERN int asn1PD_H225H324Caps (OOCTXT* pctxt, H225H324Caps* pvalue); /**************************************************************/ /* */ /* VoiceCaps */ /* */ /**************************************************************/ typedef struct EXTERN H225VoiceCaps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225VoiceCaps; EXTERN int asn1PE_H225VoiceCaps (OOCTXT* pctxt, H225VoiceCaps* pvalue); EXTERN int asn1PD_H225VoiceCaps (OOCTXT* pctxt, H225VoiceCaps* pvalue); /**************************************************************/ /* */ /* T120OnlyCaps */ /* */ /**************************************************************/ typedef struct EXTERN H225T120OnlyCaps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225T120OnlyCaps; EXTERN int asn1PE_H225T120OnlyCaps (OOCTXT* pctxt, H225T120OnlyCaps* pvalue); EXTERN int asn1PD_H225T120OnlyCaps (OOCTXT* pctxt, H225T120OnlyCaps* pvalue); /**************************************************************/ /* */ /* NonStandardProtocol */ /* */ /**************************************************************/ typedef struct EXTERN H225NonStandardProtocol { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225NonStandardProtocol; EXTERN int asn1PE_H225NonStandardProtocol (OOCTXT* pctxt, H225NonStandardProtocol* pvalue); EXTERN int asn1PD_H225NonStandardProtocol (OOCTXT* pctxt, H225NonStandardProtocol* pvalue); /**************************************************************/ /* */ /* T38FaxAnnexbOnlyCaps */ /* */ /**************************************************************/ typedef struct EXTERN H225T38FaxAnnexbOnlyCaps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; H245DataProtocolCapability t38FaxProtocol; H245T38FaxProfile t38FaxProfile; } H225T38FaxAnnexbOnlyCaps; EXTERN int asn1PE_H225T38FaxAnnexbOnlyCaps (OOCTXT* pctxt, H225T38FaxAnnexbOnlyCaps* pvalue); EXTERN int asn1PD_H225T38FaxAnnexbOnlyCaps (OOCTXT* pctxt, H225T38FaxAnnexbOnlyCaps* pvalue); /**************************************************************/ /* */ /* SIPCaps */ /* */ /**************************************************************/ typedef struct EXTERN H225SIPCaps { struct { unsigned nonStandardDataPresent : 1; unsigned dataRatesSupportedPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225DataRate dataRatesSupported; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225SIPCaps; EXTERN int asn1PE_H225SIPCaps (OOCTXT* pctxt, H225SIPCaps* pvalue); EXTERN int asn1PD_H225SIPCaps (OOCTXT* pctxt, H225SIPCaps* pvalue); /**************************************************************/ /* */ /* SupportedProtocols */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225SupportedProtocols_nonStandardData 1 #define T_H225SupportedProtocols_h310 2 #define T_H225SupportedProtocols_h320 3 #define T_H225SupportedProtocols_h321 4 #define T_H225SupportedProtocols_h322 5 #define T_H225SupportedProtocols_h323 6 #define T_H225SupportedProtocols_h324 7 #define T_H225SupportedProtocols_voice 8 #define T_H225SupportedProtocols_t120_only 9 #define T_H225SupportedProtocols_nonStandardProtocol 10 #define T_H225SupportedProtocols_t38FaxAnnexbOnly 11 #define T_H225SupportedProtocols_sip 12 #define T_H225SupportedProtocols_extElem1 13 typedef struct EXTERN H225SupportedProtocols { int t; union { /* t = 1 */ H225NonStandardParameter *nonStandardData; /* t = 2 */ H225H310Caps *h310; /* t = 3 */ H225H320Caps *h320; /* t = 4 */ H225H321Caps *h321; /* t = 5 */ H225H322Caps *h322; /* t = 6 */ H225H323Caps *h323; /* t = 7 */ H225H324Caps *h324; /* t = 8 */ H225VoiceCaps *voice; /* t = 9 */ H225T120OnlyCaps *t120_only; /* t = 10 */ H225NonStandardProtocol *nonStandardProtocol; /* t = 11 */ H225T38FaxAnnexbOnlyCaps *t38FaxAnnexbOnly; /* t = 12 */ H225SIPCaps *sip; /* t = 13 */ } u; } H225SupportedProtocols; EXTERN int asn1PE_H225SupportedProtocols (OOCTXT* pctxt, H225SupportedProtocols* pvalue); EXTERN int asn1PD_H225SupportedProtocols (OOCTXT* pctxt, H225SupportedProtocols* pvalue); /**************************************************************/ /* */ /* _SeqOfH225SupportedProtocols */ /* */ /**************************************************************/ /* List of H225SupportedProtocols */ typedef DList H225_SeqOfH225SupportedProtocols; EXTERN int asn1PE_H225_SeqOfH225SupportedProtocols (OOCTXT* pctxt, H225_SeqOfH225SupportedProtocols* pvalue); EXTERN int asn1PD_H225_SeqOfH225SupportedProtocols (OOCTXT* pctxt, H225_SeqOfH225SupportedProtocols* pvalue); /**************************************************************/ /* */ /* GatewayInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225GatewayInfo { struct { unsigned protocolPresent : 1; unsigned nonStandardDataPresent : 1; } m; H225_SeqOfH225SupportedProtocols protocol; H225NonStandardParameter nonStandardData; } H225GatewayInfo; EXTERN int asn1PE_H225GatewayInfo (OOCTXT* pctxt, H225GatewayInfo* pvalue); EXTERN int asn1PD_H225GatewayInfo (OOCTXT* pctxt, H225GatewayInfo* pvalue); /**************************************************************/ /* */ /* McuInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225McuInfo { struct { unsigned nonStandardDataPresent : 1; unsigned protocolPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225SupportedProtocols protocol; } H225McuInfo; EXTERN int asn1PE_H225McuInfo (OOCTXT* pctxt, H225McuInfo* pvalue); EXTERN int asn1PD_H225McuInfo (OOCTXT* pctxt, H225McuInfo* pvalue); /**************************************************************/ /* */ /* TerminalInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225TerminalInfo { struct { unsigned nonStandardDataPresent : 1; } m; H225NonStandardParameter nonStandardData; } H225TerminalInfo; EXTERN int asn1PE_H225TerminalInfo (OOCTXT* pctxt, H225TerminalInfo* pvalue); EXTERN int asn1PD_H225TerminalInfo (OOCTXT* pctxt, H225TerminalInfo* pvalue); /**************************************************************/ /* */ /* TunnelledProtocolAlternateIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H225TunnelledProtocolAlternateIdentifier { struct { unsigned protocolVariantPresent : 1; } m; ASN1IA5String protocolType; ASN1IA5String protocolVariant; } H225TunnelledProtocolAlternateIdentifier; EXTERN int asn1PE_H225TunnelledProtocolAlternateIdentifier (OOCTXT* pctxt, H225TunnelledProtocolAlternateIdentifier* pvalue); EXTERN int asn1PD_H225TunnelledProtocolAlternateIdentifier (OOCTXT* pctxt, H225TunnelledProtocolAlternateIdentifier* pvalue); /**************************************************************/ /* */ /* TunnelledProtocol_id */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225TunnelledProtocol_id_tunnelledProtocolObjectID 1 #define T_H225TunnelledProtocol_id_tunnelledProtocolAlternateID 2 #define T_H225TunnelledProtocol_id_extElem1 3 typedef struct EXTERN H225TunnelledProtocol_id { int t; union { /* t = 1 */ ASN1OBJID *tunnelledProtocolObjectID; /* t = 2 */ H225TunnelledProtocolAlternateIdentifier *tunnelledProtocolAlternateID; /* t = 3 */ } u; } H225TunnelledProtocol_id; EXTERN int asn1PE_H225TunnelledProtocol_id (OOCTXT* pctxt, H225TunnelledProtocol_id* pvalue); EXTERN int asn1PD_H225TunnelledProtocol_id (OOCTXT* pctxt, H225TunnelledProtocol_id* pvalue); /**************************************************************/ /* */ /* TunnelledProtocol */ /* */ /**************************************************************/ typedef struct EXTERN H225TunnelledProtocol { struct { unsigned subIdentifierPresent : 1; } m; H225TunnelledProtocol_id id; ASN1IA5String subIdentifier; } H225TunnelledProtocol; EXTERN int asn1PE_H225TunnelledProtocol (OOCTXT* pctxt, H225TunnelledProtocol* pvalue); EXTERN int asn1PD_H225TunnelledProtocol (OOCTXT* pctxt, H225TunnelledProtocol* pvalue); /**************************************************************/ /* */ /* _SeqOfH225TunnelledProtocol */ /* */ /**************************************************************/ /* List of H225TunnelledProtocol */ typedef DList H225_SeqOfH225TunnelledProtocol; EXTERN int asn1PE_H225_SeqOfH225TunnelledProtocol (OOCTXT* pctxt, H225_SeqOfH225TunnelledProtocol* pvalue); EXTERN int asn1PD_H225_SeqOfH225TunnelledProtocol (OOCTXT* pctxt, H225_SeqOfH225TunnelledProtocol* pvalue); /**************************************************************/ /* */ /* EndpointType */ /* */ /**************************************************************/ typedef struct EXTERN H225EndpointType { struct { unsigned nonStandardDataPresent : 1; unsigned vendorPresent : 1; unsigned gatekeeperPresent : 1; unsigned gatewayPresent : 1; unsigned mcuPresent : 1; unsigned terminalPresent : 1; unsigned setPresent : 1; unsigned supportedTunnelledProtocolsPresent : 1; } m; H225NonStandardParameter nonStandardData; H225VendorIdentifier vendor; H225GatekeeperInfo gatekeeper; H225GatewayInfo gateway; H225McuInfo mcu; H225TerminalInfo terminal; ASN1BOOL mc; ASN1BOOL undefinedNode; H225EndpointType_set set; H225_SeqOfH225TunnelledProtocol supportedTunnelledProtocols; } H225EndpointType; EXTERN int asn1PE_H225EndpointType (OOCTXT* pctxt, H225EndpointType* pvalue); EXTERN int asn1PD_H225EndpointType (OOCTXT* pctxt, H225EndpointType* pvalue); /**************************************************************/ /* */ /* _SeqOfH225CallReferenceValue */ /* */ /**************************************************************/ typedef struct EXTERN H225_SeqOfH225CallReferenceValue { ASN1UINT n; H225CallReferenceValue *elem; } H225_SeqOfH225CallReferenceValue; EXTERN int asn1PE_H225_SeqOfH225CallReferenceValue (OOCTXT* pctxt, H225_SeqOfH225CallReferenceValue* pvalue); EXTERN int asn1PD_H225_SeqOfH225CallReferenceValue (OOCTXT* pctxt, H225_SeqOfH225CallReferenceValue* pvalue); /**************************************************************/ /* */ /* Setup_UUIE_conferenceGoal */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225Setup_UUIE_conferenceGoal_create 1 #define T_H225Setup_UUIE_conferenceGoal_join 2 #define T_H225Setup_UUIE_conferenceGoal_invite 3 #define T_H225Setup_UUIE_conferenceGoal_capability_negotiation 4 #define T_H225Setup_UUIE_conferenceGoal_callIndependentSupplementaryService 5 #define T_H225Setup_UUIE_conferenceGoal_extElem1 6 typedef struct EXTERN H225Setup_UUIE_conferenceGoal { int t; } H225Setup_UUIE_conferenceGoal; EXTERN int asn1PE_H225Setup_UUIE_conferenceGoal (OOCTXT* pctxt, H225Setup_UUIE_conferenceGoal* pvalue); EXTERN int asn1PD_H225Setup_UUIE_conferenceGoal (OOCTXT* pctxt, H225Setup_UUIE_conferenceGoal* pvalue); /**************************************************************/ /* */ /* Q954Details */ /* */ /**************************************************************/ typedef struct EXTERN H225Q954Details { ASN1BOOL conferenceCalling; ASN1BOOL threePartyService; } H225Q954Details; EXTERN int asn1PE_H225Q954Details (OOCTXT* pctxt, H225Q954Details* pvalue); EXTERN int asn1PD_H225Q954Details (OOCTXT* pctxt, H225Q954Details* pvalue); /**************************************************************/ /* */ /* QseriesOptions */ /* */ /**************************************************************/ typedef struct EXTERN H225QseriesOptions { ASN1BOOL q932Full; ASN1BOOL q951Full; ASN1BOOL q952Full; ASN1BOOL q953Full; ASN1BOOL q955Full; ASN1BOOL q956Full; ASN1BOOL q957Full; H225Q954Details q954Info; } H225QseriesOptions; EXTERN int asn1PE_H225QseriesOptions (OOCTXT* pctxt, H225QseriesOptions* pvalue); EXTERN int asn1PD_H225QseriesOptions (OOCTXT* pctxt, H225QseriesOptions* pvalue); /**************************************************************/ /* */ /* CallType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225CallType_pointToPoint 1 #define T_H225CallType_oneToN 2 #define T_H225CallType_nToOne 3 #define T_H225CallType_nToN 4 #define T_H225CallType_extElem1 5 typedef struct EXTERN H225CallType { int t; } H225CallType; EXTERN int asn1PE_H225CallType (OOCTXT* pctxt, H225CallType* pvalue); EXTERN int asn1PD_H225CallType (OOCTXT* pctxt, H225CallType* pvalue); /**************************************************************/ /* */ /* CallIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H225CallIdentifier { H225GloballyUniqueID guid; } H225CallIdentifier; EXTERN int asn1PE_H225CallIdentifier (OOCTXT* pctxt, H225CallIdentifier* pvalue); EXTERN int asn1PD_H225CallIdentifier (OOCTXT* pctxt, H225CallIdentifier* pvalue); /**************************************************************/ /* */ /* SecurityServiceMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225SecurityServiceMode_nonStandard 1 #define T_H225SecurityServiceMode_none 2 #define T_H225SecurityServiceMode_default_ 3 #define T_H225SecurityServiceMode_extElem1 4 typedef struct EXTERN H225SecurityServiceMode { int t; union { /* t = 1 */ H225NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ /* t = 4 */ } u; } H225SecurityServiceMode; EXTERN int asn1PE_H225SecurityServiceMode (OOCTXT* pctxt, H225SecurityServiceMode* pvalue); EXTERN int asn1PD_H225SecurityServiceMode (OOCTXT* pctxt, H225SecurityServiceMode* pvalue); /**************************************************************/ /* */ /* SecurityCapabilities */ /* */ /**************************************************************/ typedef struct EXTERN H225SecurityCapabilities { struct { unsigned nonStandardPresent : 1; } m; H225NonStandardParameter nonStandard; H225SecurityServiceMode encryption; H225SecurityServiceMode authenticaton; H225SecurityServiceMode integrity; } H225SecurityCapabilities; EXTERN int asn1PE_H225SecurityCapabilities (OOCTXT* pctxt, H225SecurityCapabilities* pvalue); EXTERN int asn1PD_H225SecurityCapabilities (OOCTXT* pctxt, H225SecurityCapabilities* pvalue); /**************************************************************/ /* */ /* H245Security */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225H245Security_nonStandard 1 #define T_H225H245Security_noSecurity 2 #define T_H225H245Security_tls 3 #define T_H225H245Security_ipsec 4 #define T_H225H245Security_extElem1 5 typedef struct EXTERN H225H245Security { int t; union { /* t = 1 */ H225NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ H225SecurityCapabilities *tls; /* t = 4 */ H225SecurityCapabilities *ipsec; /* t = 5 */ } u; } H225H245Security; EXTERN int asn1PE_H225H245Security (OOCTXT* pctxt, H225H245Security* pvalue); EXTERN int asn1PD_H225H245Security (OOCTXT* pctxt, H225H245Security* pvalue); /**************************************************************/ /* */ /* _SeqOfH225H245Security */ /* */ /**************************************************************/ /* List of H225H245Security */ typedef DList H225_SeqOfH225H245Security; EXTERN int asn1PE_H225_SeqOfH225H245Security (OOCTXT* pctxt, H225_SeqOfH225H245Security* pvalue); EXTERN int asn1PD_H225_SeqOfH225H245Security (OOCTXT* pctxt, H225_SeqOfH225H245Security* pvalue); /**************************************************************/ /* */ /* _SeqOfH225ClearToken */ /* */ /**************************************************************/ /* List of H235ClearToken */ typedef DList H225_SeqOfH225ClearToken; EXTERN int asn1PE_H225_SeqOfH225ClearToken (OOCTXT* pctxt, H225_SeqOfH225ClearToken* pvalue); EXTERN int asn1PD_H225_SeqOfH225ClearToken (OOCTXT* pctxt, H225_SeqOfH225ClearToken* pvalue); /**************************************************************/ /* */ /* CryptoH323Token_cryptoEPPwdHash */ /* */ /**************************************************************/ typedef struct EXTERN H225CryptoH323Token_cryptoEPPwdHash { H225AliasAddress alias; H235TimeStamp timeStamp; H235HASHED token; } H225CryptoH323Token_cryptoEPPwdHash; EXTERN int asn1PE_H225CryptoH323Token_cryptoEPPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPPwdHash* pvalue); EXTERN int asn1PD_H225CryptoH323Token_cryptoEPPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPPwdHash* pvalue); /**************************************************************/ /* */ /* CryptoH323Token_cryptoGKPwdHash */ /* */ /**************************************************************/ typedef struct EXTERN H225CryptoH323Token_cryptoGKPwdHash { H225GatekeeperIdentifier gatekeeperId; H235TimeStamp timeStamp; H235HASHED token; } H225CryptoH323Token_cryptoGKPwdHash; EXTERN int asn1PE_H225CryptoH323Token_cryptoGKPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKPwdHash* pvalue); EXTERN int asn1PD_H225CryptoH323Token_cryptoGKPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKPwdHash* pvalue); /**************************************************************/ /* */ /* CryptoH323Token_cryptoEPCert */ /* */ /**************************************************************/ typedef struct EXTERN H225CryptoH323Token_cryptoEPCert { H235EncodedPwdCertToken toBeSigned; ASN1OBJID algorithmOID; H235Params paramS; ASN1DynBitStr signature; } H225CryptoH323Token_cryptoEPCert; EXTERN int asn1PE_H225CryptoH323Token_cryptoEPCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPCert* pvalue); EXTERN int asn1PD_H225CryptoH323Token_cryptoEPCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPCert* pvalue); /**************************************************************/ /* */ /* CryptoH323Token_cryptoGKCert */ /* */ /**************************************************************/ typedef struct EXTERN H225CryptoH323Token_cryptoGKCert { H235EncodedPwdCertToken toBeSigned; ASN1OBJID algorithmOID; H235Params paramS; ASN1DynBitStr signature; } H225CryptoH323Token_cryptoGKCert; EXTERN int asn1PE_H225CryptoH323Token_cryptoGKCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKCert* pvalue); EXTERN int asn1PD_H225CryptoH323Token_cryptoGKCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKCert* pvalue); /**************************************************************/ /* */ /* CryptoH323Token_cryptoFastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225CryptoH323Token_cryptoFastStart { H225EncodedFastStartToken toBeSigned; ASN1OBJID algorithmOID; H235Params paramS; ASN1DynBitStr signature; } H225CryptoH323Token_cryptoFastStart; EXTERN int asn1PE_H225CryptoH323Token_cryptoFastStart (OOCTXT* pctxt, H225CryptoH323Token_cryptoFastStart* pvalue); EXTERN int asn1PD_H225CryptoH323Token_cryptoFastStart (OOCTXT* pctxt, H225CryptoH323Token_cryptoFastStart* pvalue); /**************************************************************/ /* */ /* CryptoH323Token */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225CryptoH323Token_cryptoEPPwdHash 1 #define T_H225CryptoH323Token_cryptoGKPwdHash 2 #define T_H225CryptoH323Token_cryptoEPPwdEncr 3 #define T_H225CryptoH323Token_cryptoGKPwdEncr 4 #define T_H225CryptoH323Token_cryptoEPCert 5 #define T_H225CryptoH323Token_cryptoGKCert 6 #define T_H225CryptoH323Token_cryptoFastStart 7 #define T_H225CryptoH323Token_nestedcryptoToken 8 #define T_H225CryptoH323Token_extElem1 9 typedef struct EXTERN H225CryptoH323Token { int t; union { /* t = 1 */ H225CryptoH323Token_cryptoEPPwdHash *cryptoEPPwdHash; /* t = 2 */ H225CryptoH323Token_cryptoGKPwdHash *cryptoGKPwdHash; /* t = 3 */ H235ENCRYPTED *cryptoEPPwdEncr; /* t = 4 */ H235ENCRYPTED *cryptoGKPwdEncr; /* t = 5 */ H225CryptoH323Token_cryptoEPCert *cryptoEPCert; /* t = 6 */ H225CryptoH323Token_cryptoGKCert *cryptoGKCert; /* t = 7 */ H225CryptoH323Token_cryptoFastStart *cryptoFastStart; /* t = 8 */ H235CryptoToken *nestedcryptoToken; /* t = 9 */ } u; } H225CryptoH323Token; EXTERN int asn1PE_H225CryptoH323Token (OOCTXT* pctxt, H225CryptoH323Token* pvalue); EXTERN int asn1PD_H225CryptoH323Token (OOCTXT* pctxt, H225CryptoH323Token* pvalue); /**************************************************************/ /* */ /* _SeqOfH225CryptoH323Token */ /* */ /**************************************************************/ /* List of H225CryptoH323Token */ typedef DList H225_SeqOfH225CryptoH323Token; EXTERN int asn1PE_H225_SeqOfH225CryptoH323Token (OOCTXT* pctxt, H225_SeqOfH225CryptoH323Token* pvalue); EXTERN int asn1PD_H225_SeqOfH225CryptoH323Token (OOCTXT* pctxt, H225_SeqOfH225CryptoH323Token* pvalue); /**************************************************************/ /* */ /* Setup_UUIE_fastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225Setup_UUIE_fastStart { ASN1UINT n; ASN1DynOctStr *elem; } H225Setup_UUIE_fastStart; EXTERN int asn1PE_H225Setup_UUIE_fastStart (OOCTXT* pctxt, H225Setup_UUIE_fastStart* pvalue); EXTERN int asn1PD_H225Setup_UUIE_fastStart (OOCTXT* pctxt, H225Setup_UUIE_fastStart* pvalue); /**************************************************************/ /* */ /* ScnConnectionType */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225ScnConnectionType_unknown 1 #define T_H225ScnConnectionType_bChannel 2 #define T_H225ScnConnectionType_hybrid2x64 3 #define T_H225ScnConnectionType_hybrid384 4 #define T_H225ScnConnectionType_hybrid1536 5 #define T_H225ScnConnectionType_hybrid1920 6 #define T_H225ScnConnectionType_multirate 7 #define T_H225ScnConnectionType_extElem1 8 typedef struct EXTERN H225ScnConnectionType { int t; } H225ScnConnectionType; EXTERN int asn1PE_H225ScnConnectionType (OOCTXT* pctxt, H225ScnConnectionType* pvalue); EXTERN int asn1PD_H225ScnConnectionType (OOCTXT* pctxt, H225ScnConnectionType* pvalue); /**************************************************************/ /* */ /* ScnConnectionAggregation */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225ScnConnectionAggregation_auto_ 1 #define T_H225ScnConnectionAggregation_none 2 #define T_H225ScnConnectionAggregation_h221 3 #define T_H225ScnConnectionAggregation_bonded_mode1 4 #define T_H225ScnConnectionAggregation_bonded_mode2 5 #define T_H225ScnConnectionAggregation_bonded_mode3 6 #define T_H225ScnConnectionAggregation_extElem1 7 typedef struct EXTERN H225ScnConnectionAggregation { int t; } H225ScnConnectionAggregation; EXTERN int asn1PE_H225ScnConnectionAggregation (OOCTXT* pctxt, H225ScnConnectionAggregation* pvalue); EXTERN int asn1PD_H225ScnConnectionAggregation (OOCTXT* pctxt, H225ScnConnectionAggregation* pvalue); /**************************************************************/ /* */ /* Setup_UUIE_connectionParameters */ /* */ /**************************************************************/ typedef struct EXTERN H225Setup_UUIE_connectionParameters { H225ScnConnectionType connectionType; ASN1USINT numberOfScnConnections; H225ScnConnectionAggregation connectionAggregation; } H225Setup_UUIE_connectionParameters; EXTERN int asn1PE_H225Setup_UUIE_connectionParameters (OOCTXT* pctxt, H225Setup_UUIE_connectionParameters* pvalue); EXTERN int asn1PD_H225Setup_UUIE_connectionParameters (OOCTXT* pctxt, H225Setup_UUIE_connectionParameters* pvalue); /**************************************************************/ /* */ /* Setup_UUIE_language */ /* */ /**************************************************************/ typedef struct EXTERN H225Setup_UUIE_language { ASN1UINT n; ASN1IA5String *elem; } H225Setup_UUIE_language; EXTERN int asn1PE_H225Setup_UUIE_language (OOCTXT* pctxt, H225Setup_UUIE_language* pvalue); EXTERN int asn1PD_H225Setup_UUIE_language (OOCTXT* pctxt, H225Setup_UUIE_language* pvalue); /**************************************************************/ /* */ /* PresentationIndicator */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225PresentationIndicator_presentationAllowed 1 #define T_H225PresentationIndicator_presentationRestricted 2 #define T_H225PresentationIndicator_addressNotAvailable 3 #define T_H225PresentationIndicator_extElem1 4 typedef struct EXTERN H225PresentationIndicator { int t; } H225PresentationIndicator; EXTERN int asn1PE_H225PresentationIndicator (OOCTXT* pctxt, H225PresentationIndicator* pvalue); EXTERN int asn1PD_H225PresentationIndicator (OOCTXT* pctxt, H225PresentationIndicator* pvalue); /**************************************************************/ /* */ /* CallCreditServiceControl_billingMode */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225CallCreditServiceControl_billingMode_credit 1 #define T_H225CallCreditServiceControl_billingMode_debit 2 #define T_H225CallCreditServiceControl_billingMode_extElem1 3 typedef struct EXTERN H225CallCreditServiceControl_billingMode { int t; } H225CallCreditServiceControl_billingMode; EXTERN int asn1PE_H225CallCreditServiceControl_billingMode (OOCTXT* pctxt, H225CallCreditServiceControl_billingMode* pvalue); EXTERN int asn1PD_H225CallCreditServiceControl_billingMode (OOCTXT* pctxt, H225CallCreditServiceControl_billingMode* pvalue); /**************************************************************/ /* */ /* CallCreditServiceControl_callStartingPoint */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225CallCreditServiceControl_callStartingPoint_alerting 1 #define T_H225CallCreditServiceControl_callStartingPoint_connect 2 #define T_H225CallCreditServiceControl_callStartingPoint_extElem1 3 typedef struct EXTERN H225CallCreditServiceControl_callStartingPoint { int t; } H225CallCreditServiceControl_callStartingPoint; EXTERN int asn1PE_H225CallCreditServiceControl_callStartingPoint (OOCTXT* pctxt, H225CallCreditServiceControl_callStartingPoint* pvalue); EXTERN int asn1PD_H225CallCreditServiceControl_callStartingPoint (OOCTXT* pctxt, H225CallCreditServiceControl_callStartingPoint* pvalue); /**************************************************************/ /* */ /* CallCreditServiceControl */ /* */ /**************************************************************/ typedef struct EXTERN H225CallCreditServiceControl { struct { unsigned amountStringPresent : 1; unsigned billingModePresent : 1; unsigned callDurationLimitPresent : 1; unsigned enforceCallDurationLimitPresent : 1; unsigned callStartingPointPresent : 1; } m; ASN1BMPString amountString; H225CallCreditServiceControl_billingMode billingMode; ASN1UINT callDurationLimit; ASN1BOOL enforceCallDurationLimit; H225CallCreditServiceControl_callStartingPoint callStartingPoint; } H225CallCreditServiceControl; EXTERN int asn1PE_H225CallCreditServiceControl (OOCTXT* pctxt, H225CallCreditServiceControl* pvalue); EXTERN int asn1PD_H225CallCreditServiceControl (OOCTXT* pctxt, H225CallCreditServiceControl* pvalue); /**************************************************************/ /* */ /* ServiceControlDescriptor */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225ServiceControlDescriptor_url 1 #define T_H225ServiceControlDescriptor_signal 2 #define T_H225ServiceControlDescriptor_nonStandard 3 #define T_H225ServiceControlDescriptor_callCreditServiceControl 4 #define T_H225ServiceControlDescriptor_extElem1 5 typedef struct EXTERN H225ServiceControlDescriptor { int t; union { /* t = 1 */ ASN1IA5String url; /* t = 2 */ H225H248SignalsDescriptor *signal; /* t = 3 */ H225NonStandardParameter *nonStandard; /* t = 4 */ H225CallCreditServiceControl *callCreditServiceControl; /* t = 5 */ } u; } H225ServiceControlDescriptor; EXTERN int asn1PE_H225ServiceControlDescriptor (OOCTXT* pctxt, H225ServiceControlDescriptor* pvalue); EXTERN int asn1PD_H225ServiceControlDescriptor (OOCTXT* pctxt, H225ServiceControlDescriptor* pvalue); /**************************************************************/ /* */ /* ServiceControlSession_reason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225ServiceControlSession_reason_open 1 #define T_H225ServiceControlSession_reason_refresh 2 #define T_H225ServiceControlSession_reason_close 3 #define T_H225ServiceControlSession_reason_extElem1 4 typedef struct EXTERN H225ServiceControlSession_reason { int t; } H225ServiceControlSession_reason; EXTERN int asn1PE_H225ServiceControlSession_reason (OOCTXT* pctxt, H225ServiceControlSession_reason* pvalue); EXTERN int asn1PD_H225ServiceControlSession_reason (OOCTXT* pctxt, H225ServiceControlSession_reason* pvalue); /**************************************************************/ /* */ /* ServiceControlSession */ /* */ /**************************************************************/ typedef struct EXTERN H225ServiceControlSession { struct { unsigned contentsPresent : 1; } m; ASN1UINT8 sessionId; H225ServiceControlDescriptor contents; H225ServiceControlSession_reason reason; } H225ServiceControlSession; EXTERN int asn1PE_H225ServiceControlSession (OOCTXT* pctxt, H225ServiceControlSession* pvalue); EXTERN int asn1PD_H225ServiceControlSession (OOCTXT* pctxt, H225ServiceControlSession* pvalue); /**************************************************************/ /* */ /* _SeqOfH225ServiceControlSession */ /* */ /**************************************************************/ /* List of H225ServiceControlSession */ typedef DList H225_SeqOfH225ServiceControlSession; EXTERN int asn1PE_H225_SeqOfH225ServiceControlSession (OOCTXT* pctxt, H225_SeqOfH225ServiceControlSession* pvalue); EXTERN int asn1PD_H225_SeqOfH225ServiceControlSession (OOCTXT* pctxt, H225_SeqOfH225ServiceControlSession* pvalue); /**************************************************************/ /* */ /* CarrierInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225CarrierInfo { struct { unsigned carrierIdentificationCodePresent : 1; unsigned carrierNamePresent : 1; } m; H225CarrierInfo_carrierIdentificationCode carrierIdentificationCode; ASN1IA5String carrierName; } H225CarrierInfo; EXTERN int asn1PE_H225CarrierInfo (OOCTXT* pctxt, H225CarrierInfo* pvalue); EXTERN int asn1PD_H225CarrierInfo (OOCTXT* pctxt, H225CarrierInfo* pvalue); /**************************************************************/ /* */ /* CallsAvailable */ /* */ /**************************************************************/ typedef struct EXTERN H225CallsAvailable { struct { unsigned groupPresent : 1; unsigned carrierPresent : 1; } m; ASN1UINT calls; ASN1IA5String group; H225CarrierInfo carrier; } H225CallsAvailable; EXTERN int asn1PE_H225CallsAvailable (OOCTXT* pctxt, H225CallsAvailable* pvalue); EXTERN int asn1PD_H225CallsAvailable (OOCTXT* pctxt, H225CallsAvailable* pvalue); /**************************************************************/ /* */ /* _SeqOfH225CallsAvailable */ /* */ /**************************************************************/ /* List of H225CallsAvailable */ typedef DList H225_SeqOfH225CallsAvailable; EXTERN int asn1PE_H225_SeqOfH225CallsAvailable (OOCTXT* pctxt, H225_SeqOfH225CallsAvailable* pvalue); EXTERN int asn1PD_H225_SeqOfH225CallsAvailable (OOCTXT* pctxt, H225_SeqOfH225CallsAvailable* pvalue); /**************************************************************/ /* */ /* CallCapacityInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225CallCapacityInfo { struct { unsigned voiceGwCallsAvailablePresent : 1; unsigned h310GwCallsAvailablePresent : 1; unsigned h320GwCallsAvailablePresent : 1; unsigned h321GwCallsAvailablePresent : 1; unsigned h322GwCallsAvailablePresent : 1; unsigned h323GwCallsAvailablePresent : 1; unsigned h324GwCallsAvailablePresent : 1; unsigned t120OnlyGwCallsAvailablePresent : 1; unsigned t38FaxAnnexbOnlyGwCallsAvailablePresent : 1; unsigned terminalCallsAvailablePresent : 1; unsigned mcuCallsAvailablePresent : 1; unsigned sipGwCallsAvailablePresent : 1; } m; H225_SeqOfH225CallsAvailable voiceGwCallsAvailable; H225_SeqOfH225CallsAvailable h310GwCallsAvailable; H225_SeqOfH225CallsAvailable h320GwCallsAvailable; H225_SeqOfH225CallsAvailable h321GwCallsAvailable; H225_SeqOfH225CallsAvailable h322GwCallsAvailable; H225_SeqOfH225CallsAvailable h323GwCallsAvailable; H225_SeqOfH225CallsAvailable h324GwCallsAvailable; H225_SeqOfH225CallsAvailable t120OnlyGwCallsAvailable; H225_SeqOfH225CallsAvailable t38FaxAnnexbOnlyGwCallsAvailable; H225_SeqOfH225CallsAvailable terminalCallsAvailable; H225_SeqOfH225CallsAvailable mcuCallsAvailable; H225_SeqOfH225CallsAvailable sipGwCallsAvailable; } H225CallCapacityInfo; EXTERN int asn1PE_H225CallCapacityInfo (OOCTXT* pctxt, H225CallCapacityInfo* pvalue); EXTERN int asn1PD_H225CallCapacityInfo (OOCTXT* pctxt, H225CallCapacityInfo* pvalue); /**************************************************************/ /* */ /* CallCapacity */ /* */ /**************************************************************/ typedef struct EXTERN H225CallCapacity { struct { unsigned maximumCallCapacityPresent : 1; unsigned currentCallCapacityPresent : 1; } m; H225CallCapacityInfo maximumCallCapacity; H225CallCapacityInfo currentCallCapacity; } H225CallCapacity; EXTERN int asn1PE_H225CallCapacity (OOCTXT* pctxt, H225CallCapacity* pvalue); EXTERN int asn1PD_H225CallCapacity (OOCTXT* pctxt, H225CallCapacity* pvalue); /**************************************************************/ /* */ /* _SeqOfH225CicInfo_cic_element */ /* */ /**************************************************************/ typedef struct EXTERN H225_SeqOfH225CicInfo_cic_element { ASN1UINT n; H225CicInfo_cic_element *elem; } H225_SeqOfH225CicInfo_cic_element; EXTERN int asn1PE_H225_SeqOfH225CicInfo_cic_element (OOCTXT* pctxt, H225_SeqOfH225CicInfo_cic_element* pvalue); EXTERN int asn1PD_H225_SeqOfH225CicInfo_cic_element (OOCTXT* pctxt, H225_SeqOfH225CicInfo_cic_element* pvalue); /**************************************************************/ /* */ /* CicInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225CicInfo { H225_SeqOfH225CicInfo_cic_element cic; H225CicInfo_pointCode pointCode; } H225CicInfo; EXTERN int asn1PE_H225CicInfo (OOCTXT* pctxt, H225CicInfo* pvalue); EXTERN int asn1PD_H225CicInfo (OOCTXT* pctxt, H225CicInfo* pvalue); /**************************************************************/ /* */ /* GroupID_member */ /* */ /**************************************************************/ typedef struct EXTERN H225GroupID_member { ASN1UINT n; ASN1USINT *elem; } H225GroupID_member; EXTERN int asn1PE_H225GroupID_member (OOCTXT* pctxt, H225GroupID_member* pvalue); EXTERN int asn1PD_H225GroupID_member (OOCTXT* pctxt, H225GroupID_member* pvalue); /**************************************************************/ /* */ /* GroupID */ /* */ /**************************************************************/ typedef struct EXTERN H225GroupID { struct { unsigned memberPresent : 1; } m; H225GroupID_member member; ASN1IA5String group; } H225GroupID; EXTERN int asn1PE_H225GroupID (OOCTXT* pctxt, H225GroupID* pvalue); EXTERN int asn1PD_H225GroupID (OOCTXT* pctxt, H225GroupID* pvalue); /**************************************************************/ /* */ /* CircuitIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H225CircuitIdentifier { struct { unsigned cicPresent : 1; unsigned groupPresent : 1; unsigned carrierPresent : 1; } m; H225CicInfo cic; H225GroupID group; H225CarrierInfo carrier; } H225CircuitIdentifier; EXTERN int asn1PE_H225CircuitIdentifier (OOCTXT* pctxt, H225CircuitIdentifier* pvalue); EXTERN int asn1PD_H225CircuitIdentifier (OOCTXT* pctxt, H225CircuitIdentifier* pvalue); /**************************************************************/ /* */ /* _SeqOfH225GenericData */ /* */ /**************************************************************/ /* List of H225GenericData */ typedef DList H225_SeqOfH225GenericData; EXTERN int asn1PE_H225_SeqOfH225GenericData (OOCTXT* pctxt, H225_SeqOfH225GenericData* pvalue); EXTERN int asn1PD_H225_SeqOfH225GenericData (OOCTXT* pctxt, H225_SeqOfH225GenericData* pvalue); /**************************************************************/ /* */ /* CircuitInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225CircuitInfo { struct { unsigned sourceCircuitIDPresent : 1; unsigned destinationCircuitIDPresent : 1; unsigned genericDataPresent : 1; } m; H225CircuitIdentifier sourceCircuitID; H225CircuitIdentifier destinationCircuitID; H225_SeqOfH225GenericData genericData; } H225CircuitInfo; EXTERN int asn1PE_H225CircuitInfo (OOCTXT* pctxt, H225CircuitInfo* pvalue); EXTERN int asn1PD_H225CircuitInfo (OOCTXT* pctxt, H225CircuitInfo* pvalue); /**************************************************************/ /* */ /* _SeqOfH225FeatureDescriptor */ /* */ /**************************************************************/ /* List of H225FeatureDescriptor */ typedef DList H225_SeqOfH225FeatureDescriptor; EXTERN int asn1PE_H225_SeqOfH225FeatureDescriptor (OOCTXT* pctxt, H225_SeqOfH225FeatureDescriptor* pvalue); EXTERN int asn1PD_H225_SeqOfH225FeatureDescriptor (OOCTXT* pctxt, H225_SeqOfH225FeatureDescriptor* pvalue); /**************************************************************/ /* */ /* Setup_UUIE_parallelH245Control */ /* */ /**************************************************************/ typedef struct EXTERN H225Setup_UUIE_parallelH245Control { ASN1UINT n; ASN1DynOctStr *elem; } H225Setup_UUIE_parallelH245Control; EXTERN int asn1PE_H225Setup_UUIE_parallelH245Control (OOCTXT* pctxt, H225Setup_UUIE_parallelH245Control* pvalue); EXTERN int asn1PD_H225Setup_UUIE_parallelH245Control (OOCTXT* pctxt, H225Setup_UUIE_parallelH245Control* pvalue); /**************************************************************/ /* */ /* ExtendedAliasAddress */ /* */ /**************************************************************/ typedef struct EXTERN H225ExtendedAliasAddress { struct { unsigned presentationIndicatorPresent : 1; unsigned screeningIndicatorPresent : 1; } m; H225AliasAddress address; H225PresentationIndicator presentationIndicator; H225ScreeningIndicator screeningIndicator; } H225ExtendedAliasAddress; EXTERN int asn1PE_H225ExtendedAliasAddress (OOCTXT* pctxt, H225ExtendedAliasAddress* pvalue); EXTERN int asn1PD_H225ExtendedAliasAddress (OOCTXT* pctxt, H225ExtendedAliasAddress* pvalue); /**************************************************************/ /* */ /* _SeqOfH225ExtendedAliasAddress */ /* */ /**************************************************************/ /* List of H225ExtendedAliasAddress */ typedef DList H225_SeqOfH225ExtendedAliasAddress; EXTERN int asn1PE_H225_SeqOfH225ExtendedAliasAddress (OOCTXT* pctxt, H225_SeqOfH225ExtendedAliasAddress* pvalue); EXTERN int asn1PD_H225_SeqOfH225ExtendedAliasAddress (OOCTXT* pctxt, H225_SeqOfH225ExtendedAliasAddress* pvalue); /**************************************************************/ /* */ /* Setup_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Setup_UUIE { struct { unsigned h245AddressPresent : 1; unsigned sourceAddressPresent : 1; unsigned destinationAddressPresent : 1; unsigned destCallSignalAddressPresent : 1; unsigned destExtraCallInfoPresent : 1; unsigned destExtraCRVPresent : 1; unsigned callServicesPresent : 1; unsigned sourceCallSignalAddressPresent : 1; unsigned remoteExtensionAddressPresent : 1; unsigned callIdentifierPresent : 1; unsigned h245SecurityCapabilityPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned fastStartPresent : 1; unsigned mediaWaitForConnectPresent : 1; unsigned canOverlapSendPresent : 1; unsigned endpointIdentifierPresent : 1; unsigned multipleCallsPresent : 1; unsigned maintainConnectionPresent : 1; unsigned connectionParametersPresent : 1; unsigned languagePresent : 1; unsigned presentationIndicatorPresent : 1; unsigned screeningIndicatorPresent : 1; unsigned serviceControlPresent : 1; unsigned symmetricOperationRequiredPresent : 1; unsigned capacityPresent : 1; unsigned circuitInfoPresent : 1; unsigned desiredProtocolsPresent : 1; unsigned neededFeaturesPresent : 1; unsigned desiredFeaturesPresent : 1; unsigned supportedFeaturesPresent : 1; unsigned parallelH245ControlPresent : 1; unsigned additionalSourceAddressesPresent : 1; unsigned hopCountPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225TransportAddress h245Address; H225_SeqOfH225AliasAddress sourceAddress; H225EndpointType sourceInfo; H225_SeqOfH225AliasAddress destinationAddress; H225TransportAddress destCallSignalAddress; H225_SeqOfH225AliasAddress destExtraCallInfo; H225_SeqOfH225CallReferenceValue destExtraCRV; ASN1BOOL activeMC; H225ConferenceIdentifier conferenceID; H225Setup_UUIE_conferenceGoal conferenceGoal; H225QseriesOptions callServices; H225CallType callType; H225TransportAddress sourceCallSignalAddress; H225AliasAddress remoteExtensionAddress; H225CallIdentifier callIdentifier; H225_SeqOfH225H245Security h245SecurityCapability; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225Setup_UUIE_fastStart fastStart; ASN1BOOL mediaWaitForConnect; ASN1BOOL canOverlapSend; H225EndpointIdentifier endpointIdentifier; ASN1BOOL multipleCalls; ASN1BOOL maintainConnection; H225Setup_UUIE_connectionParameters connectionParameters; H225Setup_UUIE_language language; H225PresentationIndicator presentationIndicator; H225ScreeningIndicator screeningIndicator; H225_SeqOfH225ServiceControlSession serviceControl; H225CallCapacity capacity; H225CircuitInfo circuitInfo; H225_SeqOfH225SupportedProtocols desiredProtocols; H225_SeqOfH225FeatureDescriptor neededFeatures; H225_SeqOfH225FeatureDescriptor desiredFeatures; H225_SeqOfH225FeatureDescriptor supportedFeatures; H225Setup_UUIE_parallelH245Control parallelH245Control; H225_SeqOfH225ExtendedAliasAddress additionalSourceAddresses; ASN1UINT8 hopCount; } H225Setup_UUIE; EXTERN int asn1PE_H225Setup_UUIE (OOCTXT* pctxt, H225Setup_UUIE* pvalue); EXTERN int asn1PD_H225Setup_UUIE (OOCTXT* pctxt, H225Setup_UUIE* pvalue); /**************************************************************/ /* */ /* CallProceeding_UUIE_fastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225CallProceeding_UUIE_fastStart { ASN1UINT n; ASN1DynOctStr *elem; } H225CallProceeding_UUIE_fastStart; EXTERN int asn1PE_H225CallProceeding_UUIE_fastStart (OOCTXT* pctxt, H225CallProceeding_UUIE_fastStart* pvalue); EXTERN int asn1PD_H225CallProceeding_UUIE_fastStart (OOCTXT* pctxt, H225CallProceeding_UUIE_fastStart* pvalue); /**************************************************************/ /* */ /* FeatureSet */ /* */ /**************************************************************/ typedef struct EXTERN H225FeatureSet { struct { unsigned neededFeaturesPresent : 1; unsigned desiredFeaturesPresent : 1; unsigned supportedFeaturesPresent : 1; } m; ASN1BOOL replacementFeatureSet; H225_SeqOfH225FeatureDescriptor neededFeatures; H225_SeqOfH225FeatureDescriptor desiredFeatures; H225_SeqOfH225FeatureDescriptor supportedFeatures; } H225FeatureSet; EXTERN int asn1PE_H225FeatureSet (OOCTXT* pctxt, H225FeatureSet* pvalue); EXTERN int asn1PD_H225FeatureSet (OOCTXT* pctxt, H225FeatureSet* pvalue); /**************************************************************/ /* */ /* CallProceeding_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225CallProceeding_UUIE { struct { unsigned h245AddressPresent : 1; unsigned callIdentifierPresent : 1; unsigned h245SecurityModePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned fastStartPresent : 1; unsigned multipleCallsPresent : 1; unsigned maintainConnectionPresent : 1; unsigned fastConnectRefusedPresent : 1; unsigned featureSetPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225EndpointType destinationInfo; H225TransportAddress h245Address; H225CallIdentifier callIdentifier; H225H245Security h245SecurityMode; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225CallProceeding_UUIE_fastStart fastStart; ASN1BOOL multipleCalls; ASN1BOOL maintainConnection; H225FeatureSet featureSet; } H225CallProceeding_UUIE; EXTERN int asn1PE_H225CallProceeding_UUIE (OOCTXT* pctxt, H225CallProceeding_UUIE* pvalue); EXTERN int asn1PD_H225CallProceeding_UUIE (OOCTXT* pctxt, H225CallProceeding_UUIE* pvalue); /**************************************************************/ /* */ /* Connect_UUIE_fastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225Connect_UUIE_fastStart { ASN1UINT n; ASN1DynOctStr *elem; } H225Connect_UUIE_fastStart; EXTERN int asn1PE_H225Connect_UUIE_fastStart (OOCTXT* pctxt, H225Connect_UUIE_fastStart* pvalue); EXTERN int asn1PD_H225Connect_UUIE_fastStart (OOCTXT* pctxt, H225Connect_UUIE_fastStart* pvalue); /**************************************************************/ /* */ /* Connect_UUIE_language */ /* */ /**************************************************************/ typedef struct EXTERN H225Connect_UUIE_language { ASN1UINT n; ASN1IA5String *elem; } H225Connect_UUIE_language; EXTERN int asn1PE_H225Connect_UUIE_language (OOCTXT* pctxt, H225Connect_UUIE_language* pvalue); EXTERN int asn1PD_H225Connect_UUIE_language (OOCTXT* pctxt, H225Connect_UUIE_language* pvalue); /**************************************************************/ /* */ /* Connect_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Connect_UUIE { struct { unsigned h245AddressPresent : 1; unsigned callIdentifierPresent : 1; unsigned h245SecurityModePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned fastStartPresent : 1; unsigned multipleCallsPresent : 1; unsigned maintainConnectionPresent : 1; unsigned languagePresent : 1; unsigned connectedAddressPresent : 1; unsigned presentationIndicatorPresent : 1; unsigned screeningIndicatorPresent : 1; unsigned fastConnectRefusedPresent : 1; unsigned serviceControlPresent : 1; unsigned capacityPresent : 1; unsigned featureSetPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225TransportAddress h245Address; H225EndpointType destinationInfo; H225ConferenceIdentifier conferenceID; H225CallIdentifier callIdentifier; H225H245Security h245SecurityMode; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225Connect_UUIE_fastStart fastStart; ASN1BOOL multipleCalls; ASN1BOOL maintainConnection; H225Connect_UUIE_language language; H225_SeqOfH225AliasAddress connectedAddress; H225PresentationIndicator presentationIndicator; H225ScreeningIndicator screeningIndicator; H225_SeqOfH225ServiceControlSession serviceControl; H225CallCapacity capacity; H225FeatureSet featureSet; } H225Connect_UUIE; EXTERN int asn1PE_H225Connect_UUIE (OOCTXT* pctxt, H225Connect_UUIE* pvalue); EXTERN int asn1PD_H225Connect_UUIE (OOCTXT* pctxt, H225Connect_UUIE* pvalue); /**************************************************************/ /* */ /* Alerting_UUIE_fastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225Alerting_UUIE_fastStart { ASN1UINT n; ASN1DynOctStr *elem; } H225Alerting_UUIE_fastStart; EXTERN int asn1PE_H225Alerting_UUIE_fastStart (OOCTXT* pctxt, H225Alerting_UUIE_fastStart* pvalue); EXTERN int asn1PD_H225Alerting_UUIE_fastStart (OOCTXT* pctxt, H225Alerting_UUIE_fastStart* pvalue); /**************************************************************/ /* */ /* Alerting_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Alerting_UUIE { struct { unsigned h245AddressPresent : 1; unsigned callIdentifierPresent : 1; unsigned h245SecurityModePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned fastStartPresent : 1; unsigned multipleCallsPresent : 1; unsigned maintainConnectionPresent : 1; unsigned alertingAddressPresent : 1; unsigned presentationIndicatorPresent : 1; unsigned screeningIndicatorPresent : 1; unsigned fastConnectRefusedPresent : 1; unsigned serviceControlPresent : 1; unsigned capacityPresent : 1; unsigned featureSetPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225EndpointType destinationInfo; H225TransportAddress h245Address; H225CallIdentifier callIdentifier; H225H245Security h245SecurityMode; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225Alerting_UUIE_fastStart fastStart; ASN1BOOL multipleCalls; ASN1BOOL maintainConnection; H225_SeqOfH225AliasAddress alertingAddress; H225PresentationIndicator presentationIndicator; H225ScreeningIndicator screeningIndicator; H225_SeqOfH225ServiceControlSession serviceControl; H225CallCapacity capacity; H225FeatureSet featureSet; } H225Alerting_UUIE; EXTERN int asn1PE_H225Alerting_UUIE (OOCTXT* pctxt, H225Alerting_UUIE* pvalue); EXTERN int asn1PD_H225Alerting_UUIE (OOCTXT* pctxt, H225Alerting_UUIE* pvalue); /**************************************************************/ /* */ /* Information_UUIE_fastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225Information_UUIE_fastStart { ASN1UINT n; ASN1DynOctStr *elem; } H225Information_UUIE_fastStart; EXTERN int asn1PE_H225Information_UUIE_fastStart (OOCTXT* pctxt, H225Information_UUIE_fastStart* pvalue); EXTERN int asn1PD_H225Information_UUIE_fastStart (OOCTXT* pctxt, H225Information_UUIE_fastStart* pvalue); /**************************************************************/ /* */ /* Information_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Information_UUIE { struct { unsigned callIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned fastStartPresent : 1; unsigned fastConnectRefusedPresent : 1; unsigned circuitInfoPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225Information_UUIE_fastStart fastStart; H225CircuitInfo circuitInfo; } H225Information_UUIE; EXTERN int asn1PE_H225Information_UUIE (OOCTXT* pctxt, H225Information_UUIE* pvalue); EXTERN int asn1PD_H225Information_UUIE (OOCTXT* pctxt, H225Information_UUIE* pvalue); /**************************************************************/ /* */ /* SecurityErrors */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225SecurityErrors_securityWrongSyncTime 1 #define T_H225SecurityErrors_securityReplay 2 #define T_H225SecurityErrors_securityWrongGeneralID 3 #define T_H225SecurityErrors_securityWrongSendersID 4 #define T_H225SecurityErrors_securityIntegrityFailed 5 #define T_H225SecurityErrors_securityWrongOID 6 #define T_H225SecurityErrors_securityDHmismatch 7 #define T_H225SecurityErrors_securityCertificateExpired 8 #define T_H225SecurityErrors_securityCertificateDateInvalid 9 #define T_H225SecurityErrors_securityCertificateRevoked 10 #define T_H225SecurityErrors_securityCertificateNotReadable 11 #define T_H225SecurityErrors_securityCertificateSignatureInvalid 12 #define T_H225SecurityErrors_securityCertificateMissing 13 #define T_H225SecurityErrors_securityCertificateIncomplete 14 #define T_H225SecurityErrors_securityUnsupportedCertificateAlgOID 15 #define T_H225SecurityErrors_securityUnknownCA 16 #define T_H225SecurityErrors_extElem1 17 typedef struct EXTERN H225SecurityErrors { int t; } H225SecurityErrors; EXTERN int asn1PE_H225SecurityErrors (OOCTXT* pctxt, H225SecurityErrors* pvalue); EXTERN int asn1PD_H225SecurityErrors (OOCTXT* pctxt, H225SecurityErrors* pvalue); /**************************************************************/ /* */ /* ReleaseCompleteReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225ReleaseCompleteReason_noBandwidth 1 #define T_H225ReleaseCompleteReason_gatekeeperResources 2 #define T_H225ReleaseCompleteReason_unreachableDestination 3 #define T_H225ReleaseCompleteReason_destinationRejection 4 #define T_H225ReleaseCompleteReason_invalidRevision 5 #define T_H225ReleaseCompleteReason_noPermission 6 #define T_H225ReleaseCompleteReason_unreachableGatekeeper 7 #define T_H225ReleaseCompleteReason_gatewayResources 8 #define T_H225ReleaseCompleteReason_badFormatAddress 9 #define T_H225ReleaseCompleteReason_adaptiveBusy 10 #define T_H225ReleaseCompleteReason_inConf 11 #define T_H225ReleaseCompleteReason_undefinedReason 12 #define T_H225ReleaseCompleteReason_facilityCallDeflection 13 #define T_H225ReleaseCompleteReason_securityDenied 14 #define T_H225ReleaseCompleteReason_calledPartyNotRegistered 15 #define T_H225ReleaseCompleteReason_callerNotRegistered 16 #define T_H225ReleaseCompleteReason_newConnectionNeeded 17 #define T_H225ReleaseCompleteReason_nonStandardReason 18 #define T_H225ReleaseCompleteReason_replaceWithConferenceInvite 19 #define T_H225ReleaseCompleteReason_genericDataReason 20 #define T_H225ReleaseCompleteReason_neededFeatureNotSupported 21 #define T_H225ReleaseCompleteReason_tunnelledSignallingRejected 22 #define T_H225ReleaseCompleteReason_invalidCID 23 #define T_H225ReleaseCompleteReason_securityError 24 #define T_H225ReleaseCompleteReason_hopCountExceeded 25 #define T_H225ReleaseCompleteReason_extElem1 26 typedef struct EXTERN H225ReleaseCompleteReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ /* t = 10 */ /* t = 11 */ /* t = 12 */ /* t = 13 */ /* t = 14 */ /* t = 15 */ /* t = 16 */ /* t = 17 */ /* t = 18 */ H225NonStandardParameter *nonStandardReason; /* t = 19 */ H225ConferenceIdentifier *replaceWithConferenceInvite; /* t = 20 */ /* t = 21 */ /* t = 22 */ /* t = 23 */ /* t = 24 */ H225SecurityErrors *securityError; /* t = 25 */ /* t = 26 */ } u; } H225ReleaseCompleteReason; EXTERN int asn1PE_H225ReleaseCompleteReason (OOCTXT* pctxt, H225ReleaseCompleteReason* pvalue); EXTERN int asn1PD_H225ReleaseCompleteReason (OOCTXT* pctxt, H225ReleaseCompleteReason* pvalue); /**************************************************************/ /* */ /* ReleaseComplete_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225ReleaseComplete_UUIE { struct { unsigned reasonPresent : 1; unsigned callIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned busyAddressPresent : 1; unsigned presentationIndicatorPresent : 1; unsigned screeningIndicatorPresent : 1; unsigned capacityPresent : 1; unsigned serviceControlPresent : 1; unsigned featureSetPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225ReleaseCompleteReason reason; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225_SeqOfH225AliasAddress busyAddress; H225PresentationIndicator presentationIndicator; H225ScreeningIndicator screeningIndicator; H225CallCapacity capacity; H225_SeqOfH225ServiceControlSession serviceControl; H225FeatureSet featureSet; } H225ReleaseComplete_UUIE; EXTERN int asn1PE_H225ReleaseComplete_UUIE (OOCTXT* pctxt, H225ReleaseComplete_UUIE* pvalue); EXTERN int asn1PD_H225ReleaseComplete_UUIE (OOCTXT* pctxt, H225ReleaseComplete_UUIE* pvalue); /**************************************************************/ /* */ /* FacilityReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225FacilityReason_routeCallToGatekeeper 1 #define T_H225FacilityReason_callForwarded 2 #define T_H225FacilityReason_routeCallToMC 3 #define T_H225FacilityReason_undefinedReason 4 #define T_H225FacilityReason_conferenceListChoice 5 #define T_H225FacilityReason_startH245 6 #define T_H225FacilityReason_noH245 7 #define T_H225FacilityReason_newTokens 8 #define T_H225FacilityReason_featureSetUpdate 9 #define T_H225FacilityReason_forwardedElements 10 #define T_H225FacilityReason_transportedInformation 11 #define T_H225FacilityReason_extElem1 12 typedef struct EXTERN H225FacilityReason { int t; } H225FacilityReason; EXTERN int asn1PE_H225FacilityReason (OOCTXT* pctxt, H225FacilityReason* pvalue); EXTERN int asn1PD_H225FacilityReason (OOCTXT* pctxt, H225FacilityReason* pvalue); /**************************************************************/ /* */ /* ConferenceList */ /* */ /**************************************************************/ typedef struct EXTERN H225ConferenceList { struct { unsigned conferenceIDPresent : 1; unsigned conferenceAliasPresent : 1; unsigned nonStandardDataPresent : 1; } m; H225ConferenceIdentifier conferenceID; H225AliasAddress conferenceAlias; H225NonStandardParameter nonStandardData; } H225ConferenceList; EXTERN int asn1PE_H225ConferenceList (OOCTXT* pctxt, H225ConferenceList* pvalue); EXTERN int asn1PD_H225ConferenceList (OOCTXT* pctxt, H225ConferenceList* pvalue); /**************************************************************/ /* */ /* _SeqOfH225ConferenceList */ /* */ /**************************************************************/ /* List of H225ConferenceList */ typedef DList H225_SeqOfH225ConferenceList; EXTERN int asn1PE_H225_SeqOfH225ConferenceList (OOCTXT* pctxt, H225_SeqOfH225ConferenceList* pvalue); EXTERN int asn1PD_H225_SeqOfH225ConferenceList (OOCTXT* pctxt, H225_SeqOfH225ConferenceList* pvalue); /**************************************************************/ /* */ /* Facility_UUIE_fastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225Facility_UUIE_fastStart { ASN1UINT n; ASN1DynOctStr *elem; } H225Facility_UUIE_fastStart; EXTERN int asn1PE_H225Facility_UUIE_fastStart (OOCTXT* pctxt, H225Facility_UUIE_fastStart* pvalue); EXTERN int asn1PD_H225Facility_UUIE_fastStart (OOCTXT* pctxt, H225Facility_UUIE_fastStart* pvalue); /**************************************************************/ /* */ /* Facility_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Facility_UUIE { struct { unsigned alternativeAddressPresent : 1; unsigned alternativeAliasAddressPresent : 1; unsigned conferenceIDPresent : 1; unsigned callIdentifierPresent : 1; unsigned destExtraCallInfoPresent : 1; unsigned remoteExtensionAddressPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned conferencesPresent : 1; unsigned h245AddressPresent : 1; unsigned fastStartPresent : 1; unsigned multipleCallsPresent : 1; unsigned maintainConnectionPresent : 1; unsigned fastConnectRefusedPresent : 1; unsigned serviceControlPresent : 1; unsigned circuitInfoPresent : 1; unsigned featureSetPresent : 1; unsigned destinationInfoPresent : 1; unsigned h245SecurityModePresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225TransportAddress alternativeAddress; H225_SeqOfH225AliasAddress alternativeAliasAddress; H225ConferenceIdentifier conferenceID; H225FacilityReason reason; H225CallIdentifier callIdentifier; H225_SeqOfH225AliasAddress destExtraCallInfo; H225AliasAddress remoteExtensionAddress; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225_SeqOfH225ConferenceList conferences; H225TransportAddress h245Address; H225Facility_UUIE_fastStart fastStart; ASN1BOOL multipleCalls; ASN1BOOL maintainConnection; H225_SeqOfH225ServiceControlSession serviceControl; H225CircuitInfo circuitInfo; H225FeatureSet featureSet; H225EndpointType destinationInfo; H225H245Security h245SecurityMode; } H225Facility_UUIE; EXTERN int asn1PE_H225Facility_UUIE (OOCTXT* pctxt, H225Facility_UUIE* pvalue); EXTERN int asn1PD_H225Facility_UUIE (OOCTXT* pctxt, H225Facility_UUIE* pvalue); /**************************************************************/ /* */ /* Progress_UUIE_fastStart */ /* */ /**************************************************************/ typedef struct EXTERN H225Progress_UUIE_fastStart { ASN1UINT n; ASN1DynOctStr *elem; } H225Progress_UUIE_fastStart; EXTERN int asn1PE_H225Progress_UUIE_fastStart (OOCTXT* pctxt, H225Progress_UUIE_fastStart* pvalue); EXTERN int asn1PD_H225Progress_UUIE_fastStart (OOCTXT* pctxt, H225Progress_UUIE_fastStart* pvalue); /**************************************************************/ /* */ /* Progress_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Progress_UUIE { struct { unsigned h245AddressPresent : 1; unsigned h245SecurityModePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned fastStartPresent : 1; unsigned multipleCallsPresent : 1; unsigned maintainConnectionPresent : 1; unsigned fastConnectRefusedPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225EndpointType destinationInfo; H225TransportAddress h245Address; H225CallIdentifier callIdentifier; H225H245Security h245SecurityMode; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225Progress_UUIE_fastStart fastStart; ASN1BOOL multipleCalls; ASN1BOOL maintainConnection; } H225Progress_UUIE; EXTERN int asn1PE_H225Progress_UUIE (OOCTXT* pctxt, H225Progress_UUIE* pvalue); EXTERN int asn1PD_H225Progress_UUIE (OOCTXT* pctxt, H225Progress_UUIE* pvalue); /**************************************************************/ /* */ /* Status_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Status_UUIE { struct { unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; } H225Status_UUIE; EXTERN int asn1PE_H225Status_UUIE (OOCTXT* pctxt, H225Status_UUIE* pvalue); EXTERN int asn1PD_H225Status_UUIE (OOCTXT* pctxt, H225Status_UUIE* pvalue); /**************************************************************/ /* */ /* StatusInquiry_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225StatusInquiry_UUIE { struct { unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; } H225StatusInquiry_UUIE; EXTERN int asn1PE_H225StatusInquiry_UUIE (OOCTXT* pctxt, H225StatusInquiry_UUIE* pvalue); EXTERN int asn1PD_H225StatusInquiry_UUIE (OOCTXT* pctxt, H225StatusInquiry_UUIE* pvalue); /**************************************************************/ /* */ /* SetupAcknowledge_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225SetupAcknowledge_UUIE { struct { unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; } H225SetupAcknowledge_UUIE; EXTERN int asn1PE_H225SetupAcknowledge_UUIE (OOCTXT* pctxt, H225SetupAcknowledge_UUIE* pvalue); EXTERN int asn1PD_H225SetupAcknowledge_UUIE (OOCTXT* pctxt, H225SetupAcknowledge_UUIE* pvalue); /**************************************************************/ /* */ /* Notify_UUIE */ /* */ /**************************************************************/ typedef struct EXTERN H225Notify_UUIE { struct { unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; } m; H225ProtocolIdentifier protocolIdentifier; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; } H225Notify_UUIE; EXTERN int asn1PE_H225Notify_UUIE (OOCTXT* pctxt, H225Notify_UUIE* pvalue); EXTERN int asn1PD_H225Notify_UUIE (OOCTXT* pctxt, H225Notify_UUIE* pvalue); /**************************************************************/ /* */ /* H323_UU_PDU_h323_message_body */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225H323_UU_PDU_h323_message_body_setup 1 #define T_H225H323_UU_PDU_h323_message_body_callProceeding 2 #define T_H225H323_UU_PDU_h323_message_body_connect 3 #define T_H225H323_UU_PDU_h323_message_body_alerting 4 #define T_H225H323_UU_PDU_h323_message_body_information 5 #define T_H225H323_UU_PDU_h323_message_body_releaseComplete 6 #define T_H225H323_UU_PDU_h323_message_body_facility 7 #define T_H225H323_UU_PDU_h323_message_body_progress 8 #define T_H225H323_UU_PDU_h323_message_body_empty 9 #define T_H225H323_UU_PDU_h323_message_body_status 10 #define T_H225H323_UU_PDU_h323_message_body_statusInquiry 11 #define T_H225H323_UU_PDU_h323_message_body_setupAcknowledge 12 #define T_H225H323_UU_PDU_h323_message_body_notify 13 #define T_H225H323_UU_PDU_h323_message_body_extElem1 14 typedef struct EXTERN H225H323_UU_PDU_h323_message_body { int t; union { /* t = 1 */ H225Setup_UUIE *setup; /* t = 2 */ H225CallProceeding_UUIE *callProceeding; /* t = 3 */ H225Connect_UUIE *connect; /* t = 4 */ H225Alerting_UUIE *alerting; /* t = 5 */ H225Information_UUIE *information; /* t = 6 */ H225ReleaseComplete_UUIE *releaseComplete; /* t = 7 */ H225Facility_UUIE *facility; /* t = 8 */ H225Progress_UUIE *progress; /* t = 9 */ /* t = 10 */ H225Status_UUIE *status; /* t = 11 */ H225StatusInquiry_UUIE *statusInquiry; /* t = 12 */ H225SetupAcknowledge_UUIE *setupAcknowledge; /* t = 13 */ H225Notify_UUIE *notify; /* t = 14 */ } u; } H225H323_UU_PDU_h323_message_body; EXTERN int asn1PE_H225H323_UU_PDU_h323_message_body (OOCTXT* pctxt, H225H323_UU_PDU_h323_message_body* pvalue); EXTERN int asn1PD_H225H323_UU_PDU_h323_message_body (OOCTXT* pctxt, H225H323_UU_PDU_h323_message_body* pvalue); /**************************************************************/ /* */ /* H323_UU_PDU_h4501SupplementaryService */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UU_PDU_h4501SupplementaryService { ASN1UINT n; ASN1DynOctStr *elem; } H225H323_UU_PDU_h4501SupplementaryService; EXTERN int asn1PE_H225H323_UU_PDU_h4501SupplementaryService (OOCTXT* pctxt, H225H323_UU_PDU_h4501SupplementaryService* pvalue); EXTERN int asn1PD_H225H323_UU_PDU_h4501SupplementaryService (OOCTXT* pctxt, H225H323_UU_PDU_h4501SupplementaryService* pvalue); /**************************************************************/ /* */ /* H323_UU_PDU_h245Control */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UU_PDU_h245Control { ASN1UINT n; ASN1DynOctStr *elem; } H225H323_UU_PDU_h245Control; EXTERN int asn1PE_H225H323_UU_PDU_h245Control (OOCTXT* pctxt, H225H323_UU_PDU_h245Control* pvalue); EXTERN int asn1PD_H225H323_UU_PDU_h245Control (OOCTXT* pctxt, H225H323_UU_PDU_h245Control* pvalue); /**************************************************************/ /* */ /* _SeqOfH225NonStandardParameter */ /* */ /**************************************************************/ /* List of H225NonStandardParameter */ typedef DList H225_SeqOfH225NonStandardParameter; EXTERN int asn1PE_H225_SeqOfH225NonStandardParameter (OOCTXT* pctxt, H225_SeqOfH225NonStandardParameter* pvalue); EXTERN int asn1PD_H225_SeqOfH225NonStandardParameter (OOCTXT* pctxt, H225_SeqOfH225NonStandardParameter* pvalue); /**************************************************************/ /* */ /* CallLinkage */ /* */ /**************************************************************/ typedef struct EXTERN H225CallLinkage { struct { unsigned globalCallIdPresent : 1; unsigned threadIdPresent : 1; } m; H225GloballyUniqueID globalCallId; H225GloballyUniqueID threadId; } H225CallLinkage; EXTERN int asn1PE_H225CallLinkage (OOCTXT* pctxt, H225CallLinkage* pvalue); EXTERN int asn1PD_H225CallLinkage (OOCTXT* pctxt, H225CallLinkage* pvalue); /**************************************************************/ /* */ /* H323_UU_PDU_tunnelledSignallingMessage_messageContent */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UU_PDU_tunnelledSignallingMessage_messageContent { ASN1UINT n; ASN1DynOctStr *elem; } H225H323_UU_PDU_tunnelledSignallingMessage_messageContent; EXTERN int asn1PE_H225H323_UU_PDU_tunnelledSignallingMessage_messageContent (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage_messageContent* pvalue); EXTERN int asn1PD_H225H323_UU_PDU_tunnelledSignallingMessage_messageContent (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage_messageContent* pvalue); /**************************************************************/ /* */ /* H323_UU_PDU_tunnelledSignallingMessage */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UU_PDU_tunnelledSignallingMessage { struct { unsigned tunnellingRequiredPresent : 1; unsigned nonStandardDataPresent : 1; } m; H225TunnelledProtocol tunnelledProtocolID; H225H323_UU_PDU_tunnelledSignallingMessage_messageContent messageContent; H225NonStandardParameter nonStandardData; } H225H323_UU_PDU_tunnelledSignallingMessage; EXTERN int asn1PE_H225H323_UU_PDU_tunnelledSignallingMessage (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage* pvalue); EXTERN int asn1PD_H225H323_UU_PDU_tunnelledSignallingMessage (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage* pvalue); /**************************************************************/ /* */ /* StimulusControl */ /* */ /**************************************************************/ typedef struct EXTERN H225StimulusControl { struct { unsigned nonStandardPresent : 1; unsigned isTextPresent : 1; unsigned h248MessagePresent : 1; } m; H225NonStandardParameter nonStandard; ASN1DynOctStr h248Message; } H225StimulusControl; EXTERN int asn1PE_H225StimulusControl (OOCTXT* pctxt, H225StimulusControl* pvalue); EXTERN int asn1PD_H225StimulusControl (OOCTXT* pctxt, H225StimulusControl* pvalue); /**************************************************************/ /* */ /* H323_UU_PDU */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UU_PDU { struct { unsigned nonStandardDataPresent : 1; unsigned h4501SupplementaryServicePresent : 1; unsigned h245TunnelingPresent : 1; unsigned h245ControlPresent : 1; unsigned nonStandardControlPresent : 1; unsigned callLinkagePresent : 1; unsigned tunnelledSignallingMessagePresent : 1; unsigned provisionalRespToH245TunnelingPresent : 1; unsigned stimulusControlPresent : 1; unsigned genericDataPresent : 1; } m; H225H323_UU_PDU_h323_message_body h323_message_body; H225NonStandardParameter nonStandardData; H225H323_UU_PDU_h4501SupplementaryService h4501SupplementaryService; ASN1BOOL h245Tunneling; H225H323_UU_PDU_h245Control h245Control; H225_SeqOfH225NonStandardParameter nonStandardControl; H225CallLinkage callLinkage; H225H323_UU_PDU_tunnelledSignallingMessage tunnelledSignallingMessage; H225StimulusControl stimulusControl; H225_SeqOfH225GenericData genericData; } H225H323_UU_PDU; EXTERN int asn1PE_H225H323_UU_PDU (OOCTXT* pctxt, H225H323_UU_PDU* pvalue); EXTERN int asn1PD_H225H323_UU_PDU (OOCTXT* pctxt, H225H323_UU_PDU* pvalue); /**************************************************************/ /* */ /* H323_UserInformation_user_data */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UserInformation_user_data { ASN1UINT8 protocol_discriminator; H225H323_UserInformation_user_data_user_information user_information; } H225H323_UserInformation_user_data; EXTERN int asn1PE_H225H323_UserInformation_user_data (OOCTXT* pctxt, H225H323_UserInformation_user_data* pvalue); EXTERN int asn1PD_H225H323_UserInformation_user_data (OOCTXT* pctxt, H225H323_UserInformation_user_data* pvalue); /**************************************************************/ /* */ /* H323_UserInformation */ /* */ /**************************************************************/ typedef struct EXTERN H225H323_UserInformation { struct { unsigned user_dataPresent : 1; } m; H225H323_UU_PDU h323_uu_pdu; H225H323_UserInformation_user_data user_data; } H225H323_UserInformation; EXTERN int asn1PE_H225H323_UserInformation (OOCTXT* pctxt, H225H323_UserInformation* pvalue); EXTERN int asn1PD_H225H323_UserInformation (OOCTXT* pctxt, H225H323_UserInformation* pvalue); /**************************************************************/ /* */ /* AddressPattern_range */ /* */ /**************************************************************/ typedef struct EXTERN H225AddressPattern_range { H225PartyNumber startOfRange; H225PartyNumber endOfRange; } H225AddressPattern_range; EXTERN int asn1PE_H225AddressPattern_range (OOCTXT* pctxt, H225AddressPattern_range* pvalue); EXTERN int asn1PD_H225AddressPattern_range (OOCTXT* pctxt, H225AddressPattern_range* pvalue); /**************************************************************/ /* */ /* AddressPattern */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225AddressPattern_wildcard 1 #define T_H225AddressPattern_range 2 #define T_H225AddressPattern_extElem1 3 typedef struct EXTERN H225AddressPattern { int t; union { /* t = 1 */ H225AliasAddress *wildcard; /* t = 2 */ H225AddressPattern_range *range; /* t = 3 */ } u; } H225AddressPattern; EXTERN int asn1PE_H225AddressPattern (OOCTXT* pctxt, H225AddressPattern* pvalue); EXTERN int asn1PD_H225AddressPattern (OOCTXT* pctxt, H225AddressPattern* pvalue); /**************************************************************/ /* */ /* _SeqOfH225TransportAddress */ /* */ /**************************************************************/ /* List of H225TransportAddress */ typedef DList H225_SeqOfH225TransportAddress; EXTERN int asn1PE_H225_SeqOfH225TransportAddress (OOCTXT* pctxt, H225_SeqOfH225TransportAddress* pvalue); EXTERN int asn1PD_H225_SeqOfH225TransportAddress (OOCTXT* pctxt, H225_SeqOfH225TransportAddress* pvalue); /**************************************************************/ /* */ /* AlternateTransportAddresses */ /* */ /**************************************************************/ typedef struct EXTERN H225AlternateTransportAddresses { struct { unsigned annexEPresent : 1; unsigned sctpPresent : 1; } m; H225_SeqOfH225TransportAddress annexE; H225_SeqOfH225TransportAddress sctp; } H225AlternateTransportAddresses; EXTERN int asn1PE_H225AlternateTransportAddresses (OOCTXT* pctxt, H225AlternateTransportAddresses* pvalue); EXTERN int asn1PD_H225AlternateTransportAddresses (OOCTXT* pctxt, H225AlternateTransportAddresses* pvalue); /**************************************************************/ /* */ /* Endpoint */ /* */ /**************************************************************/ typedef struct EXTERN H225Endpoint { struct { unsigned nonStandardDataPresent : 1; unsigned aliasAddressPresent : 1; unsigned callSignalAddressPresent : 1; unsigned rasAddressPresent : 1; unsigned endpointTypePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned priorityPresent : 1; unsigned remoteExtensionAddressPresent : 1; unsigned destExtraCallInfoPresent : 1; unsigned alternateTransportAddressesPresent : 1; unsigned circuitInfoPresent : 1; unsigned featureSetPresent : 1; } m; H225NonStandardParameter nonStandardData; H225_SeqOfH225AliasAddress aliasAddress; H225_SeqOfH225TransportAddress callSignalAddress; H225_SeqOfH225TransportAddress rasAddress; H225EndpointType endpointType; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; ASN1UINT8 priority; H225_SeqOfH225AliasAddress remoteExtensionAddress; H225_SeqOfH225AliasAddress destExtraCallInfo; H225AlternateTransportAddresses alternateTransportAddresses; H225CircuitInfo circuitInfo; H225FeatureSet featureSet; } H225Endpoint; EXTERN int asn1PE_H225Endpoint (OOCTXT* pctxt, H225Endpoint* pvalue); EXTERN int asn1PD_H225Endpoint (OOCTXT* pctxt, H225Endpoint* pvalue); /**************************************************************/ /* */ /* UseSpecifiedTransport */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225UseSpecifiedTransport_tcp 1 #define T_H225UseSpecifiedTransport_annexE 2 #define T_H225UseSpecifiedTransport_sctp 3 #define T_H225UseSpecifiedTransport_extElem1 4 typedef struct EXTERN H225UseSpecifiedTransport { int t; } H225UseSpecifiedTransport; EXTERN int asn1PE_H225UseSpecifiedTransport (OOCTXT* pctxt, H225UseSpecifiedTransport* pvalue); EXTERN int asn1PD_H225UseSpecifiedTransport (OOCTXT* pctxt, H225UseSpecifiedTransport* pvalue); /**************************************************************/ /* */ /* AlternateGK */ /* */ /**************************************************************/ typedef struct EXTERN H225AlternateGK { struct { unsigned gatekeeperIdentifierPresent : 1; } m; H225TransportAddress rasAddress; H225GatekeeperIdentifier gatekeeperIdentifier; ASN1BOOL needToRegister; ASN1UINT8 priority; } H225AlternateGK; EXTERN int asn1PE_H225AlternateGK (OOCTXT* pctxt, H225AlternateGK* pvalue); EXTERN int asn1PD_H225AlternateGK (OOCTXT* pctxt, H225AlternateGK* pvalue); /**************************************************************/ /* */ /* _SeqOfH225AlternateGK */ /* */ /**************************************************************/ /* List of H225AlternateGK */ typedef DList H225_SeqOfH225AlternateGK; EXTERN int asn1PE_H225_SeqOfH225AlternateGK (OOCTXT* pctxt, H225_SeqOfH225AlternateGK* pvalue); EXTERN int asn1PD_H225_SeqOfH225AlternateGK (OOCTXT* pctxt, H225_SeqOfH225AlternateGK* pvalue); /**************************************************************/ /* */ /* AltGKInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225AltGKInfo { H225_SeqOfH225AlternateGK alternateGatekeeper; ASN1BOOL altGKisPermanent; } H225AltGKInfo; EXTERN int asn1PE_H225AltGKInfo (OOCTXT* pctxt, H225AltGKInfo* pvalue); EXTERN int asn1PD_H225AltGKInfo (OOCTXT* pctxt, H225AltGKInfo* pvalue); /**************************************************************/ /* */ /* SecurityErrors2 */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225SecurityErrors2_securityWrongSyncTime 1 #define T_H225SecurityErrors2_securityReplay 2 #define T_H225SecurityErrors2_securityWrongGeneralID 3 #define T_H225SecurityErrors2_securityWrongSendersID 4 #define T_H225SecurityErrors2_securityIntegrityFailed 5 #define T_H225SecurityErrors2_securityWrongOID 6 #define T_H225SecurityErrors2_extElem1 7 typedef struct EXTERN H225SecurityErrors2 { int t; } H225SecurityErrors2; EXTERN int asn1PE_H225SecurityErrors2 (OOCTXT* pctxt, H225SecurityErrors2* pvalue); EXTERN int asn1PD_H225SecurityErrors2 (OOCTXT* pctxt, H225SecurityErrors2* pvalue); /**************************************************************/ /* */ /* EncryptIntAlg */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225EncryptIntAlg_nonStandard 1 #define T_H225EncryptIntAlg_isoAlgorithm 2 #define T_H225EncryptIntAlg_extElem1 3 typedef struct EXTERN H225EncryptIntAlg { int t; union { /* t = 1 */ H225NonStandardParameter *nonStandard; /* t = 2 */ ASN1OBJID *isoAlgorithm; /* t = 3 */ } u; } H225EncryptIntAlg; EXTERN int asn1PE_H225EncryptIntAlg (OOCTXT* pctxt, H225EncryptIntAlg* pvalue); EXTERN int asn1PD_H225EncryptIntAlg (OOCTXT* pctxt, H225EncryptIntAlg* pvalue); /**************************************************************/ /* */ /* NonIsoIntegrityMechanism */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225NonIsoIntegrityMechanism_hMAC_MD5 1 #define T_H225NonIsoIntegrityMechanism_hMAC_iso10118_2_s 2 #define T_H225NonIsoIntegrityMechanism_hMAC_iso10118_2_l 3 #define T_H225NonIsoIntegrityMechanism_hMAC_iso10118_3 4 #define T_H225NonIsoIntegrityMechanism_extElem1 5 typedef struct EXTERN H225NonIsoIntegrityMechanism { int t; union { /* t = 1 */ /* t = 2 */ H225EncryptIntAlg *hMAC_iso10118_2_s; /* t = 3 */ H225EncryptIntAlg *hMAC_iso10118_2_l; /* t = 4 */ ASN1OBJID *hMAC_iso10118_3; /* t = 5 */ } u; } H225NonIsoIntegrityMechanism; EXTERN int asn1PE_H225NonIsoIntegrityMechanism (OOCTXT* pctxt, H225NonIsoIntegrityMechanism* pvalue); EXTERN int asn1PD_H225NonIsoIntegrityMechanism (OOCTXT* pctxt, H225NonIsoIntegrityMechanism* pvalue); /**************************************************************/ /* */ /* IntegrityMechanism */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225IntegrityMechanism_nonStandard 1 #define T_H225IntegrityMechanism_digSig 2 #define T_H225IntegrityMechanism_iso9797 3 #define T_H225IntegrityMechanism_nonIsoIM 4 #define T_H225IntegrityMechanism_extElem1 5 typedef struct EXTERN H225IntegrityMechanism { int t; union { /* t = 1 */ H225NonStandardParameter *nonStandard; /* t = 2 */ /* t = 3 */ ASN1OBJID *iso9797; /* t = 4 */ H225NonIsoIntegrityMechanism *nonIsoIM; /* t = 5 */ } u; } H225IntegrityMechanism; EXTERN int asn1PE_H225IntegrityMechanism (OOCTXT* pctxt, H225IntegrityMechanism* pvalue); EXTERN int asn1PD_H225IntegrityMechanism (OOCTXT* pctxt, H225IntegrityMechanism* pvalue); /**************************************************************/ /* */ /* ICV */ /* */ /**************************************************************/ typedef struct EXTERN H225ICV { ASN1OBJID algorithmOID; ASN1DynBitStr icv; } H225ICV; EXTERN int asn1PE_H225ICV (OOCTXT* pctxt, H225ICV* pvalue); EXTERN int asn1PD_H225ICV (OOCTXT* pctxt, H225ICV* pvalue); /**************************************************************/ /* */ /* CapacityReportingCapability */ /* */ /**************************************************************/ typedef struct EXTERN H225CapacityReportingCapability { ASN1BOOL canReportCallCapacity; } H225CapacityReportingCapability; EXTERN int asn1PE_H225CapacityReportingCapability (OOCTXT* pctxt, H225CapacityReportingCapability* pvalue); EXTERN int asn1PD_H225CapacityReportingCapability (OOCTXT* pctxt, H225CapacityReportingCapability* pvalue); /**************************************************************/ /* */ /* CapacityReportingSpecification_when */ /* */ /**************************************************************/ typedef struct EXTERN H225CapacityReportingSpecification_when { struct { unsigned callStartPresent : 1; unsigned callEndPresent : 1; } m; ASN1OCTET __dummy__; } H225CapacityReportingSpecification_when; EXTERN int asn1PE_H225CapacityReportingSpecification_when (OOCTXT* pctxt, H225CapacityReportingSpecification_when* pvalue); EXTERN int asn1PD_H225CapacityReportingSpecification_when (OOCTXT* pctxt, H225CapacityReportingSpecification_when* pvalue); /**************************************************************/ /* */ /* CapacityReportingSpecification */ /* */ /**************************************************************/ typedef struct EXTERN H225CapacityReportingSpecification { H225CapacityReportingSpecification_when when; } H225CapacityReportingSpecification; EXTERN int asn1PE_H225CapacityReportingSpecification (OOCTXT* pctxt, H225CapacityReportingSpecification* pvalue); EXTERN int asn1PD_H225CapacityReportingSpecification (OOCTXT* pctxt, H225CapacityReportingSpecification* pvalue); /**************************************************************/ /* */ /* RasUsageInfoTypes */ /* */ /**************************************************************/ typedef struct EXTERN H225RasUsageInfoTypes { struct { unsigned startTimePresent : 1; unsigned endTimePresent : 1; unsigned terminationCausePresent : 1; } m; H225_SeqOfH225NonStandardParameter nonStandardUsageTypes; } H225RasUsageInfoTypes; EXTERN int asn1PE_H225RasUsageInfoTypes (OOCTXT* pctxt, H225RasUsageInfoTypes* pvalue); EXTERN int asn1PD_H225RasUsageInfoTypes (OOCTXT* pctxt, H225RasUsageInfoTypes* pvalue); /**************************************************************/ /* */ /* RasUsageSpecification_when */ /* */ /**************************************************************/ typedef struct EXTERN H225RasUsageSpecification_when { struct { unsigned startPresent : 1; unsigned endPresent : 1; unsigned inIrrPresent : 1; } m; ASN1OCTET __dummy__; } H225RasUsageSpecification_when; EXTERN int asn1PE_H225RasUsageSpecification_when (OOCTXT* pctxt, H225RasUsageSpecification_when* pvalue); EXTERN int asn1PD_H225RasUsageSpecification_when (OOCTXT* pctxt, H225RasUsageSpecification_when* pvalue); /**************************************************************/ /* */ /* RasUsageSpecification_callStartingPoint */ /* */ /**************************************************************/ typedef struct EXTERN H225RasUsageSpecification_callStartingPoint { struct { unsigned alertingPresent : 1; unsigned connectPresent : 1; } m; ASN1OCTET __dummy__; } H225RasUsageSpecification_callStartingPoint; EXTERN int asn1PE_H225RasUsageSpecification_callStartingPoint (OOCTXT* pctxt, H225RasUsageSpecification_callStartingPoint* pvalue); EXTERN int asn1PD_H225RasUsageSpecification_callStartingPoint (OOCTXT* pctxt, H225RasUsageSpecification_callStartingPoint* pvalue); /**************************************************************/ /* */ /* RasUsageSpecification */ /* */ /**************************************************************/ typedef struct EXTERN H225RasUsageSpecification { struct { unsigned callStartingPointPresent : 1; } m; H225RasUsageSpecification_when when; H225RasUsageSpecification_callStartingPoint callStartingPoint; H225RasUsageInfoTypes required; } H225RasUsageSpecification; EXTERN int asn1PE_H225RasUsageSpecification (OOCTXT* pctxt, H225RasUsageSpecification* pvalue); EXTERN int asn1PD_H225RasUsageSpecification (OOCTXT* pctxt, H225RasUsageSpecification* pvalue); /**************************************************************/ /* */ /* RasUsageInformation */ /* */ /**************************************************************/ typedef struct EXTERN H225RasUsageInformation { struct { unsigned alertingTimePresent : 1; unsigned connectTimePresent : 1; unsigned endTimePresent : 1; } m; H225_SeqOfH225NonStandardParameter nonStandardUsageFields; H235TimeStamp alertingTime; H235TimeStamp connectTime; H235TimeStamp endTime; } H225RasUsageInformation; EXTERN int asn1PE_H225RasUsageInformation (OOCTXT* pctxt, H225RasUsageInformation* pvalue); EXTERN int asn1PD_H225RasUsageInformation (OOCTXT* pctxt, H225RasUsageInformation* pvalue); /**************************************************************/ /* */ /* CallTerminationCause */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225CallTerminationCause_releaseCompleteReason 1 #define T_H225CallTerminationCause_releaseCompleteCauseIE 2 #define T_H225CallTerminationCause_extElem1 3 typedef struct EXTERN H225CallTerminationCause { int t; union { /* t = 1 */ H225ReleaseCompleteReason *releaseCompleteReason; /* t = 2 */ H225CallTerminationCause_releaseCompleteCauseIE *releaseCompleteCauseIE; /* t = 3 */ } u; } H225CallTerminationCause; EXTERN int asn1PE_H225CallTerminationCause (OOCTXT* pctxt, H225CallTerminationCause* pvalue); EXTERN int asn1PD_H225CallTerminationCause (OOCTXT* pctxt, H225CallTerminationCause* pvalue); /**************************************************************/ /* */ /* TransportChannelInfo */ /* */ /**************************************************************/ typedef struct EXTERN H225TransportChannelInfo { struct { unsigned sendAddressPresent : 1; unsigned recvAddressPresent : 1; } m; H225TransportAddress sendAddress; H225TransportAddress recvAddress; } H225TransportChannelInfo; EXTERN int asn1PE_H225TransportChannelInfo (OOCTXT* pctxt, H225TransportChannelInfo* pvalue); EXTERN int asn1PD_H225TransportChannelInfo (OOCTXT* pctxt, H225TransportChannelInfo* pvalue); /**************************************************************/ /* */ /* BandwidthDetails */ /* */ /**************************************************************/ typedef struct EXTERN H225BandwidthDetails { ASN1BOOL sender; ASN1BOOL multicast; H225BandWidth bandwidth; H225TransportChannelInfo rtcpAddresses; } H225BandwidthDetails; EXTERN int asn1PE_H225BandwidthDetails (OOCTXT* pctxt, H225BandwidthDetails* pvalue); EXTERN int asn1PD_H225BandwidthDetails (OOCTXT* pctxt, H225BandwidthDetails* pvalue); /**************************************************************/ /* */ /* CallCreditCapability */ /* */ /**************************************************************/ typedef struct EXTERN H225CallCreditCapability { struct { unsigned canDisplayAmountStringPresent : 1; unsigned canEnforceDurationLimitPresent : 1; } m; ASN1BOOL canDisplayAmountString; ASN1BOOL canEnforceDurationLimit; } H225CallCreditCapability; EXTERN int asn1PE_H225CallCreditCapability (OOCTXT* pctxt, H225CallCreditCapability* pvalue); EXTERN int asn1PD_H225CallCreditCapability (OOCTXT* pctxt, H225CallCreditCapability* pvalue); /**************************************************************/ /* */ /* RTPSession_associatedSessionIds */ /* */ /**************************************************************/ typedef struct EXTERN H225RTPSession_associatedSessionIds { ASN1UINT n; ASN1UINT8 *elem; } H225RTPSession_associatedSessionIds; EXTERN int asn1PE_H225RTPSession_associatedSessionIds (OOCTXT* pctxt, H225RTPSession_associatedSessionIds* pvalue); EXTERN int asn1PD_H225RTPSession_associatedSessionIds (OOCTXT* pctxt, H225RTPSession_associatedSessionIds* pvalue); /**************************************************************/ /* */ /* RTPSession */ /* */ /**************************************************************/ typedef struct EXTERN H225RTPSession { struct { unsigned multicastPresent : 1; unsigned bandwidthPresent : 1; } m; H225TransportChannelInfo rtpAddress; H225TransportChannelInfo rtcpAddress; ASN1PrintableString cname; ASN1UINT ssrc; ASN1UINT8 sessionId; H225RTPSession_associatedSessionIds associatedSessionIds; H225BandWidth bandwidth; } H225RTPSession; EXTERN int asn1PE_H225RTPSession (OOCTXT* pctxt, H225RTPSession* pvalue); EXTERN int asn1PD_H225RTPSession (OOCTXT* pctxt, H225RTPSession* pvalue); /**************************************************************/ /* */ /* _SeqOfH225Endpoint */ /* */ /**************************************************************/ /* List of H225Endpoint */ typedef DList H225_SeqOfH225Endpoint; EXTERN int asn1PE_H225_SeqOfH225Endpoint (OOCTXT* pctxt, H225_SeqOfH225Endpoint* pvalue); EXTERN int asn1PD_H225_SeqOfH225Endpoint (OOCTXT* pctxt, H225_SeqOfH225Endpoint* pvalue); /**************************************************************/ /* */ /* _SeqOfH225AuthenticationMechanism */ /* */ /**************************************************************/ /* List of H235AuthenticationMechanism */ typedef DList H225_SeqOfH225AuthenticationMechanism; EXTERN int asn1PE_H225_SeqOfH225AuthenticationMechanism (OOCTXT* pctxt, H225_SeqOfH225AuthenticationMechanism* pvalue); EXTERN int asn1PD_H225_SeqOfH225AuthenticationMechanism (OOCTXT* pctxt, H225_SeqOfH225AuthenticationMechanism* pvalue); /**************************************************************/ /* */ /* GatekeeperRequest_algorithmOIDs */ /* */ /**************************************************************/ typedef struct EXTERN H225GatekeeperRequest_algorithmOIDs { ASN1UINT n; ASN1OBJID *elem; } H225GatekeeperRequest_algorithmOIDs; EXTERN int asn1PE_H225GatekeeperRequest_algorithmOIDs (OOCTXT* pctxt, H225GatekeeperRequest_algorithmOIDs* pvalue); EXTERN int asn1PD_H225GatekeeperRequest_algorithmOIDs (OOCTXT* pctxt, H225GatekeeperRequest_algorithmOIDs* pvalue); /**************************************************************/ /* */ /* _SeqOfH225IntegrityMechanism */ /* */ /**************************************************************/ /* List of H225IntegrityMechanism */ typedef DList H225_SeqOfH225IntegrityMechanism; EXTERN int asn1PE_H225_SeqOfH225IntegrityMechanism (OOCTXT* pctxt, H225_SeqOfH225IntegrityMechanism* pvalue); EXTERN int asn1PD_H225_SeqOfH225IntegrityMechanism (OOCTXT* pctxt, H225_SeqOfH225IntegrityMechanism* pvalue); /**************************************************************/ /* */ /* GatekeeperRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225GatekeeperRequest { struct { unsigned nonStandardDataPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned callServicesPresent : 1; unsigned endpointAliasPresent : 1; unsigned alternateEndpointsPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned authenticationCapabilityPresent : 1; unsigned algorithmOIDsPresent : 1; unsigned integrityPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned supportsAltGKPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; H225TransportAddress rasAddress; H225EndpointType endpointType; H225GatekeeperIdentifier gatekeeperIdentifier; H225QseriesOptions callServices; H225_SeqOfH225AliasAddress endpointAlias; H225_SeqOfH225Endpoint alternateEndpoints; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225_SeqOfH225AuthenticationMechanism authenticationCapability; H225GatekeeperRequest_algorithmOIDs algorithmOIDs; H225_SeqOfH225IntegrityMechanism integrity; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225GatekeeperRequest; EXTERN int asn1PE_H225GatekeeperRequest (OOCTXT* pctxt, H225GatekeeperRequest* pvalue); EXTERN int asn1PD_H225GatekeeperRequest (OOCTXT* pctxt, H225GatekeeperRequest* pvalue); /**************************************************************/ /* */ /* GatekeeperConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225GatekeeperConfirm { struct { unsigned nonStandardDataPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned alternateGatekeeperPresent : 1; unsigned authenticationModePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned algorithmOIDPresent : 1; unsigned integrityPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; H225GatekeeperIdentifier gatekeeperIdentifier; H225TransportAddress rasAddress; H225_SeqOfH225AlternateGK alternateGatekeeper; H235AuthenticationMechanism authenticationMode; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; ASN1OBJID algorithmOID; H225_SeqOfH225IntegrityMechanism integrity; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225GatekeeperConfirm; EXTERN int asn1PE_H225GatekeeperConfirm (OOCTXT* pctxt, H225GatekeeperConfirm* pvalue); EXTERN int asn1PD_H225GatekeeperConfirm (OOCTXT* pctxt, H225GatekeeperConfirm* pvalue); /**************************************************************/ /* */ /* GatekeeperRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225GatekeeperRejectReason_resourceUnavailable 1 #define T_H225GatekeeperRejectReason_terminalExcluded 2 #define T_H225GatekeeperRejectReason_invalidRevision 3 #define T_H225GatekeeperRejectReason_undefinedReason 4 #define T_H225GatekeeperRejectReason_securityDenial 5 #define T_H225GatekeeperRejectReason_genericDataReason 6 #define T_H225GatekeeperRejectReason_neededFeatureNotSupported 7 #define T_H225GatekeeperRejectReason_securityError 8 #define T_H225GatekeeperRejectReason_extElem1 9 typedef struct EXTERN H225GatekeeperRejectReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ H225SecurityErrors *securityError; /* t = 9 */ } u; } H225GatekeeperRejectReason; EXTERN int asn1PE_H225GatekeeperRejectReason (OOCTXT* pctxt, H225GatekeeperRejectReason* pvalue); EXTERN int asn1PD_H225GatekeeperRejectReason (OOCTXT* pctxt, H225GatekeeperRejectReason* pvalue); /**************************************************************/ /* */ /* GatekeeperReject */ /* */ /**************************************************************/ typedef struct EXTERN H225GatekeeperReject { struct { unsigned nonStandardDataPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; H225GatekeeperIdentifier gatekeeperIdentifier; H225GatekeeperRejectReason rejectReason; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225GatekeeperReject; EXTERN int asn1PE_H225GatekeeperReject (OOCTXT* pctxt, H225GatekeeperReject* pvalue); EXTERN int asn1PD_H225GatekeeperReject (OOCTXT* pctxt, H225GatekeeperReject* pvalue); /**************************************************************/ /* */ /* _SeqOfH225AddressPattern */ /* */ /**************************************************************/ /* List of H225AddressPattern */ typedef DList H225_SeqOfH225AddressPattern; EXTERN int asn1PE_H225_SeqOfH225AddressPattern (OOCTXT* pctxt, H225_SeqOfH225AddressPattern* pvalue); EXTERN int asn1PD_H225_SeqOfH225AddressPattern (OOCTXT* pctxt, H225_SeqOfH225AddressPattern* pvalue); /**************************************************************/ /* */ /* _SeqOfH225H248PackagesDescriptor */ /* */ /**************************************************************/ typedef struct EXTERN H225_SeqOfH225H248PackagesDescriptor { ASN1UINT n; H225H248PackagesDescriptor *elem; } H225_SeqOfH225H248PackagesDescriptor; EXTERN int asn1PE_H225_SeqOfH225H248PackagesDescriptor (OOCTXT* pctxt, H225_SeqOfH225H248PackagesDescriptor* pvalue); EXTERN int asn1PD_H225_SeqOfH225H248PackagesDescriptor (OOCTXT* pctxt, H225_SeqOfH225H248PackagesDescriptor* pvalue); /**************************************************************/ /* */ /* RegistrationRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225RegistrationRequest { struct { unsigned nonStandardDataPresent : 1; unsigned terminalAliasPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned alternateEndpointsPresent : 1; unsigned timeToLivePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned keepAlivePresent : 1; unsigned endpointIdentifierPresent : 1; unsigned willSupplyUUIEsPresent : 1; unsigned maintainConnectionPresent : 1; unsigned alternateTransportAddressesPresent : 1; unsigned additiveRegistrationPresent : 1; unsigned terminalAliasPatternPresent : 1; unsigned supportsAltGKPresent : 1; unsigned usageReportingCapabilityPresent : 1; unsigned multipleCallsPresent : 1; unsigned supportedH248PackagesPresent : 1; unsigned callCreditCapabilityPresent : 1; unsigned capacityReportingCapabilityPresent : 1; unsigned capacityPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; unsigned restartPresent : 1; unsigned supportsACFSequencesPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; ASN1BOOL discoveryComplete; H225_SeqOfH225TransportAddress callSignalAddress; H225_SeqOfH225TransportAddress rasAddress; H225EndpointType terminalType; H225_SeqOfH225AliasAddress terminalAlias; H225GatekeeperIdentifier gatekeeperIdentifier; H225VendorIdentifier endpointVendor; H225_SeqOfH225Endpoint alternateEndpoints; H225TimeToLive timeToLive; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; ASN1BOOL keepAlive; H225EndpointIdentifier endpointIdentifier; ASN1BOOL willSupplyUUIEs; ASN1BOOL maintainConnection; H225AlternateTransportAddresses alternateTransportAddresses; H225_SeqOfH225AddressPattern terminalAliasPattern; H225RasUsageInfoTypes usageReportingCapability; ASN1BOOL multipleCalls; H225_SeqOfH225H248PackagesDescriptor supportedH248Packages; H225CallCreditCapability callCreditCapability; H225CapacityReportingCapability capacityReportingCapability; H225CallCapacity capacity; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225RegistrationRequest; EXTERN int asn1PE_H225RegistrationRequest (OOCTXT* pctxt, H225RegistrationRequest* pvalue); EXTERN int asn1PD_H225RegistrationRequest (OOCTXT* pctxt, H225RegistrationRequest* pvalue); /**************************************************************/ /* */ /* RegistrationConfirm_preGrantedARQ */ /* */ /**************************************************************/ typedef struct EXTERN H225RegistrationConfirm_preGrantedARQ { struct { unsigned irrFrequencyInCallPresent : 1; unsigned totalBandwidthRestrictionPresent : 1; unsigned alternateTransportAddressesPresent : 1; unsigned useSpecifiedTransportPresent : 1; } m; ASN1BOOL makeCall; ASN1BOOL useGKCallSignalAddressToMakeCall; ASN1BOOL answerCall; ASN1BOOL useGKCallSignalAddressToAnswer; ASN1USINT irrFrequencyInCall; H225BandWidth totalBandwidthRestriction; H225AlternateTransportAddresses alternateTransportAddresses; H225UseSpecifiedTransport useSpecifiedTransport; } H225RegistrationConfirm_preGrantedARQ; EXTERN int asn1PE_H225RegistrationConfirm_preGrantedARQ (OOCTXT* pctxt, H225RegistrationConfirm_preGrantedARQ* pvalue); EXTERN int asn1PD_H225RegistrationConfirm_preGrantedARQ (OOCTXT* pctxt, H225RegistrationConfirm_preGrantedARQ* pvalue); /**************************************************************/ /* */ /* _SeqOfH225RasUsageSpecification */ /* */ /**************************************************************/ /* List of H225RasUsageSpecification */ typedef DList H225_SeqOfH225RasUsageSpecification; EXTERN int asn1PE_H225_SeqOfH225RasUsageSpecification (OOCTXT* pctxt, H225_SeqOfH225RasUsageSpecification* pvalue); EXTERN int asn1PD_H225_SeqOfH225RasUsageSpecification (OOCTXT* pctxt, H225_SeqOfH225RasUsageSpecification* pvalue); /**************************************************************/ /* */ /* RegistrationConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225RegistrationConfirm { struct { unsigned nonStandardDataPresent : 1; unsigned terminalAliasPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned alternateGatekeeperPresent : 1; unsigned timeToLivePresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned willRespondToIRRPresent : 1; unsigned preGrantedARQPresent : 1; unsigned maintainConnectionPresent : 1; unsigned serviceControlPresent : 1; unsigned supportsAdditiveRegistrationPresent : 1; unsigned terminalAliasPatternPresent : 1; unsigned supportedPrefixesPresent : 1; unsigned usageSpecPresent : 1; unsigned featureServerAliasPresent : 1; unsigned capacityReportingSpecPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; H225_SeqOfH225TransportAddress callSignalAddress; H225_SeqOfH225AliasAddress terminalAlias; H225GatekeeperIdentifier gatekeeperIdentifier; H225EndpointIdentifier endpointIdentifier; H225_SeqOfH225AlternateGK alternateGatekeeper; H225TimeToLive timeToLive; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; ASN1BOOL willRespondToIRR; H225RegistrationConfirm_preGrantedARQ preGrantedARQ; ASN1BOOL maintainConnection; H225_SeqOfH225ServiceControlSession serviceControl; H225_SeqOfH225AddressPattern terminalAliasPattern; H225_SeqOfH225SupportedPrefix supportedPrefixes; H225_SeqOfH225RasUsageSpecification usageSpec; H225AliasAddress featureServerAlias; H225CapacityReportingSpecification capacityReportingSpec; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225RegistrationConfirm; EXTERN int asn1PE_H225RegistrationConfirm (OOCTXT* pctxt, H225RegistrationConfirm* pvalue); EXTERN int asn1PD_H225RegistrationConfirm (OOCTXT* pctxt, H225RegistrationConfirm* pvalue); /**************************************************************/ /* */ /* RegistrationRejectReason_invalidTerminalAliases */ /* */ /**************************************************************/ typedef struct EXTERN H225RegistrationRejectReason_invalidTerminalAliases { struct { unsigned terminalAliasPresent : 1; unsigned terminalAliasPatternPresent : 1; unsigned supportedPrefixesPresent : 1; } m; H225_SeqOfH225AliasAddress terminalAlias; H225_SeqOfH225AddressPattern terminalAliasPattern; H225_SeqOfH225SupportedPrefix supportedPrefixes; } H225RegistrationRejectReason_invalidTerminalAliases; EXTERN int asn1PE_H225RegistrationRejectReason_invalidTerminalAliases (OOCTXT* pctxt, H225RegistrationRejectReason_invalidTerminalAliases* pvalue); EXTERN int asn1PD_H225RegistrationRejectReason_invalidTerminalAliases (OOCTXT* pctxt, H225RegistrationRejectReason_invalidTerminalAliases* pvalue); /**************************************************************/ /* */ /* RegistrationRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225RegistrationRejectReason_discoveryRequired 1 #define T_H225RegistrationRejectReason_invalidRevision 2 #define T_H225RegistrationRejectReason_invalidCallSignalAddress 3 #define T_H225RegistrationRejectReason_invalidRASAddress 4 #define T_H225RegistrationRejectReason_duplicateAlias 5 #define T_H225RegistrationRejectReason_invalidTerminalType 6 #define T_H225RegistrationRejectReason_undefinedReason 7 #define T_H225RegistrationRejectReason_transportNotSupported 8 #define T_H225RegistrationRejectReason_transportQOSNotSupported 9 #define T_H225RegistrationRejectReason_resourceUnavailable 10 #define T_H225RegistrationRejectReason_invalidAlias 11 #define T_H225RegistrationRejectReason_securityDenial 12 #define T_H225RegistrationRejectReason_fullRegistrationRequired 13 #define T_H225RegistrationRejectReason_additiveRegistrationNotSupported 14 #define T_H225RegistrationRejectReason_invalidTerminalAliases 15 #define T_H225RegistrationRejectReason_genericDataReason 16 #define T_H225RegistrationRejectReason_neededFeatureNotSupported 17 #define T_H225RegistrationRejectReason_securityError 18 #define T_H225RegistrationRejectReason_extElem1 19 typedef struct EXTERN H225RegistrationRejectReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ H225_SeqOfH225AliasAddress *duplicateAlias; /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ /* t = 10 */ /* t = 11 */ /* t = 12 */ /* t = 13 */ /* t = 14 */ /* t = 15 */ H225RegistrationRejectReason_invalidTerminalAliases *invalidTerminalAliases; /* t = 16 */ /* t = 17 */ /* t = 18 */ H225SecurityErrors *securityError; /* t = 19 */ } u; } H225RegistrationRejectReason; EXTERN int asn1PE_H225RegistrationRejectReason (OOCTXT* pctxt, H225RegistrationRejectReason* pvalue); EXTERN int asn1PD_H225RegistrationRejectReason (OOCTXT* pctxt, H225RegistrationRejectReason* pvalue); /**************************************************************/ /* */ /* RegistrationReject */ /* */ /**************************************************************/ typedef struct EXTERN H225RegistrationReject { struct { unsigned nonStandardDataPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; H225RegistrationRejectReason rejectReason; H225GatekeeperIdentifier gatekeeperIdentifier; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225RegistrationReject; EXTERN int asn1PE_H225RegistrationReject (OOCTXT* pctxt, H225RegistrationReject* pvalue); EXTERN int asn1PD_H225RegistrationReject (OOCTXT* pctxt, H225RegistrationReject* pvalue); /**************************************************************/ /* */ /* UnregRequestReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225UnregRequestReason_reregistrationRequired 1 #define T_H225UnregRequestReason_ttlExpired 2 #define T_H225UnregRequestReason_securityDenial 3 #define T_H225UnregRequestReason_undefinedReason 4 #define T_H225UnregRequestReason_maintenance 5 #define T_H225UnregRequestReason_securityError 6 #define T_H225UnregRequestReason_extElem1 7 typedef struct EXTERN H225UnregRequestReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ H225SecurityErrors2 *securityError; /* t = 7 */ } u; } H225UnregRequestReason; EXTERN int asn1PE_H225UnregRequestReason (OOCTXT* pctxt, H225UnregRequestReason* pvalue); EXTERN int asn1PD_H225UnregRequestReason (OOCTXT* pctxt, H225UnregRequestReason* pvalue); /**************************************************************/ /* */ /* UnregistrationRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225UnregistrationRequest { struct { unsigned endpointAliasPresent : 1; unsigned nonStandardDataPresent : 1; unsigned endpointIdentifierPresent : 1; unsigned alternateEndpointsPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned reasonPresent : 1; unsigned endpointAliasPatternPresent : 1; unsigned supportedPrefixesPresent : 1; unsigned alternateGatekeeperPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225_SeqOfH225TransportAddress callSignalAddress; H225_SeqOfH225AliasAddress endpointAlias; H225NonStandardParameter nonStandardData; H225EndpointIdentifier endpointIdentifier; H225_SeqOfH225Endpoint alternateEndpoints; H225GatekeeperIdentifier gatekeeperIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225UnregRequestReason reason; H225_SeqOfH225AddressPattern endpointAliasPattern; H225_SeqOfH225SupportedPrefix supportedPrefixes; H225_SeqOfH225AlternateGK alternateGatekeeper; H225_SeqOfH225GenericData genericData; } H225UnregistrationRequest; EXTERN int asn1PE_H225UnregistrationRequest (OOCTXT* pctxt, H225UnregistrationRequest* pvalue); EXTERN int asn1PD_H225UnregistrationRequest (OOCTXT* pctxt, H225UnregistrationRequest* pvalue); /**************************************************************/ /* */ /* UnregistrationConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225UnregistrationConfirm { struct { unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225_SeqOfH225GenericData genericData; } H225UnregistrationConfirm; EXTERN int asn1PE_H225UnregistrationConfirm (OOCTXT* pctxt, H225UnregistrationConfirm* pvalue); EXTERN int asn1PD_H225UnregistrationConfirm (OOCTXT* pctxt, H225UnregistrationConfirm* pvalue); /**************************************************************/ /* */ /* UnregRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225UnregRejectReason_notCurrentlyRegistered 1 #define T_H225UnregRejectReason_callInProgress 2 #define T_H225UnregRejectReason_undefinedReason 3 #define T_H225UnregRejectReason_permissionDenied 4 #define T_H225UnregRejectReason_securityDenial 5 #define T_H225UnregRejectReason_securityError 6 #define T_H225UnregRejectReason_extElem1 7 typedef struct EXTERN H225UnregRejectReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ H225SecurityErrors2 *securityError; /* t = 7 */ } u; } H225UnregRejectReason; EXTERN int asn1PE_H225UnregRejectReason (OOCTXT* pctxt, H225UnregRejectReason* pvalue); EXTERN int asn1PD_H225UnregRejectReason (OOCTXT* pctxt, H225UnregRejectReason* pvalue); /**************************************************************/ /* */ /* UnregistrationReject */ /* */ /**************************************************************/ typedef struct EXTERN H225UnregistrationReject { struct { unsigned nonStandardDataPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225UnregRejectReason rejectReason; H225NonStandardParameter nonStandardData; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225_SeqOfH225GenericData genericData; } H225UnregistrationReject; EXTERN int asn1PE_H225UnregistrationReject (OOCTXT* pctxt, H225UnregistrationReject* pvalue); EXTERN int asn1PD_H225UnregistrationReject (OOCTXT* pctxt, H225UnregistrationReject* pvalue); /**************************************************************/ /* */ /* CallModel */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225CallModel_direct 1 #define T_H225CallModel_gatekeeperRouted 2 #define T_H225CallModel_extElem1 3 typedef struct EXTERN H225CallModel { int t; } H225CallModel; EXTERN int asn1PE_H225CallModel (OOCTXT* pctxt, H225CallModel* pvalue); EXTERN int asn1PD_H225CallModel (OOCTXT* pctxt, H225CallModel* pvalue); /**************************************************************/ /* */ /* TransportQOS */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225TransportQOS_endpointControlled 1 #define T_H225TransportQOS_gatekeeperControlled 2 #define T_H225TransportQOS_noControl 3 #define T_H225TransportQOS_extElem1 4 typedef struct EXTERN H225TransportQOS { int t; } H225TransportQOS; EXTERN int asn1PE_H225TransportQOS (OOCTXT* pctxt, H225TransportQOS* pvalue); EXTERN int asn1PD_H225TransportQOS (OOCTXT* pctxt, H225TransportQOS* pvalue); /**************************************************************/ /* */ /* AdmissionRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225AdmissionRequest { struct { unsigned callModelPresent : 1; unsigned destinationInfoPresent : 1; unsigned destCallSignalAddressPresent : 1; unsigned destExtraCallInfoPresent : 1; unsigned srcCallSignalAddressPresent : 1; unsigned nonStandardDataPresent : 1; unsigned callServicesPresent : 1; unsigned canMapAliasPresent : 1; unsigned callIdentifierPresent : 1; unsigned srcAlternativesPresent : 1; unsigned destAlternativesPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned transportQOSPresent : 1; unsigned willSupplyUUIEsPresent : 1; unsigned callLinkagePresent : 1; unsigned gatewayDataRatePresent : 1; unsigned capacityPresent : 1; unsigned circuitInfoPresent : 1; unsigned desiredProtocolsPresent : 1; unsigned desiredTunnelledProtocolPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; unsigned canMapSrcAliasPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225CallType callType; H225CallModel callModel; H225EndpointIdentifier endpointIdentifier; H225_SeqOfH225AliasAddress destinationInfo; H225TransportAddress destCallSignalAddress; H225_SeqOfH225AliasAddress destExtraCallInfo; H225_SeqOfH225AliasAddress srcInfo; H225TransportAddress srcCallSignalAddress; H225BandWidth bandWidth; H225CallReferenceValue callReferenceValue; H225NonStandardParameter nonStandardData; H225QseriesOptions callServices; H225ConferenceIdentifier conferenceID; ASN1BOOL activeMC; ASN1BOOL answerCall; ASN1BOOL canMapAlias; H225CallIdentifier callIdentifier; H225_SeqOfH225Endpoint srcAlternatives; H225_SeqOfH225Endpoint destAlternatives; H225GatekeeperIdentifier gatekeeperIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225TransportQOS transportQOS; ASN1BOOL willSupplyUUIEs; H225CallLinkage callLinkage; H225DataRate gatewayDataRate; H225CallCapacity capacity; H225CircuitInfo circuitInfo; H225_SeqOfH225SupportedProtocols desiredProtocols; H225TunnelledProtocol desiredTunnelledProtocol; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; ASN1BOOL canMapSrcAlias; } H225AdmissionRequest; EXTERN int asn1PE_H225AdmissionRequest (OOCTXT* pctxt, H225AdmissionRequest* pvalue); EXTERN int asn1PD_H225AdmissionRequest (OOCTXT* pctxt, H225AdmissionRequest* pvalue); /**************************************************************/ /* */ /* UUIEsRequested */ /* */ /**************************************************************/ typedef struct EXTERN H225UUIEsRequested { struct { unsigned statusPresent : 1; unsigned statusInquiryPresent : 1; unsigned setupAcknowledgePresent : 1; unsigned notifyPresent : 1; } m; ASN1BOOL setup; ASN1BOOL callProceeding; ASN1BOOL connect; ASN1BOOL alerting; ASN1BOOL information; ASN1BOOL releaseComplete; ASN1BOOL facility; ASN1BOOL progress; ASN1BOOL empty; ASN1BOOL status; ASN1BOOL statusInquiry; ASN1BOOL setupAcknowledge; ASN1BOOL notify; } H225UUIEsRequested; EXTERN int asn1PE_H225UUIEsRequested (OOCTXT* pctxt, H225UUIEsRequested* pvalue); EXTERN int asn1PD_H225UUIEsRequested (OOCTXT* pctxt, H225UUIEsRequested* pvalue); /**************************************************************/ /* */ /* AdmissionConfirm_language */ /* */ /**************************************************************/ typedef struct EXTERN H225AdmissionConfirm_language { ASN1UINT n; ASN1IA5String *elem; } H225AdmissionConfirm_language; EXTERN int asn1PE_H225AdmissionConfirm_language (OOCTXT* pctxt, H225AdmissionConfirm_language* pvalue); EXTERN int asn1PD_H225AdmissionConfirm_language (OOCTXT* pctxt, H225AdmissionConfirm_language* pvalue); /**************************************************************/ /* */ /* AdmissionConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225AdmissionConfirm { struct { unsigned irrFrequencyPresent : 1; unsigned nonStandardDataPresent : 1; unsigned destinationInfoPresent : 1; unsigned destExtraCallInfoPresent : 1; unsigned destinationTypePresent : 1; unsigned remoteExtensionAddressPresent : 1; unsigned alternateEndpointsPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned transportQOSPresent : 1; unsigned willRespondToIRRPresent : 1; unsigned uuiesRequestedPresent : 1; unsigned languagePresent : 1; unsigned alternateTransportAddressesPresent : 1; unsigned useSpecifiedTransportPresent : 1; unsigned circuitInfoPresent : 1; unsigned usageSpecPresent : 1; unsigned supportedProtocolsPresent : 1; unsigned serviceControlPresent : 1; unsigned multipleCallsPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; unsigned modifiedSrcInfoPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225BandWidth bandWidth; H225CallModel callModel; H225TransportAddress destCallSignalAddress; ASN1USINT irrFrequency; H225NonStandardParameter nonStandardData; H225_SeqOfH225AliasAddress destinationInfo; H225_SeqOfH225AliasAddress destExtraCallInfo; H225EndpointType destinationType; H225_SeqOfH225AliasAddress remoteExtensionAddress; H225_SeqOfH225Endpoint alternateEndpoints; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225TransportQOS transportQOS; ASN1BOOL willRespondToIRR; H225UUIEsRequested uuiesRequested; H225AdmissionConfirm_language language; H225AlternateTransportAddresses alternateTransportAddresses; H225UseSpecifiedTransport useSpecifiedTransport; H225CircuitInfo circuitInfo; H225_SeqOfH225RasUsageSpecification usageSpec; H225_SeqOfH225SupportedProtocols supportedProtocols; H225_SeqOfH225ServiceControlSession serviceControl; ASN1BOOL multipleCalls; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; H225_SeqOfH225AliasAddress modifiedSrcInfo; } H225AdmissionConfirm; EXTERN int asn1PE_H225AdmissionConfirm (OOCTXT* pctxt, H225AdmissionConfirm* pvalue); EXTERN int asn1PD_H225AdmissionConfirm (OOCTXT* pctxt, H225AdmissionConfirm* pvalue); /**************************************************************/ /* */ /* _SeqOfH225PartyNumber */ /* */ /**************************************************************/ /* List of H225PartyNumber */ typedef DList H225_SeqOfH225PartyNumber; EXTERN int asn1PE_H225_SeqOfH225PartyNumber (OOCTXT* pctxt, H225_SeqOfH225PartyNumber* pvalue); EXTERN int asn1PD_H225_SeqOfH225PartyNumber (OOCTXT* pctxt, H225_SeqOfH225PartyNumber* pvalue); /**************************************************************/ /* */ /* AdmissionRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225AdmissionRejectReason_calledPartyNotRegistered 1 #define T_H225AdmissionRejectReason_invalidPermission 2 #define T_H225AdmissionRejectReason_requestDenied 3 #define T_H225AdmissionRejectReason_undefinedReason 4 #define T_H225AdmissionRejectReason_callerNotRegistered 5 #define T_H225AdmissionRejectReason_routeCallToGatekeeper 6 #define T_H225AdmissionRejectReason_invalidEndpointIdentifier 7 #define T_H225AdmissionRejectReason_resourceUnavailable 8 #define T_H225AdmissionRejectReason_securityDenial 9 #define T_H225AdmissionRejectReason_qosControlNotSupported 10 #define T_H225AdmissionRejectReason_incompleteAddress 11 #define T_H225AdmissionRejectReason_aliasesInconsistent 12 #define T_H225AdmissionRejectReason_routeCallToSCN 13 #define T_H225AdmissionRejectReason_exceedsCallCapacity 14 #define T_H225AdmissionRejectReason_collectDestination 15 #define T_H225AdmissionRejectReason_collectPIN 16 #define T_H225AdmissionRejectReason_genericDataReason 17 #define T_H225AdmissionRejectReason_neededFeatureNotSupported 18 #define T_H225AdmissionRejectReason_securityErrors 19 #define T_H225AdmissionRejectReason_securityDHmismatch 20 #define T_H225AdmissionRejectReason_noRouteToDestination 21 #define T_H225AdmissionRejectReason_unallocatedNumber 22 #define T_H225AdmissionRejectReason_extElem1 23 typedef struct EXTERN H225AdmissionRejectReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ /* t = 9 */ /* t = 10 */ /* t = 11 */ /* t = 12 */ /* t = 13 */ H225_SeqOfH225PartyNumber *routeCallToSCN; /* t = 14 */ /* t = 15 */ /* t = 16 */ /* t = 17 */ /* t = 18 */ /* t = 19 */ H225SecurityErrors2 *securityErrors; /* t = 20 */ /* t = 21 */ /* t = 22 */ /* t = 23 */ } u; } H225AdmissionRejectReason; EXTERN int asn1PE_H225AdmissionRejectReason (OOCTXT* pctxt, H225AdmissionRejectReason* pvalue); EXTERN int asn1PD_H225AdmissionRejectReason (OOCTXT* pctxt, H225AdmissionRejectReason* pvalue); /**************************************************************/ /* */ /* AdmissionReject */ /* */ /**************************************************************/ typedef struct EXTERN H225AdmissionReject { struct { unsigned nonStandardDataPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned callSignalAddressPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned serviceControlPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225AdmissionRejectReason rejectReason; H225NonStandardParameter nonStandardData; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225_SeqOfH225TransportAddress callSignalAddress; H225ICV integrityCheckValue; H225_SeqOfH225ServiceControlSession serviceControl; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225AdmissionReject; EXTERN int asn1PE_H225AdmissionReject (OOCTXT* pctxt, H225AdmissionReject* pvalue); EXTERN int asn1PD_H225AdmissionReject (OOCTXT* pctxt, H225AdmissionReject* pvalue); /**************************************************************/ /* */ /* _SeqOfH225BandwidthDetails */ /* */ /**************************************************************/ /* List of H225BandwidthDetails */ typedef DList H225_SeqOfH225BandwidthDetails; EXTERN int asn1PE_H225_SeqOfH225BandwidthDetails (OOCTXT* pctxt, H225_SeqOfH225BandwidthDetails* pvalue); EXTERN int asn1PD_H225_SeqOfH225BandwidthDetails (OOCTXT* pctxt, H225_SeqOfH225BandwidthDetails* pvalue); /**************************************************************/ /* */ /* BandwidthRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225BandwidthRequest { struct { unsigned callTypePresent : 1; unsigned nonStandardDataPresent : 1; unsigned callIdentifierPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned answeredCallPresent : 1; unsigned callLinkagePresent : 1; unsigned capacityPresent : 1; unsigned usageInformationPresent : 1; unsigned bandwidthDetailsPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225EndpointIdentifier endpointIdentifier; H225ConferenceIdentifier conferenceID; H225CallReferenceValue callReferenceValue; H225CallType callType; H225BandWidth bandWidth; H225NonStandardParameter nonStandardData; H225CallIdentifier callIdentifier; H225GatekeeperIdentifier gatekeeperIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; ASN1BOOL answeredCall; H225CallLinkage callLinkage; H225CallCapacity capacity; H225RasUsageInformation usageInformation; H225_SeqOfH225BandwidthDetails bandwidthDetails; H225_SeqOfH225GenericData genericData; } H225BandwidthRequest; EXTERN int asn1PE_H225BandwidthRequest (OOCTXT* pctxt, H225BandwidthRequest* pvalue); EXTERN int asn1PD_H225BandwidthRequest (OOCTXT* pctxt, H225BandwidthRequest* pvalue); /**************************************************************/ /* */ /* BandwidthConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225BandwidthConfirm { struct { unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned capacityPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225BandWidth bandWidth; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225CallCapacity capacity; H225_SeqOfH225GenericData genericData; } H225BandwidthConfirm; EXTERN int asn1PE_H225BandwidthConfirm (OOCTXT* pctxt, H225BandwidthConfirm* pvalue); EXTERN int asn1PD_H225BandwidthConfirm (OOCTXT* pctxt, H225BandwidthConfirm* pvalue); /**************************************************************/ /* */ /* BandRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225BandRejectReason_notBound 1 #define T_H225BandRejectReason_invalidConferenceID 2 #define T_H225BandRejectReason_invalidPermission 3 #define T_H225BandRejectReason_insufficientResources 4 #define T_H225BandRejectReason_invalidRevision 5 #define T_H225BandRejectReason_undefinedReason 6 #define T_H225BandRejectReason_securityDenial 7 #define T_H225BandRejectReason_securityError 8 #define T_H225BandRejectReason_extElem1 9 typedef struct EXTERN H225BandRejectReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ /* t = 8 */ H225SecurityErrors2 *securityError; /* t = 9 */ } u; } H225BandRejectReason; EXTERN int asn1PE_H225BandRejectReason (OOCTXT* pctxt, H225BandRejectReason* pvalue); EXTERN int asn1PD_H225BandRejectReason (OOCTXT* pctxt, H225BandRejectReason* pvalue); /**************************************************************/ /* */ /* BandwidthReject */ /* */ /**************************************************************/ typedef struct EXTERN H225BandwidthReject { struct { unsigned nonStandardDataPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225BandRejectReason rejectReason; H225BandWidth allowedBandWidth; H225NonStandardParameter nonStandardData; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225_SeqOfH225GenericData genericData; } H225BandwidthReject; EXTERN int asn1PE_H225BandwidthReject (OOCTXT* pctxt, H225BandwidthReject* pvalue); EXTERN int asn1PD_H225BandwidthReject (OOCTXT* pctxt, H225BandwidthReject* pvalue); /**************************************************************/ /* */ /* DisengageReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225DisengageReason_forcedDrop 1 #define T_H225DisengageReason_normalDrop 2 #define T_H225DisengageReason_undefinedReason 3 #define T_H225DisengageReason_extElem1 4 typedef struct EXTERN H225DisengageReason { int t; } H225DisengageReason; EXTERN int asn1PE_H225DisengageReason (OOCTXT* pctxt, H225DisengageReason* pvalue); EXTERN int asn1PD_H225DisengageReason (OOCTXT* pctxt, H225DisengageReason* pvalue); /**************************************************************/ /* */ /* DisengageRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225DisengageRequest { struct { unsigned nonStandardDataPresent : 1; unsigned callIdentifierPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned answeredCallPresent : 1; unsigned callLinkagePresent : 1; unsigned capacityPresent : 1; unsigned circuitInfoPresent : 1; unsigned usageInformationPresent : 1; unsigned terminationCausePresent : 1; unsigned serviceControlPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225EndpointIdentifier endpointIdentifier; H225ConferenceIdentifier conferenceID; H225CallReferenceValue callReferenceValue; H225DisengageReason disengageReason; H225NonStandardParameter nonStandardData; H225CallIdentifier callIdentifier; H225GatekeeperIdentifier gatekeeperIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; ASN1BOOL answeredCall; H225CallLinkage callLinkage; H225CallCapacity capacity; H225CircuitInfo circuitInfo; H225RasUsageInformation usageInformation; H225CallTerminationCause terminationCause; H225_SeqOfH225ServiceControlSession serviceControl; H225_SeqOfH225GenericData genericData; } H225DisengageRequest; EXTERN int asn1PE_H225DisengageRequest (OOCTXT* pctxt, H225DisengageRequest* pvalue); EXTERN int asn1PD_H225DisengageRequest (OOCTXT* pctxt, H225DisengageRequest* pvalue); /**************************************************************/ /* */ /* DisengageConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225DisengageConfirm { struct { unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned capacityPresent : 1; unsigned circuitInfoPresent : 1; unsigned usageInformationPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225CallCapacity capacity; H225CircuitInfo circuitInfo; H225RasUsageInformation usageInformation; H225_SeqOfH225GenericData genericData; } H225DisengageConfirm; EXTERN int asn1PE_H225DisengageConfirm (OOCTXT* pctxt, H225DisengageConfirm* pvalue); EXTERN int asn1PD_H225DisengageConfirm (OOCTXT* pctxt, H225DisengageConfirm* pvalue); /**************************************************************/ /* */ /* DisengageRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225DisengageRejectReason_notRegistered 1 #define T_H225DisengageRejectReason_requestToDropOther 2 #define T_H225DisengageRejectReason_securityDenial 3 #define T_H225DisengageRejectReason_securityError 4 #define T_H225DisengageRejectReason_extElem1 5 typedef struct EXTERN H225DisengageRejectReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ H225SecurityErrors2 *securityError; /* t = 5 */ } u; } H225DisengageRejectReason; EXTERN int asn1PE_H225DisengageRejectReason (OOCTXT* pctxt, H225DisengageRejectReason* pvalue); EXTERN int asn1PD_H225DisengageRejectReason (OOCTXT* pctxt, H225DisengageRejectReason* pvalue); /**************************************************************/ /* */ /* DisengageReject */ /* */ /**************************************************************/ typedef struct EXTERN H225DisengageReject { struct { unsigned nonStandardDataPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225DisengageRejectReason rejectReason; H225NonStandardParameter nonStandardData; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225_SeqOfH225GenericData genericData; } H225DisengageReject; EXTERN int asn1PE_H225DisengageReject (OOCTXT* pctxt, H225DisengageReject* pvalue); EXTERN int asn1PD_H225DisengageReject (OOCTXT* pctxt, H225DisengageReject* pvalue); /**************************************************************/ /* */ /* LocationRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225LocationRequest { struct { unsigned endpointIdentifierPresent : 1; unsigned nonStandardDataPresent : 1; unsigned sourceInfoPresent : 1; unsigned canMapAliasPresent : 1; unsigned gatekeeperIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned desiredProtocolsPresent : 1; unsigned desiredTunnelledProtocolPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; unsigned hopCountPresent : 1; unsigned circuitInfoPresent : 1; unsigned callIdentifierPresent : 1; unsigned bandWidthPresent : 1; unsigned sourceEndpointInfoPresent : 1; unsigned canMapSrcAliasPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225EndpointIdentifier endpointIdentifier; H225_SeqOfH225AliasAddress destinationInfo; H225NonStandardParameter nonStandardData; H225TransportAddress replyAddress; H225_SeqOfH225AliasAddress sourceInfo; ASN1BOOL canMapAlias; H225GatekeeperIdentifier gatekeeperIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225_SeqOfH225SupportedProtocols desiredProtocols; H225TunnelledProtocol desiredTunnelledProtocol; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; ASN1UINT8 hopCount; H225CircuitInfo circuitInfo; H225CallIdentifier callIdentifier; H225BandWidth bandWidth; H225_SeqOfH225AliasAddress sourceEndpointInfo; ASN1BOOL canMapSrcAlias; } H225LocationRequest; EXTERN int asn1PE_H225LocationRequest (OOCTXT* pctxt, H225LocationRequest* pvalue); EXTERN int asn1PD_H225LocationRequest (OOCTXT* pctxt, H225LocationRequest* pvalue); /**************************************************************/ /* */ /* LocationConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225LocationConfirm { struct { unsigned nonStandardDataPresent : 1; unsigned destinationInfoPresent : 1; unsigned destExtraCallInfoPresent : 1; unsigned destinationTypePresent : 1; unsigned remoteExtensionAddressPresent : 1; unsigned alternateEndpointsPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned alternateTransportAddressesPresent : 1; unsigned supportedProtocolsPresent : 1; unsigned multipleCallsPresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; unsigned circuitInfoPresent : 1; unsigned serviceControlPresent : 1; unsigned modifiedSrcInfoPresent : 1; unsigned bandWidthPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225TransportAddress callSignalAddress; H225TransportAddress rasAddress; H225NonStandardParameter nonStandardData; H225_SeqOfH225AliasAddress destinationInfo; H225_SeqOfH225AliasAddress destExtraCallInfo; H225EndpointType destinationType; H225_SeqOfH225AliasAddress remoteExtensionAddress; H225_SeqOfH225Endpoint alternateEndpoints; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225AlternateTransportAddresses alternateTransportAddresses; H225_SeqOfH225SupportedProtocols supportedProtocols; ASN1BOOL multipleCalls; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; H225CircuitInfo circuitInfo; H225_SeqOfH225ServiceControlSession serviceControl; H225_SeqOfH225AliasAddress modifiedSrcInfo; H225BandWidth bandWidth; } H225LocationConfirm; EXTERN int asn1PE_H225LocationConfirm (OOCTXT* pctxt, H225LocationConfirm* pvalue); EXTERN int asn1PD_H225LocationConfirm (OOCTXT* pctxt, H225LocationConfirm* pvalue); /**************************************************************/ /* */ /* LocationRejectReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225LocationRejectReason_notRegistered 1 #define T_H225LocationRejectReason_invalidPermission 2 #define T_H225LocationRejectReason_requestDenied 3 #define T_H225LocationRejectReason_undefinedReason 4 #define T_H225LocationRejectReason_securityDenial 5 #define T_H225LocationRejectReason_aliasesInconsistent 6 #define T_H225LocationRejectReason_routeCalltoSCN 7 #define T_H225LocationRejectReason_resourceUnavailable 8 #define T_H225LocationRejectReason_genericDataReason 9 #define T_H225LocationRejectReason_neededFeatureNotSupported 10 #define T_H225LocationRejectReason_hopCountExceeded 11 #define T_H225LocationRejectReason_incompleteAddress 12 #define T_H225LocationRejectReason_securityError 13 #define T_H225LocationRejectReason_securityDHmismatch 14 #define T_H225LocationRejectReason_noRouteToDestination 15 #define T_H225LocationRejectReason_unallocatedNumber 16 #define T_H225LocationRejectReason_extElem1 17 typedef struct EXTERN H225LocationRejectReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ /* t = 5 */ /* t = 6 */ /* t = 7 */ H225_SeqOfH225PartyNumber *routeCalltoSCN; /* t = 8 */ /* t = 9 */ /* t = 10 */ /* t = 11 */ /* t = 12 */ /* t = 13 */ H225SecurityErrors2 *securityError; /* t = 14 */ /* t = 15 */ /* t = 16 */ /* t = 17 */ } u; } H225LocationRejectReason; EXTERN int asn1PE_H225LocationRejectReason (OOCTXT* pctxt, H225LocationRejectReason* pvalue); EXTERN int asn1PD_H225LocationRejectReason (OOCTXT* pctxt, H225LocationRejectReason* pvalue); /**************************************************************/ /* */ /* LocationReject */ /* */ /**************************************************************/ typedef struct EXTERN H225LocationReject { struct { unsigned nonStandardDataPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; unsigned serviceControlPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225LocationRejectReason rejectReason; H225NonStandardParameter nonStandardData; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; H225_SeqOfH225ServiceControlSession serviceControl; } H225LocationReject; EXTERN int asn1PE_H225LocationReject (OOCTXT* pctxt, H225LocationReject* pvalue); EXTERN int asn1PD_H225LocationReject (OOCTXT* pctxt, H225LocationReject* pvalue); /**************************************************************/ /* */ /* InfoRequest */ /* */ /**************************************************************/ typedef struct EXTERN H225InfoRequest { struct { unsigned nonStandardDataPresent : 1; unsigned replyAddressPresent : 1; unsigned callIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned uuiesRequestedPresent : 1; unsigned callLinkagePresent : 1; unsigned usageInfoRequestedPresent : 1; unsigned segmentedResponseSupportedPresent : 1; unsigned nextSegmentRequestedPresent : 1; unsigned capacityInfoRequestedPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225CallReferenceValue callReferenceValue; H225NonStandardParameter nonStandardData; H225TransportAddress replyAddress; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225UUIEsRequested uuiesRequested; H225CallLinkage callLinkage; H225RasUsageInfoTypes usageInfoRequested; ASN1USINT nextSegmentRequested; H225_SeqOfH225GenericData genericData; } H225InfoRequest; EXTERN int asn1PE_H225InfoRequest (OOCTXT* pctxt, H225InfoRequest* pvalue); EXTERN int asn1PD_H225InfoRequest (OOCTXT* pctxt, H225InfoRequest* pvalue); /**************************************************************/ /* */ /* _SeqOfH225RTPSession */ /* */ /**************************************************************/ /* List of H225RTPSession */ typedef DList H225_SeqOfH225RTPSession; EXTERN int asn1PE_H225_SeqOfH225RTPSession (OOCTXT* pctxt, H225_SeqOfH225RTPSession* pvalue); EXTERN int asn1PD_H225_SeqOfH225RTPSession (OOCTXT* pctxt, H225_SeqOfH225RTPSession* pvalue); /**************************************************************/ /* */ /* _SeqOfH225TransportChannelInfo */ /* */ /**************************************************************/ /* List of H225TransportChannelInfo */ typedef DList H225_SeqOfH225TransportChannelInfo; EXTERN int asn1PE_H225_SeqOfH225TransportChannelInfo (OOCTXT* pctxt, H225_SeqOfH225TransportChannelInfo* pvalue); EXTERN int asn1PD_H225_SeqOfH225TransportChannelInfo (OOCTXT* pctxt, H225_SeqOfH225TransportChannelInfo* pvalue); /**************************************************************/ /* */ /* _SeqOfH225ConferenceIdentifier */ /* */ /**************************************************************/ typedef struct EXTERN H225_SeqOfH225ConferenceIdentifier { ASN1UINT n; H225ConferenceIdentifier *elem; } H225_SeqOfH225ConferenceIdentifier; EXTERN int asn1PE_H225_SeqOfH225ConferenceIdentifier (OOCTXT* pctxt, H225_SeqOfH225ConferenceIdentifier* pvalue); EXTERN int asn1PD_H225_SeqOfH225ConferenceIdentifier (OOCTXT* pctxt, H225_SeqOfH225ConferenceIdentifier* pvalue); /**************************************************************/ /* */ /* InfoRequestResponse_perCallInfo_element_pdu_element */ /* */ /**************************************************************/ typedef struct EXTERN H225InfoRequestResponse_perCallInfo_element_pdu_element { H225H323_UU_PDU h323pdu; ASN1BOOL sent; } H225InfoRequestResponse_perCallInfo_element_pdu_element; EXTERN int asn1PE_H225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue); EXTERN int asn1PD_H225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue); /**************************************************************/ /* */ /* _SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_el */ /* */ /**************************************************************/ /* List of H225InfoRequestResponse_perCallInfo_element_pdu_element */ typedef DList H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element; EXTERN int asn1PE_H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue); EXTERN int asn1PD_H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue); /**************************************************************/ /* */ /* InfoRequestResponse_perCallInfo_element */ /* */ /**************************************************************/ typedef struct EXTERN H225InfoRequestResponse_perCallInfo_element { struct { unsigned nonStandardDataPresent : 1; unsigned originatorPresent : 1; unsigned audioPresent : 1; unsigned videoPresent : 1; unsigned dataPresent : 1; unsigned callIdentifierPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned substituteConfIDsPresent : 1; unsigned pduPresent : 1; unsigned callLinkagePresent : 1; unsigned usageInformationPresent : 1; unsigned circuitInfoPresent : 1; } m; H225NonStandardParameter nonStandardData; H225CallReferenceValue callReferenceValue; H225ConferenceIdentifier conferenceID; ASN1BOOL originator; H225_SeqOfH225RTPSession audio; H225_SeqOfH225RTPSession video; H225_SeqOfH225TransportChannelInfo data; H225TransportChannelInfo h245; H225TransportChannelInfo callSignaling; H225CallType callType; H225BandWidth bandWidth; H225CallModel callModel; H225CallIdentifier callIdentifier; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225_SeqOfH225ConferenceIdentifier substituteConfIDs; H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element pdu; H225CallLinkage callLinkage; H225RasUsageInformation usageInformation; H225CircuitInfo circuitInfo; } H225InfoRequestResponse_perCallInfo_element; EXTERN int asn1PE_H225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element* pvalue); EXTERN int asn1PD_H225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element* pvalue); /**************************************************************/ /* */ /* _SeqOfH225InfoRequestResponse_perCallInfo_element */ /* */ /**************************************************************/ /* List of H225InfoRequestResponse_perCallInfo_element */ typedef DList H225_SeqOfH225InfoRequestResponse_perCallInfo_element; EXTERN int asn1PE_H225_SeqOfH225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element* pvalue); EXTERN int asn1PD_H225_SeqOfH225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element* pvalue); /**************************************************************/ /* */ /* InfoRequestResponseStatus */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225InfoRequestResponseStatus_complete 1 #define T_H225InfoRequestResponseStatus_incomplete 2 #define T_H225InfoRequestResponseStatus_segment 3 #define T_H225InfoRequestResponseStatus_invalidCall 4 #define T_H225InfoRequestResponseStatus_extElem1 5 typedef struct EXTERN H225InfoRequestResponseStatus { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ ASN1USINT segment; /* t = 4 */ /* t = 5 */ } u; } H225InfoRequestResponseStatus; EXTERN int asn1PE_H225InfoRequestResponseStatus (OOCTXT* pctxt, H225InfoRequestResponseStatus* pvalue); EXTERN int asn1PD_H225InfoRequestResponseStatus (OOCTXT* pctxt, H225InfoRequestResponseStatus* pvalue); /**************************************************************/ /* */ /* InfoRequestResponse */ /* */ /**************************************************************/ typedef struct EXTERN H225InfoRequestResponse { struct { unsigned nonStandardDataPresent : 1; unsigned endpointAliasPresent : 1; unsigned perCallInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned needResponsePresent : 1; unsigned capacityPresent : 1; unsigned irrStatusPresent : 1; unsigned unsolicitedPresent : 1; unsigned genericDataPresent : 1; } m; H225NonStandardParameter nonStandardData; H225RequestSeqNum requestSeqNum; H225EndpointType endpointType; H225EndpointIdentifier endpointIdentifier; H225TransportAddress rasAddress; H225_SeqOfH225TransportAddress callSignalAddress; H225_SeqOfH225AliasAddress endpointAlias; H225_SeqOfH225InfoRequestResponse_perCallInfo_element perCallInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; ASN1BOOL needResponse; H225CallCapacity capacity; H225InfoRequestResponseStatus irrStatus; ASN1BOOL unsolicited; H225_SeqOfH225GenericData genericData; } H225InfoRequestResponse; EXTERN int asn1PE_H225InfoRequestResponse (OOCTXT* pctxt, H225InfoRequestResponse* pvalue); EXTERN int asn1PD_H225InfoRequestResponse (OOCTXT* pctxt, H225InfoRequestResponse* pvalue); /**************************************************************/ /* */ /* NonStandardMessage */ /* */ /**************************************************************/ typedef struct EXTERN H225NonStandardMessage { struct { unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225NonStandardMessage; EXTERN int asn1PE_H225NonStandardMessage (OOCTXT* pctxt, H225NonStandardMessage* pvalue); EXTERN int asn1PD_H225NonStandardMessage (OOCTXT* pctxt, H225NonStandardMessage* pvalue); /**************************************************************/ /* */ /* UnknownMessageResponse */ /* */ /**************************************************************/ typedef struct EXTERN H225UnknownMessageResponse { struct { unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned messageNotUnderstoodPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; ASN1DynOctStr messageNotUnderstood; } H225UnknownMessageResponse; EXTERN int asn1PE_H225UnknownMessageResponse (OOCTXT* pctxt, H225UnknownMessageResponse* pvalue); EXTERN int asn1PD_H225UnknownMessageResponse (OOCTXT* pctxt, H225UnknownMessageResponse* pvalue); /**************************************************************/ /* */ /* RequestInProgress */ /* */ /**************************************************************/ typedef struct EXTERN H225RequestInProgress { struct { unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; } m; H225RequestSeqNum requestSeqNum; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; ASN1USINT delay; } H225RequestInProgress; EXTERN int asn1PE_H225RequestInProgress (OOCTXT* pctxt, H225RequestInProgress* pvalue); EXTERN int asn1PD_H225RequestInProgress (OOCTXT* pctxt, H225RequestInProgress* pvalue); /**************************************************************/ /* */ /* ResourcesAvailableIndicate */ /* */ /**************************************************************/ typedef struct EXTERN H225ResourcesAvailableIndicate { struct { unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned capacityPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; H225EndpointIdentifier endpointIdentifier; H225_SeqOfH225SupportedProtocols protocols; ASN1BOOL almostOutOfResources; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225CallCapacity capacity; H225_SeqOfH225GenericData genericData; } H225ResourcesAvailableIndicate; EXTERN int asn1PE_H225ResourcesAvailableIndicate (OOCTXT* pctxt, H225ResourcesAvailableIndicate* pvalue); EXTERN int asn1PD_H225ResourcesAvailableIndicate (OOCTXT* pctxt, H225ResourcesAvailableIndicate* pvalue); /**************************************************************/ /* */ /* ResourcesAvailableConfirm */ /* */ /**************************************************************/ typedef struct EXTERN H225ResourcesAvailableConfirm { struct { unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ProtocolIdentifier protocolIdentifier; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225_SeqOfH225GenericData genericData; } H225ResourcesAvailableConfirm; EXTERN int asn1PE_H225ResourcesAvailableConfirm (OOCTXT* pctxt, H225ResourcesAvailableConfirm* pvalue); EXTERN int asn1PD_H225ResourcesAvailableConfirm (OOCTXT* pctxt, H225ResourcesAvailableConfirm* pvalue); /**************************************************************/ /* */ /* InfoRequestAck */ /* */ /**************************************************************/ typedef struct EXTERN H225InfoRequestAck { struct { unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; } m; H225RequestSeqNum requestSeqNum; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; } H225InfoRequestAck; EXTERN int asn1PE_H225InfoRequestAck (OOCTXT* pctxt, H225InfoRequestAck* pvalue); EXTERN int asn1PD_H225InfoRequestAck (OOCTXT* pctxt, H225InfoRequestAck* pvalue); /**************************************************************/ /* */ /* InfoRequestNakReason */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225InfoRequestNakReason_notRegistered 1 #define T_H225InfoRequestNakReason_securityDenial 2 #define T_H225InfoRequestNakReason_undefinedReason 3 #define T_H225InfoRequestNakReason_securityError 4 #define T_H225InfoRequestNakReason_extElem1 5 typedef struct EXTERN H225InfoRequestNakReason { int t; union { /* t = 1 */ /* t = 2 */ /* t = 3 */ /* t = 4 */ H225SecurityErrors2 *securityError; /* t = 5 */ } u; } H225InfoRequestNakReason; EXTERN int asn1PE_H225InfoRequestNakReason (OOCTXT* pctxt, H225InfoRequestNakReason* pvalue); EXTERN int asn1PD_H225InfoRequestNakReason (OOCTXT* pctxt, H225InfoRequestNakReason* pvalue); /**************************************************************/ /* */ /* InfoRequestNak */ /* */ /**************************************************************/ typedef struct EXTERN H225InfoRequestNak { struct { unsigned nonStandardDataPresent : 1; unsigned altGKInfoPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; } m; H225RequestSeqNum requestSeqNum; H225NonStandardParameter nonStandardData; H225InfoRequestNakReason nakReason; H225AltGKInfo altGKInfo; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; } H225InfoRequestNak; EXTERN int asn1PE_H225InfoRequestNak (OOCTXT* pctxt, H225InfoRequestNak* pvalue); EXTERN int asn1PD_H225InfoRequestNak (OOCTXT* pctxt, H225InfoRequestNak* pvalue); /**************************************************************/ /* */ /* ServiceControlIndication_callSpecific */ /* */ /**************************************************************/ typedef struct EXTERN H225ServiceControlIndication_callSpecific { H225CallIdentifier callIdentifier; H225ConferenceIdentifier conferenceID; ASN1BOOL answeredCall; } H225ServiceControlIndication_callSpecific; EXTERN int asn1PE_H225ServiceControlIndication_callSpecific (OOCTXT* pctxt, H225ServiceControlIndication_callSpecific* pvalue); EXTERN int asn1PD_H225ServiceControlIndication_callSpecific (OOCTXT* pctxt, H225ServiceControlIndication_callSpecific* pvalue); /**************************************************************/ /* */ /* ServiceControlIndication */ /* */ /**************************************************************/ typedef struct EXTERN H225ServiceControlIndication { struct { unsigned nonStandardDataPresent : 1; unsigned endpointIdentifierPresent : 1; unsigned callSpecificPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225NonStandardParameter nonStandardData; H225_SeqOfH225ServiceControlSession serviceControl; H225EndpointIdentifier endpointIdentifier; H225ServiceControlIndication_callSpecific callSpecific; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225ServiceControlIndication; EXTERN int asn1PE_H225ServiceControlIndication (OOCTXT* pctxt, H225ServiceControlIndication* pvalue); EXTERN int asn1PD_H225ServiceControlIndication (OOCTXT* pctxt, H225ServiceControlIndication* pvalue); /**************************************************************/ /* */ /* ServiceControlResponse_result */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225ServiceControlResponse_result_started 1 #define T_H225ServiceControlResponse_result_failed 2 #define T_H225ServiceControlResponse_result_stopped 3 #define T_H225ServiceControlResponse_result_notAvailable 4 #define T_H225ServiceControlResponse_result_neededFeatureNotSupported 5 #define T_H225ServiceControlResponse_result_extElem1 6 typedef struct EXTERN H225ServiceControlResponse_result { int t; } H225ServiceControlResponse_result; EXTERN int asn1PE_H225ServiceControlResponse_result (OOCTXT* pctxt, H225ServiceControlResponse_result* pvalue); EXTERN int asn1PD_H225ServiceControlResponse_result (OOCTXT* pctxt, H225ServiceControlResponse_result* pvalue); /**************************************************************/ /* */ /* ServiceControlResponse */ /* */ /**************************************************************/ typedef struct EXTERN H225ServiceControlResponse { struct { unsigned resultPresent : 1; unsigned nonStandardDataPresent : 1; unsigned tokensPresent : 1; unsigned cryptoTokensPresent : 1; unsigned integrityCheckValuePresent : 1; unsigned featureSetPresent : 1; unsigned genericDataPresent : 1; } m; H225RequestSeqNum requestSeqNum; H225ServiceControlResponse_result result; H225NonStandardParameter nonStandardData; H225_SeqOfH225ClearToken tokens; H225_SeqOfH225CryptoH323Token cryptoTokens; H225ICV integrityCheckValue; H225FeatureSet featureSet; H225_SeqOfH225GenericData genericData; } H225ServiceControlResponse; EXTERN int asn1PE_H225ServiceControlResponse (OOCTXT* pctxt, H225ServiceControlResponse* pvalue); EXTERN int asn1PD_H225ServiceControlResponse (OOCTXT* pctxt, H225ServiceControlResponse* pvalue); /**************************************************************/ /* */ /* _SeqOfH225AdmissionConfirm */ /* */ /**************************************************************/ /* List of H225AdmissionConfirm */ typedef DList H225_SeqOfH225AdmissionConfirm; EXTERN int asn1PE_H225_SeqOfH225AdmissionConfirm (OOCTXT* pctxt, H225_SeqOfH225AdmissionConfirm* pvalue); EXTERN int asn1PD_H225_SeqOfH225AdmissionConfirm (OOCTXT* pctxt, H225_SeqOfH225AdmissionConfirm* pvalue); /**************************************************************/ /* */ /* RasMessage */ /* */ /**************************************************************/ /* Choice tag constants */ #define T_H225RasMessage_gatekeeperRequest 1 #define T_H225RasMessage_gatekeeperConfirm 2 #define T_H225RasMessage_gatekeeperReject 3 #define T_H225RasMessage_registrationRequest 4 #define T_H225RasMessage_registrationConfirm 5 #define T_H225RasMessage_registrationReject 6 #define T_H225RasMessage_unregistrationRequest 7 #define T_H225RasMessage_unregistrationConfirm 8 #define T_H225RasMessage_unregistrationReject 9 #define T_H225RasMessage_admissionRequest 10 #define T_H225RasMessage_admissionConfirm 11 #define T_H225RasMessage_admissionReject 12 #define T_H225RasMessage_bandwidthRequest 13 #define T_H225RasMessage_bandwidthConfirm 14 #define T_H225RasMessage_bandwidthReject 15 #define T_H225RasMessage_disengageRequest 16 #define T_H225RasMessage_disengageConfirm 17 #define T_H225RasMessage_disengageReject 18 #define T_H225RasMessage_locationRequest 19 #define T_H225RasMessage_locationConfirm 20 #define T_H225RasMessage_locationReject 21 #define T_H225RasMessage_infoRequest 22 #define T_H225RasMessage_infoRequestResponse 23 #define T_H225RasMessage_nonStandardMessage 24 #define T_H225RasMessage_unknownMessageResponse 25 #define T_H225RasMessage_requestInProgress 26 #define T_H225RasMessage_resourcesAvailableIndicate 27 #define T_H225RasMessage_resourcesAvailableConfirm 28 #define T_H225RasMessage_infoRequestAck 29 #define T_H225RasMessage_infoRequestNak 30 #define T_H225RasMessage_serviceControlIndication 31 #define T_H225RasMessage_serviceControlResponse 32 #define T_H225RasMessage_admissionConfirmSequence 33 #define T_H225RasMessage_extElem1 34 typedef struct EXTERN H225RasMessage { int t; union { /* t = 1 */ H225GatekeeperRequest *gatekeeperRequest; /* t = 2 */ H225GatekeeperConfirm *gatekeeperConfirm; /* t = 3 */ H225GatekeeperReject *gatekeeperReject; /* t = 4 */ H225RegistrationRequest *registrationRequest; /* t = 5 */ H225RegistrationConfirm *registrationConfirm; /* t = 6 */ H225RegistrationReject *registrationReject; /* t = 7 */ H225UnregistrationRequest *unregistrationRequest; /* t = 8 */ H225UnregistrationConfirm *unregistrationConfirm; /* t = 9 */ H225UnregistrationReject *unregistrationReject; /* t = 10 */ H225AdmissionRequest *admissionRequest; /* t = 11 */ H225AdmissionConfirm *admissionConfirm; /* t = 12 */ H225AdmissionReject *admissionReject; /* t = 13 */ H225BandwidthRequest *bandwidthRequest; /* t = 14 */ H225BandwidthConfirm *bandwidthConfirm; /* t = 15 */ H225BandwidthReject *bandwidthReject; /* t = 16 */ H225DisengageRequest *disengageRequest; /* t = 17 */ H225DisengageConfirm *disengageConfirm; /* t = 18 */ H225DisengageReject *disengageReject; /* t = 19 */ H225LocationRequest *locationRequest; /* t = 20 */ H225LocationConfirm *locationConfirm; /* t = 21 */ H225LocationReject *locationReject; /* t = 22 */ H225InfoRequest *infoRequest; /* t = 23 */ H225InfoRequestResponse *infoRequestResponse; /* t = 24 */ H225NonStandardMessage *nonStandardMessage; /* t = 25 */ H225UnknownMessageResponse *unknownMessageResponse; /* t = 26 */ H225RequestInProgress *requestInProgress; /* t = 27 */ H225ResourcesAvailableIndicate *resourcesAvailableIndicate; /* t = 28 */ H225ResourcesAvailableConfirm *resourcesAvailableConfirm; /* t = 29 */ H225InfoRequestAck *infoRequestAck; /* t = 30 */ H225InfoRequestNak *infoRequestNak; /* t = 31 */ H225ServiceControlIndication *serviceControlIndication; /* t = 32 */ H225ServiceControlResponse *serviceControlResponse; /* t = 33 */ H225_SeqOfH225AdmissionConfirm *admissionConfirmSequence; /* t = 34 */ } u; } H225RasMessage; EXTERN int asn1PE_H225RasMessage (OOCTXT* pctxt, H225RasMessage* pvalue); EXTERN int asn1PD_H225RasMessage (OOCTXT* pctxt, H225RasMessage* pvalue); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/h323/MULTIMEDIA-SYSTEM-CONTROLDec.c0000644000175000007640000444736711274375744023664 0ustar sharkyjerryweb/* * 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" #include "eventHandler.h" /**************************************************************/ /* */ /* NonStandardIdentifier_h221NonStandard */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NonStandardIdentifier_h221NonStandard (OOCTXT* pctxt, H245NonStandardIdentifier_h221NonStandard* pvalue) { int stat = ASN_OK; /* decode t35CountryCode */ invokeStartElement (pctxt, "t35CountryCode", -1); stat = decodeConsUInt8 (pctxt, &pvalue->t35CountryCode, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->t35CountryCode); invokeEndElement (pctxt, "t35CountryCode", -1); /* decode t35Extension */ invokeStartElement (pctxt, "t35Extension", -1); stat = decodeConsUInt8 (pctxt, &pvalue->t35Extension, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->t35Extension); invokeEndElement (pctxt, "t35Extension", -1); /* decode manufacturerCode */ invokeStartElement (pctxt, "manufacturerCode", -1); stat = decodeConsUInt16 (pctxt, &pvalue->manufacturerCode, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->manufacturerCode); invokeEndElement (pctxt, "manufacturerCode", -1); return (stat); } /**************************************************************/ /* */ /* NonStandardIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NonStandardIdentifier (OOCTXT* pctxt, H245NonStandardIdentifier* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* object */ case 0: invokeStartElement (pctxt, "object", -1); pvalue->u.object = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.object); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.object->numids, pvalue->u.object->subid); invokeEndElement (pctxt, "object", -1); break; /* h221NonStandard */ case 1: invokeStartElement (pctxt, "h221NonStandard", -1); pvalue->u.h221NonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardIdentifier_h221NonStandard); stat = asn1PD_H245NonStandardIdentifier_h221NonStandard (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h221NonStandard", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NonStandardParameter (OOCTXT* pctxt, H245NonStandardParameter* pvalue) { int stat = ASN_OK; /* decode nonStandardIdentifier */ invokeStartElement (pctxt, "nonStandardIdentifier", -1); stat = asn1PD_H245NonStandardIdentifier (pctxt, &pvalue->nonStandardIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardIdentifier", -1); /* decode data */ invokeStartElement (pctxt, "data", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->data); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->data.numocts, pvalue->data.data); invokeEndElement (pctxt, "data", -1); return (stat); } /**************************************************************/ /* */ /* V42bis */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V42bis (OOCTXT* pctxt, H245V42bis* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode numberOfCodewords */ invokeStartElement (pctxt, "numberOfCodewords", -1); stat = decodeConsUnsigned (pctxt, &pvalue->numberOfCodewords, 1U, 65536U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfCodewords); invokeEndElement (pctxt, "numberOfCodewords", -1); /* decode maximumStringLength */ invokeStartElement (pctxt, "maximumStringLength", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumStringLength, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumStringLength); invokeEndElement (pctxt, "maximumStringLength", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CompressionType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CompressionType (OOCTXT* pctxt, H245CompressionType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* v42bis */ case 0: invokeStartElement (pctxt, "v42bis", -1); pvalue->u.v42bis = ALLOC_ASN1ELEM (pctxt, H245V42bis); stat = asn1PD_H245V42bis (pctxt, pvalue->u.v42bis); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v42bis", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* DataProtocolCapability_v76wCompression */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataProtocolCapability_v76wCompression (OOCTXT* pctxt, H245DataProtocolCapability_v76wCompression* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* transmitCompression */ case 0: invokeStartElement (pctxt, "transmitCompression", -1); pvalue->u.transmitCompression = ALLOC_ASN1ELEM (pctxt, H245CompressionType); stat = asn1PD_H245CompressionType (pctxt, pvalue->u.transmitCompression); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitCompression", -1); break; /* receiveCompression */ case 1: invokeStartElement (pctxt, "receiveCompression", -1); pvalue->u.receiveCompression = ALLOC_ASN1ELEM (pctxt, H245CompressionType); stat = asn1PD_H245CompressionType (pctxt, pvalue->u.receiveCompression); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveCompression", -1); break; /* transmitAndReceiveCompression */ case 2: invokeStartElement (pctxt, "transmitAndReceiveCompression", -1); pvalue->u.transmitAndReceiveCompression = ALLOC_ASN1ELEM (pctxt, H245CompressionType); stat = asn1PD_H245CompressionType (pctxt, pvalue->u.transmitAndReceiveCompression); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitAndReceiveCompression", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* DataProtocolCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataProtocolCapability (OOCTXT* pctxt, H245DataProtocolCapability* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 6); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* v14buffered */ case 1: invokeStartElement (pctxt, "v14buffered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v14buffered", -1); break; /* v42lapm */ case 2: invokeStartElement (pctxt, "v42lapm", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v42lapm", -1); break; /* hdlcFrameTunnelling */ case 3: invokeStartElement (pctxt, "hdlcFrameTunnelling", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hdlcFrameTunnelling", -1); break; /* h310SeparateVCStack */ case 4: invokeStartElement (pctxt, "h310SeparateVCStack", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "h310SeparateVCStack", -1); break; /* h310SingleVCStack */ case 5: invokeStartElement (pctxt, "h310SingleVCStack", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "h310SingleVCStack", -1); break; /* transparent */ case 6: invokeStartElement (pctxt, "transparent", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transparent", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 8; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* segmentationAndReassembly */ case 8: invokeStartElement (pctxt, "segmentationAndReassembly", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "segmentationAndReassembly", -1); break; /* hdlcFrameTunnelingwSAR */ case 9: invokeStartElement (pctxt, "hdlcFrameTunnelingwSAR", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hdlcFrameTunnelingwSAR", -1); break; /* v120 */ case 10: invokeStartElement (pctxt, "v120", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v120", -1); break; /* separateLANStack */ case 11: invokeStartElement (pctxt, "separateLANStack", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "separateLANStack", -1); break; /* v76wCompression */ case 12: invokeStartElement (pctxt, "v76wCompression", -1); pvalue->u.v76wCompression = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability_v76wCompression); stat = asn1PD_H245DataProtocolCapability_v76wCompression (pctxt, pvalue->u.v76wCompression); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v76wCompression", -1); break; /* tcp */ case 13: invokeStartElement (pctxt, "tcp", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "tcp", -1); break; /* udp */ case 14: invokeStartElement (pctxt, "udp", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "udp", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* T38FaxRateManagement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245T38FaxRateManagement (OOCTXT* pctxt, H245T38FaxRateManagement* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* localTCF */ case 0: invokeStartElement (pctxt, "localTCF", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "localTCF", -1); break; /* transferredTCF */ case 1: invokeStartElement (pctxt, "transferredTCF", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transferredTCF", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* T38FaxUdpOptions_t38FaxUdpEC */ /* */ /**************************************************************/ EXTERN int asn1PD_H245T38FaxUdpOptions_t38FaxUdpEC (OOCTXT* pctxt, H245T38FaxUdpOptions_t38FaxUdpEC* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* t38UDPFEC */ case 0: invokeStartElement (pctxt, "t38UDPFEC", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "t38UDPFEC", -1); break; /* t38UDPRedundancy */ case 1: invokeStartElement (pctxt, "t38UDPRedundancy", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "t38UDPRedundancy", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* T38FaxUdpOptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245T38FaxUdpOptions (OOCTXT* pctxt, H245T38FaxUdpOptions* pvalue) { int stat = ASN_OK; ASN1BOOL optbit = 0; /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.t38FaxMaxBufferPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.t38FaxMaxDatagramPresent = optbit; /* decode t38FaxMaxBuffer */ if (pvalue->m.t38FaxMaxBufferPresent) { invokeStartElement (pctxt, "t38FaxMaxBuffer", -1); stat = decodeUnconsInteger (pctxt, &pvalue->t38FaxMaxBuffer); if (stat != ASN_OK) return stat; invokeIntValue (pctxt, pvalue->t38FaxMaxBuffer); invokeEndElement (pctxt, "t38FaxMaxBuffer", -1); } /* decode t38FaxMaxDatagram */ if (pvalue->m.t38FaxMaxDatagramPresent) { invokeStartElement (pctxt, "t38FaxMaxDatagram", -1); stat = decodeUnconsInteger (pctxt, &pvalue->t38FaxMaxDatagram); if (stat != ASN_OK) return stat; invokeIntValue (pctxt, pvalue->t38FaxMaxDatagram); invokeEndElement (pctxt, "t38FaxMaxDatagram", -1); } /* decode t38FaxUdpEC */ invokeStartElement (pctxt, "t38FaxUdpEC", -1); stat = asn1PD_H245T38FaxUdpOptions_t38FaxUdpEC (pctxt, &pvalue->t38FaxUdpEC); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxUdpEC", -1); return (stat); } /**************************************************************/ /* */ /* T38FaxTcpOptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245T38FaxTcpOptions (OOCTXT* pctxt, H245T38FaxTcpOptions* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode t38TCPBidirectionalMode */ invokeStartElement (pctxt, "t38TCPBidirectionalMode", -1); stat = DECODEBIT (pctxt, &pvalue->t38TCPBidirectionalMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->t38TCPBidirectionalMode); invokeEndElement (pctxt, "t38TCPBidirectionalMode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* T38FaxProfile */ /* */ /**************************************************************/ EXTERN int asn1PD_H245T38FaxProfile (OOCTXT* pctxt, H245T38FaxProfile* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode fillBitRemoval */ invokeStartElement (pctxt, "fillBitRemoval", -1); stat = DECODEBIT (pctxt, &pvalue->fillBitRemoval); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fillBitRemoval); invokeEndElement (pctxt, "fillBitRemoval", -1); /* decode transcodingJBIG */ invokeStartElement (pctxt, "transcodingJBIG", -1); stat = DECODEBIT (pctxt, &pvalue->transcodingJBIG); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->transcodingJBIG); invokeEndElement (pctxt, "transcodingJBIG", -1); /* decode transcodingMMR */ invokeStartElement (pctxt, "transcodingMMR", -1); stat = DECODEBIT (pctxt, &pvalue->transcodingMMR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->transcodingMMR); invokeEndElement (pctxt, "transcodingMMR", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 4 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.versionPresent = 1; invokeStartElement (pctxt, "version", -1); stat = decodeConsUInt8 (pctxt, &pvalue->version, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->version); invokeEndElement (pctxt, "version", -1); break; case 1: pvalue->m.t38FaxRateManagementPresent = 1; invokeStartElement (pctxt, "t38FaxRateManagement", -1); stat = asn1PD_H245T38FaxRateManagement (pctxt, &pvalue->t38FaxRateManagement); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxRateManagement", -1); break; case 2: pvalue->m.t38FaxUdpOptionsPresent = 1; invokeStartElement (pctxt, "t38FaxUdpOptions", -1); stat = asn1PD_H245T38FaxUdpOptions (pctxt, &pvalue->t38FaxUdpOptions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxUdpOptions", -1); break; case 3: pvalue->m.t38FaxTcpOptionsPresent = 1; invokeStartElement (pctxt, "t38FaxTcpOptions", -1); stat = asn1PD_H245T38FaxTcpOptions (pctxt, &pvalue->t38FaxTcpOptions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxTcpOptions", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* NonStandardMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NonStandardMessage (OOCTXT* pctxt, H245NonStandardMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode nonStandardData */ invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H245NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDetermination */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MasterSlaveDetermination (OOCTXT* pctxt, H245MasterSlaveDetermination* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalType */ invokeStartElement (pctxt, "terminalType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->terminalType, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->terminalType); invokeEndElement (pctxt, "terminalType", -1); /* decode statusDeterminationNumber */ invokeStartElement (pctxt, "statusDeterminationNumber", -1); stat = decodeConsUnsigned (pctxt, &pvalue->statusDeterminationNumber, 0U, 16777215U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->statusDeterminationNumber); invokeEndElement (pctxt, "statusDeterminationNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SequenceNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245SequenceNumber (OOCTXT* pctxt, H245SequenceNumber* pvalue) { int stat = ASN_OK; stat = decodeConsUInt8 (pctxt, pvalue, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* VCCapability_aal1 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability_aal1 (OOCTXT* pctxt, H245VCCapability_aal1* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode nullClockRecovery */ invokeStartElement (pctxt, "nullClockRecovery", -1); stat = DECODEBIT (pctxt, &pvalue->nullClockRecovery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->nullClockRecovery); invokeEndElement (pctxt, "nullClockRecovery", -1); /* decode srtsClockRecovery */ invokeStartElement (pctxt, "srtsClockRecovery", -1); stat = DECODEBIT (pctxt, &pvalue->srtsClockRecovery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->srtsClockRecovery); invokeEndElement (pctxt, "srtsClockRecovery", -1); /* decode adaptiveClockRecovery */ invokeStartElement (pctxt, "adaptiveClockRecovery", -1); stat = DECODEBIT (pctxt, &pvalue->adaptiveClockRecovery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->adaptiveClockRecovery); invokeEndElement (pctxt, "adaptiveClockRecovery", -1); /* decode nullErrorCorrection */ invokeStartElement (pctxt, "nullErrorCorrection", -1); stat = DECODEBIT (pctxt, &pvalue->nullErrorCorrection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->nullErrorCorrection); invokeEndElement (pctxt, "nullErrorCorrection", -1); /* decode longInterleaver */ invokeStartElement (pctxt, "longInterleaver", -1); stat = DECODEBIT (pctxt, &pvalue->longInterleaver); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->longInterleaver); invokeEndElement (pctxt, "longInterleaver", -1); /* decode shortInterleaver */ invokeStartElement (pctxt, "shortInterleaver", -1); stat = DECODEBIT (pctxt, &pvalue->shortInterleaver); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->shortInterleaver); invokeEndElement (pctxt, "shortInterleaver", -1); /* decode errorCorrectionOnly */ invokeStartElement (pctxt, "errorCorrectionOnly", -1); stat = DECODEBIT (pctxt, &pvalue->errorCorrectionOnly); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->errorCorrectionOnly); invokeEndElement (pctxt, "errorCorrectionOnly", -1); /* decode structuredDataTransfer */ invokeStartElement (pctxt, "structuredDataTransfer", -1); stat = DECODEBIT (pctxt, &pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->structuredDataTransfer); invokeEndElement (pctxt, "structuredDataTransfer", -1); /* decode partiallyFilledCells */ invokeStartElement (pctxt, "partiallyFilledCells", -1); stat = DECODEBIT (pctxt, &pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->partiallyFilledCells); invokeEndElement (pctxt, "partiallyFilledCells", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VCCapability_aal5 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability_aal5 (OOCTXT* pctxt, H245VCCapability_aal5* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardMaximumSDUSize */ invokeStartElement (pctxt, "forwardMaximumSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->forwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->forwardMaximumSDUSize); invokeEndElement (pctxt, "forwardMaximumSDUSize", -1); /* decode backwardMaximumSDUSize */ invokeStartElement (pctxt, "backwardMaximumSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->backwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->backwardMaximumSDUSize); invokeEndElement (pctxt, "backwardMaximumSDUSize", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VCCapability_availableBitRates_type_rangeOfBitRates */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability_availableBitRates_type_rangeOfBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates_type_rangeOfBitRates* pvalue) { int stat = ASN_OK; /* decode lowerBitRate */ invokeStartElement (pctxt, "lowerBitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->lowerBitRate, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->lowerBitRate); invokeEndElement (pctxt, "lowerBitRate", -1); /* decode higherBitRate */ invokeStartElement (pctxt, "higherBitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->higherBitRate, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->higherBitRate); invokeEndElement (pctxt, "higherBitRate", -1); return (stat); } /**************************************************************/ /* */ /* VCCapability_availableBitRates_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability_availableBitRates_type (OOCTXT* pctxt, H245VCCapability_availableBitRates_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* singleBitRate */ case 0: invokeStartElement (pctxt, "singleBitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.singleBitRate, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.singleBitRate); invokeEndElement (pctxt, "singleBitRate", -1); break; /* rangeOfBitRates */ case 1: invokeStartElement (pctxt, "rangeOfBitRates", -1); pvalue->u.rangeOfBitRates = ALLOC_ASN1ELEM (pctxt, H245VCCapability_availableBitRates_type_rangeOfBitRates); stat = asn1PD_H245VCCapability_availableBitRates_type_rangeOfBitRates (pctxt, pvalue->u.rangeOfBitRates); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rangeOfBitRates", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* VCCapability_availableBitRates */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability_availableBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245VCCapability_availableBitRates_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* Q2931Address_address_nsapAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Q2931Address_address_nsapAddress (OOCTXT* pctxt, H245Q2931Address_address_nsapAddress* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* Q2931Address_address */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Q2931Address_address (OOCTXT* pctxt, H245Q2931Address_address* pvalue) { static Asn1SizeCnst internationalNumber_lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* internationalNumber */ case 0: invokeStartElement (pctxt, "internationalNumber", -1); addSizeConstraint (pctxt, &internationalNumber_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.internationalNumber, NUM_CANSET, 4, 4, 4); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.internationalNumber); invokeEndElement (pctxt, "internationalNumber", -1); break; /* nsapAddress */ case 1: invokeStartElement (pctxt, "nsapAddress", -1); pvalue->u.nsapAddress = ALLOC_ASN1ELEM (pctxt, H245Q2931Address_address_nsapAddress); stat = asn1PD_H245Q2931Address_address_nsapAddress (pctxt, pvalue->u.nsapAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nsapAddress", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Q2931Address_subaddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Q2931Address_subaddress (OOCTXT* pctxt, H245Q2931Address_subaddress* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* Q2931Address */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Q2931Address (OOCTXT* pctxt, H245Q2931Address* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.subaddressPresent = optbit; /* decode address */ invokeStartElement (pctxt, "address", -1); stat = asn1PD_H245Q2931Address_address (pctxt, &pvalue->address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "address", -1); /* decode subaddress */ if (pvalue->m.subaddressPresent) { invokeStartElement (pctxt, "subaddress", -1); stat = asn1PD_H245Q2931Address_subaddress (pctxt, &pvalue->subaddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "subaddress", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VCCapability_aal1ViaGateway_gatewayAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability_aal1ViaGateway_gatewayAddress (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway_gatewayAddress* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245Q2931Address* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245Q2931Address); stat = asn1PD_H245Q2931Address (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* VCCapability_aal1ViaGateway */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability_aal1ViaGateway (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode gatewayAddress */ invokeStartElement (pctxt, "gatewayAddress", -1); stat = asn1PD_H245VCCapability_aal1ViaGateway_gatewayAddress (pctxt, &pvalue->gatewayAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatewayAddress", -1); /* decode nullClockRecovery */ invokeStartElement (pctxt, "nullClockRecovery", -1); stat = DECODEBIT (pctxt, &pvalue->nullClockRecovery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->nullClockRecovery); invokeEndElement (pctxt, "nullClockRecovery", -1); /* decode srtsClockRecovery */ invokeStartElement (pctxt, "srtsClockRecovery", -1); stat = DECODEBIT (pctxt, &pvalue->srtsClockRecovery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->srtsClockRecovery); invokeEndElement (pctxt, "srtsClockRecovery", -1); /* decode adaptiveClockRecovery */ invokeStartElement (pctxt, "adaptiveClockRecovery", -1); stat = DECODEBIT (pctxt, &pvalue->adaptiveClockRecovery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->adaptiveClockRecovery); invokeEndElement (pctxt, "adaptiveClockRecovery", -1); /* decode nullErrorCorrection */ invokeStartElement (pctxt, "nullErrorCorrection", -1); stat = DECODEBIT (pctxt, &pvalue->nullErrorCorrection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->nullErrorCorrection); invokeEndElement (pctxt, "nullErrorCorrection", -1); /* decode longInterleaver */ invokeStartElement (pctxt, "longInterleaver", -1); stat = DECODEBIT (pctxt, &pvalue->longInterleaver); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->longInterleaver); invokeEndElement (pctxt, "longInterleaver", -1); /* decode shortInterleaver */ invokeStartElement (pctxt, "shortInterleaver", -1); stat = DECODEBIT (pctxt, &pvalue->shortInterleaver); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->shortInterleaver); invokeEndElement (pctxt, "shortInterleaver", -1); /* decode errorCorrectionOnly */ invokeStartElement (pctxt, "errorCorrectionOnly", -1); stat = DECODEBIT (pctxt, &pvalue->errorCorrectionOnly); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->errorCorrectionOnly); invokeEndElement (pctxt, "errorCorrectionOnly", -1); /* decode structuredDataTransfer */ invokeStartElement (pctxt, "structuredDataTransfer", -1); stat = DECODEBIT (pctxt, &pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->structuredDataTransfer); invokeEndElement (pctxt, "structuredDataTransfer", -1); /* decode partiallyFilledCells */ invokeStartElement (pctxt, "partiallyFilledCells", -1); stat = DECODEBIT (pctxt, &pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->partiallyFilledCells); invokeEndElement (pctxt, "partiallyFilledCells", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VCCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VCCapability (OOCTXT* pctxt, H245VCCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.aal1Present = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.aal5Present = optbit; /* decode aal1 */ if (pvalue->m.aal1Present) { invokeStartElement (pctxt, "aal1", -1); stat = asn1PD_H245VCCapability_aal1 (pctxt, &pvalue->aal1); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal1", -1); } /* decode aal5 */ if (pvalue->m.aal5Present) { invokeStartElement (pctxt, "aal5", -1); stat = asn1PD_H245VCCapability_aal5 (pctxt, &pvalue->aal5); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal5", -1); } /* decode transportStream */ invokeStartElement (pctxt, "transportStream", -1); stat = DECODEBIT (pctxt, &pvalue->transportStream); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->transportStream); invokeEndElement (pctxt, "transportStream", -1); /* decode programStream */ invokeStartElement (pctxt, "programStream", -1); stat = DECODEBIT (pctxt, &pvalue->programStream); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->programStream); invokeEndElement (pctxt, "programStream", -1); /* decode availableBitRates */ invokeStartElement (pctxt, "availableBitRates", -1); stat = asn1PD_H245VCCapability_availableBitRates (pctxt, &pvalue->availableBitRates); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "availableBitRates", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.aal1ViaGatewayPresent = 1; invokeStartElement (pctxt, "aal1ViaGateway", -1); stat = asn1PD_H245VCCapability_aal1ViaGateway (pctxt, &pvalue->aal1ViaGateway); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal1ViaGateway", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SetOfH245VCCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SetOfH245VCCapability (OOCTXT* pctxt, H245_SetOfH245VCCapability* pvalue) { int stat = ASN_OK; H245VCCapability* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245VCCapability); stat = asn1PD_H245VCCapability (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* H222Capability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H222Capability (OOCTXT* pctxt, H245H222Capability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode numberOfVCs */ invokeStartElement (pctxt, "numberOfVCs", -1); stat = decodeConsUInt16 (pctxt, &pvalue->numberOfVCs, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfVCs); invokeEndElement (pctxt, "numberOfVCs", -1); /* decode vcCapability */ invokeStartElement (pctxt, "vcCapability", -1); stat = asn1PD_H245_SetOfH245VCCapability (pctxt, &pvalue->vcCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "vcCapability", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223Capability_h223MultiplexTableCapability_enhanced */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223Capability_h223MultiplexTableCapability_enhanced (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability_enhanced* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode maximumNestingDepth */ invokeStartElement (pctxt, "maximumNestingDepth", -1); stat = decodeConsUInt8 (pctxt, &pvalue->maximumNestingDepth, 1U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumNestingDepth); invokeEndElement (pctxt, "maximumNestingDepth", -1); /* decode maximumElementListSize */ invokeStartElement (pctxt, "maximumElementListSize", -1); stat = decodeConsUInt8 (pctxt, &pvalue->maximumElementListSize, 2U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumElementListSize); invokeEndElement (pctxt, "maximumElementListSize", -1); /* decode maximumSubElementListSize */ invokeStartElement (pctxt, "maximumSubElementListSize", -1); stat = decodeConsUInt8 (pctxt, &pvalue->maximumSubElementListSize, 2U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumSubElementListSize); invokeEndElement (pctxt, "maximumSubElementListSize", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223Capability_h223MultiplexTableCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223Capability_h223MultiplexTableCapability (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* basic */ case 0: invokeStartElement (pctxt, "basic", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "basic", -1); break; /* enhanced */ case 1: invokeStartElement (pctxt, "enhanced", -1); pvalue->u.enhanced = ALLOC_ASN1ELEM (pctxt, H245H223Capability_h223MultiplexTableCapability_enhanced); stat = asn1PD_H245H223Capability_h223MultiplexTableCapability_enhanced (pctxt, pvalue->u.enhanced); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "enhanced", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* H223Capability_mobileOperationTransmitCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223Capability_mobileOperationTransmitCapability (OOCTXT* pctxt, H245H223Capability_mobileOperationTransmitCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode modeChangeCapability */ invokeStartElement (pctxt, "modeChangeCapability", -1); stat = DECODEBIT (pctxt, &pvalue->modeChangeCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->modeChangeCapability); invokeEndElement (pctxt, "modeChangeCapability", -1); /* decode h223AnnexA */ invokeStartElement (pctxt, "h223AnnexA", -1); stat = DECODEBIT (pctxt, &pvalue->h223AnnexA); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->h223AnnexA); invokeEndElement (pctxt, "h223AnnexA", -1); /* decode h223AnnexADoubleFlag */ invokeStartElement (pctxt, "h223AnnexADoubleFlag", -1); stat = DECODEBIT (pctxt, &pvalue->h223AnnexADoubleFlag); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->h223AnnexADoubleFlag); invokeEndElement (pctxt, "h223AnnexADoubleFlag", -1); /* decode h223AnnexB */ invokeStartElement (pctxt, "h223AnnexB", -1); stat = DECODEBIT (pctxt, &pvalue->h223AnnexB); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->h223AnnexB); invokeEndElement (pctxt, "h223AnnexB", -1); /* decode h223AnnexBwithHeader */ invokeStartElement (pctxt, "h223AnnexBwithHeader", -1); stat = DECODEBIT (pctxt, &pvalue->h223AnnexBwithHeader); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->h223AnnexBwithHeader); invokeEndElement (pctxt, "h223AnnexBwithHeader", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223AnnexCCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AnnexCCapability (OOCTXT* pctxt, H245H223AnnexCCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode videoWithAL1M */ invokeStartElement (pctxt, "videoWithAL1M", -1); stat = DECODEBIT (pctxt, &pvalue->videoWithAL1M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoWithAL1M); invokeEndElement (pctxt, "videoWithAL1M", -1); /* decode videoWithAL2M */ invokeStartElement (pctxt, "videoWithAL2M", -1); stat = DECODEBIT (pctxt, &pvalue->videoWithAL2M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoWithAL2M); invokeEndElement (pctxt, "videoWithAL2M", -1); /* decode videoWithAL3M */ invokeStartElement (pctxt, "videoWithAL3M", -1); stat = DECODEBIT (pctxt, &pvalue->videoWithAL3M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoWithAL3M); invokeEndElement (pctxt, "videoWithAL3M", -1); /* decode audioWithAL1M */ invokeStartElement (pctxt, "audioWithAL1M", -1); stat = DECODEBIT (pctxt, &pvalue->audioWithAL1M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioWithAL1M); invokeEndElement (pctxt, "audioWithAL1M", -1); /* decode audioWithAL2M */ invokeStartElement (pctxt, "audioWithAL2M", -1); stat = DECODEBIT (pctxt, &pvalue->audioWithAL2M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioWithAL2M); invokeEndElement (pctxt, "audioWithAL2M", -1); /* decode audioWithAL3M */ invokeStartElement (pctxt, "audioWithAL3M", -1); stat = DECODEBIT (pctxt, &pvalue->audioWithAL3M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioWithAL3M); invokeEndElement (pctxt, "audioWithAL3M", -1); /* decode dataWithAL1M */ invokeStartElement (pctxt, "dataWithAL1M", -1); stat = DECODEBIT (pctxt, &pvalue->dataWithAL1M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dataWithAL1M); invokeEndElement (pctxt, "dataWithAL1M", -1); /* decode dataWithAL2M */ invokeStartElement (pctxt, "dataWithAL2M", -1); stat = DECODEBIT (pctxt, &pvalue->dataWithAL2M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dataWithAL2M); invokeEndElement (pctxt, "dataWithAL2M", -1); /* decode dataWithAL3M */ invokeStartElement (pctxt, "dataWithAL3M", -1); stat = DECODEBIT (pctxt, &pvalue->dataWithAL3M); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dataWithAL3M); invokeEndElement (pctxt, "dataWithAL3M", -1); /* decode alpduInterleaving */ invokeStartElement (pctxt, "alpduInterleaving", -1); stat = DECODEBIT (pctxt, &pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alpduInterleaving); invokeEndElement (pctxt, "alpduInterleaving", -1); /* decode maximumAL1MPDUSize */ invokeStartElement (pctxt, "maximumAL1MPDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumAL1MPDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumAL1MPDUSize); invokeEndElement (pctxt, "maximumAL1MPDUSize", -1); /* decode maximumAL2MSDUSize */ invokeStartElement (pctxt, "maximumAL2MSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumAL2MSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumAL2MSDUSize); invokeEndElement (pctxt, "maximumAL2MSDUSize", -1); /* decode maximumAL3MSDUSize */ invokeStartElement (pctxt, "maximumAL3MSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumAL3MSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumAL3MSDUSize); invokeEndElement (pctxt, "maximumAL3MSDUSize", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.rsCodeCapabilityPresent = 1; invokeStartElement (pctxt, "rsCodeCapability", -1); stat = DECODEBIT (pctxt, &pvalue->rsCodeCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->rsCodeCapability); invokeEndElement (pctxt, "rsCodeCapability", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H223Capability_mobileMultilinkFrameCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223Capability_mobileMultilinkFrameCapability (OOCTXT* pctxt, H245H223Capability_mobileMultilinkFrameCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode maximumSampleSize */ invokeStartElement (pctxt, "maximumSampleSize", -1); stat = decodeConsUInt8 (pctxt, &pvalue->maximumSampleSize, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumSampleSize); invokeEndElement (pctxt, "maximumSampleSize", -1); /* decode maximumPayloadLength */ invokeStartElement (pctxt, "maximumPayloadLength", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumPayloadLength, 1U, 65025U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumPayloadLength); invokeEndElement (pctxt, "maximumPayloadLength", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223Capability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223Capability (OOCTXT* pctxt, H245H223Capability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode transportWithI_frames */ invokeStartElement (pctxt, "transportWithI_frames", -1); stat = DECODEBIT (pctxt, &pvalue->transportWithI_frames); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->transportWithI_frames); invokeEndElement (pctxt, "transportWithI_frames", -1); /* decode videoWithAL1 */ invokeStartElement (pctxt, "videoWithAL1", -1); stat = DECODEBIT (pctxt, &pvalue->videoWithAL1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoWithAL1); invokeEndElement (pctxt, "videoWithAL1", -1); /* decode videoWithAL2 */ invokeStartElement (pctxt, "videoWithAL2", -1); stat = DECODEBIT (pctxt, &pvalue->videoWithAL2); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoWithAL2); invokeEndElement (pctxt, "videoWithAL2", -1); /* decode videoWithAL3 */ invokeStartElement (pctxt, "videoWithAL3", -1); stat = DECODEBIT (pctxt, &pvalue->videoWithAL3); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoWithAL3); invokeEndElement (pctxt, "videoWithAL3", -1); /* decode audioWithAL1 */ invokeStartElement (pctxt, "audioWithAL1", -1); stat = DECODEBIT (pctxt, &pvalue->audioWithAL1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioWithAL1); invokeEndElement (pctxt, "audioWithAL1", -1); /* decode audioWithAL2 */ invokeStartElement (pctxt, "audioWithAL2", -1); stat = DECODEBIT (pctxt, &pvalue->audioWithAL2); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioWithAL2); invokeEndElement (pctxt, "audioWithAL2", -1); /* decode audioWithAL3 */ invokeStartElement (pctxt, "audioWithAL3", -1); stat = DECODEBIT (pctxt, &pvalue->audioWithAL3); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioWithAL3); invokeEndElement (pctxt, "audioWithAL3", -1); /* decode dataWithAL1 */ invokeStartElement (pctxt, "dataWithAL1", -1); stat = DECODEBIT (pctxt, &pvalue->dataWithAL1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dataWithAL1); invokeEndElement (pctxt, "dataWithAL1", -1); /* decode dataWithAL2 */ invokeStartElement (pctxt, "dataWithAL2", -1); stat = DECODEBIT (pctxt, &pvalue->dataWithAL2); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dataWithAL2); invokeEndElement (pctxt, "dataWithAL2", -1); /* decode dataWithAL3 */ invokeStartElement (pctxt, "dataWithAL3", -1); stat = DECODEBIT (pctxt, &pvalue->dataWithAL3); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dataWithAL3); invokeEndElement (pctxt, "dataWithAL3", -1); /* decode maximumAl2SDUSize */ invokeStartElement (pctxt, "maximumAl2SDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumAl2SDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumAl2SDUSize); invokeEndElement (pctxt, "maximumAl2SDUSize", -1); /* decode maximumAl3SDUSize */ invokeStartElement (pctxt, "maximumAl3SDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumAl3SDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumAl3SDUSize); invokeEndElement (pctxt, "maximumAl3SDUSize", -1); /* decode maximumDelayJitter */ invokeStartElement (pctxt, "maximumDelayJitter", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumDelayJitter, 0U, 1023U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumDelayJitter); invokeEndElement (pctxt, "maximumDelayJitter", -1); /* decode h223MultiplexTableCapability */ invokeStartElement (pctxt, "h223MultiplexTableCapability", -1); stat = asn1PD_H245H223Capability_h223MultiplexTableCapability (pctxt, &pvalue->h223MultiplexTableCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223MultiplexTableCapability", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 6 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.maxMUXPDUSizeCapabilityPresent = 1; invokeStartElement (pctxt, "maxMUXPDUSizeCapability", -1); stat = DECODEBIT (pctxt, &pvalue->maxMUXPDUSizeCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maxMUXPDUSizeCapability); invokeEndElement (pctxt, "maxMUXPDUSizeCapability", -1); break; case 1: pvalue->m.nsrpSupportPresent = 1; invokeStartElement (pctxt, "nsrpSupport", -1); stat = DECODEBIT (pctxt, &pvalue->nsrpSupport); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->nsrpSupport); invokeEndElement (pctxt, "nsrpSupport", -1); break; case 2: pvalue->m.mobileOperationTransmitCapabilityPresent = 1; invokeStartElement (pctxt, "mobileOperationTransmitCapability", -1); stat = asn1PD_H245H223Capability_mobileOperationTransmitCapability (pctxt, &pvalue->mobileOperationTransmitCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mobileOperationTransmitCapability", -1); break; case 3: pvalue->m.h223AnnexCCapabilityPresent = 1; invokeStartElement (pctxt, "h223AnnexCCapability", -1); stat = asn1PD_H245H223AnnexCCapability (pctxt, &pvalue->h223AnnexCCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223AnnexCCapability", -1); break; case 4: pvalue->m.bitRatePresent = 1; invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 19200U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); break; case 5: pvalue->m.mobileMultilinkFrameCapabilityPresent = 1; invokeStartElement (pctxt, "mobileMultilinkFrameCapability", -1); stat = asn1PD_H245H223Capability_mobileMultilinkFrameCapability (pctxt, &pvalue->mobileMultilinkFrameCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mobileMultilinkFrameCapability", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* V75Capability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V75Capability (OOCTXT* pctxt, H245V75Capability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioHeader */ invokeStartElement (pctxt, "audioHeader", -1); stat = DECODEBIT (pctxt, &pvalue->audioHeader); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioHeader); invokeEndElement (pctxt, "audioHeader", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* V76Capability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76Capability (OOCTXT* pctxt, H245V76Capability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode suspendResumeCapabilitywAddress */ invokeStartElement (pctxt, "suspendResumeCapabilitywAddress", -1); stat = DECODEBIT (pctxt, &pvalue->suspendResumeCapabilitywAddress); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->suspendResumeCapabilitywAddress); invokeEndElement (pctxt, "suspendResumeCapabilitywAddress", -1); /* decode suspendResumeCapabilitywoAddress */ invokeStartElement (pctxt, "suspendResumeCapabilitywoAddress", -1); stat = DECODEBIT (pctxt, &pvalue->suspendResumeCapabilitywoAddress); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->suspendResumeCapabilitywoAddress); invokeEndElement (pctxt, "suspendResumeCapabilitywoAddress", -1); /* decode rejCapability */ invokeStartElement (pctxt, "rejCapability", -1); stat = DECODEBIT (pctxt, &pvalue->rejCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->rejCapability); invokeEndElement (pctxt, "rejCapability", -1); /* decode sREJCapability */ invokeStartElement (pctxt, "sREJCapability", -1); stat = DECODEBIT (pctxt, &pvalue->sREJCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->sREJCapability); invokeEndElement (pctxt, "sREJCapability", -1); /* decode mREJCapability */ invokeStartElement (pctxt, "mREJCapability", -1); stat = DECODEBIT (pctxt, &pvalue->mREJCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->mREJCapability); invokeEndElement (pctxt, "mREJCapability", -1); /* decode crc8bitCapability */ invokeStartElement (pctxt, "crc8bitCapability", -1); stat = DECODEBIT (pctxt, &pvalue->crc8bitCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->crc8bitCapability); invokeEndElement (pctxt, "crc8bitCapability", -1); /* decode crc16bitCapability */ invokeStartElement (pctxt, "crc16bitCapability", -1); stat = DECODEBIT (pctxt, &pvalue->crc16bitCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->crc16bitCapability); invokeEndElement (pctxt, "crc16bitCapability", -1); /* decode crc32bitCapability */ invokeStartElement (pctxt, "crc32bitCapability", -1); stat = DECODEBIT (pctxt, &pvalue->crc32bitCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->crc32bitCapability); invokeEndElement (pctxt, "crc32bitCapability", -1); /* decode uihCapability */ invokeStartElement (pctxt, "uihCapability", -1); stat = DECODEBIT (pctxt, &pvalue->uihCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->uihCapability); invokeEndElement (pctxt, "uihCapability", -1); /* decode numOfDLCS */ invokeStartElement (pctxt, "numOfDLCS", -1); stat = decodeConsUInt16 (pctxt, &pvalue->numOfDLCS, 2U, 8191U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numOfDLCS); invokeEndElement (pctxt, "numOfDLCS", -1); /* decode twoOctetAddressFieldCapability */ invokeStartElement (pctxt, "twoOctetAddressFieldCapability", -1); stat = DECODEBIT (pctxt, &pvalue->twoOctetAddressFieldCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->twoOctetAddressFieldCapability); invokeEndElement (pctxt, "twoOctetAddressFieldCapability", -1); /* decode loopBackTestCapability */ invokeStartElement (pctxt, "loopBackTestCapability", -1); stat = DECODEBIT (pctxt, &pvalue->loopBackTestCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->loopBackTestCapability); invokeEndElement (pctxt, "loopBackTestCapability", -1); /* decode n401Capability */ invokeStartElement (pctxt, "n401Capability", -1); stat = decodeConsUInt16 (pctxt, &pvalue->n401Capability, 1U, 4095U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->n401Capability); invokeEndElement (pctxt, "n401Capability", -1); /* decode maxWindowSizeCapability */ invokeStartElement (pctxt, "maxWindowSizeCapability", -1); stat = decodeConsUInt8 (pctxt, &pvalue->maxWindowSizeCapability, 1U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxWindowSizeCapability); invokeEndElement (pctxt, "maxWindowSizeCapability", -1); /* decode v75Capability */ invokeStartElement (pctxt, "v75Capability", -1); stat = asn1PD_H245V75Capability (pctxt, &pvalue->v75Capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v75Capability", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* T84Profile_t84Restricted */ /* */ /**************************************************************/ EXTERN int asn1PD_H245T84Profile_t84Restricted (OOCTXT* pctxt, H245T84Profile_t84Restricted* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode qcif */ invokeStartElement (pctxt, "qcif", -1); stat = DECODEBIT (pctxt, &pvalue->qcif); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->qcif); invokeEndElement (pctxt, "qcif", -1); /* decode cif */ invokeStartElement (pctxt, "cif", -1); stat = DECODEBIT (pctxt, &pvalue->cif); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->cif); invokeEndElement (pctxt, "cif", -1); /* decode ccir601Seq */ invokeStartElement (pctxt, "ccir601Seq", -1); stat = DECODEBIT (pctxt, &pvalue->ccir601Seq); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->ccir601Seq); invokeEndElement (pctxt, "ccir601Seq", -1); /* decode ccir601Prog */ invokeStartElement (pctxt, "ccir601Prog", -1); stat = DECODEBIT (pctxt, &pvalue->ccir601Prog); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->ccir601Prog); invokeEndElement (pctxt, "ccir601Prog", -1); /* decode hdtvSeq */ invokeStartElement (pctxt, "hdtvSeq", -1); stat = DECODEBIT (pctxt, &pvalue->hdtvSeq); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->hdtvSeq); invokeEndElement (pctxt, "hdtvSeq", -1); /* decode hdtvProg */ invokeStartElement (pctxt, "hdtvProg", -1); stat = DECODEBIT (pctxt, &pvalue->hdtvProg); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->hdtvProg); invokeEndElement (pctxt, "hdtvProg", -1); /* decode g3FacsMH200x100 */ invokeStartElement (pctxt, "g3FacsMH200x100", -1); stat = DECODEBIT (pctxt, &pvalue->g3FacsMH200x100); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->g3FacsMH200x100); invokeEndElement (pctxt, "g3FacsMH200x100", -1); /* decode g3FacsMH200x200 */ invokeStartElement (pctxt, "g3FacsMH200x200", -1); stat = DECODEBIT (pctxt, &pvalue->g3FacsMH200x200); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->g3FacsMH200x200); invokeEndElement (pctxt, "g3FacsMH200x200", -1); /* decode g4FacsMMR200x100 */ invokeStartElement (pctxt, "g4FacsMMR200x100", -1); stat = DECODEBIT (pctxt, &pvalue->g4FacsMMR200x100); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->g4FacsMMR200x100); invokeEndElement (pctxt, "g4FacsMMR200x100", -1); /* decode g4FacsMMR200x200 */ invokeStartElement (pctxt, "g4FacsMMR200x200", -1); stat = DECODEBIT (pctxt, &pvalue->g4FacsMMR200x200); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->g4FacsMMR200x200); invokeEndElement (pctxt, "g4FacsMMR200x200", -1); /* decode jbig200x200Seq */ invokeStartElement (pctxt, "jbig200x200Seq", -1); stat = DECODEBIT (pctxt, &pvalue->jbig200x200Seq); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->jbig200x200Seq); invokeEndElement (pctxt, "jbig200x200Seq", -1); /* decode jbig200x200Prog */ invokeStartElement (pctxt, "jbig200x200Prog", -1); stat = DECODEBIT (pctxt, &pvalue->jbig200x200Prog); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->jbig200x200Prog); invokeEndElement (pctxt, "jbig200x200Prog", -1); /* decode jbig300x300Seq */ invokeStartElement (pctxt, "jbig300x300Seq", -1); stat = DECODEBIT (pctxt, &pvalue->jbig300x300Seq); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->jbig300x300Seq); invokeEndElement (pctxt, "jbig300x300Seq", -1); /* decode jbig300x300Prog */ invokeStartElement (pctxt, "jbig300x300Prog", -1); stat = DECODEBIT (pctxt, &pvalue->jbig300x300Prog); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->jbig300x300Prog); invokeEndElement (pctxt, "jbig300x300Prog", -1); /* decode digPhotoLow */ invokeStartElement (pctxt, "digPhotoLow", -1); stat = DECODEBIT (pctxt, &pvalue->digPhotoLow); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->digPhotoLow); invokeEndElement (pctxt, "digPhotoLow", -1); /* decode digPhotoMedSeq */ invokeStartElement (pctxt, "digPhotoMedSeq", -1); stat = DECODEBIT (pctxt, &pvalue->digPhotoMedSeq); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->digPhotoMedSeq); invokeEndElement (pctxt, "digPhotoMedSeq", -1); /* decode digPhotoMedProg */ invokeStartElement (pctxt, "digPhotoMedProg", -1); stat = DECODEBIT (pctxt, &pvalue->digPhotoMedProg); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->digPhotoMedProg); invokeEndElement (pctxt, "digPhotoMedProg", -1); /* decode digPhotoHighSeq */ invokeStartElement (pctxt, "digPhotoHighSeq", -1); stat = DECODEBIT (pctxt, &pvalue->digPhotoHighSeq); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->digPhotoHighSeq); invokeEndElement (pctxt, "digPhotoHighSeq", -1); /* decode digPhotoHighProg */ invokeStartElement (pctxt, "digPhotoHighProg", -1); stat = DECODEBIT (pctxt, &pvalue->digPhotoHighProg); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->digPhotoHighProg); invokeEndElement (pctxt, "digPhotoHighProg", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* T84Profile */ /* */ /**************************************************************/ EXTERN int asn1PD_H245T84Profile (OOCTXT* pctxt, H245T84Profile* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* t84Unrestricted */ case 0: invokeStartElement (pctxt, "t84Unrestricted", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "t84Unrestricted", -1); break; /* t84Restricted */ case 1: invokeStartElement (pctxt, "t84Restricted", -1); pvalue->u.t84Restricted = ALLOC_ASN1ELEM (pctxt, H245T84Profile_t84Restricted); stat = asn1PD_H245T84Profile_t84Restricted (pctxt, pvalue->u.t84Restricted); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t84Restricted", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application_t84 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataApplicationCapability_application_t84 (OOCTXT* pctxt, H245DataApplicationCapability_application_t84* pvalue) { int stat = ASN_OK; /* decode t84Protocol */ invokeStartElement (pctxt, "t84Protocol", -1); stat = asn1PD_H245DataProtocolCapability (pctxt, &pvalue->t84Protocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t84Protocol", -1); /* decode t84Profile */ invokeStartElement (pctxt, "t84Profile", -1); stat = asn1PD_H245T84Profile (pctxt, &pvalue->t84Profile); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t84Profile", -1); return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application_nlpid */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataApplicationCapability_application_nlpid (OOCTXT* pctxt, H245DataApplicationCapability_application_nlpid* pvalue) { int stat = ASN_OK; /* decode nlpidProtocol */ invokeStartElement (pctxt, "nlpidProtocol", -1); stat = asn1PD_H245DataProtocolCapability (pctxt, &pvalue->nlpidProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nlpidProtocol", -1); /* decode nlpidData */ invokeStartElement (pctxt, "nlpidData", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->nlpidData); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->nlpidData.numocts, pvalue->nlpidData.data); invokeEndElement (pctxt, "nlpidData", -1); return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application_t38fax */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataApplicationCapability_application_t38fax (OOCTXT* pctxt, H245DataApplicationCapability_application_t38fax* pvalue) { int stat = ASN_OK; /* decode t38FaxProtocol */ invokeStartElement (pctxt, "t38FaxProtocol", -1); stat = asn1PD_H245DataProtocolCapability (pctxt, &pvalue->t38FaxProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxProtocol", -1); /* decode t38FaxProfile */ invokeStartElement (pctxt, "t38FaxProfile", -1); stat = asn1PD_H245T38FaxProfile (pctxt, &pvalue->t38FaxProfile); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxProfile", -1); return (stat); } /**************************************************************/ /* */ /* CapabilityIdentifier_uuid */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CapabilityIdentifier_uuid (OOCTXT* pctxt, H245CapabilityIdentifier_uuid* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* CapabilityIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CapabilityIdentifier (OOCTXT* pctxt, H245CapabilityIdentifier* pvalue) { static Asn1SizeCnst domainBased_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* standard */ case 0: invokeStartElement (pctxt, "standard", -1); pvalue->u.standard = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.standard); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.standard->numids, pvalue->u.standard->subid); invokeEndElement (pctxt, "standard", -1); break; /* h221NonStandard */ case 1: invokeStartElement (pctxt, "h221NonStandard", -1); pvalue->u.h221NonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h221NonStandard", -1); break; /* uuid */ case 2: invokeStartElement (pctxt, "uuid", -1); pvalue->u.uuid = ALLOC_ASN1ELEM (pctxt, H245CapabilityIdentifier_uuid); stat = asn1PD_H245CapabilityIdentifier_uuid (pctxt, pvalue->u.uuid); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "uuid", -1); break; /* domainBased */ case 3: invokeStartElement (pctxt, "domainBased", -1); addSizeConstraint (pctxt, &domainBased_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.domainBased, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.domainBased); invokeEndElement (pctxt, "domainBased", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ParameterIdentifier_uuid */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ParameterIdentifier_uuid (OOCTXT* pctxt, H245ParameterIdentifier_uuid* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ParameterIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ParameterIdentifier (OOCTXT* pctxt, H245ParameterIdentifier* pvalue) { static Asn1SizeCnst domainBased_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* standard */ case 0: invokeStartElement (pctxt, "standard", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.standard, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.standard); invokeEndElement (pctxt, "standard", -1); break; /* h221NonStandard */ case 1: invokeStartElement (pctxt, "h221NonStandard", -1); pvalue->u.h221NonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h221NonStandard", -1); break; /* uuid */ case 2: invokeStartElement (pctxt, "uuid", -1); pvalue->u.uuid = ALLOC_ASN1ELEM (pctxt, H245ParameterIdentifier_uuid); stat = asn1PD_H245ParameterIdentifier_uuid (pctxt, pvalue->u.uuid); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "uuid", -1); break; /* domainBased */ case 3: invokeStartElement (pctxt, "domainBased", -1); addSizeConstraint (pctxt, &domainBased_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.domainBased, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.domainBased); invokeEndElement (pctxt, "domainBased", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ParameterValue */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ParameterValue (OOCTXT* pctxt, H245ParameterValue* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 7); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* logical */ case 0: invokeStartElement (pctxt, "logical", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "logical", -1); break; /* booleanArray */ case 1: invokeStartElement (pctxt, "booleanArray", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.booleanArray, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.booleanArray); invokeEndElement (pctxt, "booleanArray", -1); break; /* unsignedMin */ case 2: invokeStartElement (pctxt, "unsignedMin", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.unsignedMin, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.unsignedMin); invokeEndElement (pctxt, "unsignedMin", -1); break; /* unsignedMax */ case 3: invokeStartElement (pctxt, "unsignedMax", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.unsignedMax, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.unsignedMax); invokeEndElement (pctxt, "unsignedMax", -1); break; /* unsigned32Min */ case 4: invokeStartElement (pctxt, "unsigned32Min", -1); stat = decodeConsUnsigned (pctxt, &pvalue->u.unsigned32Min, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.unsigned32Min); invokeEndElement (pctxt, "unsigned32Min", -1); break; /* unsigned32Max */ case 5: invokeStartElement (pctxt, "unsigned32Max", -1); stat = decodeConsUnsigned (pctxt, &pvalue->u.unsigned32Max, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.unsigned32Max); invokeEndElement (pctxt, "unsigned32Max", -1); break; /* octetString */ case 6: invokeStartElement (pctxt, "octetString", -1); pvalue->u.octetString = ALLOC_ASN1ELEM (pctxt, ASN1DynOctStr); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)pvalue->u.octetString); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->u.octetString->numocts, pvalue->u.octetString->data); invokeEndElement (pctxt, "octetString", -1); break; /* genericParameter */ case 7: invokeStartElement (pctxt, "genericParameter", -1); pvalue->u.genericParameter = ALLOC_ASN1ELEM (pctxt, H245_SeqOfH245GenericParameter); stat = asn1PD_H245_SeqOfH245GenericParameter (pctxt, (H245_SeqOfH245GenericParameter*)pvalue->u.genericParameter); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericParameter", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 9; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245ParameterIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245ParameterIdentifier (OOCTXT* pctxt, H245_SeqOfH245ParameterIdentifier* pvalue) { int stat = ASN_OK; H245ParameterIdentifier* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245ParameterIdentifier); stat = asn1PD_H245ParameterIdentifier (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* GenericParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H245GenericParameter (OOCTXT* pctxt, H245GenericParameter* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.supersedesPresent = optbit; /* decode parameterIdentifier */ invokeStartElement (pctxt, "parameterIdentifier", -1); stat = asn1PD_H245ParameterIdentifier (pctxt, &pvalue->parameterIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "parameterIdentifier", -1); /* decode parameterValue */ invokeStartElement (pctxt, "parameterValue", -1); stat = asn1PD_H245ParameterValue (pctxt, &pvalue->parameterValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "parameterValue", -1); /* decode supersedes */ if (pvalue->m.supersedesPresent) { invokeStartElement (pctxt, "supersedes", -1); stat = asn1PD_H245_SeqOfH245ParameterIdentifier (pctxt, &pvalue->supersedes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supersedes", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245GenericParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245GenericParameter (OOCTXT* pctxt, H245_SeqOfH245GenericParameter* pvalue) { int stat = ASN_OK; H245GenericParameter* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245GenericParameter); stat = asn1PD_H245GenericParameter (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* GenericCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245GenericCapability (OOCTXT* pctxt, H245GenericCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.maxBitRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.collapsingPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonCollapsingPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonCollapsingRawPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.transportPresent = optbit; /* decode capabilityIdentifier */ invokeStartElement (pctxt, "capabilityIdentifier", -1); stat = asn1PD_H245CapabilityIdentifier (pctxt, &pvalue->capabilityIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityIdentifier", -1); /* decode maxBitRate */ if (pvalue->m.maxBitRatePresent) { invokeStartElement (pctxt, "maxBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->maxBitRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxBitRate); invokeEndElement (pctxt, "maxBitRate", -1); } /* decode collapsing */ if (pvalue->m.collapsingPresent) { invokeStartElement (pctxt, "collapsing", -1); stat = asn1PD_H245_SeqOfH245GenericParameter (pctxt, &pvalue->collapsing); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "collapsing", -1); } /* decode nonCollapsing */ if (pvalue->m.nonCollapsingPresent) { invokeStartElement (pctxt, "nonCollapsing", -1); stat = asn1PD_H245_SeqOfH245GenericParameter (pctxt, &pvalue->nonCollapsing); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonCollapsing", -1); } /* decode nonCollapsingRaw */ if (pvalue->m.nonCollapsingRawPresent) { invokeStartElement (pctxt, "nonCollapsingRaw", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->nonCollapsingRaw); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->nonCollapsingRaw.numocts, pvalue->nonCollapsingRaw.data); invokeEndElement (pctxt, "nonCollapsingRaw", -1); } /* decode transport */ if (pvalue->m.transportPresent) { invokeStartElement (pctxt, "transport", -1); stat = asn1PD_H245DataProtocolCapability (pctxt, &pvalue->transport); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transport", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataApplicationCapability_application (OOCTXT* pctxt, H245DataApplicationCapability_application* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 9); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* t120 */ case 1: invokeStartElement (pctxt, "t120", -1); pvalue->u.t120 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t120); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t120", -1); break; /* dsm_cc */ case 2: invokeStartElement (pctxt, "dsm_cc", -1); pvalue->u.dsm_cc = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.dsm_cc); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dsm_cc", -1); break; /* userData */ case 3: invokeStartElement (pctxt, "userData", -1); pvalue->u.userData = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.userData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "userData", -1); break; /* t84 */ case 4: invokeStartElement (pctxt, "t84", -1); pvalue->u.t84 = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability_application_t84); stat = asn1PD_H245DataApplicationCapability_application_t84 (pctxt, pvalue->u.t84); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t84", -1); break; /* t434 */ case 5: invokeStartElement (pctxt, "t434", -1); pvalue->u.t434 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t434); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t434", -1); break; /* h224 */ case 6: invokeStartElement (pctxt, "h224", -1); pvalue->u.h224 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.h224); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h224", -1); break; /* nlpid */ case 7: invokeStartElement (pctxt, "nlpid", -1); pvalue->u.nlpid = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability_application_nlpid); stat = asn1PD_H245DataApplicationCapability_application_nlpid (pctxt, pvalue->u.nlpid); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nlpid", -1); break; /* dsvdControl */ case 8: invokeStartElement (pctxt, "dsvdControl", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dsvdControl", -1); break; /* h222DataPartitioning */ case 9: invokeStartElement (pctxt, "h222DataPartitioning", -1); pvalue->u.h222DataPartitioning = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.h222DataPartitioning); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h222DataPartitioning", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 11; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* t30fax */ case 11: invokeStartElement (pctxt, "t30fax", -1); pvalue->u.t30fax = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t30fax); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t30fax", -1); break; /* t140 */ case 12: invokeStartElement (pctxt, "t140", -1); pvalue->u.t140 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t140); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t140", -1); break; /* t38fax */ case 13: invokeStartElement (pctxt, "t38fax", -1); pvalue->u.t38fax = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability_application_t38fax); stat = asn1PD_H245DataApplicationCapability_application_t38fax (pctxt, pvalue->u.t38fax); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38fax", -1); break; /* genericDataCapability */ case 14: invokeStartElement (pctxt, "genericDataCapability", -1); pvalue->u.genericDataCapability = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericDataCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericDataCapability", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataApplicationCapability (OOCTXT* pctxt, H245DataApplicationCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode application */ invokeStartElement (pctxt, "application", -1); stat = asn1PD_H245DataApplicationCapability_application (pctxt, &pvalue->application); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "application", -1); /* decode maxBitRate */ invokeStartElement (pctxt, "maxBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->maxBitRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxBitRate); invokeEndElement (pctxt, "maxBitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245DataApplicationCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245DataApplicationCapability (OOCTXT* pctxt, H245_SeqOfH245DataApplicationCapability* pvalue) { int stat = ASN_OK; H245DataApplicationCapability* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245DataApplicationCapability); stat = asn1PD_H245DataApplicationCapability (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* MediaDistributionCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MediaDistributionCapability (OOCTXT* pctxt, H245MediaDistributionCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.centralizedDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.distributedDataPresent = optbit; /* decode centralizedControl */ invokeStartElement (pctxt, "centralizedControl", -1); stat = DECODEBIT (pctxt, &pvalue->centralizedControl); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->centralizedControl); invokeEndElement (pctxt, "centralizedControl", -1); /* decode distributedControl */ invokeStartElement (pctxt, "distributedControl", -1); stat = DECODEBIT (pctxt, &pvalue->distributedControl); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->distributedControl); invokeEndElement (pctxt, "distributedControl", -1); /* decode centralizedAudio */ invokeStartElement (pctxt, "centralizedAudio", -1); stat = DECODEBIT (pctxt, &pvalue->centralizedAudio); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->centralizedAudio); invokeEndElement (pctxt, "centralizedAudio", -1); /* decode distributedAudio */ invokeStartElement (pctxt, "distributedAudio", -1); stat = DECODEBIT (pctxt, &pvalue->distributedAudio); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->distributedAudio); invokeEndElement (pctxt, "distributedAudio", -1); /* decode centralizedVideo */ invokeStartElement (pctxt, "centralizedVideo", -1); stat = DECODEBIT (pctxt, &pvalue->centralizedVideo); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->centralizedVideo); invokeEndElement (pctxt, "centralizedVideo", -1); /* decode distributedVideo */ invokeStartElement (pctxt, "distributedVideo", -1); stat = DECODEBIT (pctxt, &pvalue->distributedVideo); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->distributedVideo); invokeEndElement (pctxt, "distributedVideo", -1); /* decode centralizedData */ if (pvalue->m.centralizedDataPresent) { invokeStartElement (pctxt, "centralizedData", -1); stat = asn1PD_H245_SeqOfH245DataApplicationCapability (pctxt, &pvalue->centralizedData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "centralizedData", -1); } /* decode distributedData */ if (pvalue->m.distributedDataPresent) { invokeStartElement (pctxt, "distributedData", -1); stat = asn1PD_H245_SeqOfH245DataApplicationCapability (pctxt, &pvalue->distributedData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "distributedData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245MediaDistributionCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245MediaDistributionCapability (OOCTXT* pctxt, H245_SeqOfH245MediaDistributionCapability* pvalue) { int stat = ASN_OK; H245MediaDistributionCapability* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MediaDistributionCapability); stat = asn1PD_H245MediaDistributionCapability (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* MultipointCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultipointCapability (OOCTXT* pctxt, H245MultipointCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode multicastCapability */ invokeStartElement (pctxt, "multicastCapability", -1); stat = DECODEBIT (pctxt, &pvalue->multicastCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multicastCapability); invokeEndElement (pctxt, "multicastCapability", -1); /* decode multiUniCastConference */ invokeStartElement (pctxt, "multiUniCastConference", -1); stat = DECODEBIT (pctxt, &pvalue->multiUniCastConference); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multiUniCastConference); invokeEndElement (pctxt, "multiUniCastConference", -1); /* decode mediaDistributionCapability */ invokeStartElement (pctxt, "mediaDistributionCapability", -1); stat = asn1PD_H245_SeqOfH245MediaDistributionCapability (pctxt, &pvalue->mediaDistributionCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaDistributionCapability", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H2250Capability_mcCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250Capability_mcCapability (OOCTXT* pctxt, H245H2250Capability_mcCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode centralizedConferenceMC */ invokeStartElement (pctxt, "centralizedConferenceMC", -1); stat = DECODEBIT (pctxt, &pvalue->centralizedConferenceMC); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->centralizedConferenceMC); invokeEndElement (pctxt, "centralizedConferenceMC", -1); /* decode decentralizedConferenceMC */ invokeStartElement (pctxt, "decentralizedConferenceMC", -1); stat = DECODEBIT (pctxt, &pvalue->decentralizedConferenceMC); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->decentralizedConferenceMC); invokeEndElement (pctxt, "decentralizedConferenceMC", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RTPPayloadType_payloadDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPPayloadType_payloadDescriptor (OOCTXT* pctxt, H245RTPPayloadType_payloadDescriptor* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandardIdentifier */ case 0: invokeStartElement (pctxt, "nonStandardIdentifier", -1); pvalue->u.nonStandardIdentifier = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandardIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardIdentifier", -1); break; /* rfc_number */ case 1: invokeStartElement (pctxt, "rfc_number", -1); /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit == 0) { stat = decodeConsInteger (pctxt, &pvalue->u.rfc_number, 1, 32768); if (stat != ASN_OK) return stat; } else { stat = decodeUnconsInteger (pctxt, &pvalue->u.rfc_number); if (stat != ASN_OK) return stat; } invokeIntValue (pctxt, pvalue->u.rfc_number); invokeEndElement (pctxt, "rfc_number", -1); break; /* oid */ case 2: invokeStartElement (pctxt, "oid", -1); pvalue->u.oid = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.oid); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.oid->numids, pvalue->u.oid->subid); invokeEndElement (pctxt, "oid", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RTPPayloadType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPPayloadType (OOCTXT* pctxt, H245RTPPayloadType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.payloadTypePresent = optbit; /* decode payloadDescriptor */ invokeStartElement (pctxt, "payloadDescriptor", -1); stat = asn1PD_H245RTPPayloadType_payloadDescriptor (pctxt, &pvalue->payloadDescriptor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "payloadDescriptor", -1); /* decode payloadType */ if (pvalue->m.payloadTypePresent) { invokeStartElement (pctxt, "payloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->payloadType, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->payloadType); invokeEndElement (pctxt, "payloadType", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MediaPacketizationCapability_rtpPayloadType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MediaPacketizationCapability_rtpPayloadType (OOCTXT* pctxt, H245MediaPacketizationCapability_rtpPayloadType* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245RTPPayloadType* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245RTPPayloadType); stat = asn1PD_H245RTPPayloadType (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MediaPacketizationCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MediaPacketizationCapability (OOCTXT* pctxt, H245MediaPacketizationCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode h261aVideoPacketization */ invokeStartElement (pctxt, "h261aVideoPacketization", -1); stat = DECODEBIT (pctxt, &pvalue->h261aVideoPacketization); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->h261aVideoPacketization); invokeEndElement (pctxt, "h261aVideoPacketization", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.rtpPayloadTypePresent = 1; invokeStartElement (pctxt, "rtpPayloadType", -1); stat = asn1PD_H245MediaPacketizationCapability_rtpPayloadType (pctxt, &pvalue->rtpPayloadType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtpPayloadType", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* QOSMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245QOSMode (OOCTXT* pctxt, H245QOSMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* guaranteedQOS */ case 0: invokeStartElement (pctxt, "guaranteedQOS", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "guaranteedQOS", -1); break; /* controlledLoad */ case 1: invokeStartElement (pctxt, "controlledLoad", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "controlledLoad", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RSVPParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RSVPParameters (OOCTXT* pctxt, H245RSVPParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.qosModePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokenRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.bucketSizePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.peakRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.minPolicedPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.maxPktSizePresent = optbit; /* decode qosMode */ if (pvalue->m.qosModePresent) { invokeStartElement (pctxt, "qosMode", -1); stat = asn1PD_H245QOSMode (pctxt, &pvalue->qosMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "qosMode", -1); } /* decode tokenRate */ if (pvalue->m.tokenRatePresent) { invokeStartElement (pctxt, "tokenRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->tokenRate, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->tokenRate); invokeEndElement (pctxt, "tokenRate", -1); } /* decode bucketSize */ if (pvalue->m.bucketSizePresent) { invokeStartElement (pctxt, "bucketSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->bucketSize, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bucketSize); invokeEndElement (pctxt, "bucketSize", -1); } /* decode peakRate */ if (pvalue->m.peakRatePresent) { invokeStartElement (pctxt, "peakRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->peakRate, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->peakRate); invokeEndElement (pctxt, "peakRate", -1); } /* decode minPoliced */ if (pvalue->m.minPolicedPresent) { invokeStartElement (pctxt, "minPoliced", -1); stat = decodeConsUnsigned (pctxt, &pvalue->minPoliced, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->minPoliced); invokeEndElement (pctxt, "minPoliced", -1); } /* decode maxPktSize */ if (pvalue->m.maxPktSizePresent) { invokeStartElement (pctxt, "maxPktSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->maxPktSize, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxPktSize); invokeEndElement (pctxt, "maxPktSize", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ATMParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ATMParameters (OOCTXT* pctxt, H245ATMParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode maxNTUSize */ invokeStartElement (pctxt, "maxNTUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxNTUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxNTUSize); invokeEndElement (pctxt, "maxNTUSize", -1); /* decode atmUBR */ invokeStartElement (pctxt, "atmUBR", -1); stat = DECODEBIT (pctxt, &pvalue->atmUBR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->atmUBR); invokeEndElement (pctxt, "atmUBR", -1); /* decode atmrtVBR */ invokeStartElement (pctxt, "atmrtVBR", -1); stat = DECODEBIT (pctxt, &pvalue->atmrtVBR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->atmrtVBR); invokeEndElement (pctxt, "atmrtVBR", -1); /* decode atmnrtVBR */ invokeStartElement (pctxt, "atmnrtVBR", -1); stat = DECODEBIT (pctxt, &pvalue->atmnrtVBR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->atmnrtVBR); invokeEndElement (pctxt, "atmnrtVBR", -1); /* decode atmABR */ invokeStartElement (pctxt, "atmABR", -1); stat = DECODEBIT (pctxt, &pvalue->atmABR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->atmABR); invokeEndElement (pctxt, "atmABR", -1); /* decode atmCBR */ invokeStartElement (pctxt, "atmCBR", -1); stat = DECODEBIT (pctxt, &pvalue->atmCBR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->atmCBR); invokeEndElement (pctxt, "atmCBR", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* QOSCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245QOSCapability (OOCTXT* pctxt, H245QOSCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.rsvpParametersPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.atmParametersPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H245NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode rsvpParameters */ if (pvalue->m.rsvpParametersPresent) { invokeStartElement (pctxt, "rsvpParameters", -1); stat = asn1PD_H245RSVPParameters (pctxt, &pvalue->rsvpParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rsvpParameters", -1); } /* decode atmParameters */ if (pvalue->m.atmParametersPresent) { invokeStartElement (pctxt, "atmParameters", -1); stat = asn1PD_H245ATMParameters (pctxt, &pvalue->atmParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "atmParameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TransportCapability_qOSCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TransportCapability_qOSCapabilities (OOCTXT* pctxt, H245TransportCapability_qOSCapabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245QOSCapability* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245QOSCapability); stat = asn1PD_H245QOSCapability (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MediaTransportType_atm_AAL5_compressed */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MediaTransportType_atm_AAL5_compressed (OOCTXT* pctxt, H245MediaTransportType_atm_AAL5_compressed* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode variable_delta */ invokeStartElement (pctxt, "variable_delta", -1); stat = DECODEBIT (pctxt, &pvalue->variable_delta); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->variable_delta); invokeEndElement (pctxt, "variable_delta", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MediaTransportType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MediaTransportType (OOCTXT* pctxt, H245MediaTransportType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* ip_UDP */ case 0: invokeStartElement (pctxt, "ip_UDP", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "ip_UDP", -1); break; /* ip_TCP */ case 1: invokeStartElement (pctxt, "ip_TCP", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "ip_TCP", -1); break; /* atm_AAL5_UNIDIR */ case 2: invokeStartElement (pctxt, "atm_AAL5_UNIDIR", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "atm_AAL5_UNIDIR", -1); break; /* atm_AAL5_BIDIR */ case 3: invokeStartElement (pctxt, "atm_AAL5_BIDIR", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "atm_AAL5_BIDIR", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* atm_AAL5_compressed */ case 5: invokeStartElement (pctxt, "atm_AAL5_compressed", -1); pvalue->u.atm_AAL5_compressed = ALLOC_ASN1ELEM (pctxt, H245MediaTransportType_atm_AAL5_compressed); stat = asn1PD_H245MediaTransportType_atm_AAL5_compressed (pctxt, pvalue->u.atm_AAL5_compressed); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "atm_AAL5_compressed", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MediaChannelCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MediaChannelCapability (OOCTXT* pctxt, H245MediaChannelCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.mediaTransportPresent = optbit; /* decode mediaTransport */ if (pvalue->m.mediaTransportPresent) { invokeStartElement (pctxt, "mediaTransport", -1); stat = asn1PD_H245MediaTransportType (pctxt, &pvalue->mediaTransport); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaTransport", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TransportCapability_mediaChannelCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TransportCapability_mediaChannelCapabilities (OOCTXT* pctxt, H245TransportCapability_mediaChannelCapabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245MediaChannelCapability* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MediaChannelCapability); stat = asn1PD_H245MediaChannelCapability (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* TransportCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TransportCapability (OOCTXT* pctxt, H245TransportCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.qOSCapabilitiesPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaChannelCapabilitiesPresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } /* decode qOSCapabilities */ if (pvalue->m.qOSCapabilitiesPresent) { invokeStartElement (pctxt, "qOSCapabilities", -1); stat = asn1PD_H245TransportCapability_qOSCapabilities (pctxt, &pvalue->qOSCapabilities); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "qOSCapabilities", -1); } /* decode mediaChannelCapabilities */ if (pvalue->m.mediaChannelCapabilitiesPresent) { invokeStartElement (pctxt, "mediaChannelCapabilities", -1); stat = asn1PD_H245TransportCapability_mediaChannelCapabilities (pctxt, &pvalue->mediaChannelCapabilities); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaChannelCapabilities", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyFrameMapping_frameSequence */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPH263VideoRedundancyFrameMapping_frameSequence (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping_frameSequence* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeConsUInt8 (pctxt, &pvalue->elem[xx1], 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyFrameMapping */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPH263VideoRedundancyFrameMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode threadNumber */ invokeStartElement (pctxt, "threadNumber", -1); stat = decodeConsUInt8 (pctxt, &pvalue->threadNumber, 0U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->threadNumber); invokeEndElement (pctxt, "threadNumber", -1); /* decode frameSequence */ invokeStartElement (pctxt, "frameSequence", -1); stat = asn1PD_H245RTPH263VideoRedundancyFrameMapping_frameSequence (pctxt, &pvalue->frameSequence); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "frameSequence", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_frameToThreadMapping_cust */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245RTPH263VideoRedundancyFrameMapping* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245RTPH263VideoRedundancyFrameMapping); stat = asn1PD_H245RTPH263VideoRedundancyFrameMapping (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_frameToThreadMapping */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* roundrobin */ case 0: invokeStartElement (pctxt, "roundrobin", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "roundrobin", -1); break; /* custom */ case 1: invokeStartElement (pctxt, "custom", -1); pvalue->u.custom = ALLOC_ASN1ELEM (pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom); stat = asn1PD_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom (pctxt, pvalue->u.custom); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "custom", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_containedThreads */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding_containedThreads (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_containedThreads* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeConsUInt8 (pctxt, &pvalue->elem[xx1], 0U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RTPH263VideoRedundancyEncoding (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.containedThreadsPresent = optbit; /* decode numberOfThreads */ invokeStartElement (pctxt, "numberOfThreads", -1); stat = decodeConsUInt8 (pctxt, &pvalue->numberOfThreads, 1U, 16U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfThreads); invokeEndElement (pctxt, "numberOfThreads", -1); /* decode framesBetweenSyncPoints */ invokeStartElement (pctxt, "framesBetweenSyncPoints", -1); stat = decodeConsUInt16 (pctxt, &pvalue->framesBetweenSyncPoints, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->framesBetweenSyncPoints); invokeEndElement (pctxt, "framesBetweenSyncPoints", -1); /* decode frameToThreadMapping */ invokeStartElement (pctxt, "frameToThreadMapping", -1); stat = asn1PD_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping (pctxt, &pvalue->frameToThreadMapping); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "frameToThreadMapping", -1); /* decode containedThreads */ if (pvalue->m.containedThreadsPresent) { invokeStartElement (pctxt, "containedThreads", -1); stat = asn1PD_H245RTPH263VideoRedundancyEncoding_containedThreads (pctxt, &pvalue->containedThreads); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "containedThreads", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingMethod */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingMethod (OOCTXT* pctxt, H245RedundancyEncodingMethod* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* rtpAudioRedundancyEncoding */ case 1: invokeStartElement (pctxt, "rtpAudioRedundancyEncoding", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "rtpAudioRedundancyEncoding", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* rtpH263VideoRedundancyEncoding */ case 3: invokeStartElement (pctxt, "rtpH263VideoRedundancyEncoding", -1); pvalue->u.rtpH263VideoRedundancyEncoding = ALLOC_ASN1ELEM (pctxt, H245RTPH263VideoRedundancyEncoding); stat = asn1PD_H245RTPH263VideoRedundancyEncoding (pctxt, pvalue->u.rtpH263VideoRedundancyEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtpH263VideoRedundancyEncoding", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* CapabilityTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CapabilityTableEntryNumber (OOCTXT* pctxt, H245CapabilityTableEntryNumber* pvalue) { int stat = ASN_OK; stat = decodeConsUInt16 (pctxt, pvalue, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingCapability_secondaryEncoding */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingCapability_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingCapability_secondaryEncoding* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245CapabilityTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingCapability (OOCTXT* pctxt, H245RedundancyEncodingCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.secondaryEncodingPresent = optbit; /* decode redundancyEncodingMethod */ invokeStartElement (pctxt, "redundancyEncodingMethod", -1); stat = asn1PD_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncodingMethod", -1); /* decode primaryEncoding */ invokeStartElement (pctxt, "primaryEncoding", -1); stat = asn1PD_H245CapabilityTableEntryNumber (pctxt, &pvalue->primaryEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "primaryEncoding", -1); /* decode secondaryEncoding */ if (pvalue->m.secondaryEncodingPresent) { invokeStartElement (pctxt, "secondaryEncoding", -1); stat = asn1PD_H245RedundancyEncodingCapability_secondaryEncoding (pctxt, &pvalue->secondaryEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "secondaryEncoding", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H2250Capability_redundancyEncodingCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250Capability_redundancyEncodingCapability (OOCTXT* pctxt, H245H2250Capability_redundancyEncodingCapability* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245RedundancyEncodingCapability* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245RedundancyEncodingCapability); stat = asn1PD_H245RedundancyEncodingCapability (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* H2250Capability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250Capability (OOCTXT* pctxt, H245H2250Capability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode maximumAudioDelayJitter */ invokeStartElement (pctxt, "maximumAudioDelayJitter", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumAudioDelayJitter, 0U, 1023U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumAudioDelayJitter); invokeEndElement (pctxt, "maximumAudioDelayJitter", -1); /* decode receiveMultipointCapability */ invokeStartElement (pctxt, "receiveMultipointCapability", -1); stat = asn1PD_H245MultipointCapability (pctxt, &pvalue->receiveMultipointCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveMultipointCapability", -1); /* decode transmitMultipointCapability */ invokeStartElement (pctxt, "transmitMultipointCapability", -1); stat = asn1PD_H245MultipointCapability (pctxt, &pvalue->transmitMultipointCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitMultipointCapability", -1); /* decode receiveAndTransmitMultipointCapability */ invokeStartElement (pctxt, "receiveAndTransmitMultipointCapability", -1); stat = asn1PD_H245MultipointCapability (pctxt, &pvalue->receiveAndTransmitMultipointCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveAndTransmitMultipointCapability", -1); /* decode mcCapability */ invokeStartElement (pctxt, "mcCapability", -1); stat = asn1PD_H245H2250Capability_mcCapability (pctxt, &pvalue->mcCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mcCapability", -1); /* decode rtcpVideoControlCapability */ invokeStartElement (pctxt, "rtcpVideoControlCapability", -1); stat = DECODEBIT (pctxt, &pvalue->rtcpVideoControlCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->rtcpVideoControlCapability); invokeEndElement (pctxt, "rtcpVideoControlCapability", -1); /* decode mediaPacketizationCapability */ invokeStartElement (pctxt, "mediaPacketizationCapability", -1); stat = asn1PD_H245MediaPacketizationCapability (pctxt, &pvalue->mediaPacketizationCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaPacketizationCapability", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 4 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.transportCapabilityPresent = 1; invokeStartElement (pctxt, "transportCapability", -1); stat = asn1PD_H245TransportCapability (pctxt, &pvalue->transportCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transportCapability", -1); break; case 1: pvalue->m.redundancyEncodingCapabilityPresent = 1; invokeStartElement (pctxt, "redundancyEncodingCapability", -1); stat = asn1PD_H245H2250Capability_redundancyEncodingCapability (pctxt, &pvalue->redundancyEncodingCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncodingCapability", -1); break; case 2: pvalue->m.logicalChannelSwitchingCapabilityPresent = 1; invokeStartElement (pctxt, "logicalChannelSwitchingCapability", -1); stat = DECODEBIT (pctxt, &pvalue->logicalChannelSwitchingCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->logicalChannelSwitchingCapability); invokeEndElement (pctxt, "logicalChannelSwitchingCapability", -1); break; case 3: pvalue->m.t120DynamicPortCapabilityPresent = 1; invokeStartElement (pctxt, "t120DynamicPortCapability", -1); stat = DECODEBIT (pctxt, &pvalue->t120DynamicPortCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->t120DynamicPortCapability); invokeEndElement (pctxt, "t120DynamicPortCapability", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* MultiplexCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexCapability (OOCTXT* pctxt, H245MultiplexCapability* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* h222Capability */ case 1: invokeStartElement (pctxt, "h222Capability", -1); pvalue->u.h222Capability = ALLOC_ASN1ELEM (pctxt, H245H222Capability); stat = asn1PD_H245H222Capability (pctxt, pvalue->u.h222Capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h222Capability", -1); break; /* h223Capability */ case 2: invokeStartElement (pctxt, "h223Capability", -1); pvalue->u.h223Capability = ALLOC_ASN1ELEM (pctxt, H245H223Capability); stat = asn1PD_H245H223Capability (pctxt, pvalue->u.h223Capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223Capability", -1); break; /* v76Capability */ case 3: invokeStartElement (pctxt, "v76Capability", -1); pvalue->u.v76Capability = ALLOC_ASN1ELEM (pctxt, H245V76Capability); stat = asn1PD_H245V76Capability (pctxt, pvalue->u.v76Capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v76Capability", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* h2250Capability */ case 5: invokeStartElement (pctxt, "h2250Capability", -1); pvalue->u.h2250Capability = ALLOC_ASN1ELEM (pctxt, H245H2250Capability); stat = asn1PD_H245H2250Capability (pctxt, pvalue->u.h2250Capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h2250Capability", -1); break; /* genericMultiplexCapability */ case 6: invokeStartElement (pctxt, "genericMultiplexCapability", -1); pvalue->u.genericMultiplexCapability = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericMultiplexCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericMultiplexCapability", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H261VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H261VideoCapability (OOCTXT* pctxt, H245H261VideoCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.qcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cifMPIPresent = optbit; /* decode qcifMPI */ if (pvalue->m.qcifMPIPresent) { invokeStartElement (pctxt, "qcifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->qcifMPI, 1U, 4U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->qcifMPI); invokeEndElement (pctxt, "qcifMPI", -1); } /* decode cifMPI */ if (pvalue->m.cifMPIPresent) { invokeStartElement (pctxt, "cifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->cifMPI, 1U, 4U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cifMPI); invokeEndElement (pctxt, "cifMPI", -1); } /* decode temporalSpatialTradeOffCapability */ invokeStartElement (pctxt, "temporalSpatialTradeOffCapability", -1); stat = DECODEBIT (pctxt, &pvalue->temporalSpatialTradeOffCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->temporalSpatialTradeOffCapability); invokeEndElement (pctxt, "temporalSpatialTradeOffCapability", -1); /* decode maxBitRate */ invokeStartElement (pctxt, "maxBitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxBitRate, 1U, 19200U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxBitRate); invokeEndElement (pctxt, "maxBitRate", -1); /* decode stillImageTransmission */ invokeStartElement (pctxt, "stillImageTransmission", -1); stat = DECODEBIT (pctxt, &pvalue->stillImageTransmission); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->stillImageTransmission); invokeEndElement (pctxt, "stillImageTransmission", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.videoBadMBsCapPresent = 1; invokeStartElement (pctxt, "videoBadMBsCap", -1); stat = DECODEBIT (pctxt, &pvalue->videoBadMBsCap); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoBadMBsCap); invokeEndElement (pctxt, "videoBadMBsCap", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H262VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H262VideoCapability (OOCTXT* pctxt, H245H262VideoCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.videoBitRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.vbvBufferSizePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.samplesPerLinePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.linesPerFramePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.framesPerSecondPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.luminanceSampleRatePresent = optbit; /* decode profileAndLevel_SPatML */ invokeStartElement (pctxt, "profileAndLevel_SPatML", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_SPatML); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_SPatML); invokeEndElement (pctxt, "profileAndLevel_SPatML", -1); /* decode profileAndLevel_MPatLL */ invokeStartElement (pctxt, "profileAndLevel_MPatLL", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_MPatLL); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_MPatLL); invokeEndElement (pctxt, "profileAndLevel_MPatLL", -1); /* decode profileAndLevel_MPatML */ invokeStartElement (pctxt, "profileAndLevel_MPatML", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_MPatML); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_MPatML); invokeEndElement (pctxt, "profileAndLevel_MPatML", -1); /* decode profileAndLevel_MPatH_14 */ invokeStartElement (pctxt, "profileAndLevel_MPatH_14", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_MPatH_14); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_MPatH_14); invokeEndElement (pctxt, "profileAndLevel_MPatH_14", -1); /* decode profileAndLevel_MPatHL */ invokeStartElement (pctxt, "profileAndLevel_MPatHL", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_MPatHL); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_MPatHL); invokeEndElement (pctxt, "profileAndLevel_MPatHL", -1); /* decode profileAndLevel_SNRatLL */ invokeStartElement (pctxt, "profileAndLevel_SNRatLL", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_SNRatLL); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_SNRatLL); invokeEndElement (pctxt, "profileAndLevel_SNRatLL", -1); /* decode profileAndLevel_SNRatML */ invokeStartElement (pctxt, "profileAndLevel_SNRatML", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_SNRatML); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_SNRatML); invokeEndElement (pctxt, "profileAndLevel_SNRatML", -1); /* decode profileAndLevel_SpatialatH_14 */ invokeStartElement (pctxt, "profileAndLevel_SpatialatH_14", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_SpatialatH_14); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_SpatialatH_14); invokeEndElement (pctxt, "profileAndLevel_SpatialatH_14", -1); /* decode profileAndLevel_HPatML */ invokeStartElement (pctxt, "profileAndLevel_HPatML", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_HPatML); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_HPatML); invokeEndElement (pctxt, "profileAndLevel_HPatML", -1); /* decode profileAndLevel_HPatH_14 */ invokeStartElement (pctxt, "profileAndLevel_HPatH_14", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_HPatH_14); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_HPatH_14); invokeEndElement (pctxt, "profileAndLevel_HPatH_14", -1); /* decode profileAndLevel_HPatHL */ invokeStartElement (pctxt, "profileAndLevel_HPatHL", -1); stat = DECODEBIT (pctxt, &pvalue->profileAndLevel_HPatHL); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->profileAndLevel_HPatHL); invokeEndElement (pctxt, "profileAndLevel_HPatHL", -1); /* decode videoBitRate */ if (pvalue->m.videoBitRatePresent) { invokeStartElement (pctxt, "videoBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->videoBitRate); invokeEndElement (pctxt, "videoBitRate", -1); } /* decode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { invokeStartElement (pctxt, "vbvBufferSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->vbvBufferSize); invokeEndElement (pctxt, "vbvBufferSize", -1); } /* decode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { invokeStartElement (pctxt, "samplesPerLine", -1); stat = decodeConsUInt16 (pctxt, &pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->samplesPerLine); invokeEndElement (pctxt, "samplesPerLine", -1); } /* decode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { invokeStartElement (pctxt, "linesPerFrame", -1); stat = decodeConsUInt16 (pctxt, &pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->linesPerFrame); invokeEndElement (pctxt, "linesPerFrame", -1); } /* decode framesPerSecond */ if (pvalue->m.framesPerSecondPresent) { invokeStartElement (pctxt, "framesPerSecond", -1); stat = decodeConsUInt8 (pctxt, &pvalue->framesPerSecond, 0U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->framesPerSecond); invokeEndElement (pctxt, "framesPerSecond", -1); } /* decode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { invokeStartElement (pctxt, "luminanceSampleRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->luminanceSampleRate); invokeEndElement (pctxt, "luminanceSampleRate", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.videoBadMBsCapPresent = 1; invokeStartElement (pctxt, "videoBadMBsCap", -1); stat = DECODEBIT (pctxt, &pvalue->videoBadMBsCap); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoBadMBsCap); invokeEndElement (pctxt, "videoBadMBsCap", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* TransparencyParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TransparencyParameters (OOCTXT* pctxt, H245TransparencyParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode presentationOrder */ invokeStartElement (pctxt, "presentationOrder", -1); stat = decodeConsUInt16 (pctxt, &pvalue->presentationOrder, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->presentationOrder); invokeEndElement (pctxt, "presentationOrder", -1); /* decode offset_x */ invokeStartElement (pctxt, "offset_x", -1); stat = decodeConsInteger (pctxt, &pvalue->offset_x, -262144, 262143); if (stat != ASN_OK) return stat; invokeIntValue (pctxt, pvalue->offset_x); invokeEndElement (pctxt, "offset_x", -1); /* decode offset_y */ invokeStartElement (pctxt, "offset_y", -1); stat = decodeConsInteger (pctxt, &pvalue->offset_y, -262144, 262143); if (stat != ASN_OK) return stat; invokeIntValue (pctxt, pvalue->offset_y); invokeEndElement (pctxt, "offset_y", -1); /* decode scale_x */ invokeStartElement (pctxt, "scale_x", -1); stat = decodeConsUInt8 (pctxt, &pvalue->scale_x, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->scale_x); invokeEndElement (pctxt, "scale_x", -1); /* decode scale_y */ invokeStartElement (pctxt, "scale_y", -1); stat = decodeConsUInt8 (pctxt, &pvalue->scale_y, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->scale_y); invokeEndElement (pctxt, "scale_y", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_additionalPictureMemory */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RefPictureSelection_additionalPictureMemory (OOCTXT* pctxt, H245RefPictureSelection_additionalPictureMemory* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.sqcifAdditionalPictureMemoryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.qcifAdditionalPictureMemoryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cifAdditionalPictureMemoryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif4AdditionalPictureMemoryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif16AdditionalPictureMemoryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.bigCpfAdditionalPictureMemoryPresent = optbit; /* decode sqcifAdditionalPictureMemory */ if (pvalue->m.sqcifAdditionalPictureMemoryPresent) { invokeStartElement (pctxt, "sqcifAdditionalPictureMemory", -1); stat = decodeConsUInt16 (pctxt, &pvalue->sqcifAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sqcifAdditionalPictureMemory); invokeEndElement (pctxt, "sqcifAdditionalPictureMemory", -1); } /* decode qcifAdditionalPictureMemory */ if (pvalue->m.qcifAdditionalPictureMemoryPresent) { invokeStartElement (pctxt, "qcifAdditionalPictureMemory", -1); stat = decodeConsUInt16 (pctxt, &pvalue->qcifAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->qcifAdditionalPictureMemory); invokeEndElement (pctxt, "qcifAdditionalPictureMemory", -1); } /* decode cifAdditionalPictureMemory */ if (pvalue->m.cifAdditionalPictureMemoryPresent) { invokeStartElement (pctxt, "cifAdditionalPictureMemory", -1); stat = decodeConsUInt16 (pctxt, &pvalue->cifAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cifAdditionalPictureMemory); invokeEndElement (pctxt, "cifAdditionalPictureMemory", -1); } /* decode cif4AdditionalPictureMemory */ if (pvalue->m.cif4AdditionalPictureMemoryPresent) { invokeStartElement (pctxt, "cif4AdditionalPictureMemory", -1); stat = decodeConsUInt16 (pctxt, &pvalue->cif4AdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif4AdditionalPictureMemory); invokeEndElement (pctxt, "cif4AdditionalPictureMemory", -1); } /* decode cif16AdditionalPictureMemory */ if (pvalue->m.cif16AdditionalPictureMemoryPresent) { invokeStartElement (pctxt, "cif16AdditionalPictureMemory", -1); stat = decodeConsUInt16 (pctxt, &pvalue->cif16AdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif16AdditionalPictureMemory); invokeEndElement (pctxt, "cif16AdditionalPictureMemory", -1); } /* decode bigCpfAdditionalPictureMemory */ if (pvalue->m.bigCpfAdditionalPictureMemoryPresent) { invokeStartElement (pctxt, "bigCpfAdditionalPictureMemory", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bigCpfAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bigCpfAdditionalPictureMemory); invokeEndElement (pctxt, "bigCpfAdditionalPictureMemory", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_videoBackChannelSend */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RefPictureSelection_videoBackChannelSend (OOCTXT* pctxt, H245RefPictureSelection_videoBackChannelSend* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* none */ case 0: invokeStartElement (pctxt, "none", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "none", -1); break; /* ackMessageOnly */ case 1: invokeStartElement (pctxt, "ackMessageOnly", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "ackMessageOnly", -1); break; /* nackMessageOnly */ case 2: invokeStartElement (pctxt, "nackMessageOnly", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nackMessageOnly", -1); break; /* ackOrNackMessageOnly */ case 3: invokeStartElement (pctxt, "ackOrNackMessageOnly", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "ackOrNackMessageOnly", -1); break; /* ackAndNackMessage */ case 4: invokeStartElement (pctxt, "ackAndNackMessage", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "ackAndNackMessage", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_enhancedReferencePicSelect_subPictur */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode mpuHorizMBs */ invokeStartElement (pctxt, "mpuHorizMBs", -1); stat = decodeConsUInt8 (pctxt, &pvalue->mpuHorizMBs, 1U, 128U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->mpuHorizMBs); invokeEndElement (pctxt, "mpuHorizMBs", -1); /* decode mpuVertMBs */ invokeStartElement (pctxt, "mpuVertMBs", -1); stat = decodeConsUInt8 (pctxt, &pvalue->mpuVertMBs, 1U, 72U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->mpuVertMBs); invokeEndElement (pctxt, "mpuVertMBs", -1); /* decode mpuTotalNumber */ invokeStartElement (pctxt, "mpuTotalNumber", -1); stat = decodeConsUnsigned (pctxt, &pvalue->mpuTotalNumber, 1U, 65536U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->mpuTotalNumber); invokeEndElement (pctxt, "mpuTotalNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_enhancedReferencePicSelect */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RefPictureSelection_enhancedReferencePicSelect (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.subPictureRemovalParametersPresent = optbit; /* decode subPictureRemovalParameters */ if (pvalue->m.subPictureRemovalParametersPresent) { invokeStartElement (pctxt, "subPictureRemovalParameters", -1); stat = asn1PD_H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters (pctxt, &pvalue->subPictureRemovalParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "subPictureRemovalParameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RefPictureSelection (OOCTXT* pctxt, H245RefPictureSelection* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.additionalPictureMemoryPresent = optbit; /* decode additionalPictureMemory */ if (pvalue->m.additionalPictureMemoryPresent) { invokeStartElement (pctxt, "additionalPictureMemory", -1); stat = asn1PD_H245RefPictureSelection_additionalPictureMemory (pctxt, &pvalue->additionalPictureMemory); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "additionalPictureMemory", -1); } /* decode videoMux */ invokeStartElement (pctxt, "videoMux", -1); stat = DECODEBIT (pctxt, &pvalue->videoMux); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoMux); invokeEndElement (pctxt, "videoMux", -1); /* decode videoBackChannelSend */ invokeStartElement (pctxt, "videoBackChannelSend", -1); stat = asn1PD_H245RefPictureSelection_videoBackChannelSend (pctxt, &pvalue->videoBackChannelSend); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoBackChannelSend", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.enhancedReferencePicSelectPresent = 1; invokeStartElement (pctxt, "enhancedReferencePicSelect", -1); stat = asn1PD_H245RefPictureSelection_enhancedReferencePicSelect (pctxt, &pvalue->enhancedReferencePicSelect); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "enhancedReferencePicSelect", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* CustomPictureClockFrequency */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureClockFrequency (OOCTXT* pctxt, H245CustomPictureClockFrequency* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.sqcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.qcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif4MPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif16MPIPresent = optbit; /* decode clockConversionCode */ invokeStartElement (pctxt, "clockConversionCode", -1); stat = decodeConsUInt16 (pctxt, &pvalue->clockConversionCode, 1000U, 1001U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->clockConversionCode); invokeEndElement (pctxt, "clockConversionCode", -1); /* decode clockDivisor */ invokeStartElement (pctxt, "clockDivisor", -1); stat = decodeConsUInt8 (pctxt, &pvalue->clockDivisor, 1U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->clockDivisor); invokeEndElement (pctxt, "clockDivisor", -1); /* decode sqcifMPI */ if (pvalue->m.sqcifMPIPresent) { invokeStartElement (pctxt, "sqcifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->sqcifMPI, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sqcifMPI); invokeEndElement (pctxt, "sqcifMPI", -1); } /* decode qcifMPI */ if (pvalue->m.qcifMPIPresent) { invokeStartElement (pctxt, "qcifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->qcifMPI, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->qcifMPI); invokeEndElement (pctxt, "qcifMPI", -1); } /* decode cifMPI */ if (pvalue->m.cifMPIPresent) { invokeStartElement (pctxt, "cifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->cifMPI, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cifMPI); invokeEndElement (pctxt, "cifMPI", -1); } /* decode cif4MPI */ if (pvalue->m.cif4MPIPresent) { invokeStartElement (pctxt, "cif4MPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->cif4MPI, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif4MPI); invokeEndElement (pctxt, "cif4MPI", -1); } /* decode cif16MPI */ if (pvalue->m.cif16MPIPresent) { invokeStartElement (pctxt, "cif16MPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->cif16MPI, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif16MPI); invokeEndElement (pctxt, "cif16MPI", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H263Options_customPictureClockFrequency */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263Options_customPictureClockFrequency (OOCTXT* pctxt, H245H263Options_customPictureClockFrequency* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H245CustomPictureClockFrequency* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CustomPictureClockFrequency); stat = asn1PD_H245CustomPictureClockFrequency (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_mPI_customPCF_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat_mPI_customPCF_element (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF_element* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode clockConversionCode */ invokeStartElement (pctxt, "clockConversionCode", -1); stat = decodeConsUInt16 (pctxt, &pvalue->clockConversionCode, 1000U, 1001U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->clockConversionCode); invokeEndElement (pctxt, "clockConversionCode", -1); /* decode clockDivisor */ invokeStartElement (pctxt, "clockDivisor", -1); stat = decodeConsUInt8 (pctxt, &pvalue->clockDivisor, 1U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->clockDivisor); invokeEndElement (pctxt, "clockDivisor", -1); /* decode customMPI */ invokeStartElement (pctxt, "customMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->customMPI, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->customMPI); invokeEndElement (pctxt, "customMPI", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_mPI_customPCF */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat_mPI_customPCF (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H245CustomPictureFormat_mPI_customPCF_element* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CustomPictureFormat_mPI_customPCF_element); stat = asn1PD_H245CustomPictureFormat_mPI_customPCF_element (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_mPI */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat_mPI (OOCTXT* pctxt, H245CustomPictureFormat_mPI* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.standardMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.customPCFPresent = optbit; /* decode standardMPI */ if (pvalue->m.standardMPIPresent) { invokeStartElement (pctxt, "standardMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->standardMPI, 1U, 31U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->standardMPI); invokeEndElement (pctxt, "standardMPI", -1); } /* decode customPCF */ if (pvalue->m.customPCFPresent) { invokeStartElement (pctxt, "customPCF", -1); stat = asn1PD_H245CustomPictureFormat_mPI_customPCF (pctxt, &pvalue->customPCF); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "customPCF", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_pixelAspectCo */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeConsUInt8 (pctxt, &pvalue->elem[xx1], 1U, 14U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_extendedPAR_e */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode width */ invokeStartElement (pctxt, "width", -1); stat = decodeConsUInt8 (pctxt, &pvalue->width, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->width); invokeEndElement (pctxt, "width", -1); /* decode height */ invokeStartElement (pctxt, "height", -1); stat = decodeConsUInt8 (pctxt, &pvalue->height, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->height); invokeEndElement (pctxt, "height", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_extendedPAR */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation_extendedPAR (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element); stat = asn1PD_H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat_pixelAspectInformation (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* anyPixelAspectRatio */ case 0: invokeStartElement (pctxt, "anyPixelAspectRatio", -1); stat = DECODEBIT (pctxt, &pvalue->u.anyPixelAspectRatio); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->u.anyPixelAspectRatio); invokeEndElement (pctxt, "anyPixelAspectRatio", -1); break; /* pixelAspectCode */ case 1: invokeStartElement (pctxt, "pixelAspectCode", -1); pvalue->u.pixelAspectCode = ALLOC_ASN1ELEM (pctxt, H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode); stat = asn1PD_H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode (pctxt, pvalue->u.pixelAspectCode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "pixelAspectCode", -1); break; /* extendedPAR */ case 2: invokeStartElement (pctxt, "extendedPAR", -1); pvalue->u.extendedPAR = ALLOC_ASN1ELEM (pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR); stat = asn1PD_H245CustomPictureFormat_pixelAspectInformation_extendedPAR (pctxt, pvalue->u.extendedPAR); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "extendedPAR", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CustomPictureFormat (OOCTXT* pctxt, H245CustomPictureFormat* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode maxCustomPictureWidth */ invokeStartElement (pctxt, "maxCustomPictureWidth", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxCustomPictureWidth, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxCustomPictureWidth); invokeEndElement (pctxt, "maxCustomPictureWidth", -1); /* decode maxCustomPictureHeight */ invokeStartElement (pctxt, "maxCustomPictureHeight", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxCustomPictureHeight, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxCustomPictureHeight); invokeEndElement (pctxt, "maxCustomPictureHeight", -1); /* decode minCustomPictureWidth */ invokeStartElement (pctxt, "minCustomPictureWidth", -1); stat = decodeConsUInt16 (pctxt, &pvalue->minCustomPictureWidth, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->minCustomPictureWidth); invokeEndElement (pctxt, "minCustomPictureWidth", -1); /* decode minCustomPictureHeight */ invokeStartElement (pctxt, "minCustomPictureHeight", -1); stat = decodeConsUInt16 (pctxt, &pvalue->minCustomPictureHeight, 1U, 2048U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->minCustomPictureHeight); invokeEndElement (pctxt, "minCustomPictureHeight", -1); /* decode mPI */ invokeStartElement (pctxt, "mPI", -1); stat = asn1PD_H245CustomPictureFormat_mPI (pctxt, &pvalue->mPI); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mPI", -1); /* decode pixelAspectInformation */ invokeStartElement (pctxt, "pixelAspectInformation", -1); stat = asn1PD_H245CustomPictureFormat_pixelAspectInformation (pctxt, &pvalue->pixelAspectInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "pixelAspectInformation", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H263Options_customPictureFormat */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263Options_customPictureFormat (OOCTXT* pctxt, H245H263Options_customPictureFormat* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H245CustomPictureFormat* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CustomPictureFormat); stat = asn1PD_H245CustomPictureFormat (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* H263Version3Options */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263Version3Options (OOCTXT* pctxt, H245H263Version3Options* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode dataPartitionedSlices */ invokeStartElement (pctxt, "dataPartitionedSlices", -1); stat = DECODEBIT (pctxt, &pvalue->dataPartitionedSlices); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dataPartitionedSlices); invokeEndElement (pctxt, "dataPartitionedSlices", -1); /* decode fixedPointIDCT0 */ invokeStartElement (pctxt, "fixedPointIDCT0", -1); stat = DECODEBIT (pctxt, &pvalue->fixedPointIDCT0); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fixedPointIDCT0); invokeEndElement (pctxt, "fixedPointIDCT0", -1); /* decode interlacedFields */ invokeStartElement (pctxt, "interlacedFields", -1); stat = DECODEBIT (pctxt, &pvalue->interlacedFields); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->interlacedFields); invokeEndElement (pctxt, "interlacedFields", -1); /* decode currentPictureHeaderRepetition */ invokeStartElement (pctxt, "currentPictureHeaderRepetition", -1); stat = DECODEBIT (pctxt, &pvalue->currentPictureHeaderRepetition); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->currentPictureHeaderRepetition); invokeEndElement (pctxt, "currentPictureHeaderRepetition", -1); /* decode previousPictureHeaderRepetition */ invokeStartElement (pctxt, "previousPictureHeaderRepetition", -1); stat = DECODEBIT (pctxt, &pvalue->previousPictureHeaderRepetition); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->previousPictureHeaderRepetition); invokeEndElement (pctxt, "previousPictureHeaderRepetition", -1); /* decode nextPictureHeaderRepetition */ invokeStartElement (pctxt, "nextPictureHeaderRepetition", -1); stat = DECODEBIT (pctxt, &pvalue->nextPictureHeaderRepetition); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->nextPictureHeaderRepetition); invokeEndElement (pctxt, "nextPictureHeaderRepetition", -1); /* decode pictureNumber */ invokeStartElement (pctxt, "pictureNumber", -1); stat = DECODEBIT (pctxt, &pvalue->pictureNumber); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->pictureNumber); invokeEndElement (pctxt, "pictureNumber", -1); /* decode spareReferencePictures */ invokeStartElement (pctxt, "spareReferencePictures", -1); stat = DECODEBIT (pctxt, &pvalue->spareReferencePictures); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->spareReferencePictures); invokeEndElement (pctxt, "spareReferencePictures", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H263ModeComboFlags */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263ModeComboFlags (OOCTXT* pctxt, H245H263ModeComboFlags* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode unrestrictedVector */ invokeStartElement (pctxt, "unrestrictedVector", -1); stat = DECODEBIT (pctxt, &pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->unrestrictedVector); invokeEndElement (pctxt, "unrestrictedVector", -1); /* decode arithmeticCoding */ invokeStartElement (pctxt, "arithmeticCoding", -1); stat = DECODEBIT (pctxt, &pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->arithmeticCoding); invokeEndElement (pctxt, "arithmeticCoding", -1); /* decode advancedPrediction */ invokeStartElement (pctxt, "advancedPrediction", -1); stat = DECODEBIT (pctxt, &pvalue->advancedPrediction); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->advancedPrediction); invokeEndElement (pctxt, "advancedPrediction", -1); /* decode pbFrames */ invokeStartElement (pctxt, "pbFrames", -1); stat = DECODEBIT (pctxt, &pvalue->pbFrames); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->pbFrames); invokeEndElement (pctxt, "pbFrames", -1); /* decode advancedIntraCodingMode */ invokeStartElement (pctxt, "advancedIntraCodingMode", -1); stat = DECODEBIT (pctxt, &pvalue->advancedIntraCodingMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->advancedIntraCodingMode); invokeEndElement (pctxt, "advancedIntraCodingMode", -1); /* decode deblockingFilterMode */ invokeStartElement (pctxt, "deblockingFilterMode", -1); stat = DECODEBIT (pctxt, &pvalue->deblockingFilterMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->deblockingFilterMode); invokeEndElement (pctxt, "deblockingFilterMode", -1); /* decode unlimitedMotionVectors */ invokeStartElement (pctxt, "unlimitedMotionVectors", -1); stat = DECODEBIT (pctxt, &pvalue->unlimitedMotionVectors); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->unlimitedMotionVectors); invokeEndElement (pctxt, "unlimitedMotionVectors", -1); /* decode slicesInOrder_NonRect */ invokeStartElement (pctxt, "slicesInOrder_NonRect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesInOrder_NonRect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesInOrder_NonRect); invokeEndElement (pctxt, "slicesInOrder_NonRect", -1); /* decode slicesInOrder_Rect */ invokeStartElement (pctxt, "slicesInOrder_Rect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesInOrder_Rect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesInOrder_Rect); invokeEndElement (pctxt, "slicesInOrder_Rect", -1); /* decode slicesNoOrder_NonRect */ invokeStartElement (pctxt, "slicesNoOrder_NonRect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesNoOrder_NonRect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesNoOrder_NonRect); invokeEndElement (pctxt, "slicesNoOrder_NonRect", -1); /* decode slicesNoOrder_Rect */ invokeStartElement (pctxt, "slicesNoOrder_Rect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesNoOrder_Rect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesNoOrder_Rect); invokeEndElement (pctxt, "slicesNoOrder_Rect", -1); /* decode improvedPBFramesMode */ invokeStartElement (pctxt, "improvedPBFramesMode", -1); stat = DECODEBIT (pctxt, &pvalue->improvedPBFramesMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->improvedPBFramesMode); invokeEndElement (pctxt, "improvedPBFramesMode", -1); /* decode referencePicSelect */ invokeStartElement (pctxt, "referencePicSelect", -1); stat = DECODEBIT (pctxt, &pvalue->referencePicSelect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->referencePicSelect); invokeEndElement (pctxt, "referencePicSelect", -1); /* decode dynamicPictureResizingByFour */ invokeStartElement (pctxt, "dynamicPictureResizingByFour", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicPictureResizingByFour); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicPictureResizingByFour); invokeEndElement (pctxt, "dynamicPictureResizingByFour", -1); /* decode dynamicPictureResizingSixteenthPel */ invokeStartElement (pctxt, "dynamicPictureResizingSixteenthPel", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicPictureResizingSixteenthPel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicPictureResizingSixteenthPel); invokeEndElement (pctxt, "dynamicPictureResizingSixteenthPel", -1); /* decode dynamicWarpingHalfPel */ invokeStartElement (pctxt, "dynamicWarpingHalfPel", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicWarpingHalfPel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicWarpingHalfPel); invokeEndElement (pctxt, "dynamicWarpingHalfPel", -1); /* decode dynamicWarpingSixteenthPel */ invokeStartElement (pctxt, "dynamicWarpingSixteenthPel", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicWarpingSixteenthPel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicWarpingSixteenthPel); invokeEndElement (pctxt, "dynamicWarpingSixteenthPel", -1); /* decode reducedResolutionUpdate */ invokeStartElement (pctxt, "reducedResolutionUpdate", -1); stat = DECODEBIT (pctxt, &pvalue->reducedResolutionUpdate); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->reducedResolutionUpdate); invokeEndElement (pctxt, "reducedResolutionUpdate", -1); /* decode independentSegmentDecoding */ invokeStartElement (pctxt, "independentSegmentDecoding", -1); stat = DECODEBIT (pctxt, &pvalue->independentSegmentDecoding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->independentSegmentDecoding); invokeEndElement (pctxt, "independentSegmentDecoding", -1); /* decode alternateInterVLCMode */ invokeStartElement (pctxt, "alternateInterVLCMode", -1); stat = DECODEBIT (pctxt, &pvalue->alternateInterVLCMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alternateInterVLCMode); invokeEndElement (pctxt, "alternateInterVLCMode", -1); /* decode modifiedQuantizationMode */ invokeStartElement (pctxt, "modifiedQuantizationMode", -1); stat = DECODEBIT (pctxt, &pvalue->modifiedQuantizationMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->modifiedQuantizationMode); invokeEndElement (pctxt, "modifiedQuantizationMode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.enhancedReferencePicSelectPresent = 1; invokeStartElement (pctxt, "enhancedReferencePicSelect", -1); stat = DECODEBIT (pctxt, &pvalue->enhancedReferencePicSelect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->enhancedReferencePicSelect); invokeEndElement (pctxt, "enhancedReferencePicSelect", -1); break; case 1: pvalue->m.h263Version3OptionsPresent = 1; invokeStartElement (pctxt, "h263Version3Options", -1); stat = asn1PD_H245H263Version3Options (pctxt, &pvalue->h263Version3Options); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263Version3Options", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H263VideoModeCombos_h263VideoCoupledModes */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263VideoModeCombos_h263VideoCoupledModes (OOCTXT* pctxt, H245H263VideoModeCombos_h263VideoCoupledModes* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H245H263ModeComboFlags* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245H263ModeComboFlags); stat = asn1PD_H245H263ModeComboFlags (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* H263VideoModeCombos */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263VideoModeCombos (OOCTXT* pctxt, H245H263VideoModeCombos* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode h263VideoUncoupledModes */ invokeStartElement (pctxt, "h263VideoUncoupledModes", -1); stat = asn1PD_H245H263ModeComboFlags (pctxt, &pvalue->h263VideoUncoupledModes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263VideoUncoupledModes", -1); /* decode h263VideoCoupledModes */ invokeStartElement (pctxt, "h263VideoCoupledModes", -1); stat = asn1PD_H245H263VideoModeCombos_h263VideoCoupledModes (pctxt, &pvalue->h263VideoCoupledModes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263VideoCoupledModes", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H263Options_modeCombos */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263Options_modeCombos (OOCTXT* pctxt, H245H263Options_modeCombos* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H245H263VideoModeCombos* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245H263VideoModeCombos); stat = asn1PD_H245H263VideoModeCombos (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* H263Options */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263Options (OOCTXT* pctxt, H245H263Options* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.transparencyParametersPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.refPictureSelectionPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.customPictureClockFrequencyPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.customPictureFormatPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.modeCombosPresent = optbit; /* decode advancedIntraCodingMode */ invokeStartElement (pctxt, "advancedIntraCodingMode", -1); stat = DECODEBIT (pctxt, &pvalue->advancedIntraCodingMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->advancedIntraCodingMode); invokeEndElement (pctxt, "advancedIntraCodingMode", -1); /* decode deblockingFilterMode */ invokeStartElement (pctxt, "deblockingFilterMode", -1); stat = DECODEBIT (pctxt, &pvalue->deblockingFilterMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->deblockingFilterMode); invokeEndElement (pctxt, "deblockingFilterMode", -1); /* decode improvedPBFramesMode */ invokeStartElement (pctxt, "improvedPBFramesMode", -1); stat = DECODEBIT (pctxt, &pvalue->improvedPBFramesMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->improvedPBFramesMode); invokeEndElement (pctxt, "improvedPBFramesMode", -1); /* decode unlimitedMotionVectors */ invokeStartElement (pctxt, "unlimitedMotionVectors", -1); stat = DECODEBIT (pctxt, &pvalue->unlimitedMotionVectors); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->unlimitedMotionVectors); invokeEndElement (pctxt, "unlimitedMotionVectors", -1); /* decode fullPictureFreeze */ invokeStartElement (pctxt, "fullPictureFreeze", -1); stat = DECODEBIT (pctxt, &pvalue->fullPictureFreeze); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fullPictureFreeze); invokeEndElement (pctxt, "fullPictureFreeze", -1); /* decode partialPictureFreezeAndRelease */ invokeStartElement (pctxt, "partialPictureFreezeAndRelease", -1); stat = DECODEBIT (pctxt, &pvalue->partialPictureFreezeAndRelease); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->partialPictureFreezeAndRelease); invokeEndElement (pctxt, "partialPictureFreezeAndRelease", -1); /* decode resizingPartPicFreezeAndRelease */ invokeStartElement (pctxt, "resizingPartPicFreezeAndRelease", -1); stat = DECODEBIT (pctxt, &pvalue->resizingPartPicFreezeAndRelease); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->resizingPartPicFreezeAndRelease); invokeEndElement (pctxt, "resizingPartPicFreezeAndRelease", -1); /* decode fullPictureSnapshot */ invokeStartElement (pctxt, "fullPictureSnapshot", -1); stat = DECODEBIT (pctxt, &pvalue->fullPictureSnapshot); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fullPictureSnapshot); invokeEndElement (pctxt, "fullPictureSnapshot", -1); /* decode partialPictureSnapshot */ invokeStartElement (pctxt, "partialPictureSnapshot", -1); stat = DECODEBIT (pctxt, &pvalue->partialPictureSnapshot); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->partialPictureSnapshot); invokeEndElement (pctxt, "partialPictureSnapshot", -1); /* decode videoSegmentTagging */ invokeStartElement (pctxt, "videoSegmentTagging", -1); stat = DECODEBIT (pctxt, &pvalue->videoSegmentTagging); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoSegmentTagging); invokeEndElement (pctxt, "videoSegmentTagging", -1); /* decode progressiveRefinement */ invokeStartElement (pctxt, "progressiveRefinement", -1); stat = DECODEBIT (pctxt, &pvalue->progressiveRefinement); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->progressiveRefinement); invokeEndElement (pctxt, "progressiveRefinement", -1); /* decode dynamicPictureResizingByFour */ invokeStartElement (pctxt, "dynamicPictureResizingByFour", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicPictureResizingByFour); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicPictureResizingByFour); invokeEndElement (pctxt, "dynamicPictureResizingByFour", -1); /* decode dynamicPictureResizingSixteenthPel */ invokeStartElement (pctxt, "dynamicPictureResizingSixteenthPel", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicPictureResizingSixteenthPel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicPictureResizingSixteenthPel); invokeEndElement (pctxt, "dynamicPictureResizingSixteenthPel", -1); /* decode dynamicWarpingHalfPel */ invokeStartElement (pctxt, "dynamicWarpingHalfPel", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicWarpingHalfPel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicWarpingHalfPel); invokeEndElement (pctxt, "dynamicWarpingHalfPel", -1); /* decode dynamicWarpingSixteenthPel */ invokeStartElement (pctxt, "dynamicWarpingSixteenthPel", -1); stat = DECODEBIT (pctxt, &pvalue->dynamicWarpingSixteenthPel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->dynamicWarpingSixteenthPel); invokeEndElement (pctxt, "dynamicWarpingSixteenthPel", -1); /* decode independentSegmentDecoding */ invokeStartElement (pctxt, "independentSegmentDecoding", -1); stat = DECODEBIT (pctxt, &pvalue->independentSegmentDecoding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->independentSegmentDecoding); invokeEndElement (pctxt, "independentSegmentDecoding", -1); /* decode slicesInOrder_NonRect */ invokeStartElement (pctxt, "slicesInOrder_NonRect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesInOrder_NonRect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesInOrder_NonRect); invokeEndElement (pctxt, "slicesInOrder_NonRect", -1); /* decode slicesInOrder_Rect */ invokeStartElement (pctxt, "slicesInOrder_Rect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesInOrder_Rect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesInOrder_Rect); invokeEndElement (pctxt, "slicesInOrder_Rect", -1); /* decode slicesNoOrder_NonRect */ invokeStartElement (pctxt, "slicesNoOrder_NonRect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesNoOrder_NonRect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesNoOrder_NonRect); invokeEndElement (pctxt, "slicesNoOrder_NonRect", -1); /* decode slicesNoOrder_Rect */ invokeStartElement (pctxt, "slicesNoOrder_Rect", -1); stat = DECODEBIT (pctxt, &pvalue->slicesNoOrder_Rect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->slicesNoOrder_Rect); invokeEndElement (pctxt, "slicesNoOrder_Rect", -1); /* decode alternateInterVLCMode */ invokeStartElement (pctxt, "alternateInterVLCMode", -1); stat = DECODEBIT (pctxt, &pvalue->alternateInterVLCMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alternateInterVLCMode); invokeEndElement (pctxt, "alternateInterVLCMode", -1); /* decode modifiedQuantizationMode */ invokeStartElement (pctxt, "modifiedQuantizationMode", -1); stat = DECODEBIT (pctxt, &pvalue->modifiedQuantizationMode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->modifiedQuantizationMode); invokeEndElement (pctxt, "modifiedQuantizationMode", -1); /* decode reducedResolutionUpdate */ invokeStartElement (pctxt, "reducedResolutionUpdate", -1); stat = DECODEBIT (pctxt, &pvalue->reducedResolutionUpdate); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->reducedResolutionUpdate); invokeEndElement (pctxt, "reducedResolutionUpdate", -1); /* decode transparencyParameters */ if (pvalue->m.transparencyParametersPresent) { invokeStartElement (pctxt, "transparencyParameters", -1); stat = asn1PD_H245TransparencyParameters (pctxt, &pvalue->transparencyParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transparencyParameters", -1); } /* decode separateVideoBackChannel */ invokeStartElement (pctxt, "separateVideoBackChannel", -1); stat = DECODEBIT (pctxt, &pvalue->separateVideoBackChannel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->separateVideoBackChannel); invokeEndElement (pctxt, "separateVideoBackChannel", -1); /* decode refPictureSelection */ if (pvalue->m.refPictureSelectionPresent) { invokeStartElement (pctxt, "refPictureSelection", -1); stat = asn1PD_H245RefPictureSelection (pctxt, &pvalue->refPictureSelection); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "refPictureSelection", -1); } /* decode customPictureClockFrequency */ if (pvalue->m.customPictureClockFrequencyPresent) { invokeStartElement (pctxt, "customPictureClockFrequency", -1); stat = asn1PD_H245H263Options_customPictureClockFrequency (pctxt, &pvalue->customPictureClockFrequency); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "customPictureClockFrequency", -1); } /* decode customPictureFormat */ if (pvalue->m.customPictureFormatPresent) { invokeStartElement (pctxt, "customPictureFormat", -1); stat = asn1PD_H245H263Options_customPictureFormat (pctxt, &pvalue->customPictureFormat); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "customPictureFormat", -1); } /* decode modeCombos */ if (pvalue->m.modeCombosPresent) { invokeStartElement (pctxt, "modeCombos", -1); stat = asn1PD_H245H263Options_modeCombos (pctxt, &pvalue->modeCombos); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "modeCombos", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.videoBadMBsCapPresent = 1; invokeStartElement (pctxt, "videoBadMBsCap", -1); stat = DECODEBIT (pctxt, &pvalue->videoBadMBsCap); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoBadMBsCap); invokeEndElement (pctxt, "videoBadMBsCap", -1); break; case 1: pvalue->m.h263Version3OptionsPresent = 1; invokeStartElement (pctxt, "h263Version3Options", -1); stat = asn1PD_H245H263Version3Options (pctxt, &pvalue->h263Version3Options); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263Version3Options", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* EnhancementOptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EnhancementOptions (OOCTXT* pctxt, H245EnhancementOptions* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.sqcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.qcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif4MPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif16MPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.slowSqcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.slowQcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.slowCifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.slowCif4MPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.slowCif16MPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h263OptionsPresent = optbit; /* decode sqcifMPI */ if (pvalue->m.sqcifMPIPresent) { invokeStartElement (pctxt, "sqcifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sqcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sqcifMPI); invokeEndElement (pctxt, "sqcifMPI", -1); } /* decode qcifMPI */ if (pvalue->m.qcifMPIPresent) { invokeStartElement (pctxt, "qcifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->qcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->qcifMPI); invokeEndElement (pctxt, "qcifMPI", -1); } /* decode cifMPI */ if (pvalue->m.cifMPIPresent) { invokeStartElement (pctxt, "cifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->cifMPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cifMPI); invokeEndElement (pctxt, "cifMPI", -1); } /* decode cif4MPI */ if (pvalue->m.cif4MPIPresent) { invokeStartElement (pctxt, "cif4MPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->cif4MPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif4MPI); invokeEndElement (pctxt, "cif4MPI", -1); } /* decode cif16MPI */ if (pvalue->m.cif16MPIPresent) { invokeStartElement (pctxt, "cif16MPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->cif16MPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif16MPI); invokeEndElement (pctxt, "cif16MPI", -1); } /* decode maxBitRate */ invokeStartElement (pctxt, "maxBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->maxBitRate, 1U, 192400U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxBitRate); invokeEndElement (pctxt, "maxBitRate", -1); /* decode unrestrictedVector */ invokeStartElement (pctxt, "unrestrictedVector", -1); stat = DECODEBIT (pctxt, &pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->unrestrictedVector); invokeEndElement (pctxt, "unrestrictedVector", -1); /* decode arithmeticCoding */ invokeStartElement (pctxt, "arithmeticCoding", -1); stat = DECODEBIT (pctxt, &pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->arithmeticCoding); invokeEndElement (pctxt, "arithmeticCoding", -1); /* decode temporalSpatialTradeOffCapability */ invokeStartElement (pctxt, "temporalSpatialTradeOffCapability", -1); stat = DECODEBIT (pctxt, &pvalue->temporalSpatialTradeOffCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->temporalSpatialTradeOffCapability); invokeEndElement (pctxt, "temporalSpatialTradeOffCapability", -1); /* decode slowSqcifMPI */ if (pvalue->m.slowSqcifMPIPresent) { invokeStartElement (pctxt, "slowSqcifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowSqcifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowSqcifMPI); invokeEndElement (pctxt, "slowSqcifMPI", -1); } /* decode slowQcifMPI */ if (pvalue->m.slowQcifMPIPresent) { invokeStartElement (pctxt, "slowQcifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowQcifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowQcifMPI); invokeEndElement (pctxt, "slowQcifMPI", -1); } /* decode slowCifMPI */ if (pvalue->m.slowCifMPIPresent) { invokeStartElement (pctxt, "slowCifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowCifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowCifMPI); invokeEndElement (pctxt, "slowCifMPI", -1); } /* decode slowCif4MPI */ if (pvalue->m.slowCif4MPIPresent) { invokeStartElement (pctxt, "slowCif4MPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowCif4MPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowCif4MPI); invokeEndElement (pctxt, "slowCif4MPI", -1); } /* decode slowCif16MPI */ if (pvalue->m.slowCif16MPIPresent) { invokeStartElement (pctxt, "slowCif16MPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowCif16MPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowCif16MPI); invokeEndElement (pctxt, "slowCif16MPI", -1); } /* decode errorCompensation */ invokeStartElement (pctxt, "errorCompensation", -1); stat = DECODEBIT (pctxt, &pvalue->errorCompensation); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->errorCompensation); invokeEndElement (pctxt, "errorCompensation", -1); /* decode h263Options */ if (pvalue->m.h263OptionsPresent) { invokeStartElement (pctxt, "h263Options", -1); stat = asn1PD_H245H263Options (pctxt, &pvalue->h263Options); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263Options", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo_snrEnhancement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EnhancementLayerInfo_snrEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_snrEnhancement* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; H245EnhancementOptions* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245EnhancementOptions); stat = asn1PD_H245EnhancementOptions (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo_spatialEnhancement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EnhancementLayerInfo_spatialEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_spatialEnhancement* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; H245EnhancementOptions* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245EnhancementOptions); stat = asn1PD_H245EnhancementOptions (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* BEnhancementParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245BEnhancementParameters (OOCTXT* pctxt, H245BEnhancementParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode enhancementOptions */ invokeStartElement (pctxt, "enhancementOptions", -1); stat = asn1PD_H245EnhancementOptions (pctxt, &pvalue->enhancementOptions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "enhancementOptions", -1); /* decode numberOfBPictures */ invokeStartElement (pctxt, "numberOfBPictures", -1); stat = decodeConsUInt8 (pctxt, &pvalue->numberOfBPictures, 1U, 64U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfBPictures); invokeEndElement (pctxt, "numberOfBPictures", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo_bPictureEnhancement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EnhancementLayerInfo_bPictureEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_bPictureEnhancement* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; H245BEnhancementParameters* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245BEnhancementParameters); stat = asn1PD_H245BEnhancementParameters (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EnhancementLayerInfo (OOCTXT* pctxt, H245EnhancementLayerInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.snrEnhancementPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.spatialEnhancementPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.bPictureEnhancementPresent = optbit; /* decode baseBitRateConstrained */ invokeStartElement (pctxt, "baseBitRateConstrained", -1); stat = DECODEBIT (pctxt, &pvalue->baseBitRateConstrained); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->baseBitRateConstrained); invokeEndElement (pctxt, "baseBitRateConstrained", -1); /* decode snrEnhancement */ if (pvalue->m.snrEnhancementPresent) { invokeStartElement (pctxt, "snrEnhancement", -1); stat = asn1PD_H245EnhancementLayerInfo_snrEnhancement (pctxt, &pvalue->snrEnhancement); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "snrEnhancement", -1); } /* decode spatialEnhancement */ if (pvalue->m.spatialEnhancementPresent) { invokeStartElement (pctxt, "spatialEnhancement", -1); stat = asn1PD_H245EnhancementLayerInfo_spatialEnhancement (pctxt, &pvalue->spatialEnhancement); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "spatialEnhancement", -1); } /* decode bPictureEnhancement */ if (pvalue->m.bPictureEnhancementPresent) { invokeStartElement (pctxt, "bPictureEnhancement", -1); stat = asn1PD_H245EnhancementLayerInfo_bPictureEnhancement (pctxt, &pvalue->bPictureEnhancement); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bPictureEnhancement", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H263VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263VideoCapability (OOCTXT* pctxt, H245H263VideoCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.sqcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.qcifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cifMPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif4MPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cif16MPIPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.hrd_BPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.bppMaxKbPresent = optbit; /* decode sqcifMPI */ if (pvalue->m.sqcifMPIPresent) { invokeStartElement (pctxt, "sqcifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sqcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sqcifMPI); invokeEndElement (pctxt, "sqcifMPI", -1); } /* decode qcifMPI */ if (pvalue->m.qcifMPIPresent) { invokeStartElement (pctxt, "qcifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->qcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->qcifMPI); invokeEndElement (pctxt, "qcifMPI", -1); } /* decode cifMPI */ if (pvalue->m.cifMPIPresent) { invokeStartElement (pctxt, "cifMPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->cifMPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cifMPI); invokeEndElement (pctxt, "cifMPI", -1); } /* decode cif4MPI */ if (pvalue->m.cif4MPIPresent) { invokeStartElement (pctxt, "cif4MPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->cif4MPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif4MPI); invokeEndElement (pctxt, "cif4MPI", -1); } /* decode cif16MPI */ if (pvalue->m.cif16MPIPresent) { invokeStartElement (pctxt, "cif16MPI", -1); stat = decodeConsUInt8 (pctxt, &pvalue->cif16MPI, 1U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->cif16MPI); invokeEndElement (pctxt, "cif16MPI", -1); } /* decode maxBitRate */ invokeStartElement (pctxt, "maxBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->maxBitRate, 1U, 192400U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxBitRate); invokeEndElement (pctxt, "maxBitRate", -1); /* decode unrestrictedVector */ invokeStartElement (pctxt, "unrestrictedVector", -1); stat = DECODEBIT (pctxt, &pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->unrestrictedVector); invokeEndElement (pctxt, "unrestrictedVector", -1); /* decode arithmeticCoding */ invokeStartElement (pctxt, "arithmeticCoding", -1); stat = DECODEBIT (pctxt, &pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->arithmeticCoding); invokeEndElement (pctxt, "arithmeticCoding", -1); /* decode advancedPrediction */ invokeStartElement (pctxt, "advancedPrediction", -1); stat = DECODEBIT (pctxt, &pvalue->advancedPrediction); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->advancedPrediction); invokeEndElement (pctxt, "advancedPrediction", -1); /* decode pbFrames */ invokeStartElement (pctxt, "pbFrames", -1); stat = DECODEBIT (pctxt, &pvalue->pbFrames); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->pbFrames); invokeEndElement (pctxt, "pbFrames", -1); /* decode temporalSpatialTradeOffCapability */ invokeStartElement (pctxt, "temporalSpatialTradeOffCapability", -1); stat = DECODEBIT (pctxt, &pvalue->temporalSpatialTradeOffCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->temporalSpatialTradeOffCapability); invokeEndElement (pctxt, "temporalSpatialTradeOffCapability", -1); /* decode hrd_B */ if (pvalue->m.hrd_BPresent) { invokeStartElement (pctxt, "hrd_B", -1); stat = decodeConsUnsigned (pctxt, &pvalue->hrd_B, 0U, 524287U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->hrd_B); invokeEndElement (pctxt, "hrd_B", -1); } /* decode bppMaxKb */ if (pvalue->m.bppMaxKbPresent) { invokeStartElement (pctxt, "bppMaxKb", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bppMaxKb, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bppMaxKb); invokeEndElement (pctxt, "bppMaxKb", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 8 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.slowSqcifMPIPresent = 1; invokeStartElement (pctxt, "slowSqcifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowSqcifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowSqcifMPI); invokeEndElement (pctxt, "slowSqcifMPI", -1); break; case 1: pvalue->m.slowQcifMPIPresent = 1; invokeStartElement (pctxt, "slowQcifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowQcifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowQcifMPI); invokeEndElement (pctxt, "slowQcifMPI", -1); break; case 2: pvalue->m.slowCifMPIPresent = 1; invokeStartElement (pctxt, "slowCifMPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowCifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowCifMPI); invokeEndElement (pctxt, "slowCifMPI", -1); break; case 3: pvalue->m.slowCif4MPIPresent = 1; invokeStartElement (pctxt, "slowCif4MPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowCif4MPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowCif4MPI); invokeEndElement (pctxt, "slowCif4MPI", -1); break; case 4: pvalue->m.slowCif16MPIPresent = 1; invokeStartElement (pctxt, "slowCif16MPI", -1); stat = decodeConsUInt16 (pctxt, &pvalue->slowCif16MPI, 1U, 3600U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->slowCif16MPI); invokeEndElement (pctxt, "slowCif16MPI", -1); break; case 5: pvalue->m.errorCompensationPresent = 1; invokeStartElement (pctxt, "errorCompensation", -1); stat = DECODEBIT (pctxt, &pvalue->errorCompensation); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->errorCompensation); invokeEndElement (pctxt, "errorCompensation", -1); break; case 6: pvalue->m.enhancementLayerInfoPresent = 1; invokeStartElement (pctxt, "enhancementLayerInfo", -1); stat = asn1PD_H245EnhancementLayerInfo (pctxt, &pvalue->enhancementLayerInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "enhancementLayerInfo", -1); break; case 7: pvalue->m.h263OptionsPresent = 1; invokeStartElement (pctxt, "h263Options", -1); stat = asn1PD_H245H263Options (pctxt, &pvalue->h263Options); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263Options", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* IS11172VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS11172VideoCapability (OOCTXT* pctxt, H245IS11172VideoCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.videoBitRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.vbvBufferSizePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.samplesPerLinePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.linesPerFramePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.pictureRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.luminanceSampleRatePresent = optbit; /* decode constrainedBitstream */ invokeStartElement (pctxt, "constrainedBitstream", -1); stat = DECODEBIT (pctxt, &pvalue->constrainedBitstream); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->constrainedBitstream); invokeEndElement (pctxt, "constrainedBitstream", -1); /* decode videoBitRate */ if (pvalue->m.videoBitRatePresent) { invokeStartElement (pctxt, "videoBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->videoBitRate); invokeEndElement (pctxt, "videoBitRate", -1); } /* decode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { invokeStartElement (pctxt, "vbvBufferSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->vbvBufferSize); invokeEndElement (pctxt, "vbvBufferSize", -1); } /* decode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { invokeStartElement (pctxt, "samplesPerLine", -1); stat = decodeConsUInt16 (pctxt, &pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->samplesPerLine); invokeEndElement (pctxt, "samplesPerLine", -1); } /* decode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { invokeStartElement (pctxt, "linesPerFrame", -1); stat = decodeConsUInt16 (pctxt, &pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->linesPerFrame); invokeEndElement (pctxt, "linesPerFrame", -1); } /* decode pictureRate */ if (pvalue->m.pictureRatePresent) { invokeStartElement (pctxt, "pictureRate", -1); stat = decodeConsUInt8 (pctxt, &pvalue->pictureRate, 0U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->pictureRate); invokeEndElement (pctxt, "pictureRate", -1); } /* decode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { invokeStartElement (pctxt, "luminanceSampleRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->luminanceSampleRate); invokeEndElement (pctxt, "luminanceSampleRate", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.videoBadMBsCapPresent = 1; invokeStartElement (pctxt, "videoBadMBsCap", -1); stat = DECODEBIT (pctxt, &pvalue->videoBadMBsCap); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoBadMBsCap); invokeEndElement (pctxt, "videoBadMBsCap", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VideoCapability (OOCTXT* pctxt, H245VideoCapability* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* h261VideoCapability */ case 1: invokeStartElement (pctxt, "h261VideoCapability", -1); pvalue->u.h261VideoCapability = ALLOC_ASN1ELEM (pctxt, H245H261VideoCapability); stat = asn1PD_H245H261VideoCapability (pctxt, pvalue->u.h261VideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h261VideoCapability", -1); break; /* h262VideoCapability */ case 2: invokeStartElement (pctxt, "h262VideoCapability", -1); pvalue->u.h262VideoCapability = ALLOC_ASN1ELEM (pctxt, H245H262VideoCapability); stat = asn1PD_H245H262VideoCapability (pctxt, pvalue->u.h262VideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h262VideoCapability", -1); break; /* h263VideoCapability */ case 3: invokeStartElement (pctxt, "h263VideoCapability", -1); pvalue->u.h263VideoCapability = ALLOC_ASN1ELEM (pctxt, H245H263VideoCapability); stat = asn1PD_H245H263VideoCapability (pctxt, pvalue->u.h263VideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263VideoCapability", -1); break; /* is11172VideoCapability */ case 4: invokeStartElement (pctxt, "is11172VideoCapability", -1); pvalue->u.is11172VideoCapability = ALLOC_ASN1ELEM (pctxt, H245IS11172VideoCapability); stat = asn1PD_H245IS11172VideoCapability (pctxt, pvalue->u.is11172VideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "is11172VideoCapability", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* genericVideoCapability */ case 6: invokeStartElement (pctxt, "genericVideoCapability", -1); pvalue->u.genericVideoCapability = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericVideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericVideoCapability", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* AudioCapability_g7231 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AudioCapability_g7231 (OOCTXT* pctxt, H245AudioCapability_g7231* pvalue) { int stat = ASN_OK; /* decode maxAl_sduAudioFrames */ invokeStartElement (pctxt, "maxAl_sduAudioFrames", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxAl_sduAudioFrames, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxAl_sduAudioFrames); invokeEndElement (pctxt, "maxAl_sduAudioFrames", -1); /* decode silenceSuppression */ invokeStartElement (pctxt, "silenceSuppression", -1); stat = DECODEBIT (pctxt, &pvalue->silenceSuppression); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->silenceSuppression); invokeEndElement (pctxt, "silenceSuppression", -1); return (stat); } /**************************************************************/ /* */ /* IS11172AudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS11172AudioCapability (OOCTXT* pctxt, H245IS11172AudioCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioLayer1 */ invokeStartElement (pctxt, "audioLayer1", -1); stat = DECODEBIT (pctxt, &pvalue->audioLayer1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioLayer1); invokeEndElement (pctxt, "audioLayer1", -1); /* decode audioLayer2 */ invokeStartElement (pctxt, "audioLayer2", -1); stat = DECODEBIT (pctxt, &pvalue->audioLayer2); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioLayer2); invokeEndElement (pctxt, "audioLayer2", -1); /* decode audioLayer3 */ invokeStartElement (pctxt, "audioLayer3", -1); stat = DECODEBIT (pctxt, &pvalue->audioLayer3); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioLayer3); invokeEndElement (pctxt, "audioLayer3", -1); /* decode audioSampling32k */ invokeStartElement (pctxt, "audioSampling32k", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling32k); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling32k); invokeEndElement (pctxt, "audioSampling32k", -1); /* decode audioSampling44k1 */ invokeStartElement (pctxt, "audioSampling44k1", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling44k1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling44k1); invokeEndElement (pctxt, "audioSampling44k1", -1); /* decode audioSampling48k */ invokeStartElement (pctxt, "audioSampling48k", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling48k); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling48k); invokeEndElement (pctxt, "audioSampling48k", -1); /* decode singleChannel */ invokeStartElement (pctxt, "singleChannel", -1); stat = DECODEBIT (pctxt, &pvalue->singleChannel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->singleChannel); invokeEndElement (pctxt, "singleChannel", -1); /* decode twoChannels */ invokeStartElement (pctxt, "twoChannels", -1); stat = DECODEBIT (pctxt, &pvalue->twoChannels); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->twoChannels); invokeEndElement (pctxt, "twoChannels", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 448U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* IS13818AudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS13818AudioCapability (OOCTXT* pctxt, H245IS13818AudioCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioLayer1 */ invokeStartElement (pctxt, "audioLayer1", -1); stat = DECODEBIT (pctxt, &pvalue->audioLayer1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioLayer1); invokeEndElement (pctxt, "audioLayer1", -1); /* decode audioLayer2 */ invokeStartElement (pctxt, "audioLayer2", -1); stat = DECODEBIT (pctxt, &pvalue->audioLayer2); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioLayer2); invokeEndElement (pctxt, "audioLayer2", -1); /* decode audioLayer3 */ invokeStartElement (pctxt, "audioLayer3", -1); stat = DECODEBIT (pctxt, &pvalue->audioLayer3); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioLayer3); invokeEndElement (pctxt, "audioLayer3", -1); /* decode audioSampling16k */ invokeStartElement (pctxt, "audioSampling16k", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling16k); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling16k); invokeEndElement (pctxt, "audioSampling16k", -1); /* decode audioSampling22k05 */ invokeStartElement (pctxt, "audioSampling22k05", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling22k05); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling22k05); invokeEndElement (pctxt, "audioSampling22k05", -1); /* decode audioSampling24k */ invokeStartElement (pctxt, "audioSampling24k", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling24k); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling24k); invokeEndElement (pctxt, "audioSampling24k", -1); /* decode audioSampling32k */ invokeStartElement (pctxt, "audioSampling32k", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling32k); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling32k); invokeEndElement (pctxt, "audioSampling32k", -1); /* decode audioSampling44k1 */ invokeStartElement (pctxt, "audioSampling44k1", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling44k1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling44k1); invokeEndElement (pctxt, "audioSampling44k1", -1); /* decode audioSampling48k */ invokeStartElement (pctxt, "audioSampling48k", -1); stat = DECODEBIT (pctxt, &pvalue->audioSampling48k); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioSampling48k); invokeEndElement (pctxt, "audioSampling48k", -1); /* decode singleChannel */ invokeStartElement (pctxt, "singleChannel", -1); stat = DECODEBIT (pctxt, &pvalue->singleChannel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->singleChannel); invokeEndElement (pctxt, "singleChannel", -1); /* decode twoChannels */ invokeStartElement (pctxt, "twoChannels", -1); stat = DECODEBIT (pctxt, &pvalue->twoChannels); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->twoChannels); invokeEndElement (pctxt, "twoChannels", -1); /* decode threeChannels2_1 */ invokeStartElement (pctxt, "threeChannels2_1", -1); stat = DECODEBIT (pctxt, &pvalue->threeChannels2_1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->threeChannels2_1); invokeEndElement (pctxt, "threeChannels2_1", -1); /* decode threeChannels3_0 */ invokeStartElement (pctxt, "threeChannels3_0", -1); stat = DECODEBIT (pctxt, &pvalue->threeChannels3_0); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->threeChannels3_0); invokeEndElement (pctxt, "threeChannels3_0", -1); /* decode fourChannels2_0_2_0 */ invokeStartElement (pctxt, "fourChannels2_0_2_0", -1); stat = DECODEBIT (pctxt, &pvalue->fourChannels2_0_2_0); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fourChannels2_0_2_0); invokeEndElement (pctxt, "fourChannels2_0_2_0", -1); /* decode fourChannels2_2 */ invokeStartElement (pctxt, "fourChannels2_2", -1); stat = DECODEBIT (pctxt, &pvalue->fourChannels2_2); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fourChannels2_2); invokeEndElement (pctxt, "fourChannels2_2", -1); /* decode fourChannels3_1 */ invokeStartElement (pctxt, "fourChannels3_1", -1); stat = DECODEBIT (pctxt, &pvalue->fourChannels3_1); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fourChannels3_1); invokeEndElement (pctxt, "fourChannels3_1", -1); /* decode fiveChannels3_0_2_0 */ invokeStartElement (pctxt, "fiveChannels3_0_2_0", -1); stat = DECODEBIT (pctxt, &pvalue->fiveChannels3_0_2_0); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fiveChannels3_0_2_0); invokeEndElement (pctxt, "fiveChannels3_0_2_0", -1); /* decode fiveChannels3_2 */ invokeStartElement (pctxt, "fiveChannels3_2", -1); stat = DECODEBIT (pctxt, &pvalue->fiveChannels3_2); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->fiveChannels3_2); invokeEndElement (pctxt, "fiveChannels3_2", -1); /* decode lowFrequencyEnhancement */ invokeStartElement (pctxt, "lowFrequencyEnhancement", -1); stat = DECODEBIT (pctxt, &pvalue->lowFrequencyEnhancement); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->lowFrequencyEnhancement); invokeEndElement (pctxt, "lowFrequencyEnhancement", -1); /* decode multilingual */ invokeStartElement (pctxt, "multilingual", -1); stat = DECODEBIT (pctxt, &pvalue->multilingual); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multilingual); invokeEndElement (pctxt, "multilingual", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 1130U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* G7231AnnexCCapability_g723AnnexCAudioMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245G7231AnnexCCapability_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCCapability_g723AnnexCAudioMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode highRateMode0 */ invokeStartElement (pctxt, "highRateMode0", -1); stat = decodeConsUInt8 (pctxt, &pvalue->highRateMode0, 27U, 78U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->highRateMode0); invokeEndElement (pctxt, "highRateMode0", -1); /* decode highRateMode1 */ invokeStartElement (pctxt, "highRateMode1", -1); stat = decodeConsUInt8 (pctxt, &pvalue->highRateMode1, 27U, 78U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->highRateMode1); invokeEndElement (pctxt, "highRateMode1", -1); /* decode lowRateMode0 */ invokeStartElement (pctxt, "lowRateMode0", -1); stat = decodeConsUInt8 (pctxt, &pvalue->lowRateMode0, 23U, 66U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->lowRateMode0); invokeEndElement (pctxt, "lowRateMode0", -1); /* decode lowRateMode1 */ invokeStartElement (pctxt, "lowRateMode1", -1); stat = decodeConsUInt8 (pctxt, &pvalue->lowRateMode1, 23U, 66U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->lowRateMode1); invokeEndElement (pctxt, "lowRateMode1", -1); /* decode sidMode0 */ invokeStartElement (pctxt, "sidMode0", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sidMode0, 6U, 17U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sidMode0); invokeEndElement (pctxt, "sidMode0", -1); /* decode sidMode1 */ invokeStartElement (pctxt, "sidMode1", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sidMode1, 6U, 17U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sidMode1); invokeEndElement (pctxt, "sidMode1", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* G7231AnnexCCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245G7231AnnexCCapability (OOCTXT* pctxt, H245G7231AnnexCCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.g723AnnexCAudioModePresent = optbit; /* decode maxAl_sduAudioFrames */ invokeStartElement (pctxt, "maxAl_sduAudioFrames", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxAl_sduAudioFrames, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxAl_sduAudioFrames); invokeEndElement (pctxt, "maxAl_sduAudioFrames", -1); /* decode silenceSuppression */ invokeStartElement (pctxt, "silenceSuppression", -1); stat = DECODEBIT (pctxt, &pvalue->silenceSuppression); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->silenceSuppression); invokeEndElement (pctxt, "silenceSuppression", -1); /* decode g723AnnexCAudioMode */ if (pvalue->m.g723AnnexCAudioModePresent) { invokeStartElement (pctxt, "g723AnnexCAudioMode", -1); stat = asn1PD_H245G7231AnnexCCapability_g723AnnexCAudioMode (pctxt, &pvalue->g723AnnexCAudioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g723AnnexCAudioMode", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* GSMAudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245GSMAudioCapability (OOCTXT* pctxt, H245GSMAudioCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioUnitSize */ invokeStartElement (pctxt, "audioUnitSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->audioUnitSize, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->audioUnitSize); invokeEndElement (pctxt, "audioUnitSize", -1); /* decode comfortNoise */ invokeStartElement (pctxt, "comfortNoise", -1); stat = DECODEBIT (pctxt, &pvalue->comfortNoise); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->comfortNoise); invokeEndElement (pctxt, "comfortNoise", -1); /* decode scrambled */ invokeStartElement (pctxt, "scrambled", -1); stat = DECODEBIT (pctxt, &pvalue->scrambled); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->scrambled); invokeEndElement (pctxt, "scrambled", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* G729Extensions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245G729Extensions (OOCTXT* pctxt, H245G729Extensions* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.audioUnitPresent = optbit; /* decode audioUnit */ if (pvalue->m.audioUnitPresent) { invokeStartElement (pctxt, "audioUnit", -1); stat = decodeConsUInt16 (pctxt, &pvalue->audioUnit, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->audioUnit); invokeEndElement (pctxt, "audioUnit", -1); } /* decode annexA */ invokeStartElement (pctxt, "annexA", -1); stat = DECODEBIT (pctxt, &pvalue->annexA); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->annexA); invokeEndElement (pctxt, "annexA", -1); /* decode annexB */ invokeStartElement (pctxt, "annexB", -1); stat = DECODEBIT (pctxt, &pvalue->annexB); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->annexB); invokeEndElement (pctxt, "annexB", -1); /* decode annexD */ invokeStartElement (pctxt, "annexD", -1); stat = DECODEBIT (pctxt, &pvalue->annexD); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->annexD); invokeEndElement (pctxt, "annexD", -1); /* decode annexE */ invokeStartElement (pctxt, "annexE", -1); stat = DECODEBIT (pctxt, &pvalue->annexE); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->annexE); invokeEndElement (pctxt, "annexE", -1); /* decode annexF */ invokeStartElement (pctxt, "annexF", -1); stat = DECODEBIT (pctxt, &pvalue->annexF); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->annexF); invokeEndElement (pctxt, "annexF", -1); /* decode annexG */ invokeStartElement (pctxt, "annexG", -1); stat = DECODEBIT (pctxt, &pvalue->annexG); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->annexG); invokeEndElement (pctxt, "annexG", -1); /* decode annexH */ invokeStartElement (pctxt, "annexH", -1); stat = DECODEBIT (pctxt, &pvalue->annexH); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->annexH); invokeEndElement (pctxt, "annexH", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VBDCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VBDCapability (OOCTXT* pctxt, H245VBDCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); pvalue->type = ALLOC_ASN1ELEM (pctxt, H245AudioCapability); stat = asn1PD_H245AudioCapability (pctxt, (H245AudioCapability*)pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NoPTAudioTelephonyEventCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NoPTAudioTelephonyEventCapability (OOCTXT* pctxt, H245NoPTAudioTelephonyEventCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioTelephoneEvent */ invokeStartElement (pctxt, "audioTelephoneEvent", -1); stat = decodeVarWidthCharString (pctxt, &pvalue->audioTelephoneEvent); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->audioTelephoneEvent); invokeEndElement (pctxt, "audioTelephoneEvent", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NoPTAudioToneCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NoPTAudioToneCapability (OOCTXT* pctxt, H245NoPTAudioToneCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* AudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AudioCapability (OOCTXT* pctxt, H245AudioCapability* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 13); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* g711Alaw64k */ case 1: invokeStartElement (pctxt, "g711Alaw64k", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g711Alaw64k, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g711Alaw64k); invokeEndElement (pctxt, "g711Alaw64k", -1); break; /* g711Alaw56k */ case 2: invokeStartElement (pctxt, "g711Alaw56k", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g711Alaw56k, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g711Alaw56k); invokeEndElement (pctxt, "g711Alaw56k", -1); break; /* g711Ulaw64k */ case 3: invokeStartElement (pctxt, "g711Ulaw64k", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g711Ulaw64k, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g711Ulaw64k); invokeEndElement (pctxt, "g711Ulaw64k", -1); break; /* g711Ulaw56k */ case 4: invokeStartElement (pctxt, "g711Ulaw56k", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g711Ulaw56k, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g711Ulaw56k); invokeEndElement (pctxt, "g711Ulaw56k", -1); break; /* g722_64k */ case 5: invokeStartElement (pctxt, "g722_64k", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g722_64k, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g722_64k); invokeEndElement (pctxt, "g722_64k", -1); break; /* g722_56k */ case 6: invokeStartElement (pctxt, "g722_56k", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g722_56k, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g722_56k); invokeEndElement (pctxt, "g722_56k", -1); break; /* g722_48k */ case 7: invokeStartElement (pctxt, "g722_48k", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g722_48k, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g722_48k); invokeEndElement (pctxt, "g722_48k", -1); break; /* g7231 */ case 8: invokeStartElement (pctxt, "g7231", -1); pvalue->u.g7231 = ALLOC_ASN1ELEM (pctxt, H245AudioCapability_g7231); stat = asn1PD_H245AudioCapability_g7231 (pctxt, pvalue->u.g7231); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g7231", -1); break; /* g728 */ case 9: invokeStartElement (pctxt, "g728", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g728, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g728); invokeEndElement (pctxt, "g728", -1); break; /* g729 */ case 10: invokeStartElement (pctxt, "g729", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g729, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g729); invokeEndElement (pctxt, "g729", -1); break; /* g729AnnexA */ case 11: invokeStartElement (pctxt, "g729AnnexA", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g729AnnexA, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g729AnnexA); invokeEndElement (pctxt, "g729AnnexA", -1); break; /* is11172AudioCapability */ case 12: invokeStartElement (pctxt, "is11172AudioCapability", -1); pvalue->u.is11172AudioCapability = ALLOC_ASN1ELEM (pctxt, H245IS11172AudioCapability); stat = asn1PD_H245IS11172AudioCapability (pctxt, pvalue->u.is11172AudioCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "is11172AudioCapability", -1); break; /* is13818AudioCapability */ case 13: invokeStartElement (pctxt, "is13818AudioCapability", -1); pvalue->u.is13818AudioCapability = ALLOC_ASN1ELEM (pctxt, H245IS13818AudioCapability); stat = asn1PD_H245IS13818AudioCapability (pctxt, pvalue->u.is13818AudioCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "is13818AudioCapability", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 15; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* g729wAnnexB */ case 15: invokeStartElement (pctxt, "g729wAnnexB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g729wAnnexB, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g729wAnnexB); invokeEndElement (pctxt, "g729wAnnexB", -1); break; /* g729AnnexAwAnnexB */ case 16: invokeStartElement (pctxt, "g729AnnexAwAnnexB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g729AnnexAwAnnexB, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g729AnnexAwAnnexB); invokeEndElement (pctxt, "g729AnnexAwAnnexB", -1); break; /* g7231AnnexCCapability */ case 17: invokeStartElement (pctxt, "g7231AnnexCCapability", -1); pvalue->u.g7231AnnexCCapability = ALLOC_ASN1ELEM (pctxt, H245G7231AnnexCCapability); stat = asn1PD_H245G7231AnnexCCapability (pctxt, pvalue->u.g7231AnnexCCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g7231AnnexCCapability", -1); break; /* gsmFullRate */ case 18: invokeStartElement (pctxt, "gsmFullRate", -1); pvalue->u.gsmFullRate = ALLOC_ASN1ELEM (pctxt, H245GSMAudioCapability); stat = asn1PD_H245GSMAudioCapability (pctxt, pvalue->u.gsmFullRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gsmFullRate", -1); break; /* gsmHalfRate */ case 19: invokeStartElement (pctxt, "gsmHalfRate", -1); pvalue->u.gsmHalfRate = ALLOC_ASN1ELEM (pctxt, H245GSMAudioCapability); stat = asn1PD_H245GSMAudioCapability (pctxt, pvalue->u.gsmHalfRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gsmHalfRate", -1); break; /* gsmEnhancedFullRate */ case 20: invokeStartElement (pctxt, "gsmEnhancedFullRate", -1); pvalue->u.gsmEnhancedFullRate = ALLOC_ASN1ELEM (pctxt, H245GSMAudioCapability); stat = asn1PD_H245GSMAudioCapability (pctxt, pvalue->u.gsmEnhancedFullRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gsmEnhancedFullRate", -1); break; /* genericAudioCapability */ case 21: invokeStartElement (pctxt, "genericAudioCapability", -1); pvalue->u.genericAudioCapability = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericAudioCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericAudioCapability", -1); break; /* g729Extensions */ case 22: invokeStartElement (pctxt, "g729Extensions", -1); pvalue->u.g729Extensions = ALLOC_ASN1ELEM (pctxt, H245G729Extensions); stat = asn1PD_H245G729Extensions (pctxt, pvalue->u.g729Extensions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g729Extensions", -1); break; /* vbd */ case 23: invokeStartElement (pctxt, "vbd", -1); pvalue->u.vbd = ALLOC_ASN1ELEM (pctxt, H245VBDCapability); stat = asn1PD_H245VBDCapability (pctxt, pvalue->u.vbd); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "vbd", -1); break; /* audioTelephonyEvent */ case 24: invokeStartElement (pctxt, "audioTelephonyEvent", -1); pvalue->u.audioTelephonyEvent = ALLOC_ASN1ELEM (pctxt, H245NoPTAudioTelephonyEventCapability); stat = asn1PD_H245NoPTAudioTelephonyEventCapability (pctxt, pvalue->u.audioTelephonyEvent); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioTelephonyEvent", -1); break; /* audioTone */ case 25: invokeStartElement (pctxt, "audioTone", -1); pvalue->u.audioTone = ALLOC_ASN1ELEM (pctxt, H245NoPTAudioToneCapability); stat = asn1PD_H245NoPTAudioToneCapability (pctxt, pvalue->u.audioTone); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioTone", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* Capability_h233EncryptionReceiveCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Capability_h233EncryptionReceiveCapability (OOCTXT* pctxt, H245Capability_h233EncryptionReceiveCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode h233IVResponseTime */ invokeStartElement (pctxt, "h233IVResponseTime", -1); stat = decodeConsUInt8 (pctxt, &pvalue->h233IVResponseTime, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->h233IVResponseTime); invokeEndElement (pctxt, "h233IVResponseTime", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245NonStandardParameter (OOCTXT* pctxt, H245_SeqOfH245NonStandardParameter* pvalue) { int stat = ASN_OK; H245NonStandardParameter* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* ConferenceCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceCapability (OOCTXT* pctxt, H245ConferenceCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode chairControlCapability */ invokeStartElement (pctxt, "chairControlCapability", -1); stat = DECODEBIT (pctxt, &pvalue->chairControlCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->chairControlCapability); invokeEndElement (pctxt, "chairControlCapability", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.videoIndicateMixingCapabilityPresent = 1; invokeStartElement (pctxt, "videoIndicateMixingCapability", -1); stat = DECODEBIT (pctxt, &pvalue->videoIndicateMixingCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->videoIndicateMixingCapability); invokeEndElement (pctxt, "videoIndicateMixingCapability", -1); break; case 1: pvalue->m.multipointVisualizationCapabilityPresent = 1; invokeStartElement (pctxt, "multipointVisualizationCapability", -1); stat = DECODEBIT (pctxt, &pvalue->multipointVisualizationCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipointVisualizationCapability); invokeEndElement (pctxt, "multipointVisualizationCapability", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* MediaEncryptionAlgorithm */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MediaEncryptionAlgorithm (OOCTXT* pctxt, H245MediaEncryptionAlgorithm* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* algorithm */ case 1: invokeStartElement (pctxt, "algorithm", -1); pvalue->u.algorithm = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.algorithm); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.algorithm->numids, pvalue->u.algorithm->subid); invokeEndElement (pctxt, "algorithm", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EncryptionCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionCapability (OOCTXT* pctxt, H245EncryptionCapability* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245MediaEncryptionAlgorithm* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MediaEncryptionAlgorithm); stat = asn1PD_H245MediaEncryptionAlgorithm (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* AuthenticationCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AuthenticationCapability (OOCTXT* pctxt, H245AuthenticationCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.antiSpamAlgorithmPresent = 1; invokeStartElement (pctxt, "antiSpamAlgorithm", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->antiSpamAlgorithm); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->antiSpamAlgorithm.numids, pvalue->antiSpamAlgorithm.subid); invokeEndElement (pctxt, "antiSpamAlgorithm", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* IntegrityCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IntegrityCapability (OOCTXT* pctxt, H245IntegrityCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* EncryptionAuthenticationAndIntegrity */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionAuthenticationAndIntegrity (OOCTXT* pctxt, H245EncryptionAuthenticationAndIntegrity* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.encryptionCapabilityPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.authenticationCapabilityPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCapabilityPresent = optbit; /* decode encryptionCapability */ if (pvalue->m.encryptionCapabilityPresent) { invokeStartElement (pctxt, "encryptionCapability", -1); stat = asn1PD_H245EncryptionCapability (pctxt, &pvalue->encryptionCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionCapability", -1); } /* decode authenticationCapability */ if (pvalue->m.authenticationCapabilityPresent) { invokeStartElement (pctxt, "authenticationCapability", -1); stat = asn1PD_H245AuthenticationCapability (pctxt, &pvalue->authenticationCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "authenticationCapability", -1); } /* decode integrityCapability */ if (pvalue->m.integrityCapabilityPresent) { invokeStartElement (pctxt, "integrityCapability", -1); stat = asn1PD_H245IntegrityCapability (pctxt, &pvalue->integrityCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCapability", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H235SecurityCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H235SecurityCapability (OOCTXT* pctxt, H245H235SecurityCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode encryptionAuthenticationAndIntegrity */ invokeStartElement (pctxt, "encryptionAuthenticationAndIntegrity", -1); stat = asn1PD_H245EncryptionAuthenticationAndIntegrity (pctxt, &pvalue->encryptionAuthenticationAndIntegrity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionAuthenticationAndIntegrity", -1); /* decode mediaCapability */ invokeStartElement (pctxt, "mediaCapability", -1); stat = asn1PD_H245CapabilityTableEntryNumber (pctxt, &pvalue->mediaCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaCapability", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UserInputCapability_nonStandard */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputCapability_nonStandard (OOCTXT* pctxt, H245UserInputCapability_nonStandard* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H245NonStandardParameter* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* UserInputCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputCapability (OOCTXT* pctxt, H245UserInputCapability* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245UserInputCapability_nonStandard); stat = asn1PD_H245UserInputCapability_nonStandard (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* basicString */ case 1: invokeStartElement (pctxt, "basicString", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "basicString", -1); break; /* iA5String */ case 2: invokeStartElement (pctxt, "iA5String", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "iA5String", -1); break; /* generalString */ case 3: invokeStartElement (pctxt, "generalString", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "generalString", -1); break; /* dtmf */ case 4: invokeStartElement (pctxt, "dtmf", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dtmf", -1); break; /* hookflash */ case 5: invokeStartElement (pctxt, "hookflash", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hookflash", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* extendedAlphanumeric */ case 7: invokeStartElement (pctxt, "extendedAlphanumeric", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "extendedAlphanumeric", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MultiplexFormat */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexFormat (OOCTXT* pctxt, H245MultiplexFormat* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* h222Capability */ case 1: invokeStartElement (pctxt, "h222Capability", -1); pvalue->u.h222Capability = ALLOC_ASN1ELEM (pctxt, H245H222Capability); stat = asn1PD_H245H222Capability (pctxt, pvalue->u.h222Capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h222Capability", -1); break; /* h223Capability */ case 2: invokeStartElement (pctxt, "h223Capability", -1); pvalue->u.h223Capability = ALLOC_ASN1ELEM (pctxt, H245H223Capability); stat = asn1PD_H245H223Capability (pctxt, pvalue->u.h223Capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223Capability", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* AlternativeCapabilitySet */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AlternativeCapabilitySet (OOCTXT* pctxt, H245AlternativeCapabilitySet* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245CapabilityTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamCapability_capabilityOnMuxStream */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexedStreamCapability_capabilityOnMuxStream (OOCTXT* pctxt, H245MultiplexedStreamCapability_capabilityOnMuxStream* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245AlternativeCapabilitySet* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245AlternativeCapabilitySet); stat = asn1PD_H245AlternativeCapabilitySet (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexedStreamCapability (OOCTXT* pctxt, H245MultiplexedStreamCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.capabilityOnMuxStreamPresent = optbit; /* decode multiplexFormat */ invokeStartElement (pctxt, "multiplexFormat", -1); stat = asn1PD_H245MultiplexFormat (pctxt, &pvalue->multiplexFormat); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexFormat", -1); /* decode controlOnMuxStream */ invokeStartElement (pctxt, "controlOnMuxStream", -1); stat = DECODEBIT (pctxt, &pvalue->controlOnMuxStream); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->controlOnMuxStream); invokeEndElement (pctxt, "controlOnMuxStream", -1); /* decode capabilityOnMuxStream */ if (pvalue->m.capabilityOnMuxStreamPresent) { invokeStartElement (pctxt, "capabilityOnMuxStream", -1); stat = asn1PD_H245MultiplexedStreamCapability_capabilityOnMuxStream (pctxt, &pvalue->capabilityOnMuxStream); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityOnMuxStream", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* AudioTelephonyEventCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AudioTelephonyEventCapability (OOCTXT* pctxt, H245AudioTelephonyEventCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode dynamicRTPPayloadType */ invokeStartElement (pctxt, "dynamicRTPPayloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->dynamicRTPPayloadType); invokeEndElement (pctxt, "dynamicRTPPayloadType", -1); /* decode audioTelephoneEvent */ invokeStartElement (pctxt, "audioTelephoneEvent", -1); stat = decodeVarWidthCharString (pctxt, &pvalue->audioTelephoneEvent); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->audioTelephoneEvent); invokeEndElement (pctxt, "audioTelephoneEvent", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* AudioToneCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AudioToneCapability (OOCTXT* pctxt, H245AudioToneCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode dynamicRTPPayloadType */ invokeStartElement (pctxt, "dynamicRTPPayloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->dynamicRTPPayloadType); invokeEndElement (pctxt, "dynamicRTPPayloadType", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECCapability_rfc2733_separateStream */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECCapability_rfc2733_separateStream (OOCTXT* pctxt, H245FECCapability_rfc2733_separateStream* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode separatePort */ invokeStartElement (pctxt, "separatePort", -1); stat = DECODEBIT (pctxt, &pvalue->separatePort); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->separatePort); invokeEndElement (pctxt, "separatePort", -1); /* decode samePort */ invokeStartElement (pctxt, "samePort", -1); stat = DECODEBIT (pctxt, &pvalue->samePort); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->samePort); invokeEndElement (pctxt, "samePort", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECCapability_rfc2733 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECCapability_rfc2733 (OOCTXT* pctxt, H245FECCapability_rfc2733* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode redundancyEncoding */ invokeStartElement (pctxt, "redundancyEncoding", -1); stat = DECODEBIT (pctxt, &pvalue->redundancyEncoding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->redundancyEncoding); invokeEndElement (pctxt, "redundancyEncoding", -1); /* decode separateStream */ invokeStartElement (pctxt, "separateStream", -1); stat = asn1PD_H245FECCapability_rfc2733_separateStream (pctxt, &pvalue->separateStream); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "separateStream", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECCapability (OOCTXT* pctxt, H245FECCapability* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* rfc2733 */ case 0: invokeStartElement (pctxt, "rfc2733", -1); pvalue->u.rfc2733 = ALLOC_ASN1ELEM (pctxt, H245FECCapability_rfc2733); stat = asn1PD_H245FECCapability_rfc2733 (pctxt, pvalue->u.rfc2733); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rfc2733", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamCapability_capabilities */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplePayloadStreamCapability_capabilities (OOCTXT* pctxt, H245MultiplePayloadStreamCapability_capabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245AlternativeCapabilitySet* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245AlternativeCapabilitySet); stat = asn1PD_H245AlternativeCapabilitySet (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplePayloadStreamCapability (OOCTXT* pctxt, H245MultiplePayloadStreamCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode capabilities */ invokeStartElement (pctxt, "capabilities", -1); stat = asn1PD_H245MultiplePayloadStreamCapability_capabilities (pctxt, &pvalue->capabilities); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilities", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* Capability */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Capability (OOCTXT* pctxt, H245Capability* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 11); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* receiveVideoCapability */ case 1: invokeStartElement (pctxt, "receiveVideoCapability", -1); pvalue->u.receiveVideoCapability = ALLOC_ASN1ELEM (pctxt, H245VideoCapability); stat = asn1PD_H245VideoCapability (pctxt, pvalue->u.receiveVideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveVideoCapability", -1); break; /* transmitVideoCapability */ case 2: invokeStartElement (pctxt, "transmitVideoCapability", -1); pvalue->u.transmitVideoCapability = ALLOC_ASN1ELEM (pctxt, H245VideoCapability); stat = asn1PD_H245VideoCapability (pctxt, pvalue->u.transmitVideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitVideoCapability", -1); break; /* receiveAndTransmitVideoCapability */ case 3: invokeStartElement (pctxt, "receiveAndTransmitVideoCapability", -1); pvalue->u.receiveAndTransmitVideoCapability = ALLOC_ASN1ELEM (pctxt, H245VideoCapability); stat = asn1PD_H245VideoCapability (pctxt, pvalue->u.receiveAndTransmitVideoCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveAndTransmitVideoCapability", -1); break; /* receiveAudioCapability */ case 4: invokeStartElement (pctxt, "receiveAudioCapability", -1); pvalue->u.receiveAudioCapability = ALLOC_ASN1ELEM (pctxt, H245AudioCapability); stat = asn1PD_H245AudioCapability (pctxt, pvalue->u.receiveAudioCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveAudioCapability", -1); break; /* transmitAudioCapability */ case 5: invokeStartElement (pctxt, "transmitAudioCapability", -1); pvalue->u.transmitAudioCapability = ALLOC_ASN1ELEM (pctxt, H245AudioCapability); stat = asn1PD_H245AudioCapability (pctxt, pvalue->u.transmitAudioCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitAudioCapability", -1); break; /* receiveAndTransmitAudioCapability */ case 6: invokeStartElement (pctxt, "receiveAndTransmitAudioCapability", -1); pvalue->u.receiveAndTransmitAudioCapability = ALLOC_ASN1ELEM (pctxt, H245AudioCapability); stat = asn1PD_H245AudioCapability (pctxt, pvalue->u.receiveAndTransmitAudioCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveAndTransmitAudioCapability", -1); break; /* receiveDataApplicationCapability */ case 7: invokeStartElement (pctxt, "receiveDataApplicationCapability", -1); pvalue->u.receiveDataApplicationCapability = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability); stat = asn1PD_H245DataApplicationCapability (pctxt, pvalue->u.receiveDataApplicationCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveDataApplicationCapability", -1); break; /* transmitDataApplicationCapability */ case 8: invokeStartElement (pctxt, "transmitDataApplicationCapability", -1); pvalue->u.transmitDataApplicationCapability = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability); stat = asn1PD_H245DataApplicationCapability (pctxt, pvalue->u.transmitDataApplicationCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitDataApplicationCapability", -1); break; /* receiveAndTransmitDataApplicationCapability */ case 9: invokeStartElement (pctxt, "receiveAndTransmitDataApplicationCapability", -1); pvalue->u.receiveAndTransmitDataApplicationCapability = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability); stat = asn1PD_H245DataApplicationCapability (pctxt, pvalue->u.receiveAndTransmitDataApplicationCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveAndTransmitDataApplicationCapability", -1); break; /* h233EncryptionTransmitCapability */ case 10: invokeStartElement (pctxt, "h233EncryptionTransmitCapability", -1); stat = DECODEBIT (pctxt, &pvalue->u.h233EncryptionTransmitCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->u.h233EncryptionTransmitCapability); invokeEndElement (pctxt, "h233EncryptionTransmitCapability", -1); break; /* h233EncryptionReceiveCapability */ case 11: invokeStartElement (pctxt, "h233EncryptionReceiveCapability", -1); pvalue->u.h233EncryptionReceiveCapability = ALLOC_ASN1ELEM (pctxt, H245Capability_h233EncryptionReceiveCapability); stat = asn1PD_H245Capability_h233EncryptionReceiveCapability (pctxt, pvalue->u.h233EncryptionReceiveCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h233EncryptionReceiveCapability", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 13; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* conferenceCapability */ case 13: invokeStartElement (pctxt, "conferenceCapability", -1); pvalue->u.conferenceCapability = ALLOC_ASN1ELEM (pctxt, H245ConferenceCapability); stat = asn1PD_H245ConferenceCapability (pctxt, pvalue->u.conferenceCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceCapability", -1); break; /* h235SecurityCapability */ case 14: invokeStartElement (pctxt, "h235SecurityCapability", -1); pvalue->u.h235SecurityCapability = ALLOC_ASN1ELEM (pctxt, H245H235SecurityCapability); stat = asn1PD_H245H235SecurityCapability (pctxt, pvalue->u.h235SecurityCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h235SecurityCapability", -1); break; /* maxPendingReplacementFor */ case 15: invokeStartElement (pctxt, "maxPendingReplacementFor", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.maxPendingReplacementFor, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.maxPendingReplacementFor); invokeEndElement (pctxt, "maxPendingReplacementFor", -1); break; /* receiveUserInputCapability */ case 16: invokeStartElement (pctxt, "receiveUserInputCapability", -1); pvalue->u.receiveUserInputCapability = ALLOC_ASN1ELEM (pctxt, H245UserInputCapability); stat = asn1PD_H245UserInputCapability (pctxt, pvalue->u.receiveUserInputCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveUserInputCapability", -1); break; /* transmitUserInputCapability */ case 17: invokeStartElement (pctxt, "transmitUserInputCapability", -1); pvalue->u.transmitUserInputCapability = ALLOC_ASN1ELEM (pctxt, H245UserInputCapability); stat = asn1PD_H245UserInputCapability (pctxt, pvalue->u.transmitUserInputCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitUserInputCapability", -1); break; /* receiveAndTransmitUserInputCapability */ case 18: invokeStartElement (pctxt, "receiveAndTransmitUserInputCapability", -1); pvalue->u.receiveAndTransmitUserInputCapability = ALLOC_ASN1ELEM (pctxt, H245UserInputCapability); stat = asn1PD_H245UserInputCapability (pctxt, pvalue->u.receiveAndTransmitUserInputCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveAndTransmitUserInputCapability", -1); break; /* genericControlCapability */ case 19: invokeStartElement (pctxt, "genericControlCapability", -1); pvalue->u.genericControlCapability = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericControlCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericControlCapability", -1); break; /* receiveMultiplexedStreamCapability */ case 20: invokeStartElement (pctxt, "receiveMultiplexedStreamCapability", -1); pvalue->u.receiveMultiplexedStreamCapability = ALLOC_ASN1ELEM (pctxt, H245MultiplexedStreamCapability); stat = asn1PD_H245MultiplexedStreamCapability (pctxt, pvalue->u.receiveMultiplexedStreamCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveMultiplexedStreamCapability", -1); break; /* transmitMultiplexedStreamCapability */ case 21: invokeStartElement (pctxt, "transmitMultiplexedStreamCapability", -1); pvalue->u.transmitMultiplexedStreamCapability = ALLOC_ASN1ELEM (pctxt, H245MultiplexedStreamCapability); stat = asn1PD_H245MultiplexedStreamCapability (pctxt, pvalue->u.transmitMultiplexedStreamCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transmitMultiplexedStreamCapability", -1); break; /* receiveAndTransmitMultiplexedStreamCapability */ case 22: invokeStartElement (pctxt, "receiveAndTransmitMultiplexedStreamCapability", -1); pvalue->u.receiveAndTransmitMultiplexedStreamCapability = ALLOC_ASN1ELEM (pctxt, H245MultiplexedStreamCapability); stat = asn1PD_H245MultiplexedStreamCapability (pctxt, pvalue->u.receiveAndTransmitMultiplexedStreamCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveAndTransmitMultiplexedStreamCapability", -1); break; /* receiveRTPAudioTelephonyEventCapability */ case 23: invokeStartElement (pctxt, "receiveRTPAudioTelephonyEventCapability", -1); pvalue->u.receiveRTPAudioTelephonyEventCapability = ALLOC_ASN1ELEM (pctxt, H245AudioTelephonyEventCapability); stat = asn1PD_H245AudioTelephonyEventCapability (pctxt, pvalue->u.receiveRTPAudioTelephonyEventCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveRTPAudioTelephonyEventCapability", -1); break; /* receiveRTPAudioToneCapability */ case 24: invokeStartElement (pctxt, "receiveRTPAudioToneCapability", -1); pvalue->u.receiveRTPAudioToneCapability = ALLOC_ASN1ELEM (pctxt, H245AudioToneCapability); stat = asn1PD_H245AudioToneCapability (pctxt, pvalue->u.receiveRTPAudioToneCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "receiveRTPAudioToneCapability", -1); break; /* fecCapability */ case 25: invokeStartElement (pctxt, "fecCapability", -1); pvalue->u.fecCapability = ALLOC_ASN1ELEM (pctxt, H245FECCapability); stat = asn1PD_H245FECCapability (pctxt, pvalue->u.fecCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fecCapability", -1); break; /* multiplePayloadStreamCapability */ case 26: invokeStartElement (pctxt, "multiplePayloadStreamCapability", -1); pvalue->u.multiplePayloadStreamCapability = ALLOC_ASN1ELEM (pctxt, H245MultiplePayloadStreamCapability); stat = asn1PD_H245MultiplePayloadStreamCapability (pctxt, pvalue->u.multiplePayloadStreamCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplePayloadStreamCapability", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* CapabilityTableEntry */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CapabilityTableEntry (OOCTXT* pctxt, H245CapabilityTableEntry* pvalue) { int stat = ASN_OK; ASN1BOOL optbit = 0; /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.capabilityPresent = optbit; /* decode capabilityTableEntryNumber */ invokeStartElement (pctxt, "capabilityTableEntryNumber", -1); stat = asn1PD_H245CapabilityTableEntryNumber (pctxt, &pvalue->capabilityTableEntryNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityTableEntryNumber", -1); /* decode capability */ if (pvalue->m.capabilityPresent) { invokeStartElement (pctxt, "capability", -1); stat = asn1PD_H245Capability (pctxt, &pvalue->capability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capability", -1); } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySet_capabilityTable */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySet_capabilityTable (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityTable* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245CapabilityTableEntry* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CapabilityTableEntry); stat = asn1PD_H245CapabilityTableEntry (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* CapabilityDescriptorNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CapabilityDescriptorNumber (OOCTXT* pctxt, H245CapabilityDescriptorNumber* pvalue) { int stat = ASN_OK; stat = decodeConsUInt8 (pctxt, pvalue, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* CapabilityDescriptor_simultaneousCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CapabilityDescriptor_simultaneousCapabilities (OOCTXT* pctxt, H245CapabilityDescriptor_simultaneousCapabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245AlternativeCapabilitySet* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245AlternativeCapabilitySet); stat = asn1PD_H245AlternativeCapabilitySet (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* CapabilityDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CapabilityDescriptor (OOCTXT* pctxt, H245CapabilityDescriptor* pvalue) { int stat = ASN_OK; ASN1BOOL optbit = 0; /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.simultaneousCapabilitiesPresent = optbit; /* decode capabilityDescriptorNumber */ invokeStartElement (pctxt, "capabilityDescriptorNumber", -1); stat = asn1PD_H245CapabilityDescriptorNumber (pctxt, &pvalue->capabilityDescriptorNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityDescriptorNumber", -1); /* decode simultaneousCapabilities */ if (pvalue->m.simultaneousCapabilitiesPresent) { invokeStartElement (pctxt, "simultaneousCapabilities", -1); stat = asn1PD_H245CapabilityDescriptor_simultaneousCapabilities (pctxt, &pvalue->simultaneousCapabilities); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "simultaneousCapabilities", -1); } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySet_capabilityDescriptors */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySet_capabilityDescriptors (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityDescriptors* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245CapabilityDescriptor* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CapabilityDescriptor); stat = asn1PD_H245CapabilityDescriptor (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySet */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySet (OOCTXT* pctxt, H245TerminalCapabilitySet* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.multiplexCapabilityPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.capabilityTablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.capabilityDescriptorsPresent = optbit; /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->protocolIdentifier.numids, pvalue->protocolIdentifier.subid); invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode multiplexCapability */ if (pvalue->m.multiplexCapabilityPresent) { invokeStartElement (pctxt, "multiplexCapability", -1); stat = asn1PD_H245MultiplexCapability (pctxt, &pvalue->multiplexCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexCapability", -1); } /* decode capabilityTable */ if (pvalue->m.capabilityTablePresent) { invokeStartElement (pctxt, "capabilityTable", -1); stat = asn1PD_H245TerminalCapabilitySet_capabilityTable (pctxt, &pvalue->capabilityTable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityTable", -1); } /* decode capabilityDescriptors */ if (pvalue->m.capabilityDescriptorsPresent) { invokeStartElement (pctxt, "capabilityDescriptors", -1); stat = asn1PD_H245TerminalCapabilitySet_capabilityDescriptors (pctxt, &pvalue->capabilityDescriptors); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityDescriptors", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* LogicalChannelNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245LogicalChannelNumber (OOCTXT* pctxt, H245LogicalChannelNumber* pvalue) { int stat = ASN_OK; stat = decodeConsUInt16 (pctxt, pvalue, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* EncryptionMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionMode (OOCTXT* pctxt, H245EncryptionMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* h233Encryption */ case 1: invokeStartElement (pctxt, "h233Encryption", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "h233Encryption", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingElement (OOCTXT* pctxt, H245RedundancyEncodingElement* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.payloadTypePresent = optbit; /* decode dataType */ invokeStartElement (pctxt, "dataType", -1); pvalue->dataType = ALLOC_ASN1ELEM (pctxt, H245DataType); stat = asn1PD_H245DataType (pctxt, (H245DataType*)pvalue->dataType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataType", -1); /* decode payloadType */ if (pvalue->m.payloadTypePresent) { invokeStartElement (pctxt, "payloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->payloadType, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->payloadType); invokeEndElement (pctxt, "payloadType", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245RedundancyEncodingElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245RedundancyEncodingElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingElement* pvalue) { int stat = ASN_OK; H245RedundancyEncodingElement* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245RedundancyEncodingElement); stat = asn1PD_H245RedundancyEncodingElement (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncoding_rtpRedundancyEncoding */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncoding_rtpRedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding_rtpRedundancyEncoding* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.primaryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.secondaryPresent = optbit; /* decode primary */ if (pvalue->m.primaryPresent) { invokeStartElement (pctxt, "primary", -1); stat = asn1PD_H245RedundancyEncodingElement (pctxt, &pvalue->primary); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "primary", -1); } /* decode secondary */ if (pvalue->m.secondaryPresent) { invokeStartElement (pctxt, "secondary", -1); stat = asn1PD_H245_SeqOfH245RedundancyEncodingElement (pctxt, &pvalue->secondary); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "secondary", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RedundancyEncoding */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.secondaryEncodingPresent = optbit; /* decode redundancyEncodingMethod */ invokeStartElement (pctxt, "redundancyEncodingMethod", -1); stat = asn1PD_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncodingMethod", -1); /* decode secondaryEncoding */ if (pvalue->m.secondaryEncodingPresent) { invokeStartElement (pctxt, "secondaryEncoding", -1); pvalue->secondaryEncoding = ALLOC_ASN1ELEM (pctxt, H245DataType); stat = asn1PD_H245DataType (pctxt, (H245DataType*)pvalue->secondaryEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "secondaryEncoding", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.rtpRedundancyEncodingPresent = 1; invokeStartElement (pctxt, "rtpRedundancyEncoding", -1); stat = asn1PD_H245RedundancyEncoding_rtpRedundancyEncoding (pctxt, &pvalue->rtpRedundancyEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtpRedundancyEncoding", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplePayloadStreamElement (OOCTXT* pctxt, H245MultiplePayloadStreamElement* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.payloadTypePresent = optbit; /* decode dataType */ invokeStartElement (pctxt, "dataType", -1); pvalue->dataType = ALLOC_ASN1ELEM (pctxt, H245DataType); stat = asn1PD_H245DataType (pctxt, (H245DataType*)pvalue->dataType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataType", -1); /* decode payloadType */ if (pvalue->m.payloadTypePresent) { invokeStartElement (pctxt, "payloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->payloadType, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->payloadType); invokeEndElement (pctxt, "payloadType", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245MultiplePayloadStreamElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245MultiplePayloadStreamElement (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElement* pvalue) { int stat = ASN_OK; H245MultiplePayloadStreamElement* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MultiplePayloadStreamElement); stat = asn1PD_H245MultiplePayloadStreamElement (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStream */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplePayloadStream (OOCTXT* pctxt, H245MultiplePayloadStream* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode elements */ invokeStartElement (pctxt, "elements", -1); stat = asn1PD_H245_SeqOfH245MultiplePayloadStreamElement (pctxt, &pvalue->elements); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elements", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream_differentPort */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECData_rfc2733_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_differentPort* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.protectedPayloadTypePresent = optbit; /* decode protectedSessionID */ invokeStartElement (pctxt, "protectedSessionID", -1); stat = decodeConsUInt8 (pctxt, &pvalue->protectedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->protectedSessionID); invokeEndElement (pctxt, "protectedSessionID", -1); /* decode protectedPayloadType */ if (pvalue->m.protectedPayloadTypePresent) { invokeStartElement (pctxt, "protectedPayloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->protectedPayloadType, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->protectedPayloadType); invokeEndElement (pctxt, "protectedPayloadType", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream_samePort */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECData_rfc2733_mode_separateStream_samePort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_samePort* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode protectedPayloadType */ invokeStartElement (pctxt, "protectedPayloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->protectedPayloadType, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->protectedPayloadType); invokeEndElement (pctxt, "protectedPayloadType", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECData_rfc2733_mode_separateStream (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* differentPort */ case 0: invokeStartElement (pctxt, "differentPort", -1); pvalue->u.differentPort = ALLOC_ASN1ELEM (pctxt, H245FECData_rfc2733_mode_separateStream_differentPort); stat = asn1PD_H245FECData_rfc2733_mode_separateStream_differentPort (pctxt, pvalue->u.differentPort); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "differentPort", -1); break; /* samePort */ case 1: invokeStartElement (pctxt, "samePort", -1); pvalue->u.samePort = ALLOC_ASN1ELEM (pctxt, H245FECData_rfc2733_mode_separateStream_samePort); stat = asn1PD_H245FECData_rfc2733_mode_separateStream_samePort (pctxt, pvalue->u.samePort); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "samePort", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECData_rfc2733_mode (OOCTXT* pctxt, H245FECData_rfc2733_mode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* redundancyEncoding */ case 0: invokeStartElement (pctxt, "redundancyEncoding", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "redundancyEncoding", -1); break; /* separateStream */ case 1: invokeStartElement (pctxt, "separateStream", -1); pvalue->u.separateStream = ALLOC_ASN1ELEM (pctxt, H245FECData_rfc2733_mode_separateStream); stat = asn1PD_H245FECData_rfc2733_mode_separateStream (pctxt, pvalue->u.separateStream); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "separateStream", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECData_rfc2733 (OOCTXT* pctxt, H245FECData_rfc2733* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode mode */ invokeStartElement (pctxt, "mode", -1); stat = asn1PD_H245FECData_rfc2733_mode (pctxt, &pvalue->mode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECData */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECData (OOCTXT* pctxt, H245FECData* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* rfc2733 */ case 0: invokeStartElement (pctxt, "rfc2733", -1); pvalue->u.rfc2733 = ALLOC_ASN1ELEM (pctxt, H245FECData_rfc2733); stat = asn1PD_H245FECData_rfc2733 (pctxt, pvalue->u.rfc2733); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rfc2733", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* H235Media_mediaType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H235Media_mediaType (OOCTXT* pctxt, H245H235Media_mediaType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* videoData */ case 1: invokeStartElement (pctxt, "videoData", -1); pvalue->u.videoData = ALLOC_ASN1ELEM (pctxt, H245VideoCapability); stat = asn1PD_H245VideoCapability (pctxt, pvalue->u.videoData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoData", -1); break; /* audioData */ case 2: invokeStartElement (pctxt, "audioData", -1); pvalue->u.audioData = ALLOC_ASN1ELEM (pctxt, H245AudioCapability); stat = asn1PD_H245AudioCapability (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioData", -1); break; /* data */ case 3: invokeStartElement (pctxt, "data", -1); pvalue->u.data = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability); stat = asn1PD_H245DataApplicationCapability (pctxt, pvalue->u.data); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "data", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* redundancyEncoding */ case 5: invokeStartElement (pctxt, "redundancyEncoding", -1); pvalue->u.redundancyEncoding = ALLOC_ASN1ELEM (pctxt, H245RedundancyEncoding); stat = asn1PD_H245RedundancyEncoding (pctxt, pvalue->u.redundancyEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncoding", -1); break; /* multiplePayloadStream */ case 6: invokeStartElement (pctxt, "multiplePayloadStream", -1); pvalue->u.multiplePayloadStream = ALLOC_ASN1ELEM (pctxt, H245MultiplePayloadStream); stat = asn1PD_H245MultiplePayloadStream (pctxt, pvalue->u.multiplePayloadStream); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplePayloadStream", -1); break; /* fec */ case 7: invokeStartElement (pctxt, "fec", -1); pvalue->u.fec = ALLOC_ASN1ELEM (pctxt, H245FECData); stat = asn1PD_H245FECData (pctxt, pvalue->u.fec); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fec", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H235Media */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H235Media (OOCTXT* pctxt, H245H235Media* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode encryptionAuthenticationAndIntegrity */ invokeStartElement (pctxt, "encryptionAuthenticationAndIntegrity", -1); stat = asn1PD_H245EncryptionAuthenticationAndIntegrity (pctxt, &pvalue->encryptionAuthenticationAndIntegrity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionAuthenticationAndIntegrity", -1); /* decode mediaType */ invokeStartElement (pctxt, "mediaType", -1); stat = asn1PD_H245H235Media_mediaType (pctxt, &pvalue->mediaType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaType", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexedStreamParameter (OOCTXT* pctxt, H245MultiplexedStreamParameter* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode multiplexFormat */ invokeStartElement (pctxt, "multiplexFormat", -1); stat = asn1PD_H245MultiplexFormat (pctxt, &pvalue->multiplexFormat); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexFormat", -1); /* decode controlOnMuxStream */ invokeStartElement (pctxt, "controlOnMuxStream", -1); stat = DECODEBIT (pctxt, &pvalue->controlOnMuxStream); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->controlOnMuxStream); invokeEndElement (pctxt, "controlOnMuxStream", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* DataType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataType (OOCTXT* pctxt, H245DataType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* nullData */ case 1: invokeStartElement (pctxt, "nullData", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nullData", -1); break; /* videoData */ case 2: invokeStartElement (pctxt, "videoData", -1); pvalue->u.videoData = ALLOC_ASN1ELEM (pctxt, H245VideoCapability); stat = asn1PD_H245VideoCapability (pctxt, pvalue->u.videoData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoData", -1); break; /* audioData */ case 3: invokeStartElement (pctxt, "audioData", -1); pvalue->u.audioData = ALLOC_ASN1ELEM (pctxt, H245AudioCapability); stat = asn1PD_H245AudioCapability (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioData", -1); break; /* data */ case 4: invokeStartElement (pctxt, "data", -1); pvalue->u.data = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability); stat = asn1PD_H245DataApplicationCapability (pctxt, pvalue->u.data); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "data", -1); break; /* encryptionData */ case 5: invokeStartElement (pctxt, "encryptionData", -1); pvalue->u.encryptionData = ALLOC_ASN1ELEM (pctxt, H245EncryptionMode); stat = asn1PD_H245EncryptionMode (pctxt, pvalue->u.encryptionData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionData", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* h235Control */ case 7: invokeStartElement (pctxt, "h235Control", -1); pvalue->u.h235Control = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.h235Control); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h235Control", -1); break; /* h235Media */ case 8: invokeStartElement (pctxt, "h235Media", -1); pvalue->u.h235Media = ALLOC_ASN1ELEM (pctxt, H245H235Media); stat = asn1PD_H245H235Media (pctxt, pvalue->u.h235Media); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h235Media", -1); break; /* multiplexedStream */ case 9: invokeStartElement (pctxt, "multiplexedStream", -1); pvalue->u.multiplexedStream = ALLOC_ASN1ELEM (pctxt, H245MultiplexedStreamParameter); stat = asn1PD_H245MultiplexedStreamParameter (pctxt, pvalue->u.multiplexedStream); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexedStream", -1); break; /* redundancyEncoding */ case 10: invokeStartElement (pctxt, "redundancyEncoding", -1); pvalue->u.redundancyEncoding = ALLOC_ASN1ELEM (pctxt, H245RedundancyEncoding); stat = asn1PD_H245RedundancyEncoding (pctxt, pvalue->u.redundancyEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncoding", -1); break; /* multiplePayloadStream */ case 11: invokeStartElement (pctxt, "multiplePayloadStream", -1); pvalue->u.multiplePayloadStream = ALLOC_ASN1ELEM (pctxt, H245MultiplePayloadStream); stat = asn1PD_H245MultiplePayloadStream (pctxt, pvalue->u.multiplePayloadStream); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplePayloadStream", -1); break; /* fec */ case 12: invokeStartElement (pctxt, "fec", -1); pvalue->u.fec = ALLOC_ASN1ELEM (pctxt, H245FECData); stat = asn1PD_H245FECData (pctxt, pvalue->u.fec); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fec", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H222LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H222LogicalChannelParameters (OOCTXT* pctxt, H245H222LogicalChannelParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.pcr_pidPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.programDescriptorsPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.streamDescriptorsPresent = optbit; /* decode resourceID */ invokeStartElement (pctxt, "resourceID", -1); stat = decodeConsUInt16 (pctxt, &pvalue->resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->resourceID); invokeEndElement (pctxt, "resourceID", -1); /* decode subChannelID */ invokeStartElement (pctxt, "subChannelID", -1); stat = decodeConsUInt16 (pctxt, &pvalue->subChannelID, 0U, 8191U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->subChannelID); invokeEndElement (pctxt, "subChannelID", -1); /* decode pcr_pid */ if (pvalue->m.pcr_pidPresent) { invokeStartElement (pctxt, "pcr_pid", -1); stat = decodeConsUInt16 (pctxt, &pvalue->pcr_pid, 0U, 8191U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->pcr_pid); invokeEndElement (pctxt, "pcr_pid", -1); } /* decode programDescriptors */ if (pvalue->m.programDescriptorsPresent) { invokeStartElement (pctxt, "programDescriptors", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->programDescriptors); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->programDescriptors.numocts, pvalue->programDescriptors.data); invokeEndElement (pctxt, "programDescriptors", -1); } /* decode streamDescriptors */ if (pvalue->m.streamDescriptorsPresent) { invokeStartElement (pctxt, "streamDescriptors", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->streamDescriptors); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->streamDescriptors.numocts, pvalue->streamDescriptors.data); invokeEndElement (pctxt, "streamDescriptors", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223LogicalChannelParameters_adaptationLayerType_al3 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223LogicalChannelParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType_al3* pvalue) { int stat = ASN_OK; /* decode controlFieldOctets */ invokeStartElement (pctxt, "controlFieldOctets", -1); stat = decodeConsUInt8 (pctxt, &pvalue->controlFieldOctets, 0U, 2U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->controlFieldOctets); invokeEndElement (pctxt, "controlFieldOctets", -1); /* decode sendBufferSize */ invokeStartElement (pctxt, "sendBufferSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->sendBufferSize, 0U, 16777215U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sendBufferSize); invokeEndElement (pctxt, "sendBufferSize", -1); return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_transferMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL1MParameters_transferMode (OOCTXT* pctxt, H245H223AL1MParameters_transferMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* framed */ case 0: invokeStartElement (pctxt, "framed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "framed", -1); break; /* unframed */ case 1: invokeStartElement (pctxt, "unframed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unframed", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_headerFEC */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL1MParameters_headerFEC (OOCTXT* pctxt, H245H223AL1MParameters_headerFEC* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* sebch16_7 */ case 0: invokeStartElement (pctxt, "sebch16_7", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "sebch16_7", -1); break; /* golay24_12 */ case 1: invokeStartElement (pctxt, "golay24_12", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "golay24_12", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_crcLength */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL1MParameters_crcLength (OOCTXT* pctxt, H245H223AL1MParameters_crcLength* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* crc4bit */ case 0: invokeStartElement (pctxt, "crc4bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc4bit", -1); break; /* crc12bit */ case 1: invokeStartElement (pctxt, "crc12bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc12bit", -1); break; /* crc20bit */ case 2: invokeStartElement (pctxt, "crc20bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc20bit", -1); break; /* crc28bit */ case 3: invokeStartElement (pctxt, "crc28bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc28bit", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* crc8bit */ case 5: invokeStartElement (pctxt, "crc8bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc8bit", -1); break; /* crc16bit */ case 6: invokeStartElement (pctxt, "crc16bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc16bit", -1); break; /* crc32bit */ case 7: invokeStartElement (pctxt, "crc32bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc32bit", -1); break; /* crcNotUsed */ case 8: invokeStartElement (pctxt, "crcNotUsed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crcNotUsed", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H223AnnexCArqParameters_numberOfRetransmissions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AnnexCArqParameters_numberOfRetransmissions (OOCTXT* pctxt, H245H223AnnexCArqParameters_numberOfRetransmissions* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* finite */ case 0: invokeStartElement (pctxt, "finite", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.finite, 0U, 16U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.finite); invokeEndElement (pctxt, "finite", -1); break; /* infinite */ case 1: invokeStartElement (pctxt, "infinite", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "infinite", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223AnnexCArqParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AnnexCArqParameters (OOCTXT* pctxt, H245H223AnnexCArqParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode numberOfRetransmissions */ invokeStartElement (pctxt, "numberOfRetransmissions", -1); stat = asn1PD_H245H223AnnexCArqParameters_numberOfRetransmissions (pctxt, &pvalue->numberOfRetransmissions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "numberOfRetransmissions", -1); /* decode sendBufferSize */ invokeStartElement (pctxt, "sendBufferSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->sendBufferSize, 0U, 16777215U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sendBufferSize); invokeEndElement (pctxt, "sendBufferSize", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_arqType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL1MParameters_arqType (OOCTXT* pctxt, H245H223AL1MParameters_arqType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noArq */ case 0: invokeStartElement (pctxt, "noArq", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noArq", -1); break; /* typeIArq */ case 1: invokeStartElement (pctxt, "typeIArq", -1); pvalue->u.typeIArq = ALLOC_ASN1ELEM (pctxt, H245H223AnnexCArqParameters); stat = asn1PD_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIArq); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "typeIArq", -1); break; /* typeIIArq */ case 2: invokeStartElement (pctxt, "typeIIArq", -1); pvalue->u.typeIIArq = ALLOC_ASN1ELEM (pctxt, H245H223AnnexCArqParameters); stat = asn1PD_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIIArq); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "typeIIArq", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL1MParameters (OOCTXT* pctxt, H245H223AL1MParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode transferMode */ invokeStartElement (pctxt, "transferMode", -1); stat = asn1PD_H245H223AL1MParameters_transferMode (pctxt, &pvalue->transferMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transferMode", -1); /* decode headerFEC */ invokeStartElement (pctxt, "headerFEC", -1); stat = asn1PD_H245H223AL1MParameters_headerFEC (pctxt, &pvalue->headerFEC); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "headerFEC", -1); /* decode crcLength */ invokeStartElement (pctxt, "crcLength", -1); stat = asn1PD_H245H223AL1MParameters_crcLength (pctxt, &pvalue->crcLength); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "crcLength", -1); /* decode rcpcCodeRate */ invokeStartElement (pctxt, "rcpcCodeRate", -1); stat = decodeConsUInt8 (pctxt, &pvalue->rcpcCodeRate, 8U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->rcpcCodeRate); invokeEndElement (pctxt, "rcpcCodeRate", -1); /* decode arqType */ invokeStartElement (pctxt, "arqType", -1); stat = asn1PD_H245H223AL1MParameters_arqType (pctxt, &pvalue->arqType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "arqType", -1); /* decode alpduInterleaving */ invokeStartElement (pctxt, "alpduInterleaving", -1); stat = DECODEBIT (pctxt, &pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alpduInterleaving); invokeEndElement (pctxt, "alpduInterleaving", -1); /* decode alsduSplitting */ invokeStartElement (pctxt, "alsduSplitting", -1); stat = DECODEBIT (pctxt, &pvalue->alsduSplitting); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alsduSplitting); invokeEndElement (pctxt, "alsduSplitting", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.rsCodeCorrectionPresent = 1; invokeStartElement (pctxt, "rsCodeCorrection", -1); stat = decodeConsUInt8 (pctxt, &pvalue->rsCodeCorrection, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->rsCodeCorrection); invokeEndElement (pctxt, "rsCodeCorrection", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H223AL2MParameters_headerFEC */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL2MParameters_headerFEC (OOCTXT* pctxt, H245H223AL2MParameters_headerFEC* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* sebch16_5 */ case 0: invokeStartElement (pctxt, "sebch16_5", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "sebch16_5", -1); break; /* golay24_12 */ case 1: invokeStartElement (pctxt, "golay24_12", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "golay24_12", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223AL2MParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL2MParameters (OOCTXT* pctxt, H245H223AL2MParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode headerFEC */ invokeStartElement (pctxt, "headerFEC", -1); stat = asn1PD_H245H223AL2MParameters_headerFEC (pctxt, &pvalue->headerFEC); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "headerFEC", -1); /* decode alpduInterleaving */ invokeStartElement (pctxt, "alpduInterleaving", -1); stat = DECODEBIT (pctxt, &pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alpduInterleaving); invokeEndElement (pctxt, "alpduInterleaving", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters_headerFormat */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL3MParameters_headerFormat (OOCTXT* pctxt, H245H223AL3MParameters_headerFormat* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* sebch16_7 */ case 0: invokeStartElement (pctxt, "sebch16_7", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "sebch16_7", -1); break; /* golay24_12 */ case 1: invokeStartElement (pctxt, "golay24_12", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "golay24_12", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters_crcLength */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL3MParameters_crcLength (OOCTXT* pctxt, H245H223AL3MParameters_crcLength* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* crc4bit */ case 0: invokeStartElement (pctxt, "crc4bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc4bit", -1); break; /* crc12bit */ case 1: invokeStartElement (pctxt, "crc12bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc12bit", -1); break; /* crc20bit */ case 2: invokeStartElement (pctxt, "crc20bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc20bit", -1); break; /* crc28bit */ case 3: invokeStartElement (pctxt, "crc28bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc28bit", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* crc8bit */ case 5: invokeStartElement (pctxt, "crc8bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc8bit", -1); break; /* crc16bit */ case 6: invokeStartElement (pctxt, "crc16bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc16bit", -1); break; /* crc32bit */ case 7: invokeStartElement (pctxt, "crc32bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc32bit", -1); break; /* crcNotUsed */ case 8: invokeStartElement (pctxt, "crcNotUsed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crcNotUsed", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters_arqType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL3MParameters_arqType (OOCTXT* pctxt, H245H223AL3MParameters_arqType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noArq */ case 0: invokeStartElement (pctxt, "noArq", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noArq", -1); break; /* typeIArq */ case 1: invokeStartElement (pctxt, "typeIArq", -1); pvalue->u.typeIArq = ALLOC_ASN1ELEM (pctxt, H245H223AnnexCArqParameters); stat = asn1PD_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIArq); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "typeIArq", -1); break; /* typeIIArq */ case 2: invokeStartElement (pctxt, "typeIIArq", -1); pvalue->u.typeIIArq = ALLOC_ASN1ELEM (pctxt, H245H223AnnexCArqParameters); stat = asn1PD_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIIArq); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "typeIIArq", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223AL3MParameters (OOCTXT* pctxt, H245H223AL3MParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode headerFormat */ invokeStartElement (pctxt, "headerFormat", -1); stat = asn1PD_H245H223AL3MParameters_headerFormat (pctxt, &pvalue->headerFormat); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "headerFormat", -1); /* decode crcLength */ invokeStartElement (pctxt, "crcLength", -1); stat = asn1PD_H245H223AL3MParameters_crcLength (pctxt, &pvalue->crcLength); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "crcLength", -1); /* decode rcpcCodeRate */ invokeStartElement (pctxt, "rcpcCodeRate", -1); stat = decodeConsUInt8 (pctxt, &pvalue->rcpcCodeRate, 8U, 32U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->rcpcCodeRate); invokeEndElement (pctxt, "rcpcCodeRate", -1); /* decode arqType */ invokeStartElement (pctxt, "arqType", -1); stat = asn1PD_H245H223AL3MParameters_arqType (pctxt, &pvalue->arqType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "arqType", -1); /* decode alpduInterleaving */ invokeStartElement (pctxt, "alpduInterleaving", -1); stat = DECODEBIT (pctxt, &pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alpduInterleaving); invokeEndElement (pctxt, "alpduInterleaving", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.rsCodeCorrectionPresent = 1; invokeStartElement (pctxt, "rsCodeCorrection", -1); stat = decodeConsUInt8 (pctxt, &pvalue->rsCodeCorrection, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->rsCodeCorrection); invokeEndElement (pctxt, "rsCodeCorrection", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H223LogicalChannelParameters_adaptationLayerType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223LogicalChannelParameters_adaptationLayerType (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* al1Framed */ case 1: invokeStartElement (pctxt, "al1Framed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al1Framed", -1); break; /* al1NotFramed */ case 2: invokeStartElement (pctxt, "al1NotFramed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al1NotFramed", -1); break; /* al2WithoutSequenceNumbers */ case 3: invokeStartElement (pctxt, "al2WithoutSequenceNumbers", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al2WithoutSequenceNumbers", -1); break; /* al2WithSequenceNumbers */ case 4: invokeStartElement (pctxt, "al2WithSequenceNumbers", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al2WithSequenceNumbers", -1); break; /* al3 */ case 5: invokeStartElement (pctxt, "al3", -1); pvalue->u.al3 = ALLOC_ASN1ELEM (pctxt, H245H223LogicalChannelParameters_adaptationLayerType_al3); stat = asn1PD_H245H223LogicalChannelParameters_adaptationLayerType_al3 (pctxt, pvalue->u.al3); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al3", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* al1M */ case 7: invokeStartElement (pctxt, "al1M", -1); pvalue->u.al1M = ALLOC_ASN1ELEM (pctxt, H245H223AL1MParameters); stat = asn1PD_H245H223AL1MParameters (pctxt, pvalue->u.al1M); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al1M", -1); break; /* al2M */ case 8: invokeStartElement (pctxt, "al2M", -1); pvalue->u.al2M = ALLOC_ASN1ELEM (pctxt, H245H223AL2MParameters); stat = asn1PD_H245H223AL2MParameters (pctxt, pvalue->u.al2M); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al2M", -1); break; /* al3M */ case 9: invokeStartElement (pctxt, "al3M", -1); pvalue->u.al3M = ALLOC_ASN1ELEM (pctxt, H245H223AL3MParameters); stat = asn1PD_H245H223AL3MParameters (pctxt, pvalue->u.al3M); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al3M", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H223LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223LogicalChannelParameters (OOCTXT* pctxt, H245H223LogicalChannelParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode adaptationLayerType */ invokeStartElement (pctxt, "adaptationLayerType", -1); stat = asn1PD_H245H223LogicalChannelParameters_adaptationLayerType (pctxt, &pvalue->adaptationLayerType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "adaptationLayerType", -1); /* decode segmentableFlag */ invokeStartElement (pctxt, "segmentableFlag", -1); stat = DECODEBIT (pctxt, &pvalue->segmentableFlag); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->segmentableFlag); invokeEndElement (pctxt, "segmentableFlag", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CRCLength */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CRCLength (OOCTXT* pctxt, H245CRCLength* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* crc8bit */ case 0: invokeStartElement (pctxt, "crc8bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc8bit", -1); break; /* crc16bit */ case 1: invokeStartElement (pctxt, "crc16bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc16bit", -1); break; /* crc32bit */ case 2: invokeStartElement (pctxt, "crc32bit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "crc32bit", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* V76HDLCParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76HDLCParameters (OOCTXT* pctxt, H245V76HDLCParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode crcLength */ invokeStartElement (pctxt, "crcLength", -1); stat = asn1PD_H245CRCLength (pctxt, &pvalue->crcLength); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "crcLength", -1); /* decode n401 */ invokeStartElement (pctxt, "n401", -1); stat = decodeConsUInt16 (pctxt, &pvalue->n401, 1U, 4095U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->n401); invokeEndElement (pctxt, "n401", -1); /* decode loopbackTestProcedure */ invokeStartElement (pctxt, "loopbackTestProcedure", -1); stat = DECODEBIT (pctxt, &pvalue->loopbackTestProcedure); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->loopbackTestProcedure); invokeEndElement (pctxt, "loopbackTestProcedure", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_suspendResume */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76LogicalChannelParameters_suspendResume (OOCTXT* pctxt, H245V76LogicalChannelParameters_suspendResume* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noSuspendResume */ case 0: invokeStartElement (pctxt, "noSuspendResume", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noSuspendResume", -1); break; /* suspendResumewAddress */ case 1: invokeStartElement (pctxt, "suspendResumewAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "suspendResumewAddress", -1); break; /* suspendResumewoAddress */ case 2: invokeStartElement (pctxt, "suspendResumewoAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "suspendResumewoAddress", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode_eRM_recovery */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76LogicalChannelParameters_mode_eRM_recovery (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM_recovery* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* rej */ case 0: invokeStartElement (pctxt, "rej", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "rej", -1); break; /* sREJ */ case 1: invokeStartElement (pctxt, "sREJ", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "sREJ", -1); break; /* mSREJ */ case 2: invokeStartElement (pctxt, "mSREJ", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "mSREJ", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode_eRM */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76LogicalChannelParameters_mode_eRM (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode windowSize */ invokeStartElement (pctxt, "windowSize", -1); stat = decodeConsUInt8 (pctxt, &pvalue->windowSize, 1U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->windowSize); invokeEndElement (pctxt, "windowSize", -1); /* decode recovery */ invokeStartElement (pctxt, "recovery", -1); stat = asn1PD_H245V76LogicalChannelParameters_mode_eRM_recovery (pctxt, &pvalue->recovery); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "recovery", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76LogicalChannelParameters_mode (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* eRM */ case 0: invokeStartElement (pctxt, "eRM", -1); pvalue->u.eRM = ALLOC_ASN1ELEM (pctxt, H245V76LogicalChannelParameters_mode_eRM); stat = asn1PD_H245V76LogicalChannelParameters_mode_eRM (pctxt, pvalue->u.eRM); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "eRM", -1); break; /* uNERM */ case 1: invokeStartElement (pctxt, "uNERM", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "uNERM", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* V75Parameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V75Parameters (OOCTXT* pctxt, H245V75Parameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioHeaderPresent */ invokeStartElement (pctxt, "audioHeaderPresent", -1); stat = DECODEBIT (pctxt, &pvalue->audioHeaderPresent); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->audioHeaderPresent); invokeEndElement (pctxt, "audioHeaderPresent", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76LogicalChannelParameters (OOCTXT* pctxt, H245V76LogicalChannelParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode hdlcParameters */ invokeStartElement (pctxt, "hdlcParameters", -1); stat = asn1PD_H245V76HDLCParameters (pctxt, &pvalue->hdlcParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "hdlcParameters", -1); /* decode suspendResume */ invokeStartElement (pctxt, "suspendResume", -1); stat = asn1PD_H245V76LogicalChannelParameters_suspendResume (pctxt, &pvalue->suspendResume); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "suspendResume", -1); /* decode uIH */ invokeStartElement (pctxt, "uIH", -1); stat = DECODEBIT (pctxt, &pvalue->uIH); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->uIH); invokeEndElement (pctxt, "uIH", -1); /* decode mode */ invokeStartElement (pctxt, "mode", -1); stat = asn1PD_H245V76LogicalChannelParameters_mode (pctxt, &pvalue->mode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mode", -1); /* decode v75Parameters */ invokeStartElement (pctxt, "v75Parameters", -1); stat = asn1PD_H245V75Parameters (pctxt, &pvalue->v75Parameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v75Parameters", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPAddress_network */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPAddress_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPAddress (OOCTXT* pctxt, H245UnicastAddress_iPAddress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode network */ invokeStartElement (pctxt, "network", -1); stat = asn1PD_H245UnicastAddress_iPAddress_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "network", -1); /* decode tsapIdentifier */ invokeStartElement (pctxt, "tsapIdentifier", -1); stat = decodeConsUInt16 (pctxt, &pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->tsapIdentifier); invokeEndElement (pctxt, "tsapIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_node */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPXAddress_node (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_node* pvalue) { static Asn1SizeCnst lsize1 = { 0, 6, 6, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_netnum */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPXAddress_netnum (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_netnum* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_tsapIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPXAddress_tsapIdentifier (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_tsapIdentifier* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 2, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPXAddress (OOCTXT* pctxt, H245UnicastAddress_iPXAddress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode node */ invokeStartElement (pctxt, "node", -1); stat = asn1PD_H245UnicastAddress_iPXAddress_node (pctxt, &pvalue->node); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "node", -1); /* decode netnum */ invokeStartElement (pctxt, "netnum", -1); stat = asn1PD_H245UnicastAddress_iPXAddress_netnum (pctxt, &pvalue->netnum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "netnum", -1); /* decode tsapIdentifier */ invokeStartElement (pctxt, "tsapIdentifier", -1); stat = asn1PD_H245UnicastAddress_iPXAddress_tsapIdentifier (pctxt, &pvalue->tsapIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tsapIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iP6Address_network */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iP6Address_network (OOCTXT* pctxt, H245UnicastAddress_iP6Address_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iP6Address */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iP6Address (OOCTXT* pctxt, H245UnicastAddress_iP6Address* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode network */ invokeStartElement (pctxt, "network", -1); stat = asn1PD_H245UnicastAddress_iP6Address_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "network", -1); /* decode tsapIdentifier */ invokeStartElement (pctxt, "tsapIdentifier", -1); stat = decodeConsUInt16 (pctxt, &pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->tsapIdentifier); invokeEndElement (pctxt, "tsapIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_netBios */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_netBios (OOCTXT* pctxt, H245UnicastAddress_netBios* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_routing */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress_routing (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_routing* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* strict */ case 0: invokeStartElement (pctxt, "strict", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "strict", -1); break; /* loose */ case 1: invokeStartElement (pctxt, "loose", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "loose", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_network */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_route_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_route_element* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* _SeqOfH245UnicastAddress_iPSourceRouteAddress_route_elem */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, H245UnicastAddress_iPSourceRouteAddress_route_element); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245UnicastAddress_iPSourceRouteAddress_route_element (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_iPSourceRouteAddress (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode routing */ invokeStartElement (pctxt, "routing", -1); stat = asn1PD_H245UnicastAddress_iPSourceRouteAddress_routing (pctxt, &pvalue->routing); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "routing", -1); /* decode network */ invokeStartElement (pctxt, "network", -1); stat = asn1PD_H245UnicastAddress_iPSourceRouteAddress_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "network", -1); /* decode tsapIdentifier */ invokeStartElement (pctxt, "tsapIdentifier", -1); stat = decodeConsUInt16 (pctxt, &pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->tsapIdentifier); invokeEndElement (pctxt, "tsapIdentifier", -1); /* decode route */ invokeStartElement (pctxt, "route", -1); stat = asn1PD_H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element (pctxt, &pvalue->route); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "route", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_nsap */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress_nsap (OOCTXT* pctxt, H245UnicastAddress_nsap* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* UnicastAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UnicastAddress (OOCTXT* pctxt, H245UnicastAddress* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* iPAddress */ case 0: invokeStartElement (pctxt, "iPAddress", -1); pvalue->u.iPAddress = ALLOC_ASN1ELEM (pctxt, H245UnicastAddress_iPAddress); stat = asn1PD_H245UnicastAddress_iPAddress (pctxt, pvalue->u.iPAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iPAddress", -1); break; /* iPXAddress */ case 1: invokeStartElement (pctxt, "iPXAddress", -1); pvalue->u.iPXAddress = ALLOC_ASN1ELEM (pctxt, H245UnicastAddress_iPXAddress); stat = asn1PD_H245UnicastAddress_iPXAddress (pctxt, pvalue->u.iPXAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iPXAddress", -1); break; /* iP6Address */ case 2: invokeStartElement (pctxt, "iP6Address", -1); pvalue->u.iP6Address = ALLOC_ASN1ELEM (pctxt, H245UnicastAddress_iP6Address); stat = asn1PD_H245UnicastAddress_iP6Address (pctxt, pvalue->u.iP6Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iP6Address", -1); break; /* netBios */ case 3: invokeStartElement (pctxt, "netBios", -1); pvalue->u.netBios = ALLOC_ASN1ELEM (pctxt, H245UnicastAddress_netBios); stat = asn1PD_H245UnicastAddress_netBios (pctxt, pvalue->u.netBios); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "netBios", -1); break; /* iPSourceRouteAddress */ case 4: invokeStartElement (pctxt, "iPSourceRouteAddress", -1); pvalue->u.iPSourceRouteAddress = ALLOC_ASN1ELEM (pctxt, H245UnicastAddress_iPSourceRouteAddress); stat = asn1PD_H245UnicastAddress_iPSourceRouteAddress (pctxt, pvalue->u.iPSourceRouteAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iPSourceRouteAddress", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* nsap */ case 6: invokeStartElement (pctxt, "nsap", -1); pvalue->u.nsap = ALLOC_ASN1ELEM (pctxt, H245UnicastAddress_nsap); stat = asn1PD_H245UnicastAddress_nsap (pctxt, pvalue->u.nsap); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nsap", -1); break; /* nonStandardAddress */ case 7: invokeStartElement (pctxt, "nonStandardAddress", -1); pvalue->u.nonStandardAddress = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandardAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardAddress", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iPAddress_network */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MulticastAddress_iPAddress_network (OOCTXT* pctxt, H245MulticastAddress_iPAddress_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iPAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MulticastAddress_iPAddress (OOCTXT* pctxt, H245MulticastAddress_iPAddress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode network */ invokeStartElement (pctxt, "network", -1); stat = asn1PD_H245MulticastAddress_iPAddress_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "network", -1); /* decode tsapIdentifier */ invokeStartElement (pctxt, "tsapIdentifier", -1); stat = decodeConsUInt16 (pctxt, &pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->tsapIdentifier); invokeEndElement (pctxt, "tsapIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iP6Address_network */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MulticastAddress_iP6Address_network (OOCTXT* pctxt, H245MulticastAddress_iP6Address_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iP6Address */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MulticastAddress_iP6Address (OOCTXT* pctxt, H245MulticastAddress_iP6Address* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode network */ invokeStartElement (pctxt, "network", -1); stat = asn1PD_H245MulticastAddress_iP6Address_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "network", -1); /* decode tsapIdentifier */ invokeStartElement (pctxt, "tsapIdentifier", -1); stat = decodeConsUInt16 (pctxt, &pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->tsapIdentifier); invokeEndElement (pctxt, "tsapIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MulticastAddress_nsap */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MulticastAddress_nsap (OOCTXT* pctxt, H245MulticastAddress_nsap* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* MulticastAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MulticastAddress (OOCTXT* pctxt, H245MulticastAddress* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* iPAddress */ case 0: invokeStartElement (pctxt, "iPAddress", -1); pvalue->u.iPAddress = ALLOC_ASN1ELEM (pctxt, H245MulticastAddress_iPAddress); stat = asn1PD_H245MulticastAddress_iPAddress (pctxt, pvalue->u.iPAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iPAddress", -1); break; /* iP6Address */ case 1: invokeStartElement (pctxt, "iP6Address", -1); pvalue->u.iP6Address = ALLOC_ASN1ELEM (pctxt, H245MulticastAddress_iP6Address); stat = asn1PD_H245MulticastAddress_iP6Address (pctxt, pvalue->u.iP6Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iP6Address", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* nsap */ case 3: invokeStartElement (pctxt, "nsap", -1); pvalue->u.nsap = ALLOC_ASN1ELEM (pctxt, H245MulticastAddress_nsap); stat = asn1PD_H245MulticastAddress_nsap (pctxt, pvalue->u.nsap); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nsap", -1); break; /* nonStandardAddress */ case 4: invokeStartElement (pctxt, "nonStandardAddress", -1); pvalue->u.nonStandardAddress = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandardAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardAddress", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* TransportAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TransportAddress (OOCTXT* pctxt, H245TransportAddress* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unicastAddress */ case 0: invokeStartElement (pctxt, "unicastAddress", -1); pvalue->u.unicastAddress = ALLOC_ASN1ELEM (pctxt, H245UnicastAddress); stat = asn1PD_H245UnicastAddress (pctxt, pvalue->u.unicastAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "unicastAddress", -1); break; /* multicastAddress */ case 1: invokeStartElement (pctxt, "multicastAddress", -1); pvalue->u.multicastAddress = ALLOC_ASN1ELEM (pctxt, H245MulticastAddress); stat = asn1PD_H245MulticastAddress (pctxt, pvalue->u.multicastAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multicastAddress", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* McuNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245McuNumber (OOCTXT* pctxt, H245McuNumber* pvalue) { int stat = ASN_OK; stat = decodeConsUInt8 (pctxt, pvalue, 0U, 192U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* TerminalNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalNumber (OOCTXT* pctxt, H245TerminalNumber* pvalue) { int stat = ASN_OK; stat = decodeConsUInt8 (pctxt, pvalue, 0U, 192U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* TerminalLabel */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalLabel (OOCTXT* pctxt, H245TerminalLabel* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode mcuNumber */ invokeStartElement (pctxt, "mcuNumber", -1); stat = asn1PD_H245McuNumber (pctxt, &pvalue->mcuNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mcuNumber", -1); /* decode terminalNumber */ invokeStartElement (pctxt, "terminalNumber", -1); stat = asn1PD_H245TerminalNumber (pctxt, &pvalue->terminalNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H2250LogicalChannelParameters_mediaPacketization */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250LogicalChannelParameters_mediaPacketization (OOCTXT* pctxt, H245H2250LogicalChannelParameters_mediaPacketization* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* h261aVideoPacketization */ case 0: invokeStartElement (pctxt, "h261aVideoPacketization", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "h261aVideoPacketization", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* rtpPayloadType */ case 2: invokeStartElement (pctxt, "rtpPayloadType", -1); pvalue->u.rtpPayloadType = ALLOC_ASN1ELEM (pctxt, H245RTPPayloadType); stat = asn1PD_H245RTPPayloadType (pctxt, pvalue->u.rtpPayloadType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtpPayloadType", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H2250LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250LogicalChannelParameters (OOCTXT* pctxt, H245H2250LogicalChannelParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.associatedSessionIDPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaChannelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaGuaranteedDeliveryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaControlChannelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaControlGuaranteedDeliveryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.silenceSuppressionPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destinationPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.dynamicRTPPayloadTypePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaPacketizationPresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } /* decode sessionID */ invokeStartElement (pctxt, "sessionID", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sessionID, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sessionID); invokeEndElement (pctxt, "sessionID", -1); /* decode associatedSessionID */ if (pvalue->m.associatedSessionIDPresent) { invokeStartElement (pctxt, "associatedSessionID", -1); stat = decodeConsUInt8 (pctxt, &pvalue->associatedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->associatedSessionID); invokeEndElement (pctxt, "associatedSessionID", -1); } /* decode mediaChannel */ if (pvalue->m.mediaChannelPresent) { invokeStartElement (pctxt, "mediaChannel", -1); stat = asn1PD_H245TransportAddress (pctxt, &pvalue->mediaChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaChannel", -1); } /* decode mediaGuaranteedDelivery */ if (pvalue->m.mediaGuaranteedDeliveryPresent) { invokeStartElement (pctxt, "mediaGuaranteedDelivery", -1); stat = DECODEBIT (pctxt, &pvalue->mediaGuaranteedDelivery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->mediaGuaranteedDelivery); invokeEndElement (pctxt, "mediaGuaranteedDelivery", -1); } /* decode mediaControlChannel */ if (pvalue->m.mediaControlChannelPresent) { invokeStartElement (pctxt, "mediaControlChannel", -1); stat = asn1PD_H245TransportAddress (pctxt, &pvalue->mediaControlChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaControlChannel", -1); } /* decode mediaControlGuaranteedDelivery */ if (pvalue->m.mediaControlGuaranteedDeliveryPresent) { invokeStartElement (pctxt, "mediaControlGuaranteedDelivery", -1); stat = DECODEBIT (pctxt, &pvalue->mediaControlGuaranteedDelivery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->mediaControlGuaranteedDelivery); invokeEndElement (pctxt, "mediaControlGuaranteedDelivery", -1); } /* decode silenceSuppression */ if (pvalue->m.silenceSuppressionPresent) { invokeStartElement (pctxt, "silenceSuppression", -1); stat = DECODEBIT (pctxt, &pvalue->silenceSuppression); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->silenceSuppression); invokeEndElement (pctxt, "silenceSuppression", -1); } /* decode destination */ if (pvalue->m.destinationPresent) { invokeStartElement (pctxt, "destination", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->destination); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destination", -1); } /* decode dynamicRTPPayloadType */ if (pvalue->m.dynamicRTPPayloadTypePresent) { invokeStartElement (pctxt, "dynamicRTPPayloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->dynamicRTPPayloadType); invokeEndElement (pctxt, "dynamicRTPPayloadType", -1); } /* decode mediaPacketization */ if (pvalue->m.mediaPacketizationPresent) { invokeStartElement (pctxt, "mediaPacketization", -1); stat = asn1PD_H245H2250LogicalChannelParameters_mediaPacketization (pctxt, &pvalue->mediaPacketization); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaPacketization", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 3 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.transportCapabilityPresent = 1; invokeStartElement (pctxt, "transportCapability", -1); stat = asn1PD_H245TransportCapability (pctxt, &pvalue->transportCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transportCapability", -1); break; case 1: pvalue->m.redundancyEncodingPresent = 1; invokeStartElement (pctxt, "redundancyEncoding", -1); stat = asn1PD_H245RedundancyEncoding (pctxt, &pvalue->redundancyEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncoding", -1); break; case 2: pvalue->m.sourcePresent = 1; invokeStartElement (pctxt, "source", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->source); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "source", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_forwardLogicalChannelParameters_multi */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* h222LogicalChannelParameters */ case 0: invokeStartElement (pctxt, "h222LogicalChannelParameters", -1); pvalue->u.h222LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245H222LogicalChannelParameters); stat = asn1PD_H245H222LogicalChannelParameters (pctxt, pvalue->u.h222LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h222LogicalChannelParameters", -1); break; /* h223LogicalChannelParameters */ case 1: invokeStartElement (pctxt, "h223LogicalChannelParameters", -1); pvalue->u.h223LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245H223LogicalChannelParameters); stat = asn1PD_H245H223LogicalChannelParameters (pctxt, pvalue->u.h223LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223LogicalChannelParameters", -1); break; /* v76LogicalChannelParameters */ case 2: invokeStartElement (pctxt, "v76LogicalChannelParameters", -1); pvalue->u.v76LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245V76LogicalChannelParameters); stat = asn1PD_H245V76LogicalChannelParameters (pctxt, pvalue->u.v76LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v76LogicalChannelParameters", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* h2250LogicalChannelParameters */ case 4: invokeStartElement (pctxt, "h2250LogicalChannelParameters", -1); pvalue->u.h2250LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245H2250LogicalChannelParameters); stat = asn1PD_H245H2250LogicalChannelParameters (pctxt, pvalue->u.h2250LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h2250LogicalChannelParameters", -1); break; /* none */ case 5: invokeStartElement (pctxt, "none", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "none", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_forwardLogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannel_forwardLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.portNumberPresent = optbit; /* decode portNumber */ if (pvalue->m.portNumberPresent) { invokeStartElement (pctxt, "portNumber", -1); stat = decodeConsUInt16 (pctxt, &pvalue->portNumber, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->portNumber); invokeEndElement (pctxt, "portNumber", -1); } /* decode dataType */ invokeStartElement (pctxt, "dataType", -1); stat = asn1PD_H245DataType (pctxt, &pvalue->dataType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataType", -1); /* decode multiplexParameters */ invokeStartElement (pctxt, "multiplexParameters", -1); stat = asn1PD_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters (pctxt, &pvalue->multiplexParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexParameters", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.forwardLogicalChannelDependencyPresent = 1; invokeStartElement (pctxt, "forwardLogicalChannelDependency", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelDependency); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelDependency", -1); break; case 1: pvalue->m.replacementForPresent = 1; invokeStartElement (pctxt, "replacementFor", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->replacementFor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "replacementFor", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_reverseLogicalChannelParameters_multi */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* h223LogicalChannelParameters */ case 0: invokeStartElement (pctxt, "h223LogicalChannelParameters", -1); pvalue->u.h223LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245H223LogicalChannelParameters); stat = asn1PD_H245H223LogicalChannelParameters (pctxt, pvalue->u.h223LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223LogicalChannelParameters", -1); break; /* v76LogicalChannelParameters */ case 1: invokeStartElement (pctxt, "v76LogicalChannelParameters", -1); pvalue->u.v76LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245V76LogicalChannelParameters); stat = asn1PD_H245V76LogicalChannelParameters (pctxt, pvalue->u.v76LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v76LogicalChannelParameters", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* h2250LogicalChannelParameters */ case 3: invokeStartElement (pctxt, "h2250LogicalChannelParameters", -1); pvalue->u.h2250LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245H2250LogicalChannelParameters); stat = asn1PD_H245H2250LogicalChannelParameters (pctxt, pvalue->u.h2250LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h2250LogicalChannelParameters", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_reverseLogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannel_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.multiplexParametersPresent = optbit; /* decode dataType */ invokeStartElement (pctxt, "dataType", -1); stat = asn1PD_H245DataType (pctxt, &pvalue->dataType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataType", -1); /* decode multiplexParameters */ if (pvalue->m.multiplexParametersPresent) { invokeStartElement (pctxt, "multiplexParameters", -1); stat = asn1PD_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters (pctxt, &pvalue->multiplexParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexParameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.reverseLogicalChannelDependencyPresent = 1; invokeStartElement (pctxt, "reverseLogicalChannelDependency", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->reverseLogicalChannelDependency); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reverseLogicalChannelDependency", -1); break; case 1: pvalue->m.replacementForPresent = 1; invokeStartElement (pctxt, "replacementFor", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->replacementFor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "replacementFor", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_distribution */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NetworkAccessParameters_distribution (OOCTXT* pctxt, H245NetworkAccessParameters_distribution* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unicast */ case 0: invokeStartElement (pctxt, "unicast", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unicast", -1); break; /* multicast */ case 1: invokeStartElement (pctxt, "multicast", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multicast", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_networkAddress */ /* */ /**************************************************************/ extern EXTERN const char* gs_MULTIMEDIA_SYSTEM_CONTROL_NetworkAccessParameters_networkAddress_e164Address_CharSet; EXTERN int asn1PD_H245NetworkAccessParameters_networkAddress (OOCTXT* pctxt, H245NetworkAccessParameters_networkAddress* pvalue) { static Asn1SizeCnst e164Address_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* q2931Address */ case 0: invokeStartElement (pctxt, "q2931Address", -1); pvalue->u.q2931Address = ALLOC_ASN1ELEM (pctxt, H245Q2931Address); stat = asn1PD_H245Q2931Address (pctxt, pvalue->u.q2931Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "q2931Address", -1); break; /* e164Address */ case 1: invokeStartElement (pctxt, "e164Address", -1); addSizeConstraint (pctxt, &e164Address_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.e164Address, gs_MULTIMEDIA_SYSTEM_CONTROL_NetworkAccessParameters_networkAddress_e164Address_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.e164Address); invokeEndElement (pctxt, "e164Address", -1); break; /* localAreaAddress */ case 2: invokeStartElement (pctxt, "localAreaAddress", -1); pvalue->u.localAreaAddress = ALLOC_ASN1ELEM (pctxt, H245TransportAddress); stat = asn1PD_H245TransportAddress (pctxt, pvalue->u.localAreaAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "localAreaAddress", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_externalReference */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NetworkAccessParameters_externalReference (OOCTXT* pctxt, H245NetworkAccessParameters_externalReference* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 255, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_t120SetupProcedure */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NetworkAccessParameters_t120SetupProcedure (OOCTXT* pctxt, H245NetworkAccessParameters_t120SetupProcedure* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* originateCall */ case 0: invokeStartElement (pctxt, "originateCall", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "originateCall", -1); break; /* waitForCall */ case 1: invokeStartElement (pctxt, "waitForCall", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "waitForCall", -1); break; /* issueQuery */ case 2: invokeStartElement (pctxt, "issueQuery", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "issueQuery", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NetworkAccessParameters (OOCTXT* pctxt, H245NetworkAccessParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.distributionPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.externalReferencePresent = optbit; /* decode distribution */ if (pvalue->m.distributionPresent) { invokeStartElement (pctxt, "distribution", -1); stat = asn1PD_H245NetworkAccessParameters_distribution (pctxt, &pvalue->distribution); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "distribution", -1); } /* decode networkAddress */ invokeStartElement (pctxt, "networkAddress", -1); stat = asn1PD_H245NetworkAccessParameters_networkAddress (pctxt, &pvalue->networkAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "networkAddress", -1); /* decode associateConference */ invokeStartElement (pctxt, "associateConference", -1); stat = DECODEBIT (pctxt, &pvalue->associateConference); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->associateConference); invokeEndElement (pctxt, "associateConference", -1); /* decode externalReference */ if (pvalue->m.externalReferencePresent) { invokeStartElement (pctxt, "externalReference", -1); stat = asn1PD_H245NetworkAccessParameters_externalReference (pctxt, &pvalue->externalReference); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "externalReference", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.t120SetupProcedurePresent = 1; invokeStartElement (pctxt, "t120SetupProcedure", -1); stat = asn1PD_H245NetworkAccessParameters_t120SetupProcedure (pctxt, &pvalue->t120SetupProcedure); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t120SetupProcedure", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* EscrowData_escrowValue */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EscrowData_escrowValue (OOCTXT* pctxt, H245EscrowData_escrowValue* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* EscrowData */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EscrowData (OOCTXT* pctxt, H245EscrowData* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode escrowID */ invokeStartElement (pctxt, "escrowID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->escrowID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->escrowID.numids, pvalue->escrowID.subid); invokeEndElement (pctxt, "escrowID", -1); /* decode escrowValue */ invokeStartElement (pctxt, "escrowValue", -1); stat = asn1PD_H245EscrowData_escrowValue (pctxt, &pvalue->escrowValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "escrowValue", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* EncryptionSync_escrowentry */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionSync_escrowentry (OOCTXT* pctxt, H245EncryptionSync_escrowentry* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245EscrowData* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245EscrowData); stat = asn1PD_H245EscrowData (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* EncryptionSync */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionSync (OOCTXT* pctxt, H245EncryptionSync* pvalue) { static Asn1SizeCnst h235Key_lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.escrowentryPresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } /* decode synchFlag */ invokeStartElement (pctxt, "synchFlag", -1); stat = decodeConsUInt8 (pctxt, &pvalue->synchFlag, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->synchFlag); invokeEndElement (pctxt, "synchFlag", -1); /* decode h235Key */ invokeStartElement (pctxt, "h235Key", -1); addSizeConstraint (pctxt, &h235Key_lsize1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->h235Key); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->h235Key.numocts, pvalue->h235Key.data); invokeEndElement (pctxt, "h235Key", -1); /* decode escrowentry */ if (pvalue->m.escrowentryPresent) { invokeStartElement (pctxt, "escrowentry", -1); stat = asn1PD_H245EncryptionSync_escrowentry (pctxt, &pvalue->escrowentry); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "escrowentry", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannel (OOCTXT* pctxt, H245OpenLogicalChannel* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.reverseLogicalChannelParametersPresent = optbit; /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); /* decode forwardLogicalChannelParameters */ invokeStartElement (pctxt, "forwardLogicalChannelParameters", -1); stat = asn1PD_H245OpenLogicalChannel_forwardLogicalChannelParameters (pctxt, &pvalue->forwardLogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelParameters", -1); /* decode reverseLogicalChannelParameters */ if (pvalue->m.reverseLogicalChannelParametersPresent) { invokeStartElement (pctxt, "reverseLogicalChannelParameters", -1); stat = asn1PD_H245OpenLogicalChannel_reverseLogicalChannelParameters (pctxt, &pvalue->reverseLogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reverseLogicalChannelParameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.separateStackPresent = 1; invokeStartElement (pctxt, "separateStack", -1); stat = asn1PD_H245NetworkAccessParameters (pctxt, &pvalue->separateStack); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "separateStack", -1); break; case 1: pvalue->m.encryptionSyncPresent = 1; invokeStartElement (pctxt, "encryptionSync", -1); stat = asn1PD_H245EncryptionSync (pctxt, &pvalue->encryptionSync); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionSync", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannel_source */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CloseLogicalChannel_source (OOCTXT* pctxt, H245CloseLogicalChannel_source* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* user */ case 0: invokeStartElement (pctxt, "user", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "user", -1); break; /* lcse */ case 1: invokeStartElement (pctxt, "lcse", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "lcse", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannel_reason */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CloseLogicalChannel_reason (OOCTXT* pctxt, H245CloseLogicalChannel_reason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unknown */ case 0: invokeStartElement (pctxt, "unknown", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unknown", -1); break; /* reopen */ case 1: invokeStartElement (pctxt, "reopen", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "reopen", -1); break; /* reservationFailure */ case 2: invokeStartElement (pctxt, "reservationFailure", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "reservationFailure", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannel */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CloseLogicalChannel (OOCTXT* pctxt, H245CloseLogicalChannel* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); /* decode source */ invokeStartElement (pctxt, "source", -1); stat = asn1PD_H245CloseLogicalChannel_source (pctxt, &pvalue->source); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "source", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.reasonPresent = 1; invokeStartElement (pctxt, "reason", -1); stat = asn1PD_H245CloseLogicalChannel_reason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reason", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* RequestChannelClose_reason */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestChannelClose_reason (OOCTXT* pctxt, H245RequestChannelClose_reason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unknown */ case 0: invokeStartElement (pctxt, "unknown", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unknown", -1); break; /* normal */ case 1: invokeStartElement (pctxt, "normal", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "normal", -1); break; /* reopen */ case 2: invokeStartElement (pctxt, "reopen", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "reopen", -1); break; /* reservationFailure */ case 3: invokeStartElement (pctxt, "reservationFailure", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "reservationFailure", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestChannelClose */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestChannelClose (OOCTXT* pctxt, H245RequestChannelClose* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.qosCapabilityPresent = 1; invokeStartElement (pctxt, "qosCapability", -1); stat = asn1PD_H245QOSCapability (pctxt, &pvalue->qosCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "qosCapability", -1); break; case 1: pvalue->m.reasonPresent = 1; invokeStartElement (pctxt, "reason", -1); stat = asn1PD_H245RequestChannelClose_reason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reason", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* MultiplexTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexTableEntryNumber* pvalue) { int stat = ASN_OK; stat = decodeConsUInt8 (pctxt, pvalue, 1U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* MultiplexElement_type_subElementList */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexElement_type_subElementList (OOCTXT* pctxt, H245MultiplexElement_type_subElementList* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 255, 0 }; int stat = ASN_OK; H245MultiplexElement* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MultiplexElement); stat = asn1PD_H245MultiplexElement (pctxt, (H245MultiplexElement*)pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MultiplexElement_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexElement_type (OOCTXT* pctxt, H245MultiplexElement_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* logicalChannelNumber */ case 0: invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.logicalChannelNumber, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.logicalChannelNumber); invokeEndElement (pctxt, "logicalChannelNumber", -1); break; /* subElementList */ case 1: invokeStartElement (pctxt, "subElementList", -1); pvalue->u.subElementList = ALLOC_ASN1ELEM (pctxt, H245MultiplexElement_type_subElementList); stat = asn1PD_H245MultiplexElement_type_subElementList (pctxt, pvalue->u.subElementList); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "subElementList", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MultiplexElement_repeatCount */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexElement_repeatCount (OOCTXT* pctxt, H245MultiplexElement_repeatCount* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* finite */ case 0: invokeStartElement (pctxt, "finite", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.finite, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.finite); invokeEndElement (pctxt, "finite", -1); break; /* untilClosingFlag */ case 1: invokeStartElement (pctxt, "untilClosingFlag", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "untilClosingFlag", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MultiplexElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexElement (OOCTXT* pctxt, H245MultiplexElement* pvalue) { int stat = ASN_OK; /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245MultiplexElement_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); /* decode repeatCount */ invokeStartElement (pctxt, "repeatCount", -1); stat = asn1PD_H245MultiplexElement_repeatCount (pctxt, &pvalue->repeatCount); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "repeatCount", -1); return (stat); } /**************************************************************/ /* */ /* MultiplexEntryDescriptor_elementList */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntryDescriptor_elementList (OOCTXT* pctxt, H245MultiplexEntryDescriptor_elementList* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245MultiplexElement* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MultiplexElement); stat = asn1PD_H245MultiplexElement (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MultiplexEntryDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntryDescriptor (OOCTXT* pctxt, H245MultiplexEntryDescriptor* pvalue) { int stat = ASN_OK; ASN1BOOL optbit = 0; /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.elementListPresent = optbit; /* decode multiplexTableEntryNumber */ invokeStartElement (pctxt, "multiplexTableEntryNumber", -1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexTableEntryNumber", -1); /* decode elementList */ if (pvalue->m.elementListPresent) { invokeStartElement (pctxt, "elementList", -1); stat = asn1PD_H245MultiplexEntryDescriptor_elementList (pctxt, &pvalue->elementList); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elementList", -1); } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySend_multiplexEntryDescriptors */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySend_multiplexEntryDescriptors (OOCTXT* pctxt, H245MultiplexEntrySend_multiplexEntryDescriptors* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; H245MultiplexEntryDescriptor* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MultiplexEntryDescriptor); stat = asn1PD_H245MultiplexEntryDescriptor (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySend */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySend (OOCTXT* pctxt, H245MultiplexEntrySend* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode multiplexEntryDescriptors */ invokeStartElement (pctxt, "multiplexEntryDescriptors", -1); stat = asn1PD_H245MultiplexEntrySend_multiplexEntryDescriptors (pctxt, &pvalue->multiplexEntryDescriptors); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexEntryDescriptors", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntry_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntry_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntry_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntry */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntry (OOCTXT* pctxt, H245RequestMultiplexEntry* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode entryNumbers */ invokeStartElement (pctxt, "entryNumbers", -1); stat = asn1PD_H245RequestMultiplexEntry_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "entryNumbers", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H261VideoMode_resolution */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H261VideoMode_resolution (OOCTXT* pctxt, H245H261VideoMode_resolution* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* qcif */ case 0: invokeStartElement (pctxt, "qcif", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "qcif", -1); break; /* cif */ case 1: invokeStartElement (pctxt, "cif", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cif", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* H261VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H261VideoMode (OOCTXT* pctxt, H245H261VideoMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode resolution */ invokeStartElement (pctxt, "resolution", -1); stat = asn1PD_H245H261VideoMode_resolution (pctxt, &pvalue->resolution); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "resolution", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 19200U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); /* decode stillImageTransmission */ invokeStartElement (pctxt, "stillImageTransmission", -1); stat = DECODEBIT (pctxt, &pvalue->stillImageTransmission); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->stillImageTransmission); invokeEndElement (pctxt, "stillImageTransmission", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H262VideoMode_profileAndLevel */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H262VideoMode_profileAndLevel (OOCTXT* pctxt, H245H262VideoMode_profileAndLevel* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 10); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* profileAndLevel_SPatML */ case 0: invokeStartElement (pctxt, "profileAndLevel_SPatML", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_SPatML", -1); break; /* profileAndLevel_MPatLL */ case 1: invokeStartElement (pctxt, "profileAndLevel_MPatLL", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_MPatLL", -1); break; /* profileAndLevel_MPatML */ case 2: invokeStartElement (pctxt, "profileAndLevel_MPatML", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_MPatML", -1); break; /* profileAndLevel_MPatH_14 */ case 3: invokeStartElement (pctxt, "profileAndLevel_MPatH_14", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_MPatH_14", -1); break; /* profileAndLevel_MPatHL */ case 4: invokeStartElement (pctxt, "profileAndLevel_MPatHL", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_MPatHL", -1); break; /* profileAndLevel_SNRatLL */ case 5: invokeStartElement (pctxt, "profileAndLevel_SNRatLL", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_SNRatLL", -1); break; /* profileAndLevel_SNRatML */ case 6: invokeStartElement (pctxt, "profileAndLevel_SNRatML", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_SNRatML", -1); break; /* profileAndLevel_SpatialatH_14 */ case 7: invokeStartElement (pctxt, "profileAndLevel_SpatialatH_14", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_SpatialatH_14", -1); break; /* profileAndLevel_HPatML */ case 8: invokeStartElement (pctxt, "profileAndLevel_HPatML", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_HPatML", -1); break; /* profileAndLevel_HPatH_14 */ case 9: invokeStartElement (pctxt, "profileAndLevel_HPatH_14", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_HPatH_14", -1); break; /* profileAndLevel_HPatHL */ case 10: invokeStartElement (pctxt, "profileAndLevel_HPatHL", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "profileAndLevel_HPatHL", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 12; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H262VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H262VideoMode (OOCTXT* pctxt, H245H262VideoMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.videoBitRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.vbvBufferSizePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.samplesPerLinePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.linesPerFramePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.framesPerSecondPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.luminanceSampleRatePresent = optbit; /* decode profileAndLevel */ invokeStartElement (pctxt, "profileAndLevel", -1); stat = asn1PD_H245H262VideoMode_profileAndLevel (pctxt, &pvalue->profileAndLevel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "profileAndLevel", -1); /* decode videoBitRate */ if (pvalue->m.videoBitRatePresent) { invokeStartElement (pctxt, "videoBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->videoBitRate); invokeEndElement (pctxt, "videoBitRate", -1); } /* decode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { invokeStartElement (pctxt, "vbvBufferSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->vbvBufferSize); invokeEndElement (pctxt, "vbvBufferSize", -1); } /* decode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { invokeStartElement (pctxt, "samplesPerLine", -1); stat = decodeConsUInt16 (pctxt, &pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->samplesPerLine); invokeEndElement (pctxt, "samplesPerLine", -1); } /* decode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { invokeStartElement (pctxt, "linesPerFrame", -1); stat = decodeConsUInt16 (pctxt, &pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->linesPerFrame); invokeEndElement (pctxt, "linesPerFrame", -1); } /* decode framesPerSecond */ if (pvalue->m.framesPerSecondPresent) { invokeStartElement (pctxt, "framesPerSecond", -1); stat = decodeConsUInt8 (pctxt, &pvalue->framesPerSecond, 0U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->framesPerSecond); invokeEndElement (pctxt, "framesPerSecond", -1); } /* decode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { invokeStartElement (pctxt, "luminanceSampleRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->luminanceSampleRate); invokeEndElement (pctxt, "luminanceSampleRate", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H263VideoMode_resolution */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263VideoMode_resolution (OOCTXT* pctxt, H245H263VideoMode_resolution* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* sqcif */ case 0: invokeStartElement (pctxt, "sqcif", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "sqcif", -1); break; /* qcif */ case 1: invokeStartElement (pctxt, "qcif", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "qcif", -1); break; /* cif */ case 2: invokeStartElement (pctxt, "cif", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cif", -1); break; /* cif4 */ case 3: invokeStartElement (pctxt, "cif4", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cif4", -1); break; /* cif16 */ case 4: invokeStartElement (pctxt, "cif16", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cif16", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* custom */ case 6: invokeStartElement (pctxt, "custom", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "custom", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H263VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H263VideoMode (OOCTXT* pctxt, H245H263VideoMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode resolution */ invokeStartElement (pctxt, "resolution", -1); stat = asn1PD_H245H263VideoMode_resolution (pctxt, &pvalue->resolution); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "resolution", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 19200U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); /* decode unrestrictedVector */ invokeStartElement (pctxt, "unrestrictedVector", -1); stat = DECODEBIT (pctxt, &pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->unrestrictedVector); invokeEndElement (pctxt, "unrestrictedVector", -1); /* decode arithmeticCoding */ invokeStartElement (pctxt, "arithmeticCoding", -1); stat = DECODEBIT (pctxt, &pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->arithmeticCoding); invokeEndElement (pctxt, "arithmeticCoding", -1); /* decode advancedPrediction */ invokeStartElement (pctxt, "advancedPrediction", -1); stat = DECODEBIT (pctxt, &pvalue->advancedPrediction); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->advancedPrediction); invokeEndElement (pctxt, "advancedPrediction", -1); /* decode pbFrames */ invokeStartElement (pctxt, "pbFrames", -1); stat = DECODEBIT (pctxt, &pvalue->pbFrames); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->pbFrames); invokeEndElement (pctxt, "pbFrames", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 3 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.errorCompensationPresent = 1; invokeStartElement (pctxt, "errorCompensation", -1); stat = DECODEBIT (pctxt, &pvalue->errorCompensation); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->errorCompensation); invokeEndElement (pctxt, "errorCompensation", -1); break; case 1: pvalue->m.enhancementLayerInfoPresent = 1; invokeStartElement (pctxt, "enhancementLayerInfo", -1); stat = asn1PD_H245EnhancementLayerInfo (pctxt, &pvalue->enhancementLayerInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "enhancementLayerInfo", -1); break; case 2: pvalue->m.h263OptionsPresent = 1; invokeStartElement (pctxt, "h263Options", -1); stat = asn1PD_H245H263Options (pctxt, &pvalue->h263Options); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263Options", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* IS11172VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS11172VideoMode (OOCTXT* pctxt, H245IS11172VideoMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.videoBitRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.vbvBufferSizePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.samplesPerLinePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.linesPerFramePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.pictureRatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.luminanceSampleRatePresent = optbit; /* decode constrainedBitstream */ invokeStartElement (pctxt, "constrainedBitstream", -1); stat = DECODEBIT (pctxt, &pvalue->constrainedBitstream); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->constrainedBitstream); invokeEndElement (pctxt, "constrainedBitstream", -1); /* decode videoBitRate */ if (pvalue->m.videoBitRatePresent) { invokeStartElement (pctxt, "videoBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->videoBitRate); invokeEndElement (pctxt, "videoBitRate", -1); } /* decode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { invokeStartElement (pctxt, "vbvBufferSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->vbvBufferSize); invokeEndElement (pctxt, "vbvBufferSize", -1); } /* decode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { invokeStartElement (pctxt, "samplesPerLine", -1); stat = decodeConsUInt16 (pctxt, &pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->samplesPerLine); invokeEndElement (pctxt, "samplesPerLine", -1); } /* decode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { invokeStartElement (pctxt, "linesPerFrame", -1); stat = decodeConsUInt16 (pctxt, &pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->linesPerFrame); invokeEndElement (pctxt, "linesPerFrame", -1); } /* decode pictureRate */ if (pvalue->m.pictureRatePresent) { invokeStartElement (pctxt, "pictureRate", -1); stat = decodeConsUInt8 (pctxt, &pvalue->pictureRate, 0U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->pictureRate); invokeEndElement (pctxt, "pictureRate", -1); } /* decode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { invokeStartElement (pctxt, "luminanceSampleRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->luminanceSampleRate); invokeEndElement (pctxt, "luminanceSampleRate", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VideoMode (OOCTXT* pctxt, H245VideoMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* h261VideoMode */ case 1: invokeStartElement (pctxt, "h261VideoMode", -1); pvalue->u.h261VideoMode = ALLOC_ASN1ELEM (pctxt, H245H261VideoMode); stat = asn1PD_H245H261VideoMode (pctxt, pvalue->u.h261VideoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h261VideoMode", -1); break; /* h262VideoMode */ case 2: invokeStartElement (pctxt, "h262VideoMode", -1); pvalue->u.h262VideoMode = ALLOC_ASN1ELEM (pctxt, H245H262VideoMode); stat = asn1PD_H245H262VideoMode (pctxt, pvalue->u.h262VideoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h262VideoMode", -1); break; /* h263VideoMode */ case 3: invokeStartElement (pctxt, "h263VideoMode", -1); pvalue->u.h263VideoMode = ALLOC_ASN1ELEM (pctxt, H245H263VideoMode); stat = asn1PD_H245H263VideoMode (pctxt, pvalue->u.h263VideoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h263VideoMode", -1); break; /* is11172VideoMode */ case 4: invokeStartElement (pctxt, "is11172VideoMode", -1); pvalue->u.is11172VideoMode = ALLOC_ASN1ELEM (pctxt, H245IS11172VideoMode); stat = asn1PD_H245IS11172VideoMode (pctxt, pvalue->u.is11172VideoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "is11172VideoMode", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* genericVideoMode */ case 6: invokeStartElement (pctxt, "genericVideoMode", -1); pvalue->u.genericVideoMode = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericVideoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericVideoMode", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* AudioMode_g7231 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AudioMode_g7231 (OOCTXT* pctxt, H245AudioMode_g7231* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noSilenceSuppressionLowRate */ case 0: invokeStartElement (pctxt, "noSilenceSuppressionLowRate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noSilenceSuppressionLowRate", -1); break; /* noSilenceSuppressionHighRate */ case 1: invokeStartElement (pctxt, "noSilenceSuppressionHighRate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noSilenceSuppressionHighRate", -1); break; /* silenceSuppressionLowRate */ case 2: invokeStartElement (pctxt, "silenceSuppressionLowRate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "silenceSuppressionLowRate", -1); break; /* silenceSuppressionHighRate */ case 3: invokeStartElement (pctxt, "silenceSuppressionHighRate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "silenceSuppressionHighRate", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode_audioLayer */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS11172AudioMode_audioLayer (OOCTXT* pctxt, H245IS11172AudioMode_audioLayer* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* audioLayer1 */ case 0: invokeStartElement (pctxt, "audioLayer1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioLayer1", -1); break; /* audioLayer2 */ case 1: invokeStartElement (pctxt, "audioLayer2", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioLayer2", -1); break; /* audioLayer3 */ case 2: invokeStartElement (pctxt, "audioLayer3", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioLayer3", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode_audioSampling */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS11172AudioMode_audioSampling (OOCTXT* pctxt, H245IS11172AudioMode_audioSampling* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* audioSampling32k */ case 0: invokeStartElement (pctxt, "audioSampling32k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling32k", -1); break; /* audioSampling44k1 */ case 1: invokeStartElement (pctxt, "audioSampling44k1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling44k1", -1); break; /* audioSampling48k */ case 2: invokeStartElement (pctxt, "audioSampling48k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling48k", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode_multichannelType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS11172AudioMode_multichannelType (OOCTXT* pctxt, H245IS11172AudioMode_multichannelType* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* singleChannel */ case 0: invokeStartElement (pctxt, "singleChannel", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "singleChannel", -1); break; /* twoChannelStereo */ case 1: invokeStartElement (pctxt, "twoChannelStereo", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "twoChannelStereo", -1); break; /* twoChannelDual */ case 2: invokeStartElement (pctxt, "twoChannelDual", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "twoChannelDual", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS11172AudioMode (OOCTXT* pctxt, H245IS11172AudioMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioLayer */ invokeStartElement (pctxt, "audioLayer", -1); stat = asn1PD_H245IS11172AudioMode_audioLayer (pctxt, &pvalue->audioLayer); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioLayer", -1); /* decode audioSampling */ invokeStartElement (pctxt, "audioSampling", -1); stat = asn1PD_H245IS11172AudioMode_audioSampling (pctxt, &pvalue->audioSampling); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioSampling", -1); /* decode multichannelType */ invokeStartElement (pctxt, "multichannelType", -1); stat = asn1PD_H245IS11172AudioMode_multichannelType (pctxt, &pvalue->multichannelType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multichannelType", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 448U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode_audioLayer */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS13818AudioMode_audioLayer (OOCTXT* pctxt, H245IS13818AudioMode_audioLayer* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* audioLayer1 */ case 0: invokeStartElement (pctxt, "audioLayer1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioLayer1", -1); break; /* audioLayer2 */ case 1: invokeStartElement (pctxt, "audioLayer2", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioLayer2", -1); break; /* audioLayer3 */ case 2: invokeStartElement (pctxt, "audioLayer3", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioLayer3", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode_audioSampling */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS13818AudioMode_audioSampling (OOCTXT* pctxt, H245IS13818AudioMode_audioSampling* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* audioSampling16k */ case 0: invokeStartElement (pctxt, "audioSampling16k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling16k", -1); break; /* audioSampling22k05 */ case 1: invokeStartElement (pctxt, "audioSampling22k05", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling22k05", -1); break; /* audioSampling24k */ case 2: invokeStartElement (pctxt, "audioSampling24k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling24k", -1); break; /* audioSampling32k */ case 3: invokeStartElement (pctxt, "audioSampling32k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling32k", -1); break; /* audioSampling44k1 */ case 4: invokeStartElement (pctxt, "audioSampling44k1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling44k1", -1); break; /* audioSampling48k */ case 5: invokeStartElement (pctxt, "audioSampling48k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "audioSampling48k", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode_multichannelType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS13818AudioMode_multichannelType (OOCTXT* pctxt, H245IS13818AudioMode_multichannelType* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 9); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* singleChannel */ case 0: invokeStartElement (pctxt, "singleChannel", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "singleChannel", -1); break; /* twoChannelStereo */ case 1: invokeStartElement (pctxt, "twoChannelStereo", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "twoChannelStereo", -1); break; /* twoChannelDual */ case 2: invokeStartElement (pctxt, "twoChannelDual", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "twoChannelDual", -1); break; /* threeChannels2_1 */ case 3: invokeStartElement (pctxt, "threeChannels2_1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "threeChannels2_1", -1); break; /* threeChannels3_0 */ case 4: invokeStartElement (pctxt, "threeChannels3_0", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "threeChannels3_0", -1); break; /* fourChannels2_0_2_0 */ case 5: invokeStartElement (pctxt, "fourChannels2_0_2_0", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fourChannels2_0_2_0", -1); break; /* fourChannels2_2 */ case 6: invokeStartElement (pctxt, "fourChannels2_2", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fourChannels2_2", -1); break; /* fourChannels3_1 */ case 7: invokeStartElement (pctxt, "fourChannels3_1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fourChannels3_1", -1); break; /* fiveChannels3_0_2_0 */ case 8: invokeStartElement (pctxt, "fiveChannels3_0_2_0", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fiveChannels3_0_2_0", -1); break; /* fiveChannels3_2 */ case 9: invokeStartElement (pctxt, "fiveChannels3_2", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fiveChannels3_2", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IS13818AudioMode (OOCTXT* pctxt, H245IS13818AudioMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode audioLayer */ invokeStartElement (pctxt, "audioLayer", -1); stat = asn1PD_H245IS13818AudioMode_audioLayer (pctxt, &pvalue->audioLayer); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioLayer", -1); /* decode audioSampling */ invokeStartElement (pctxt, "audioSampling", -1); stat = asn1PD_H245IS13818AudioMode_audioSampling (pctxt, &pvalue->audioSampling); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioSampling", -1); /* decode multichannelType */ invokeStartElement (pctxt, "multichannelType", -1); stat = asn1PD_H245IS13818AudioMode_multichannelType (pctxt, &pvalue->multichannelType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multichannelType", -1); /* decode lowFrequencyEnhancement */ invokeStartElement (pctxt, "lowFrequencyEnhancement", -1); stat = DECODEBIT (pctxt, &pvalue->lowFrequencyEnhancement); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->lowFrequencyEnhancement); invokeEndElement (pctxt, "lowFrequencyEnhancement", -1); /* decode multilingual */ invokeStartElement (pctxt, "multilingual", -1); stat = DECODEBIT (pctxt, &pvalue->multilingual); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multilingual); invokeEndElement (pctxt, "multilingual", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 1130U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* G7231AnnexCMode_g723AnnexCAudioMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245G7231AnnexCMode_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCMode_g723AnnexCAudioMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode highRateMode0 */ invokeStartElement (pctxt, "highRateMode0", -1); stat = decodeConsUInt8 (pctxt, &pvalue->highRateMode0, 27U, 78U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->highRateMode0); invokeEndElement (pctxt, "highRateMode0", -1); /* decode highRateMode1 */ invokeStartElement (pctxt, "highRateMode1", -1); stat = decodeConsUInt8 (pctxt, &pvalue->highRateMode1, 27U, 78U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->highRateMode1); invokeEndElement (pctxt, "highRateMode1", -1); /* decode lowRateMode0 */ invokeStartElement (pctxt, "lowRateMode0", -1); stat = decodeConsUInt8 (pctxt, &pvalue->lowRateMode0, 23U, 66U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->lowRateMode0); invokeEndElement (pctxt, "lowRateMode0", -1); /* decode lowRateMode1 */ invokeStartElement (pctxt, "lowRateMode1", -1); stat = decodeConsUInt8 (pctxt, &pvalue->lowRateMode1, 23U, 66U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->lowRateMode1); invokeEndElement (pctxt, "lowRateMode1", -1); /* decode sidMode0 */ invokeStartElement (pctxt, "sidMode0", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sidMode0, 6U, 17U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sidMode0); invokeEndElement (pctxt, "sidMode0", -1); /* decode sidMode1 */ invokeStartElement (pctxt, "sidMode1", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sidMode1, 6U, 17U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sidMode1); invokeEndElement (pctxt, "sidMode1", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* G7231AnnexCMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245G7231AnnexCMode (OOCTXT* pctxt, H245G7231AnnexCMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode maxAl_sduAudioFrames */ invokeStartElement (pctxt, "maxAl_sduAudioFrames", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxAl_sduAudioFrames, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxAl_sduAudioFrames); invokeEndElement (pctxt, "maxAl_sduAudioFrames", -1); /* decode silenceSuppression */ invokeStartElement (pctxt, "silenceSuppression", -1); stat = DECODEBIT (pctxt, &pvalue->silenceSuppression); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->silenceSuppression); invokeEndElement (pctxt, "silenceSuppression", -1); /* decode g723AnnexCAudioMode */ invokeStartElement (pctxt, "g723AnnexCAudioMode", -1); stat = asn1PD_H245G7231AnnexCMode_g723AnnexCAudioMode (pctxt, &pvalue->g723AnnexCAudioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g723AnnexCAudioMode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VBDMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VBDMode (OOCTXT* pctxt, H245VBDMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); pvalue->type = ALLOC_ASN1ELEM (pctxt, H245AudioMode); stat = asn1PD_H245AudioMode (pctxt, (H245AudioMode*)pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* AudioMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245AudioMode (OOCTXT* pctxt, H245AudioMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 13); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* g711Alaw64k */ case 1: invokeStartElement (pctxt, "g711Alaw64k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g711Alaw64k", -1); break; /* g711Alaw56k */ case 2: invokeStartElement (pctxt, "g711Alaw56k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g711Alaw56k", -1); break; /* g711Ulaw64k */ case 3: invokeStartElement (pctxt, "g711Ulaw64k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g711Ulaw64k", -1); break; /* g711Ulaw56k */ case 4: invokeStartElement (pctxt, "g711Ulaw56k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g711Ulaw56k", -1); break; /* g722_64k */ case 5: invokeStartElement (pctxt, "g722_64k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g722_64k", -1); break; /* g722_56k */ case 6: invokeStartElement (pctxt, "g722_56k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g722_56k", -1); break; /* g722_48k */ case 7: invokeStartElement (pctxt, "g722_48k", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g722_48k", -1); break; /* g728 */ case 8: invokeStartElement (pctxt, "g728", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g728", -1); break; /* g729 */ case 9: invokeStartElement (pctxt, "g729", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g729", -1); break; /* g729AnnexA */ case 10: invokeStartElement (pctxt, "g729AnnexA", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "g729AnnexA", -1); break; /* g7231 */ case 11: invokeStartElement (pctxt, "g7231", -1); pvalue->u.g7231 = ALLOC_ASN1ELEM (pctxt, H245AudioMode_g7231); stat = asn1PD_H245AudioMode_g7231 (pctxt, pvalue->u.g7231); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g7231", -1); break; /* is11172AudioMode */ case 12: invokeStartElement (pctxt, "is11172AudioMode", -1); pvalue->u.is11172AudioMode = ALLOC_ASN1ELEM (pctxt, H245IS11172AudioMode); stat = asn1PD_H245IS11172AudioMode (pctxt, pvalue->u.is11172AudioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "is11172AudioMode", -1); break; /* is13818AudioMode */ case 13: invokeStartElement (pctxt, "is13818AudioMode", -1); pvalue->u.is13818AudioMode = ALLOC_ASN1ELEM (pctxt, H245IS13818AudioMode); stat = asn1PD_H245IS13818AudioMode (pctxt, pvalue->u.is13818AudioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "is13818AudioMode", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 15; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* g729wAnnexB */ case 15: invokeStartElement (pctxt, "g729wAnnexB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g729wAnnexB, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g729wAnnexB); invokeEndElement (pctxt, "g729wAnnexB", -1); break; /* g729AnnexAwAnnexB */ case 16: invokeStartElement (pctxt, "g729AnnexAwAnnexB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.g729AnnexAwAnnexB, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.g729AnnexAwAnnexB); invokeEndElement (pctxt, "g729AnnexAwAnnexB", -1); break; /* g7231AnnexCMode */ case 17: invokeStartElement (pctxt, "g7231AnnexCMode", -1); pvalue->u.g7231AnnexCMode = ALLOC_ASN1ELEM (pctxt, H245G7231AnnexCMode); stat = asn1PD_H245G7231AnnexCMode (pctxt, pvalue->u.g7231AnnexCMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g7231AnnexCMode", -1); break; /* gsmFullRate */ case 18: invokeStartElement (pctxt, "gsmFullRate", -1); pvalue->u.gsmFullRate = ALLOC_ASN1ELEM (pctxt, H245GSMAudioCapability); stat = asn1PD_H245GSMAudioCapability (pctxt, pvalue->u.gsmFullRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gsmFullRate", -1); break; /* gsmHalfRate */ case 19: invokeStartElement (pctxt, "gsmHalfRate", -1); pvalue->u.gsmHalfRate = ALLOC_ASN1ELEM (pctxt, H245GSMAudioCapability); stat = asn1PD_H245GSMAudioCapability (pctxt, pvalue->u.gsmHalfRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gsmHalfRate", -1); break; /* gsmEnhancedFullRate */ case 20: invokeStartElement (pctxt, "gsmEnhancedFullRate", -1); pvalue->u.gsmEnhancedFullRate = ALLOC_ASN1ELEM (pctxt, H245GSMAudioCapability); stat = asn1PD_H245GSMAudioCapability (pctxt, pvalue->u.gsmEnhancedFullRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gsmEnhancedFullRate", -1); break; /* genericAudioMode */ case 21: invokeStartElement (pctxt, "genericAudioMode", -1); pvalue->u.genericAudioMode = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericAudioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericAudioMode", -1); break; /* g729Extensions */ case 22: invokeStartElement (pctxt, "g729Extensions", -1); pvalue->u.g729Extensions = ALLOC_ASN1ELEM (pctxt, H245G729Extensions); stat = asn1PD_H245G729Extensions (pctxt, pvalue->u.g729Extensions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "g729Extensions", -1); break; /* vbd */ case 23: invokeStartElement (pctxt, "vbd", -1); pvalue->u.vbd = ALLOC_ASN1ELEM (pctxt, H245VBDMode); stat = asn1PD_H245VBDMode (pctxt, pvalue->u.vbd); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "vbd", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* DataMode_application_nlpid */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataMode_application_nlpid (OOCTXT* pctxt, H245DataMode_application_nlpid* pvalue) { int stat = ASN_OK; /* decode nlpidProtocol */ invokeStartElement (pctxt, "nlpidProtocol", -1); stat = asn1PD_H245DataProtocolCapability (pctxt, &pvalue->nlpidProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nlpidProtocol", -1); /* decode nlpidData */ invokeStartElement (pctxt, "nlpidData", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->nlpidData); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->nlpidData.numocts, pvalue->nlpidData.data); invokeEndElement (pctxt, "nlpidData", -1); return (stat); } /**************************************************************/ /* */ /* DataMode_application_t38fax */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataMode_application_t38fax (OOCTXT* pctxt, H245DataMode_application_t38fax* pvalue) { int stat = ASN_OK; /* decode t38FaxProtocol */ invokeStartElement (pctxt, "t38FaxProtocol", -1); stat = asn1PD_H245DataProtocolCapability (pctxt, &pvalue->t38FaxProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxProtocol", -1); /* decode t38FaxProfile */ invokeStartElement (pctxt, "t38FaxProfile", -1); stat = asn1PD_H245T38FaxProfile (pctxt, &pvalue->t38FaxProfile); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxProfile", -1); return (stat); } /**************************************************************/ /* */ /* DataMode_application */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataMode_application (OOCTXT* pctxt, H245DataMode_application* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 9); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* t120 */ case 1: invokeStartElement (pctxt, "t120", -1); pvalue->u.t120 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t120); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t120", -1); break; /* dsm_cc */ case 2: invokeStartElement (pctxt, "dsm_cc", -1); pvalue->u.dsm_cc = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.dsm_cc); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dsm_cc", -1); break; /* userData */ case 3: invokeStartElement (pctxt, "userData", -1); pvalue->u.userData = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.userData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "userData", -1); break; /* t84 */ case 4: invokeStartElement (pctxt, "t84", -1); pvalue->u.t84 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t84); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t84", -1); break; /* t434 */ case 5: invokeStartElement (pctxt, "t434", -1); pvalue->u.t434 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t434); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t434", -1); break; /* h224 */ case 6: invokeStartElement (pctxt, "h224", -1); pvalue->u.h224 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.h224); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h224", -1); break; /* nlpid */ case 7: invokeStartElement (pctxt, "nlpid", -1); pvalue->u.nlpid = ALLOC_ASN1ELEM (pctxt, H245DataMode_application_nlpid); stat = asn1PD_H245DataMode_application_nlpid (pctxt, pvalue->u.nlpid); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nlpid", -1); break; /* dsvdControl */ case 8: invokeStartElement (pctxt, "dsvdControl", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dsvdControl", -1); break; /* h222DataPartitioning */ case 9: invokeStartElement (pctxt, "h222DataPartitioning", -1); pvalue->u.h222DataPartitioning = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.h222DataPartitioning); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h222DataPartitioning", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 11; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* t30fax */ case 11: invokeStartElement (pctxt, "t30fax", -1); pvalue->u.t30fax = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t30fax); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t30fax", -1); break; /* t140 */ case 12: invokeStartElement (pctxt, "t140", -1); pvalue->u.t140 = ALLOC_ASN1ELEM (pctxt, H245DataProtocolCapability); stat = asn1PD_H245DataProtocolCapability (pctxt, pvalue->u.t140); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t140", -1); break; /* t38fax */ case 13: invokeStartElement (pctxt, "t38fax", -1); pvalue->u.t38fax = ALLOC_ASN1ELEM (pctxt, H245DataMode_application_t38fax); stat = asn1PD_H245DataMode_application_t38fax (pctxt, pvalue->u.t38fax); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38fax", -1); break; /* genericDataMode */ case 14: invokeStartElement (pctxt, "genericDataMode", -1); pvalue->u.genericDataMode = ALLOC_ASN1ELEM (pctxt, H245GenericCapability); stat = asn1PD_H245GenericCapability (pctxt, pvalue->u.genericDataMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericDataMode", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* DataMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DataMode (OOCTXT* pctxt, H245DataMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode application */ invokeStartElement (pctxt, "application", -1); stat = asn1PD_H245DataMode_application (pctxt, &pvalue->application); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "application", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->bitRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H235Mode_mediaMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H235Mode_mediaMode (OOCTXT* pctxt, H245H235Mode_mediaMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* videoMode */ case 1: invokeStartElement (pctxt, "videoMode", -1); pvalue->u.videoMode = ALLOC_ASN1ELEM (pctxt, H245VideoMode); stat = asn1PD_H245VideoMode (pctxt, pvalue->u.videoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoMode", -1); break; /* audioMode */ case 2: invokeStartElement (pctxt, "audioMode", -1); pvalue->u.audioMode = ALLOC_ASN1ELEM (pctxt, H245AudioMode); stat = asn1PD_H245AudioMode (pctxt, pvalue->u.audioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioMode", -1); break; /* dataMode */ case 3: invokeStartElement (pctxt, "dataMode", -1); pvalue->u.dataMode = ALLOC_ASN1ELEM (pctxt, H245DataMode); stat = asn1PD_H245DataMode (pctxt, pvalue->u.dataMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataMode", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H235Mode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H235Mode (OOCTXT* pctxt, H245H235Mode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode encryptionAuthenticationAndIntegrity */ invokeStartElement (pctxt, "encryptionAuthenticationAndIntegrity", -1); stat = asn1PD_H245EncryptionAuthenticationAndIntegrity (pctxt, &pvalue->encryptionAuthenticationAndIntegrity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionAuthenticationAndIntegrity", -1); /* decode mediaMode */ invokeStartElement (pctxt, "mediaMode", -1); stat = asn1PD_H245H235Mode_mediaMode (pctxt, &pvalue->mediaMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaMode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingDTModeElement_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingDTModeElement_type (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* videoMode */ case 1: invokeStartElement (pctxt, "videoMode", -1); pvalue->u.videoMode = ALLOC_ASN1ELEM (pctxt, H245VideoMode); stat = asn1PD_H245VideoMode (pctxt, pvalue->u.videoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoMode", -1); break; /* audioMode */ case 2: invokeStartElement (pctxt, "audioMode", -1); pvalue->u.audioMode = ALLOC_ASN1ELEM (pctxt, H245AudioMode); stat = asn1PD_H245AudioMode (pctxt, pvalue->u.audioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioMode", -1); break; /* dataMode */ case 3: invokeStartElement (pctxt, "dataMode", -1); pvalue->u.dataMode = ALLOC_ASN1ELEM (pctxt, H245DataMode); stat = asn1PD_H245DataMode (pctxt, pvalue->u.dataMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataMode", -1); break; /* encryptionMode */ case 4: invokeStartElement (pctxt, "encryptionMode", -1); pvalue->u.encryptionMode = ALLOC_ASN1ELEM (pctxt, H245EncryptionMode); stat = asn1PD_H245EncryptionMode (pctxt, pvalue->u.encryptionMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionMode", -1); break; /* h235Mode */ case 5: invokeStartElement (pctxt, "h235Mode", -1); pvalue->u.h235Mode = ALLOC_ASN1ELEM (pctxt, H245H235Mode); stat = asn1PD_H245H235Mode (pctxt, pvalue->u.h235Mode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h235Mode", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingDTModeElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245RedundancyEncodingDTModeElement_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245RedundancyEncodingDTModeElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingDTModeElement* pvalue) { int stat = ASN_OK; H245RedundancyEncodingDTModeElement* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245RedundancyEncodingDTModeElement); stat = asn1PD_H245RedundancyEncodingDTModeElement (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingDTMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingDTMode (OOCTXT* pctxt, H245RedundancyEncodingDTMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode redundancyEncodingMethod */ invokeStartElement (pctxt, "redundancyEncodingMethod", -1); stat = asn1PD_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncodingMethod", -1); /* decode primary */ invokeStartElement (pctxt, "primary", -1); stat = asn1PD_H245RedundancyEncodingDTModeElement (pctxt, &pvalue->primary); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "primary", -1); /* decode secondary */ invokeStartElement (pctxt, "secondary", -1); stat = asn1PD_H245_SeqOfH245RedundancyEncodingDTModeElement (pctxt, &pvalue->secondary); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "secondary", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamElementMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245MultiplePayloadStreamElementMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); pvalue->type = ALLOC_ASN1ELEM (pctxt, H245ModeElementType); stat = asn1PD_H245ModeElementType (pctxt, (H245ModeElementType*)pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245MultiplePayloadStreamElementMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElementMode* pvalue) { int stat = ASN_OK; H245MultiplePayloadStreamElementMode* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MultiplePayloadStreamElementMode); stat = asn1PD_H245MultiplePayloadStreamElementMode (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplePayloadStreamMode (OOCTXT* pctxt, H245MultiplePayloadStreamMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode elements */ invokeStartElement (pctxt, "elements", -1); stat = asn1PD_H245_SeqOfH245MultiplePayloadStreamElementMode (pctxt, &pvalue->elements); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elements", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream_differentPort */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_differentPort* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.protectedPayloadTypePresent = optbit; /* decode protectedSessionID */ invokeStartElement (pctxt, "protectedSessionID", -1); stat = decodeConsUInt8 (pctxt, &pvalue->protectedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->protectedSessionID); invokeEndElement (pctxt, "protectedSessionID", -1); /* decode protectedPayloadType */ if (pvalue->m.protectedPayloadTypePresent) { invokeStartElement (pctxt, "protectedPayloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->protectedPayloadType, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->protectedPayloadType); invokeEndElement (pctxt, "protectedPayloadType", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream_samePort */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode_separateStream_samePort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_samePort* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode protectedType */ invokeStartElement (pctxt, "protectedType", -1); pvalue->protectedType = ALLOC_ASN1ELEM (pctxt, H245ModeElementType); stat = asn1PD_H245ModeElementType (pctxt, (H245ModeElementType*)pvalue->protectedType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protectedType", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode_separateStream (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* differentPort */ case 0: invokeStartElement (pctxt, "differentPort", -1); pvalue->u.differentPort = ALLOC_ASN1ELEM (pctxt, H245FECMode_rfc2733Mode_mode_separateStream_differentPort); stat = asn1PD_H245FECMode_rfc2733Mode_mode_separateStream_differentPort (pctxt, pvalue->u.differentPort); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "differentPort", -1); break; /* samePort */ case 1: invokeStartElement (pctxt, "samePort", -1); pvalue->u.samePort = ALLOC_ASN1ELEM (pctxt, H245FECMode_rfc2733Mode_mode_separateStream_samePort); stat = asn1PD_H245FECMode_rfc2733Mode_mode_separateStream_samePort (pctxt, pvalue->u.samePort); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "samePort", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECMode_rfc2733Mode_mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* redundancyEncoding */ case 0: invokeStartElement (pctxt, "redundancyEncoding", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "redundancyEncoding", -1); break; /* separateStream */ case 1: invokeStartElement (pctxt, "separateStream", -1); pvalue->u.separateStream = ALLOC_ASN1ELEM (pctxt, H245FECMode_rfc2733Mode_mode_separateStream); stat = asn1PD_H245FECMode_rfc2733Mode_mode_separateStream (pctxt, pvalue->u.separateStream); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "separateStream", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECMode_rfc2733Mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode mode */ invokeStartElement (pctxt, "mode", -1); stat = asn1PD_H245FECMode_rfc2733Mode_mode (pctxt, &pvalue->mode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FECMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FECMode (OOCTXT* pctxt, H245FECMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* rfc2733Mode */ case 0: invokeStartElement (pctxt, "rfc2733Mode", -1); pvalue->u.rfc2733Mode = ALLOC_ASN1ELEM (pctxt, H245FECMode_rfc2733Mode); stat = asn1PD_H245FECMode_rfc2733Mode (pctxt, pvalue->u.rfc2733Mode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rfc2733Mode", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ModeElementType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ModeElementType (OOCTXT* pctxt, H245ModeElementType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* videoMode */ case 1: invokeStartElement (pctxt, "videoMode", -1); pvalue->u.videoMode = ALLOC_ASN1ELEM (pctxt, H245VideoMode); stat = asn1PD_H245VideoMode (pctxt, pvalue->u.videoMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoMode", -1); break; /* audioMode */ case 2: invokeStartElement (pctxt, "audioMode", -1); pvalue->u.audioMode = ALLOC_ASN1ELEM (pctxt, H245AudioMode); stat = asn1PD_H245AudioMode (pctxt, pvalue->u.audioMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioMode", -1); break; /* dataMode */ case 3: invokeStartElement (pctxt, "dataMode", -1); pvalue->u.dataMode = ALLOC_ASN1ELEM (pctxt, H245DataMode); stat = asn1PD_H245DataMode (pctxt, pvalue->u.dataMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataMode", -1); break; /* encryptionMode */ case 4: invokeStartElement (pctxt, "encryptionMode", -1); pvalue->u.encryptionMode = ALLOC_ASN1ELEM (pctxt, H245EncryptionMode); stat = asn1PD_H245EncryptionMode (pctxt, pvalue->u.encryptionMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionMode", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* h235Mode */ case 6: invokeStartElement (pctxt, "h235Mode", -1); pvalue->u.h235Mode = ALLOC_ASN1ELEM (pctxt, H245H235Mode); stat = asn1PD_H245H235Mode (pctxt, pvalue->u.h235Mode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h235Mode", -1); break; /* multiplexedStreamMode */ case 7: invokeStartElement (pctxt, "multiplexedStreamMode", -1); pvalue->u.multiplexedStreamMode = ALLOC_ASN1ELEM (pctxt, H245MultiplexedStreamParameter); stat = asn1PD_H245MultiplexedStreamParameter (pctxt, pvalue->u.multiplexedStreamMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexedStreamMode", -1); break; /* redundancyEncodingDTMode */ case 8: invokeStartElement (pctxt, "redundancyEncodingDTMode", -1); pvalue->u.redundancyEncodingDTMode = ALLOC_ASN1ELEM (pctxt, H245RedundancyEncodingDTMode); stat = asn1PD_H245RedundancyEncodingDTMode (pctxt, pvalue->u.redundancyEncodingDTMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncodingDTMode", -1); break; /* multiplePayloadStreamMode */ case 9: invokeStartElement (pctxt, "multiplePayloadStreamMode", -1); pvalue->u.multiplePayloadStreamMode = ALLOC_ASN1ELEM (pctxt, H245MultiplePayloadStreamMode); stat = asn1PD_H245MultiplePayloadStreamMode (pctxt, pvalue->u.multiplePayloadStreamMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplePayloadStreamMode", -1); break; /* fecMode */ case 10: invokeStartElement (pctxt, "fecMode", -1); pvalue->u.fecMode = ALLOC_ASN1ELEM (pctxt, H245FECMode); stat = asn1PD_H245FECMode (pctxt, pvalue->u.fecMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fecMode", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H223ModeParameters_adaptationLayerType_al3 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223ModeParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType_al3* pvalue) { int stat = ASN_OK; /* decode controlFieldOctets */ invokeStartElement (pctxt, "controlFieldOctets", -1); stat = decodeConsUInt8 (pctxt, &pvalue->controlFieldOctets, 0U, 2U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->controlFieldOctets); invokeEndElement (pctxt, "controlFieldOctets", -1); /* decode sendBufferSize */ invokeStartElement (pctxt, "sendBufferSize", -1); stat = decodeConsUnsigned (pctxt, &pvalue->sendBufferSize, 0U, 16777215U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sendBufferSize); invokeEndElement (pctxt, "sendBufferSize", -1); return (stat); } /**************************************************************/ /* */ /* H223ModeParameters_adaptationLayerType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223ModeParameters_adaptationLayerType (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* al1Framed */ case 1: invokeStartElement (pctxt, "al1Framed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al1Framed", -1); break; /* al1NotFramed */ case 2: invokeStartElement (pctxt, "al1NotFramed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al1NotFramed", -1); break; /* al2WithoutSequenceNumbers */ case 3: invokeStartElement (pctxt, "al2WithoutSequenceNumbers", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al2WithoutSequenceNumbers", -1); break; /* al2WithSequenceNumbers */ case 4: invokeStartElement (pctxt, "al2WithSequenceNumbers", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "al2WithSequenceNumbers", -1); break; /* al3 */ case 5: invokeStartElement (pctxt, "al3", -1); pvalue->u.al3 = ALLOC_ASN1ELEM (pctxt, H245H223ModeParameters_adaptationLayerType_al3); stat = asn1PD_H245H223ModeParameters_adaptationLayerType_al3 (pctxt, pvalue->u.al3); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al3", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* al1M */ case 7: invokeStartElement (pctxt, "al1M", -1); pvalue->u.al1M = ALLOC_ASN1ELEM (pctxt, H245H223AL1MParameters); stat = asn1PD_H245H223AL1MParameters (pctxt, pvalue->u.al1M); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al1M", -1); break; /* al2M */ case 8: invokeStartElement (pctxt, "al2M", -1); pvalue->u.al2M = ALLOC_ASN1ELEM (pctxt, H245H223AL2MParameters); stat = asn1PD_H245H223AL2MParameters (pctxt, pvalue->u.al2M); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al2M", -1); break; /* al3M */ case 9: invokeStartElement (pctxt, "al3M", -1); pvalue->u.al3M = ALLOC_ASN1ELEM (pctxt, H245H223AL3MParameters); stat = asn1PD_H245H223AL3MParameters (pctxt, pvalue->u.al3M); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "al3M", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H223ModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223ModeParameters (OOCTXT* pctxt, H245H223ModeParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode adaptationLayerType */ invokeStartElement (pctxt, "adaptationLayerType", -1); stat = asn1PD_H245H223ModeParameters_adaptationLayerType (pctxt, &pvalue->adaptationLayerType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "adaptationLayerType", -1); /* decode segmentableFlag */ invokeStartElement (pctxt, "segmentableFlag", -1); stat = DECODEBIT (pctxt, &pvalue->segmentableFlag); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->segmentableFlag); invokeEndElement (pctxt, "segmentableFlag", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* V76ModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245V76ModeParameters (OOCTXT* pctxt, H245V76ModeParameters* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* suspendResumewAddress */ case 0: invokeStartElement (pctxt, "suspendResumewAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "suspendResumewAddress", -1); break; /* suspendResumewoAddress */ case 1: invokeStartElement (pctxt, "suspendResumewoAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "suspendResumewoAddress", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingMode_secondaryEncoding */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingMode_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingMode_secondaryEncoding* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* audioData */ case 1: invokeStartElement (pctxt, "audioData", -1); pvalue->u.audioData = ALLOC_ASN1ELEM (pctxt, H245AudioMode); stat = asn1PD_H245AudioMode (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioData", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RedundancyEncodingMode (OOCTXT* pctxt, H245RedundancyEncodingMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.secondaryEncodingPresent = optbit; /* decode redundancyEncodingMethod */ invokeStartElement (pctxt, "redundancyEncodingMethod", -1); stat = asn1PD_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncodingMethod", -1); /* decode secondaryEncoding */ if (pvalue->m.secondaryEncodingPresent) { invokeStartElement (pctxt, "secondaryEncoding", -1); stat = asn1PD_H245RedundancyEncodingMode_secondaryEncoding (pctxt, &pvalue->secondaryEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "secondaryEncoding", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H2250ModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250ModeParameters (OOCTXT* pctxt, H245H2250ModeParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.redundancyEncodingModePresent = optbit; /* decode redundancyEncodingMode */ if (pvalue->m.redundancyEncodingModePresent) { invokeStartElement (pctxt, "redundancyEncodingMode", -1); stat = asn1PD_H245RedundancyEncodingMode (pctxt, &pvalue->redundancyEncodingMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncodingMode", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexedStreamModeParameters (OOCTXT* pctxt, H245MultiplexedStreamModeParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ModeElement */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ModeElement (OOCTXT* pctxt, H245ModeElement* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.h223ModeParametersPresent = optbit; /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245ModeElementType (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); /* decode h223ModeParameters */ if (pvalue->m.h223ModeParametersPresent) { invokeStartElement (pctxt, "h223ModeParameters", -1); stat = asn1PD_H245H223ModeParameters (pctxt, &pvalue->h223ModeParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223ModeParameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 4 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.v76ModeParametersPresent = 1; invokeStartElement (pctxt, "v76ModeParameters", -1); stat = asn1PD_H245V76ModeParameters (pctxt, &pvalue->v76ModeParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "v76ModeParameters", -1); break; case 1: pvalue->m.h2250ModeParametersPresent = 1; invokeStartElement (pctxt, "h2250ModeParameters", -1); stat = asn1PD_H245H2250ModeParameters (pctxt, &pvalue->h2250ModeParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h2250ModeParameters", -1); break; case 2: pvalue->m.genericModeParametersPresent = 1; invokeStartElement (pctxt, "genericModeParameters", -1); stat = asn1PD_H245GenericCapability (pctxt, &pvalue->genericModeParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericModeParameters", -1); break; case 3: pvalue->m.multiplexedStreamModeParametersPresent = 1; invokeStartElement (pctxt, "multiplexedStreamModeParameters", -1); stat = asn1PD_H245MultiplexedStreamModeParameters (pctxt, &pvalue->multiplexedStreamModeParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexedStreamModeParameters", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* ModeDescription */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ModeDescription (OOCTXT* pctxt, H245ModeDescription* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245ModeElement* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245ModeElement); stat = asn1PD_H245ModeElement (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* RequestMode_requestedModes */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMode_requestedModes (OOCTXT* pctxt, H245RequestMode_requestedModes* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245ModeDescription* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245ModeDescription); stat = asn1PD_H245ModeDescription (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* RequestMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMode (OOCTXT* pctxt, H245RequestMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode requestedModes */ invokeStartElement (pctxt, "requestedModes", -1); stat = asn1PD_H245RequestMode_requestedModes (pctxt, &pvalue->requestedModes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestedModes", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RoundTripDelayRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RoundTripDelayRequest (OOCTXT* pctxt, H245RoundTripDelayRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopRequest_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopRequest_type (OOCTXT* pctxt, H245MaintenanceLoopRequest_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* systemLoop */ case 0: invokeStartElement (pctxt, "systemLoop", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "systemLoop", -1); break; /* mediaLoop */ case 1: invokeStartElement (pctxt, "mediaLoop", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.mediaLoop); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaLoop", -1); break; /* logicalChannelLoop */ case 2: invokeStartElement (pctxt, "logicalChannelLoop", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.logicalChannelLoop); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelLoop", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopRequest (OOCTXT* pctxt, H245MaintenanceLoopRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245MaintenanceLoopRequest_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CommunicationModeRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommunicationModeRequest (OOCTXT* pctxt, H245CommunicationModeRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* Criteria */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Criteria (OOCTXT* pctxt, H245Criteria* pvalue) { static Asn1SizeCnst value_lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode field */ invokeStartElement (pctxt, "field", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->field); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->field.numids, pvalue->field.subid); invokeEndElement (pctxt, "field", -1); /* decode value */ invokeStartElement (pctxt, "value", -1); addSizeConstraint (pctxt, &value_lsize1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->value); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->value.numocts, pvalue->value.data); invokeEndElement (pctxt, "value", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CertSelectionCriteria */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CertSelectionCriteria (OOCTXT* pctxt, H245CertSelectionCriteria* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H245Criteria* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245Criteria); stat = asn1PD_H245Criteria (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* ConferenceRequest_requestTerminalCertificate */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceRequest_requestTerminalCertificate (OOCTXT* pctxt, H245ConferenceRequest_requestTerminalCertificate* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.terminalLabelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.certSelectionCriteriaPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.sRandomPresent = optbit; /* decode terminalLabel */ if (pvalue->m.terminalLabelPresent) { invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); } /* decode certSelectionCriteria */ if (pvalue->m.certSelectionCriteriaPresent) { invokeStartElement (pctxt, "certSelectionCriteria", -1); stat = asn1PD_H245CertSelectionCriteria (pctxt, &pvalue->certSelectionCriteria); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "certSelectionCriteria", -1); } /* decode sRandom */ if (pvalue->m.sRandomPresent) { invokeStartElement (pctxt, "sRandom", -1); stat = decodeConsUnsigned (pctxt, &pvalue->sRandom, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sRandom); invokeEndElement (pctxt, "sRandom", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RemoteMCRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RemoteMCRequest (OOCTXT* pctxt, H245RemoteMCRequest* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* masterActivate */ case 0: invokeStartElement (pctxt, "masterActivate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "masterActivate", -1); break; /* slaveActivate */ case 1: invokeStartElement (pctxt, "slaveActivate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "slaveActivate", -1); break; /* deActivate */ case 2: invokeStartElement (pctxt, "deActivate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "deActivate", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ConferenceRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceRequest (OOCTXT* pctxt, H245ConferenceRequest* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 7); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* terminalListRequest */ case 0: invokeStartElement (pctxt, "terminalListRequest", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "terminalListRequest", -1); break; /* makeMeChair */ case 1: invokeStartElement (pctxt, "makeMeChair", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "makeMeChair", -1); break; /* cancelMakeMeChair */ case 2: invokeStartElement (pctxt, "cancelMakeMeChair", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelMakeMeChair", -1); break; /* dropTerminal */ case 3: invokeStartElement (pctxt, "dropTerminal", -1); pvalue->u.dropTerminal = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.dropTerminal); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dropTerminal", -1); break; /* requestTerminalID */ case 4: invokeStartElement (pctxt, "requestTerminalID", -1); pvalue->u.requestTerminalID = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.requestTerminalID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestTerminalID", -1); break; /* enterH243Password */ case 5: invokeStartElement (pctxt, "enterH243Password", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "enterH243Password", -1); break; /* enterH243TerminalID */ case 6: invokeStartElement (pctxt, "enterH243TerminalID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "enterH243TerminalID", -1); break; /* enterH243ConferenceID */ case 7: invokeStartElement (pctxt, "enterH243ConferenceID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "enterH243ConferenceID", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 9; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* enterExtensionAddress */ case 9: invokeStartElement (pctxt, "enterExtensionAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "enterExtensionAddress", -1); break; /* requestChairTokenOwner */ case 10: invokeStartElement (pctxt, "requestChairTokenOwner", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "requestChairTokenOwner", -1); break; /* requestTerminalCertificate */ case 11: invokeStartElement (pctxt, "requestTerminalCertificate", -1); pvalue->u.requestTerminalCertificate = ALLOC_ASN1ELEM (pctxt, H245ConferenceRequest_requestTerminalCertificate); stat = asn1PD_H245ConferenceRequest_requestTerminalCertificate (pctxt, pvalue->u.requestTerminalCertificate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestTerminalCertificate", -1); break; /* broadcastMyLogicalChannel */ case 12: invokeStartElement (pctxt, "broadcastMyLogicalChannel", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.broadcastMyLogicalChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "broadcastMyLogicalChannel", -1); break; /* makeTerminalBroadcaster */ case 13: invokeStartElement (pctxt, "makeTerminalBroadcaster", -1); pvalue->u.makeTerminalBroadcaster = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.makeTerminalBroadcaster); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "makeTerminalBroadcaster", -1); break; /* sendThisSource */ case 14: invokeStartElement (pctxt, "sendThisSource", -1); pvalue->u.sendThisSource = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.sendThisSource); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sendThisSource", -1); break; /* requestAllTerminalIDs */ case 15: invokeStartElement (pctxt, "requestAllTerminalIDs", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "requestAllTerminalIDs", -1); break; /* remoteMCRequest */ case 16: invokeStartElement (pctxt, "remoteMCRequest", -1); pvalue->u.remoteMCRequest = ALLOC_ASN1ELEM (pctxt, H245RemoteMCRequest); stat = asn1PD_H245RemoteMCRequest (pctxt, pvalue->u.remoteMCRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "remoteMCRequest", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_callInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkRequest_callInformation (OOCTXT* pctxt, H245MultilinkRequest_callInformation* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode maxNumberOfAdditionalConnections */ invokeStartElement (pctxt, "maxNumberOfAdditionalConnections", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maxNumberOfAdditionalConnections, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maxNumberOfAdditionalConnections); invokeEndElement (pctxt, "maxNumberOfAdditionalConnections", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* DialingInformationNetworkType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DialingInformationNetworkType (OOCTXT* pctxt, H245DialingInformationNetworkType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* n_isdn */ case 1: invokeStartElement (pctxt, "n_isdn", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "n_isdn", -1); break; /* gstn */ case 2: invokeStartElement (pctxt, "gstn", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "gstn", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* mobile */ case 4: invokeStartElement (pctxt, "mobile", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "mobile", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* DialingInformationNumber_networkType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DialingInformationNumber_networkType (OOCTXT* pctxt, H245DialingInformationNumber_networkType* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 255, 0 }; int stat = ASN_OK; H245DialingInformationNetworkType* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245DialingInformationNetworkType); stat = asn1PD_H245DialingInformationNetworkType (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* DialingInformationNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DialingInformationNumber (OOCTXT* pctxt, H245DialingInformationNumber* pvalue) { static Asn1SizeCnst networkAddress_lsize1 = { 0, 0, 40, 0 }; static Asn1SizeCnst subAddress_lsize1 = { 0, 1, 40, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.subAddressPresent = optbit; /* decode networkAddress */ invokeStartElement (pctxt, "networkAddress", -1); addSizeConstraint (pctxt, &networkAddress_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->networkAddress, NUM_CANSET, 4, 4, 4); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->networkAddress); invokeEndElement (pctxt, "networkAddress", -1); /* decode subAddress */ if (pvalue->m.subAddressPresent) { invokeStartElement (pctxt, "subAddress", -1); addSizeConstraint (pctxt, &subAddress_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->subAddress, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->subAddress); invokeEndElement (pctxt, "subAddress", -1); } /* decode networkType */ invokeStartElement (pctxt, "networkType", -1); stat = asn1PD_H245DialingInformationNumber_networkType (pctxt, &pvalue->networkType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "networkType", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* DialingInformation_differential */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DialingInformation_differential (OOCTXT* pctxt, H245DialingInformation_differential* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; H245DialingInformationNumber* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245DialingInformationNumber); stat = asn1PD_H245DialingInformationNumber (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* DialingInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H245DialingInformation (OOCTXT* pctxt, H245DialingInformation* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* differential */ case 1: invokeStartElement (pctxt, "differential", -1); pvalue->u.differential = ALLOC_ASN1ELEM (pctxt, H245DialingInformation_differential); stat = asn1PD_H245DialingInformation_differential (pctxt, pvalue->u.differential); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "differential", -1); break; /* infoNotAvailable */ case 2: invokeStartElement (pctxt, "infoNotAvailable", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.infoNotAvailable, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.infoNotAvailable); invokeEndElement (pctxt, "infoNotAvailable", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_addConnection */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkRequest_addConnection (OOCTXT* pctxt, H245MultilinkRequest_addConnection* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode dialingInformation */ invokeStartElement (pctxt, "dialingInformation", -1); stat = asn1PD_H245DialingInformation (pctxt, &pvalue->dialingInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dialingInformation", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConnectionIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConnectionIdentifier (OOCTXT* pctxt, H245ConnectionIdentifier* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode channelTag */ invokeStartElement (pctxt, "channelTag", -1); stat = decodeConsUnsigned (pctxt, &pvalue->channelTag, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->channelTag); invokeEndElement (pctxt, "channelTag", -1); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = decodeConsUnsigned (pctxt, &pvalue->sequenceNumber, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sequenceNumber); invokeEndElement (pctxt, "sequenceNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_removeConnection */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkRequest_removeConnection (OOCTXT* pctxt, H245MultilinkRequest_removeConnection* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode connectionIdentifier */ invokeStartElement (pctxt, "connectionIdentifier", -1); stat = asn1PD_H245ConnectionIdentifier (pctxt, &pvalue->connectionIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectionIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_maximumHeaderInterval_requestType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkRequest_maximumHeaderInterval_requestType (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval_requestType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* currentIntervalInformation */ case 0: invokeStartElement (pctxt, "currentIntervalInformation", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "currentIntervalInformation", -1); break; /* requestedInterval */ case 1: invokeStartElement (pctxt, "requestedInterval", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.requestedInterval, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.requestedInterval); invokeEndElement (pctxt, "requestedInterval", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_maximumHeaderInterval */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkRequest_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode requestType */ invokeStartElement (pctxt, "requestType", -1); stat = asn1PD_H245MultilinkRequest_maximumHeaderInterval_requestType (pctxt, &pvalue->requestType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestType", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkRequest (OOCTXT* pctxt, H245MultilinkRequest* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* callInformation */ case 1: invokeStartElement (pctxt, "callInformation", -1); pvalue->u.callInformation = ALLOC_ASN1ELEM (pctxt, H245MultilinkRequest_callInformation); stat = asn1PD_H245MultilinkRequest_callInformation (pctxt, pvalue->u.callInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callInformation", -1); break; /* addConnection */ case 2: invokeStartElement (pctxt, "addConnection", -1); pvalue->u.addConnection = ALLOC_ASN1ELEM (pctxt, H245MultilinkRequest_addConnection); stat = asn1PD_H245MultilinkRequest_addConnection (pctxt, pvalue->u.addConnection); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "addConnection", -1); break; /* removeConnection */ case 3: invokeStartElement (pctxt, "removeConnection", -1); pvalue->u.removeConnection = ALLOC_ASN1ELEM (pctxt, H245MultilinkRequest_removeConnection); stat = asn1PD_H245MultilinkRequest_removeConnection (pctxt, pvalue->u.removeConnection); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "removeConnection", -1); break; /* maximumHeaderInterval */ case 4: invokeStartElement (pctxt, "maximumHeaderInterval", -1); pvalue->u.maximumHeaderInterval = ALLOC_ASN1ELEM (pctxt, H245MultilinkRequest_maximumHeaderInterval); stat = asn1PD_H245MultilinkRequest_maximumHeaderInterval (pctxt, pvalue->u.maximumHeaderInterval); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maximumHeaderInterval", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MaximumBitRate */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaximumBitRate (OOCTXT* pctxt, H245MaximumBitRate* pvalue) { int stat = ASN_OK; stat = decodeConsUnsigned (pctxt, pvalue, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245LogicalChannelRateRequest (OOCTXT* pctxt, H245LogicalChannelRateRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); /* decode maximumBitRate */ invokeStartElement (pctxt, "maximumBitRate", -1); stat = asn1PD_H245MaximumBitRate (pctxt, &pvalue->maximumBitRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maximumBitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMessage (OOCTXT* pctxt, H245RequestMessage* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 10); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* masterSlaveDetermination */ case 1: invokeStartElement (pctxt, "masterSlaveDetermination", -1); pvalue->u.masterSlaveDetermination = ALLOC_ASN1ELEM (pctxt, H245MasterSlaveDetermination); stat = asn1PD_H245MasterSlaveDetermination (pctxt, pvalue->u.masterSlaveDetermination); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "masterSlaveDetermination", -1); break; /* terminalCapabilitySet */ case 2: invokeStartElement (pctxt, "terminalCapabilitySet", -1); pvalue->u.terminalCapabilitySet = ALLOC_ASN1ELEM (pctxt, H245TerminalCapabilitySet); stat = asn1PD_H245TerminalCapabilitySet (pctxt, pvalue->u.terminalCapabilitySet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalCapabilitySet", -1); break; /* openLogicalChannel */ case 3: invokeStartElement (pctxt, "openLogicalChannel", -1); pvalue->u.openLogicalChannel = ALLOC_ASN1ELEM (pctxt, H245OpenLogicalChannel); stat = asn1PD_H245OpenLogicalChannel (pctxt, pvalue->u.openLogicalChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "openLogicalChannel", -1); break; /* closeLogicalChannel */ case 4: invokeStartElement (pctxt, "closeLogicalChannel", -1); pvalue->u.closeLogicalChannel = ALLOC_ASN1ELEM (pctxt, H245CloseLogicalChannel); stat = asn1PD_H245CloseLogicalChannel (pctxt, pvalue->u.closeLogicalChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "closeLogicalChannel", -1); break; /* requestChannelClose */ case 5: invokeStartElement (pctxt, "requestChannelClose", -1); pvalue->u.requestChannelClose = ALLOC_ASN1ELEM (pctxt, H245RequestChannelClose); stat = asn1PD_H245RequestChannelClose (pctxt, pvalue->u.requestChannelClose); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestChannelClose", -1); break; /* multiplexEntrySend */ case 6: invokeStartElement (pctxt, "multiplexEntrySend", -1); pvalue->u.multiplexEntrySend = ALLOC_ASN1ELEM (pctxt, H245MultiplexEntrySend); stat = asn1PD_H245MultiplexEntrySend (pctxt, pvalue->u.multiplexEntrySend); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexEntrySend", -1); break; /* requestMultiplexEntry */ case 7: invokeStartElement (pctxt, "requestMultiplexEntry", -1); pvalue->u.requestMultiplexEntry = ALLOC_ASN1ELEM (pctxt, H245RequestMultiplexEntry); stat = asn1PD_H245RequestMultiplexEntry (pctxt, pvalue->u.requestMultiplexEntry); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestMultiplexEntry", -1); break; /* requestMode */ case 8: invokeStartElement (pctxt, "requestMode", -1); pvalue->u.requestMode = ALLOC_ASN1ELEM (pctxt, H245RequestMode); stat = asn1PD_H245RequestMode (pctxt, pvalue->u.requestMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestMode", -1); break; /* roundTripDelayRequest */ case 9: invokeStartElement (pctxt, "roundTripDelayRequest", -1); pvalue->u.roundTripDelayRequest = ALLOC_ASN1ELEM (pctxt, H245RoundTripDelayRequest); stat = asn1PD_H245RoundTripDelayRequest (pctxt, pvalue->u.roundTripDelayRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "roundTripDelayRequest", -1); break; /* maintenanceLoopRequest */ case 10: invokeStartElement (pctxt, "maintenanceLoopRequest", -1); pvalue->u.maintenanceLoopRequest = ALLOC_ASN1ELEM (pctxt, H245MaintenanceLoopRequest); stat = asn1PD_H245MaintenanceLoopRequest (pctxt, pvalue->u.maintenanceLoopRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maintenanceLoopRequest", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 12; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* communicationModeRequest */ case 12: invokeStartElement (pctxt, "communicationModeRequest", -1); pvalue->u.communicationModeRequest = ALLOC_ASN1ELEM (pctxt, H245CommunicationModeRequest); stat = asn1PD_H245CommunicationModeRequest (pctxt, pvalue->u.communicationModeRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "communicationModeRequest", -1); break; /* conferenceRequest */ case 13: invokeStartElement (pctxt, "conferenceRequest", -1); pvalue->u.conferenceRequest = ALLOC_ASN1ELEM (pctxt, H245ConferenceRequest); stat = asn1PD_H245ConferenceRequest (pctxt, pvalue->u.conferenceRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceRequest", -1); break; /* multilinkRequest */ case 14: invokeStartElement (pctxt, "multilinkRequest", -1); pvalue->u.multilinkRequest = ALLOC_ASN1ELEM (pctxt, H245MultilinkRequest); stat = asn1PD_H245MultilinkRequest (pctxt, pvalue->u.multilinkRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multilinkRequest", -1); break; /* logicalChannelRateRequest */ case 15: invokeStartElement (pctxt, "logicalChannelRateRequest", -1); pvalue->u.logicalChannelRateRequest = ALLOC_ASN1ELEM (pctxt, H245LogicalChannelRateRequest); stat = asn1PD_H245LogicalChannelRateRequest (pctxt, pvalue->u.logicalChannelRateRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelRateRequest", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationAck_decision */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MasterSlaveDeterminationAck_decision (OOCTXT* pctxt, H245MasterSlaveDeterminationAck_decision* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* master */ case 0: invokeStartElement (pctxt, "master", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "master", -1); break; /* slave */ case 1: invokeStartElement (pctxt, "slave", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "slave", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MasterSlaveDeterminationAck (OOCTXT* pctxt, H245MasterSlaveDeterminationAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode decision */ invokeStartElement (pctxt, "decision", -1); stat = asn1PD_H245MasterSlaveDeterminationAck_decision (pctxt, &pvalue->decision); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "decision", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MasterSlaveDeterminationReject_cause (OOCTXT* pctxt, H245MasterSlaveDeterminationReject_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* identicalNumbers */ case 0: invokeStartElement (pctxt, "identicalNumbers", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "identicalNumbers", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MasterSlaveDeterminationReject (OOCTXT* pctxt, H245MasterSlaveDeterminationReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245MasterSlaveDeterminationReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySetAck (OOCTXT* pctxt, H245TerminalCapabilitySetAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetReject_cause_tableEntryCapacityExce */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* highestEntryNumberProcessed */ case 0: invokeStartElement (pctxt, "highestEntryNumberProcessed", -1); stat = asn1PD_H245CapabilityTableEntryNumber (pctxt, &pvalue->u.highestEntryNumberProcessed); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "highestEntryNumberProcessed", -1); break; /* noneProcessed */ case 1: invokeStartElement (pctxt, "noneProcessed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noneProcessed", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySetReject_cause (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unspecified */ case 0: invokeStartElement (pctxt, "unspecified", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unspecified", -1); break; /* undefinedTableEntryUsed */ case 1: invokeStartElement (pctxt, "undefinedTableEntryUsed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedTableEntryUsed", -1); break; /* descriptorCapacityExceeded */ case 2: invokeStartElement (pctxt, "descriptorCapacityExceeded", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "descriptorCapacityExceeded", -1); break; /* tableEntryCapacityExceeded */ case 3: invokeStartElement (pctxt, "tableEntryCapacityExceeded", -1); pvalue->u.tableEntryCapacityExceeded = ALLOC_ASN1ELEM (pctxt, H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded); stat = asn1PD_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded (pctxt, pvalue->u.tableEntryCapacityExceeded); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tableEntryCapacityExceeded", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySetReject (OOCTXT* pctxt, H245TerminalCapabilitySetReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245TerminalCapabilitySetReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck_reverseLogicalChannelParameters_mu */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* h222LogicalChannelParameters */ case 0: invokeStartElement (pctxt, "h222LogicalChannelParameters", -1); pvalue->u.h222LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245H222LogicalChannelParameters); stat = asn1PD_H245H222LogicalChannelParameters (pctxt, pvalue->u.h222LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h222LogicalChannelParameters", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* h2250LogicalChannelParameters */ case 2: invokeStartElement (pctxt, "h2250LogicalChannelParameters", -1); pvalue->u.h2250LogicalChannelParameters = ALLOC_ASN1ELEM (pctxt, H245H2250LogicalChannelParameters); stat = asn1PD_H245H2250LogicalChannelParameters (pctxt, pvalue->u.h2250LogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h2250LogicalChannelParameters", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck_reverseLogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannelAck_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.portNumberPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.multiplexParametersPresent = optbit; /* decode reverseLogicalChannelNumber */ invokeStartElement (pctxt, "reverseLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->reverseLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reverseLogicalChannelNumber", -1); /* decode portNumber */ if (pvalue->m.portNumberPresent) { invokeStartElement (pctxt, "portNumber", -1); stat = decodeConsUInt16 (pctxt, &pvalue->portNumber, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->portNumber); invokeEndElement (pctxt, "portNumber", -1); } /* decode multiplexParameters */ if (pvalue->m.multiplexParametersPresent) { invokeStartElement (pctxt, "multiplexParameters", -1); stat = asn1PD_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters (pctxt, &pvalue->multiplexParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexParameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.replacementForPresent = 1; invokeStartElement (pctxt, "replacementFor", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->replacementFor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "replacementFor", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H2250LogicalChannelAckParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250LogicalChannelAckParameters (OOCTXT* pctxt, H245H2250LogicalChannelAckParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.sessionIDPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaChannelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaControlChannelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.dynamicRTPPayloadTypePresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } /* decode sessionID */ if (pvalue->m.sessionIDPresent) { invokeStartElement (pctxt, "sessionID", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sessionID, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sessionID); invokeEndElement (pctxt, "sessionID", -1); } /* decode mediaChannel */ if (pvalue->m.mediaChannelPresent) { invokeStartElement (pctxt, "mediaChannel", -1); stat = asn1PD_H245TransportAddress (pctxt, &pvalue->mediaChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaChannel", -1); } /* decode mediaControlChannel */ if (pvalue->m.mediaControlChannelPresent) { invokeStartElement (pctxt, "mediaControlChannel", -1); stat = asn1PD_H245TransportAddress (pctxt, &pvalue->mediaControlChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaControlChannel", -1); } /* decode dynamicRTPPayloadType */ if (pvalue->m.dynamicRTPPayloadTypePresent) { invokeStartElement (pctxt, "dynamicRTPPayloadType", -1); stat = decodeConsUInt8 (pctxt, &pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->dynamicRTPPayloadType); invokeEndElement (pctxt, "dynamicRTPPayloadType", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.flowControlToZeroPresent = 1; invokeStartElement (pctxt, "flowControlToZero", -1); stat = DECODEBIT (pctxt, &pvalue->flowControlToZero); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->flowControlToZero); invokeEndElement (pctxt, "flowControlToZero", -1); break; case 1: pvalue->m.portNumberPresent = 1; invokeStartElement (pctxt, "portNumber", -1); stat = decodeConsUInt16 (pctxt, &pvalue->portNumber, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->portNumber); invokeEndElement (pctxt, "portNumber", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck_forwardMultiplexAckParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannelAck_forwardMultiplexAckParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_forwardMultiplexAckParameters* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* h2250LogicalChannelAckParameters */ case 0: invokeStartElement (pctxt, "h2250LogicalChannelAckParameters", -1); pvalue->u.h2250LogicalChannelAckParameters = ALLOC_ASN1ELEM (pctxt, H245H2250LogicalChannelAckParameters); stat = asn1PD_H245H2250LogicalChannelAckParameters (pctxt, pvalue->u.h2250LogicalChannelAckParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h2250LogicalChannelAckParameters", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannelAck (OOCTXT* pctxt, H245OpenLogicalChannelAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.reverseLogicalChannelParametersPresent = optbit; /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); /* decode reverseLogicalChannelParameters */ if (pvalue->m.reverseLogicalChannelParametersPresent) { invokeStartElement (pctxt, "reverseLogicalChannelParameters", -1); stat = asn1PD_H245OpenLogicalChannelAck_reverseLogicalChannelParameters (pctxt, &pvalue->reverseLogicalChannelParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reverseLogicalChannelParameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 3 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.separateStackPresent = 1; invokeStartElement (pctxt, "separateStack", -1); stat = asn1PD_H245NetworkAccessParameters (pctxt, &pvalue->separateStack); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "separateStack", -1); break; case 1: pvalue->m.forwardMultiplexAckParametersPresent = 1; invokeStartElement (pctxt, "forwardMultiplexAckParameters", -1); stat = asn1PD_H245OpenLogicalChannelAck_forwardMultiplexAckParameters (pctxt, &pvalue->forwardMultiplexAckParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardMultiplexAckParameters", -1); break; case 2: pvalue->m.encryptionSyncPresent = 1; invokeStartElement (pctxt, "encryptionSync", -1); stat = asn1PD_H245EncryptionSync (pctxt, &pvalue->encryptionSync); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionSync", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannelReject_cause (OOCTXT* pctxt, H245OpenLogicalChannelReject_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unspecified */ case 0: invokeStartElement (pctxt, "unspecified", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unspecified", -1); break; /* unsuitableReverseParameters */ case 1: invokeStartElement (pctxt, "unsuitableReverseParameters", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unsuitableReverseParameters", -1); break; /* dataTypeNotSupported */ case 2: invokeStartElement (pctxt, "dataTypeNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dataTypeNotSupported", -1); break; /* dataTypeNotAvailable */ case 3: invokeStartElement (pctxt, "dataTypeNotAvailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dataTypeNotAvailable", -1); break; /* unknownDataType */ case 4: invokeStartElement (pctxt, "unknownDataType", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unknownDataType", -1); break; /* dataTypeALCombinationNotSupported */ case 5: invokeStartElement (pctxt, "dataTypeALCombinationNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dataTypeALCombinationNotSupported", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* multicastChannelNotAllowed */ case 7: invokeStartElement (pctxt, "multicastChannelNotAllowed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multicastChannelNotAllowed", -1); break; /* insufficientBandwidth */ case 8: invokeStartElement (pctxt, "insufficientBandwidth", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "insufficientBandwidth", -1); break; /* separateStackEstablishmentFailed */ case 9: invokeStartElement (pctxt, "separateStackEstablishmentFailed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "separateStackEstablishmentFailed", -1); break; /* invalidSessionID */ case 10: invokeStartElement (pctxt, "invalidSessionID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidSessionID", -1); break; /* masterSlaveConflict */ case 11: invokeStartElement (pctxt, "masterSlaveConflict", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "masterSlaveConflict", -1); break; /* waitForCommunicationMode */ case 12: invokeStartElement (pctxt, "waitForCommunicationMode", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "waitForCommunicationMode", -1); break; /* invalidDependentChannel */ case 13: invokeStartElement (pctxt, "invalidDependentChannel", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidDependentChannel", -1); break; /* replacementForRejected */ case 14: invokeStartElement (pctxt, "replacementForRejected", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "replacementForRejected", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannelReject (OOCTXT* pctxt, H245OpenLogicalChannelReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245OpenLogicalChannelReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannelAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CloseLogicalChannelAck (OOCTXT* pctxt, H245CloseLogicalChannelAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestChannelCloseAck (OOCTXT* pctxt, H245RequestChannelCloseAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestChannelCloseReject_cause (OOCTXT* pctxt, H245RequestChannelCloseReject_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unspecified */ case 0: invokeStartElement (pctxt, "unspecified", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unspecified", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestChannelCloseReject (OOCTXT* pctxt, H245RequestChannelCloseReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245RequestChannelCloseReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendAck_multiplexTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySendAck_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendAck_multiplexTableEntryNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySendAck (OOCTXT* pctxt, H245MultiplexEntrySendAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode multiplexTableEntryNumber */ invokeStartElement (pctxt, "multiplexTableEntryNumber", -1); stat = asn1PD_H245MultiplexEntrySendAck_multiplexTableEntryNumber (pctxt, &pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexTableEntryNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultiplexEntryRejectionDescriptions_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unspecifiedCause */ case 0: invokeStartElement (pctxt, "unspecifiedCause", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unspecifiedCause", -1); break; /* descriptorTooComplex */ case 1: invokeStartElement (pctxt, "descriptorTooComplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "descriptorTooComplex", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultiplexEntryRejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode multiplexTableEntryNumber */ invokeStartElement (pctxt, "multiplexTableEntryNumber", -1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexTableEntryNumber", -1); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245MultiplexEntryRejectionDescriptions_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendReject_rejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySendReject_rejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntrySendReject_rejectionDescriptions* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; H245MultiplexEntryRejectionDescriptions* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245MultiplexEntryRejectionDescriptions); stat = asn1PD_H245MultiplexEntryRejectionDescriptions (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySendReject (OOCTXT* pctxt, H245MultiplexEntrySendReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode rejectionDescriptions */ invokeStartElement (pctxt, "rejectionDescriptions", -1); stat = asn1PD_H245MultiplexEntrySendReject_rejectionDescriptions (pctxt, &pvalue->rejectionDescriptions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectionDescriptions", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryAck_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryAck_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryAck_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryAck (OOCTXT* pctxt, H245RequestMultiplexEntryAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode entryNumbers */ invokeStartElement (pctxt, "entryNumbers", -1); stat = asn1PD_H245RequestMultiplexEntryAck_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "entryNumbers", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryReject_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryReject_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryReject_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRejectionDescriptions_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unspecifiedCause */ case 0: invokeStartElement (pctxt, "unspecifiedCause", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unspecifiedCause", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode multiplexTableEntryNumber */ invokeStartElement (pctxt, "multiplexTableEntryNumber", -1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexTableEntryNumber", -1); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245RequestMultiplexEntryRejectionDescriptions_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryReject_rejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryReject_rejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryReject_rejectionDescriptions* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; H245RequestMultiplexEntryRejectionDescriptions* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245RequestMultiplexEntryRejectionDescriptions); stat = asn1PD_H245RequestMultiplexEntryRejectionDescriptions (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryReject (OOCTXT* pctxt, H245RequestMultiplexEntryReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode entryNumbers */ invokeStartElement (pctxt, "entryNumbers", -1); stat = asn1PD_H245RequestMultiplexEntryReject_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "entryNumbers", -1); /* decode rejectionDescriptions */ invokeStartElement (pctxt, "rejectionDescriptions", -1); stat = asn1PD_H245RequestMultiplexEntryReject_rejectionDescriptions (pctxt, &pvalue->rejectionDescriptions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectionDescriptions", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestModeAck_response */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestModeAck_response (OOCTXT* pctxt, H245RequestModeAck_response* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* willTransmitMostPreferredMode */ case 0: invokeStartElement (pctxt, "willTransmitMostPreferredMode", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "willTransmitMostPreferredMode", -1); break; /* willTransmitLessPreferredMode */ case 1: invokeStartElement (pctxt, "willTransmitLessPreferredMode", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "willTransmitLessPreferredMode", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestModeAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestModeAck (OOCTXT* pctxt, H245RequestModeAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode response */ invokeStartElement (pctxt, "response", -1); stat = asn1PD_H245RequestModeAck_response (pctxt, &pvalue->response); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "response", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestModeReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestModeReject_cause (OOCTXT* pctxt, H245RequestModeReject_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* modeUnavailable */ case 0: invokeStartElement (pctxt, "modeUnavailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "modeUnavailable", -1); break; /* multipointConstraint */ case 1: invokeStartElement (pctxt, "multipointConstraint", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multipointConstraint", -1); break; /* requestDenied */ case 2: invokeStartElement (pctxt, "requestDenied", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "requestDenied", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestModeReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestModeReject (OOCTXT* pctxt, H245RequestModeReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245RequestModeReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RoundTripDelayResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RoundTripDelayResponse (OOCTXT* pctxt, H245RoundTripDelayResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopAck_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopAck_type (OOCTXT* pctxt, H245MaintenanceLoopAck_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* systemLoop */ case 0: invokeStartElement (pctxt, "systemLoop", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "systemLoop", -1); break; /* mediaLoop */ case 1: invokeStartElement (pctxt, "mediaLoop", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.mediaLoop); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaLoop", -1); break; /* logicalChannelLoop */ case 2: invokeStartElement (pctxt, "logicalChannelLoop", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.logicalChannelLoop); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelLoop", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopAck (OOCTXT* pctxt, H245MaintenanceLoopAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245MaintenanceLoopAck_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopReject_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopReject_type (OOCTXT* pctxt, H245MaintenanceLoopReject_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* systemLoop */ case 0: invokeStartElement (pctxt, "systemLoop", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "systemLoop", -1); break; /* mediaLoop */ case 1: invokeStartElement (pctxt, "mediaLoop", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.mediaLoop); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaLoop", -1); break; /* logicalChannelLoop */ case 2: invokeStartElement (pctxt, "logicalChannelLoop", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.logicalChannelLoop); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelLoop", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopReject_cause (OOCTXT* pctxt, H245MaintenanceLoopReject_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* canNotPerformLoop */ case 0: invokeStartElement (pctxt, "canNotPerformLoop", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "canNotPerformLoop", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopReject (OOCTXT* pctxt, H245MaintenanceLoopReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245MaintenanceLoopReject_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245MaintenanceLoopReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CommunicationModeTableEntry_dataType */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommunicationModeTableEntry_dataType (OOCTXT* pctxt, H245CommunicationModeTableEntry_dataType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* videoData */ case 0: invokeStartElement (pctxt, "videoData", -1); pvalue->u.videoData = ALLOC_ASN1ELEM (pctxt, H245VideoCapability); stat = asn1PD_H245VideoCapability (pctxt, pvalue->u.videoData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoData", -1); break; /* audioData */ case 1: invokeStartElement (pctxt, "audioData", -1); pvalue->u.audioData = ALLOC_ASN1ELEM (pctxt, H245AudioCapability); stat = asn1PD_H245AudioCapability (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audioData", -1); break; /* data */ case 2: invokeStartElement (pctxt, "data", -1); pvalue->u.data = ALLOC_ASN1ELEM (pctxt, H245DataApplicationCapability); stat = asn1PD_H245DataApplicationCapability (pctxt, pvalue->u.data); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "data", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CommunicationModeTableEntry */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommunicationModeTableEntry (OOCTXT* pctxt, H245CommunicationModeTableEntry* pvalue) { static Asn1SizeCnst sessionDescription_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.associatedSessionIDPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.terminalLabelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaChannelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaGuaranteedDeliveryPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaControlChannelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mediaControlGuaranteedDeliveryPresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } /* decode sessionID */ invokeStartElement (pctxt, "sessionID", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sessionID, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sessionID); invokeEndElement (pctxt, "sessionID", -1); /* decode associatedSessionID */ if (pvalue->m.associatedSessionIDPresent) { invokeStartElement (pctxt, "associatedSessionID", -1); stat = decodeConsUInt8 (pctxt, &pvalue->associatedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->associatedSessionID); invokeEndElement (pctxt, "associatedSessionID", -1); } /* decode terminalLabel */ if (pvalue->m.terminalLabelPresent) { invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); } /* decode sessionDescription */ invokeStartElement (pctxt, "sessionDescription", -1); addSizeConstraint (pctxt, &sessionDescription_lsize1); stat = decodeBMPString (pctxt, &pvalue->sessionDescription, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->sessionDescription.nchars, pvalue->sessionDescription.data); invokeEndElement (pctxt, "sessionDescription", -1); /* decode dataType */ invokeStartElement (pctxt, "dataType", -1); stat = asn1PD_H245CommunicationModeTableEntry_dataType (pctxt, &pvalue->dataType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataType", -1); /* decode mediaChannel */ if (pvalue->m.mediaChannelPresent) { invokeStartElement (pctxt, "mediaChannel", -1); stat = asn1PD_H245TransportAddress (pctxt, &pvalue->mediaChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaChannel", -1); } /* decode mediaGuaranteedDelivery */ if (pvalue->m.mediaGuaranteedDeliveryPresent) { invokeStartElement (pctxt, "mediaGuaranteedDelivery", -1); stat = DECODEBIT (pctxt, &pvalue->mediaGuaranteedDelivery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->mediaGuaranteedDelivery); invokeEndElement (pctxt, "mediaGuaranteedDelivery", -1); } /* decode mediaControlChannel */ if (pvalue->m.mediaControlChannelPresent) { invokeStartElement (pctxt, "mediaControlChannel", -1); stat = asn1PD_H245TransportAddress (pctxt, &pvalue->mediaControlChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mediaControlChannel", -1); } /* decode mediaControlGuaranteedDelivery */ if (pvalue->m.mediaControlGuaranteedDeliveryPresent) { invokeStartElement (pctxt, "mediaControlGuaranteedDelivery", -1); stat = DECODEBIT (pctxt, &pvalue->mediaControlGuaranteedDelivery); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->mediaControlGuaranteedDelivery); invokeEndElement (pctxt, "mediaControlGuaranteedDelivery", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 3 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.redundancyEncodingPresent = 1; invokeStartElement (pctxt, "redundancyEncoding", -1); stat = asn1PD_H245RedundancyEncoding (pctxt, &pvalue->redundancyEncoding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "redundancyEncoding", -1); break; case 1: pvalue->m.sessionDependencyPresent = 1; invokeStartElement (pctxt, "sessionDependency", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sessionDependency, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sessionDependency); invokeEndElement (pctxt, "sessionDependency", -1); break; case 2: pvalue->m.destinationPresent = 1; invokeStartElement (pctxt, "destination", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->destination); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destination", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* CommunicationModeResponse_communicationModeTable */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommunicationModeResponse_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeResponse_communicationModeTable* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245CommunicationModeTableEntry* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CommunicationModeTableEntry); stat = asn1PD_H245CommunicationModeTableEntry (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* CommunicationModeResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommunicationModeResponse (OOCTXT* pctxt, H245CommunicationModeResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 0); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* communicationModeTable */ case 0: invokeStartElement (pctxt, "communicationModeTable", -1); pvalue->u.communicationModeTable = ALLOC_ASN1ELEM (pctxt, H245CommunicationModeResponse_communicationModeTable); stat = asn1PD_H245CommunicationModeResponse_communicationModeTable (pctxt, pvalue->u.communicationModeTable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "communicationModeTable", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 2; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TerminalID */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalID (OOCTXT* pctxt, H245TerminalID* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_mCTerminalIDResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_mCTerminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_mCTerminalIDResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalLabel */ invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); /* decode terminalID */ invokeStartElement (pctxt, "terminalID", -1); stat = asn1PD_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalID", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_terminalIDResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_terminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalIDResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalLabel */ invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); /* decode terminalID */ invokeStartElement (pctxt, "terminalID", -1); stat = asn1PD_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalID", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceID */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceID (OOCTXT* pctxt, H245ConferenceID* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_conferenceIDResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_conferenceIDResponse (OOCTXT* pctxt, H245ConferenceResponse_conferenceIDResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalLabel */ invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H245ConferenceID (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* Password */ /* */ /**************************************************************/ EXTERN int asn1PD_H245Password (OOCTXT* pctxt, H245Password* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_passwordResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_passwordResponse (OOCTXT* pctxt, H245ConferenceResponse_passwordResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalLabel */ invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); /* decode password */ invokeStartElement (pctxt, "password", -1); stat = asn1PD_H245Password (pctxt, &pvalue->password); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "password", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_terminalListResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_terminalListResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalListResponse* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245TerminalLabel* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_makeMeChairResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_makeMeChairResponse (OOCTXT* pctxt, H245ConferenceResponse_makeMeChairResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* grantedChairToken */ case 0: invokeStartElement (pctxt, "grantedChairToken", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "grantedChairToken", -1); break; /* deniedChairToken */ case 1: invokeStartElement (pctxt, "deniedChairToken", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "deniedChairToken", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_extensionAddressResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_extensionAddressResponse (OOCTXT* pctxt, H245ConferenceResponse_extensionAddressResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode extensionAddress */ invokeStartElement (pctxt, "extensionAddress", -1); stat = asn1PD_H245TerminalID (pctxt, &pvalue->extensionAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "extensionAddress", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_chairTokenOwnerResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_chairTokenOwnerResponse (OOCTXT* pctxt, H245ConferenceResponse_chairTokenOwnerResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalLabel */ invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); /* decode terminalID */ invokeStartElement (pctxt, "terminalID", -1); stat = asn1PD_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalID", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_terminalCertificateResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_terminalCertificateResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalCertificateResponse* pvalue) { static Asn1SizeCnst certificateResponse_lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.terminalLabelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.certificateResponsePresent = optbit; /* decode terminalLabel */ if (pvalue->m.terminalLabelPresent) { invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); } /* decode certificateResponse */ if (pvalue->m.certificateResponsePresent) { invokeStartElement (pctxt, "certificateResponse", -1); addSizeConstraint (pctxt, &certificateResponse_lsize1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->certificateResponse); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->certificateResponse.numocts, pvalue->certificateResponse.data); invokeEndElement (pctxt, "certificateResponse", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_broadcastMyLogicalChannelResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_broadcastMyLogicalChannelResponse (OOCTXT* pctxt, H245ConferenceResponse_broadcastMyLogicalChannelResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* grantedBroadcastMyLogicalChannel */ case 0: invokeStartElement (pctxt, "grantedBroadcastMyLogicalChannel", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "grantedBroadcastMyLogicalChannel", -1); break; /* deniedBroadcastMyLogicalChannel */ case 1: invokeStartElement (pctxt, "deniedBroadcastMyLogicalChannel", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "deniedBroadcastMyLogicalChannel", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_makeTerminalBroadcasterResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_makeTerminalBroadcasterResponse (OOCTXT* pctxt, H245ConferenceResponse_makeTerminalBroadcasterResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* grantedMakeTerminalBroadcaster */ case 0: invokeStartElement (pctxt, "grantedMakeTerminalBroadcaster", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "grantedMakeTerminalBroadcaster", -1); break; /* deniedMakeTerminalBroadcaster */ case 1: invokeStartElement (pctxt, "deniedMakeTerminalBroadcaster", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "deniedMakeTerminalBroadcaster", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_sendThisSourceResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse_sendThisSourceResponse (OOCTXT* pctxt, H245ConferenceResponse_sendThisSourceResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* grantedSendThisSource */ case 0: invokeStartElement (pctxt, "grantedSendThisSource", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "grantedSendThisSource", -1); break; /* deniedSendThisSource */ case 1: invokeStartElement (pctxt, "deniedSendThisSource", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "deniedSendThisSource", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TerminalInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalInformation (OOCTXT* pctxt, H245TerminalInformation* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalLabel */ invokeStartElement (pctxt, "terminalLabel", -1); stat = asn1PD_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLabel", -1); /* decode terminalID */ invokeStartElement (pctxt, "terminalID", -1); stat = asn1PD_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalID", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245TerminalInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245TerminalInformation (OOCTXT* pctxt, H245_SeqOfH245TerminalInformation* pvalue) { int stat = ASN_OK; H245TerminalInformation* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245TerminalInformation); stat = asn1PD_H245TerminalInformation (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* RequestAllTerminalIDsResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestAllTerminalIDsResponse (OOCTXT* pctxt, H245RequestAllTerminalIDsResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalInformation */ invokeStartElement (pctxt, "terminalInformation", -1); stat = asn1PD_H245_SeqOfH245TerminalInformation (pctxt, &pvalue->terminalInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalInformation", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RemoteMCResponse_reject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RemoteMCResponse_reject (OOCTXT* pctxt, H245RemoteMCResponse_reject* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unspecified */ case 0: invokeStartElement (pctxt, "unspecified", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unspecified", -1); break; /* functionNotSupported */ case 1: invokeStartElement (pctxt, "functionNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "functionNotSupported", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RemoteMCResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RemoteMCResponse (OOCTXT* pctxt, H245RemoteMCResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* accept */ case 0: invokeStartElement (pctxt, "accept", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "accept", -1); break; /* reject */ case 1: invokeStartElement (pctxt, "reject", -1); pvalue->u.reject = ALLOC_ASN1ELEM (pctxt, H245RemoteMCResponse_reject); stat = asn1PD_H245RemoteMCResponse_reject (pctxt, pvalue->u.reject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reject", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceResponse (OOCTXT* pctxt, H245ConferenceResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 7); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* mCTerminalIDResponse */ case 0: invokeStartElement (pctxt, "mCTerminalIDResponse", -1); pvalue->u.mCTerminalIDResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_mCTerminalIDResponse); stat = asn1PD_H245ConferenceResponse_mCTerminalIDResponse (pctxt, pvalue->u.mCTerminalIDResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mCTerminalIDResponse", -1); break; /* terminalIDResponse */ case 1: invokeStartElement (pctxt, "terminalIDResponse", -1); pvalue->u.terminalIDResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_terminalIDResponse); stat = asn1PD_H245ConferenceResponse_terminalIDResponse (pctxt, pvalue->u.terminalIDResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalIDResponse", -1); break; /* conferenceIDResponse */ case 2: invokeStartElement (pctxt, "conferenceIDResponse", -1); pvalue->u.conferenceIDResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_conferenceIDResponse); stat = asn1PD_H245ConferenceResponse_conferenceIDResponse (pctxt, pvalue->u.conferenceIDResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceIDResponse", -1); break; /* passwordResponse */ case 3: invokeStartElement (pctxt, "passwordResponse", -1); pvalue->u.passwordResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_passwordResponse); stat = asn1PD_H245ConferenceResponse_passwordResponse (pctxt, pvalue->u.passwordResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "passwordResponse", -1); break; /* terminalListResponse */ case 4: invokeStartElement (pctxt, "terminalListResponse", -1); pvalue->u.terminalListResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_terminalListResponse); stat = asn1PD_H245ConferenceResponse_terminalListResponse (pctxt, pvalue->u.terminalListResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalListResponse", -1); break; /* videoCommandReject */ case 5: invokeStartElement (pctxt, "videoCommandReject", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "videoCommandReject", -1); break; /* terminalDropReject */ case 6: invokeStartElement (pctxt, "terminalDropReject", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "terminalDropReject", -1); break; /* makeMeChairResponse */ case 7: invokeStartElement (pctxt, "makeMeChairResponse", -1); pvalue->u.makeMeChairResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_makeMeChairResponse); stat = asn1PD_H245ConferenceResponse_makeMeChairResponse (pctxt, pvalue->u.makeMeChairResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "makeMeChairResponse", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 9; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* extensionAddressResponse */ case 9: invokeStartElement (pctxt, "extensionAddressResponse", -1); pvalue->u.extensionAddressResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_extensionAddressResponse); stat = asn1PD_H245ConferenceResponse_extensionAddressResponse (pctxt, pvalue->u.extensionAddressResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "extensionAddressResponse", -1); break; /* chairTokenOwnerResponse */ case 10: invokeStartElement (pctxt, "chairTokenOwnerResponse", -1); pvalue->u.chairTokenOwnerResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_chairTokenOwnerResponse); stat = asn1PD_H245ConferenceResponse_chairTokenOwnerResponse (pctxt, pvalue->u.chairTokenOwnerResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "chairTokenOwnerResponse", -1); break; /* terminalCertificateResponse */ case 11: invokeStartElement (pctxt, "terminalCertificateResponse", -1); pvalue->u.terminalCertificateResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_terminalCertificateResponse); stat = asn1PD_H245ConferenceResponse_terminalCertificateResponse (pctxt, pvalue->u.terminalCertificateResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalCertificateResponse", -1); break; /* broadcastMyLogicalChannelResponse */ case 12: invokeStartElement (pctxt, "broadcastMyLogicalChannelResponse", -1); pvalue->u.broadcastMyLogicalChannelResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_broadcastMyLogicalChannelResponse); stat = asn1PD_H245ConferenceResponse_broadcastMyLogicalChannelResponse (pctxt, pvalue->u.broadcastMyLogicalChannelResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "broadcastMyLogicalChannelResponse", -1); break; /* makeTerminalBroadcasterResponse */ case 13: invokeStartElement (pctxt, "makeTerminalBroadcasterResponse", -1); pvalue->u.makeTerminalBroadcasterResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_makeTerminalBroadcasterResponse); stat = asn1PD_H245ConferenceResponse_makeTerminalBroadcasterResponse (pctxt, pvalue->u.makeTerminalBroadcasterResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "makeTerminalBroadcasterResponse", -1); break; /* sendThisSourceResponse */ case 14: invokeStartElement (pctxt, "sendThisSourceResponse", -1); pvalue->u.sendThisSourceResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse_sendThisSourceResponse); stat = asn1PD_H245ConferenceResponse_sendThisSourceResponse (pctxt, pvalue->u.sendThisSourceResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sendThisSourceResponse", -1); break; /* requestAllTerminalIDsResponse */ case 15: invokeStartElement (pctxt, "requestAllTerminalIDsResponse", -1); pvalue->u.requestAllTerminalIDsResponse = ALLOC_ASN1ELEM (pctxt, H245RequestAllTerminalIDsResponse); stat = asn1PD_H245RequestAllTerminalIDsResponse (pctxt, pvalue->u.requestAllTerminalIDsResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestAllTerminalIDsResponse", -1); break; /* remoteMCResponse */ case 16: invokeStartElement (pctxt, "remoteMCResponse", -1); pvalue->u.remoteMCResponse = ALLOC_ASN1ELEM (pctxt, H245RemoteMCResponse); stat = asn1PD_H245RemoteMCResponse (pctxt, pvalue->u.remoteMCResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "remoteMCResponse", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_callInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkResponse_callInformation (OOCTXT* pctxt, H245MultilinkResponse_callInformation* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode dialingInformation */ invokeStartElement (pctxt, "dialingInformation", -1); stat = asn1PD_H245DialingInformation (pctxt, &pvalue->dialingInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dialingInformation", -1); /* decode callAssociationNumber */ invokeStartElement (pctxt, "callAssociationNumber", -1); stat = decodeConsUnsigned (pctxt, &pvalue->callAssociationNumber, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->callAssociationNumber); invokeEndElement (pctxt, "callAssociationNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_addConnection_responseCode_rejected */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkResponse_addConnection_responseCode_rejected (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode_rejected* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* connectionsNotAvailable */ case 0: invokeStartElement (pctxt, "connectionsNotAvailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "connectionsNotAvailable", -1); break; /* userRejected */ case 1: invokeStartElement (pctxt, "userRejected", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "userRejected", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_addConnection_responseCode */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkResponse_addConnection_responseCode (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* accepted */ case 0: invokeStartElement (pctxt, "accepted", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "accepted", -1); break; /* rejected */ case 1: invokeStartElement (pctxt, "rejected", -1); pvalue->u.rejected = ALLOC_ASN1ELEM (pctxt, H245MultilinkResponse_addConnection_responseCode_rejected); stat = asn1PD_H245MultilinkResponse_addConnection_responseCode_rejected (pctxt, pvalue->u.rejected); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejected", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_addConnection */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkResponse_addConnection (OOCTXT* pctxt, H245MultilinkResponse_addConnection* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode responseCode */ invokeStartElement (pctxt, "responseCode", -1); stat = asn1PD_H245MultilinkResponse_addConnection_responseCode (pctxt, &pvalue->responseCode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "responseCode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_removeConnection */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkResponse_removeConnection (OOCTXT* pctxt, H245MultilinkResponse_removeConnection* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode connectionIdentifier */ invokeStartElement (pctxt, "connectionIdentifier", -1); stat = asn1PD_H245ConnectionIdentifier (pctxt, &pvalue->connectionIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectionIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_maximumHeaderInterval */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkResponse_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkResponse_maximumHeaderInterval* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode currentInterval */ invokeStartElement (pctxt, "currentInterval", -1); stat = decodeConsUInt16 (pctxt, &pvalue->currentInterval, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->currentInterval); invokeEndElement (pctxt, "currentInterval", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkResponse (OOCTXT* pctxt, H245MultilinkResponse* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* callInformation */ case 1: invokeStartElement (pctxt, "callInformation", -1); pvalue->u.callInformation = ALLOC_ASN1ELEM (pctxt, H245MultilinkResponse_callInformation); stat = asn1PD_H245MultilinkResponse_callInformation (pctxt, pvalue->u.callInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callInformation", -1); break; /* addConnection */ case 2: invokeStartElement (pctxt, "addConnection", -1); pvalue->u.addConnection = ALLOC_ASN1ELEM (pctxt, H245MultilinkResponse_addConnection); stat = asn1PD_H245MultilinkResponse_addConnection (pctxt, pvalue->u.addConnection); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "addConnection", -1); break; /* removeConnection */ case 3: invokeStartElement (pctxt, "removeConnection", -1); pvalue->u.removeConnection = ALLOC_ASN1ELEM (pctxt, H245MultilinkResponse_removeConnection); stat = asn1PD_H245MultilinkResponse_removeConnection (pctxt, pvalue->u.removeConnection); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "removeConnection", -1); break; /* maximumHeaderInterval */ case 4: invokeStartElement (pctxt, "maximumHeaderInterval", -1); pvalue->u.maximumHeaderInterval = ALLOC_ASN1ELEM (pctxt, H245MultilinkResponse_maximumHeaderInterval); stat = asn1PD_H245MultilinkResponse_maximumHeaderInterval (pctxt, pvalue->u.maximumHeaderInterval); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maximumHeaderInterval", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateAcknowledge */ /* */ /**************************************************************/ EXTERN int asn1PD_H245LogicalChannelRateAcknowledge (OOCTXT* pctxt, H245LogicalChannelRateAcknowledge* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); /* decode maximumBitRate */ invokeStartElement (pctxt, "maximumBitRate", -1); stat = asn1PD_H245MaximumBitRate (pctxt, &pvalue->maximumBitRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maximumBitRate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H245LogicalChannelRateRejectReason (OOCTXT* pctxt, H245LogicalChannelRateRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* undefinedReason */ case 0: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; /* insufficientResources */ case 1: invokeStartElement (pctxt, "insufficientResources", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "insufficientResources", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H245LogicalChannelRateReject (OOCTXT* pctxt, H245LogicalChannelRateReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.currentMaximumBitRatePresent = optbit; /* decode sequenceNumber */ invokeStartElement (pctxt, "sequenceNumber", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->sequenceNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sequenceNumber", -1); /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H245LogicalChannelRateRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); /* decode currentMaximumBitRate */ if (pvalue->m.currentMaximumBitRatePresent) { invokeStartElement (pctxt, "currentMaximumBitRate", -1); stat = asn1PD_H245MaximumBitRate (pctxt, &pvalue->currentMaximumBitRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "currentMaximumBitRate", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ResponseMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ResponseMessage (OOCTXT* pctxt, H245ResponseMessage* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 18); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* masterSlaveDeterminationAck */ case 1: invokeStartElement (pctxt, "masterSlaveDeterminationAck", -1); pvalue->u.masterSlaveDeterminationAck = ALLOC_ASN1ELEM (pctxt, H245MasterSlaveDeterminationAck); stat = asn1PD_H245MasterSlaveDeterminationAck (pctxt, pvalue->u.masterSlaveDeterminationAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "masterSlaveDeterminationAck", -1); break; /* masterSlaveDeterminationReject */ case 2: invokeStartElement (pctxt, "masterSlaveDeterminationReject", -1); pvalue->u.masterSlaveDeterminationReject = ALLOC_ASN1ELEM (pctxt, H245MasterSlaveDeterminationReject); stat = asn1PD_H245MasterSlaveDeterminationReject (pctxt, pvalue->u.masterSlaveDeterminationReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "masterSlaveDeterminationReject", -1); break; /* terminalCapabilitySetAck */ case 3: invokeStartElement (pctxt, "terminalCapabilitySetAck", -1); pvalue->u.terminalCapabilitySetAck = ALLOC_ASN1ELEM (pctxt, H245TerminalCapabilitySetAck); stat = asn1PD_H245TerminalCapabilitySetAck (pctxt, pvalue->u.terminalCapabilitySetAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalCapabilitySetAck", -1); break; /* terminalCapabilitySetReject */ case 4: invokeStartElement (pctxt, "terminalCapabilitySetReject", -1); pvalue->u.terminalCapabilitySetReject = ALLOC_ASN1ELEM (pctxt, H245TerminalCapabilitySetReject); stat = asn1PD_H245TerminalCapabilitySetReject (pctxt, pvalue->u.terminalCapabilitySetReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalCapabilitySetReject", -1); break; /* openLogicalChannelAck */ case 5: invokeStartElement (pctxt, "openLogicalChannelAck", -1); pvalue->u.openLogicalChannelAck = ALLOC_ASN1ELEM (pctxt, H245OpenLogicalChannelAck); stat = asn1PD_H245OpenLogicalChannelAck (pctxt, pvalue->u.openLogicalChannelAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "openLogicalChannelAck", -1); break; /* openLogicalChannelReject */ case 6: invokeStartElement (pctxt, "openLogicalChannelReject", -1); pvalue->u.openLogicalChannelReject = ALLOC_ASN1ELEM (pctxt, H245OpenLogicalChannelReject); stat = asn1PD_H245OpenLogicalChannelReject (pctxt, pvalue->u.openLogicalChannelReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "openLogicalChannelReject", -1); break; /* closeLogicalChannelAck */ case 7: invokeStartElement (pctxt, "closeLogicalChannelAck", -1); pvalue->u.closeLogicalChannelAck = ALLOC_ASN1ELEM (pctxt, H245CloseLogicalChannelAck); stat = asn1PD_H245CloseLogicalChannelAck (pctxt, pvalue->u.closeLogicalChannelAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "closeLogicalChannelAck", -1); break; /* requestChannelCloseAck */ case 8: invokeStartElement (pctxt, "requestChannelCloseAck", -1); pvalue->u.requestChannelCloseAck = ALLOC_ASN1ELEM (pctxt, H245RequestChannelCloseAck); stat = asn1PD_H245RequestChannelCloseAck (pctxt, pvalue->u.requestChannelCloseAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestChannelCloseAck", -1); break; /* requestChannelCloseReject */ case 9: invokeStartElement (pctxt, "requestChannelCloseReject", -1); pvalue->u.requestChannelCloseReject = ALLOC_ASN1ELEM (pctxt, H245RequestChannelCloseReject); stat = asn1PD_H245RequestChannelCloseReject (pctxt, pvalue->u.requestChannelCloseReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestChannelCloseReject", -1); break; /* multiplexEntrySendAck */ case 10: invokeStartElement (pctxt, "multiplexEntrySendAck", -1); pvalue->u.multiplexEntrySendAck = ALLOC_ASN1ELEM (pctxt, H245MultiplexEntrySendAck); stat = asn1PD_H245MultiplexEntrySendAck (pctxt, pvalue->u.multiplexEntrySendAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexEntrySendAck", -1); break; /* multiplexEntrySendReject */ case 11: invokeStartElement (pctxt, "multiplexEntrySendReject", -1); pvalue->u.multiplexEntrySendReject = ALLOC_ASN1ELEM (pctxt, H245MultiplexEntrySendReject); stat = asn1PD_H245MultiplexEntrySendReject (pctxt, pvalue->u.multiplexEntrySendReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexEntrySendReject", -1); break; /* requestMultiplexEntryAck */ case 12: invokeStartElement (pctxt, "requestMultiplexEntryAck", -1); pvalue->u.requestMultiplexEntryAck = ALLOC_ASN1ELEM (pctxt, H245RequestMultiplexEntryAck); stat = asn1PD_H245RequestMultiplexEntryAck (pctxt, pvalue->u.requestMultiplexEntryAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestMultiplexEntryAck", -1); break; /* requestMultiplexEntryReject */ case 13: invokeStartElement (pctxt, "requestMultiplexEntryReject", -1); pvalue->u.requestMultiplexEntryReject = ALLOC_ASN1ELEM (pctxt, H245RequestMultiplexEntryReject); stat = asn1PD_H245RequestMultiplexEntryReject (pctxt, pvalue->u.requestMultiplexEntryReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestMultiplexEntryReject", -1); break; /* requestModeAck */ case 14: invokeStartElement (pctxt, "requestModeAck", -1); pvalue->u.requestModeAck = ALLOC_ASN1ELEM (pctxt, H245RequestModeAck); stat = asn1PD_H245RequestModeAck (pctxt, pvalue->u.requestModeAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestModeAck", -1); break; /* requestModeReject */ case 15: invokeStartElement (pctxt, "requestModeReject", -1); pvalue->u.requestModeReject = ALLOC_ASN1ELEM (pctxt, H245RequestModeReject); stat = asn1PD_H245RequestModeReject (pctxt, pvalue->u.requestModeReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestModeReject", -1); break; /* roundTripDelayResponse */ case 16: invokeStartElement (pctxt, "roundTripDelayResponse", -1); pvalue->u.roundTripDelayResponse = ALLOC_ASN1ELEM (pctxt, H245RoundTripDelayResponse); stat = asn1PD_H245RoundTripDelayResponse (pctxt, pvalue->u.roundTripDelayResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "roundTripDelayResponse", -1); break; /* maintenanceLoopAck */ case 17: invokeStartElement (pctxt, "maintenanceLoopAck", -1); pvalue->u.maintenanceLoopAck = ALLOC_ASN1ELEM (pctxt, H245MaintenanceLoopAck); stat = asn1PD_H245MaintenanceLoopAck (pctxt, pvalue->u.maintenanceLoopAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maintenanceLoopAck", -1); break; /* maintenanceLoopReject */ case 18: invokeStartElement (pctxt, "maintenanceLoopReject", -1); pvalue->u.maintenanceLoopReject = ALLOC_ASN1ELEM (pctxt, H245MaintenanceLoopReject); stat = asn1PD_H245MaintenanceLoopReject (pctxt, pvalue->u.maintenanceLoopReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maintenanceLoopReject", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 20; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* communicationModeResponse */ case 20: invokeStartElement (pctxt, "communicationModeResponse", -1); pvalue->u.communicationModeResponse = ALLOC_ASN1ELEM (pctxt, H245CommunicationModeResponse); stat = asn1PD_H245CommunicationModeResponse (pctxt, pvalue->u.communicationModeResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "communicationModeResponse", -1); break; /* conferenceResponse */ case 21: invokeStartElement (pctxt, "conferenceResponse", -1); pvalue->u.conferenceResponse = ALLOC_ASN1ELEM (pctxt, H245ConferenceResponse); stat = asn1PD_H245ConferenceResponse (pctxt, pvalue->u.conferenceResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceResponse", -1); break; /* multilinkResponse */ case 22: invokeStartElement (pctxt, "multilinkResponse", -1); pvalue->u.multilinkResponse = ALLOC_ASN1ELEM (pctxt, H245MultilinkResponse); stat = asn1PD_H245MultilinkResponse (pctxt, pvalue->u.multilinkResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multilinkResponse", -1); break; /* logicalChannelRateAcknowledge */ case 23: invokeStartElement (pctxt, "logicalChannelRateAcknowledge", -1); pvalue->u.logicalChannelRateAcknowledge = ALLOC_ASN1ELEM (pctxt, H245LogicalChannelRateAcknowledge); stat = asn1PD_H245LogicalChannelRateAcknowledge (pctxt, pvalue->u.logicalChannelRateAcknowledge); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelRateAcknowledge", -1); break; /* logicalChannelRateReject */ case 24: invokeStartElement (pctxt, "logicalChannelRateReject", -1); pvalue->u.logicalChannelRateReject = ALLOC_ASN1ELEM (pctxt, H245LogicalChannelRateReject); stat = asn1PD_H245LogicalChannelRateReject (pctxt, pvalue->u.logicalChannelRateReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelRateReject", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopOffCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MaintenanceLoopOffCommand (OOCTXT* pctxt, H245MaintenanceLoopOffCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest_capabilityTabl */ /* */ /**************************************************************/ EXTERN int asn1PD_H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, H245CapabilityTableEntryNumber); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245CapabilityTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest_capabilityDesc */ /* */ /**************************************************************/ EXTERN int asn1PD_H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245CapabilityDescriptorNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245SendTerminalCapabilitySet_specificRequest (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.capabilityTableEntryNumbersPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.capabilityDescriptorNumbersPresent = optbit; /* decode multiplexCapability */ invokeStartElement (pctxt, "multiplexCapability", -1); stat = DECODEBIT (pctxt, &pvalue->multiplexCapability); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multiplexCapability); invokeEndElement (pctxt, "multiplexCapability", -1); /* decode capabilityTableEntryNumbers */ if (pvalue->m.capabilityTableEntryNumbersPresent) { invokeStartElement (pctxt, "capabilityTableEntryNumbers", -1); stat = asn1PD_H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers (pctxt, &pvalue->capabilityTableEntryNumbers); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityTableEntryNumbers", -1); } /* decode capabilityDescriptorNumbers */ if (pvalue->m.capabilityDescriptorNumbersPresent) { invokeStartElement (pctxt, "capabilityDescriptorNumbers", -1); stat = asn1PD_H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers (pctxt, &pvalue->capabilityDescriptorNumbers); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capabilityDescriptorNumbers", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet */ /* */ /**************************************************************/ EXTERN int asn1PD_H245SendTerminalCapabilitySet (OOCTXT* pctxt, H245SendTerminalCapabilitySet* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* specificRequest */ case 0: invokeStartElement (pctxt, "specificRequest", -1); pvalue->u.specificRequest = ALLOC_ASN1ELEM (pctxt, H245SendTerminalCapabilitySet_specificRequest); stat = asn1PD_H245SendTerminalCapabilitySet_specificRequest (pctxt, pvalue->u.specificRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "specificRequest", -1); break; /* genericRequest */ case 1: invokeStartElement (pctxt, "genericRequest", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "genericRequest", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EncryptionCommand_encryptionAlgorithmID */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionCommand_encryptionAlgorithmID (OOCTXT* pctxt, H245EncryptionCommand_encryptionAlgorithmID* pvalue) { int stat = ASN_OK; /* decode h233AlgorithmIdentifier */ invokeStartElement (pctxt, "h233AlgorithmIdentifier", -1); stat = asn1PD_H245SequenceNumber (pctxt, &pvalue->h233AlgorithmIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h233AlgorithmIdentifier", -1); /* decode associatedAlgorithm */ invokeStartElement (pctxt, "associatedAlgorithm", -1); stat = asn1PD_H245NonStandardParameter (pctxt, &pvalue->associatedAlgorithm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "associatedAlgorithm", -1); return (stat); } /**************************************************************/ /* */ /* EncryptionCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionCommand (OOCTXT* pctxt, H245EncryptionCommand* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* encryptionSE */ case 0: invokeStartElement (pctxt, "encryptionSE", -1); pvalue->u.encryptionSE = ALLOC_ASN1ELEM (pctxt, ASN1DynOctStr); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)pvalue->u.encryptionSE); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->u.encryptionSE->numocts, pvalue->u.encryptionSE->data); invokeEndElement (pctxt, "encryptionSE", -1); break; /* encryptionIVRequest */ case 1: invokeStartElement (pctxt, "encryptionIVRequest", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "encryptionIVRequest", -1); break; /* encryptionAlgorithmID */ case 2: invokeStartElement (pctxt, "encryptionAlgorithmID", -1); pvalue->u.encryptionAlgorithmID = ALLOC_ASN1ELEM (pctxt, H245EncryptionCommand_encryptionAlgorithmID); stat = asn1PD_H245EncryptionCommand_encryptionAlgorithmID (pctxt, pvalue->u.encryptionAlgorithmID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionAlgorithmID", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FlowControlCommand_scope */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FlowControlCommand_scope (OOCTXT* pctxt, H245FlowControlCommand_scope* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* logicalChannelNumber */ case 0: invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); break; /* resourceID */ case 1: invokeStartElement (pctxt, "resourceID", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.resourceID); invokeEndElement (pctxt, "resourceID", -1); break; /* wholeMultiplex */ case 2: invokeStartElement (pctxt, "wholeMultiplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "wholeMultiplex", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlCommand_restriction */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FlowControlCommand_restriction (OOCTXT* pctxt, H245FlowControlCommand_restriction* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* maximumBitRate */ case 0: invokeStartElement (pctxt, "maximumBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->u.maximumBitRate, 0U, 16777215U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.maximumBitRate); invokeEndElement (pctxt, "maximumBitRate", -1); break; /* noRestriction */ case 1: invokeStartElement (pctxt, "noRestriction", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noRestriction", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FlowControlCommand (OOCTXT* pctxt, H245FlowControlCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode scope */ invokeStartElement (pctxt, "scope", -1); stat = asn1PD_H245FlowControlCommand_scope (pctxt, &pvalue->scope); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "scope", -1); /* decode restriction */ invokeStartElement (pctxt, "restriction", -1); stat = asn1PD_H245FlowControlCommand_restriction (pctxt, &pvalue->restriction); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "restriction", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* EndSessionCommand_gstnOptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EndSessionCommand_gstnOptions (OOCTXT* pctxt, H245EndSessionCommand_gstnOptions* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* telephonyMode */ case 0: invokeStartElement (pctxt, "telephonyMode", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "telephonyMode", -1); break; /* v8bis */ case 1: invokeStartElement (pctxt, "v8bis", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v8bis", -1); break; /* v34DSVD */ case 2: invokeStartElement (pctxt, "v34DSVD", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v34DSVD", -1); break; /* v34DuplexFAX */ case 3: invokeStartElement (pctxt, "v34DuplexFAX", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v34DuplexFAX", -1); break; /* v34H324 */ case 4: invokeStartElement (pctxt, "v34H324", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v34H324", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EndSessionCommand_isdnOptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EndSessionCommand_isdnOptions (OOCTXT* pctxt, H245EndSessionCommand_isdnOptions* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* telephonyMode */ case 0: invokeStartElement (pctxt, "telephonyMode", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "telephonyMode", -1); break; /* v140 */ case 1: invokeStartElement (pctxt, "v140", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "v140", -1); break; /* terminalOnHold */ case 2: invokeStartElement (pctxt, "terminalOnHold", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "terminalOnHold", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EndSessionCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EndSessionCommand (OOCTXT* pctxt, H245EndSessionCommand* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* disconnect */ case 1: invokeStartElement (pctxt, "disconnect", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "disconnect", -1); break; /* gstnOptions */ case 2: invokeStartElement (pctxt, "gstnOptions", -1); pvalue->u.gstnOptions = ALLOC_ASN1ELEM (pctxt, H245EndSessionCommand_gstnOptions); stat = asn1PD_H245EndSessionCommand_gstnOptions (pctxt, pvalue->u.gstnOptions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gstnOptions", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* isdnOptions */ case 4: invokeStartElement (pctxt, "isdnOptions", -1); pvalue->u.isdnOptions = ALLOC_ASN1ELEM (pctxt, H245EndSessionCommand_isdnOptions); stat = asn1PD_H245EndSessionCommand_isdnOptions (pctxt, pvalue->u.isdnOptions); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "isdnOptions", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoFastUpdateGOB */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand_type_videoFastUpdateGOB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateGOB* pvalue) { int stat = ASN_OK; /* decode firstGOB */ invokeStartElement (pctxt, "firstGOB", -1); stat = decodeConsUInt8 (pctxt, &pvalue->firstGOB, 0U, 17U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->firstGOB); invokeEndElement (pctxt, "firstGOB", -1); /* decode numberOfGOBs */ invokeStartElement (pctxt, "numberOfGOBs", -1); stat = decodeConsUInt8 (pctxt, &pvalue->numberOfGOBs, 1U, 18U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfGOBs); invokeEndElement (pctxt, "numberOfGOBs", -1); return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoFastUpdateMB */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand_type_videoFastUpdateMB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateMB* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.firstGOBPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.firstMBPresent = optbit; /* decode firstGOB */ if (pvalue->m.firstGOBPresent) { invokeStartElement (pctxt, "firstGOB", -1); stat = decodeConsUInt8 (pctxt, &pvalue->firstGOB, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->firstGOB); invokeEndElement (pctxt, "firstGOB", -1); } /* decode firstMB */ if (pvalue->m.firstMBPresent) { invokeStartElement (pctxt, "firstMB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->firstMB, 1U, 8192U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->firstMB); invokeEndElement (pctxt, "firstMB", -1); } /* decode numberOfMBs */ invokeStartElement (pctxt, "numberOfMBs", -1); stat = decodeConsUInt16 (pctxt, &pvalue->numberOfMBs, 1U, 8192U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfMBs); invokeEndElement (pctxt, "numberOfMBs", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* KeyProtectionMethod */ /* */ /**************************************************************/ EXTERN int asn1PD_H245KeyProtectionMethod (OOCTXT* pctxt, H245KeyProtectionMethod* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode secureChannel */ invokeStartElement (pctxt, "secureChannel", -1); stat = DECODEBIT (pctxt, &pvalue->secureChannel); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->secureChannel); invokeEndElement (pctxt, "secureChannel", -1); /* decode sharedSecret */ invokeStartElement (pctxt, "sharedSecret", -1); stat = DECODEBIT (pctxt, &pvalue->sharedSecret); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->sharedSecret); invokeEndElement (pctxt, "sharedSecret", -1); /* decode certProtectedKey */ invokeStartElement (pctxt, "certProtectedKey", -1); stat = DECODEBIT (pctxt, &pvalue->certProtectedKey); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->certProtectedKey); invokeEndElement (pctxt, "certProtectedKey", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* EncryptionUpdateRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H245EncryptionUpdateRequest (OOCTXT* pctxt, H245EncryptionUpdateRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.keyProtectionMethodPresent = optbit; /* decode keyProtectionMethod */ if (pvalue->m.keyProtectionMethodPresent) { invokeStartElement (pctxt, "keyProtectionMethod", -1); stat = asn1PD_H245KeyProtectionMethod (pctxt, &pvalue->keyProtectionMethod); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "keyProtectionMethod", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_progressiveRefinementStart_rep */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* doOneProgression */ case 0: invokeStartElement (pctxt, "doOneProgression", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "doOneProgression", -1); break; /* doContinuousProgressions */ case 1: invokeStartElement (pctxt, "doContinuousProgressions", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "doContinuousProgressions", -1); break; /* doOneIndependentProgression */ case 2: invokeStartElement (pctxt, "doOneIndependentProgression", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "doOneIndependentProgression", -1); break; /* doContinuousIndependentProgressions */ case 3: invokeStartElement (pctxt, "doContinuousIndependentProgressions", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "doContinuousIndependentProgressions", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_progressiveRefinementStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand_type_progressiveRefinementStart (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode repeatCount */ invokeStartElement (pctxt, "repeatCount", -1); stat = asn1PD_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount (pctxt, &pvalue->repeatCount); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "repeatCount", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoBadMBs */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand_type_videoBadMBs (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoBadMBs* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode firstMB */ invokeStartElement (pctxt, "firstMB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->firstMB, 1U, 9216U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->firstMB); invokeEndElement (pctxt, "firstMB", -1); /* decode numberOfMBs */ invokeStartElement (pctxt, "numberOfMBs", -1); stat = decodeConsUInt16 (pctxt, &pvalue->numberOfMBs, 1U, 9216U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfMBs); invokeEndElement (pctxt, "numberOfMBs", -1); /* decode temporalReference */ invokeStartElement (pctxt, "temporalReference", -1); stat = decodeConsUInt16 (pctxt, &pvalue->temporalReference, 0U, 1023U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->temporalReference); invokeEndElement (pctxt, "temporalReference", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* PictureReference */ /* */ /**************************************************************/ EXTERN int asn1PD_H245PictureReference (OOCTXT* pctxt, H245PictureReference* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* pictureNumber */ case 0: invokeStartElement (pctxt, "pictureNumber", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.pictureNumber, 0U, 1023U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.pictureNumber); invokeEndElement (pctxt, "pictureNumber", -1); break; /* longTermPictureIndex */ case 1: invokeStartElement (pctxt, "longTermPictureIndex", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.longTermPictureIndex, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.longTermPictureIndex); invokeEndElement (pctxt, "longTermPictureIndex", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245PictureReference */ /* */ /**************************************************************/ EXTERN int asn1PD_H245_SeqOfH245PictureReference (OOCTXT* pctxt, H245_SeqOfH245PictureReference* pvalue) { int stat = ASN_OK; H245PictureReference* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245PictureReference); stat = asn1PD_H245PictureReference (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_lostPartialPicture */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand_type_lostPartialPicture (OOCTXT* pctxt, H245MiscellaneousCommand_type_lostPartialPicture* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode pictureReference */ invokeStartElement (pctxt, "pictureReference", -1); stat = asn1PD_H245PictureReference (pctxt, &pvalue->pictureReference); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "pictureReference", -1); /* decode firstMB */ invokeStartElement (pctxt, "firstMB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->firstMB, 1U, 9216U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->firstMB); invokeEndElement (pctxt, "firstMB", -1); /* decode numberOfMBs */ invokeStartElement (pctxt, "numberOfMBs", -1); stat = decodeConsUInt16 (pctxt, &pvalue->numberOfMBs, 1U, 9216U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfMBs); invokeEndElement (pctxt, "numberOfMBs", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand_type (OOCTXT* pctxt, H245MiscellaneousCommand_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 9); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* equaliseDelay */ case 0: invokeStartElement (pctxt, "equaliseDelay", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "equaliseDelay", -1); break; /* zeroDelay */ case 1: invokeStartElement (pctxt, "zeroDelay", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "zeroDelay", -1); break; /* multipointModeCommand */ case 2: invokeStartElement (pctxt, "multipointModeCommand", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multipointModeCommand", -1); break; /* cancelMultipointModeCommand */ case 3: invokeStartElement (pctxt, "cancelMultipointModeCommand", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelMultipointModeCommand", -1); break; /* videoFreezePicture */ case 4: invokeStartElement (pctxt, "videoFreezePicture", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "videoFreezePicture", -1); break; /* videoFastUpdatePicture */ case 5: invokeStartElement (pctxt, "videoFastUpdatePicture", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "videoFastUpdatePicture", -1); break; /* videoFastUpdateGOB */ case 6: invokeStartElement (pctxt, "videoFastUpdateGOB", -1); pvalue->u.videoFastUpdateGOB = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousCommand_type_videoFastUpdateGOB); stat = asn1PD_H245MiscellaneousCommand_type_videoFastUpdateGOB (pctxt, pvalue->u.videoFastUpdateGOB); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoFastUpdateGOB", -1); break; /* videoTemporalSpatialTradeOff */ case 7: invokeStartElement (pctxt, "videoTemporalSpatialTradeOff", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.videoTemporalSpatialTradeOff, 0U, 31U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.videoTemporalSpatialTradeOff); invokeEndElement (pctxt, "videoTemporalSpatialTradeOff", -1); break; /* videoSendSyncEveryGOB */ case 8: invokeStartElement (pctxt, "videoSendSyncEveryGOB", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "videoSendSyncEveryGOB", -1); break; /* videoSendSyncEveryGOBCancel */ case 9: invokeStartElement (pctxt, "videoSendSyncEveryGOBCancel", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "videoSendSyncEveryGOBCancel", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 11; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* videoFastUpdateMB */ case 11: invokeStartElement (pctxt, "videoFastUpdateMB", -1); pvalue->u.videoFastUpdateMB = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousCommand_type_videoFastUpdateMB); stat = asn1PD_H245MiscellaneousCommand_type_videoFastUpdateMB (pctxt, pvalue->u.videoFastUpdateMB); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoFastUpdateMB", -1); break; /* maxH223MUXPDUsize */ case 12: invokeStartElement (pctxt, "maxH223MUXPDUsize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.maxH223MUXPDUsize, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.maxH223MUXPDUsize); invokeEndElement (pctxt, "maxH223MUXPDUsize", -1); break; /* encryptionUpdate */ case 13: invokeStartElement (pctxt, "encryptionUpdate", -1); pvalue->u.encryptionUpdate = ALLOC_ASN1ELEM (pctxt, H245EncryptionSync); stat = asn1PD_H245EncryptionSync (pctxt, pvalue->u.encryptionUpdate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionUpdate", -1); break; /* encryptionUpdateRequest */ case 14: invokeStartElement (pctxt, "encryptionUpdateRequest", -1); pvalue->u.encryptionUpdateRequest = ALLOC_ASN1ELEM (pctxt, H245EncryptionUpdateRequest); stat = asn1PD_H245EncryptionUpdateRequest (pctxt, pvalue->u.encryptionUpdateRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionUpdateRequest", -1); break; /* switchReceiveMediaOff */ case 15: invokeStartElement (pctxt, "switchReceiveMediaOff", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "switchReceiveMediaOff", -1); break; /* switchReceiveMediaOn */ case 16: invokeStartElement (pctxt, "switchReceiveMediaOn", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "switchReceiveMediaOn", -1); break; /* progressiveRefinementStart */ case 17: invokeStartElement (pctxt, "progressiveRefinementStart", -1); pvalue->u.progressiveRefinementStart = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart); stat = asn1PD_H245MiscellaneousCommand_type_progressiveRefinementStart (pctxt, pvalue->u.progressiveRefinementStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "progressiveRefinementStart", -1); break; /* progressiveRefinementAbortOne */ case 18: invokeStartElement (pctxt, "progressiveRefinementAbortOne", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "progressiveRefinementAbortOne", -1); break; /* progressiveRefinementAbortContinuous */ case 19: invokeStartElement (pctxt, "progressiveRefinementAbortContinuous", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "progressiveRefinementAbortContinuous", -1); break; /* videoBadMBs */ case 20: invokeStartElement (pctxt, "videoBadMBs", -1); pvalue->u.videoBadMBs = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousCommand_type_videoBadMBs); stat = asn1PD_H245MiscellaneousCommand_type_videoBadMBs (pctxt, pvalue->u.videoBadMBs); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoBadMBs", -1); break; /* lostPicture */ case 21: invokeStartElement (pctxt, "lostPicture", -1); pvalue->u.lostPicture = ALLOC_ASN1ELEM (pctxt, H245_SeqOfH245PictureReference); stat = asn1PD_H245_SeqOfH245PictureReference (pctxt, pvalue->u.lostPicture); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "lostPicture", -1); break; /* lostPartialPicture */ case 22: invokeStartElement (pctxt, "lostPartialPicture", -1); pvalue->u.lostPartialPicture = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousCommand_type_lostPartialPicture); stat = asn1PD_H245MiscellaneousCommand_type_lostPartialPicture (pctxt, pvalue->u.lostPartialPicture); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "lostPartialPicture", -1); break; /* recoveryReferencePicture */ case 23: invokeStartElement (pctxt, "recoveryReferencePicture", -1); pvalue->u.recoveryReferencePicture = ALLOC_ASN1ELEM (pctxt, H245_SeqOfH245PictureReference); stat = asn1PD_H245_SeqOfH245PictureReference (pctxt, pvalue->u.recoveryReferencePicture); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "recoveryReferencePicture", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousCommand (OOCTXT* pctxt, H245MiscellaneousCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245MiscellaneousCommand_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CommunicationModeCommand_communicationModeTable */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommunicationModeCommand_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeCommand_communicationModeTable* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; H245CommunicationModeTableEntry* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H245CommunicationModeTableEntry); stat = asn1PD_H245CommunicationModeTableEntry (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* CommunicationModeCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommunicationModeCommand (OOCTXT* pctxt, H245CommunicationModeCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode communicationModeTable */ invokeStartElement (pctxt, "communicationModeTable", -1); stat = asn1PD_H245CommunicationModeCommand_communicationModeTable (pctxt, &pvalue->communicationModeTable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "communicationModeTable", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SubstituteConferenceIDCommand_conferenceIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H245SubstituteConferenceIDCommand_conferenceIdentifier (OOCTXT* pctxt, H245SubstituteConferenceIDCommand_conferenceIdentifier* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* SubstituteConferenceIDCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245SubstituteConferenceIDCommand (OOCTXT* pctxt, H245SubstituteConferenceIDCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode conferenceIdentifier */ invokeStartElement (pctxt, "conferenceIdentifier", -1); stat = asn1PD_H245SubstituteConferenceIDCommand_conferenceIdentifier (pctxt, &pvalue->conferenceIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceCommand (OOCTXT* pctxt, H245ConferenceCommand* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 6); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* broadcastMyLogicalChannel */ case 0: invokeStartElement (pctxt, "broadcastMyLogicalChannel", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.broadcastMyLogicalChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "broadcastMyLogicalChannel", -1); break; /* cancelBroadcastMyLogicalChannel */ case 1: invokeStartElement (pctxt, "cancelBroadcastMyLogicalChannel", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.cancelBroadcastMyLogicalChannel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cancelBroadcastMyLogicalChannel", -1); break; /* makeTerminalBroadcaster */ case 2: invokeStartElement (pctxt, "makeTerminalBroadcaster", -1); pvalue->u.makeTerminalBroadcaster = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.makeTerminalBroadcaster); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "makeTerminalBroadcaster", -1); break; /* cancelMakeTerminalBroadcaster */ case 3: invokeStartElement (pctxt, "cancelMakeTerminalBroadcaster", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelMakeTerminalBroadcaster", -1); break; /* sendThisSource */ case 4: invokeStartElement (pctxt, "sendThisSource", -1); pvalue->u.sendThisSource = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.sendThisSource); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sendThisSource", -1); break; /* cancelSendThisSource */ case 5: invokeStartElement (pctxt, "cancelSendThisSource", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelSendThisSource", -1); break; /* dropConference */ case 6: invokeStartElement (pctxt, "dropConference", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dropConference", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 8; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* substituteConferenceIDCommand */ case 8: invokeStartElement (pctxt, "substituteConferenceIDCommand", -1); pvalue->u.substituteConferenceIDCommand = ALLOC_ASN1ELEM (pctxt, H245SubstituteConferenceIDCommand); stat = asn1PD_H245SubstituteConferenceIDCommand (pctxt, pvalue->u.substituteConferenceIDCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "substituteConferenceIDCommand", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H223MultiplexReconfiguration_h223ModeChange */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223MultiplexReconfiguration_h223ModeChange (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223ModeChange* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* toLevel0 */ case 0: invokeStartElement (pctxt, "toLevel0", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "toLevel0", -1); break; /* toLevel1 */ case 1: invokeStartElement (pctxt, "toLevel1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "toLevel1", -1); break; /* toLevel2 */ case 2: invokeStartElement (pctxt, "toLevel2", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "toLevel2", -1); break; /* toLevel2withOptionalHeader */ case 3: invokeStartElement (pctxt, "toLevel2withOptionalHeader", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "toLevel2withOptionalHeader", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223MultiplexReconfiguration_h223AnnexADoubleFlag */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223AnnexADoubleFlag* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* start */ case 0: invokeStartElement (pctxt, "start", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "start", -1); break; /* stop */ case 1: invokeStartElement (pctxt, "stop", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "stop", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223MultiplexReconfiguration */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223MultiplexReconfiguration (OOCTXT* pctxt, H245H223MultiplexReconfiguration* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* h223ModeChange */ case 0: invokeStartElement (pctxt, "h223ModeChange", -1); pvalue->u.h223ModeChange = ALLOC_ASN1ELEM (pctxt, H245H223MultiplexReconfiguration_h223ModeChange); stat = asn1PD_H245H223MultiplexReconfiguration_h223ModeChange (pctxt, pvalue->u.h223ModeChange); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223ModeChange", -1); break; /* h223AnnexADoubleFlag */ case 1: invokeStartElement (pctxt, "h223AnnexADoubleFlag", -1); pvalue->u.h223AnnexADoubleFlag = ALLOC_ASN1ELEM (pctxt, H245H223MultiplexReconfiguration_h223AnnexADoubleFlag); stat = asn1PD_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag (pctxt, pvalue->u.h223AnnexADoubleFlag); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223AnnexADoubleFlag", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1_clockRecovery */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_clockRecovery* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nullClockRecovery */ case 0: invokeStartElement (pctxt, "nullClockRecovery", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nullClockRecovery", -1); break; /* srtsClockRecovery */ case 1: invokeStartElement (pctxt, "srtsClockRecovery", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "srtsClockRecovery", -1); break; /* adaptiveClockRecovery */ case 2: invokeStartElement (pctxt, "adaptiveClockRecovery", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "adaptiveClockRecovery", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1_errorCorrection */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_errorCorrection* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nullErrorCorrection */ case 0: invokeStartElement (pctxt, "nullErrorCorrection", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nullErrorCorrection", -1); break; /* longInterleaver */ case 1: invokeStartElement (pctxt, "longInterleaver", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "longInterleaver", -1); break; /* shortInterleaver */ case 2: invokeStartElement (pctxt, "shortInterleaver", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "shortInterleaver", -1); break; /* errorCorrectionOnly */ case 3: invokeStartElement (pctxt, "errorCorrectionOnly", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "errorCorrectionOnly", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_aal_aal1 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode clockRecovery */ invokeStartElement (pctxt, "clockRecovery", -1); stat = asn1PD_H245NewATMVCCommand_aal_aal1_clockRecovery (pctxt, &pvalue->clockRecovery); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "clockRecovery", -1); /* decode errorCorrection */ invokeStartElement (pctxt, "errorCorrection", -1); stat = asn1PD_H245NewATMVCCommand_aal_aal1_errorCorrection (pctxt, &pvalue->errorCorrection); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "errorCorrection", -1); /* decode structuredDataTransfer */ invokeStartElement (pctxt, "structuredDataTransfer", -1); stat = DECODEBIT (pctxt, &pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->structuredDataTransfer); invokeEndElement (pctxt, "structuredDataTransfer", -1); /* decode partiallyFilledCells */ invokeStartElement (pctxt, "partiallyFilledCells", -1); stat = DECODEBIT (pctxt, &pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->partiallyFilledCells); invokeEndElement (pctxt, "partiallyFilledCells", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal5 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_aal_aal5 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal5* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardMaximumSDUSize */ invokeStartElement (pctxt, "forwardMaximumSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->forwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->forwardMaximumSDUSize); invokeEndElement (pctxt, "forwardMaximumSDUSize", -1); /* decode backwardMaximumSDUSize */ invokeStartElement (pctxt, "backwardMaximumSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->backwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->backwardMaximumSDUSize); invokeEndElement (pctxt, "backwardMaximumSDUSize", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_aal (OOCTXT* pctxt, H245NewATMVCCommand_aal* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* aal1 */ case 0: invokeStartElement (pctxt, "aal1", -1); pvalue->u.aal1 = ALLOC_ASN1ELEM (pctxt, H245NewATMVCCommand_aal_aal1); stat = asn1PD_H245NewATMVCCommand_aal_aal1 (pctxt, pvalue->u.aal1); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal1", -1); break; /* aal5 */ case 1: invokeStartElement (pctxt, "aal5", -1); pvalue->u.aal5 = ALLOC_ASN1ELEM (pctxt, H245NewATMVCCommand_aal_aal5); stat = asn1PD_H245NewATMVCCommand_aal_aal5 (pctxt, pvalue->u.aal5); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal5", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_multiplex* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noMultiplex */ case 0: invokeStartElement (pctxt, "noMultiplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noMultiplex", -1); break; /* transportStream */ case 1: invokeStartElement (pctxt, "transportStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transportStream", -1); break; /* programStream */ case 2: invokeStartElement (pctxt, "programStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "programStream", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_reverseParameters_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters_multiplex* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noMultiplex */ case 0: invokeStartElement (pctxt, "noMultiplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noMultiplex", -1); break; /* transportStream */ case 1: invokeStartElement (pctxt, "transportStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transportStream", -1); break; /* programStream */ case 2: invokeStartElement (pctxt, "programStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "programStream", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_reverseParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand_reverseParameters (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); /* decode bitRateLockedToPCRClock */ invokeStartElement (pctxt, "bitRateLockedToPCRClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToPCRClock); invokeEndElement (pctxt, "bitRateLockedToPCRClock", -1); /* decode bitRateLockedToNetworkClock */ invokeStartElement (pctxt, "bitRateLockedToNetworkClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToNetworkClock); invokeEndElement (pctxt, "bitRateLockedToNetworkClock", -1); /* decode multiplex */ invokeStartElement (pctxt, "multiplex", -1); stat = asn1PD_H245NewATMVCCommand_reverseParameters_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplex", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCCommand (OOCTXT* pctxt, H245NewATMVCCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode resourceID */ invokeStartElement (pctxt, "resourceID", -1); stat = decodeConsUInt16 (pctxt, &pvalue->resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->resourceID); invokeEndElement (pctxt, "resourceID", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); /* decode bitRateLockedToPCRClock */ invokeStartElement (pctxt, "bitRateLockedToPCRClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToPCRClock); invokeEndElement (pctxt, "bitRateLockedToPCRClock", -1); /* decode bitRateLockedToNetworkClock */ invokeStartElement (pctxt, "bitRateLockedToNetworkClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToNetworkClock); invokeEndElement (pctxt, "bitRateLockedToNetworkClock", -1); /* decode aal */ invokeStartElement (pctxt, "aal", -1); stat = asn1PD_H245NewATMVCCommand_aal (pctxt, &pvalue->aal); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal", -1); /* decode multiplex */ invokeStartElement (pctxt, "multiplex", -1); stat = asn1PD_H245NewATMVCCommand_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplex", -1); /* decode reverseParameters */ invokeStartElement (pctxt, "reverseParameters", -1); stat = asn1PD_H245NewATMVCCommand_reverseParameters (pctxt, &pvalue->reverseParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reverseParameters", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MobileMultilinkReconfigurationCommand_status */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MobileMultilinkReconfigurationCommand_status (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand_status* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* synchronized_ */ case 0: invokeStartElement (pctxt, "synchronized_", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "synchronized_", -1); break; /* reconfiguration */ case 1: invokeStartElement (pctxt, "reconfiguration", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "reconfiguration", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MobileMultilinkReconfigurationCommand */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MobileMultilinkReconfigurationCommand (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sampleSize */ invokeStartElement (pctxt, "sampleSize", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sampleSize, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sampleSize); invokeEndElement (pctxt, "sampleSize", -1); /* decode samplesPerFrame */ invokeStartElement (pctxt, "samplesPerFrame", -1); stat = decodeConsUInt8 (pctxt, &pvalue->samplesPerFrame, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->samplesPerFrame); invokeEndElement (pctxt, "samplesPerFrame", -1); /* decode status */ invokeStartElement (pctxt, "status", -1); stat = asn1PD_H245MobileMultilinkReconfigurationCommand_status (pctxt, &pvalue->status); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "status", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CommandMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H245CommandMessage (OOCTXT* pctxt, H245CommandMessage* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 6); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* maintenanceLoopOffCommand */ case 1: invokeStartElement (pctxt, "maintenanceLoopOffCommand", -1); pvalue->u.maintenanceLoopOffCommand = ALLOC_ASN1ELEM (pctxt, H245MaintenanceLoopOffCommand); stat = asn1PD_H245MaintenanceLoopOffCommand (pctxt, pvalue->u.maintenanceLoopOffCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maintenanceLoopOffCommand", -1); break; /* sendTerminalCapabilitySet */ case 2: invokeStartElement (pctxt, "sendTerminalCapabilitySet", -1); pvalue->u.sendTerminalCapabilitySet = ALLOC_ASN1ELEM (pctxt, H245SendTerminalCapabilitySet); stat = asn1PD_H245SendTerminalCapabilitySet (pctxt, pvalue->u.sendTerminalCapabilitySet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sendTerminalCapabilitySet", -1); break; /* encryptionCommand */ case 3: invokeStartElement (pctxt, "encryptionCommand", -1); pvalue->u.encryptionCommand = ALLOC_ASN1ELEM (pctxt, H245EncryptionCommand); stat = asn1PD_H245EncryptionCommand (pctxt, pvalue->u.encryptionCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryptionCommand", -1); break; /* flowControlCommand */ case 4: invokeStartElement (pctxt, "flowControlCommand", -1); pvalue->u.flowControlCommand = ALLOC_ASN1ELEM (pctxt, H245FlowControlCommand); stat = asn1PD_H245FlowControlCommand (pctxt, pvalue->u.flowControlCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "flowControlCommand", -1); break; /* endSessionCommand */ case 5: invokeStartElement (pctxt, "endSessionCommand", -1); pvalue->u.endSessionCommand = ALLOC_ASN1ELEM (pctxt, H245EndSessionCommand); stat = asn1PD_H245EndSessionCommand (pctxt, pvalue->u.endSessionCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endSessionCommand", -1); break; /* miscellaneousCommand */ case 6: invokeStartElement (pctxt, "miscellaneousCommand", -1); pvalue->u.miscellaneousCommand = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousCommand); stat = asn1PD_H245MiscellaneousCommand (pctxt, pvalue->u.miscellaneousCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "miscellaneousCommand", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 8; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* communicationModeCommand */ case 8: invokeStartElement (pctxt, "communicationModeCommand", -1); pvalue->u.communicationModeCommand = ALLOC_ASN1ELEM (pctxt, H245CommunicationModeCommand); stat = asn1PD_H245CommunicationModeCommand (pctxt, pvalue->u.communicationModeCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "communicationModeCommand", -1); break; /* conferenceCommand */ case 9: invokeStartElement (pctxt, "conferenceCommand", -1); pvalue->u.conferenceCommand = ALLOC_ASN1ELEM (pctxt, H245ConferenceCommand); stat = asn1PD_H245ConferenceCommand (pctxt, pvalue->u.conferenceCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceCommand", -1); break; /* h223MultiplexReconfiguration */ case 10: invokeStartElement (pctxt, "h223MultiplexReconfiguration", -1); pvalue->u.h223MultiplexReconfiguration = ALLOC_ASN1ELEM (pctxt, H245H223MultiplexReconfiguration); stat = asn1PD_H245H223MultiplexReconfiguration (pctxt, pvalue->u.h223MultiplexReconfiguration); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223MultiplexReconfiguration", -1); break; /* newATMVCCommand */ case 11: invokeStartElement (pctxt, "newATMVCCommand", -1); pvalue->u.newATMVCCommand = ALLOC_ASN1ELEM (pctxt, H245NewATMVCCommand); stat = asn1PD_H245NewATMVCCommand (pctxt, pvalue->u.newATMVCCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "newATMVCCommand", -1); break; /* mobileMultilinkReconfigurationCommand */ case 12: invokeStartElement (pctxt, "mobileMultilinkReconfigurationCommand", -1); pvalue->u.mobileMultilinkReconfigurationCommand = ALLOC_ASN1ELEM (pctxt, H245MobileMultilinkReconfigurationCommand); stat = asn1PD_H245MobileMultilinkReconfigurationCommand (pctxt, pvalue->u.mobileMultilinkReconfigurationCommand); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mobileMultilinkReconfigurationCommand", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* FunctionNotUnderstood */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FunctionNotUnderstood (OOCTXT* pctxt, H245FunctionNotUnderstood* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* request */ case 0: invokeStartElement (pctxt, "request", -1); pvalue->u.request = ALLOC_ASN1ELEM (pctxt, H245RequestMessage); stat = asn1PD_H245RequestMessage (pctxt, pvalue->u.request); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "request", -1); break; /* response */ case 1: invokeStartElement (pctxt, "response", -1); pvalue->u.response = ALLOC_ASN1ELEM (pctxt, H245ResponseMessage); stat = asn1PD_H245ResponseMessage (pctxt, pvalue->u.response); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "response", -1); break; /* command */ case 2: invokeStartElement (pctxt, "command", -1); pvalue->u.command = ALLOC_ASN1ELEM (pctxt, H245CommandMessage); stat = asn1PD_H245CommandMessage (pctxt, pvalue->u.command); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "command", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationRelease */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MasterSlaveDeterminationRelease (OOCTXT* pctxt, H245MasterSlaveDeterminationRelease* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetRelease */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalCapabilitySetRelease (OOCTXT* pctxt, H245TerminalCapabilitySetRelease* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H245OpenLogicalChannelConfirm (OOCTXT* pctxt, H245OpenLogicalChannelConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseRelease */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestChannelCloseRelease (OOCTXT* pctxt, H245RequestChannelCloseRelease* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardLogicalChannelNumber */ invokeStartElement (pctxt, "forwardLogicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "forwardLogicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendRelease_multiplexTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySendRelease_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendRelease_multiplexTableEntryNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendRelease */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultiplexEntrySendRelease (OOCTXT* pctxt, H245MultiplexEntrySendRelease* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode multiplexTableEntryNumber */ invokeStartElement (pctxt, "multiplexTableEntryNumber", -1); stat = asn1PD_H245MultiplexEntrySendRelease_multiplexTableEntryNumber (pctxt, &pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexTableEntryNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRelease_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryRelease_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryRelease_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H245MultiplexTableEntryNumber (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRelease */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestMultiplexEntryRelease (OOCTXT* pctxt, H245RequestMultiplexEntryRelease* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode entryNumbers */ invokeStartElement (pctxt, "entryNumbers", -1); stat = asn1PD_H245RequestMultiplexEntryRelease_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "entryNumbers", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RequestModeRelease */ /* */ /**************************************************************/ EXTERN int asn1PD_H245RequestModeRelease (OOCTXT* pctxt, H245RequestModeRelease* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MiscellaneousIndication_type_videoNotDecodedMBs */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousIndication_type_videoNotDecodedMBs (OOCTXT* pctxt, H245MiscellaneousIndication_type_videoNotDecodedMBs* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode firstMB */ invokeStartElement (pctxt, "firstMB", -1); stat = decodeConsUInt16 (pctxt, &pvalue->firstMB, 1U, 8192U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->firstMB); invokeEndElement (pctxt, "firstMB", -1); /* decode numberOfMBs */ invokeStartElement (pctxt, "numberOfMBs", -1); stat = decodeConsUInt16 (pctxt, &pvalue->numberOfMBs, 1U, 8192U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfMBs); invokeEndElement (pctxt, "numberOfMBs", -1); /* decode temporalReference */ invokeStartElement (pctxt, "temporalReference", -1); stat = decodeConsUInt8 (pctxt, &pvalue->temporalReference, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->temporalReference); invokeEndElement (pctxt, "temporalReference", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MiscellaneousIndication_type */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousIndication_type (OOCTXT* pctxt, H245MiscellaneousIndication_type* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 9); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* logicalChannelActive */ case 0: invokeStartElement (pctxt, "logicalChannelActive", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "logicalChannelActive", -1); break; /* logicalChannelInactive */ case 1: invokeStartElement (pctxt, "logicalChannelInactive", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "logicalChannelInactive", -1); break; /* multipointConference */ case 2: invokeStartElement (pctxt, "multipointConference", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multipointConference", -1); break; /* cancelMultipointConference */ case 3: invokeStartElement (pctxt, "cancelMultipointConference", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelMultipointConference", -1); break; /* multipointZeroComm */ case 4: invokeStartElement (pctxt, "multipointZeroComm", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multipointZeroComm", -1); break; /* cancelMultipointZeroComm */ case 5: invokeStartElement (pctxt, "cancelMultipointZeroComm", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelMultipointZeroComm", -1); break; /* multipointSecondaryStatus */ case 6: invokeStartElement (pctxt, "multipointSecondaryStatus", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multipointSecondaryStatus", -1); break; /* cancelMultipointSecondaryStatus */ case 7: invokeStartElement (pctxt, "cancelMultipointSecondaryStatus", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelMultipointSecondaryStatus", -1); break; /* videoIndicateReadyToActivate */ case 8: invokeStartElement (pctxt, "videoIndicateReadyToActivate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "videoIndicateReadyToActivate", -1); break; /* videoTemporalSpatialTradeOff */ case 9: invokeStartElement (pctxt, "videoTemporalSpatialTradeOff", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.videoTemporalSpatialTradeOff, 0U, 31U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.videoTemporalSpatialTradeOff); invokeEndElement (pctxt, "videoTemporalSpatialTradeOff", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 11; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* videoNotDecodedMBs */ case 11: invokeStartElement (pctxt, "videoNotDecodedMBs", -1); pvalue->u.videoNotDecodedMBs = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousIndication_type_videoNotDecodedMBs); stat = asn1PD_H245MiscellaneousIndication_type_videoNotDecodedMBs (pctxt, pvalue->u.videoNotDecodedMBs); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoNotDecodedMBs", -1); break; /* transportCapability */ case 12: invokeStartElement (pctxt, "transportCapability", -1); pvalue->u.transportCapability = ALLOC_ASN1ELEM (pctxt, H245TransportCapability); stat = asn1PD_H245TransportCapability (pctxt, pvalue->u.transportCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transportCapability", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MiscellaneousIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MiscellaneousIndication (OOCTXT* pctxt, H245MiscellaneousIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = asn1PD_H245MiscellaneousIndication_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "type", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* JitterIndication_scope */ /* */ /**************************************************************/ EXTERN int asn1PD_H245JitterIndication_scope (OOCTXT* pctxt, H245JitterIndication_scope* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* logicalChannelNumber */ case 0: invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); break; /* resourceID */ case 1: invokeStartElement (pctxt, "resourceID", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.resourceID); invokeEndElement (pctxt, "resourceID", -1); break; /* wholeMultiplex */ case 2: invokeStartElement (pctxt, "wholeMultiplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "wholeMultiplex", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* JitterIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245JitterIndication (OOCTXT* pctxt, H245JitterIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.skippedFrameCountPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.additionalDecoderBufferPresent = optbit; /* decode scope */ invokeStartElement (pctxt, "scope", -1); stat = asn1PD_H245JitterIndication_scope (pctxt, &pvalue->scope); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "scope", -1); /* decode estimatedReceivedJitterMantissa */ invokeStartElement (pctxt, "estimatedReceivedJitterMantissa", -1); stat = decodeConsUInt8 (pctxt, &pvalue->estimatedReceivedJitterMantissa, 0U, 3U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->estimatedReceivedJitterMantissa); invokeEndElement (pctxt, "estimatedReceivedJitterMantissa", -1); /* decode estimatedReceivedJitterExponent */ invokeStartElement (pctxt, "estimatedReceivedJitterExponent", -1); stat = decodeConsUInt8 (pctxt, &pvalue->estimatedReceivedJitterExponent, 0U, 7U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->estimatedReceivedJitterExponent); invokeEndElement (pctxt, "estimatedReceivedJitterExponent", -1); /* decode skippedFrameCount */ if (pvalue->m.skippedFrameCountPresent) { invokeStartElement (pctxt, "skippedFrameCount", -1); stat = decodeConsUInt8 (pctxt, &pvalue->skippedFrameCount, 0U, 15U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->skippedFrameCount); invokeEndElement (pctxt, "skippedFrameCount", -1); } /* decode additionalDecoderBuffer */ if (pvalue->m.additionalDecoderBufferPresent) { invokeStartElement (pctxt, "additionalDecoderBuffer", -1); stat = decodeConsUnsigned (pctxt, &pvalue->additionalDecoderBuffer, 0U, 262143U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->additionalDecoderBuffer); invokeEndElement (pctxt, "additionalDecoderBuffer", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H223SkewIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H223SkewIndication (OOCTXT* pctxt, H245H223SkewIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode logicalChannelNumber1 */ invokeStartElement (pctxt, "logicalChannelNumber1", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber1); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber1", -1); /* decode logicalChannelNumber2 */ invokeStartElement (pctxt, "logicalChannelNumber2", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber2); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber2", -1); /* decode skew */ invokeStartElement (pctxt, "skew", -1); stat = decodeConsUInt16 (pctxt, &pvalue->skew, 0U, 4095U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->skew); invokeEndElement (pctxt, "skew", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1_clockRecovery */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_clockRecovery* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nullClockRecovery */ case 0: invokeStartElement (pctxt, "nullClockRecovery", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nullClockRecovery", -1); break; /* srtsClockRecovery */ case 1: invokeStartElement (pctxt, "srtsClockRecovery", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "srtsClockRecovery", -1); break; /* adaptiveClockRecovery */ case 2: invokeStartElement (pctxt, "adaptiveClockRecovery", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "adaptiveClockRecovery", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1_errorCorrection */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_errorCorrection* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nullErrorCorrection */ case 0: invokeStartElement (pctxt, "nullErrorCorrection", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nullErrorCorrection", -1); break; /* longInterleaver */ case 1: invokeStartElement (pctxt, "longInterleaver", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "longInterleaver", -1); break; /* shortInterleaver */ case 2: invokeStartElement (pctxt, "shortInterleaver", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "shortInterleaver", -1); break; /* errorCorrectionOnly */ case 3: invokeStartElement (pctxt, "errorCorrectionOnly", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "errorCorrectionOnly", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_aal_aal1 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode clockRecovery */ invokeStartElement (pctxt, "clockRecovery", -1); stat = asn1PD_H245NewATMVCIndication_aal_aal1_clockRecovery (pctxt, &pvalue->clockRecovery); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "clockRecovery", -1); /* decode errorCorrection */ invokeStartElement (pctxt, "errorCorrection", -1); stat = asn1PD_H245NewATMVCIndication_aal_aal1_errorCorrection (pctxt, &pvalue->errorCorrection); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "errorCorrection", -1); /* decode structuredDataTransfer */ invokeStartElement (pctxt, "structuredDataTransfer", -1); stat = DECODEBIT (pctxt, &pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->structuredDataTransfer); invokeEndElement (pctxt, "structuredDataTransfer", -1); /* decode partiallyFilledCells */ invokeStartElement (pctxt, "partiallyFilledCells", -1); stat = DECODEBIT (pctxt, &pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->partiallyFilledCells); invokeEndElement (pctxt, "partiallyFilledCells", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal5 */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_aal_aal5 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal5* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode forwardMaximumSDUSize */ invokeStartElement (pctxt, "forwardMaximumSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->forwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->forwardMaximumSDUSize); invokeEndElement (pctxt, "forwardMaximumSDUSize", -1); /* decode backwardMaximumSDUSize */ invokeStartElement (pctxt, "backwardMaximumSDUSize", -1); stat = decodeConsUInt16 (pctxt, &pvalue->backwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->backwardMaximumSDUSize); invokeEndElement (pctxt, "backwardMaximumSDUSize", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_aal (OOCTXT* pctxt, H245NewATMVCIndication_aal* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* aal1 */ case 0: invokeStartElement (pctxt, "aal1", -1); pvalue->u.aal1 = ALLOC_ASN1ELEM (pctxt, H245NewATMVCIndication_aal_aal1); stat = asn1PD_H245NewATMVCIndication_aal_aal1 (pctxt, pvalue->u.aal1); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal1", -1); break; /* aal5 */ case 1: invokeStartElement (pctxt, "aal5", -1); pvalue->u.aal5 = ALLOC_ASN1ELEM (pctxt, H245NewATMVCIndication_aal_aal5); stat = asn1PD_H245NewATMVCIndication_aal_aal5 (pctxt, pvalue->u.aal5); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal5", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_multiplex* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noMultiplex */ case 0: invokeStartElement (pctxt, "noMultiplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noMultiplex", -1); break; /* transportStream */ case 1: invokeStartElement (pctxt, "transportStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transportStream", -1); break; /* programStream */ case 2: invokeStartElement (pctxt, "programStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "programStream", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_reverseParameters_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters_multiplex* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noMultiplex */ case 0: invokeStartElement (pctxt, "noMultiplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noMultiplex", -1); break; /* transportStream */ case 1: invokeStartElement (pctxt, "transportStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transportStream", -1); break; /* programStream */ case 2: invokeStartElement (pctxt, "programStream", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "programStream", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_reverseParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication_reverseParameters (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); /* decode bitRateLockedToPCRClock */ invokeStartElement (pctxt, "bitRateLockedToPCRClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToPCRClock); invokeEndElement (pctxt, "bitRateLockedToPCRClock", -1); /* decode bitRateLockedToNetworkClock */ invokeStartElement (pctxt, "bitRateLockedToNetworkClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToNetworkClock); invokeEndElement (pctxt, "bitRateLockedToNetworkClock", -1); /* decode multiplex */ invokeStartElement (pctxt, "multiplex", -1); stat = asn1PD_H245NewATMVCIndication_reverseParameters_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplex", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245NewATMVCIndication (OOCTXT* pctxt, H245NewATMVCIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode resourceID */ invokeStartElement (pctxt, "resourceID", -1); stat = decodeConsUInt16 (pctxt, &pvalue->resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->resourceID); invokeEndElement (pctxt, "resourceID", -1); /* decode bitRate */ invokeStartElement (pctxt, "bitRate", -1); stat = decodeConsUInt16 (pctxt, &pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->bitRate); invokeEndElement (pctxt, "bitRate", -1); /* decode bitRateLockedToPCRClock */ invokeStartElement (pctxt, "bitRateLockedToPCRClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToPCRClock); invokeEndElement (pctxt, "bitRateLockedToPCRClock", -1); /* decode bitRateLockedToNetworkClock */ invokeStartElement (pctxt, "bitRateLockedToNetworkClock", -1); stat = DECODEBIT (pctxt, &pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->bitRateLockedToNetworkClock); invokeEndElement (pctxt, "bitRateLockedToNetworkClock", -1); /* decode aal */ invokeStartElement (pctxt, "aal", -1); stat = asn1PD_H245NewATMVCIndication_aal (pctxt, &pvalue->aal); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aal", -1); /* decode multiplex */ invokeStartElement (pctxt, "multiplex", -1); stat = asn1PD_H245NewATMVCIndication_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplex", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.reverseParametersPresent = 1; invokeStartElement (pctxt, "reverseParameters", -1); stat = asn1PD_H245NewATMVCIndication_reverseParameters (pctxt, &pvalue->reverseParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reverseParameters", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_userInputSupportIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputIndication_userInputSupportIndication (OOCTXT* pctxt, H245UserInputIndication_userInputSupportIndication* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* basicString */ case 1: invokeStartElement (pctxt, "basicString", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "basicString", -1); break; /* iA5String */ case 2: invokeStartElement (pctxt, "iA5String", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "iA5String", -1); break; /* generalString */ case 3: invokeStartElement (pctxt, "generalString", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "generalString", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signal_rtp */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputIndication_signal_rtp (OOCTXT* pctxt, H245UserInputIndication_signal_rtp* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.timestampPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.expirationTimePresent = optbit; /* decode timestamp */ if (pvalue->m.timestampPresent) { invokeStartElement (pctxt, "timestamp", -1); stat = decodeConsUnsigned (pctxt, &pvalue->timestamp, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->timestamp); invokeEndElement (pctxt, "timestamp", -1); } /* decode expirationTime */ if (pvalue->m.expirationTimePresent) { invokeStartElement (pctxt, "expirationTime", -1); stat = decodeConsUnsigned (pctxt, &pvalue->expirationTime, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->expirationTime); invokeEndElement (pctxt, "expirationTime", -1); } /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signal */ /* */ /**************************************************************/ extern EXTERN const char* gs_MULTIMEDIA_SYSTEM_CONTROL_UserInputIndication_signal_signalType_CharSet; EXTERN int asn1PD_H245UserInputIndication_signal (OOCTXT* pctxt, H245UserInputIndication_signal* pvalue) { static Asn1SizeCnst signalType_lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.durationPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.rtpPresent = optbit; /* decode signalType */ invokeStartElement (pctxt, "signalType", -1); addSizeConstraint (pctxt, &signalType_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->signalType, gs_MULTIMEDIA_SYSTEM_CONTROL_UserInputIndication_signal_signalType_CharSet, 8, 5, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->signalType); invokeEndElement (pctxt, "signalType", -1); /* decode duration */ if (pvalue->m.durationPresent) { invokeStartElement (pctxt, "duration", -1); stat = decodeConsUInt16 (pctxt, &pvalue->duration, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->duration); invokeEndElement (pctxt, "duration", -1); } /* decode rtp */ if (pvalue->m.rtpPresent) { invokeStartElement (pctxt, "rtp", -1); stat = asn1PD_H245UserInputIndication_signal_rtp (pctxt, &pvalue->rtp); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtp", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.rtpPayloadIndicationPresent = 1; invokeStartElement (pctxt, "rtpPayloadIndication", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "rtpPayloadIndication", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signalUpdate_rtp */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputIndication_signalUpdate_rtp (OOCTXT* pctxt, H245UserInputIndication_signalUpdate_rtp* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode logicalChannelNumber */ invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signalUpdate */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputIndication_signalUpdate (OOCTXT* pctxt, H245UserInputIndication_signalUpdate* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.rtpPresent = optbit; /* decode duration */ invokeStartElement (pctxt, "duration", -1); stat = decodeConsUInt16 (pctxt, &pvalue->duration, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->duration); invokeEndElement (pctxt, "duration", -1); /* decode rtp */ if (pvalue->m.rtpPresent) { invokeStartElement (pctxt, "rtp", -1); stat = asn1PD_H245UserInputIndication_signalUpdate_rtp (pctxt, &pvalue->rtp); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtp", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_extendedAlphanumeric */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputIndication_extendedAlphanumeric (OOCTXT* pctxt, H245UserInputIndication_extendedAlphanumeric* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.rtpPayloadIndicationPresent = optbit; /* decode alphanumeric */ invokeStartElement (pctxt, "alphanumeric", -1); stat = decodeVarWidthCharString (pctxt, &pvalue->alphanumeric); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->alphanumeric); invokeEndElement (pctxt, "alphanumeric", -1); /* decode rtpPayloadIndication */ if (pvalue->m.rtpPayloadIndicationPresent) { invokeStartElement (pctxt, "rtpPayloadIndication", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "rtpPayloadIndication", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245UserInputIndication (OOCTXT* pctxt, H245UserInputIndication* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardParameter); stat = asn1PD_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* alphanumeric */ case 1: invokeStartElement (pctxt, "alphanumeric", -1); stat = decodeVarWidthCharString (pctxt, &pvalue->u.alphanumeric); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.alphanumeric); invokeEndElement (pctxt, "alphanumeric", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* userInputSupportIndication */ case 3: invokeStartElement (pctxt, "userInputSupportIndication", -1); pvalue->u.userInputSupportIndication = ALLOC_ASN1ELEM (pctxt, H245UserInputIndication_userInputSupportIndication); stat = asn1PD_H245UserInputIndication_userInputSupportIndication (pctxt, pvalue->u.userInputSupportIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "userInputSupportIndication", -1); break; /* signal */ case 4: invokeStartElement (pctxt, "signal", -1); pvalue->u.signal = ALLOC_ASN1ELEM (pctxt, H245UserInputIndication_signal); stat = asn1PD_H245UserInputIndication_signal (pctxt, pvalue->u.signal); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "signal", -1); break; /* signalUpdate */ case 5: invokeStartElement (pctxt, "signalUpdate", -1); pvalue->u.signalUpdate = ALLOC_ASN1ELEM (pctxt, H245UserInputIndication_signalUpdate); stat = asn1PD_H245UserInputIndication_signalUpdate (pctxt, pvalue->u.signalUpdate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "signalUpdate", -1); break; /* extendedAlphanumeric */ case 6: invokeStartElement (pctxt, "extendedAlphanumeric", -1); pvalue->u.extendedAlphanumeric = ALLOC_ASN1ELEM (pctxt, H245UserInputIndication_extendedAlphanumeric); stat = asn1PD_H245UserInputIndication_extendedAlphanumeric (pctxt, pvalue->u.extendedAlphanumeric); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "extendedAlphanumeric", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H2250MaximumSkewIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245H2250MaximumSkewIndication (OOCTXT* pctxt, H245H2250MaximumSkewIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode logicalChannelNumber1 */ invokeStartElement (pctxt, "logicalChannelNumber1", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber1); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber1", -1); /* decode logicalChannelNumber2 */ invokeStartElement (pctxt, "logicalChannelNumber2", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->logicalChannelNumber2); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber2", -1); /* decode maximumSkew */ invokeStartElement (pctxt, "maximumSkew", -1); stat = decodeConsUInt16 (pctxt, &pvalue->maximumSkew, 0U, 4095U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->maximumSkew); invokeEndElement (pctxt, "maximumSkew", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MCLocationIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MCLocationIndication (OOCTXT* pctxt, H245MCLocationIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode signalAddress */ invokeStartElement (pctxt, "signalAddress", -1); stat = asn1PD_H245TransportAddress (pctxt, &pvalue->signalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "signalAddress", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TerminalYouAreSeeingInSubPictureNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245TerminalYouAreSeeingInSubPictureNumber (OOCTXT* pctxt, H245TerminalYouAreSeeingInSubPictureNumber* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode terminalNumber */ invokeStartElement (pctxt, "terminalNumber", -1); stat = asn1PD_H245TerminalNumber (pctxt, &pvalue->terminalNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalNumber", -1); /* decode subPictureNumber */ invokeStartElement (pctxt, "subPictureNumber", -1); stat = decodeConsUInt8 (pctxt, &pvalue->subPictureNumber, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->subPictureNumber); invokeEndElement (pctxt, "subPictureNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* VideoIndicateCompose */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VideoIndicateCompose (OOCTXT* pctxt, H245VideoIndicateCompose* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode compositionNumber */ invokeStartElement (pctxt, "compositionNumber", -1); stat = decodeConsUInt8 (pctxt, &pvalue->compositionNumber, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->compositionNumber); invokeEndElement (pctxt, "compositionNumber", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ConferenceIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245ConferenceIndication (OOCTXT* pctxt, H245ConferenceIndication* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 9); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* sbeNumber */ case 0: invokeStartElement (pctxt, "sbeNumber", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.sbeNumber, 0U, 9U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.sbeNumber); invokeEndElement (pctxt, "sbeNumber", -1); break; /* terminalNumberAssign */ case 1: invokeStartElement (pctxt, "terminalNumberAssign", -1); pvalue->u.terminalNumberAssign = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.terminalNumberAssign); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalNumberAssign", -1); break; /* terminalJoinedConference */ case 2: invokeStartElement (pctxt, "terminalJoinedConference", -1); pvalue->u.terminalJoinedConference = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.terminalJoinedConference); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalJoinedConference", -1); break; /* terminalLeftConference */ case 3: invokeStartElement (pctxt, "terminalLeftConference", -1); pvalue->u.terminalLeftConference = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.terminalLeftConference); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalLeftConference", -1); break; /* seenByAtLeastOneOther */ case 4: invokeStartElement (pctxt, "seenByAtLeastOneOther", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "seenByAtLeastOneOther", -1); break; /* cancelSeenByAtLeastOneOther */ case 5: invokeStartElement (pctxt, "cancelSeenByAtLeastOneOther", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelSeenByAtLeastOneOther", -1); break; /* seenByAll */ case 6: invokeStartElement (pctxt, "seenByAll", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "seenByAll", -1); break; /* cancelSeenByAll */ case 7: invokeStartElement (pctxt, "cancelSeenByAll", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "cancelSeenByAll", -1); break; /* terminalYouAreSeeing */ case 8: invokeStartElement (pctxt, "terminalYouAreSeeing", -1); pvalue->u.terminalYouAreSeeing = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.terminalYouAreSeeing); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalYouAreSeeing", -1); break; /* requestForFloor */ case 9: invokeStartElement (pctxt, "requestForFloor", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "requestForFloor", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 11; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* withdrawChairToken */ case 11: invokeStartElement (pctxt, "withdrawChairToken", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "withdrawChairToken", -1); break; /* floorRequested */ case 12: invokeStartElement (pctxt, "floorRequested", -1); pvalue->u.floorRequested = ALLOC_ASN1ELEM (pctxt, H245TerminalLabel); stat = asn1PD_H245TerminalLabel (pctxt, pvalue->u.floorRequested); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "floorRequested", -1); break; /* terminalYouAreSeeingInSubPictureNumber */ case 13: invokeStartElement (pctxt, "terminalYouAreSeeingInSubPictureNumber", -1); pvalue->u.terminalYouAreSeeingInSubPictureNumber = ALLOC_ASN1ELEM (pctxt, H245TerminalYouAreSeeingInSubPictureNumber); stat = asn1PD_H245TerminalYouAreSeeingInSubPictureNumber (pctxt, pvalue->u.terminalYouAreSeeingInSubPictureNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalYouAreSeeingInSubPictureNumber", -1); break; /* videoIndicateCompose */ case 14: invokeStartElement (pctxt, "videoIndicateCompose", -1); pvalue->u.videoIndicateCompose = ALLOC_ASN1ELEM (pctxt, H245VideoIndicateCompose); stat = asn1PD_H245VideoIndicateCompose (pctxt, pvalue->u.videoIndicateCompose); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "videoIndicateCompose", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* VendorIdentification_productNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VendorIdentification_productNumber (OOCTXT* pctxt, H245VendorIdentification_productNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* VendorIdentification_versionNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VendorIdentification_versionNumber (OOCTXT* pctxt, H245VendorIdentification_versionNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* VendorIdentification */ /* */ /**************************************************************/ EXTERN int asn1PD_H245VendorIdentification (OOCTXT* pctxt, H245VendorIdentification* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.productNumberPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.versionNumberPresent = optbit; /* decode vendor */ invokeStartElement (pctxt, "vendor", -1); stat = asn1PD_H245NonStandardIdentifier (pctxt, &pvalue->vendor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "vendor", -1); /* decode productNumber */ if (pvalue->m.productNumberPresent) { invokeStartElement (pctxt, "productNumber", -1); stat = asn1PD_H245VendorIdentification_productNumber (pctxt, &pvalue->productNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "productNumber", -1); } /* decode versionNumber */ if (pvalue->m.versionNumberPresent) { invokeStartElement (pctxt, "versionNumber", -1); stat = asn1PD_H245VendorIdentification_versionNumber (pctxt, &pvalue->versionNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "versionNumber", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FunctionNotSupported_cause */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FunctionNotSupported_cause (OOCTXT* pctxt, H245FunctionNotSupported_cause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* syntaxError */ case 0: invokeStartElement (pctxt, "syntaxError", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "syntaxError", -1); break; /* semanticError */ case 1: invokeStartElement (pctxt, "semanticError", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "semanticError", -1); break; /* unknownFunction */ case 2: invokeStartElement (pctxt, "unknownFunction", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unknownFunction", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FunctionNotSupported */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FunctionNotSupported (OOCTXT* pctxt, H245FunctionNotSupported* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.returnedFunctionPresent = optbit; /* decode cause */ invokeStartElement (pctxt, "cause", -1); stat = asn1PD_H245FunctionNotSupported_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cause", -1); /* decode returnedFunction */ if (pvalue->m.returnedFunctionPresent) { invokeStartElement (pctxt, "returnedFunction", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->returnedFunction); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->returnedFunction.numocts, pvalue->returnedFunction.data); invokeEndElement (pctxt, "returnedFunction", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkIndication_crcDesired */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkIndication_crcDesired (OOCTXT* pctxt, H245MultilinkIndication_crcDesired* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkIndication_excessiveError */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkIndication_excessiveError (OOCTXT* pctxt, H245MultilinkIndication_excessiveError* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode connectionIdentifier */ invokeStartElement (pctxt, "connectionIdentifier", -1); stat = asn1PD_H245ConnectionIdentifier (pctxt, &pvalue->connectionIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectionIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MultilinkIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultilinkIndication (OOCTXT* pctxt, H245MultilinkIndication* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* crcDesired */ case 1: invokeStartElement (pctxt, "crcDesired", -1); pvalue->u.crcDesired = ALLOC_ASN1ELEM (pctxt, H245MultilinkIndication_crcDesired); stat = asn1PD_H245MultilinkIndication_crcDesired (pctxt, pvalue->u.crcDesired); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "crcDesired", -1); break; /* excessiveError */ case 2: invokeStartElement (pctxt, "excessiveError", -1); pvalue->u.excessiveError = ALLOC_ASN1ELEM (pctxt, H245MultilinkIndication_excessiveError); stat = asn1PD_H245MultilinkIndication_excessiveError (pctxt, pvalue->u.excessiveError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "excessiveError", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateRelease */ /* */ /**************************************************************/ EXTERN int asn1PD_H245LogicalChannelRateRelease (OOCTXT* pctxt, H245LogicalChannelRateRelease* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FlowControlIndication_scope */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FlowControlIndication_scope (OOCTXT* pctxt, H245FlowControlIndication_scope* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* logicalChannelNumber */ case 0: invokeStartElement (pctxt, "logicalChannelNumber", -1); stat = asn1PD_H245LogicalChannelNumber (pctxt, &pvalue->u.logicalChannelNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelNumber", -1); break; /* resourceID */ case 1: invokeStartElement (pctxt, "resourceID", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.resourceID); invokeEndElement (pctxt, "resourceID", -1); break; /* wholeMultiplex */ case 2: invokeStartElement (pctxt, "wholeMultiplex", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "wholeMultiplex", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlIndication_restriction */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FlowControlIndication_restriction (OOCTXT* pctxt, H245FlowControlIndication_restriction* pvalue) { int stat = ASN_OK; ASN1UINT ui; stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* maximumBitRate */ case 0: invokeStartElement (pctxt, "maximumBitRate", -1); stat = decodeConsUnsigned (pctxt, &pvalue->u.maximumBitRate, 0U, 16777215U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.maximumBitRate); invokeEndElement (pctxt, "maximumBitRate", -1); break; /* noRestriction */ case 1: invokeStartElement (pctxt, "noRestriction", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noRestriction", -1); break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245FlowControlIndication (OOCTXT* pctxt, H245FlowControlIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode scope */ invokeStartElement (pctxt, "scope", -1); stat = asn1PD_H245FlowControlIndication_scope (pctxt, &pvalue->scope); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "scope", -1); /* decode restriction */ invokeStartElement (pctxt, "restriction", -1); stat = asn1PD_H245FlowControlIndication_restriction (pctxt, &pvalue->restriction); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "restriction", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MobileMultilinkReconfigurationIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MobileMultilinkReconfigurationIndication (OOCTXT* pctxt, H245MobileMultilinkReconfigurationIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sampleSize */ invokeStartElement (pctxt, "sampleSize", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sampleSize, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sampleSize); invokeEndElement (pctxt, "sampleSize", -1); /* decode samplesPerFrame */ invokeStartElement (pctxt, "samplesPerFrame", -1); stat = decodeConsUInt8 (pctxt, &pvalue->samplesPerFrame, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->samplesPerFrame); invokeEndElement (pctxt, "samplesPerFrame", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* IndicationMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H245IndicationMessage (OOCTXT* pctxt, H245IndicationMessage* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 13); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H245NonStandardMessage); stat = asn1PD_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* functionNotUnderstood */ case 1: invokeStartElement (pctxt, "functionNotUnderstood", -1); pvalue->u.functionNotUnderstood = ALLOC_ASN1ELEM (pctxt, H245FunctionNotUnderstood); stat = asn1PD_H245FunctionNotUnderstood (pctxt, pvalue->u.functionNotUnderstood); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "functionNotUnderstood", -1); break; /* masterSlaveDeterminationRelease */ case 2: invokeStartElement (pctxt, "masterSlaveDeterminationRelease", -1); pvalue->u.masterSlaveDeterminationRelease = ALLOC_ASN1ELEM (pctxt, H245MasterSlaveDeterminationRelease); stat = asn1PD_H245MasterSlaveDeterminationRelease (pctxt, pvalue->u.masterSlaveDeterminationRelease); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "masterSlaveDeterminationRelease", -1); break; /* terminalCapabilitySetRelease */ case 3: invokeStartElement (pctxt, "terminalCapabilitySetRelease", -1); pvalue->u.terminalCapabilitySetRelease = ALLOC_ASN1ELEM (pctxt, H245TerminalCapabilitySetRelease); stat = asn1PD_H245TerminalCapabilitySetRelease (pctxt, pvalue->u.terminalCapabilitySetRelease); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalCapabilitySetRelease", -1); break; /* openLogicalChannelConfirm */ case 4: invokeStartElement (pctxt, "openLogicalChannelConfirm", -1); pvalue->u.openLogicalChannelConfirm = ALLOC_ASN1ELEM (pctxt, H245OpenLogicalChannelConfirm); stat = asn1PD_H245OpenLogicalChannelConfirm (pctxt, pvalue->u.openLogicalChannelConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "openLogicalChannelConfirm", -1); break; /* requestChannelCloseRelease */ case 5: invokeStartElement (pctxt, "requestChannelCloseRelease", -1); pvalue->u.requestChannelCloseRelease = ALLOC_ASN1ELEM (pctxt, H245RequestChannelCloseRelease); stat = asn1PD_H245RequestChannelCloseRelease (pctxt, pvalue->u.requestChannelCloseRelease); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestChannelCloseRelease", -1); break; /* multiplexEntrySendRelease */ case 6: invokeStartElement (pctxt, "multiplexEntrySendRelease", -1); pvalue->u.multiplexEntrySendRelease = ALLOC_ASN1ELEM (pctxt, H245MultiplexEntrySendRelease); stat = asn1PD_H245MultiplexEntrySendRelease (pctxt, pvalue->u.multiplexEntrySendRelease); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multiplexEntrySendRelease", -1); break; /* requestMultiplexEntryRelease */ case 7: invokeStartElement (pctxt, "requestMultiplexEntryRelease", -1); pvalue->u.requestMultiplexEntryRelease = ALLOC_ASN1ELEM (pctxt, H245RequestMultiplexEntryRelease); stat = asn1PD_H245RequestMultiplexEntryRelease (pctxt, pvalue->u.requestMultiplexEntryRelease); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestMultiplexEntryRelease", -1); break; /* requestModeRelease */ case 8: invokeStartElement (pctxt, "requestModeRelease", -1); pvalue->u.requestModeRelease = ALLOC_ASN1ELEM (pctxt, H245RequestModeRelease); stat = asn1PD_H245RequestModeRelease (pctxt, pvalue->u.requestModeRelease); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestModeRelease", -1); break; /* miscellaneousIndication */ case 9: invokeStartElement (pctxt, "miscellaneousIndication", -1); pvalue->u.miscellaneousIndication = ALLOC_ASN1ELEM (pctxt, H245MiscellaneousIndication); stat = asn1PD_H245MiscellaneousIndication (pctxt, pvalue->u.miscellaneousIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "miscellaneousIndication", -1); break; /* jitterIndication */ case 10: invokeStartElement (pctxt, "jitterIndication", -1); pvalue->u.jitterIndication = ALLOC_ASN1ELEM (pctxt, H245JitterIndication); stat = asn1PD_H245JitterIndication (pctxt, pvalue->u.jitterIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "jitterIndication", -1); break; /* h223SkewIndication */ case 11: invokeStartElement (pctxt, "h223SkewIndication", -1); pvalue->u.h223SkewIndication = ALLOC_ASN1ELEM (pctxt, H245H223SkewIndication); stat = asn1PD_H245H223SkewIndication (pctxt, pvalue->u.h223SkewIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h223SkewIndication", -1); break; /* newATMVCIndication */ case 12: invokeStartElement (pctxt, "newATMVCIndication", -1); pvalue->u.newATMVCIndication = ALLOC_ASN1ELEM (pctxt, H245NewATMVCIndication); stat = asn1PD_H245NewATMVCIndication (pctxt, pvalue->u.newATMVCIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "newATMVCIndication", -1); break; /* userInput */ case 13: invokeStartElement (pctxt, "userInput", -1); pvalue->u.userInput = ALLOC_ASN1ELEM (pctxt, H245UserInputIndication); stat = asn1PD_H245UserInputIndication (pctxt, pvalue->u.userInput); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "userInput", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 15; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* h2250MaximumSkewIndication */ case 15: invokeStartElement (pctxt, "h2250MaximumSkewIndication", -1); pvalue->u.h2250MaximumSkewIndication = ALLOC_ASN1ELEM (pctxt, H245H2250MaximumSkewIndication); stat = asn1PD_H245H2250MaximumSkewIndication (pctxt, pvalue->u.h2250MaximumSkewIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h2250MaximumSkewIndication", -1); break; /* mcLocationIndication */ case 16: invokeStartElement (pctxt, "mcLocationIndication", -1); pvalue->u.mcLocationIndication = ALLOC_ASN1ELEM (pctxt, H245MCLocationIndication); stat = asn1PD_H245MCLocationIndication (pctxt, pvalue->u.mcLocationIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mcLocationIndication", -1); break; /* conferenceIndication */ case 17: invokeStartElement (pctxt, "conferenceIndication", -1); pvalue->u.conferenceIndication = ALLOC_ASN1ELEM (pctxt, H245ConferenceIndication); stat = asn1PD_H245ConferenceIndication (pctxt, pvalue->u.conferenceIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceIndication", -1); break; /* vendorIdentification */ case 18: invokeStartElement (pctxt, "vendorIdentification", -1); pvalue->u.vendorIdentification = ALLOC_ASN1ELEM (pctxt, H245VendorIdentification); stat = asn1PD_H245VendorIdentification (pctxt, pvalue->u.vendorIdentification); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "vendorIdentification", -1); break; /* functionNotSupported */ case 19: invokeStartElement (pctxt, "functionNotSupported", -1); pvalue->u.functionNotSupported = ALLOC_ASN1ELEM (pctxt, H245FunctionNotSupported); stat = asn1PD_H245FunctionNotSupported (pctxt, pvalue->u.functionNotSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "functionNotSupported", -1); break; /* multilinkIndication */ case 20: invokeStartElement (pctxt, "multilinkIndication", -1); pvalue->u.multilinkIndication = ALLOC_ASN1ELEM (pctxt, H245MultilinkIndication); stat = asn1PD_H245MultilinkIndication (pctxt, pvalue->u.multilinkIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "multilinkIndication", -1); break; /* logicalChannelRateRelease */ case 21: invokeStartElement (pctxt, "logicalChannelRateRelease", -1); pvalue->u.logicalChannelRateRelease = ALLOC_ASN1ELEM (pctxt, H245LogicalChannelRateRelease); stat = asn1PD_H245LogicalChannelRateRelease (pctxt, pvalue->u.logicalChannelRateRelease); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "logicalChannelRateRelease", -1); break; /* flowControlIndication */ case 22: invokeStartElement (pctxt, "flowControlIndication", -1); pvalue->u.flowControlIndication = ALLOC_ASN1ELEM (pctxt, H245FlowControlIndication); stat = asn1PD_H245FlowControlIndication (pctxt, pvalue->u.flowControlIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "flowControlIndication", -1); break; /* mobileMultilinkReconfigurationIndication */ case 23: invokeStartElement (pctxt, "mobileMultilinkReconfigurationIndication", -1); pvalue->u.mobileMultilinkReconfigurationIndication = ALLOC_ASN1ELEM (pctxt, H245MobileMultilinkReconfigurationIndication); stat = asn1PD_H245MobileMultilinkReconfigurationIndication (pctxt, pvalue->u.mobileMultilinkReconfigurationIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mobileMultilinkReconfigurationIndication", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* MultimediaSystemControlMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H245MultimediaSystemControlMessage (OOCTXT* pctxt, H245MultimediaSystemControlMessage* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* request */ case 0: invokeStartElement (pctxt, "request", -1); pvalue->u.request = ALLOC_ASN1ELEM (pctxt, H245RequestMessage); stat = asn1PD_H245RequestMessage (pctxt, pvalue->u.request); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "request", -1); break; /* response */ case 1: invokeStartElement (pctxt, "response", -1); pvalue->u.response = ALLOC_ASN1ELEM (pctxt, H245ResponseMessage); stat = asn1PD_H245ResponseMessage (pctxt, pvalue->u.response); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "response", -1); break; /* command */ case 2: invokeStartElement (pctxt, "command", -1); pvalue->u.command = ALLOC_ASN1ELEM (pctxt, H245CommandMessage); stat = asn1PD_H245CommandMessage (pctxt, pvalue->u.command); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "command", -1); break; /* indication */ case 3: invokeStartElement (pctxt, "indication", -1); pvalue->u.indication = ALLOC_ASN1ELEM (pctxt, H245IndicationMessage); stat = asn1PD_H245IndicationMessage (pctxt, pvalue->u.indication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "indication", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } asterisk-11.7.0/addons/ooh323c/src/h323/H235-SECURITY-MESSAGESEnc.c0000644000175000007640000011143211222440006023121 0ustar sharkyjerryweb/* * 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 "H235-SECURITY-MESSAGES.h" /**************************************************************/ /* */ /* ChallengeString */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ChallengeString (OOCTXT* pctxt, H235ChallengeString* pvalue) { static Asn1SizeCnst lsize1 = { 0, 8, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TimeStamp */ /* */ /**************************************************************/ EXTERN int asn1PE_H235TimeStamp (OOCTXT* pctxt, H235TimeStamp value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RandomVal */ /* */ /**************************************************************/ EXTERN int asn1PE_H235RandomVal (OOCTXT* pctxt, H235RandomVal value) { int stat = ASN_OK; stat = encodeUnconsInteger (pctxt, value); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Password */ /* */ /**************************************************************/ EXTERN int asn1PE_H235Password (OOCTXT* pctxt, H235Password value) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBMPString (pctxt, value, 0); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncodedPwdCertToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H235EncodedPwdCertToken (OOCTXT* pctxt, H235EncodedPwdCertToken value) { int stat = ASN_OK; stat = encodeOpenType (pctxt, value.numocts, value.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H235NonStandardParameter (OOCTXT* pctxt, H235NonStandardParameter* pvalue) { int stat = ASN_OK; /* encode nonStandardIdentifier */ stat = encodeObjectIdentifier (pctxt, &pvalue->nonStandardIdentifier); if (stat != ASN_OK) return stat; /* encode data */ stat = encodeOctetString (pctxt, pvalue->data.numocts, pvalue->data.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* AuthenticationBES */ /* */ /**************************************************************/ EXTERN int asn1PE_H235AuthenticationBES (OOCTXT* pctxt, H235AuthenticationBES* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* default_ */ case 1: /* NULL */ break; /* radius */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* AuthenticationMechanism */ /* */ /**************************************************************/ EXTERN int asn1PE_H235AuthenticationMechanism (OOCTXT* pctxt, H235AuthenticationMechanism* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 7); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 6); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* dhExch */ case 1: /* NULL */ break; /* pwdSymEnc */ case 2: /* NULL */ break; /* pwdHash */ case 3: /* NULL */ break; /* certSign */ case 4: /* NULL */ break; /* ipsec */ case 5: /* NULL */ break; /* tls */ case 6: /* NULL */ break; /* nonStandard */ case 7: stat = asn1PE_H235NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 8); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* authenticationBES */ case 8: stat = asn1PE_H235AuthenticationBES (&lctxt, pvalue->u.authenticationBES); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* DHset_halfkey */ /* */ /**************************************************************/ EXTERN int asn1PE_H235DHset_halfkey (OOCTXT* pctxt, H235DHset_halfkey* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 2048, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DHset_modSize */ /* */ /**************************************************************/ EXTERN int asn1PE_H235DHset_modSize (OOCTXT* pctxt, H235DHset_modSize* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 2048, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DHset_generator */ /* */ /**************************************************************/ EXTERN int asn1PE_H235DHset_generator (OOCTXT* pctxt, H235DHset_generator* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 2048, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DHset */ /* */ /**************************************************************/ EXTERN int asn1PE_H235DHset (OOCTXT* pctxt, H235DHset* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode halfkey */ stat = asn1PE_H235DHset_halfkey (pctxt, &pvalue->halfkey); if (stat != ASN_OK) return stat; /* encode modSize */ stat = asn1PE_H235DHset_modSize (pctxt, &pvalue->modSize); if (stat != ASN_OK) return stat; /* encode generator */ stat = asn1PE_H235DHset_generator (pctxt, &pvalue->generator); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TypedCertificate */ /* */ /**************************************************************/ EXTERN int asn1PE_H235TypedCertificate (OOCTXT* pctxt, H235TypedCertificate* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = encodeObjectIdentifier (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; /* encode certificate */ stat = encodeOctetString (pctxt, pvalue->certificate.numocts, pvalue->certificate.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Identifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H235Identifier (OOCTXT* pctxt, H235Identifier value) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBMPString (pctxt, value, 0); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECpoint_x */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECpoint_x (OOCTXT* pctxt, H235ECpoint_x* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECpoint_y */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECpoint_y (OOCTXT* pctxt, H235ECpoint_y* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECpoint */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECpoint (OOCTXT* pctxt, H235ECpoint* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.xPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.yPresent); /* encode x */ if (pvalue->m.xPresent) { stat = asn1PE_H235ECpoint_x (pctxt, &pvalue->x); if (stat != ASN_OK) return stat; } /* encode y */ if (pvalue->m.yPresent) { stat = asn1PE_H235ECpoint_y (pctxt, &pvalue->y); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp_modulus */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdhp_modulus (OOCTXT* pctxt, H235ECKASDH_eckasdhp_modulus* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp_weierstrassA */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdhp_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassA* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp_weierstrassB */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdhp_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassB* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdhp (OOCTXT* pctxt, H235ECKASDH_eckasdhp* pvalue) { int stat = ASN_OK; /* encode public_key */ stat = asn1PE_H235ECpoint (pctxt, &pvalue->public_key); if (stat != ASN_OK) return stat; /* encode modulus */ stat = asn1PE_H235ECKASDH_eckasdhp_modulus (pctxt, &pvalue->modulus); if (stat != ASN_OK) return stat; /* encode base */ stat = asn1PE_H235ECpoint (pctxt, &pvalue->base); if (stat != ASN_OK) return stat; /* encode weierstrassA */ stat = asn1PE_H235ECKASDH_eckasdhp_weierstrassA (pctxt, &pvalue->weierstrassA); if (stat != ASN_OK) return stat; /* encode weierstrassB */ stat = asn1PE_H235ECKASDH_eckasdhp_weierstrassB (pctxt, &pvalue->weierstrassB); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2_fieldSize */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdh2_fieldSize (OOCTXT* pctxt, H235ECKASDH_eckasdh2_fieldSize* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2_weierstrassA */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdh2_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassA* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2_weierstrassB */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdh2_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassB* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2 */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH_eckasdh2 (OOCTXT* pctxt, H235ECKASDH_eckasdh2* pvalue) { int stat = ASN_OK; /* encode public_key */ stat = asn1PE_H235ECpoint (pctxt, &pvalue->public_key); if (stat != ASN_OK) return stat; /* encode fieldSize */ stat = asn1PE_H235ECKASDH_eckasdh2_fieldSize (pctxt, &pvalue->fieldSize); if (stat != ASN_OK) return stat; /* encode base */ stat = asn1PE_H235ECpoint (pctxt, &pvalue->base); if (stat != ASN_OK) return stat; /* encode weierstrassA */ stat = asn1PE_H235ECKASDH_eckasdh2_weierstrassA (pctxt, &pvalue->weierstrassA); if (stat != ASN_OK) return stat; /* encode weierstrassB */ stat = asn1PE_H235ECKASDH_eckasdh2_weierstrassB (pctxt, &pvalue->weierstrassB); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ECKASDH */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ECKASDH (OOCTXT* pctxt, H235ECKASDH* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* eckasdhp */ case 1: stat = asn1PE_H235ECKASDH_eckasdhp (pctxt, pvalue->u.eckasdhp); if (stat != ASN_OK) return stat; break; /* eckasdh2 */ case 2: stat = asn1PE_H235ECKASDH_eckasdh2 (pctxt, pvalue->u.eckasdh2); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ClearToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ClearToken (OOCTXT* pctxt, H235ClearToken* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.eckasdhkeyPresent || pvalue->m.sendersIDPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.timeStampPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.passwordPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.dhkeyPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.challengePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.randomPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.certificatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.generalIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); /* encode tokenOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; /* encode timeStamp */ if (pvalue->m.timeStampPresent) { stat = asn1PE_H235TimeStamp (pctxt, pvalue->timeStamp); if (stat != ASN_OK) return stat; } /* encode password */ if (pvalue->m.passwordPresent) { stat = asn1PE_H235Password (pctxt, pvalue->password); if (stat != ASN_OK) return stat; } /* encode dhkey */ if (pvalue->m.dhkeyPresent) { stat = asn1PE_H235DHset (pctxt, &pvalue->dhkey); if (stat != ASN_OK) return stat; } /* encode challenge */ if (pvalue->m.challengePresent) { stat = asn1PE_H235ChallengeString (pctxt, &pvalue->challenge); if (stat != ASN_OK) return stat; } /* encode random */ if (pvalue->m.randomPresent) { stat = asn1PE_H235RandomVal (pctxt, pvalue->random); if (stat != ASN_OK) return stat; } /* encode certificate */ if (pvalue->m.certificatePresent) { stat = asn1PE_H235TypedCertificate (pctxt, &pvalue->certificate); if (stat != ASN_OK) return stat; } /* encode generalID */ if (pvalue->m.generalIDPresent) { stat = asn1PE_H235Identifier (pctxt, pvalue->generalID); if (stat != ASN_OK) return stat; } /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H235NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.eckasdhkeyPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sendersIDPresent); /* encode extension elements */ if (pvalue->m.eckasdhkeyPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H235ECKASDH (&lctxt, &pvalue->eckasdhkey); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.sendersIDPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H235Identifier (&lctxt, pvalue->sendersID); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* IV8 */ /* */ /**************************************************************/ EXTERN int asn1PE_H235IV8 (OOCTXT* pctxt, H235IV8* pvalue) { static Asn1SizeCnst lsize1 = { 0, 8, 8, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* IV16 */ /* */ /**************************************************************/ EXTERN int asn1PE_H235IV16 (OOCTXT* pctxt, H235IV16* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Params */ /* */ /**************************************************************/ EXTERN int asn1PE_H235Params (OOCTXT* pctxt, H235Params* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.iv16Present); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.ranIntPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.iv8Present); /* encode ranInt */ if (pvalue->m.ranIntPresent) { stat = encodeUnconsInteger (pctxt, pvalue->ranInt); if (stat != ASN_OK) return stat; } /* encode iv8 */ if (pvalue->m.iv8Present) { stat = asn1PE_H235IV8 (pctxt, &pvalue->iv8); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.iv16Present); /* encode extension elements */ if (pvalue->m.iv16Present) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H235IV16 (&lctxt, &pvalue->iv16); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* ENCRYPTED */ /* */ /**************************************************************/ EXTERN int asn1PE_H235ENCRYPTED (OOCTXT* pctxt, H235ENCRYPTED* pvalue) { int stat = ASN_OK; /* encode algorithmOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; /* encode paramS */ stat = asn1PE_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; /* encode encryptedData */ stat = encodeOctetString (pctxt, pvalue->encryptedData.numocts, pvalue->encryptedData.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoEncryptedToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H235CryptoToken_cryptoEncryptedToken (OOCTXT* pctxt, H235CryptoToken_cryptoEncryptedToken* pvalue) { int stat = ASN_OK; /* encode tokenOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; /* encode token */ stat = asn1PE_H235ENCRYPTED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncodedGeneralToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H235EncodedGeneralToken (OOCTXT* pctxt, H235EncodedGeneralToken value) { int stat = ASN_OK; stat = encodeOpenType (pctxt, value.numocts, value.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoSignedToken_token */ /* */ /**************************************************************/ EXTERN int asn1PE_H235CryptoToken_cryptoSignedToken_token (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken_token* pvalue) { int stat = ASN_OK; /* encode toBeSigned */ stat = asn1PE_H235EncodedGeneralToken (pctxt, pvalue->toBeSigned); if (stat != ASN_OK) return stat; /* encode algorithmOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; /* encode paramS */ stat = asn1PE_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; /* encode signature */ stat = encodeBitString (pctxt, pvalue->signature.numbits, pvalue->signature.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoSignedToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H235CryptoToken_cryptoSignedToken (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken* pvalue) { int stat = ASN_OK; /* encode tokenOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; /* encode token */ stat = asn1PE_H235CryptoToken_cryptoSignedToken_token (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* HASHED */ /* */ /**************************************************************/ EXTERN int asn1PE_H235HASHED (OOCTXT* pctxt, H235HASHED* pvalue) { int stat = ASN_OK; /* encode algorithmOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; /* encode paramS */ stat = asn1PE_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; /* encode hash */ stat = encodeBitString (pctxt, pvalue->hash.numbits, pvalue->hash.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoHashedToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H235CryptoToken_cryptoHashedToken (OOCTXT* pctxt, H235CryptoToken_cryptoHashedToken* pvalue) { int stat = ASN_OK; /* encode tokenOID */ stat = encodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; /* encode hashedVals */ stat = asn1PE_H235ClearToken (pctxt, &pvalue->hashedVals); if (stat != ASN_OK) return stat; /* encode token */ stat = asn1PE_H235HASHED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CryptoToken */ /* */ /**************************************************************/ EXTERN int asn1PE_H235CryptoToken (OOCTXT* pctxt, H235CryptoToken* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* cryptoEncryptedToken */ case 1: stat = asn1PE_H235CryptoToken_cryptoEncryptedToken (pctxt, pvalue->u.cryptoEncryptedToken); if (stat != ASN_OK) return stat; break; /* cryptoSignedToken */ case 2: stat = asn1PE_H235CryptoToken_cryptoSignedToken (pctxt, pvalue->u.cryptoSignedToken); if (stat != ASN_OK) return stat; break; /* cryptoHashedToken */ case 3: stat = asn1PE_H235CryptoToken_cryptoHashedToken (pctxt, pvalue->u.cryptoHashedToken); if (stat != ASN_OK) return stat; break; /* cryptoPwdEncr */ case 4: stat = asn1PE_H235ENCRYPTED (pctxt, pvalue->u.cryptoPwdEncr); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } asterisk-11.7.0/addons/ooh323c/src/h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c0000644000175000007640000273262411222440006023636 0ustar sharkyjerryweb/* * 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" /**************************************************************/ /* */ /* NonStandardIdentifier_h221NonStandard */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NonStandardIdentifier_h221NonStandard (OOCTXT* pctxt, H245NonStandardIdentifier_h221NonStandard* pvalue) { int stat = ASN_OK; /* encode t35CountryCode */ stat = encodeConsUnsigned (pctxt, pvalue->t35CountryCode, 0U, 255U); if (stat != ASN_OK) return stat; /* encode t35Extension */ stat = encodeConsUnsigned (pctxt, pvalue->t35Extension, 0U, 255U); if (stat != ASN_OK) return stat; /* encode manufacturerCode */ stat = encodeConsUnsigned (pctxt, pvalue->manufacturerCode, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NonStandardIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NonStandardIdentifier (OOCTXT* pctxt, H245NonStandardIdentifier* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* object */ case 1: stat = encodeObjectIdentifier (pctxt, pvalue->u.object); if (stat != ASN_OK) return stat; break; /* h221NonStandard */ case 2: stat = asn1PE_H245NonStandardIdentifier_h221NonStandard (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NonStandardParameter (OOCTXT* pctxt, H245NonStandardParameter* pvalue) { int stat = ASN_OK; /* encode nonStandardIdentifier */ stat = asn1PE_H245NonStandardIdentifier (pctxt, &pvalue->nonStandardIdentifier); if (stat != ASN_OK) return stat; /* encode data */ stat = encodeOctetString (pctxt, pvalue->data.numocts, pvalue->data.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* V42bis */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V42bis (OOCTXT* pctxt, H245V42bis* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode numberOfCodewords */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfCodewords, 1U, 65536U); if (stat != ASN_OK) return stat; /* encode maximumStringLength */ stat = encodeConsUnsigned (pctxt, pvalue->maximumStringLength, 1U, 256U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CompressionType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CompressionType (OOCTXT* pctxt, H245CompressionType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* v42bis */ case 1: stat = asn1PE_H245V42bis (pctxt, pvalue->u.v42bis); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* DataProtocolCapability_v76wCompression */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataProtocolCapability_v76wCompression (OOCTXT* pctxt, H245DataProtocolCapability_v76wCompression* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* transmitCompression */ case 1: stat = asn1PE_H245CompressionType (pctxt, pvalue->u.transmitCompression); if (stat != ASN_OK) return stat; break; /* receiveCompression */ case 2: stat = asn1PE_H245CompressionType (pctxt, pvalue->u.receiveCompression); if (stat != ASN_OK) return stat; break; /* transmitAndReceiveCompression */ case 3: stat = asn1PE_H245CompressionType (pctxt, pvalue->u.transmitAndReceiveCompression); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* DataProtocolCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataProtocolCapability (OOCTXT* pctxt, H245DataProtocolCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 7); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 6); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* v14buffered */ case 2: /* NULL */ break; /* v42lapm */ case 3: /* NULL */ break; /* hdlcFrameTunnelling */ case 4: /* NULL */ break; /* h310SeparateVCStack */ case 5: /* NULL */ break; /* h310SingleVCStack */ case 6: /* NULL */ break; /* transparent */ case 7: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 8); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* segmentationAndReassembly */ case 8: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* hdlcFrameTunnelingwSAR */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* v120 */ case 10: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* separateLANStack */ case 11: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* v76wCompression */ case 12: stat = asn1PE_H245DataProtocolCapability_v76wCompression (&lctxt, pvalue->u.v76wCompression); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* tcp */ case 13: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* udp */ case 14: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* T38FaxRateManagement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245T38FaxRateManagement (OOCTXT* pctxt, H245T38FaxRateManagement* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* localTCF */ case 1: /* NULL */ break; /* transferredTCF */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* T38FaxUdpOptions_t38FaxUdpEC */ /* */ /**************************************************************/ EXTERN int asn1PE_H245T38FaxUdpOptions_t38FaxUdpEC (OOCTXT* pctxt, H245T38FaxUdpOptions_t38FaxUdpEC* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* t38UDPFEC */ case 1: /* NULL */ break; /* t38UDPRedundancy */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* T38FaxUdpOptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245T38FaxUdpOptions (OOCTXT* pctxt, H245T38FaxUdpOptions* pvalue) { int stat = ASN_OK; encodeBit (pctxt, (ASN1BOOL)pvalue->m.t38FaxMaxBufferPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.t38FaxMaxDatagramPresent); /* encode t38FaxMaxBuffer */ if (pvalue->m.t38FaxMaxBufferPresent) { stat = encodeUnconsInteger (pctxt, pvalue->t38FaxMaxBuffer); if (stat != ASN_OK) return stat; } /* encode t38FaxMaxDatagram */ if (pvalue->m.t38FaxMaxDatagramPresent) { stat = encodeUnconsInteger (pctxt, pvalue->t38FaxMaxDatagram); if (stat != ASN_OK) return stat; } /* encode t38FaxUdpEC */ stat = asn1PE_H245T38FaxUdpOptions_t38FaxUdpEC (pctxt, &pvalue->t38FaxUdpEC); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* T38FaxTcpOptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245T38FaxTcpOptions (OOCTXT* pctxt, H245T38FaxTcpOptions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode t38TCPBidirectionalMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->t38TCPBidirectionalMode); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* T38FaxProfile */ /* */ /**************************************************************/ EXTERN int asn1PE_H245T38FaxProfile (OOCTXT* pctxt, H245T38FaxProfile* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.versionPresent || pvalue->m.t38FaxRateManagementPresent || pvalue->m.t38FaxUdpOptionsPresent || pvalue->m.t38FaxTcpOptionsPresent); encodeBit (pctxt, extbit); /* encode fillBitRemoval */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fillBitRemoval); if (stat != ASN_OK) return stat; /* encode transcodingJBIG */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->transcodingJBIG); if (stat != ASN_OK) return stat; /* encode transcodingMMR */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->transcodingMMR); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 3); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.versionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.t38FaxRateManagementPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.t38FaxUdpOptionsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.t38FaxTcpOptionsPresent); /* encode extension elements */ if (pvalue->m.versionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->version, 0U, 255U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.t38FaxRateManagementPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245T38FaxRateManagement (&lctxt, &pvalue->t38FaxRateManagement); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.t38FaxUdpOptionsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245T38FaxUdpOptions (&lctxt, &pvalue->t38FaxUdpOptions); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.t38FaxTcpOptionsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245T38FaxTcpOptions (&lctxt, &pvalue->t38FaxTcpOptions); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* NonStandardMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NonStandardMessage (OOCTXT* pctxt, H245NonStandardMessage* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode nonStandardData */ stat = asn1PE_H245NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MasterSlaveDetermination */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MasterSlaveDetermination (OOCTXT* pctxt, H245MasterSlaveDetermination* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalType */ stat = encodeConsUnsigned (pctxt, pvalue->terminalType, 0U, 255U); if (stat != ASN_OK) return stat; /* encode statusDeterminationNumber */ stat = encodeConsUnsigned (pctxt, pvalue->statusDeterminationNumber, 0U, 16777215U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* SequenceNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245SequenceNumber (OOCTXT* pctxt, H245SequenceNumber value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 0U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VCCapability_aal1 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability_aal1 (OOCTXT* pctxt, H245VCCapability_aal1* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode nullClockRecovery */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->nullClockRecovery); if (stat != ASN_OK) return stat; /* encode srtsClockRecovery */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->srtsClockRecovery); if (stat != ASN_OK) return stat; /* encode adaptiveClockRecovery */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->adaptiveClockRecovery); if (stat != ASN_OK) return stat; /* encode nullErrorCorrection */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->nullErrorCorrection); if (stat != ASN_OK) return stat; /* encode longInterleaver */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->longInterleaver); if (stat != ASN_OK) return stat; /* encode shortInterleaver */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->shortInterleaver); if (stat != ASN_OK) return stat; /* encode errorCorrectionOnly */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->errorCorrectionOnly); if (stat != ASN_OK) return stat; /* encode structuredDataTransfer */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; /* encode partiallyFilledCells */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VCCapability_aal5 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability_aal5 (OOCTXT* pctxt, H245VCCapability_aal5* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardMaximumSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->forwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode backwardMaximumSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->backwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VCCapability_availableBitRates_type_rangeOfBitRates */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability_availableBitRates_type_rangeOfBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates_type_rangeOfBitRates* pvalue) { int stat = ASN_OK; /* encode lowerBitRate */ stat = encodeConsUnsigned (pctxt, pvalue->lowerBitRate, 1U, 65535U); if (stat != ASN_OK) return stat; /* encode higherBitRate */ stat = encodeConsUnsigned (pctxt, pvalue->higherBitRate, 1U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VCCapability_availableBitRates_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability_availableBitRates_type (OOCTXT* pctxt, H245VCCapability_availableBitRates_type* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* singleBitRate */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.singleBitRate, 1U, 65535U); if (stat != ASN_OK) return stat; break; /* rangeOfBitRates */ case 2: stat = asn1PE_H245VCCapability_availableBitRates_type_rangeOfBitRates (pctxt, pvalue->u.rangeOfBitRates); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* VCCapability_availableBitRates */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability_availableBitRates (OOCTXT* pctxt, H245VCCapability_availableBitRates* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245VCCapability_availableBitRates_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Q2931Address_address_nsapAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Q2931Address_address_nsapAddress (OOCTXT* pctxt, H245Q2931Address_address_nsapAddress* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Q2931Address_address */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Q2931Address_address (OOCTXT* pctxt, H245Q2931Address_address* pvalue) { static Asn1SizeCnst internationalNumber_lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* internationalNumber */ case 1: addSizeConstraint (pctxt, &internationalNumber_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.internationalNumber, NUM_CANSET, 4, 4, 4); if (stat != ASN_OK) return stat; break; /* nsapAddress */ case 2: stat = asn1PE_H245Q2931Address_address_nsapAddress (pctxt, pvalue->u.nsapAddress); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* Q2931Address_subaddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Q2931Address_subaddress (OOCTXT* pctxt, H245Q2931Address_subaddress* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Q2931Address */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Q2931Address (OOCTXT* pctxt, H245Q2931Address* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.subaddressPresent); /* encode address */ stat = asn1PE_H245Q2931Address_address (pctxt, &pvalue->address); if (stat != ASN_OK) return stat; /* encode subaddress */ if (pvalue->m.subaddressPresent) { stat = asn1PE_H245Q2931Address_subaddress (pctxt, &pvalue->subaddress); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* VCCapability_aal1ViaGateway_gatewayAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability_aal1ViaGateway_gatewayAddress (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway_gatewayAddress* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245Q2931Address (pctxt, ((H245Q2931Address*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* VCCapability_aal1ViaGateway */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability_aal1ViaGateway (OOCTXT* pctxt, H245VCCapability_aal1ViaGateway* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode gatewayAddress */ stat = asn1PE_H245VCCapability_aal1ViaGateway_gatewayAddress (pctxt, &pvalue->gatewayAddress); if (stat != ASN_OK) return stat; /* encode nullClockRecovery */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->nullClockRecovery); if (stat != ASN_OK) return stat; /* encode srtsClockRecovery */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->srtsClockRecovery); if (stat != ASN_OK) return stat; /* encode adaptiveClockRecovery */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->adaptiveClockRecovery); if (stat != ASN_OK) return stat; /* encode nullErrorCorrection */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->nullErrorCorrection); if (stat != ASN_OK) return stat; /* encode longInterleaver */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->longInterleaver); if (stat != ASN_OK) return stat; /* encode shortInterleaver */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->shortInterleaver); if (stat != ASN_OK) return stat; /* encode errorCorrectionOnly */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->errorCorrectionOnly); if (stat != ASN_OK) return stat; /* encode structuredDataTransfer */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; /* encode partiallyFilledCells */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VCCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VCCapability (OOCTXT* pctxt, H245VCCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.aal1ViaGatewayPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.aal1Present); encodeBit (pctxt, (ASN1BOOL)pvalue->m.aal5Present); /* encode aal1 */ if (pvalue->m.aal1Present) { stat = asn1PE_H245VCCapability_aal1 (pctxt, &pvalue->aal1); if (stat != ASN_OK) return stat; } /* encode aal5 */ if (pvalue->m.aal5Present) { stat = asn1PE_H245VCCapability_aal5 (pctxt, &pvalue->aal5); if (stat != ASN_OK) return stat; } /* encode transportStream */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->transportStream); if (stat != ASN_OK) return stat; /* encode programStream */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->programStream); if (stat != ASN_OK) return stat; /* encode availableBitRates */ stat = asn1PE_H245VCCapability_availableBitRates (pctxt, &pvalue->availableBitRates); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.aal1ViaGatewayPresent); /* encode extension elements */ if (pvalue->m.aal1ViaGatewayPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245VCCapability_aal1ViaGateway (&lctxt, &pvalue->aal1ViaGateway); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* _SetOfH245VCCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SetOfH245VCCapability (OOCTXT* pctxt, H245_SetOfH245VCCapability* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245VCCapability (pctxt, ((H245VCCapability*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* H222Capability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H222Capability (OOCTXT* pctxt, H245H222Capability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode numberOfVCs */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfVCs, 1U, 256U); if (stat != ASN_OK) return stat; /* encode vcCapability */ stat = asn1PE_H245_SetOfH245VCCapability (pctxt, &pvalue->vcCapability); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223Capability_h223MultiplexTableCapability_enhanced */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223Capability_h223MultiplexTableCapability_enhanced (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability_enhanced* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode maximumNestingDepth */ stat = encodeConsUnsigned (pctxt, pvalue->maximumNestingDepth, 1U, 15U); if (stat != ASN_OK) return stat; /* encode maximumElementListSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumElementListSize, 2U, 255U); if (stat != ASN_OK) return stat; /* encode maximumSubElementListSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumSubElementListSize, 2U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223Capability_h223MultiplexTableCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223Capability_h223MultiplexTableCapability (OOCTXT* pctxt, H245H223Capability_h223MultiplexTableCapability* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* basic */ case 1: /* NULL */ break; /* enhanced */ case 2: stat = asn1PE_H245H223Capability_h223MultiplexTableCapability_enhanced (pctxt, pvalue->u.enhanced); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* H223Capability_mobileOperationTransmitCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223Capability_mobileOperationTransmitCapability (OOCTXT* pctxt, H245H223Capability_mobileOperationTransmitCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode modeChangeCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->modeChangeCapability); if (stat != ASN_OK) return stat; /* encode h223AnnexA */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->h223AnnexA); if (stat != ASN_OK) return stat; /* encode h223AnnexADoubleFlag */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->h223AnnexADoubleFlag); if (stat != ASN_OK) return stat; /* encode h223AnnexB */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->h223AnnexB); if (stat != ASN_OK) return stat; /* encode h223AnnexBwithHeader */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->h223AnnexBwithHeader); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223AnnexCCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AnnexCCapability (OOCTXT* pctxt, H245H223AnnexCCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.rsCodeCapabilityPresent); encodeBit (pctxt, extbit); /* encode videoWithAL1M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoWithAL1M); if (stat != ASN_OK) return stat; /* encode videoWithAL2M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoWithAL2M); if (stat != ASN_OK) return stat; /* encode videoWithAL3M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoWithAL3M); if (stat != ASN_OK) return stat; /* encode audioWithAL1M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioWithAL1M); if (stat != ASN_OK) return stat; /* encode audioWithAL2M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioWithAL2M); if (stat != ASN_OK) return stat; /* encode audioWithAL3M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioWithAL3M); if (stat != ASN_OK) return stat; /* encode dataWithAL1M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dataWithAL1M); if (stat != ASN_OK) return stat; /* encode dataWithAL2M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dataWithAL2M); if (stat != ASN_OK) return stat; /* encode dataWithAL3M */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dataWithAL3M); if (stat != ASN_OK) return stat; /* encode alpduInterleaving */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; /* encode maximumAL1MPDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumAL1MPDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode maximumAL2MSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumAL2MSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode maximumAL3MSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumAL3MSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.rsCodeCapabilityPresent); /* encode extension elements */ if (pvalue->m.rsCodeCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->rsCodeCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H223Capability_mobileMultilinkFrameCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223Capability_mobileMultilinkFrameCapability (OOCTXT* pctxt, H245H223Capability_mobileMultilinkFrameCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode maximumSampleSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumSampleSize, 1U, 255U); if (stat != ASN_OK) return stat; /* encode maximumPayloadLength */ stat = encodeConsUnsigned (pctxt, pvalue->maximumPayloadLength, 1U, 65025U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223Capability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223Capability (OOCTXT* pctxt, H245H223Capability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.maxMUXPDUSizeCapabilityPresent || pvalue->m.nsrpSupportPresent || pvalue->m.mobileOperationTransmitCapabilityPresent || pvalue->m.h223AnnexCCapabilityPresent || pvalue->m.bitRatePresent || pvalue->m.mobileMultilinkFrameCapabilityPresent); encodeBit (pctxt, extbit); /* encode transportWithI_frames */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->transportWithI_frames); if (stat != ASN_OK) return stat; /* encode videoWithAL1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoWithAL1); if (stat != ASN_OK) return stat; /* encode videoWithAL2 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoWithAL2); if (stat != ASN_OK) return stat; /* encode videoWithAL3 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoWithAL3); if (stat != ASN_OK) return stat; /* encode audioWithAL1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioWithAL1); if (stat != ASN_OK) return stat; /* encode audioWithAL2 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioWithAL2); if (stat != ASN_OK) return stat; /* encode audioWithAL3 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioWithAL3); if (stat != ASN_OK) return stat; /* encode dataWithAL1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dataWithAL1); if (stat != ASN_OK) return stat; /* encode dataWithAL2 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dataWithAL2); if (stat != ASN_OK) return stat; /* encode dataWithAL3 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dataWithAL3); if (stat != ASN_OK) return stat; /* encode maximumAl2SDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumAl2SDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode maximumAl3SDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->maximumAl3SDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode maximumDelayJitter */ stat = encodeConsUnsigned (pctxt, pvalue->maximumDelayJitter, 0U, 1023U); if (stat != ASN_OK) return stat; /* encode h223MultiplexTableCapability */ stat = asn1PE_H245H223Capability_h223MultiplexTableCapability (pctxt, &pvalue->h223MultiplexTableCapability); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 5); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.maxMUXPDUSizeCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nsrpSupportPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mobileOperationTransmitCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h223AnnexCCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bitRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mobileMultilinkFrameCapabilityPresent); /* encode extension elements */ if (pvalue->m.maxMUXPDUSizeCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->maxMUXPDUSizeCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.nsrpSupportPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->nsrpSupport); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.mobileOperationTransmitCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H223Capability_mobileOperationTransmitCapability (&lctxt, &pvalue->mobileOperationTransmitCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h223AnnexCCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H223AnnexCCapability (&lctxt, &pvalue->h223AnnexCCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.bitRatePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->bitRate, 1U, 19200U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.mobileMultilinkFrameCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H223Capability_mobileMultilinkFrameCapability (&lctxt, &pvalue->mobileMultilinkFrameCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* V75Capability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V75Capability (OOCTXT* pctxt, H245V75Capability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioHeader */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioHeader); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* V76Capability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76Capability (OOCTXT* pctxt, H245V76Capability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode suspendResumeCapabilitywAddress */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->suspendResumeCapabilitywAddress); if (stat != ASN_OK) return stat; /* encode suspendResumeCapabilitywoAddress */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->suspendResumeCapabilitywoAddress); if (stat != ASN_OK) return stat; /* encode rejCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->rejCapability); if (stat != ASN_OK) return stat; /* encode sREJCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->sREJCapability); if (stat != ASN_OK) return stat; /* encode mREJCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->mREJCapability); if (stat != ASN_OK) return stat; /* encode crc8bitCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->crc8bitCapability); if (stat != ASN_OK) return stat; /* encode crc16bitCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->crc16bitCapability); if (stat != ASN_OK) return stat; /* encode crc32bitCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->crc32bitCapability); if (stat != ASN_OK) return stat; /* encode uihCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->uihCapability); if (stat != ASN_OK) return stat; /* encode numOfDLCS */ stat = encodeConsUnsigned (pctxt, pvalue->numOfDLCS, 2U, 8191U); if (stat != ASN_OK) return stat; /* encode twoOctetAddressFieldCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->twoOctetAddressFieldCapability); if (stat != ASN_OK) return stat; /* encode loopBackTestCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->loopBackTestCapability); if (stat != ASN_OK) return stat; /* encode n401Capability */ stat = encodeConsUnsigned (pctxt, pvalue->n401Capability, 1U, 4095U); if (stat != ASN_OK) return stat; /* encode maxWindowSizeCapability */ stat = encodeConsUnsigned (pctxt, pvalue->maxWindowSizeCapability, 1U, 127U); if (stat != ASN_OK) return stat; /* encode v75Capability */ stat = asn1PE_H245V75Capability (pctxt, &pvalue->v75Capability); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* T84Profile_t84Restricted */ /* */ /**************************************************************/ EXTERN int asn1PE_H245T84Profile_t84Restricted (OOCTXT* pctxt, H245T84Profile_t84Restricted* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode qcif */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->qcif); if (stat != ASN_OK) return stat; /* encode cif */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->cif); if (stat != ASN_OK) return stat; /* encode ccir601Seq */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->ccir601Seq); if (stat != ASN_OK) return stat; /* encode ccir601Prog */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->ccir601Prog); if (stat != ASN_OK) return stat; /* encode hdtvSeq */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->hdtvSeq); if (stat != ASN_OK) return stat; /* encode hdtvProg */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->hdtvProg); if (stat != ASN_OK) return stat; /* encode g3FacsMH200x100 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->g3FacsMH200x100); if (stat != ASN_OK) return stat; /* encode g3FacsMH200x200 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->g3FacsMH200x200); if (stat != ASN_OK) return stat; /* encode g4FacsMMR200x100 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->g4FacsMMR200x100); if (stat != ASN_OK) return stat; /* encode g4FacsMMR200x200 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->g4FacsMMR200x200); if (stat != ASN_OK) return stat; /* encode jbig200x200Seq */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->jbig200x200Seq); if (stat != ASN_OK) return stat; /* encode jbig200x200Prog */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->jbig200x200Prog); if (stat != ASN_OK) return stat; /* encode jbig300x300Seq */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->jbig300x300Seq); if (stat != ASN_OK) return stat; /* encode jbig300x300Prog */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->jbig300x300Prog); if (stat != ASN_OK) return stat; /* encode digPhotoLow */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->digPhotoLow); if (stat != ASN_OK) return stat; /* encode digPhotoMedSeq */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->digPhotoMedSeq); if (stat != ASN_OK) return stat; /* encode digPhotoMedProg */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->digPhotoMedProg); if (stat != ASN_OK) return stat; /* encode digPhotoHighSeq */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->digPhotoHighSeq); if (stat != ASN_OK) return stat; /* encode digPhotoHighProg */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->digPhotoHighProg); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* T84Profile */ /* */ /**************************************************************/ EXTERN int asn1PE_H245T84Profile (OOCTXT* pctxt, H245T84Profile* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* t84Unrestricted */ case 1: /* NULL */ break; /* t84Restricted */ case 2: stat = asn1PE_H245T84Profile_t84Restricted (pctxt, pvalue->u.t84Restricted); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application_t84 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataApplicationCapability_application_t84 (OOCTXT* pctxt, H245DataApplicationCapability_application_t84* pvalue) { int stat = ASN_OK; /* encode t84Protocol */ stat = asn1PE_H245DataProtocolCapability (pctxt, &pvalue->t84Protocol); if (stat != ASN_OK) return stat; /* encode t84Profile */ stat = asn1PE_H245T84Profile (pctxt, &pvalue->t84Profile); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application_nlpid */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataApplicationCapability_application_nlpid (OOCTXT* pctxt, H245DataApplicationCapability_application_nlpid* pvalue) { int stat = ASN_OK; /* encode nlpidProtocol */ stat = asn1PE_H245DataProtocolCapability (pctxt, &pvalue->nlpidProtocol); if (stat != ASN_OK) return stat; /* encode nlpidData */ stat = encodeOctetString (pctxt, pvalue->nlpidData.numocts, pvalue->nlpidData.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application_t38fax */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataApplicationCapability_application_t38fax (OOCTXT* pctxt, H245DataApplicationCapability_application_t38fax* pvalue) { int stat = ASN_OK; /* encode t38FaxProtocol */ stat = asn1PE_H245DataProtocolCapability (pctxt, &pvalue->t38FaxProtocol); if (stat != ASN_OK) return stat; /* encode t38FaxProfile */ stat = asn1PE_H245T38FaxProfile (pctxt, &pvalue->t38FaxProfile); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CapabilityIdentifier_uuid */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CapabilityIdentifier_uuid (OOCTXT* pctxt, H245CapabilityIdentifier_uuid* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CapabilityIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CapabilityIdentifier (OOCTXT* pctxt, H245CapabilityIdentifier* pvalue) { static Asn1SizeCnst domainBased_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* standard */ case 1: stat = encodeObjectIdentifier (pctxt, pvalue->u.standard); if (stat != ASN_OK) return stat; break; /* h221NonStandard */ case 2: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; break; /* uuid */ case 3: stat = asn1PE_H245CapabilityIdentifier_uuid (pctxt, pvalue->u.uuid); if (stat != ASN_OK) return stat; break; /* domainBased */ case 4: addSizeConstraint (pctxt, &domainBased_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.domainBased, 0, 8, 7, 7); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ParameterIdentifier_uuid */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ParameterIdentifier_uuid (OOCTXT* pctxt, H245ParameterIdentifier_uuid* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ParameterIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ParameterIdentifier (OOCTXT* pctxt, H245ParameterIdentifier* pvalue) { static Asn1SizeCnst domainBased_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* standard */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.standard, 0U, 127U); if (stat != ASN_OK) return stat; break; /* h221NonStandard */ case 2: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; break; /* uuid */ case 3: stat = asn1PE_H245ParameterIdentifier_uuid (pctxt, pvalue->u.uuid); if (stat != ASN_OK) return stat; break; /* domainBased */ case 4: addSizeConstraint (pctxt, &domainBased_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.domainBased, 0, 8, 7, 7); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ParameterValue */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ParameterValue (OOCTXT* pctxt, H245ParameterValue* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 8); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 7); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* logical */ case 1: /* NULL */ break; /* booleanArray */ case 2: stat = encodeConsUnsigned (pctxt, pvalue->u.booleanArray, 0U, 255U); if (stat != ASN_OK) return stat; break; /* unsignedMin */ case 3: stat = encodeConsUnsigned (pctxt, pvalue->u.unsignedMin, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* unsignedMax */ case 4: stat = encodeConsUnsigned (pctxt, pvalue->u.unsignedMax, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* unsigned32Min */ case 5: stat = encodeConsUnsigned (pctxt, pvalue->u.unsigned32Min, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; break; /* unsigned32Max */ case 6: stat = encodeConsUnsigned (pctxt, pvalue->u.unsigned32Max, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; break; /* octetString */ case 7: stat = encodeOctetString (pctxt, pvalue->u.octetString->numocts, pvalue->u.octetString->data); if (stat != ASN_OK) return stat; break; /* genericParameter */ case 8: stat = asn1PE_H245_SeqOfH245GenericParameter (pctxt, (H245_SeqOfH245GenericParameter*)pvalue->u.genericParameter); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 9); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245ParameterIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245ParameterIdentifier (OOCTXT* pctxt, H245_SeqOfH245ParameterIdentifier* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245ParameterIdentifier (pctxt, ((H245ParameterIdentifier*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* GenericParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H245GenericParameter (OOCTXT* pctxt, H245GenericParameter* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.supersedesPresent); /* encode parameterIdentifier */ stat = asn1PE_H245ParameterIdentifier (pctxt, &pvalue->parameterIdentifier); if (stat != ASN_OK) return stat; /* encode parameterValue */ stat = asn1PE_H245ParameterValue (pctxt, &pvalue->parameterValue); if (stat != ASN_OK) return stat; /* encode supersedes */ if (pvalue->m.supersedesPresent) { stat = asn1PE_H245_SeqOfH245ParameterIdentifier (pctxt, &pvalue->supersedes); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245GenericParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245GenericParameter (OOCTXT* pctxt, H245_SeqOfH245GenericParameter* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245GenericParameter (pctxt, ((H245GenericParameter*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* GenericCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245GenericCapability (OOCTXT* pctxt, H245GenericCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maxBitRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.collapsingPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonCollapsingPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonCollapsingRawPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.transportPresent); /* encode capabilityIdentifier */ stat = asn1PE_H245CapabilityIdentifier (pctxt, &pvalue->capabilityIdentifier); if (stat != ASN_OK) return stat; /* encode maxBitRate */ if (pvalue->m.maxBitRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->maxBitRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode collapsing */ if (pvalue->m.collapsingPresent) { stat = asn1PE_H245_SeqOfH245GenericParameter (pctxt, &pvalue->collapsing); if (stat != ASN_OK) return stat; } /* encode nonCollapsing */ if (pvalue->m.nonCollapsingPresent) { stat = asn1PE_H245_SeqOfH245GenericParameter (pctxt, &pvalue->nonCollapsing); if (stat != ASN_OK) return stat; } /* encode nonCollapsingRaw */ if (pvalue->m.nonCollapsingRawPresent) { stat = encodeOctetString (pctxt, pvalue->nonCollapsingRaw.numocts, pvalue->nonCollapsingRaw.data); if (stat != ASN_OK) return stat; } /* encode transport */ if (pvalue->m.transportPresent) { stat = asn1PE_H245DataProtocolCapability (pctxt, &pvalue->transport); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability_application */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataApplicationCapability_application (OOCTXT* pctxt, H245DataApplicationCapability_application* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 10); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 9); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* t120 */ case 2: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.t120); if (stat != ASN_OK) return stat; break; /* dsm_cc */ case 3: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.dsm_cc); if (stat != ASN_OK) return stat; break; /* userData */ case 4: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.userData); if (stat != ASN_OK) return stat; break; /* t84 */ case 5: stat = asn1PE_H245DataApplicationCapability_application_t84 (pctxt, pvalue->u.t84); if (stat != ASN_OK) return stat; break; /* t434 */ case 6: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.t434); if (stat != ASN_OK) return stat; break; /* h224 */ case 7: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.h224); if (stat != ASN_OK) return stat; break; /* nlpid */ case 8: stat = asn1PE_H245DataApplicationCapability_application_nlpid (pctxt, pvalue->u.nlpid); if (stat != ASN_OK) return stat; break; /* dsvdControl */ case 9: /* NULL */ break; /* h222DataPartitioning */ case 10: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.h222DataPartitioning); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 11); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* t30fax */ case 11: stat = asn1PE_H245DataProtocolCapability (&lctxt, pvalue->u.t30fax); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* t140 */ case 12: stat = asn1PE_H245DataProtocolCapability (&lctxt, pvalue->u.t140); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* t38fax */ case 13: stat = asn1PE_H245DataApplicationCapability_application_t38fax (&lctxt, pvalue->u.t38fax); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericDataCapability */ case 14: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericDataCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* DataApplicationCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataApplicationCapability (OOCTXT* pctxt, H245DataApplicationCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode application */ stat = asn1PE_H245DataApplicationCapability_application (pctxt, &pvalue->application); if (stat != ASN_OK) return stat; /* encode maxBitRate */ stat = encodeConsUnsigned (pctxt, pvalue->maxBitRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH245DataApplicationCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245DataApplicationCapability (OOCTXT* pctxt, H245_SeqOfH245DataApplicationCapability* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245DataApplicationCapability (pctxt, ((H245DataApplicationCapability*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* MediaDistributionCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MediaDistributionCapability (OOCTXT* pctxt, H245MediaDistributionCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.centralizedDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.distributedDataPresent); /* encode centralizedControl */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->centralizedControl); if (stat != ASN_OK) return stat; /* encode distributedControl */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->distributedControl); if (stat != ASN_OK) return stat; /* encode centralizedAudio */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->centralizedAudio); if (stat != ASN_OK) return stat; /* encode distributedAudio */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->distributedAudio); if (stat != ASN_OK) return stat; /* encode centralizedVideo */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->centralizedVideo); if (stat != ASN_OK) return stat; /* encode distributedVideo */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->distributedVideo); if (stat != ASN_OK) return stat; /* encode centralizedData */ if (pvalue->m.centralizedDataPresent) { stat = asn1PE_H245_SeqOfH245DataApplicationCapability (pctxt, &pvalue->centralizedData); if (stat != ASN_OK) return stat; } /* encode distributedData */ if (pvalue->m.distributedDataPresent) { stat = asn1PE_H245_SeqOfH245DataApplicationCapability (pctxt, &pvalue->distributedData); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245MediaDistributionCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245MediaDistributionCapability (OOCTXT* pctxt, H245_SeqOfH245MediaDistributionCapability* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245MediaDistributionCapability (pctxt, ((H245MediaDistributionCapability*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* MultipointCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultipointCapability (OOCTXT* pctxt, H245MultipointCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode multicastCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->multicastCapability); if (stat != ASN_OK) return stat; /* encode multiUniCastConference */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->multiUniCastConference); if (stat != ASN_OK) return stat; /* encode mediaDistributionCapability */ stat = asn1PE_H245_SeqOfH245MediaDistributionCapability (pctxt, &pvalue->mediaDistributionCapability); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H2250Capability_mcCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250Capability_mcCapability (OOCTXT* pctxt, H245H2250Capability_mcCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode centralizedConferenceMC */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->centralizedConferenceMC); if (stat != ASN_OK) return stat; /* encode decentralizedConferenceMC */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->decentralizedConferenceMC); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RTPPayloadType_payloadDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPPayloadType_payloadDescriptor (OOCTXT* pctxt, H245RTPPayloadType_payloadDescriptor* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandardIdentifier */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandardIdentifier); if (stat != ASN_OK) return stat; break; /* rfc_number */ case 2: if ( (pvalue->u.rfc_number >= 1 && pvalue->u.rfc_number <= 32768) ) { extbit = 0; } else extbit = 1; /* extension bit */ encodeBit (pctxt, extbit); if (extbit) { stat = encodeUnconsInteger (pctxt, pvalue->u.rfc_number); if (stat != ASN_OK) return stat; } else { stat = encodeConsInteger (pctxt, pvalue->u.rfc_number, 1, 32768); if (stat != ASN_OK) return stat; } break; /* oid */ case 3: stat = encodeObjectIdentifier (pctxt, pvalue->u.oid); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RTPPayloadType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPPayloadType (OOCTXT* pctxt, H245RTPPayloadType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.payloadTypePresent); /* encode payloadDescriptor */ stat = asn1PE_H245RTPPayloadType_payloadDescriptor (pctxt, &pvalue->payloadDescriptor); if (stat != ASN_OK) return stat; /* encode payloadType */ if (pvalue->m.payloadTypePresent) { stat = encodeConsUnsigned (pctxt, pvalue->payloadType, 0U, 127U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MediaPacketizationCapability_rtpPayloadType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MediaPacketizationCapability_rtpPayloadType (OOCTXT* pctxt, H245MediaPacketizationCapability_rtpPayloadType* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245RTPPayloadType (pctxt, ((H245RTPPayloadType*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MediaPacketizationCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MediaPacketizationCapability (OOCTXT* pctxt, H245MediaPacketizationCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.rtpPayloadTypePresent); encodeBit (pctxt, extbit); /* encode h261aVideoPacketization */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->h261aVideoPacketization); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.rtpPayloadTypePresent); /* encode extension elements */ if (pvalue->m.rtpPayloadTypePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245MediaPacketizationCapability_rtpPayloadType (&lctxt, &pvalue->rtpPayloadType); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* QOSMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245QOSMode (OOCTXT* pctxt, H245QOSMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* guaranteedQOS */ case 1: /* NULL */ break; /* controlledLoad */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RSVPParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RSVPParameters (OOCTXT* pctxt, H245RSVPParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qosModePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.tokenRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bucketSizePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.peakRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.minPolicedPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.maxPktSizePresent); /* encode qosMode */ if (pvalue->m.qosModePresent) { stat = asn1PE_H245QOSMode (pctxt, &pvalue->qosMode); if (stat != ASN_OK) return stat; } /* encode tokenRate */ if (pvalue->m.tokenRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->tokenRate, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode bucketSize */ if (pvalue->m.bucketSizePresent) { stat = encodeConsUnsigned (pctxt, pvalue->bucketSize, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode peakRate */ if (pvalue->m.peakRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->peakRate, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode minPoliced */ if (pvalue->m.minPolicedPresent) { stat = encodeConsUnsigned (pctxt, pvalue->minPoliced, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode maxPktSize */ if (pvalue->m.maxPktSizePresent) { stat = encodeConsUnsigned (pctxt, pvalue->maxPktSize, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ATMParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ATMParameters (OOCTXT* pctxt, H245ATMParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode maxNTUSize */ stat = encodeConsUnsigned (pctxt, pvalue->maxNTUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode atmUBR */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->atmUBR); if (stat != ASN_OK) return stat; /* encode atmrtVBR */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->atmrtVBR); if (stat != ASN_OK) return stat; /* encode atmnrtVBR */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->atmnrtVBR); if (stat != ASN_OK) return stat; /* encode atmABR */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->atmABR); if (stat != ASN_OK) return stat; /* encode atmCBR */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->atmCBR); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* QOSCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245QOSCapability (OOCTXT* pctxt, H245QOSCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.rsvpParametersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.atmParametersPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H245NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode rsvpParameters */ if (pvalue->m.rsvpParametersPresent) { stat = asn1PE_H245RSVPParameters (pctxt, &pvalue->rsvpParameters); if (stat != ASN_OK) return stat; } /* encode atmParameters */ if (pvalue->m.atmParametersPresent) { stat = asn1PE_H245ATMParameters (pctxt, &pvalue->atmParameters); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TransportCapability_qOSCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TransportCapability_qOSCapabilities (OOCTXT* pctxt, H245TransportCapability_qOSCapabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245QOSCapability (pctxt, ((H245QOSCapability*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MediaTransportType_atm_AAL5_compressed */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MediaTransportType_atm_AAL5_compressed (OOCTXT* pctxt, H245MediaTransportType_atm_AAL5_compressed* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode variable_delta */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->variable_delta); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MediaTransportType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MediaTransportType (OOCTXT* pctxt, H245MediaTransportType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* ip_UDP */ case 1: /* NULL */ break; /* ip_TCP */ case 2: /* NULL */ break; /* atm_AAL5_UNIDIR */ case 3: /* NULL */ break; /* atm_AAL5_BIDIR */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* atm_AAL5_compressed */ case 5: stat = asn1PE_H245MediaTransportType_atm_AAL5_compressed (&lctxt, pvalue->u.atm_AAL5_compressed); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MediaChannelCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MediaChannelCapability (OOCTXT* pctxt, H245MediaChannelCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaTransportPresent); /* encode mediaTransport */ if (pvalue->m.mediaTransportPresent) { stat = asn1PE_H245MediaTransportType (pctxt, &pvalue->mediaTransport); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TransportCapability_mediaChannelCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TransportCapability_mediaChannelCapabilities (OOCTXT* pctxt, H245TransportCapability_mediaChannelCapabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245MediaChannelCapability (pctxt, ((H245MediaChannelCapability*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* TransportCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TransportCapability (OOCTXT* pctxt, H245TransportCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qOSCapabilitiesPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaChannelCapabilitiesPresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } /* encode qOSCapabilities */ if (pvalue->m.qOSCapabilitiesPresent) { stat = asn1PE_H245TransportCapability_qOSCapabilities (pctxt, &pvalue->qOSCapabilities); if (stat != ASN_OK) return stat; } /* encode mediaChannelCapabilities */ if (pvalue->m.mediaChannelCapabilitiesPresent) { stat = asn1PE_H245TransportCapability_mediaChannelCapabilities (pctxt, &pvalue->mediaChannelCapabilities); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyFrameMapping_frameSequence */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPH263VideoRedundancyFrameMapping_frameSequence (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping_frameSequence* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeConsUnsigned (pctxt, pvalue->elem[xx1], 0U, 255U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyFrameMapping */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPH263VideoRedundancyFrameMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyFrameMapping* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode threadNumber */ stat = encodeConsUnsigned (pctxt, pvalue->threadNumber, 0U, 15U); if (stat != ASN_OK) return stat; /* encode frameSequence */ stat = asn1PE_H245RTPH263VideoRedundancyFrameMapping_frameSequence (pctxt, &pvalue->frameSequence); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_frameToThreadMapping_cust */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245RTPH263VideoRedundancyFrameMapping (pctxt, ((H245RTPH263VideoRedundancyFrameMapping*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_frameToThreadMapping */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_frameToThreadMapping* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* roundrobin */ case 1: /* NULL */ break; /* custom */ case 2: stat = asn1PE_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping_custom (pctxt, pvalue->u.custom); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding_containedThreads */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding_containedThreads (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding_containedThreads* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeConsUnsigned (pctxt, pvalue->elem[xx1], 0U, 15U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RTPH263VideoRedundancyEncoding */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RTPH263VideoRedundancyEncoding (OOCTXT* pctxt, H245RTPH263VideoRedundancyEncoding* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.containedThreadsPresent); /* encode numberOfThreads */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfThreads, 1U, 16U); if (stat != ASN_OK) return stat; /* encode framesBetweenSyncPoints */ stat = encodeConsUnsigned (pctxt, pvalue->framesBetweenSyncPoints, 1U, 256U); if (stat != ASN_OK) return stat; /* encode frameToThreadMapping */ stat = asn1PE_H245RTPH263VideoRedundancyEncoding_frameToThreadMapping (pctxt, &pvalue->frameToThreadMapping); if (stat != ASN_OK) return stat; /* encode containedThreads */ if (pvalue->m.containedThreadsPresent) { stat = asn1PE_H245RTPH263VideoRedundancyEncoding_containedThreads (pctxt, &pvalue->containedThreads); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingMethod */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingMethod (OOCTXT* pctxt, H245RedundancyEncodingMethod* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* rtpAudioRedundancyEncoding */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* rtpH263VideoRedundancyEncoding */ case 3: stat = asn1PE_H245RTPH263VideoRedundancyEncoding (&lctxt, pvalue->u.rtpH263VideoRedundancyEncoding); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* CapabilityTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CapabilityTableEntryNumber (OOCTXT* pctxt, H245CapabilityTableEntryNumber value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 1U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingCapability_secondaryEncoding */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingCapability_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingCapability_secondaryEncoding* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245CapabilityTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingCapability (OOCTXT* pctxt, H245RedundancyEncodingCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.secondaryEncodingPresent); /* encode redundancyEncodingMethod */ stat = asn1PE_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; /* encode primaryEncoding */ stat = asn1PE_H245CapabilityTableEntryNumber (pctxt, pvalue->primaryEncoding); if (stat != ASN_OK) return stat; /* encode secondaryEncoding */ if (pvalue->m.secondaryEncodingPresent) { stat = asn1PE_H245RedundancyEncodingCapability_secondaryEncoding (pctxt, &pvalue->secondaryEncoding); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H2250Capability_redundancyEncodingCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250Capability_redundancyEncodingCapability (OOCTXT* pctxt, H245H2250Capability_redundancyEncodingCapability* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245RedundancyEncodingCapability (pctxt, ((H245RedundancyEncodingCapability*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* H2250Capability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250Capability (OOCTXT* pctxt, H245H2250Capability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.transportCapabilityPresent || pvalue->m.redundancyEncodingCapabilityPresent || pvalue->m.logicalChannelSwitchingCapabilityPresent || pvalue->m.t120DynamicPortCapabilityPresent); encodeBit (pctxt, extbit); /* encode maximumAudioDelayJitter */ stat = encodeConsUnsigned (pctxt, pvalue->maximumAudioDelayJitter, 0U, 1023U); if (stat != ASN_OK) return stat; /* encode receiveMultipointCapability */ stat = asn1PE_H245MultipointCapability (pctxt, &pvalue->receiveMultipointCapability); if (stat != ASN_OK) return stat; /* encode transmitMultipointCapability */ stat = asn1PE_H245MultipointCapability (pctxt, &pvalue->transmitMultipointCapability); if (stat != ASN_OK) return stat; /* encode receiveAndTransmitMultipointCapability */ stat = asn1PE_H245MultipointCapability (pctxt, &pvalue->receiveAndTransmitMultipointCapability); if (stat != ASN_OK) return stat; /* encode mcCapability */ stat = asn1PE_H245H2250Capability_mcCapability (pctxt, &pvalue->mcCapability); if (stat != ASN_OK) return stat; /* encode rtcpVideoControlCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->rtcpVideoControlCapability); if (stat != ASN_OK) return stat; /* encode mediaPacketizationCapability */ stat = asn1PE_H245MediaPacketizationCapability (pctxt, &pvalue->mediaPacketizationCapability); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 3); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.transportCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.redundancyEncodingCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.logicalChannelSwitchingCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.t120DynamicPortCapabilityPresent); /* encode extension elements */ if (pvalue->m.transportCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245TransportCapability (&lctxt, &pvalue->transportCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.redundancyEncodingCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H2250Capability_redundancyEncodingCapability (&lctxt, &pvalue->redundancyEncodingCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.logicalChannelSwitchingCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->logicalChannelSwitchingCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.t120DynamicPortCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->t120DynamicPortCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* MultiplexCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexCapability (OOCTXT* pctxt, H245MultiplexCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* h222Capability */ case 2: stat = asn1PE_H245H222Capability (pctxt, pvalue->u.h222Capability); if (stat != ASN_OK) return stat; break; /* h223Capability */ case 3: stat = asn1PE_H245H223Capability (pctxt, pvalue->u.h223Capability); if (stat != ASN_OK) return stat; break; /* v76Capability */ case 4: stat = asn1PE_H245V76Capability (pctxt, pvalue->u.v76Capability); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* h2250Capability */ case 5: stat = asn1PE_H245H2250Capability (&lctxt, pvalue->u.h2250Capability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericMultiplexCapability */ case 6: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericMultiplexCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H261VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H261VideoCapability (OOCTXT* pctxt, H245H261VideoCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.videoBadMBsCapPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cifMPIPresent); /* encode qcifMPI */ if (pvalue->m.qcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->qcifMPI, 1U, 4U); if (stat != ASN_OK) return stat; } /* encode cifMPI */ if (pvalue->m.cifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cifMPI, 1U, 4U); if (stat != ASN_OK) return stat; } /* encode temporalSpatialTradeOffCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->temporalSpatialTradeOffCapability); if (stat != ASN_OK) return stat; /* encode maxBitRate */ stat = encodeConsUnsigned (pctxt, pvalue->maxBitRate, 1U, 19200U); if (stat != ASN_OK) return stat; /* encode stillImageTransmission */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->stillImageTransmission); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBadMBsCapPresent); /* encode extension elements */ if (pvalue->m.videoBadMBsCapPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->videoBadMBsCap); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H262VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H262VideoCapability (OOCTXT* pctxt, H245H262VideoCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.videoBadMBsCapPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBitRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.vbvBufferSizePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.samplesPerLinePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.linesPerFramePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.framesPerSecondPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.luminanceSampleRatePresent); /* encode profileAndLevel_SPatML */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_SPatML); if (stat != ASN_OK) return stat; /* encode profileAndLevel_MPatLL */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_MPatLL); if (stat != ASN_OK) return stat; /* encode profileAndLevel_MPatML */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_MPatML); if (stat != ASN_OK) return stat; /* encode profileAndLevel_MPatH_14 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_MPatH_14); if (stat != ASN_OK) return stat; /* encode profileAndLevel_MPatHL */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_MPatHL); if (stat != ASN_OK) return stat; /* encode profileAndLevel_SNRatLL */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_SNRatLL); if (stat != ASN_OK) return stat; /* encode profileAndLevel_SNRatML */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_SNRatML); if (stat != ASN_OK) return stat; /* encode profileAndLevel_SpatialatH_14 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_SpatialatH_14); if (stat != ASN_OK) return stat; /* encode profileAndLevel_HPatML */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_HPatML); if (stat != ASN_OK) return stat; /* encode profileAndLevel_HPatH_14 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_HPatH_14); if (stat != ASN_OK) return stat; /* encode profileAndLevel_HPatHL */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->profileAndLevel_HPatHL); if (stat != ASN_OK) return stat; /* encode videoBitRate */ if (pvalue->m.videoBitRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; } /* encode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { stat = encodeConsUnsigned (pctxt, pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; } /* encode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { stat = encodeConsUnsigned (pctxt, pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { stat = encodeConsUnsigned (pctxt, pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode framesPerSecond */ if (pvalue->m.framesPerSecondPresent) { stat = encodeConsUnsigned (pctxt, pvalue->framesPerSecond, 0U, 15U); if (stat != ASN_OK) return stat; } /* encode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBadMBsCapPresent); /* encode extension elements */ if (pvalue->m.videoBadMBsCapPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->videoBadMBsCap); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* TransparencyParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TransparencyParameters (OOCTXT* pctxt, H245TransparencyParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode presentationOrder */ stat = encodeConsUnsigned (pctxt, pvalue->presentationOrder, 1U, 256U); if (stat != ASN_OK) return stat; /* encode offset_x */ stat = encodeConsInteger (pctxt, pvalue->offset_x, -262144, 262143); if (stat != ASN_OK) return stat; /* encode offset_y */ stat = encodeConsInteger (pctxt, pvalue->offset_y, -262144, 262143); if (stat != ASN_OK) return stat; /* encode scale_x */ stat = encodeConsUnsigned (pctxt, pvalue->scale_x, 1U, 255U); if (stat != ASN_OK) return stat; /* encode scale_y */ stat = encodeConsUnsigned (pctxt, pvalue->scale_y, 1U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_additionalPictureMemory */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RefPictureSelection_additionalPictureMemory (OOCTXT* pctxt, H245RefPictureSelection_additionalPictureMemory* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sqcifAdditionalPictureMemoryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qcifAdditionalPictureMemoryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cifAdditionalPictureMemoryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif4AdditionalPictureMemoryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif16AdditionalPictureMemoryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bigCpfAdditionalPictureMemoryPresent); /* encode sqcifAdditionalPictureMemory */ if (pvalue->m.sqcifAdditionalPictureMemoryPresent) { stat = encodeConsUnsigned (pctxt, pvalue->sqcifAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; } /* encode qcifAdditionalPictureMemory */ if (pvalue->m.qcifAdditionalPictureMemoryPresent) { stat = encodeConsUnsigned (pctxt, pvalue->qcifAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; } /* encode cifAdditionalPictureMemory */ if (pvalue->m.cifAdditionalPictureMemoryPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cifAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; } /* encode cif4AdditionalPictureMemory */ if (pvalue->m.cif4AdditionalPictureMemoryPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif4AdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; } /* encode cif16AdditionalPictureMemory */ if (pvalue->m.cif16AdditionalPictureMemoryPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif16AdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; } /* encode bigCpfAdditionalPictureMemory */ if (pvalue->m.bigCpfAdditionalPictureMemoryPresent) { stat = encodeConsUnsigned (pctxt, pvalue->bigCpfAdditionalPictureMemory, 1U, 256U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_videoBackChannelSend */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RefPictureSelection_videoBackChannelSend (OOCTXT* pctxt, H245RefPictureSelection_videoBackChannelSend* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* none */ case 1: /* NULL */ break; /* ackMessageOnly */ case 2: /* NULL */ break; /* nackMessageOnly */ case 3: /* NULL */ break; /* ackOrNackMessageOnly */ case 4: /* NULL */ break; /* ackAndNackMessage */ case 5: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_enhancedReferencePicSelect_subPictur */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode mpuHorizMBs */ stat = encodeConsUnsigned (pctxt, pvalue->mpuHorizMBs, 1U, 128U); if (stat != ASN_OK) return stat; /* encode mpuVertMBs */ stat = encodeConsUnsigned (pctxt, pvalue->mpuVertMBs, 1U, 72U); if (stat != ASN_OK) return stat; /* encode mpuTotalNumber */ stat = encodeConsUnsigned (pctxt, pvalue->mpuTotalNumber, 1U, 65536U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RefPictureSelection_enhancedReferencePicSelect */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RefPictureSelection_enhancedReferencePicSelect (OOCTXT* pctxt, H245RefPictureSelection_enhancedReferencePicSelect* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.subPictureRemovalParametersPresent); /* encode subPictureRemovalParameters */ if (pvalue->m.subPictureRemovalParametersPresent) { stat = asn1PE_H245RefPictureSelection_enhancedReferencePicSelect_subPictureRemovalParameters (pctxt, &pvalue->subPictureRemovalParameters); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RefPictureSelection */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RefPictureSelection (OOCTXT* pctxt, H245RefPictureSelection* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.enhancedReferencePicSelectPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.additionalPictureMemoryPresent); /* encode additionalPictureMemory */ if (pvalue->m.additionalPictureMemoryPresent) { stat = asn1PE_H245RefPictureSelection_additionalPictureMemory (pctxt, &pvalue->additionalPictureMemory); if (stat != ASN_OK) return stat; } /* encode videoMux */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoMux); if (stat != ASN_OK) return stat; /* encode videoBackChannelSend */ stat = asn1PE_H245RefPictureSelection_videoBackChannelSend (pctxt, &pvalue->videoBackChannelSend); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.enhancedReferencePicSelectPresent); /* encode extension elements */ if (pvalue->m.enhancedReferencePicSelectPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245RefPictureSelection_enhancedReferencePicSelect (&lctxt, &pvalue->enhancedReferencePicSelect); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* CustomPictureClockFrequency */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureClockFrequency (OOCTXT* pctxt, H245CustomPictureClockFrequency* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sqcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif4MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif16MPIPresent); /* encode clockConversionCode */ stat = encodeConsUnsigned (pctxt, pvalue->clockConversionCode, 1000U, 1001U); if (stat != ASN_OK) return stat; /* encode clockDivisor */ stat = encodeConsUnsigned (pctxt, pvalue->clockDivisor, 1U, 127U); if (stat != ASN_OK) return stat; /* encode sqcifMPI */ if (pvalue->m.sqcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->sqcifMPI, 1U, 2048U); if (stat != ASN_OK) return stat; } /* encode qcifMPI */ if (pvalue->m.qcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->qcifMPI, 1U, 2048U); if (stat != ASN_OK) return stat; } /* encode cifMPI */ if (pvalue->m.cifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cifMPI, 1U, 2048U); if (stat != ASN_OK) return stat; } /* encode cif4MPI */ if (pvalue->m.cif4MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif4MPI, 1U, 2048U); if (stat != ASN_OK) return stat; } /* encode cif16MPI */ if (pvalue->m.cif16MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif16MPI, 1U, 2048U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H263Options_customPictureClockFrequency */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263Options_customPictureClockFrequency (OOCTXT* pctxt, H245H263Options_customPictureClockFrequency* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CustomPictureClockFrequency (pctxt, ((H245CustomPictureClockFrequency*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_mPI_customPCF_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat_mPI_customPCF_element (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF_element* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode clockConversionCode */ stat = encodeConsUnsigned (pctxt, pvalue->clockConversionCode, 1000U, 1001U); if (stat != ASN_OK) return stat; /* encode clockDivisor */ stat = encodeConsUnsigned (pctxt, pvalue->clockDivisor, 1U, 127U); if (stat != ASN_OK) return stat; /* encode customMPI */ stat = encodeConsUnsigned (pctxt, pvalue->customMPI, 1U, 2048U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_mPI_customPCF */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat_mPI_customPCF (OOCTXT* pctxt, H245CustomPictureFormat_mPI_customPCF* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CustomPictureFormat_mPI_customPCF_element (pctxt, ((H245CustomPictureFormat_mPI_customPCF_element*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_mPI */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat_mPI (OOCTXT* pctxt, H245CustomPictureFormat_mPI* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.standardMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.customPCFPresent); /* encode standardMPI */ if (pvalue->m.standardMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->standardMPI, 1U, 31U); if (stat != ASN_OK) return stat; } /* encode customPCF */ if (pvalue->m.customPCFPresent) { stat = asn1PE_H245CustomPictureFormat_mPI_customPCF (pctxt, &pvalue->customPCF); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_pixelAspectCo */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = encodeConsUnsigned (pctxt, pvalue->elem[xx1], 1U, 14U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_extendedPAR_e */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode width */ stat = encodeConsUnsigned (pctxt, pvalue->width, 1U, 255U); if (stat != ASN_OK) return stat; /* encode height */ stat = encodeConsUnsigned (pctxt, pvalue->height, 1U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation_extendedPAR */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation_extendedPAR (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation_extendedPAR* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element (pctxt, ((H245CustomPictureFormat_pixelAspectInformation_extendedPAR_element*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat_pixelAspectInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat_pixelAspectInformation (OOCTXT* pctxt, H245CustomPictureFormat_pixelAspectInformation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* anyPixelAspectRatio */ case 1: stat = encodeBit (pctxt, (ASN1BOOL)pvalue->u.anyPixelAspectRatio); if (stat != ASN_OK) return stat; break; /* pixelAspectCode */ case 2: stat = asn1PE_H245CustomPictureFormat_pixelAspectInformation_pixelAspectCode (pctxt, pvalue->u.pixelAspectCode); if (stat != ASN_OK) return stat; break; /* extendedPAR */ case 3: stat = asn1PE_H245CustomPictureFormat_pixelAspectInformation_extendedPAR (pctxt, pvalue->u.extendedPAR); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* CustomPictureFormat */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CustomPictureFormat (OOCTXT* pctxt, H245CustomPictureFormat* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode maxCustomPictureWidth */ stat = encodeConsUnsigned (pctxt, pvalue->maxCustomPictureWidth, 1U, 2048U); if (stat != ASN_OK) return stat; /* encode maxCustomPictureHeight */ stat = encodeConsUnsigned (pctxt, pvalue->maxCustomPictureHeight, 1U, 2048U); if (stat != ASN_OK) return stat; /* encode minCustomPictureWidth */ stat = encodeConsUnsigned (pctxt, pvalue->minCustomPictureWidth, 1U, 2048U); if (stat != ASN_OK) return stat; /* encode minCustomPictureHeight */ stat = encodeConsUnsigned (pctxt, pvalue->minCustomPictureHeight, 1U, 2048U); if (stat != ASN_OK) return stat; /* encode mPI */ stat = asn1PE_H245CustomPictureFormat_mPI (pctxt, &pvalue->mPI); if (stat != ASN_OK) return stat; /* encode pixelAspectInformation */ stat = asn1PE_H245CustomPictureFormat_pixelAspectInformation (pctxt, &pvalue->pixelAspectInformation); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H263Options_customPictureFormat */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263Options_customPictureFormat (OOCTXT* pctxt, H245H263Options_customPictureFormat* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CustomPictureFormat (pctxt, ((H245CustomPictureFormat*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* H263Version3Options */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263Version3Options (OOCTXT* pctxt, H245H263Version3Options* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode dataPartitionedSlices */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dataPartitionedSlices); if (stat != ASN_OK) return stat; /* encode fixedPointIDCT0 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fixedPointIDCT0); if (stat != ASN_OK) return stat; /* encode interlacedFields */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->interlacedFields); if (stat != ASN_OK) return stat; /* encode currentPictureHeaderRepetition */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->currentPictureHeaderRepetition); if (stat != ASN_OK) return stat; /* encode previousPictureHeaderRepetition */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->previousPictureHeaderRepetition); if (stat != ASN_OK) return stat; /* encode nextPictureHeaderRepetition */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->nextPictureHeaderRepetition); if (stat != ASN_OK) return stat; /* encode pictureNumber */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->pictureNumber); if (stat != ASN_OK) return stat; /* encode spareReferencePictures */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->spareReferencePictures); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H263ModeComboFlags */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263ModeComboFlags (OOCTXT* pctxt, H245H263ModeComboFlags* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.enhancedReferencePicSelectPresent || pvalue->m.h263Version3OptionsPresent); encodeBit (pctxt, extbit); /* encode unrestrictedVector */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; /* encode arithmeticCoding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; /* encode advancedPrediction */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->advancedPrediction); if (stat != ASN_OK) return stat; /* encode pbFrames */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->pbFrames); if (stat != ASN_OK) return stat; /* encode advancedIntraCodingMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->advancedIntraCodingMode); if (stat != ASN_OK) return stat; /* encode deblockingFilterMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->deblockingFilterMode); if (stat != ASN_OK) return stat; /* encode unlimitedMotionVectors */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->unlimitedMotionVectors); if (stat != ASN_OK) return stat; /* encode slicesInOrder_NonRect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesInOrder_NonRect); if (stat != ASN_OK) return stat; /* encode slicesInOrder_Rect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesInOrder_Rect); if (stat != ASN_OK) return stat; /* encode slicesNoOrder_NonRect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesNoOrder_NonRect); if (stat != ASN_OK) return stat; /* encode slicesNoOrder_Rect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesNoOrder_Rect); if (stat != ASN_OK) return stat; /* encode improvedPBFramesMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->improvedPBFramesMode); if (stat != ASN_OK) return stat; /* encode referencePicSelect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->referencePicSelect); if (stat != ASN_OK) return stat; /* encode dynamicPictureResizingByFour */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicPictureResizingByFour); if (stat != ASN_OK) return stat; /* encode dynamicPictureResizingSixteenthPel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicPictureResizingSixteenthPel); if (stat != ASN_OK) return stat; /* encode dynamicWarpingHalfPel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicWarpingHalfPel); if (stat != ASN_OK) return stat; /* encode dynamicWarpingSixteenthPel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicWarpingSixteenthPel); if (stat != ASN_OK) return stat; /* encode reducedResolutionUpdate */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->reducedResolutionUpdate); if (stat != ASN_OK) return stat; /* encode independentSegmentDecoding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->independentSegmentDecoding); if (stat != ASN_OK) return stat; /* encode alternateInterVLCMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alternateInterVLCMode); if (stat != ASN_OK) return stat; /* encode modifiedQuantizationMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->modifiedQuantizationMode); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.enhancedReferencePicSelectPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h263Version3OptionsPresent); /* encode extension elements */ if (pvalue->m.enhancedReferencePicSelectPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->enhancedReferencePicSelect); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h263Version3OptionsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H263Version3Options (&lctxt, &pvalue->h263Version3Options); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H263VideoModeCombos_h263VideoCoupledModes */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263VideoModeCombos_h263VideoCoupledModes (OOCTXT* pctxt, H245H263VideoModeCombos_h263VideoCoupledModes* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245H263ModeComboFlags (pctxt, ((H245H263ModeComboFlags*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* H263VideoModeCombos */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263VideoModeCombos (OOCTXT* pctxt, H245H263VideoModeCombos* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode h263VideoUncoupledModes */ stat = asn1PE_H245H263ModeComboFlags (pctxt, &pvalue->h263VideoUncoupledModes); if (stat != ASN_OK) return stat; /* encode h263VideoCoupledModes */ stat = asn1PE_H245H263VideoModeCombos_h263VideoCoupledModes (pctxt, &pvalue->h263VideoCoupledModes); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H263Options_modeCombos */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263Options_modeCombos (OOCTXT* pctxt, H245H263Options_modeCombos* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245H263VideoModeCombos (pctxt, ((H245H263VideoModeCombos*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* H263Options */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263Options (OOCTXT* pctxt, H245H263Options* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.videoBadMBsCapPresent || pvalue->m.h263Version3OptionsPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.transparencyParametersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.refPictureSelectionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.customPictureClockFrequencyPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.customPictureFormatPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.modeCombosPresent); /* encode advancedIntraCodingMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->advancedIntraCodingMode); if (stat != ASN_OK) return stat; /* encode deblockingFilterMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->deblockingFilterMode); if (stat != ASN_OK) return stat; /* encode improvedPBFramesMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->improvedPBFramesMode); if (stat != ASN_OK) return stat; /* encode unlimitedMotionVectors */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->unlimitedMotionVectors); if (stat != ASN_OK) return stat; /* encode fullPictureFreeze */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fullPictureFreeze); if (stat != ASN_OK) return stat; /* encode partialPictureFreezeAndRelease */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->partialPictureFreezeAndRelease); if (stat != ASN_OK) return stat; /* encode resizingPartPicFreezeAndRelease */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->resizingPartPicFreezeAndRelease); if (stat != ASN_OK) return stat; /* encode fullPictureSnapshot */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fullPictureSnapshot); if (stat != ASN_OK) return stat; /* encode partialPictureSnapshot */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->partialPictureSnapshot); if (stat != ASN_OK) return stat; /* encode videoSegmentTagging */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->videoSegmentTagging); if (stat != ASN_OK) return stat; /* encode progressiveRefinement */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->progressiveRefinement); if (stat != ASN_OK) return stat; /* encode dynamicPictureResizingByFour */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicPictureResizingByFour); if (stat != ASN_OK) return stat; /* encode dynamicPictureResizingSixteenthPel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicPictureResizingSixteenthPel); if (stat != ASN_OK) return stat; /* encode dynamicWarpingHalfPel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicWarpingHalfPel); if (stat != ASN_OK) return stat; /* encode dynamicWarpingSixteenthPel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->dynamicWarpingSixteenthPel); if (stat != ASN_OK) return stat; /* encode independentSegmentDecoding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->independentSegmentDecoding); if (stat != ASN_OK) return stat; /* encode slicesInOrder_NonRect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesInOrder_NonRect); if (stat != ASN_OK) return stat; /* encode slicesInOrder_Rect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesInOrder_Rect); if (stat != ASN_OK) return stat; /* encode slicesNoOrder_NonRect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesNoOrder_NonRect); if (stat != ASN_OK) return stat; /* encode slicesNoOrder_Rect */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->slicesNoOrder_Rect); if (stat != ASN_OK) return stat; /* encode alternateInterVLCMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alternateInterVLCMode); if (stat != ASN_OK) return stat; /* encode modifiedQuantizationMode */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->modifiedQuantizationMode); if (stat != ASN_OK) return stat; /* encode reducedResolutionUpdate */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->reducedResolutionUpdate); if (stat != ASN_OK) return stat; /* encode transparencyParameters */ if (pvalue->m.transparencyParametersPresent) { stat = asn1PE_H245TransparencyParameters (pctxt, &pvalue->transparencyParameters); if (stat != ASN_OK) return stat; } /* encode separateVideoBackChannel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->separateVideoBackChannel); if (stat != ASN_OK) return stat; /* encode refPictureSelection */ if (pvalue->m.refPictureSelectionPresent) { stat = asn1PE_H245RefPictureSelection (pctxt, &pvalue->refPictureSelection); if (stat != ASN_OK) return stat; } /* encode customPictureClockFrequency */ if (pvalue->m.customPictureClockFrequencyPresent) { stat = asn1PE_H245H263Options_customPictureClockFrequency (pctxt, &pvalue->customPictureClockFrequency); if (stat != ASN_OK) return stat; } /* encode customPictureFormat */ if (pvalue->m.customPictureFormatPresent) { stat = asn1PE_H245H263Options_customPictureFormat (pctxt, &pvalue->customPictureFormat); if (stat != ASN_OK) return stat; } /* encode modeCombos */ if (pvalue->m.modeCombosPresent) { stat = asn1PE_H245H263Options_modeCombos (pctxt, &pvalue->modeCombos); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBadMBsCapPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h263Version3OptionsPresent); /* encode extension elements */ if (pvalue->m.videoBadMBsCapPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->videoBadMBsCap); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h263Version3OptionsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H263Version3Options (&lctxt, &pvalue->h263Version3Options); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* EnhancementOptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EnhancementOptions (OOCTXT* pctxt, H245EnhancementOptions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sqcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif4MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif16MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowSqcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowQcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowCifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowCif4MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowCif16MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h263OptionsPresent); /* encode sqcifMPI */ if (pvalue->m.sqcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->sqcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode qcifMPI */ if (pvalue->m.qcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->qcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode cifMPI */ if (pvalue->m.cifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cifMPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode cif4MPI */ if (pvalue->m.cif4MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif4MPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode cif16MPI */ if (pvalue->m.cif16MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif16MPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode maxBitRate */ stat = encodeConsUnsigned (pctxt, pvalue->maxBitRate, 1U, 192400U); if (stat != ASN_OK) return stat; /* encode unrestrictedVector */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; /* encode arithmeticCoding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; /* encode temporalSpatialTradeOffCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->temporalSpatialTradeOffCapability); if (stat != ASN_OK) return stat; /* encode slowSqcifMPI */ if (pvalue->m.slowSqcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->slowSqcifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; } /* encode slowQcifMPI */ if (pvalue->m.slowQcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->slowQcifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; } /* encode slowCifMPI */ if (pvalue->m.slowCifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->slowCifMPI, 1U, 3600U); if (stat != ASN_OK) return stat; } /* encode slowCif4MPI */ if (pvalue->m.slowCif4MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->slowCif4MPI, 1U, 3600U); if (stat != ASN_OK) return stat; } /* encode slowCif16MPI */ if (pvalue->m.slowCif16MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->slowCif16MPI, 1U, 3600U); if (stat != ASN_OK) return stat; } /* encode errorCompensation */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->errorCompensation); if (stat != ASN_OK) return stat; /* encode h263Options */ if (pvalue->m.h263OptionsPresent) { stat = asn1PE_H245H263Options (pctxt, &pvalue->h263Options); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo_snrEnhancement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EnhancementLayerInfo_snrEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_snrEnhancement* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245EnhancementOptions (pctxt, ((H245EnhancementOptions*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo_spatialEnhancement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EnhancementLayerInfo_spatialEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_spatialEnhancement* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245EnhancementOptions (pctxt, ((H245EnhancementOptions*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* BEnhancementParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245BEnhancementParameters (OOCTXT* pctxt, H245BEnhancementParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode enhancementOptions */ stat = asn1PE_H245EnhancementOptions (pctxt, &pvalue->enhancementOptions); if (stat != ASN_OK) return stat; /* encode numberOfBPictures */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfBPictures, 1U, 64U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo_bPictureEnhancement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EnhancementLayerInfo_bPictureEnhancement (OOCTXT* pctxt, H245EnhancementLayerInfo_bPictureEnhancement* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 14, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245BEnhancementParameters (pctxt, ((H245BEnhancementParameters*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* EnhancementLayerInfo */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EnhancementLayerInfo (OOCTXT* pctxt, H245EnhancementLayerInfo* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.snrEnhancementPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.spatialEnhancementPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bPictureEnhancementPresent); /* encode baseBitRateConstrained */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->baseBitRateConstrained); if (stat != ASN_OK) return stat; /* encode snrEnhancement */ if (pvalue->m.snrEnhancementPresent) { stat = asn1PE_H245EnhancementLayerInfo_snrEnhancement (pctxt, &pvalue->snrEnhancement); if (stat != ASN_OK) return stat; } /* encode spatialEnhancement */ if (pvalue->m.spatialEnhancementPresent) { stat = asn1PE_H245EnhancementLayerInfo_spatialEnhancement (pctxt, &pvalue->spatialEnhancement); if (stat != ASN_OK) return stat; } /* encode bPictureEnhancement */ if (pvalue->m.bPictureEnhancementPresent) { stat = asn1PE_H245EnhancementLayerInfo_bPictureEnhancement (pctxt, &pvalue->bPictureEnhancement); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H263VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263VideoCapability (OOCTXT* pctxt, H245H263VideoCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.slowSqcifMPIPresent || pvalue->m.slowQcifMPIPresent || pvalue->m.slowCifMPIPresent || pvalue->m.slowCif4MPIPresent || pvalue->m.slowCif16MPIPresent || pvalue->m.errorCompensationPresent || pvalue->m.enhancementLayerInfoPresent || pvalue->m.h263OptionsPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sqcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.qcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif4MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.cif16MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.hrd_BPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.bppMaxKbPresent); /* encode sqcifMPI */ if (pvalue->m.sqcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->sqcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode qcifMPI */ if (pvalue->m.qcifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->qcifMPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode cifMPI */ if (pvalue->m.cifMPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cifMPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode cif4MPI */ if (pvalue->m.cif4MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif4MPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode cif16MPI */ if (pvalue->m.cif16MPIPresent) { stat = encodeConsUnsigned (pctxt, pvalue->cif16MPI, 1U, 32U); if (stat != ASN_OK) return stat; } /* encode maxBitRate */ stat = encodeConsUnsigned (pctxt, pvalue->maxBitRate, 1U, 192400U); if (stat != ASN_OK) return stat; /* encode unrestrictedVector */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; /* encode arithmeticCoding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; /* encode advancedPrediction */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->advancedPrediction); if (stat != ASN_OK) return stat; /* encode pbFrames */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->pbFrames); if (stat != ASN_OK) return stat; /* encode temporalSpatialTradeOffCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->temporalSpatialTradeOffCapability); if (stat != ASN_OK) return stat; /* encode hrd_B */ if (pvalue->m.hrd_BPresent) { stat = encodeConsUnsigned (pctxt, pvalue->hrd_B, 0U, 524287U); if (stat != ASN_OK) return stat; } /* encode bppMaxKb */ if (pvalue->m.bppMaxKbPresent) { stat = encodeConsUnsigned (pctxt, pvalue->bppMaxKb, 0U, 65535U); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 7); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowSqcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowQcifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowCifMPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowCif4MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.slowCif16MPIPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.errorCompensationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.enhancementLayerInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h263OptionsPresent); /* encode extension elements */ if (pvalue->m.slowSqcifMPIPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->slowSqcifMPI, 1U, 3600U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.slowQcifMPIPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->slowQcifMPI, 1U, 3600U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.slowCifMPIPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->slowCifMPI, 1U, 3600U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.slowCif4MPIPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->slowCif4MPI, 1U, 3600U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.slowCif16MPIPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->slowCif16MPI, 1U, 3600U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.errorCompensationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->errorCompensation); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.enhancementLayerInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245EnhancementLayerInfo (&lctxt, &pvalue->enhancementLayerInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h263OptionsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H263Options (&lctxt, &pvalue->h263Options); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* IS11172VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS11172VideoCapability (OOCTXT* pctxt, H245IS11172VideoCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.videoBadMBsCapPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBitRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.vbvBufferSizePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.samplesPerLinePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.linesPerFramePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.pictureRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.luminanceSampleRatePresent); /* encode constrainedBitstream */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->constrainedBitstream); if (stat != ASN_OK) return stat; /* encode videoBitRate */ if (pvalue->m.videoBitRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; } /* encode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { stat = encodeConsUnsigned (pctxt, pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; } /* encode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { stat = encodeConsUnsigned (pctxt, pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { stat = encodeConsUnsigned (pctxt, pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode pictureRate */ if (pvalue->m.pictureRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->pictureRate, 0U, 15U); if (stat != ASN_OK) return stat; } /* encode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBadMBsCapPresent); /* encode extension elements */ if (pvalue->m.videoBadMBsCapPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->videoBadMBsCap); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* VideoCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VideoCapability (OOCTXT* pctxt, H245VideoCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* h261VideoCapability */ case 2: stat = asn1PE_H245H261VideoCapability (pctxt, pvalue->u.h261VideoCapability); if (stat != ASN_OK) return stat; break; /* h262VideoCapability */ case 3: stat = asn1PE_H245H262VideoCapability (pctxt, pvalue->u.h262VideoCapability); if (stat != ASN_OK) return stat; break; /* h263VideoCapability */ case 4: stat = asn1PE_H245H263VideoCapability (pctxt, pvalue->u.h263VideoCapability); if (stat != ASN_OK) return stat; break; /* is11172VideoCapability */ case 5: stat = asn1PE_H245IS11172VideoCapability (pctxt, pvalue->u.is11172VideoCapability); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* genericVideoCapability */ case 6: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericVideoCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* AudioCapability_g7231 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AudioCapability_g7231 (OOCTXT* pctxt, H245AudioCapability_g7231* pvalue) { int stat = ASN_OK; /* encode maxAl_sduAudioFrames */ stat = encodeConsUnsigned (pctxt, pvalue->maxAl_sduAudioFrames, 1U, 256U); if (stat != ASN_OK) return stat; /* encode silenceSuppression */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->silenceSuppression); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* IS11172AudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS11172AudioCapability (OOCTXT* pctxt, H245IS11172AudioCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioLayer1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioLayer1); if (stat != ASN_OK) return stat; /* encode audioLayer2 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioLayer2); if (stat != ASN_OK) return stat; /* encode audioLayer3 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioLayer3); if (stat != ASN_OK) return stat; /* encode audioSampling32k */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling32k); if (stat != ASN_OK) return stat; /* encode audioSampling44k1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling44k1); if (stat != ASN_OK) return stat; /* encode audioSampling48k */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling48k); if (stat != ASN_OK) return stat; /* encode singleChannel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->singleChannel); if (stat != ASN_OK) return stat; /* encode twoChannels */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->twoChannels); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 448U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* IS13818AudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS13818AudioCapability (OOCTXT* pctxt, H245IS13818AudioCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioLayer1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioLayer1); if (stat != ASN_OK) return stat; /* encode audioLayer2 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioLayer2); if (stat != ASN_OK) return stat; /* encode audioLayer3 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioLayer3); if (stat != ASN_OK) return stat; /* encode audioSampling16k */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling16k); if (stat != ASN_OK) return stat; /* encode audioSampling22k05 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling22k05); if (stat != ASN_OK) return stat; /* encode audioSampling24k */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling24k); if (stat != ASN_OK) return stat; /* encode audioSampling32k */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling32k); if (stat != ASN_OK) return stat; /* encode audioSampling44k1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling44k1); if (stat != ASN_OK) return stat; /* encode audioSampling48k */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioSampling48k); if (stat != ASN_OK) return stat; /* encode singleChannel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->singleChannel); if (stat != ASN_OK) return stat; /* encode twoChannels */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->twoChannels); if (stat != ASN_OK) return stat; /* encode threeChannels2_1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->threeChannels2_1); if (stat != ASN_OK) return stat; /* encode threeChannels3_0 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->threeChannels3_0); if (stat != ASN_OK) return stat; /* encode fourChannels2_0_2_0 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fourChannels2_0_2_0); if (stat != ASN_OK) return stat; /* encode fourChannels2_2 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fourChannels2_2); if (stat != ASN_OK) return stat; /* encode fourChannels3_1 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fourChannels3_1); if (stat != ASN_OK) return stat; /* encode fiveChannels3_0_2_0 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fiveChannels3_0_2_0); if (stat != ASN_OK) return stat; /* encode fiveChannels3_2 */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->fiveChannels3_2); if (stat != ASN_OK) return stat; /* encode lowFrequencyEnhancement */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->lowFrequencyEnhancement); if (stat != ASN_OK) return stat; /* encode multilingual */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->multilingual); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 1130U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* G7231AnnexCCapability_g723AnnexCAudioMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245G7231AnnexCCapability_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCCapability_g723AnnexCAudioMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode highRateMode0 */ stat = encodeConsUnsigned (pctxt, pvalue->highRateMode0, 27U, 78U); if (stat != ASN_OK) return stat; /* encode highRateMode1 */ stat = encodeConsUnsigned (pctxt, pvalue->highRateMode1, 27U, 78U); if (stat != ASN_OK) return stat; /* encode lowRateMode0 */ stat = encodeConsUnsigned (pctxt, pvalue->lowRateMode0, 23U, 66U); if (stat != ASN_OK) return stat; /* encode lowRateMode1 */ stat = encodeConsUnsigned (pctxt, pvalue->lowRateMode1, 23U, 66U); if (stat != ASN_OK) return stat; /* encode sidMode0 */ stat = encodeConsUnsigned (pctxt, pvalue->sidMode0, 6U, 17U); if (stat != ASN_OK) return stat; /* encode sidMode1 */ stat = encodeConsUnsigned (pctxt, pvalue->sidMode1, 6U, 17U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* G7231AnnexCCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245G7231AnnexCCapability (OOCTXT* pctxt, H245G7231AnnexCCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.g723AnnexCAudioModePresent); /* encode maxAl_sduAudioFrames */ stat = encodeConsUnsigned (pctxt, pvalue->maxAl_sduAudioFrames, 1U, 256U); if (stat != ASN_OK) return stat; /* encode silenceSuppression */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->silenceSuppression); if (stat != ASN_OK) return stat; /* encode g723AnnexCAudioMode */ if (pvalue->m.g723AnnexCAudioModePresent) { stat = asn1PE_H245G7231AnnexCCapability_g723AnnexCAudioMode (pctxt, &pvalue->g723AnnexCAudioMode); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* GSMAudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245GSMAudioCapability (OOCTXT* pctxt, H245GSMAudioCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioUnitSize */ stat = encodeConsUnsigned (pctxt, pvalue->audioUnitSize, 1U, 256U); if (stat != ASN_OK) return stat; /* encode comfortNoise */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->comfortNoise); if (stat != ASN_OK) return stat; /* encode scrambled */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->scrambled); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* G729Extensions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245G729Extensions (OOCTXT* pctxt, H245G729Extensions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.audioUnitPresent); /* encode audioUnit */ if (pvalue->m.audioUnitPresent) { stat = encodeConsUnsigned (pctxt, pvalue->audioUnit, 1U, 256U); if (stat != ASN_OK) return stat; } /* encode annexA */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->annexA); if (stat != ASN_OK) return stat; /* encode annexB */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->annexB); if (stat != ASN_OK) return stat; /* encode annexD */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->annexD); if (stat != ASN_OK) return stat; /* encode annexE */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->annexE); if (stat != ASN_OK) return stat; /* encode annexF */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->annexF); if (stat != ASN_OK) return stat; /* encode annexG */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->annexG); if (stat != ASN_OK) return stat; /* encode annexH */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->annexH); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VBDCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VBDCapability (OOCTXT* pctxt, H245VBDCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245AudioCapability (pctxt, (H245AudioCapability*)pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NoPTAudioTelephonyEventCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NoPTAudioTelephonyEventCapability (OOCTXT* pctxt, H245NoPTAudioTelephonyEventCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioTelephoneEvent */ stat = encodeVarWidthCharString (pctxt, pvalue->audioTelephoneEvent); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NoPTAudioToneCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NoPTAudioToneCapability (OOCTXT* pctxt, H245NoPTAudioToneCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* AudioCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AudioCapability (OOCTXT* pctxt, H245AudioCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 14); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 13); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* g711Alaw64k */ case 2: stat = encodeConsUnsigned (pctxt, pvalue->u.g711Alaw64k, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g711Alaw56k */ case 3: stat = encodeConsUnsigned (pctxt, pvalue->u.g711Alaw56k, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g711Ulaw64k */ case 4: stat = encodeConsUnsigned (pctxt, pvalue->u.g711Ulaw64k, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g711Ulaw56k */ case 5: stat = encodeConsUnsigned (pctxt, pvalue->u.g711Ulaw56k, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g722_64k */ case 6: stat = encodeConsUnsigned (pctxt, pvalue->u.g722_64k, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g722_56k */ case 7: stat = encodeConsUnsigned (pctxt, pvalue->u.g722_56k, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g722_48k */ case 8: stat = encodeConsUnsigned (pctxt, pvalue->u.g722_48k, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g7231 */ case 9: stat = asn1PE_H245AudioCapability_g7231 (pctxt, pvalue->u.g7231); if (stat != ASN_OK) return stat; break; /* g728 */ case 10: stat = encodeConsUnsigned (pctxt, pvalue->u.g728, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g729 */ case 11: stat = encodeConsUnsigned (pctxt, pvalue->u.g729, 1U, 256U); if (stat != ASN_OK) return stat; break; /* g729AnnexA */ case 12: stat = encodeConsUnsigned (pctxt, pvalue->u.g729AnnexA, 1U, 256U); if (stat != ASN_OK) return stat; break; /* is11172AudioCapability */ case 13: stat = asn1PE_H245IS11172AudioCapability (pctxt, pvalue->u.is11172AudioCapability); if (stat != ASN_OK) return stat; break; /* is13818AudioCapability */ case 14: stat = asn1PE_H245IS13818AudioCapability (pctxt, pvalue->u.is13818AudioCapability); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 15); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* g729wAnnexB */ case 15: stat = encodeConsUnsigned (&lctxt, pvalue->u.g729wAnnexB, 1U, 256U); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* g729AnnexAwAnnexB */ case 16: stat = encodeConsUnsigned (&lctxt, pvalue->u.g729AnnexAwAnnexB, 1U, 256U); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* g7231AnnexCCapability */ case 17: stat = asn1PE_H245G7231AnnexCCapability (&lctxt, pvalue->u.g7231AnnexCCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* gsmFullRate */ case 18: stat = asn1PE_H245GSMAudioCapability (&lctxt, pvalue->u.gsmFullRate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* gsmHalfRate */ case 19: stat = asn1PE_H245GSMAudioCapability (&lctxt, pvalue->u.gsmHalfRate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* gsmEnhancedFullRate */ case 20: stat = asn1PE_H245GSMAudioCapability (&lctxt, pvalue->u.gsmEnhancedFullRate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericAudioCapability */ case 21: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericAudioCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* g729Extensions */ case 22: stat = asn1PE_H245G729Extensions (&lctxt, pvalue->u.g729Extensions); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* vbd */ case 23: stat = asn1PE_H245VBDCapability (&lctxt, pvalue->u.vbd); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* audioTelephonyEvent */ case 24: stat = asn1PE_H245NoPTAudioTelephonyEventCapability (&lctxt, pvalue->u.audioTelephonyEvent); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* audioTone */ case 25: stat = asn1PE_H245NoPTAudioToneCapability (&lctxt, pvalue->u.audioTone); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* Capability_h233EncryptionReceiveCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Capability_h233EncryptionReceiveCapability (OOCTXT* pctxt, H245Capability_h233EncryptionReceiveCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode h233IVResponseTime */ stat = encodeConsUnsigned (pctxt, pvalue->h233IVResponseTime, 0U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH245NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245NonStandardParameter (OOCTXT* pctxt, H245_SeqOfH245NonStandardParameter* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245NonStandardParameter (pctxt, ((H245NonStandardParameter*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* ConferenceCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceCapability (OOCTXT* pctxt, H245ConferenceCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.videoIndicateMixingCapabilityPresent || pvalue->m.multipointVisualizationCapabilityPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardDataPresent); /* encode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { stat = asn1PE_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; } /* encode chairControlCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->chairControlCapability); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoIndicateMixingCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multipointVisualizationCapabilityPresent); /* encode extension elements */ if (pvalue->m.videoIndicateMixingCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->videoIndicateMixingCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multipointVisualizationCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->multipointVisualizationCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* MediaEncryptionAlgorithm */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MediaEncryptionAlgorithm (OOCTXT* pctxt, H245MediaEncryptionAlgorithm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* algorithm */ case 2: stat = encodeObjectIdentifier (pctxt, pvalue->u.algorithm); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* EncryptionCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionCapability (OOCTXT* pctxt, H245EncryptionCapability* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245MediaEncryptionAlgorithm (pctxt, ((H245MediaEncryptionAlgorithm*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* AuthenticationCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AuthenticationCapability (OOCTXT* pctxt, H245AuthenticationCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.antiSpamAlgorithmPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.antiSpamAlgorithmPresent); /* encode extension elements */ if (pvalue->m.antiSpamAlgorithmPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeObjectIdentifier (&lctxt, &pvalue->antiSpamAlgorithm); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* IntegrityCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IntegrityCapability (OOCTXT* pctxt, H245IntegrityCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EncryptionAuthenticationAndIntegrity */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionAuthenticationAndIntegrity (OOCTXT* pctxt, H245EncryptionAuthenticationAndIntegrity* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.encryptionCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.authenticationCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.integrityCapabilityPresent); /* encode encryptionCapability */ if (pvalue->m.encryptionCapabilityPresent) { stat = asn1PE_H245EncryptionCapability (pctxt, &pvalue->encryptionCapability); if (stat != ASN_OK) return stat; } /* encode authenticationCapability */ if (pvalue->m.authenticationCapabilityPresent) { stat = asn1PE_H245AuthenticationCapability (pctxt, &pvalue->authenticationCapability); if (stat != ASN_OK) return stat; } /* encode integrityCapability */ if (pvalue->m.integrityCapabilityPresent) { stat = asn1PE_H245IntegrityCapability (pctxt, &pvalue->integrityCapability); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H235SecurityCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H235SecurityCapability (OOCTXT* pctxt, H245H235SecurityCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode encryptionAuthenticationAndIntegrity */ stat = asn1PE_H245EncryptionAuthenticationAndIntegrity (pctxt, &pvalue->encryptionAuthenticationAndIntegrity); if (stat != ASN_OK) return stat; /* encode mediaCapability */ stat = asn1PE_H245CapabilityTableEntryNumber (pctxt, pvalue->mediaCapability); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UserInputCapability_nonStandard */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputCapability_nonStandard (OOCTXT* pctxt, H245UserInputCapability_nonStandard* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245NonStandardParameter (pctxt, ((H245NonStandardParameter*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* UserInputCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputCapability (OOCTXT* pctxt, H245UserInputCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245UserInputCapability_nonStandard (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* basicString */ case 2: /* NULL */ break; /* iA5String */ case 3: /* NULL */ break; /* generalString */ case 4: /* NULL */ break; /* dtmf */ case 5: /* NULL */ break; /* hookflash */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* extendedAlphanumeric */ case 7: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MultiplexFormat */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexFormat (OOCTXT* pctxt, H245MultiplexFormat* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* h222Capability */ case 2: stat = asn1PE_H245H222Capability (pctxt, pvalue->u.h222Capability); if (stat != ASN_OK) return stat; break; /* h223Capability */ case 3: stat = asn1PE_H245H223Capability (pctxt, pvalue->u.h223Capability); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* AlternativeCapabilitySet */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AlternativeCapabilitySet (OOCTXT* pctxt, H245AlternativeCapabilitySet* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245CapabilityTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamCapability_capabilityOnMuxStream */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexedStreamCapability_capabilityOnMuxStream (OOCTXT* pctxt, H245MultiplexedStreamCapability_capabilityOnMuxStream* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245AlternativeCapabilitySet (pctxt, ((H245AlternativeCapabilitySet*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexedStreamCapability (OOCTXT* pctxt, H245MultiplexedStreamCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capabilityOnMuxStreamPresent); /* encode multiplexFormat */ stat = asn1PE_H245MultiplexFormat (pctxt, &pvalue->multiplexFormat); if (stat != ASN_OK) return stat; /* encode controlOnMuxStream */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->controlOnMuxStream); if (stat != ASN_OK) return stat; /* encode capabilityOnMuxStream */ if (pvalue->m.capabilityOnMuxStreamPresent) { stat = asn1PE_H245MultiplexedStreamCapability_capabilityOnMuxStream (pctxt, &pvalue->capabilityOnMuxStream); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* AudioTelephonyEventCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AudioTelephonyEventCapability (OOCTXT* pctxt, H245AudioTelephonyEventCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode dynamicRTPPayloadType */ stat = encodeConsUnsigned (pctxt, pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; /* encode audioTelephoneEvent */ stat = encodeVarWidthCharString (pctxt, pvalue->audioTelephoneEvent); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* AudioToneCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AudioToneCapability (OOCTXT* pctxt, H245AudioToneCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode dynamicRTPPayloadType */ stat = encodeConsUnsigned (pctxt, pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECCapability_rfc2733_separateStream */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECCapability_rfc2733_separateStream (OOCTXT* pctxt, H245FECCapability_rfc2733_separateStream* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode separatePort */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->separatePort); if (stat != ASN_OK) return stat; /* encode samePort */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->samePort); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECCapability_rfc2733 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECCapability_rfc2733 (OOCTXT* pctxt, H245FECCapability_rfc2733* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode redundancyEncoding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->redundancyEncoding); if (stat != ASN_OK) return stat; /* encode separateStream */ stat = asn1PE_H245FECCapability_rfc2733_separateStream (pctxt, &pvalue->separateStream); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECCapability (OOCTXT* pctxt, H245FECCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* rfc2733 */ case 1: stat = asn1PE_H245FECCapability_rfc2733 (pctxt, pvalue->u.rfc2733); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamCapability_capabilities */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplePayloadStreamCapability_capabilities (OOCTXT* pctxt, H245MultiplePayloadStreamCapability_capabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245AlternativeCapabilitySet (pctxt, ((H245AlternativeCapabilitySet*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamCapability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplePayloadStreamCapability (OOCTXT* pctxt, H245MultiplePayloadStreamCapability* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode capabilities */ stat = asn1PE_H245MultiplePayloadStreamCapability_capabilities (pctxt, &pvalue->capabilities); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Capability */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Capability (OOCTXT* pctxt, H245Capability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 12); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 11); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* receiveVideoCapability */ case 2: stat = asn1PE_H245VideoCapability (pctxt, pvalue->u.receiveVideoCapability); if (stat != ASN_OK) return stat; break; /* transmitVideoCapability */ case 3: stat = asn1PE_H245VideoCapability (pctxt, pvalue->u.transmitVideoCapability); if (stat != ASN_OK) return stat; break; /* receiveAndTransmitVideoCapability */ case 4: stat = asn1PE_H245VideoCapability (pctxt, pvalue->u.receiveAndTransmitVideoCapability); if (stat != ASN_OK) return stat; break; /* receiveAudioCapability */ case 5: stat = asn1PE_H245AudioCapability (pctxt, pvalue->u.receiveAudioCapability); if (stat != ASN_OK) return stat; break; /* transmitAudioCapability */ case 6: stat = asn1PE_H245AudioCapability (pctxt, pvalue->u.transmitAudioCapability); if (stat != ASN_OK) return stat; break; /* receiveAndTransmitAudioCapability */ case 7: stat = asn1PE_H245AudioCapability (pctxt, pvalue->u.receiveAndTransmitAudioCapability); if (stat != ASN_OK) return stat; break; /* receiveDataApplicationCapability */ case 8: stat = asn1PE_H245DataApplicationCapability (pctxt, pvalue->u.receiveDataApplicationCapability); if (stat != ASN_OK) return stat; break; /* transmitDataApplicationCapability */ case 9: stat = asn1PE_H245DataApplicationCapability (pctxt, pvalue->u.transmitDataApplicationCapability); if (stat != ASN_OK) return stat; break; /* receiveAndTransmitDataApplicationCapability */ case 10: stat = asn1PE_H245DataApplicationCapability (pctxt, pvalue->u.receiveAndTransmitDataApplicationCapability); if (stat != ASN_OK) return stat; break; /* h233EncryptionTransmitCapability */ case 11: stat = encodeBit (pctxt, (ASN1BOOL)pvalue->u.h233EncryptionTransmitCapability); if (stat != ASN_OK) return stat; break; /* h233EncryptionReceiveCapability */ case 12: stat = asn1PE_H245Capability_h233EncryptionReceiveCapability (pctxt, pvalue->u.h233EncryptionReceiveCapability); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 13); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* conferenceCapability */ case 13: stat = asn1PE_H245ConferenceCapability (&lctxt, pvalue->u.conferenceCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* h235SecurityCapability */ case 14: stat = asn1PE_H245H235SecurityCapability (&lctxt, pvalue->u.h235SecurityCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* maxPendingReplacementFor */ case 15: stat = encodeConsUnsigned (&lctxt, pvalue->u.maxPendingReplacementFor, 0U, 255U); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* receiveUserInputCapability */ case 16: stat = asn1PE_H245UserInputCapability (&lctxt, pvalue->u.receiveUserInputCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* transmitUserInputCapability */ case 17: stat = asn1PE_H245UserInputCapability (&lctxt, pvalue->u.transmitUserInputCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* receiveAndTransmitUserInputCapability */ case 18: stat = asn1PE_H245UserInputCapability (&lctxt, pvalue->u.receiveAndTransmitUserInputCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericControlCapability */ case 19: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericControlCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* receiveMultiplexedStreamCapability */ case 20: stat = asn1PE_H245MultiplexedStreamCapability (&lctxt, pvalue->u.receiveMultiplexedStreamCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* transmitMultiplexedStreamCapability */ case 21: stat = asn1PE_H245MultiplexedStreamCapability (&lctxt, pvalue->u.transmitMultiplexedStreamCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* receiveAndTransmitMultiplexedStreamCapability */ case 22: stat = asn1PE_H245MultiplexedStreamCapability (&lctxt, pvalue->u.receiveAndTransmitMultiplexedStreamCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* receiveRTPAudioTelephonyEventCapability */ case 23: stat = asn1PE_H245AudioTelephonyEventCapability (&lctxt, pvalue->u.receiveRTPAudioTelephonyEventCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* receiveRTPAudioToneCapability */ case 24: stat = asn1PE_H245AudioToneCapability (&lctxt, pvalue->u.receiveRTPAudioToneCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* fecCapability */ case 25: stat = asn1PE_H245FECCapability (&lctxt, pvalue->u.fecCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multiplePayloadStreamCapability */ case 26: stat = asn1PE_H245MultiplePayloadStreamCapability (&lctxt, pvalue->u.multiplePayloadStreamCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* CapabilityTableEntry */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CapabilityTableEntry (OOCTXT* pctxt, H245CapabilityTableEntry* pvalue) { int stat = ASN_OK; encodeBit (pctxt, (ASN1BOOL)pvalue->m.capabilityPresent); /* encode capabilityTableEntryNumber */ stat = asn1PE_H245CapabilityTableEntryNumber (pctxt, pvalue->capabilityTableEntryNumber); if (stat != ASN_OK) return stat; /* encode capability */ if (pvalue->m.capabilityPresent) { stat = asn1PE_H245Capability (pctxt, &pvalue->capability); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySet_capabilityTable */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySet_capabilityTable (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityTable* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CapabilityTableEntry (pctxt, ((H245CapabilityTableEntry*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* CapabilityDescriptorNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CapabilityDescriptorNumber (OOCTXT* pctxt, H245CapabilityDescriptorNumber value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 0U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CapabilityDescriptor_simultaneousCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CapabilityDescriptor_simultaneousCapabilities (OOCTXT* pctxt, H245CapabilityDescriptor_simultaneousCapabilities* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245AlternativeCapabilitySet (pctxt, ((H245AlternativeCapabilitySet*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* CapabilityDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CapabilityDescriptor (OOCTXT* pctxt, H245CapabilityDescriptor* pvalue) { int stat = ASN_OK; encodeBit (pctxt, (ASN1BOOL)pvalue->m.simultaneousCapabilitiesPresent); /* encode capabilityDescriptorNumber */ stat = asn1PE_H245CapabilityDescriptorNumber (pctxt, pvalue->capabilityDescriptorNumber); if (stat != ASN_OK) return stat; /* encode simultaneousCapabilities */ if (pvalue->m.simultaneousCapabilitiesPresent) { stat = asn1PE_H245CapabilityDescriptor_simultaneousCapabilities (pctxt, &pvalue->simultaneousCapabilities); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySet_capabilityDescriptors */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySet_capabilityDescriptors (OOCTXT* pctxt, H245TerminalCapabilitySet_capabilityDescriptors* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CapabilityDescriptor (pctxt, ((H245CapabilityDescriptor*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySet */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySet (OOCTXT* pctxt, H245TerminalCapabilitySet* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multiplexCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capabilityTablePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capabilityDescriptorsPresent); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode protocolIdentifier */ stat = encodeObjectIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; /* encode multiplexCapability */ if (pvalue->m.multiplexCapabilityPresent) { stat = asn1PE_H245MultiplexCapability (pctxt, &pvalue->multiplexCapability); if (stat != ASN_OK) return stat; } /* encode capabilityTable */ if (pvalue->m.capabilityTablePresent) { stat = asn1PE_H245TerminalCapabilitySet_capabilityTable (pctxt, &pvalue->capabilityTable); if (stat != ASN_OK) return stat; } /* encode capabilityDescriptors */ if (pvalue->m.capabilityDescriptorsPresent) { stat = asn1PE_H245TerminalCapabilitySet_capabilityDescriptors (pctxt, &pvalue->capabilityDescriptors); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* LogicalChannelNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245LogicalChannelNumber (OOCTXT* pctxt, H245LogicalChannelNumber value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 1U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncryptionMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionMode (OOCTXT* pctxt, H245EncryptionMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* h233Encryption */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingElement (OOCTXT* pctxt, H245RedundancyEncodingElement* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.payloadTypePresent); /* encode dataType */ stat = asn1PE_H245DataType (pctxt, (H245DataType*)pvalue->dataType); if (stat != ASN_OK) return stat; /* encode payloadType */ if (pvalue->m.payloadTypePresent) { stat = encodeConsUnsigned (pctxt, pvalue->payloadType, 0U, 127U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245RedundancyEncodingElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245RedundancyEncodingElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingElement* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245RedundancyEncodingElement (pctxt, ((H245RedundancyEncodingElement*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* RedundancyEncoding_rtpRedundancyEncoding */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncoding_rtpRedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding_rtpRedundancyEncoding* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.primaryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.secondaryPresent); /* encode primary */ if (pvalue->m.primaryPresent) { stat = asn1PE_H245RedundancyEncodingElement (pctxt, &pvalue->primary); if (stat != ASN_OK) return stat; } /* encode secondary */ if (pvalue->m.secondaryPresent) { stat = asn1PE_H245_SeqOfH245RedundancyEncodingElement (pctxt, &pvalue->secondary); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RedundancyEncoding */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncoding (OOCTXT* pctxt, H245RedundancyEncoding* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.rtpRedundancyEncodingPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.secondaryEncodingPresent); /* encode redundancyEncodingMethod */ stat = asn1PE_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; /* encode secondaryEncoding */ if (pvalue->m.secondaryEncodingPresent) { stat = asn1PE_H245DataType (pctxt, (H245DataType*)pvalue->secondaryEncoding); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.rtpRedundancyEncodingPresent); /* encode extension elements */ if (pvalue->m.rtpRedundancyEncodingPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245RedundancyEncoding_rtpRedundancyEncoding (&lctxt, &pvalue->rtpRedundancyEncoding); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplePayloadStreamElement (OOCTXT* pctxt, H245MultiplePayloadStreamElement* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.payloadTypePresent); /* encode dataType */ stat = asn1PE_H245DataType (pctxt, (H245DataType*)pvalue->dataType); if (stat != ASN_OK) return stat; /* encode payloadType */ if (pvalue->m.payloadTypePresent) { stat = encodeConsUnsigned (pctxt, pvalue->payloadType, 0U, 127U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245MultiplePayloadStreamElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245MultiplePayloadStreamElement (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElement* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245MultiplePayloadStreamElement (pctxt, ((H245MultiplePayloadStreamElement*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStream */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplePayloadStream (OOCTXT* pctxt, H245MultiplePayloadStream* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode elements */ stat = asn1PE_H245_SeqOfH245MultiplePayloadStreamElement (pctxt, &pvalue->elements); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream_differentPort */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECData_rfc2733_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_differentPort* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.protectedPayloadTypePresent); /* encode protectedSessionID */ stat = encodeConsUnsigned (pctxt, pvalue->protectedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; /* encode protectedPayloadType */ if (pvalue->m.protectedPayloadTypePresent) { stat = encodeConsUnsigned (pctxt, pvalue->protectedPayloadType, 0U, 127U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream_samePort */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECData_rfc2733_mode_separateStream_samePort (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream_samePort* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode protectedPayloadType */ stat = encodeConsUnsigned (pctxt, pvalue->protectedPayloadType, 0U, 127U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode_separateStream */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECData_rfc2733_mode_separateStream (OOCTXT* pctxt, H245FECData_rfc2733_mode_separateStream* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* differentPort */ case 1: stat = asn1PE_H245FECData_rfc2733_mode_separateStream_differentPort (pctxt, pvalue->u.differentPort); if (stat != ASN_OK) return stat; break; /* samePort */ case 2: stat = asn1PE_H245FECData_rfc2733_mode_separateStream_samePort (pctxt, pvalue->u.samePort); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733_mode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECData_rfc2733_mode (OOCTXT* pctxt, H245FECData_rfc2733_mode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* redundancyEncoding */ case 1: /* NULL */ break; /* separateStream */ case 2: stat = asn1PE_H245FECData_rfc2733_mode_separateStream (pctxt, pvalue->u.separateStream); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* FECData_rfc2733 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECData_rfc2733 (OOCTXT* pctxt, H245FECData_rfc2733* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode mode */ stat = asn1PE_H245FECData_rfc2733_mode (pctxt, &pvalue->mode); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECData */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECData (OOCTXT* pctxt, H245FECData* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* rfc2733 */ case 1: stat = asn1PE_H245FECData_rfc2733 (pctxt, pvalue->u.rfc2733); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* H235Media_mediaType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H235Media_mediaType (OOCTXT* pctxt, H245H235Media_mediaType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* videoData */ case 2: stat = asn1PE_H245VideoCapability (pctxt, pvalue->u.videoData); if (stat != ASN_OK) return stat; break; /* audioData */ case 3: stat = asn1PE_H245AudioCapability (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; break; /* data */ case 4: stat = asn1PE_H245DataApplicationCapability (pctxt, pvalue->u.data); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* redundancyEncoding */ case 5: stat = asn1PE_H245RedundancyEncoding (&lctxt, pvalue->u.redundancyEncoding); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multiplePayloadStream */ case 6: stat = asn1PE_H245MultiplePayloadStream (&lctxt, pvalue->u.multiplePayloadStream); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* fec */ case 7: stat = asn1PE_H245FECData (&lctxt, pvalue->u.fec); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H235Media */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H235Media (OOCTXT* pctxt, H245H235Media* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode encryptionAuthenticationAndIntegrity */ stat = asn1PE_H245EncryptionAuthenticationAndIntegrity (pctxt, &pvalue->encryptionAuthenticationAndIntegrity); if (stat != ASN_OK) return stat; /* encode mediaType */ stat = asn1PE_H245H235Media_mediaType (pctxt, &pvalue->mediaType); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamParameter */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexedStreamParameter (OOCTXT* pctxt, H245MultiplexedStreamParameter* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode multiplexFormat */ stat = asn1PE_H245MultiplexFormat (pctxt, &pvalue->multiplexFormat); if (stat != ASN_OK) return stat; /* encode controlOnMuxStream */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->controlOnMuxStream); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DataType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataType (OOCTXT* pctxt, H245DataType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* nullData */ case 2: /* NULL */ break; /* videoData */ case 3: stat = asn1PE_H245VideoCapability (pctxt, pvalue->u.videoData); if (stat != ASN_OK) return stat; break; /* audioData */ case 4: stat = asn1PE_H245AudioCapability (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; break; /* data */ case 5: stat = asn1PE_H245DataApplicationCapability (pctxt, pvalue->u.data); if (stat != ASN_OK) return stat; break; /* encryptionData */ case 6: stat = asn1PE_H245EncryptionMode (pctxt, pvalue->u.encryptionData); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* h235Control */ case 7: stat = asn1PE_H245NonStandardParameter (&lctxt, pvalue->u.h235Control); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* h235Media */ case 8: stat = asn1PE_H245H235Media (&lctxt, pvalue->u.h235Media); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multiplexedStream */ case 9: stat = asn1PE_H245MultiplexedStreamParameter (&lctxt, pvalue->u.multiplexedStream); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* redundancyEncoding */ case 10: stat = asn1PE_H245RedundancyEncoding (&lctxt, pvalue->u.redundancyEncoding); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multiplePayloadStream */ case 11: stat = asn1PE_H245MultiplePayloadStream (&lctxt, pvalue->u.multiplePayloadStream); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* fec */ case 12: stat = asn1PE_H245FECData (&lctxt, pvalue->u.fec); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H222LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H222LogicalChannelParameters (OOCTXT* pctxt, H245H222LogicalChannelParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.pcr_pidPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.programDescriptorsPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.streamDescriptorsPresent); /* encode resourceID */ stat = encodeConsUnsigned (pctxt, pvalue->resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode subChannelID */ stat = encodeConsUnsigned (pctxt, pvalue->subChannelID, 0U, 8191U); if (stat != ASN_OK) return stat; /* encode pcr_pid */ if (pvalue->m.pcr_pidPresent) { stat = encodeConsUnsigned (pctxt, pvalue->pcr_pid, 0U, 8191U); if (stat != ASN_OK) return stat; } /* encode programDescriptors */ if (pvalue->m.programDescriptorsPresent) { stat = encodeOctetString (pctxt, pvalue->programDescriptors.numocts, pvalue->programDescriptors.data); if (stat != ASN_OK) return stat; } /* encode streamDescriptors */ if (pvalue->m.streamDescriptorsPresent) { stat = encodeOctetString (pctxt, pvalue->streamDescriptors.numocts, pvalue->streamDescriptors.data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223LogicalChannelParameters_adaptationLayerType_al3 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223LogicalChannelParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType_al3* pvalue) { int stat = ASN_OK; /* encode controlFieldOctets */ stat = encodeConsUnsigned (pctxt, pvalue->controlFieldOctets, 0U, 2U); if (stat != ASN_OK) return stat; /* encode sendBufferSize */ stat = encodeConsUnsigned (pctxt, pvalue->sendBufferSize, 0U, 16777215U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_transferMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL1MParameters_transferMode (OOCTXT* pctxt, H245H223AL1MParameters_transferMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* framed */ case 1: /* NULL */ break; /* unframed */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_headerFEC */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL1MParameters_headerFEC (OOCTXT* pctxt, H245H223AL1MParameters_headerFEC* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* sebch16_7 */ case 1: /* NULL */ break; /* golay24_12 */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_crcLength */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL1MParameters_crcLength (OOCTXT* pctxt, H245H223AL1MParameters_crcLength* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* crc4bit */ case 1: /* NULL */ break; /* crc12bit */ case 2: /* NULL */ break; /* crc20bit */ case 3: /* NULL */ break; /* crc28bit */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* crc8bit */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* crc16bit */ case 6: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* crc32bit */ case 7: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* crcNotUsed */ case 8: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H223AnnexCArqParameters_numberOfRetransmissions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AnnexCArqParameters_numberOfRetransmissions (OOCTXT* pctxt, H245H223AnnexCArqParameters_numberOfRetransmissions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* finite */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.finite, 0U, 16U); if (stat != ASN_OK) return stat; break; /* infinite */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223AnnexCArqParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AnnexCArqParameters (OOCTXT* pctxt, H245H223AnnexCArqParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode numberOfRetransmissions */ stat = asn1PE_H245H223AnnexCArqParameters_numberOfRetransmissions (pctxt, &pvalue->numberOfRetransmissions); if (stat != ASN_OK) return stat; /* encode sendBufferSize */ stat = encodeConsUnsigned (pctxt, pvalue->sendBufferSize, 0U, 16777215U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters_arqType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL1MParameters_arqType (OOCTXT* pctxt, H245H223AL1MParameters_arqType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noArq */ case 1: /* NULL */ break; /* typeIArq */ case 2: stat = asn1PE_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIArq); if (stat != ASN_OK) return stat; break; /* typeIIArq */ case 3: stat = asn1PE_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIIArq); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223AL1MParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL1MParameters (OOCTXT* pctxt, H245H223AL1MParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.rsCodeCorrectionPresent); encodeBit (pctxt, extbit); /* encode transferMode */ stat = asn1PE_H245H223AL1MParameters_transferMode (pctxt, &pvalue->transferMode); if (stat != ASN_OK) return stat; /* encode headerFEC */ stat = asn1PE_H245H223AL1MParameters_headerFEC (pctxt, &pvalue->headerFEC); if (stat != ASN_OK) return stat; /* encode crcLength */ stat = asn1PE_H245H223AL1MParameters_crcLength (pctxt, &pvalue->crcLength); if (stat != ASN_OK) return stat; /* encode rcpcCodeRate */ stat = encodeConsUnsigned (pctxt, pvalue->rcpcCodeRate, 8U, 32U); if (stat != ASN_OK) return stat; /* encode arqType */ stat = asn1PE_H245H223AL1MParameters_arqType (pctxt, &pvalue->arqType); if (stat != ASN_OK) return stat; /* encode alpduInterleaving */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; /* encode alsduSplitting */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alsduSplitting); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.rsCodeCorrectionPresent); /* encode extension elements */ if (pvalue->m.rsCodeCorrectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->rsCodeCorrection, 0U, 127U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H223AL2MParameters_headerFEC */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL2MParameters_headerFEC (OOCTXT* pctxt, H245H223AL2MParameters_headerFEC* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* sebch16_5 */ case 1: /* NULL */ break; /* golay24_12 */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223AL2MParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL2MParameters (OOCTXT* pctxt, H245H223AL2MParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode headerFEC */ stat = asn1PE_H245H223AL2MParameters_headerFEC (pctxt, &pvalue->headerFEC); if (stat != ASN_OK) return stat; /* encode alpduInterleaving */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters_headerFormat */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL3MParameters_headerFormat (OOCTXT* pctxt, H245H223AL3MParameters_headerFormat* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* sebch16_7 */ case 1: /* NULL */ break; /* golay24_12 */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters_crcLength */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL3MParameters_crcLength (OOCTXT* pctxt, H245H223AL3MParameters_crcLength* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* crc4bit */ case 1: /* NULL */ break; /* crc12bit */ case 2: /* NULL */ break; /* crc20bit */ case 3: /* NULL */ break; /* crc28bit */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* crc8bit */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* crc16bit */ case 6: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* crc32bit */ case 7: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* crcNotUsed */ case 8: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters_arqType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL3MParameters_arqType (OOCTXT* pctxt, H245H223AL3MParameters_arqType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noArq */ case 1: /* NULL */ break; /* typeIArq */ case 2: stat = asn1PE_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIArq); if (stat != ASN_OK) return stat; break; /* typeIIArq */ case 3: stat = asn1PE_H245H223AnnexCArqParameters (pctxt, pvalue->u.typeIIArq); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223AL3MParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223AL3MParameters (OOCTXT* pctxt, H245H223AL3MParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.rsCodeCorrectionPresent); encodeBit (pctxt, extbit); /* encode headerFormat */ stat = asn1PE_H245H223AL3MParameters_headerFormat (pctxt, &pvalue->headerFormat); if (stat != ASN_OK) return stat; /* encode crcLength */ stat = asn1PE_H245H223AL3MParameters_crcLength (pctxt, &pvalue->crcLength); if (stat != ASN_OK) return stat; /* encode rcpcCodeRate */ stat = encodeConsUnsigned (pctxt, pvalue->rcpcCodeRate, 8U, 32U); if (stat != ASN_OK) return stat; /* encode arqType */ stat = asn1PE_H245H223AL3MParameters_arqType (pctxt, &pvalue->arqType); if (stat != ASN_OK) return stat; /* encode alpduInterleaving */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->alpduInterleaving); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.rsCodeCorrectionPresent); /* encode extension elements */ if (pvalue->m.rsCodeCorrectionPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->rsCodeCorrection, 0U, 127U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H223LogicalChannelParameters_adaptationLayerType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223LogicalChannelParameters_adaptationLayerType (OOCTXT* pctxt, H245H223LogicalChannelParameters_adaptationLayerType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* al1Framed */ case 2: /* NULL */ break; /* al1NotFramed */ case 3: /* NULL */ break; /* al2WithoutSequenceNumbers */ case 4: /* NULL */ break; /* al2WithSequenceNumbers */ case 5: /* NULL */ break; /* al3 */ case 6: stat = asn1PE_H245H223LogicalChannelParameters_adaptationLayerType_al3 (pctxt, pvalue->u.al3); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* al1M */ case 7: stat = asn1PE_H245H223AL1MParameters (&lctxt, pvalue->u.al1M); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* al2M */ case 8: stat = asn1PE_H245H223AL2MParameters (&lctxt, pvalue->u.al2M); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* al3M */ case 9: stat = asn1PE_H245H223AL3MParameters (&lctxt, pvalue->u.al3M); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H223LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223LogicalChannelParameters (OOCTXT* pctxt, H245H223LogicalChannelParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode adaptationLayerType */ stat = asn1PE_H245H223LogicalChannelParameters_adaptationLayerType (pctxt, &pvalue->adaptationLayerType); if (stat != ASN_OK) return stat; /* encode segmentableFlag */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->segmentableFlag); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CRCLength */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CRCLength (OOCTXT* pctxt, H245CRCLength* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* crc8bit */ case 1: /* NULL */ break; /* crc16bit */ case 2: /* NULL */ break; /* crc32bit */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* V76HDLCParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76HDLCParameters (OOCTXT* pctxt, H245V76HDLCParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode crcLength */ stat = asn1PE_H245CRCLength (pctxt, &pvalue->crcLength); if (stat != ASN_OK) return stat; /* encode n401 */ stat = encodeConsUnsigned (pctxt, pvalue->n401, 1U, 4095U); if (stat != ASN_OK) return stat; /* encode loopbackTestProcedure */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->loopbackTestProcedure); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_suspendResume */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76LogicalChannelParameters_suspendResume (OOCTXT* pctxt, H245V76LogicalChannelParameters_suspendResume* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noSuspendResume */ case 1: /* NULL */ break; /* suspendResumewAddress */ case 2: /* NULL */ break; /* suspendResumewoAddress */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode_eRM_recovery */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76LogicalChannelParameters_mode_eRM_recovery (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM_recovery* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* rej */ case 1: /* NULL */ break; /* sREJ */ case 2: /* NULL */ break; /* mSREJ */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode_eRM */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76LogicalChannelParameters_mode_eRM (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode_eRM* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode windowSize */ stat = encodeConsUnsigned (pctxt, pvalue->windowSize, 1U, 127U); if (stat != ASN_OK) return stat; /* encode recovery */ stat = asn1PE_H245V76LogicalChannelParameters_mode_eRM_recovery (pctxt, &pvalue->recovery); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters_mode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76LogicalChannelParameters_mode (OOCTXT* pctxt, H245V76LogicalChannelParameters_mode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* eRM */ case 1: stat = asn1PE_H245V76LogicalChannelParameters_mode_eRM (pctxt, pvalue->u.eRM); if (stat != ASN_OK) return stat; break; /* uNERM */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* V75Parameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V75Parameters (OOCTXT* pctxt, H245V75Parameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioHeaderPresent */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->audioHeaderPresent); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* V76LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76LogicalChannelParameters (OOCTXT* pctxt, H245V76LogicalChannelParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode hdlcParameters */ stat = asn1PE_H245V76HDLCParameters (pctxt, &pvalue->hdlcParameters); if (stat != ASN_OK) return stat; /* encode suspendResume */ stat = asn1PE_H245V76LogicalChannelParameters_suspendResume (pctxt, &pvalue->suspendResume); if (stat != ASN_OK) return stat; /* encode uIH */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->uIH); if (stat != ASN_OK) return stat; /* encode mode */ stat = asn1PE_H245V76LogicalChannelParameters_mode (pctxt, &pvalue->mode); if (stat != ASN_OK) return stat; /* encode v75Parameters */ stat = asn1PE_H245V75Parameters (pctxt, &pvalue->v75Parameters); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPAddress_network */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPAddress_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPAddress (OOCTXT* pctxt, H245UnicastAddress_iPAddress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode network */ stat = asn1PE_H245UnicastAddress_iPAddress_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; /* encode tsapIdentifier */ stat = encodeConsUnsigned (pctxt, pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_node */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPXAddress_node (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_node* pvalue) { static Asn1SizeCnst lsize1 = { 0, 6, 6, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_netnum */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPXAddress_netnum (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_netnum* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress_tsapIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPXAddress_tsapIdentifier (OOCTXT* pctxt, H245UnicastAddress_iPXAddress_tsapIdentifier* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 2, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPXAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPXAddress (OOCTXT* pctxt, H245UnicastAddress_iPXAddress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode node */ stat = asn1PE_H245UnicastAddress_iPXAddress_node (pctxt, &pvalue->node); if (stat != ASN_OK) return stat; /* encode netnum */ stat = asn1PE_H245UnicastAddress_iPXAddress_netnum (pctxt, &pvalue->netnum); if (stat != ASN_OK) return stat; /* encode tsapIdentifier */ stat = asn1PE_H245UnicastAddress_iPXAddress_tsapIdentifier (pctxt, &pvalue->tsapIdentifier); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iP6Address_network */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iP6Address_network (OOCTXT* pctxt, H245UnicastAddress_iP6Address_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iP6Address */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iP6Address (OOCTXT* pctxt, H245UnicastAddress_iP6Address* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode network */ stat = asn1PE_H245UnicastAddress_iP6Address_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; /* encode tsapIdentifier */ stat = encodeConsUnsigned (pctxt, pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_netBios */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_netBios (OOCTXT* pctxt, H245UnicastAddress_netBios* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_routing */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress_routing (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_routing* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* strict */ case 1: /* NULL */ break; /* loose */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_network */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress_network (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress_route_element */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress_route_element* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH245UnicastAddress_iPSourceRouteAddress_route_elem */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element (OOCTXT* pctxt, H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245UnicastAddress_iPSourceRouteAddress_route_element (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* UnicastAddress_iPSourceRouteAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_iPSourceRouteAddress (OOCTXT* pctxt, H245UnicastAddress_iPSourceRouteAddress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode routing */ stat = asn1PE_H245UnicastAddress_iPSourceRouteAddress_routing (pctxt, &pvalue->routing); if (stat != ASN_OK) return stat; /* encode network */ stat = asn1PE_H245UnicastAddress_iPSourceRouteAddress_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; /* encode tsapIdentifier */ stat = encodeConsUnsigned (pctxt, pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode route */ stat = asn1PE_H245_SeqOfH245UnicastAddress_iPSourceRouteAddress_route_element (pctxt, &pvalue->route); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress_nsap */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress_nsap (OOCTXT* pctxt, H245UnicastAddress_nsap* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UnicastAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UnicastAddress (OOCTXT* pctxt, H245UnicastAddress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* iPAddress */ case 1: stat = asn1PE_H245UnicastAddress_iPAddress (pctxt, pvalue->u.iPAddress); if (stat != ASN_OK) return stat; break; /* iPXAddress */ case 2: stat = asn1PE_H245UnicastAddress_iPXAddress (pctxt, pvalue->u.iPXAddress); if (stat != ASN_OK) return stat; break; /* iP6Address */ case 3: stat = asn1PE_H245UnicastAddress_iP6Address (pctxt, pvalue->u.iP6Address); if (stat != ASN_OK) return stat; break; /* netBios */ case 4: stat = asn1PE_H245UnicastAddress_netBios (pctxt, pvalue->u.netBios); if (stat != ASN_OK) return stat; break; /* iPSourceRouteAddress */ case 5: stat = asn1PE_H245UnicastAddress_iPSourceRouteAddress (pctxt, pvalue->u.iPSourceRouteAddress); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* nsap */ case 6: stat = asn1PE_H245UnicastAddress_nsap (&lctxt, pvalue->u.nsap); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* nonStandardAddress */ case 7: stat = asn1PE_H245NonStandardParameter (&lctxt, pvalue->u.nonStandardAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iPAddress_network */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MulticastAddress_iPAddress_network (OOCTXT* pctxt, H245MulticastAddress_iPAddress_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iPAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MulticastAddress_iPAddress (OOCTXT* pctxt, H245MulticastAddress_iPAddress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode network */ stat = asn1PE_H245MulticastAddress_iPAddress_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; /* encode tsapIdentifier */ stat = encodeConsUnsigned (pctxt, pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iP6Address_network */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MulticastAddress_iP6Address_network (OOCTXT* pctxt, H245MulticastAddress_iP6Address_network* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MulticastAddress_iP6Address */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MulticastAddress_iP6Address (OOCTXT* pctxt, H245MulticastAddress_iP6Address* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode network */ stat = asn1PE_H245MulticastAddress_iP6Address_network (pctxt, &pvalue->network); if (stat != ASN_OK) return stat; /* encode tsapIdentifier */ stat = encodeConsUnsigned (pctxt, pvalue->tsapIdentifier, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MulticastAddress_nsap */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MulticastAddress_nsap (OOCTXT* pctxt, H245MulticastAddress_nsap* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MulticastAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MulticastAddress (OOCTXT* pctxt, H245MulticastAddress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* iPAddress */ case 1: stat = asn1PE_H245MulticastAddress_iPAddress (pctxt, pvalue->u.iPAddress); if (stat != ASN_OK) return stat; break; /* iP6Address */ case 2: stat = asn1PE_H245MulticastAddress_iP6Address (pctxt, pvalue->u.iP6Address); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* nsap */ case 3: stat = asn1PE_H245MulticastAddress_nsap (&lctxt, pvalue->u.nsap); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* nonStandardAddress */ case 4: stat = asn1PE_H245NonStandardParameter (&lctxt, pvalue->u.nonStandardAddress); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* TransportAddress */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TransportAddress (OOCTXT* pctxt, H245TransportAddress* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unicastAddress */ case 1: stat = asn1PE_H245UnicastAddress (pctxt, pvalue->u.unicastAddress); if (stat != ASN_OK) return stat; break; /* multicastAddress */ case 2: stat = asn1PE_H245MulticastAddress (pctxt, pvalue->u.multicastAddress); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* McuNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245McuNumber (OOCTXT* pctxt, H245McuNumber value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 0U, 192U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TerminalNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalNumber (OOCTXT* pctxt, H245TerminalNumber value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 0U, 192U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TerminalLabel */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalLabel (OOCTXT* pctxt, H245TerminalLabel* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode mcuNumber */ stat = asn1PE_H245McuNumber (pctxt, pvalue->mcuNumber); if (stat != ASN_OK) return stat; /* encode terminalNumber */ stat = asn1PE_H245TerminalNumber (pctxt, pvalue->terminalNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H2250LogicalChannelParameters_mediaPacketization */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250LogicalChannelParameters_mediaPacketization (OOCTXT* pctxt, H245H2250LogicalChannelParameters_mediaPacketization* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* h261aVideoPacketization */ case 1: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* rtpPayloadType */ case 2: stat = asn1PE_H245RTPPayloadType (&lctxt, pvalue->u.rtpPayloadType); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H2250LogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250LogicalChannelParameters (OOCTXT* pctxt, H245H2250LogicalChannelParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.transportCapabilityPresent || pvalue->m.redundancyEncodingPresent || pvalue->m.sourcePresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.associatedSessionIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaChannelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaGuaranteedDeliveryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaControlChannelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaControlGuaranteedDeliveryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.silenceSuppressionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.dynamicRTPPayloadTypePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaPacketizationPresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } /* encode sessionID */ stat = encodeConsUnsigned (pctxt, pvalue->sessionID, 0U, 255U); if (stat != ASN_OK) return stat; /* encode associatedSessionID */ if (pvalue->m.associatedSessionIDPresent) { stat = encodeConsUnsigned (pctxt, pvalue->associatedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; } /* encode mediaChannel */ if (pvalue->m.mediaChannelPresent) { stat = asn1PE_H245TransportAddress (pctxt, &pvalue->mediaChannel); if (stat != ASN_OK) return stat; } /* encode mediaGuaranteedDelivery */ if (pvalue->m.mediaGuaranteedDeliveryPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->mediaGuaranteedDelivery); if (stat != ASN_OK) return stat; } /* encode mediaControlChannel */ if (pvalue->m.mediaControlChannelPresent) { stat = asn1PE_H245TransportAddress (pctxt, &pvalue->mediaControlChannel); if (stat != ASN_OK) return stat; } /* encode mediaControlGuaranteedDelivery */ if (pvalue->m.mediaControlGuaranteedDeliveryPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->mediaControlGuaranteedDelivery); if (stat != ASN_OK) return stat; } /* encode silenceSuppression */ if (pvalue->m.silenceSuppressionPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->silenceSuppression); if (stat != ASN_OK) return stat; } /* encode destination */ if (pvalue->m.destinationPresent) { stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->destination); if (stat != ASN_OK) return stat; } /* encode dynamicRTPPayloadType */ if (pvalue->m.dynamicRTPPayloadTypePresent) { stat = encodeConsUnsigned (pctxt, pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; } /* encode mediaPacketization */ if (pvalue->m.mediaPacketizationPresent) { stat = asn1PE_H245H2250LogicalChannelParameters_mediaPacketization (pctxt, &pvalue->mediaPacketization); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 2); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.transportCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.redundancyEncodingPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sourcePresent); /* encode extension elements */ if (pvalue->m.transportCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245TransportCapability (&lctxt, &pvalue->transportCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.redundancyEncodingPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245RedundancyEncoding (&lctxt, &pvalue->redundancyEncoding); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.sourcePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245TerminalLabel (&lctxt, &pvalue->source); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_forwardLogicalChannelParameters_multi */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* h222LogicalChannelParameters */ case 1: stat = asn1PE_H245H222LogicalChannelParameters (pctxt, pvalue->u.h222LogicalChannelParameters); if (stat != ASN_OK) return stat; break; /* h223LogicalChannelParameters */ case 2: stat = asn1PE_H245H223LogicalChannelParameters (pctxt, pvalue->u.h223LogicalChannelParameters); if (stat != ASN_OK) return stat; break; /* v76LogicalChannelParameters */ case 3: stat = asn1PE_H245V76LogicalChannelParameters (pctxt, pvalue->u.v76LogicalChannelParameters); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* h2250LogicalChannelParameters */ case 4: stat = asn1PE_H245H2250LogicalChannelParameters (&lctxt, pvalue->u.h2250LogicalChannelParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* none */ case 5: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_forwardLogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannel_forwardLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_forwardLogicalChannelParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.forwardLogicalChannelDependencyPresent || pvalue->m.replacementForPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.portNumberPresent); /* encode portNumber */ if (pvalue->m.portNumberPresent) { stat = encodeConsUnsigned (pctxt, pvalue->portNumber, 0U, 65535U); if (stat != ASN_OK) return stat; } /* encode dataType */ stat = asn1PE_H245DataType (pctxt, &pvalue->dataType); if (stat != ASN_OK) return stat; /* encode multiplexParameters */ stat = asn1PE_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters (pctxt, &pvalue->multiplexParameters); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.forwardLogicalChannelDependencyPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.replacementForPresent); /* encode extension elements */ if (pvalue->m.forwardLogicalChannelDependencyPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245LogicalChannelNumber (&lctxt, pvalue->forwardLogicalChannelDependency); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.replacementForPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245LogicalChannelNumber (&lctxt, pvalue->replacementFor); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_reverseLogicalChannelParameters_multi */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* h223LogicalChannelParameters */ case 1: stat = asn1PE_H245H223LogicalChannelParameters (pctxt, pvalue->u.h223LogicalChannelParameters); if (stat != ASN_OK) return stat; break; /* v76LogicalChannelParameters */ case 2: stat = asn1PE_H245V76LogicalChannelParameters (pctxt, pvalue->u.v76LogicalChannelParameters); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* h2250LogicalChannelParameters */ case 3: stat = asn1PE_H245H2250LogicalChannelParameters (&lctxt, pvalue->u.h2250LogicalChannelParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel_reverseLogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannel_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannel_reverseLogicalChannelParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.reverseLogicalChannelDependencyPresent || pvalue->m.replacementForPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multiplexParametersPresent); /* encode dataType */ stat = asn1PE_H245DataType (pctxt, &pvalue->dataType); if (stat != ASN_OK) return stat; /* encode multiplexParameters */ if (pvalue->m.multiplexParametersPresent) { stat = asn1PE_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters (pctxt, &pvalue->multiplexParameters); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.reverseLogicalChannelDependencyPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.replacementForPresent); /* encode extension elements */ if (pvalue->m.reverseLogicalChannelDependencyPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245LogicalChannelNumber (&lctxt, pvalue->reverseLogicalChannelDependency); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.replacementForPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245LogicalChannelNumber (&lctxt, pvalue->replacementFor); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_distribution */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NetworkAccessParameters_distribution (OOCTXT* pctxt, H245NetworkAccessParameters_distribution* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unicast */ case 1: /* NULL */ break; /* multicast */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_networkAddress */ /* */ /**************************************************************/ extern EXTERN const char* gs_MULTIMEDIA_SYSTEM_CONTROL_NetworkAccessParameters_networkAddress_e164Address_CharSet; EXTERN int asn1PE_H245NetworkAccessParameters_networkAddress (OOCTXT* pctxt, H245NetworkAccessParameters_networkAddress* pvalue) { static Asn1SizeCnst e164Address_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* q2931Address */ case 1: stat = asn1PE_H245Q2931Address (pctxt, pvalue->u.q2931Address); if (stat != ASN_OK) return stat; break; /* e164Address */ case 2: addSizeConstraint (pctxt, &e164Address_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->u.e164Address, gs_MULTIMEDIA_SYSTEM_CONTROL_NetworkAccessParameters_networkAddress_e164Address_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; break; /* localAreaAddress */ case 3: stat = asn1PE_H245TransportAddress (pctxt, pvalue->u.localAreaAddress); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_externalReference */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NetworkAccessParameters_externalReference (OOCTXT* pctxt, H245NetworkAccessParameters_externalReference* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 255, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters_t120SetupProcedure */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NetworkAccessParameters_t120SetupProcedure (OOCTXT* pctxt, H245NetworkAccessParameters_t120SetupProcedure* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* originateCall */ case 1: /* NULL */ break; /* waitForCall */ case 2: /* NULL */ break; /* issueQuery */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NetworkAccessParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NetworkAccessParameters (OOCTXT* pctxt, H245NetworkAccessParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.t120SetupProcedurePresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.distributionPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.externalReferencePresent); /* encode distribution */ if (pvalue->m.distributionPresent) { stat = asn1PE_H245NetworkAccessParameters_distribution (pctxt, &pvalue->distribution); if (stat != ASN_OK) return stat; } /* encode networkAddress */ stat = asn1PE_H245NetworkAccessParameters_networkAddress (pctxt, &pvalue->networkAddress); if (stat != ASN_OK) return stat; /* encode associateConference */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->associateConference); if (stat != ASN_OK) return stat; /* encode externalReference */ if (pvalue->m.externalReferencePresent) { stat = asn1PE_H245NetworkAccessParameters_externalReference (pctxt, &pvalue->externalReference); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.t120SetupProcedurePresent); /* encode extension elements */ if (pvalue->m.t120SetupProcedurePresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245NetworkAccessParameters_t120SetupProcedure (&lctxt, &pvalue->t120SetupProcedure); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* EscrowData_escrowValue */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EscrowData_escrowValue (OOCTXT* pctxt, H245EscrowData_escrowValue* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeBitString (pctxt, pvalue->numbits, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EscrowData */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EscrowData (OOCTXT* pctxt, H245EscrowData* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode escrowID */ stat = encodeObjectIdentifier (pctxt, &pvalue->escrowID); if (stat != ASN_OK) return stat; /* encode escrowValue */ stat = asn1PE_H245EscrowData_escrowValue (pctxt, &pvalue->escrowValue); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncryptionSync_escrowentry */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionSync_escrowentry (OOCTXT* pctxt, H245EncryptionSync_escrowentry* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245EscrowData (pctxt, ((H245EscrowData*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* EncryptionSync */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionSync (OOCTXT* pctxt, H245EncryptionSync* pvalue) { static Asn1SizeCnst h235Key_lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.escrowentryPresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } /* encode synchFlag */ stat = encodeConsUnsigned (pctxt, pvalue->synchFlag, 0U, 255U); if (stat != ASN_OK) return stat; /* encode h235Key */ addSizeConstraint (pctxt, &h235Key_lsize1); stat = encodeOctetString (pctxt, pvalue->h235Key.numocts, pvalue->h235Key.data); if (stat != ASN_OK) return stat; /* encode escrowentry */ if (pvalue->m.escrowentryPresent) { stat = asn1PE_H245EncryptionSync_escrowentry (pctxt, &pvalue->escrowentry); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannel */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannel (OOCTXT* pctxt, H245OpenLogicalChannel* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.separateStackPresent || pvalue->m.encryptionSyncPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.reverseLogicalChannelParametersPresent); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; /* encode forwardLogicalChannelParameters */ stat = asn1PE_H245OpenLogicalChannel_forwardLogicalChannelParameters (pctxt, &pvalue->forwardLogicalChannelParameters); if (stat != ASN_OK) return stat; /* encode reverseLogicalChannelParameters */ if (pvalue->m.reverseLogicalChannelParametersPresent) { stat = asn1PE_H245OpenLogicalChannel_reverseLogicalChannelParameters (pctxt, &pvalue->reverseLogicalChannelParameters); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.separateStackPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.encryptionSyncPresent); /* encode extension elements */ if (pvalue->m.separateStackPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245NetworkAccessParameters (&lctxt, &pvalue->separateStack); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.encryptionSyncPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245EncryptionSync (&lctxt, &pvalue->encryptionSync); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannel_source */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CloseLogicalChannel_source (OOCTXT* pctxt, H245CloseLogicalChannel_source* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* user */ case 1: /* NULL */ break; /* lcse */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannel_reason */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CloseLogicalChannel_reason (OOCTXT* pctxt, H245CloseLogicalChannel_reason* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unknown */ case 1: /* NULL */ break; /* reopen */ case 2: /* NULL */ break; /* reservationFailure */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannel */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CloseLogicalChannel (OOCTXT* pctxt, H245CloseLogicalChannel* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.reasonPresent); encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; /* encode source */ stat = asn1PE_H245CloseLogicalChannel_source (pctxt, &pvalue->source); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.reasonPresent); /* encode extension elements */ if (pvalue->m.reasonPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245CloseLogicalChannel_reason (&lctxt, &pvalue->reason); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* RequestChannelClose_reason */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestChannelClose_reason (OOCTXT* pctxt, H245RequestChannelClose_reason* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unknown */ case 1: /* NULL */ break; /* normal */ case 2: /* NULL */ break; /* reopen */ case 3: /* NULL */ break; /* reservationFailure */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RequestChannelClose */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestChannelClose (OOCTXT* pctxt, H245RequestChannelClose* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.qosCapabilityPresent || pvalue->m.reasonPresent); encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.qosCapabilityPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.reasonPresent); /* encode extension elements */ if (pvalue->m.qosCapabilityPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245QOSCapability (&lctxt, &pvalue->qosCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.reasonPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245RequestChannelClose_reason (&lctxt, &pvalue->reason); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* MultiplexTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexTableEntryNumber value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 1U, 15U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplexElement_type_subElementList */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexElement_type_subElementList (OOCTXT* pctxt, H245MultiplexElement_type_subElementList* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 255, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245MultiplexElement (pctxt, (H245MultiplexElement*)((H245MultiplexElement*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MultiplexElement_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexElement_type (OOCTXT* pctxt, H245MultiplexElement_type* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* logicalChannelNumber */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.logicalChannelNumber, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* subElementList */ case 2: stat = asn1PE_H245MultiplexElement_type_subElementList (pctxt, pvalue->u.subElementList); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MultiplexElement_repeatCount */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexElement_repeatCount (OOCTXT* pctxt, H245MultiplexElement_repeatCount* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* finite */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.finite, 1U, 65535U); if (stat != ASN_OK) return stat; break; /* untilClosingFlag */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MultiplexElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexElement (OOCTXT* pctxt, H245MultiplexElement* pvalue) { int stat = ASN_OK; /* encode type */ stat = asn1PE_H245MultiplexElement_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; /* encode repeatCount */ stat = asn1PE_H245MultiplexElement_repeatCount (pctxt, &pvalue->repeatCount); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplexEntryDescriptor_elementList */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntryDescriptor_elementList (OOCTXT* pctxt, H245MultiplexEntryDescriptor_elementList* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245MultiplexElement (pctxt, ((H245MultiplexElement*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MultiplexEntryDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntryDescriptor (OOCTXT* pctxt, H245MultiplexEntryDescriptor* pvalue) { int stat = ASN_OK; encodeBit (pctxt, (ASN1BOOL)pvalue->m.elementListPresent); /* encode multiplexTableEntryNumber */ stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; /* encode elementList */ if (pvalue->m.elementListPresent) { stat = asn1PE_H245MultiplexEntryDescriptor_elementList (pctxt, &pvalue->elementList); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySend_multiplexEntryDescriptors */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySend_multiplexEntryDescriptors (OOCTXT* pctxt, H245MultiplexEntrySend_multiplexEntryDescriptors* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245MultiplexEntryDescriptor (pctxt, ((H245MultiplexEntryDescriptor*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySend */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySend (OOCTXT* pctxt, H245MultiplexEntrySend* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode multiplexEntryDescriptors */ stat = asn1PE_H245MultiplexEntrySend_multiplexEntryDescriptors (pctxt, &pvalue->multiplexEntryDescriptors); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntry_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntry_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntry_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntry */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntry (OOCTXT* pctxt, H245RequestMultiplexEntry* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode entryNumbers */ stat = asn1PE_H245RequestMultiplexEntry_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H261VideoMode_resolution */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H261VideoMode_resolution (OOCTXT* pctxt, H245H261VideoMode_resolution* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* qcif */ case 1: /* NULL */ break; /* cif */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* H261VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H261VideoMode (OOCTXT* pctxt, H245H261VideoMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode resolution */ stat = asn1PE_H245H261VideoMode_resolution (pctxt, &pvalue->resolution); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 19200U); if (stat != ASN_OK) return stat; /* encode stillImageTransmission */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->stillImageTransmission); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H262VideoMode_profileAndLevel */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H262VideoMode_profileAndLevel (OOCTXT* pctxt, H245H262VideoMode_profileAndLevel* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 11); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 10); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* profileAndLevel_SPatML */ case 1: /* NULL */ break; /* profileAndLevel_MPatLL */ case 2: /* NULL */ break; /* profileAndLevel_MPatML */ case 3: /* NULL */ break; /* profileAndLevel_MPatH_14 */ case 4: /* NULL */ break; /* profileAndLevel_MPatHL */ case 5: /* NULL */ break; /* profileAndLevel_SNRatLL */ case 6: /* NULL */ break; /* profileAndLevel_SNRatML */ case 7: /* NULL */ break; /* profileAndLevel_SpatialatH_14 */ case 8: /* NULL */ break; /* profileAndLevel_HPatML */ case 9: /* NULL */ break; /* profileAndLevel_HPatH_14 */ case 10: /* NULL */ break; /* profileAndLevel_HPatHL */ case 11: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 12); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H262VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H262VideoMode (OOCTXT* pctxt, H245H262VideoMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBitRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.vbvBufferSizePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.samplesPerLinePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.linesPerFramePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.framesPerSecondPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.luminanceSampleRatePresent); /* encode profileAndLevel */ stat = asn1PE_H245H262VideoMode_profileAndLevel (pctxt, &pvalue->profileAndLevel); if (stat != ASN_OK) return stat; /* encode videoBitRate */ if (pvalue->m.videoBitRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; } /* encode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { stat = encodeConsUnsigned (pctxt, pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; } /* encode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { stat = encodeConsUnsigned (pctxt, pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { stat = encodeConsUnsigned (pctxt, pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode framesPerSecond */ if (pvalue->m.framesPerSecondPresent) { stat = encodeConsUnsigned (pctxt, pvalue->framesPerSecond, 0U, 15U); if (stat != ASN_OK) return stat; } /* encode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H263VideoMode_resolution */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263VideoMode_resolution (OOCTXT* pctxt, H245H263VideoMode_resolution* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* sqcif */ case 1: /* NULL */ break; /* qcif */ case 2: /* NULL */ break; /* cif */ case 3: /* NULL */ break; /* cif4 */ case 4: /* NULL */ break; /* cif16 */ case 5: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* custom */ case 6: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H263VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H263VideoMode (OOCTXT* pctxt, H245H263VideoMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.errorCompensationPresent || pvalue->m.enhancementLayerInfoPresent || pvalue->m.h263OptionsPresent); encodeBit (pctxt, extbit); /* encode resolution */ stat = asn1PE_H245H263VideoMode_resolution (pctxt, &pvalue->resolution); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 19200U); if (stat != ASN_OK) return stat; /* encode unrestrictedVector */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->unrestrictedVector); if (stat != ASN_OK) return stat; /* encode arithmeticCoding */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->arithmeticCoding); if (stat != ASN_OK) return stat; /* encode advancedPrediction */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->advancedPrediction); if (stat != ASN_OK) return stat; /* encode pbFrames */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->pbFrames); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 2); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.errorCompensationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.enhancementLayerInfoPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h263OptionsPresent); /* encode extension elements */ if (pvalue->m.errorCompensationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->errorCompensation); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.enhancementLayerInfoPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245EnhancementLayerInfo (&lctxt, &pvalue->enhancementLayerInfo); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h263OptionsPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H263Options (&lctxt, &pvalue->h263Options); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* IS11172VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS11172VideoMode (OOCTXT* pctxt, H245IS11172VideoMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.videoBitRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.vbvBufferSizePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.samplesPerLinePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.linesPerFramePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.pictureRatePresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.luminanceSampleRatePresent); /* encode constrainedBitstream */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->constrainedBitstream); if (stat != ASN_OK) return stat; /* encode videoBitRate */ if (pvalue->m.videoBitRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->videoBitRate, 0U, 1073741823U); if (stat != ASN_OK) return stat; } /* encode vbvBufferSize */ if (pvalue->m.vbvBufferSizePresent) { stat = encodeConsUnsigned (pctxt, pvalue->vbvBufferSize, 0U, 262143U); if (stat != ASN_OK) return stat; } /* encode samplesPerLine */ if (pvalue->m.samplesPerLinePresent) { stat = encodeConsUnsigned (pctxt, pvalue->samplesPerLine, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode linesPerFrame */ if (pvalue->m.linesPerFramePresent) { stat = encodeConsUnsigned (pctxt, pvalue->linesPerFrame, 0U, 16383U); if (stat != ASN_OK) return stat; } /* encode pictureRate */ if (pvalue->m.pictureRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->pictureRate, 0U, 15U); if (stat != ASN_OK) return stat; } /* encode luminanceSampleRate */ if (pvalue->m.luminanceSampleRatePresent) { stat = encodeConsUnsigned (pctxt, pvalue->luminanceSampleRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* VideoMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VideoMode (OOCTXT* pctxt, H245VideoMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* h261VideoMode */ case 2: stat = asn1PE_H245H261VideoMode (pctxt, pvalue->u.h261VideoMode); if (stat != ASN_OK) return stat; break; /* h262VideoMode */ case 3: stat = asn1PE_H245H262VideoMode (pctxt, pvalue->u.h262VideoMode); if (stat != ASN_OK) return stat; break; /* h263VideoMode */ case 4: stat = asn1PE_H245H263VideoMode (pctxt, pvalue->u.h263VideoMode); if (stat != ASN_OK) return stat; break; /* is11172VideoMode */ case 5: stat = asn1PE_H245IS11172VideoMode (pctxt, pvalue->u.is11172VideoMode); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* genericVideoMode */ case 6: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericVideoMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* AudioMode_g7231 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AudioMode_g7231 (OOCTXT* pctxt, H245AudioMode_g7231* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noSilenceSuppressionLowRate */ case 1: /* NULL */ break; /* noSilenceSuppressionHighRate */ case 2: /* NULL */ break; /* silenceSuppressionLowRate */ case 3: /* NULL */ break; /* silenceSuppressionHighRate */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode_audioLayer */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS11172AudioMode_audioLayer (OOCTXT* pctxt, H245IS11172AudioMode_audioLayer* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* audioLayer1 */ case 1: /* NULL */ break; /* audioLayer2 */ case 2: /* NULL */ break; /* audioLayer3 */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode_audioSampling */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS11172AudioMode_audioSampling (OOCTXT* pctxt, H245IS11172AudioMode_audioSampling* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* audioSampling32k */ case 1: /* NULL */ break; /* audioSampling44k1 */ case 2: /* NULL */ break; /* audioSampling48k */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode_multichannelType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS11172AudioMode_multichannelType (OOCTXT* pctxt, H245IS11172AudioMode_multichannelType* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* singleChannel */ case 1: /* NULL */ break; /* twoChannelStereo */ case 2: /* NULL */ break; /* twoChannelDual */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS11172AudioMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS11172AudioMode (OOCTXT* pctxt, H245IS11172AudioMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioLayer */ stat = asn1PE_H245IS11172AudioMode_audioLayer (pctxt, &pvalue->audioLayer); if (stat != ASN_OK) return stat; /* encode audioSampling */ stat = asn1PE_H245IS11172AudioMode_audioSampling (pctxt, &pvalue->audioSampling); if (stat != ASN_OK) return stat; /* encode multichannelType */ stat = asn1PE_H245IS11172AudioMode_multichannelType (pctxt, &pvalue->multichannelType); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 448U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode_audioLayer */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS13818AudioMode_audioLayer (OOCTXT* pctxt, H245IS13818AudioMode_audioLayer* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* audioLayer1 */ case 1: /* NULL */ break; /* audioLayer2 */ case 2: /* NULL */ break; /* audioLayer3 */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode_audioSampling */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS13818AudioMode_audioSampling (OOCTXT* pctxt, H245IS13818AudioMode_audioSampling* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* audioSampling16k */ case 1: /* NULL */ break; /* audioSampling22k05 */ case 2: /* NULL */ break; /* audioSampling24k */ case 3: /* NULL */ break; /* audioSampling32k */ case 4: /* NULL */ break; /* audioSampling44k1 */ case 5: /* NULL */ break; /* audioSampling48k */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode_multichannelType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS13818AudioMode_multichannelType (OOCTXT* pctxt, H245IS13818AudioMode_multichannelType* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 9); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* singleChannel */ case 1: /* NULL */ break; /* twoChannelStereo */ case 2: /* NULL */ break; /* twoChannelDual */ case 3: /* NULL */ break; /* threeChannels2_1 */ case 4: /* NULL */ break; /* threeChannels3_0 */ case 5: /* NULL */ break; /* fourChannels2_0_2_0 */ case 6: /* NULL */ break; /* fourChannels2_2 */ case 7: /* NULL */ break; /* fourChannels3_1 */ case 8: /* NULL */ break; /* fiveChannels3_0_2_0 */ case 9: /* NULL */ break; /* fiveChannels3_2 */ case 10: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* IS13818AudioMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IS13818AudioMode (OOCTXT* pctxt, H245IS13818AudioMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode audioLayer */ stat = asn1PE_H245IS13818AudioMode_audioLayer (pctxt, &pvalue->audioLayer); if (stat != ASN_OK) return stat; /* encode audioSampling */ stat = asn1PE_H245IS13818AudioMode_audioSampling (pctxt, &pvalue->audioSampling); if (stat != ASN_OK) return stat; /* encode multichannelType */ stat = asn1PE_H245IS13818AudioMode_multichannelType (pctxt, &pvalue->multichannelType); if (stat != ASN_OK) return stat; /* encode lowFrequencyEnhancement */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->lowFrequencyEnhancement); if (stat != ASN_OK) return stat; /* encode multilingual */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->multilingual); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 1130U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* G7231AnnexCMode_g723AnnexCAudioMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245G7231AnnexCMode_g723AnnexCAudioMode (OOCTXT* pctxt, H245G7231AnnexCMode_g723AnnexCAudioMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode highRateMode0 */ stat = encodeConsUnsigned (pctxt, pvalue->highRateMode0, 27U, 78U); if (stat != ASN_OK) return stat; /* encode highRateMode1 */ stat = encodeConsUnsigned (pctxt, pvalue->highRateMode1, 27U, 78U); if (stat != ASN_OK) return stat; /* encode lowRateMode0 */ stat = encodeConsUnsigned (pctxt, pvalue->lowRateMode0, 23U, 66U); if (stat != ASN_OK) return stat; /* encode lowRateMode1 */ stat = encodeConsUnsigned (pctxt, pvalue->lowRateMode1, 23U, 66U); if (stat != ASN_OK) return stat; /* encode sidMode0 */ stat = encodeConsUnsigned (pctxt, pvalue->sidMode0, 6U, 17U); if (stat != ASN_OK) return stat; /* encode sidMode1 */ stat = encodeConsUnsigned (pctxt, pvalue->sidMode1, 6U, 17U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* G7231AnnexCMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245G7231AnnexCMode (OOCTXT* pctxt, H245G7231AnnexCMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode maxAl_sduAudioFrames */ stat = encodeConsUnsigned (pctxt, pvalue->maxAl_sduAudioFrames, 1U, 256U); if (stat != ASN_OK) return stat; /* encode silenceSuppression */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->silenceSuppression); if (stat != ASN_OK) return stat; /* encode g723AnnexCAudioMode */ stat = asn1PE_H245G7231AnnexCMode_g723AnnexCAudioMode (pctxt, &pvalue->g723AnnexCAudioMode); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VBDMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VBDMode (OOCTXT* pctxt, H245VBDMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245AudioMode (pctxt, (H245AudioMode*)pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* AudioMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245AudioMode (OOCTXT* pctxt, H245AudioMode* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 14); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 13); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* g711Alaw64k */ case 2: /* NULL */ break; /* g711Alaw56k */ case 3: /* NULL */ break; /* g711Ulaw64k */ case 4: /* NULL */ break; /* g711Ulaw56k */ case 5: /* NULL */ break; /* g722_64k */ case 6: /* NULL */ break; /* g722_56k */ case 7: /* NULL */ break; /* g722_48k */ case 8: /* NULL */ break; /* g728 */ case 9: /* NULL */ break; /* g729 */ case 10: /* NULL */ break; /* g729AnnexA */ case 11: /* NULL */ break; /* g7231 */ case 12: stat = asn1PE_H245AudioMode_g7231 (pctxt, pvalue->u.g7231); if (stat != ASN_OK) return stat; break; /* is11172AudioMode */ case 13: stat = asn1PE_H245IS11172AudioMode (pctxt, pvalue->u.is11172AudioMode); if (stat != ASN_OK) return stat; break; /* is13818AudioMode */ case 14: stat = asn1PE_H245IS13818AudioMode (pctxt, pvalue->u.is13818AudioMode); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 15); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* g729wAnnexB */ case 15: stat = encodeConsUnsigned (&lctxt, pvalue->u.g729wAnnexB, 1U, 256U); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* g729AnnexAwAnnexB */ case 16: stat = encodeConsUnsigned (&lctxt, pvalue->u.g729AnnexAwAnnexB, 1U, 256U); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* g7231AnnexCMode */ case 17: stat = asn1PE_H245G7231AnnexCMode (&lctxt, pvalue->u.g7231AnnexCMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* gsmFullRate */ case 18: stat = asn1PE_H245GSMAudioCapability (&lctxt, pvalue->u.gsmFullRate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* gsmHalfRate */ case 19: stat = asn1PE_H245GSMAudioCapability (&lctxt, pvalue->u.gsmHalfRate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* gsmEnhancedFullRate */ case 20: stat = asn1PE_H245GSMAudioCapability (&lctxt, pvalue->u.gsmEnhancedFullRate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericAudioMode */ case 21: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericAudioMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* g729Extensions */ case 22: stat = asn1PE_H245G729Extensions (&lctxt, pvalue->u.g729Extensions); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* vbd */ case 23: stat = asn1PE_H245VBDMode (&lctxt, pvalue->u.vbd); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* DataMode_application_nlpid */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataMode_application_nlpid (OOCTXT* pctxt, H245DataMode_application_nlpid* pvalue) { int stat = ASN_OK; /* encode nlpidProtocol */ stat = asn1PE_H245DataProtocolCapability (pctxt, &pvalue->nlpidProtocol); if (stat != ASN_OK) return stat; /* encode nlpidData */ stat = encodeOctetString (pctxt, pvalue->nlpidData.numocts, pvalue->nlpidData.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DataMode_application_t38fax */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataMode_application_t38fax (OOCTXT* pctxt, H245DataMode_application_t38fax* pvalue) { int stat = ASN_OK; /* encode t38FaxProtocol */ stat = asn1PE_H245DataProtocolCapability (pctxt, &pvalue->t38FaxProtocol); if (stat != ASN_OK) return stat; /* encode t38FaxProfile */ stat = asn1PE_H245T38FaxProfile (pctxt, &pvalue->t38FaxProfile); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DataMode_application */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataMode_application (OOCTXT* pctxt, H245DataMode_application* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 10); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 9); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* t120 */ case 2: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.t120); if (stat != ASN_OK) return stat; break; /* dsm_cc */ case 3: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.dsm_cc); if (stat != ASN_OK) return stat; break; /* userData */ case 4: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.userData); if (stat != ASN_OK) return stat; break; /* t84 */ case 5: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.t84); if (stat != ASN_OK) return stat; break; /* t434 */ case 6: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.t434); if (stat != ASN_OK) return stat; break; /* h224 */ case 7: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.h224); if (stat != ASN_OK) return stat; break; /* nlpid */ case 8: stat = asn1PE_H245DataMode_application_nlpid (pctxt, pvalue->u.nlpid); if (stat != ASN_OK) return stat; break; /* dsvdControl */ case 9: /* NULL */ break; /* h222DataPartitioning */ case 10: stat = asn1PE_H245DataProtocolCapability (pctxt, pvalue->u.h222DataPartitioning); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 11); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* t30fax */ case 11: stat = asn1PE_H245DataProtocolCapability (&lctxt, pvalue->u.t30fax); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* t140 */ case 12: stat = asn1PE_H245DataProtocolCapability (&lctxt, pvalue->u.t140); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* t38fax */ case 13: stat = asn1PE_H245DataMode_application_t38fax (&lctxt, pvalue->u.t38fax); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* genericDataMode */ case 14: stat = asn1PE_H245GenericCapability (&lctxt, pvalue->u.genericDataMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* DataMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DataMode (OOCTXT* pctxt, H245DataMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode application */ stat = asn1PE_H245DataMode_application (pctxt, &pvalue->application); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H235Mode_mediaMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H235Mode_mediaMode (OOCTXT* pctxt, H245H235Mode_mediaMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* videoMode */ case 2: stat = asn1PE_H245VideoMode (pctxt, pvalue->u.videoMode); if (stat != ASN_OK) return stat; break; /* audioMode */ case 3: stat = asn1PE_H245AudioMode (pctxt, pvalue->u.audioMode); if (stat != ASN_OK) return stat; break; /* dataMode */ case 4: stat = asn1PE_H245DataMode (pctxt, pvalue->u.dataMode); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H235Mode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H235Mode (OOCTXT* pctxt, H245H235Mode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode encryptionAuthenticationAndIntegrity */ stat = asn1PE_H245EncryptionAuthenticationAndIntegrity (pctxt, &pvalue->encryptionAuthenticationAndIntegrity); if (stat != ASN_OK) return stat; /* encode mediaMode */ stat = asn1PE_H245H235Mode_mediaMode (pctxt, &pvalue->mediaMode); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingDTModeElement_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingDTModeElement_type (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement_type* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* videoMode */ case 2: stat = asn1PE_H245VideoMode (pctxt, pvalue->u.videoMode); if (stat != ASN_OK) return stat; break; /* audioMode */ case 3: stat = asn1PE_H245AudioMode (pctxt, pvalue->u.audioMode); if (stat != ASN_OK) return stat; break; /* dataMode */ case 4: stat = asn1PE_H245DataMode (pctxt, pvalue->u.dataMode); if (stat != ASN_OK) return stat; break; /* encryptionMode */ case 5: stat = asn1PE_H245EncryptionMode (pctxt, pvalue->u.encryptionMode); if (stat != ASN_OK) return stat; break; /* h235Mode */ case 6: stat = asn1PE_H245H235Mode (pctxt, pvalue->u.h235Mode); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingDTModeElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245RedundancyEncodingDTModeElement* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245RedundancyEncodingDTModeElement_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH245RedundancyEncodingDTModeElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245RedundancyEncodingDTModeElement (OOCTXT* pctxt, H245_SeqOfH245RedundancyEncodingDTModeElement* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245RedundancyEncodingDTModeElement (pctxt, ((H245RedundancyEncodingDTModeElement*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingDTMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingDTMode (OOCTXT* pctxt, H245RedundancyEncodingDTMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode redundancyEncodingMethod */ stat = asn1PE_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; /* encode primary */ stat = asn1PE_H245RedundancyEncodingDTModeElement (pctxt, &pvalue->primary); if (stat != ASN_OK) return stat; /* encode secondary */ stat = asn1PE_H245_SeqOfH245RedundancyEncodingDTModeElement (pctxt, &pvalue->secondary); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamElementMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245MultiplePayloadStreamElementMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245ModeElementType (pctxt, (H245ModeElementType*)pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH245MultiplePayloadStreamElementMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245MultiplePayloadStreamElementMode (OOCTXT* pctxt, H245_SeqOfH245MultiplePayloadStreamElementMode* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245MultiplePayloadStreamElementMode (pctxt, ((H245MultiplePayloadStreamElementMode*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* MultiplePayloadStreamMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplePayloadStreamMode (OOCTXT* pctxt, H245MultiplePayloadStreamMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode elements */ stat = asn1PE_H245_SeqOfH245MultiplePayloadStreamElementMode (pctxt, &pvalue->elements); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream_differentPort */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode_separateStream_differentPort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_differentPort* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.protectedPayloadTypePresent); /* encode protectedSessionID */ stat = encodeConsUnsigned (pctxt, pvalue->protectedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; /* encode protectedPayloadType */ if (pvalue->m.protectedPayloadTypePresent) { stat = encodeConsUnsigned (pctxt, pvalue->protectedPayloadType, 0U, 127U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream_samePort */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode_separateStream_samePort (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream_samePort* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode protectedType */ stat = asn1PE_H245ModeElementType (pctxt, (H245ModeElementType*)pvalue->protectedType); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode_separateStream */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode_separateStream (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode_separateStream* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* differentPort */ case 1: stat = asn1PE_H245FECMode_rfc2733Mode_mode_separateStream_differentPort (pctxt, pvalue->u.differentPort); if (stat != ASN_OK) return stat; break; /* samePort */ case 2: stat = asn1PE_H245FECMode_rfc2733Mode_mode_separateStream_samePort (pctxt, pvalue->u.samePort); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode_mode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECMode_rfc2733Mode_mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode_mode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* redundancyEncoding */ case 1: /* NULL */ break; /* separateStream */ case 2: stat = asn1PE_H245FECMode_rfc2733Mode_mode_separateStream (pctxt, pvalue->u.separateStream); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* FECMode_rfc2733Mode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECMode_rfc2733Mode (OOCTXT* pctxt, H245FECMode_rfc2733Mode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode mode */ stat = asn1PE_H245FECMode_rfc2733Mode_mode (pctxt, &pvalue->mode); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FECMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FECMode (OOCTXT* pctxt, H245FECMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* rfc2733Mode */ case 1: stat = asn1PE_H245FECMode_rfc2733Mode (pctxt, pvalue->u.rfc2733Mode); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ModeElementType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ModeElementType (OOCTXT* pctxt, H245ModeElementType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* videoMode */ case 2: stat = asn1PE_H245VideoMode (pctxt, pvalue->u.videoMode); if (stat != ASN_OK) return stat; break; /* audioMode */ case 3: stat = asn1PE_H245AudioMode (pctxt, pvalue->u.audioMode); if (stat != ASN_OK) return stat; break; /* dataMode */ case 4: stat = asn1PE_H245DataMode (pctxt, pvalue->u.dataMode); if (stat != ASN_OK) return stat; break; /* encryptionMode */ case 5: stat = asn1PE_H245EncryptionMode (pctxt, pvalue->u.encryptionMode); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* h235Mode */ case 6: stat = asn1PE_H245H235Mode (&lctxt, pvalue->u.h235Mode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multiplexedStreamMode */ case 7: stat = asn1PE_H245MultiplexedStreamParameter (&lctxt, pvalue->u.multiplexedStreamMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* redundancyEncodingDTMode */ case 8: stat = asn1PE_H245RedundancyEncodingDTMode (&lctxt, pvalue->u.redundancyEncodingDTMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multiplePayloadStreamMode */ case 9: stat = asn1PE_H245MultiplePayloadStreamMode (&lctxt, pvalue->u.multiplePayloadStreamMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* fecMode */ case 10: stat = asn1PE_H245FECMode (&lctxt, pvalue->u.fecMode); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H223ModeParameters_adaptationLayerType_al3 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223ModeParameters_adaptationLayerType_al3 (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType_al3* pvalue) { int stat = ASN_OK; /* encode controlFieldOctets */ stat = encodeConsUnsigned (pctxt, pvalue->controlFieldOctets, 0U, 2U); if (stat != ASN_OK) return stat; /* encode sendBufferSize */ stat = encodeConsUnsigned (pctxt, pvalue->sendBufferSize, 0U, 16777215U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* H223ModeParameters_adaptationLayerType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223ModeParameters_adaptationLayerType (OOCTXT* pctxt, H245H223ModeParameters_adaptationLayerType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* al1Framed */ case 2: /* NULL */ break; /* al1NotFramed */ case 3: /* NULL */ break; /* al2WithoutSequenceNumbers */ case 4: /* NULL */ break; /* al2WithSequenceNumbers */ case 5: /* NULL */ break; /* al3 */ case 6: stat = asn1PE_H245H223ModeParameters_adaptationLayerType_al3 (pctxt, pvalue->u.al3); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* al1M */ case 7: stat = asn1PE_H245H223AL1MParameters (&lctxt, pvalue->u.al1M); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* al2M */ case 8: stat = asn1PE_H245H223AL2MParameters (&lctxt, pvalue->u.al2M); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* al3M */ case 9: stat = asn1PE_H245H223AL3MParameters (&lctxt, pvalue->u.al3M); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H223ModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223ModeParameters (OOCTXT* pctxt, H245H223ModeParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode adaptationLayerType */ stat = asn1PE_H245H223ModeParameters_adaptationLayerType (pctxt, &pvalue->adaptationLayerType); if (stat != ASN_OK) return stat; /* encode segmentableFlag */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->segmentableFlag); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* V76ModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245V76ModeParameters (OOCTXT* pctxt, H245V76ModeParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* suspendResumewAddress */ case 1: /* NULL */ break; /* suspendResumewoAddress */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingMode_secondaryEncoding */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingMode_secondaryEncoding (OOCTXT* pctxt, H245RedundancyEncodingMode_secondaryEncoding* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* audioData */ case 2: stat = asn1PE_H245AudioMode (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RedundancyEncodingMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RedundancyEncodingMode (OOCTXT* pctxt, H245RedundancyEncodingMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.secondaryEncodingPresent); /* encode redundancyEncodingMethod */ stat = asn1PE_H245RedundancyEncodingMethod (pctxt, &pvalue->redundancyEncodingMethod); if (stat != ASN_OK) return stat; /* encode secondaryEncoding */ if (pvalue->m.secondaryEncodingPresent) { stat = asn1PE_H245RedundancyEncodingMode_secondaryEncoding (pctxt, &pvalue->secondaryEncoding); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H2250ModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250ModeParameters (OOCTXT* pctxt, H245H2250ModeParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.redundancyEncodingModePresent); /* encode redundancyEncodingMode */ if (pvalue->m.redundancyEncodingModePresent) { stat = asn1PE_H245RedundancyEncodingMode (pctxt, &pvalue->redundancyEncodingMode); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultiplexedStreamModeParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexedStreamModeParameters (OOCTXT* pctxt, H245MultiplexedStreamModeParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ModeElement */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ModeElement (OOCTXT* pctxt, H245ModeElement* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.v76ModeParametersPresent || pvalue->m.h2250ModeParametersPresent || pvalue->m.genericModeParametersPresent || pvalue->m.multiplexedStreamModeParametersPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h223ModeParametersPresent); /* encode type */ stat = asn1PE_H245ModeElementType (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; /* encode h223ModeParameters */ if (pvalue->m.h223ModeParametersPresent) { stat = asn1PE_H245H223ModeParameters (pctxt, &pvalue->h223ModeParameters); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 3); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.v76ModeParametersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.h2250ModeParametersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.genericModeParametersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multiplexedStreamModeParametersPresent); /* encode extension elements */ if (pvalue->m.v76ModeParametersPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245V76ModeParameters (&lctxt, &pvalue->v76ModeParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.h2250ModeParametersPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245H2250ModeParameters (&lctxt, &pvalue->h2250ModeParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.genericModeParametersPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245GenericCapability (&lctxt, &pvalue->genericModeParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.multiplexedStreamModeParametersPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245MultiplexedStreamModeParameters (&lctxt, &pvalue->multiplexedStreamModeParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* ModeDescription */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ModeDescription (OOCTXT* pctxt, H245ModeDescription* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245ModeElement (pctxt, ((H245ModeElement*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* RequestMode_requestedModes */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMode_requestedModes (OOCTXT* pctxt, H245RequestMode_requestedModes* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245ModeDescription (pctxt, ((H245ModeDescription*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* RequestMode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMode (OOCTXT* pctxt, H245RequestMode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode requestedModes */ stat = asn1PE_H245RequestMode_requestedModes (pctxt, &pvalue->requestedModes); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RoundTripDelayRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RoundTripDelayRequest (OOCTXT* pctxt, H245RoundTripDelayRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopRequest_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopRequest_type (OOCTXT* pctxt, H245MaintenanceLoopRequest_type* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* systemLoop */ case 1: /* NULL */ break; /* mediaLoop */ case 2: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.mediaLoop); if (stat != ASN_OK) return stat; break; /* logicalChannelLoop */ case 3: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.logicalChannelLoop); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopRequest (OOCTXT* pctxt, H245MaintenanceLoopRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245MaintenanceLoopRequest_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CommunicationModeRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommunicationModeRequest (OOCTXT* pctxt, H245CommunicationModeRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* Criteria */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Criteria (OOCTXT* pctxt, H245Criteria* pvalue) { static Asn1SizeCnst value_lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode field */ stat = encodeObjectIdentifier (pctxt, &pvalue->field); if (stat != ASN_OK) return stat; /* encode value */ addSizeConstraint (pctxt, &value_lsize1); stat = encodeOctetString (pctxt, pvalue->value.numocts, pvalue->value.data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CertSelectionCriteria */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CertSelectionCriteria (OOCTXT* pctxt, H245CertSelectionCriteria* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245Criteria (pctxt, ((H245Criteria*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* ConferenceRequest_requestTerminalCertificate */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceRequest_requestTerminalCertificate (OOCTXT* pctxt, H245ConferenceRequest_requestTerminalCertificate* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalLabelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.certSelectionCriteriaPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sRandomPresent); /* encode terminalLabel */ if (pvalue->m.terminalLabelPresent) { stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; } /* encode certSelectionCriteria */ if (pvalue->m.certSelectionCriteriaPresent) { stat = asn1PE_H245CertSelectionCriteria (pctxt, &pvalue->certSelectionCriteria); if (stat != ASN_OK) return stat; } /* encode sRandom */ if (pvalue->m.sRandomPresent) { stat = encodeConsUnsigned (pctxt, pvalue->sRandom, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RemoteMCRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RemoteMCRequest (OOCTXT* pctxt, H245RemoteMCRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* masterActivate */ case 1: /* NULL */ break; /* slaveActivate */ case 2: /* NULL */ break; /* deActivate */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ConferenceRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceRequest (OOCTXT* pctxt, H245ConferenceRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 8); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 7); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* terminalListRequest */ case 1: /* NULL */ break; /* makeMeChair */ case 2: /* NULL */ break; /* cancelMakeMeChair */ case 3: /* NULL */ break; /* dropTerminal */ case 4: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.dropTerminal); if (stat != ASN_OK) return stat; break; /* requestTerminalID */ case 5: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.requestTerminalID); if (stat != ASN_OK) return stat; break; /* enterH243Password */ case 6: /* NULL */ break; /* enterH243TerminalID */ case 7: /* NULL */ break; /* enterH243ConferenceID */ case 8: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 9); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* enterExtensionAddress */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* requestChairTokenOwner */ case 10: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* requestTerminalCertificate */ case 11: stat = asn1PE_H245ConferenceRequest_requestTerminalCertificate (&lctxt, pvalue->u.requestTerminalCertificate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* broadcastMyLogicalChannel */ case 12: stat = asn1PE_H245LogicalChannelNumber (&lctxt, pvalue->u.broadcastMyLogicalChannel); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* makeTerminalBroadcaster */ case 13: stat = asn1PE_H245TerminalLabel (&lctxt, pvalue->u.makeTerminalBroadcaster); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* sendThisSource */ case 14: stat = asn1PE_H245TerminalLabel (&lctxt, pvalue->u.sendThisSource); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* requestAllTerminalIDs */ case 15: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* remoteMCRequest */ case 16: stat = asn1PE_H245RemoteMCRequest (&lctxt, pvalue->u.remoteMCRequest); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_callInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkRequest_callInformation (OOCTXT* pctxt, H245MultilinkRequest_callInformation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode maxNumberOfAdditionalConnections */ stat = encodeConsUnsigned (pctxt, pvalue->maxNumberOfAdditionalConnections, 1U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DialingInformationNetworkType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DialingInformationNetworkType (OOCTXT* pctxt, H245DialingInformationNetworkType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* n_isdn */ case 2: /* NULL */ break; /* gstn */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* mobile */ case 4: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* DialingInformationNumber_networkType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DialingInformationNumber_networkType (OOCTXT* pctxt, H245DialingInformationNumber_networkType* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 255, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245DialingInformationNetworkType (pctxt, ((H245DialingInformationNetworkType*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* DialingInformationNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DialingInformationNumber (OOCTXT* pctxt, H245DialingInformationNumber* pvalue) { static Asn1SizeCnst networkAddress_lsize1 = { 0, 0, 40, 0 }; static Asn1SizeCnst subAddress_lsize1 = { 0, 1, 40, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.subAddressPresent); /* encode networkAddress */ addSizeConstraint (pctxt, &networkAddress_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->networkAddress, NUM_CANSET, 4, 4, 4); if (stat != ASN_OK) return stat; /* encode subAddress */ if (pvalue->m.subAddressPresent) { addSizeConstraint (pctxt, &subAddress_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->subAddress, 0, 8, 7, 7); if (stat != ASN_OK) return stat; } /* encode networkType */ stat = asn1PE_H245DialingInformationNumber_networkType (pctxt, &pvalue->networkType); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* DialingInformation_differential */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DialingInformation_differential (OOCTXT* pctxt, H245DialingInformation_differential* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245DialingInformationNumber (pctxt, ((H245DialingInformationNumber*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* DialingInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H245DialingInformation (OOCTXT* pctxt, H245DialingInformation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* differential */ case 2: stat = asn1PE_H245DialingInformation_differential (pctxt, pvalue->u.differential); if (stat != ASN_OK) return stat; break; /* infoNotAvailable */ case 3: stat = encodeConsUnsigned (pctxt, pvalue->u.infoNotAvailable, 1U, 65535U); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_addConnection */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkRequest_addConnection (OOCTXT* pctxt, H245MultilinkRequest_addConnection* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode dialingInformation */ stat = asn1PE_H245DialingInformation (pctxt, &pvalue->dialingInformation); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConnectionIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConnectionIdentifier (OOCTXT* pctxt, H245ConnectionIdentifier* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode channelTag */ stat = encodeConsUnsigned (pctxt, pvalue->channelTag, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; /* encode sequenceNumber */ stat = encodeConsUnsigned (pctxt, pvalue->sequenceNumber, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_removeConnection */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkRequest_removeConnection (OOCTXT* pctxt, H245MultilinkRequest_removeConnection* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode connectionIdentifier */ stat = asn1PE_H245ConnectionIdentifier (pctxt, &pvalue->connectionIdentifier); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_maximumHeaderInterval_requestType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkRequest_maximumHeaderInterval_requestType (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval_requestType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* currentIntervalInformation */ case 1: /* NULL */ break; /* requestedInterval */ case 2: stat = encodeConsUnsigned (pctxt, pvalue->u.requestedInterval, 0U, 65535U); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MultilinkRequest_maximumHeaderInterval */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkRequest_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkRequest_maximumHeaderInterval* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode requestType */ stat = asn1PE_H245MultilinkRequest_maximumHeaderInterval_requestType (pctxt, &pvalue->requestType); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkRequest (OOCTXT* pctxt, H245MultilinkRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* callInformation */ case 2: stat = asn1PE_H245MultilinkRequest_callInformation (pctxt, pvalue->u.callInformation); if (stat != ASN_OK) return stat; break; /* addConnection */ case 3: stat = asn1PE_H245MultilinkRequest_addConnection (pctxt, pvalue->u.addConnection); if (stat != ASN_OK) return stat; break; /* removeConnection */ case 4: stat = asn1PE_H245MultilinkRequest_removeConnection (pctxt, pvalue->u.removeConnection); if (stat != ASN_OK) return stat; break; /* maximumHeaderInterval */ case 5: stat = asn1PE_H245MultilinkRequest_maximumHeaderInterval (pctxt, pvalue->u.maximumHeaderInterval); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MaximumBitRate */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaximumBitRate (OOCTXT* pctxt, H245MaximumBitRate value) { int stat = ASN_OK; stat = encodeConsUnsigned (pctxt, value, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245LogicalChannelRateRequest (OOCTXT* pctxt, H245LogicalChannelRateRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; /* encode maximumBitRate */ stat = asn1PE_H245MaximumBitRate (pctxt, pvalue->maximumBitRate); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMessage (OOCTXT* pctxt, H245RequestMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 11); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 10); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* masterSlaveDetermination */ case 2: stat = asn1PE_H245MasterSlaveDetermination (pctxt, pvalue->u.masterSlaveDetermination); if (stat != ASN_OK) return stat; break; /* terminalCapabilitySet */ case 3: stat = asn1PE_H245TerminalCapabilitySet (pctxt, pvalue->u.terminalCapabilitySet); if (stat != ASN_OK) return stat; break; /* openLogicalChannel */ case 4: stat = asn1PE_H245OpenLogicalChannel (pctxt, pvalue->u.openLogicalChannel); if (stat != ASN_OK) return stat; break; /* closeLogicalChannel */ case 5: stat = asn1PE_H245CloseLogicalChannel (pctxt, pvalue->u.closeLogicalChannel); if (stat != ASN_OK) return stat; break; /* requestChannelClose */ case 6: stat = asn1PE_H245RequestChannelClose (pctxt, pvalue->u.requestChannelClose); if (stat != ASN_OK) return stat; break; /* multiplexEntrySend */ case 7: stat = asn1PE_H245MultiplexEntrySend (pctxt, pvalue->u.multiplexEntrySend); if (stat != ASN_OK) return stat; break; /* requestMultiplexEntry */ case 8: stat = asn1PE_H245RequestMultiplexEntry (pctxt, pvalue->u.requestMultiplexEntry); if (stat != ASN_OK) return stat; break; /* requestMode */ case 9: stat = asn1PE_H245RequestMode (pctxt, pvalue->u.requestMode); if (stat != ASN_OK) return stat; break; /* roundTripDelayRequest */ case 10: stat = asn1PE_H245RoundTripDelayRequest (pctxt, pvalue->u.roundTripDelayRequest); if (stat != ASN_OK) return stat; break; /* maintenanceLoopRequest */ case 11: stat = asn1PE_H245MaintenanceLoopRequest (pctxt, pvalue->u.maintenanceLoopRequest); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 12); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* communicationModeRequest */ case 12: stat = asn1PE_H245CommunicationModeRequest (&lctxt, pvalue->u.communicationModeRequest); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* conferenceRequest */ case 13: stat = asn1PE_H245ConferenceRequest (&lctxt, pvalue->u.conferenceRequest); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multilinkRequest */ case 14: stat = asn1PE_H245MultilinkRequest (&lctxt, pvalue->u.multilinkRequest); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* logicalChannelRateRequest */ case 15: stat = asn1PE_H245LogicalChannelRateRequest (&lctxt, pvalue->u.logicalChannelRateRequest); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationAck_decision */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MasterSlaveDeterminationAck_decision (OOCTXT* pctxt, H245MasterSlaveDeterminationAck_decision* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* master */ case 1: /* NULL */ break; /* slave */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MasterSlaveDeterminationAck (OOCTXT* pctxt, H245MasterSlaveDeterminationAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode decision */ stat = asn1PE_H245MasterSlaveDeterminationAck_decision (pctxt, &pvalue->decision); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MasterSlaveDeterminationReject_cause (OOCTXT* pctxt, H245MasterSlaveDeterminationReject_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* identicalNumbers */ case 1: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MasterSlaveDeterminationReject (OOCTXT* pctxt, H245MasterSlaveDeterminationReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode cause */ stat = asn1PE_H245MasterSlaveDeterminationReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySetAck (OOCTXT* pctxt, H245TerminalCapabilitySetAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetReject_cause_tableEntryCapacityExce */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* highestEntryNumberProcessed */ case 1: stat = asn1PE_H245CapabilityTableEntryNumber (pctxt, pvalue->u.highestEntryNumberProcessed); if (stat != ASN_OK) return stat; break; /* noneProcessed */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySetReject_cause (OOCTXT* pctxt, H245TerminalCapabilitySetReject_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unspecified */ case 1: /* NULL */ break; /* undefinedTableEntryUsed */ case 2: /* NULL */ break; /* descriptorCapacityExceeded */ case 3: /* NULL */ break; /* tableEntryCapacityExceeded */ case 4: stat = asn1PE_H245TerminalCapabilitySetReject_cause_tableEntryCapacityExceeded (pctxt, pvalue->u.tableEntryCapacityExceeded); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySetReject (OOCTXT* pctxt, H245TerminalCapabilitySetReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode cause */ stat = asn1PE_H245TerminalCapabilitySetReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck_reverseLogicalChannelParameters_mu */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* h222LogicalChannelParameters */ case 1: stat = asn1PE_H245H222LogicalChannelParameters (pctxt, pvalue->u.h222LogicalChannelParameters); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* h2250LogicalChannelParameters */ case 2: stat = asn1PE_H245H2250LogicalChannelParameters (&lctxt, pvalue->u.h2250LogicalChannelParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck_reverseLogicalChannelParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannelAck_reverseLogicalChannelParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_reverseLogicalChannelParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.replacementForPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.portNumberPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.multiplexParametersPresent); /* encode reverseLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->reverseLogicalChannelNumber); if (stat != ASN_OK) return stat; /* encode portNumber */ if (pvalue->m.portNumberPresent) { stat = encodeConsUnsigned (pctxt, pvalue->portNumber, 0U, 65535U); if (stat != ASN_OK) return stat; } /* encode multiplexParameters */ if (pvalue->m.multiplexParametersPresent) { stat = asn1PE_H245OpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters (pctxt, &pvalue->multiplexParameters); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.replacementForPresent); /* encode extension elements */ if (pvalue->m.replacementForPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245LogicalChannelNumber (&lctxt, pvalue->replacementFor); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* H2250LogicalChannelAckParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250LogicalChannelAckParameters (OOCTXT* pctxt, H245H2250LogicalChannelAckParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.flowControlToZeroPresent || pvalue->m.portNumberPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sessionIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaChannelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaControlChannelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.dynamicRTPPayloadTypePresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } /* encode sessionID */ if (pvalue->m.sessionIDPresent) { stat = encodeConsUnsigned (pctxt, pvalue->sessionID, 1U, 255U); if (stat != ASN_OK) return stat; } /* encode mediaChannel */ if (pvalue->m.mediaChannelPresent) { stat = asn1PE_H245TransportAddress (pctxt, &pvalue->mediaChannel); if (stat != ASN_OK) return stat; } /* encode mediaControlChannel */ if (pvalue->m.mediaControlChannelPresent) { stat = asn1PE_H245TransportAddress (pctxt, &pvalue->mediaControlChannel); if (stat != ASN_OK) return stat; } /* encode dynamicRTPPayloadType */ if (pvalue->m.dynamicRTPPayloadTypePresent) { stat = encodeConsUnsigned (pctxt, pvalue->dynamicRTPPayloadType, 96U, 127U); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 1); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.flowControlToZeroPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.portNumberPresent); /* encode extension elements */ if (pvalue->m.flowControlToZeroPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeBit (&lctxt, (ASN1BOOL)pvalue->flowControlToZero); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.portNumberPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->portNumber, 0U, 65535U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck_forwardMultiplexAckParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannelAck_forwardMultiplexAckParameters (OOCTXT* pctxt, H245OpenLogicalChannelAck_forwardMultiplexAckParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* h2250LogicalChannelAckParameters */ case 1: stat = asn1PE_H245H2250LogicalChannelAckParameters (pctxt, pvalue->u.h2250LogicalChannelAckParameters); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannelAck (OOCTXT* pctxt, H245OpenLogicalChannelAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.separateStackPresent || pvalue->m.forwardMultiplexAckParametersPresent || pvalue->m.encryptionSyncPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.reverseLogicalChannelParametersPresent); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; /* encode reverseLogicalChannelParameters */ if (pvalue->m.reverseLogicalChannelParametersPresent) { stat = asn1PE_H245OpenLogicalChannelAck_reverseLogicalChannelParameters (pctxt, &pvalue->reverseLogicalChannelParameters); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 2); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.separateStackPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.forwardMultiplexAckParametersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.encryptionSyncPresent); /* encode extension elements */ if (pvalue->m.separateStackPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245NetworkAccessParameters (&lctxt, &pvalue->separateStack); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.forwardMultiplexAckParametersPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245OpenLogicalChannelAck_forwardMultiplexAckParameters (&lctxt, &pvalue->forwardMultiplexAckParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.encryptionSyncPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245EncryptionSync (&lctxt, &pvalue->encryptionSync); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannelReject_cause (OOCTXT* pctxt, H245OpenLogicalChannelReject_cause* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 6); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 5); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unspecified */ case 1: /* NULL */ break; /* unsuitableReverseParameters */ case 2: /* NULL */ break; /* dataTypeNotSupported */ case 3: /* NULL */ break; /* dataTypeNotAvailable */ case 4: /* NULL */ break; /* unknownDataType */ case 5: /* NULL */ break; /* dataTypeALCombinationNotSupported */ case 6: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 7); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* multicastChannelNotAllowed */ case 7: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* insufficientBandwidth */ case 8: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* separateStackEstablishmentFailed */ case 9: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* invalidSessionID */ case 10: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* masterSlaveConflict */ case 11: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* waitForCommunicationMode */ case 12: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* invalidDependentChannel */ case 13: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* replacementForRejected */ case 14: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannelReject (OOCTXT* pctxt, H245OpenLogicalChannelReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; /* encode cause */ stat = asn1PE_H245OpenLogicalChannelReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CloseLogicalChannelAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CloseLogicalChannelAck (OOCTXT* pctxt, H245CloseLogicalChannelAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestChannelCloseAck (OOCTXT* pctxt, H245RequestChannelCloseAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestChannelCloseReject_cause (OOCTXT* pctxt, H245RequestChannelCloseReject_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unspecified */ case 1: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestChannelCloseReject (OOCTXT* pctxt, H245RequestChannelCloseReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; /* encode cause */ stat = asn1PE_H245RequestChannelCloseReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendAck_multiplexTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySendAck_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendAck_multiplexTableEntryNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySendAck (OOCTXT* pctxt, H245MultiplexEntrySendAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode multiplexTableEntryNumber */ stat = asn1PE_H245MultiplexEntrySendAck_multiplexTableEntryNumber (pctxt, &pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplexEntryRejectionDescriptions_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unspecifiedCause */ case 1: /* NULL */ break; /* descriptorTooComplex */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MultiplexEntryRejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntryRejectionDescriptions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode multiplexTableEntryNumber */ stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; /* encode cause */ stat = asn1PE_H245MultiplexEntryRejectionDescriptions_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendReject_rejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySendReject_rejectionDescriptions (OOCTXT* pctxt, H245MultiplexEntrySendReject_rejectionDescriptions* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245MultiplexEntryRejectionDescriptions (pctxt, ((H245MultiplexEntryRejectionDescriptions*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySendReject (OOCTXT* pctxt, H245MultiplexEntrySendReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode rejectionDescriptions */ stat = asn1PE_H245MultiplexEntrySendReject_rejectionDescriptions (pctxt, &pvalue->rejectionDescriptions); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryAck_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryAck_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryAck_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryAck (OOCTXT* pctxt, H245RequestMultiplexEntryAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode entryNumbers */ stat = asn1PE_H245RequestMultiplexEntryAck_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryReject_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryReject_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryReject_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRejectionDescriptions_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryRejectionDescriptions_cause (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unspecifiedCause */ case 1: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryRejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryRejectionDescriptions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode multiplexTableEntryNumber */ stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; /* encode cause */ stat = asn1PE_H245RequestMultiplexEntryRejectionDescriptions_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryReject_rejectionDescriptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryReject_rejectionDescriptions (OOCTXT* pctxt, H245RequestMultiplexEntryReject_rejectionDescriptions* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245RequestMultiplexEntryRejectionDescriptions (pctxt, ((H245RequestMultiplexEntryRejectionDescriptions*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryReject (OOCTXT* pctxt, H245RequestMultiplexEntryReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode entryNumbers */ stat = asn1PE_H245RequestMultiplexEntryReject_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; /* encode rejectionDescriptions */ stat = asn1PE_H245RequestMultiplexEntryReject_rejectionDescriptions (pctxt, &pvalue->rejectionDescriptions); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestModeAck_response */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestModeAck_response (OOCTXT* pctxt, H245RequestModeAck_response* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* willTransmitMostPreferredMode */ case 1: /* NULL */ break; /* willTransmitLessPreferredMode */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RequestModeAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestModeAck (OOCTXT* pctxt, H245RequestModeAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode response */ stat = asn1PE_H245RequestModeAck_response (pctxt, &pvalue->response); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestModeReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestModeReject_cause (OOCTXT* pctxt, H245RequestModeReject_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* modeUnavailable */ case 1: /* NULL */ break; /* multipointConstraint */ case 2: /* NULL */ break; /* requestDenied */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RequestModeReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestModeReject (OOCTXT* pctxt, H245RequestModeReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode cause */ stat = asn1PE_H245RequestModeReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RoundTripDelayResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RoundTripDelayResponse (OOCTXT* pctxt, H245RoundTripDelayResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopAck_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopAck_type (OOCTXT* pctxt, H245MaintenanceLoopAck_type* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* systemLoop */ case 1: /* NULL */ break; /* mediaLoop */ case 2: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.mediaLoop); if (stat != ASN_OK) return stat; break; /* logicalChannelLoop */ case 3: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.logicalChannelLoop); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopAck */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopAck (OOCTXT* pctxt, H245MaintenanceLoopAck* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245MaintenanceLoopAck_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopReject_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopReject_type (OOCTXT* pctxt, H245MaintenanceLoopReject_type* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* systemLoop */ case 1: /* NULL */ break; /* mediaLoop */ case 2: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.mediaLoop); if (stat != ASN_OK) return stat; break; /* logicalChannelLoop */ case 3: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.logicalChannelLoop); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopReject_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopReject_cause (OOCTXT* pctxt, H245MaintenanceLoopReject_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* canNotPerformLoop */ case 1: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopReject (OOCTXT* pctxt, H245MaintenanceLoopReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode type */ stat = asn1PE_H245MaintenanceLoopReject_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; /* encode cause */ stat = asn1PE_H245MaintenanceLoopReject_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CommunicationModeTableEntry_dataType */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommunicationModeTableEntry_dataType (OOCTXT* pctxt, H245CommunicationModeTableEntry_dataType* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* videoData */ case 1: stat = asn1PE_H245VideoCapability (pctxt, pvalue->u.videoData); if (stat != ASN_OK) return stat; break; /* audioData */ case 2: stat = asn1PE_H245AudioCapability (pctxt, pvalue->u.audioData); if (stat != ASN_OK) return stat; break; /* data */ case 3: stat = asn1PE_H245DataApplicationCapability (pctxt, pvalue->u.data); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* CommunicationModeTableEntry */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommunicationModeTableEntry (OOCTXT* pctxt, H245CommunicationModeTableEntry* pvalue) { static Asn1SizeCnst sessionDescription_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.redundancyEncodingPresent || pvalue->m.sessionDependencyPresent || pvalue->m.destinationPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.nonStandardPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.associatedSessionIDPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalLabelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaChannelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaGuaranteedDeliveryPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaControlChannelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.mediaControlGuaranteedDeliveryPresent); /* encode nonStandard */ if (pvalue->m.nonStandardPresent) { stat = asn1PE_H245_SeqOfH245NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; } /* encode sessionID */ stat = encodeConsUnsigned (pctxt, pvalue->sessionID, 1U, 255U); if (stat != ASN_OK) return stat; /* encode associatedSessionID */ if (pvalue->m.associatedSessionIDPresent) { stat = encodeConsUnsigned (pctxt, pvalue->associatedSessionID, 1U, 255U); if (stat != ASN_OK) return stat; } /* encode terminalLabel */ if (pvalue->m.terminalLabelPresent) { stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; } /* encode sessionDescription */ addSizeConstraint (pctxt, &sessionDescription_lsize1); stat = encodeBMPString (pctxt, pvalue->sessionDescription, 0); if (stat != ASN_OK) return stat; /* encode dataType */ stat = asn1PE_H245CommunicationModeTableEntry_dataType (pctxt, &pvalue->dataType); if (stat != ASN_OK) return stat; /* encode mediaChannel */ if (pvalue->m.mediaChannelPresent) { stat = asn1PE_H245TransportAddress (pctxt, &pvalue->mediaChannel); if (stat != ASN_OK) return stat; } /* encode mediaGuaranteedDelivery */ if (pvalue->m.mediaGuaranteedDeliveryPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->mediaGuaranteedDelivery); if (stat != ASN_OK) return stat; } /* encode mediaControlChannel */ if (pvalue->m.mediaControlChannelPresent) { stat = asn1PE_H245TransportAddress (pctxt, &pvalue->mediaControlChannel); if (stat != ASN_OK) return stat; } /* encode mediaControlGuaranteedDelivery */ if (pvalue->m.mediaControlGuaranteedDeliveryPresent) { stat = encodeBit (pctxt, (ASN1BOOL)pvalue->mediaControlGuaranteedDelivery); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 2); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.redundancyEncodingPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.sessionDependencyPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.destinationPresent); /* encode extension elements */ if (pvalue->m.redundancyEncodingPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245RedundancyEncoding (&lctxt, &pvalue->redundancyEncoding); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.sessionDependencyPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeConsUnsigned (&lctxt, pvalue->sessionDependency, 1U, 255U); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } if (pvalue->m.destinationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245TerminalLabel (&lctxt, &pvalue->destination); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* CommunicationModeResponse_communicationModeTable */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommunicationModeResponse_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeResponse_communicationModeTable* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CommunicationModeTableEntry (pctxt, ((H245CommunicationModeTableEntry*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* CommunicationModeResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommunicationModeResponse (OOCTXT* pctxt, H245CommunicationModeResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 1); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 0); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* communicationModeTable */ case 1: stat = asn1PE_H245CommunicationModeResponse_communicationModeTable (pctxt, pvalue->u.communicationModeTable); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 2); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TerminalID */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalID (OOCTXT* pctxt, H245TerminalID* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_mCTerminalIDResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_mCTerminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_mCTerminalIDResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalLabel */ stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; /* encode terminalID */ stat = asn1PE_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_terminalIDResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_terminalIDResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalIDResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalLabel */ stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; /* encode terminalID */ stat = asn1PE_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceID */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceID (OOCTXT* pctxt, H245ConferenceID* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_conferenceIDResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_conferenceIDResponse (OOCTXT* pctxt, H245ConferenceResponse_conferenceIDResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalLabel */ stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; /* encode conferenceID */ stat = asn1PE_H245ConferenceID (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* Password */ /* */ /**************************************************************/ EXTERN int asn1PE_H245Password (OOCTXT* pctxt, H245Password* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_passwordResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_passwordResponse (OOCTXT* pctxt, H245ConferenceResponse_passwordResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalLabel */ stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; /* encode password */ stat = asn1PE_H245Password (pctxt, &pvalue->password); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_terminalListResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_terminalListResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalListResponse* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245TerminalLabel (pctxt, ((H245TerminalLabel*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_makeMeChairResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_makeMeChairResponse (OOCTXT* pctxt, H245ConferenceResponse_makeMeChairResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* grantedChairToken */ case 1: /* NULL */ break; /* deniedChairToken */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_extensionAddressResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_extensionAddressResponse (OOCTXT* pctxt, H245ConferenceResponse_extensionAddressResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode extensionAddress */ stat = asn1PE_H245TerminalID (pctxt, &pvalue->extensionAddress); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_chairTokenOwnerResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_chairTokenOwnerResponse (OOCTXT* pctxt, H245ConferenceResponse_chairTokenOwnerResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalLabel */ stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; /* encode terminalID */ stat = asn1PE_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_terminalCertificateResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_terminalCertificateResponse (OOCTXT* pctxt, H245ConferenceResponse_terminalCertificateResponse* pvalue) { static Asn1SizeCnst certificateResponse_lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.terminalLabelPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.certificateResponsePresent); /* encode terminalLabel */ if (pvalue->m.terminalLabelPresent) { stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; } /* encode certificateResponse */ if (pvalue->m.certificateResponsePresent) { addSizeConstraint (pctxt, &certificateResponse_lsize1); stat = encodeOctetString (pctxt, pvalue->certificateResponse.numocts, pvalue->certificateResponse.data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_broadcastMyLogicalChannelResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_broadcastMyLogicalChannelResponse (OOCTXT* pctxt, H245ConferenceResponse_broadcastMyLogicalChannelResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* grantedBroadcastMyLogicalChannel */ case 1: /* NULL */ break; /* deniedBroadcastMyLogicalChannel */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_makeTerminalBroadcasterResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_makeTerminalBroadcasterResponse (OOCTXT* pctxt, H245ConferenceResponse_makeTerminalBroadcasterResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* grantedMakeTerminalBroadcaster */ case 1: /* NULL */ break; /* deniedMakeTerminalBroadcaster */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse_sendThisSourceResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse_sendThisSourceResponse (OOCTXT* pctxt, H245ConferenceResponse_sendThisSourceResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* grantedSendThisSource */ case 1: /* NULL */ break; /* deniedSendThisSource */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* TerminalInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalInformation (OOCTXT* pctxt, H245TerminalInformation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalLabel */ stat = asn1PE_H245TerminalLabel (pctxt, &pvalue->terminalLabel); if (stat != ASN_OK) return stat; /* encode terminalID */ stat = asn1PE_H245TerminalID (pctxt, &pvalue->terminalID); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* _SeqOfH245TerminalInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245TerminalInformation (OOCTXT* pctxt, H245_SeqOfH245TerminalInformation* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245TerminalInformation (pctxt, ((H245TerminalInformation*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* RequestAllTerminalIDsResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestAllTerminalIDsResponse (OOCTXT* pctxt, H245RequestAllTerminalIDsResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalInformation */ stat = asn1PE_H245_SeqOfH245TerminalInformation (pctxt, &pvalue->terminalInformation); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RemoteMCResponse_reject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RemoteMCResponse_reject (OOCTXT* pctxt, H245RemoteMCResponse_reject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* unspecified */ case 1: /* NULL */ break; /* functionNotSupported */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* RemoteMCResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RemoteMCResponse (OOCTXT* pctxt, H245RemoteMCResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* accept */ case 1: /* NULL */ break; /* reject */ case 2: stat = asn1PE_H245RemoteMCResponse_reject (pctxt, pvalue->u.reject); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* ConferenceResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceResponse (OOCTXT* pctxt, H245ConferenceResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 8); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 7); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* mCTerminalIDResponse */ case 1: stat = asn1PE_H245ConferenceResponse_mCTerminalIDResponse (pctxt, pvalue->u.mCTerminalIDResponse); if (stat != ASN_OK) return stat; break; /* terminalIDResponse */ case 2: stat = asn1PE_H245ConferenceResponse_terminalIDResponse (pctxt, pvalue->u.terminalIDResponse); if (stat != ASN_OK) return stat; break; /* conferenceIDResponse */ case 3: stat = asn1PE_H245ConferenceResponse_conferenceIDResponse (pctxt, pvalue->u.conferenceIDResponse); if (stat != ASN_OK) return stat; break; /* passwordResponse */ case 4: stat = asn1PE_H245ConferenceResponse_passwordResponse (pctxt, pvalue->u.passwordResponse); if (stat != ASN_OK) return stat; break; /* terminalListResponse */ case 5: stat = asn1PE_H245ConferenceResponse_terminalListResponse (pctxt, pvalue->u.terminalListResponse); if (stat != ASN_OK) return stat; break; /* videoCommandReject */ case 6: /* NULL */ break; /* terminalDropReject */ case 7: /* NULL */ break; /* makeMeChairResponse */ case 8: stat = asn1PE_H245ConferenceResponse_makeMeChairResponse (pctxt, pvalue->u.makeMeChairResponse); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 9); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* extensionAddressResponse */ case 9: stat = asn1PE_H245ConferenceResponse_extensionAddressResponse (&lctxt, pvalue->u.extensionAddressResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* chairTokenOwnerResponse */ case 10: stat = asn1PE_H245ConferenceResponse_chairTokenOwnerResponse (&lctxt, pvalue->u.chairTokenOwnerResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* terminalCertificateResponse */ case 11: stat = asn1PE_H245ConferenceResponse_terminalCertificateResponse (&lctxt, pvalue->u.terminalCertificateResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* broadcastMyLogicalChannelResponse */ case 12: stat = asn1PE_H245ConferenceResponse_broadcastMyLogicalChannelResponse (&lctxt, pvalue->u.broadcastMyLogicalChannelResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* makeTerminalBroadcasterResponse */ case 13: stat = asn1PE_H245ConferenceResponse_makeTerminalBroadcasterResponse (&lctxt, pvalue->u.makeTerminalBroadcasterResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* sendThisSourceResponse */ case 14: stat = asn1PE_H245ConferenceResponse_sendThisSourceResponse (&lctxt, pvalue->u.sendThisSourceResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* requestAllTerminalIDsResponse */ case 15: stat = asn1PE_H245RequestAllTerminalIDsResponse (&lctxt, pvalue->u.requestAllTerminalIDsResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* remoteMCResponse */ case 16: stat = asn1PE_H245RemoteMCResponse (&lctxt, pvalue->u.remoteMCResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_callInformation */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkResponse_callInformation (OOCTXT* pctxt, H245MultilinkResponse_callInformation* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode dialingInformation */ stat = asn1PE_H245DialingInformation (pctxt, &pvalue->dialingInformation); if (stat != ASN_OK) return stat; /* encode callAssociationNumber */ stat = encodeConsUnsigned (pctxt, pvalue->callAssociationNumber, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_addConnection_responseCode_rejected */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkResponse_addConnection_responseCode_rejected (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode_rejected* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* connectionsNotAvailable */ case 1: /* NULL */ break; /* userRejected */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_addConnection_responseCode */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkResponse_addConnection_responseCode (OOCTXT* pctxt, H245MultilinkResponse_addConnection_responseCode* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* accepted */ case 1: /* NULL */ break; /* rejected */ case 2: stat = asn1PE_H245MultilinkResponse_addConnection_responseCode_rejected (pctxt, pvalue->u.rejected); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_addConnection */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkResponse_addConnection (OOCTXT* pctxt, H245MultilinkResponse_addConnection* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode responseCode */ stat = asn1PE_H245MultilinkResponse_addConnection_responseCode (pctxt, &pvalue->responseCode); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_removeConnection */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkResponse_removeConnection (OOCTXT* pctxt, H245MultilinkResponse_removeConnection* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode connectionIdentifier */ stat = asn1PE_H245ConnectionIdentifier (pctxt, &pvalue->connectionIdentifier); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkResponse_maximumHeaderInterval */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkResponse_maximumHeaderInterval (OOCTXT* pctxt, H245MultilinkResponse_maximumHeaderInterval* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode currentInterval */ stat = encodeConsUnsigned (pctxt, pvalue->currentInterval, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkResponse */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkResponse (OOCTXT* pctxt, H245MultilinkResponse* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* callInformation */ case 2: stat = asn1PE_H245MultilinkResponse_callInformation (pctxt, pvalue->u.callInformation); if (stat != ASN_OK) return stat; break; /* addConnection */ case 3: stat = asn1PE_H245MultilinkResponse_addConnection (pctxt, pvalue->u.addConnection); if (stat != ASN_OK) return stat; break; /* removeConnection */ case 4: stat = asn1PE_H245MultilinkResponse_removeConnection (pctxt, pvalue->u.removeConnection); if (stat != ASN_OK) return stat; break; /* maximumHeaderInterval */ case 5: stat = asn1PE_H245MultilinkResponse_maximumHeaderInterval (pctxt, pvalue->u.maximumHeaderInterval); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateAcknowledge */ /* */ /**************************************************************/ EXTERN int asn1PE_H245LogicalChannelRateAcknowledge (OOCTXT* pctxt, H245LogicalChannelRateAcknowledge* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; /* encode maximumBitRate */ stat = asn1PE_H245MaximumBitRate (pctxt, pvalue->maximumBitRate); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PE_H245LogicalChannelRateRejectReason (OOCTXT* pctxt, H245LogicalChannelRateRejectReason* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* undefinedReason */ case 1: /* NULL */ break; /* insufficientResources */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateReject */ /* */ /**************************************************************/ EXTERN int asn1PE_H245LogicalChannelRateReject (OOCTXT* pctxt, H245LogicalChannelRateReject* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.currentMaximumBitRatePresent); /* encode sequenceNumber */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->sequenceNumber); if (stat != ASN_OK) return stat; /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; /* encode rejectReason */ stat = asn1PE_H245LogicalChannelRateRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; /* encode currentMaximumBitRate */ if (pvalue->m.currentMaximumBitRatePresent) { stat = asn1PE_H245MaximumBitRate (pctxt, pvalue->currentMaximumBitRate); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ResponseMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ResponseMessage (OOCTXT* pctxt, H245ResponseMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 19); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 18); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* masterSlaveDeterminationAck */ case 2: stat = asn1PE_H245MasterSlaveDeterminationAck (pctxt, pvalue->u.masterSlaveDeterminationAck); if (stat != ASN_OK) return stat; break; /* masterSlaveDeterminationReject */ case 3: stat = asn1PE_H245MasterSlaveDeterminationReject (pctxt, pvalue->u.masterSlaveDeterminationReject); if (stat != ASN_OK) return stat; break; /* terminalCapabilitySetAck */ case 4: stat = asn1PE_H245TerminalCapabilitySetAck (pctxt, pvalue->u.terminalCapabilitySetAck); if (stat != ASN_OK) return stat; break; /* terminalCapabilitySetReject */ case 5: stat = asn1PE_H245TerminalCapabilitySetReject (pctxt, pvalue->u.terminalCapabilitySetReject); if (stat != ASN_OK) return stat; break; /* openLogicalChannelAck */ case 6: stat = asn1PE_H245OpenLogicalChannelAck (pctxt, pvalue->u.openLogicalChannelAck); if (stat != ASN_OK) return stat; break; /* openLogicalChannelReject */ case 7: stat = asn1PE_H245OpenLogicalChannelReject (pctxt, pvalue->u.openLogicalChannelReject); if (stat != ASN_OK) return stat; break; /* closeLogicalChannelAck */ case 8: stat = asn1PE_H245CloseLogicalChannelAck (pctxt, pvalue->u.closeLogicalChannelAck); if (stat != ASN_OK) return stat; break; /* requestChannelCloseAck */ case 9: stat = asn1PE_H245RequestChannelCloseAck (pctxt, pvalue->u.requestChannelCloseAck); if (stat != ASN_OK) return stat; break; /* requestChannelCloseReject */ case 10: stat = asn1PE_H245RequestChannelCloseReject (pctxt, pvalue->u.requestChannelCloseReject); if (stat != ASN_OK) return stat; break; /* multiplexEntrySendAck */ case 11: stat = asn1PE_H245MultiplexEntrySendAck (pctxt, pvalue->u.multiplexEntrySendAck); if (stat != ASN_OK) return stat; break; /* multiplexEntrySendReject */ case 12: stat = asn1PE_H245MultiplexEntrySendReject (pctxt, pvalue->u.multiplexEntrySendReject); if (stat != ASN_OK) return stat; break; /* requestMultiplexEntryAck */ case 13: stat = asn1PE_H245RequestMultiplexEntryAck (pctxt, pvalue->u.requestMultiplexEntryAck); if (stat != ASN_OK) return stat; break; /* requestMultiplexEntryReject */ case 14: stat = asn1PE_H245RequestMultiplexEntryReject (pctxt, pvalue->u.requestMultiplexEntryReject); if (stat != ASN_OK) return stat; break; /* requestModeAck */ case 15: stat = asn1PE_H245RequestModeAck (pctxt, pvalue->u.requestModeAck); if (stat != ASN_OK) return stat; break; /* requestModeReject */ case 16: stat = asn1PE_H245RequestModeReject (pctxt, pvalue->u.requestModeReject); if (stat != ASN_OK) return stat; break; /* roundTripDelayResponse */ case 17: stat = asn1PE_H245RoundTripDelayResponse (pctxt, pvalue->u.roundTripDelayResponse); if (stat != ASN_OK) return stat; break; /* maintenanceLoopAck */ case 18: stat = asn1PE_H245MaintenanceLoopAck (pctxt, pvalue->u.maintenanceLoopAck); if (stat != ASN_OK) return stat; break; /* maintenanceLoopReject */ case 19: stat = asn1PE_H245MaintenanceLoopReject (pctxt, pvalue->u.maintenanceLoopReject); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 20); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* communicationModeResponse */ case 20: stat = asn1PE_H245CommunicationModeResponse (&lctxt, pvalue->u.communicationModeResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* conferenceResponse */ case 21: stat = asn1PE_H245ConferenceResponse (&lctxt, pvalue->u.conferenceResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multilinkResponse */ case 22: stat = asn1PE_H245MultilinkResponse (&lctxt, pvalue->u.multilinkResponse); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* logicalChannelRateAcknowledge */ case 23: stat = asn1PE_H245LogicalChannelRateAcknowledge (&lctxt, pvalue->u.logicalChannelRateAcknowledge); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* logicalChannelRateReject */ case 24: stat = asn1PE_H245LogicalChannelRateReject (&lctxt, pvalue->u.logicalChannelRateReject); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MaintenanceLoopOffCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MaintenanceLoopOffCommand (OOCTXT* pctxt, H245MaintenanceLoopOffCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest_capabilityTabl */ /* */ /**************************************************************/ EXTERN int asn1PE_H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 65535, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245CapabilityTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest_capabilityDesc */ /* */ /**************************************************************/ EXTERN int asn1PE_H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245CapabilityDescriptorNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet_specificRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245SendTerminalCapabilitySet_specificRequest (OOCTXT* pctxt, H245SendTerminalCapabilitySet_specificRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capabilityTableEntryNumbersPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.capabilityDescriptorNumbersPresent); /* encode multiplexCapability */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->multiplexCapability); if (stat != ASN_OK) return stat; /* encode capabilityTableEntryNumbers */ if (pvalue->m.capabilityTableEntryNumbersPresent) { stat = asn1PE_H245SendTerminalCapabilitySet_specificRequest_capabilityTableEntryNumbers (pctxt, &pvalue->capabilityTableEntryNumbers); if (stat != ASN_OK) return stat; } /* encode capabilityDescriptorNumbers */ if (pvalue->m.capabilityDescriptorNumbersPresent) { stat = asn1PE_H245SendTerminalCapabilitySet_specificRequest_capabilityDescriptorNumbers (pctxt, &pvalue->capabilityDescriptorNumbers); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* SendTerminalCapabilitySet */ /* */ /**************************************************************/ EXTERN int asn1PE_H245SendTerminalCapabilitySet (OOCTXT* pctxt, H245SendTerminalCapabilitySet* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* specificRequest */ case 1: stat = asn1PE_H245SendTerminalCapabilitySet_specificRequest (pctxt, pvalue->u.specificRequest); if (stat != ASN_OK) return stat; break; /* genericRequest */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* EncryptionCommand_encryptionAlgorithmID */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionCommand_encryptionAlgorithmID (OOCTXT* pctxt, H245EncryptionCommand_encryptionAlgorithmID* pvalue) { int stat = ASN_OK; /* encode h233AlgorithmIdentifier */ stat = asn1PE_H245SequenceNumber (pctxt, pvalue->h233AlgorithmIdentifier); if (stat != ASN_OK) return stat; /* encode associatedAlgorithm */ stat = asn1PE_H245NonStandardParameter (pctxt, &pvalue->associatedAlgorithm); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncryptionCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionCommand (OOCTXT* pctxt, H245EncryptionCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* encryptionSE */ case 1: stat = encodeOctetString (pctxt, pvalue->u.encryptionSE->numocts, pvalue->u.encryptionSE->data); if (stat != ASN_OK) return stat; break; /* encryptionIVRequest */ case 2: /* NULL */ break; /* encryptionAlgorithmID */ case 3: stat = asn1PE_H245EncryptionCommand_encryptionAlgorithmID (pctxt, pvalue->u.encryptionAlgorithmID); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* FlowControlCommand_scope */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FlowControlCommand_scope (OOCTXT* pctxt, H245FlowControlCommand_scope* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* logicalChannelNumber */ case 1: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.logicalChannelNumber); if (stat != ASN_OK) return stat; break; /* resourceID */ case 2: stat = encodeConsUnsigned (pctxt, pvalue->u.resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* wholeMultiplex */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlCommand_restriction */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FlowControlCommand_restriction (OOCTXT* pctxt, H245FlowControlCommand_restriction* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* maximumBitRate */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.maximumBitRate, 0U, 16777215U); if (stat != ASN_OK) return stat; break; /* noRestriction */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FlowControlCommand (OOCTXT* pctxt, H245FlowControlCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode scope */ stat = asn1PE_H245FlowControlCommand_scope (pctxt, &pvalue->scope); if (stat != ASN_OK) return stat; /* encode restriction */ stat = asn1PE_H245FlowControlCommand_restriction (pctxt, &pvalue->restriction); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EndSessionCommand_gstnOptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EndSessionCommand_gstnOptions (OOCTXT* pctxt, H245EndSessionCommand_gstnOptions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 5); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 4); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* telephonyMode */ case 1: /* NULL */ break; /* v8bis */ case 2: /* NULL */ break; /* v34DSVD */ case 3: /* NULL */ break; /* v34DuplexFAX */ case 4: /* NULL */ break; /* v34H324 */ case 5: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 6); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* EndSessionCommand_isdnOptions */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EndSessionCommand_isdnOptions (OOCTXT* pctxt, H245EndSessionCommand_isdnOptions* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* telephonyMode */ case 1: /* NULL */ break; /* v140 */ case 2: /* NULL */ break; /* terminalOnHold */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* EndSessionCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EndSessionCommand (OOCTXT* pctxt, H245EndSessionCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* disconnect */ case 2: /* NULL */ break; /* gstnOptions */ case 3: stat = asn1PE_H245EndSessionCommand_gstnOptions (pctxt, pvalue->u.gstnOptions); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* isdnOptions */ case 4: stat = asn1PE_H245EndSessionCommand_isdnOptions (&lctxt, pvalue->u.isdnOptions); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoFastUpdateGOB */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand_type_videoFastUpdateGOB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateGOB* pvalue) { int stat = ASN_OK; /* encode firstGOB */ stat = encodeConsUnsigned (pctxt, pvalue->firstGOB, 0U, 17U); if (stat != ASN_OK) return stat; /* encode numberOfGOBs */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfGOBs, 1U, 18U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoFastUpdateMB */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand_type_videoFastUpdateMB (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoFastUpdateMB* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.firstGOBPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.firstMBPresent); /* encode firstGOB */ if (pvalue->m.firstGOBPresent) { stat = encodeConsUnsigned (pctxt, pvalue->firstGOB, 0U, 255U); if (stat != ASN_OK) return stat; } /* encode firstMB */ if (pvalue->m.firstMBPresent) { stat = encodeConsUnsigned (pctxt, pvalue->firstMB, 1U, 8192U); if (stat != ASN_OK) return stat; } /* encode numberOfMBs */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfMBs, 1U, 8192U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* KeyProtectionMethod */ /* */ /**************************************************************/ EXTERN int asn1PE_H245KeyProtectionMethod (OOCTXT* pctxt, H245KeyProtectionMethod* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode secureChannel */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->secureChannel); if (stat != ASN_OK) return stat; /* encode sharedSecret */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->sharedSecret); if (stat != ASN_OK) return stat; /* encode certProtectedKey */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->certProtectedKey); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncryptionUpdateRequest */ /* */ /**************************************************************/ EXTERN int asn1PE_H245EncryptionUpdateRequest (OOCTXT* pctxt, H245EncryptionUpdateRequest* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.keyProtectionMethodPresent); /* encode keyProtectionMethod */ if (pvalue->m.keyProtectionMethodPresent) { stat = asn1PE_H245KeyProtectionMethod (pctxt, &pvalue->keyProtectionMethod); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_progressiveRefinementStart_rep */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* doOneProgression */ case 1: /* NULL */ break; /* doContinuousProgressions */ case 2: /* NULL */ break; /* doOneIndependentProgression */ case 3: /* NULL */ break; /* doContinuousIndependentProgressions */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_progressiveRefinementStart */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand_type_progressiveRefinementStart (OOCTXT* pctxt, H245MiscellaneousCommand_type_progressiveRefinementStart* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode repeatCount */ stat = asn1PE_H245MiscellaneousCommand_type_progressiveRefinementStart_repeatCount (pctxt, &pvalue->repeatCount); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_videoBadMBs */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand_type_videoBadMBs (OOCTXT* pctxt, H245MiscellaneousCommand_type_videoBadMBs* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode firstMB */ stat = encodeConsUnsigned (pctxt, pvalue->firstMB, 1U, 9216U); if (stat != ASN_OK) return stat; /* encode numberOfMBs */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfMBs, 1U, 9216U); if (stat != ASN_OK) return stat; /* encode temporalReference */ stat = encodeConsUnsigned (pctxt, pvalue->temporalReference, 0U, 1023U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* PictureReference */ /* */ /**************************************************************/ EXTERN int asn1PE_H245PictureReference (OOCTXT* pctxt, H245PictureReference* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* pictureNumber */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.pictureNumber, 0U, 1023U); if (stat != ASN_OK) return stat; break; /* longTermPictureIndex */ case 2: stat = encodeConsUnsigned (pctxt, pvalue->u.longTermPictureIndex, 0U, 255U); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* _SeqOfH245PictureReference */ /* */ /**************************************************************/ EXTERN int asn1PE_H245_SeqOfH245PictureReference (OOCTXT* pctxt, H245_SeqOfH245PictureReference* pvalue) { int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; ASN1UINT enclen, fraglen; enclen = fraglen = xx1 = 0; pnode = pvalue->head; for (;;) { /* encode length determinant */ stat = encodeLength (pctxt, (pvalue->count - enclen)); if (stat < 0) return stat; fraglen = stat; enclen += fraglen; /* encode elements */ for (; xx1 < enclen; xx1++) { stat = asn1PE_H245PictureReference (pctxt, ((H245PictureReference*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } if ( pvalue->count == enclen && fraglen < 16384) { break; } } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type_lostPartialPicture */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand_type_lostPartialPicture (OOCTXT* pctxt, H245MiscellaneousCommand_type_lostPartialPicture* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode pictureReference */ stat = asn1PE_H245PictureReference (pctxt, &pvalue->pictureReference); if (stat != ASN_OK) return stat; /* encode firstMB */ stat = encodeConsUnsigned (pctxt, pvalue->firstMB, 1U, 9216U); if (stat != ASN_OK) return stat; /* encode numberOfMBs */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfMBs, 1U, 9216U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand_type (OOCTXT* pctxt, H245MiscellaneousCommand_type* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 10); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 9); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* equaliseDelay */ case 1: /* NULL */ break; /* zeroDelay */ case 2: /* NULL */ break; /* multipointModeCommand */ case 3: /* NULL */ break; /* cancelMultipointModeCommand */ case 4: /* NULL */ break; /* videoFreezePicture */ case 5: /* NULL */ break; /* videoFastUpdatePicture */ case 6: /* NULL */ break; /* videoFastUpdateGOB */ case 7: stat = asn1PE_H245MiscellaneousCommand_type_videoFastUpdateGOB (pctxt, pvalue->u.videoFastUpdateGOB); if (stat != ASN_OK) return stat; break; /* videoTemporalSpatialTradeOff */ case 8: stat = encodeConsUnsigned (pctxt, pvalue->u.videoTemporalSpatialTradeOff, 0U, 31U); if (stat != ASN_OK) return stat; break; /* videoSendSyncEveryGOB */ case 9: /* NULL */ break; /* videoSendSyncEveryGOBCancel */ case 10: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 11); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* videoFastUpdateMB */ case 11: stat = asn1PE_H245MiscellaneousCommand_type_videoFastUpdateMB (&lctxt, pvalue->u.videoFastUpdateMB); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* maxH223MUXPDUsize */ case 12: stat = encodeConsUnsigned (&lctxt, pvalue->u.maxH223MUXPDUsize, 1U, 65535U); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* encryptionUpdate */ case 13: stat = asn1PE_H245EncryptionSync (&lctxt, pvalue->u.encryptionUpdate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* encryptionUpdateRequest */ case 14: stat = asn1PE_H245EncryptionUpdateRequest (&lctxt, pvalue->u.encryptionUpdateRequest); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* switchReceiveMediaOff */ case 15: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* switchReceiveMediaOn */ case 16: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* progressiveRefinementStart */ case 17: stat = asn1PE_H245MiscellaneousCommand_type_progressiveRefinementStart (&lctxt, pvalue->u.progressiveRefinementStart); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* progressiveRefinementAbortOne */ case 18: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* progressiveRefinementAbortContinuous */ case 19: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* videoBadMBs */ case 20: stat = asn1PE_H245MiscellaneousCommand_type_videoBadMBs (&lctxt, pvalue->u.videoBadMBs); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* lostPicture */ case 21: stat = asn1PE_H245_SeqOfH245PictureReference (&lctxt, pvalue->u.lostPicture); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* lostPartialPicture */ case 22: stat = asn1PE_H245MiscellaneousCommand_type_lostPartialPicture (&lctxt, pvalue->u.lostPartialPicture); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* recoveryReferencePicture */ case 23: stat = asn1PE_H245_SeqOfH245PictureReference (&lctxt, pvalue->u.recoveryReferencePicture); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MiscellaneousCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousCommand (OOCTXT* pctxt, H245MiscellaneousCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; /* encode type */ stat = asn1PE_H245MiscellaneousCommand_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CommunicationModeCommand_communicationModeTable */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommunicationModeCommand_communicationModeTable (OOCTXT* pctxt, H245CommunicationModeCommand_communicationModeTable* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; DListNode* pnode; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->count); if (stat < 0) return stat; /* encode elements */ pnode = pvalue->head; for (xx1 = 0; xx1 < pvalue->count; xx1++) { stat = asn1PE_H245CommunicationModeTableEntry (pctxt, ((H245CommunicationModeTableEntry*)pnode->data)); if (stat != ASN_OK) return stat; pnode = pnode->next; } return (stat); } /**************************************************************/ /* */ /* CommunicationModeCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommunicationModeCommand (OOCTXT* pctxt, H245CommunicationModeCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode communicationModeTable */ stat = asn1PE_H245CommunicationModeCommand_communicationModeTable (pctxt, &pvalue->communicationModeTable); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* SubstituteConferenceIDCommand_conferenceIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PE_H245SubstituteConferenceIDCommand_conferenceIdentifier (OOCTXT* pctxt, H245SubstituteConferenceIDCommand_conferenceIdentifier* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* SubstituteConferenceIDCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245SubstituteConferenceIDCommand (OOCTXT* pctxt, H245SubstituteConferenceIDCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode conferenceIdentifier */ stat = asn1PE_H245SubstituteConferenceIDCommand_conferenceIdentifier (pctxt, &pvalue->conferenceIdentifier); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceCommand (OOCTXT* pctxt, H245ConferenceCommand* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 7); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 6); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* broadcastMyLogicalChannel */ case 1: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.broadcastMyLogicalChannel); if (stat != ASN_OK) return stat; break; /* cancelBroadcastMyLogicalChannel */ case 2: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.cancelBroadcastMyLogicalChannel); if (stat != ASN_OK) return stat; break; /* makeTerminalBroadcaster */ case 3: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.makeTerminalBroadcaster); if (stat != ASN_OK) return stat; break; /* cancelMakeTerminalBroadcaster */ case 4: /* NULL */ break; /* sendThisSource */ case 5: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.sendThisSource); if (stat != ASN_OK) return stat; break; /* cancelSendThisSource */ case 6: /* NULL */ break; /* dropConference */ case 7: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 8); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* substituteConferenceIDCommand */ case 8: stat = asn1PE_H245SubstituteConferenceIDCommand (&lctxt, pvalue->u.substituteConferenceIDCommand); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H223MultiplexReconfiguration_h223ModeChange */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223MultiplexReconfiguration_h223ModeChange (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223ModeChange* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* toLevel0 */ case 1: /* NULL */ break; /* toLevel1 */ case 2: /* NULL */ break; /* toLevel2 */ case 3: /* NULL */ break; /* toLevel2withOptionalHeader */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223MultiplexReconfiguration_h223AnnexADoubleFlag */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag (OOCTXT* pctxt, H245H223MultiplexReconfiguration_h223AnnexADoubleFlag* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* start */ case 1: /* NULL */ break; /* stop */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* H223MultiplexReconfiguration */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223MultiplexReconfiguration (OOCTXT* pctxt, H245H223MultiplexReconfiguration* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* h223ModeChange */ case 1: stat = asn1PE_H245H223MultiplexReconfiguration_h223ModeChange (pctxt, pvalue->u.h223ModeChange); if (stat != ASN_OK) return stat; break; /* h223AnnexADoubleFlag */ case 2: stat = asn1PE_H245H223MultiplexReconfiguration_h223AnnexADoubleFlag (pctxt, pvalue->u.h223AnnexADoubleFlag); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1_clockRecovery */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_clockRecovery* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nullClockRecovery */ case 1: /* NULL */ break; /* srtsClockRecovery */ case 2: /* NULL */ break; /* adaptiveClockRecovery */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1_errorCorrection */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1_errorCorrection* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nullErrorCorrection */ case 1: /* NULL */ break; /* longInterleaver */ case 2: /* NULL */ break; /* shortInterleaver */ case 3: /* NULL */ break; /* errorCorrectionOnly */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal1 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_aal_aal1 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal1* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode clockRecovery */ stat = asn1PE_H245NewATMVCCommand_aal_aal1_clockRecovery (pctxt, &pvalue->clockRecovery); if (stat != ASN_OK) return stat; /* encode errorCorrection */ stat = asn1PE_H245NewATMVCCommand_aal_aal1_errorCorrection (pctxt, &pvalue->errorCorrection); if (stat != ASN_OK) return stat; /* encode structuredDataTransfer */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; /* encode partiallyFilledCells */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal_aal5 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_aal_aal5 (OOCTXT* pctxt, H245NewATMVCCommand_aal_aal5* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardMaximumSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->forwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode backwardMaximumSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->backwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_aal */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_aal (OOCTXT* pctxt, H245NewATMVCCommand_aal* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* aal1 */ case 1: stat = asn1PE_H245NewATMVCCommand_aal_aal1 (pctxt, pvalue->u.aal1); if (stat != ASN_OK) return stat; break; /* aal5 */ case 2: stat = asn1PE_H245NewATMVCCommand_aal_aal5 (pctxt, pvalue->u.aal5); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_multiplex* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noMultiplex */ case 1: /* NULL */ break; /* transportStream */ case 2: /* NULL */ break; /* programStream */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_reverseParameters_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters_multiplex* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noMultiplex */ case 1: /* NULL */ break; /* transportStream */ case 2: /* NULL */ break; /* programStream */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand_reverseParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand_reverseParameters (OOCTXT* pctxt, H245NewATMVCCommand_reverseParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; /* encode bitRateLockedToPCRClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; /* encode bitRateLockedToNetworkClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; /* encode multiplex */ stat = asn1PE_H245NewATMVCCommand_reverseParameters_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NewATMVCCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCCommand (OOCTXT* pctxt, H245NewATMVCCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode resourceID */ stat = encodeConsUnsigned (pctxt, pvalue->resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; /* encode bitRateLockedToPCRClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; /* encode bitRateLockedToNetworkClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; /* encode aal */ stat = asn1PE_H245NewATMVCCommand_aal (pctxt, &pvalue->aal); if (stat != ASN_OK) return stat; /* encode multiplex */ stat = asn1PE_H245NewATMVCCommand_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; /* encode reverseParameters */ stat = asn1PE_H245NewATMVCCommand_reverseParameters (pctxt, &pvalue->reverseParameters); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MobileMultilinkReconfigurationCommand_status */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MobileMultilinkReconfigurationCommand_status (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand_status* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* synchronized_ */ case 1: /* NULL */ break; /* reconfiguration */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* MobileMultilinkReconfigurationCommand */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MobileMultilinkReconfigurationCommand (OOCTXT* pctxt, H245MobileMultilinkReconfigurationCommand* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sampleSize */ stat = encodeConsUnsigned (pctxt, pvalue->sampleSize, 1U, 255U); if (stat != ASN_OK) return stat; /* encode samplesPerFrame */ stat = encodeConsUnsigned (pctxt, pvalue->samplesPerFrame, 1U, 255U); if (stat != ASN_OK) return stat; /* encode status */ stat = asn1PE_H245MobileMultilinkReconfigurationCommand_status (pctxt, &pvalue->status); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* CommandMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H245CommandMessage (OOCTXT* pctxt, H245CommandMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 7); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 6); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* maintenanceLoopOffCommand */ case 2: stat = asn1PE_H245MaintenanceLoopOffCommand (pctxt, pvalue->u.maintenanceLoopOffCommand); if (stat != ASN_OK) return stat; break; /* sendTerminalCapabilitySet */ case 3: stat = asn1PE_H245SendTerminalCapabilitySet (pctxt, pvalue->u.sendTerminalCapabilitySet); if (stat != ASN_OK) return stat; break; /* encryptionCommand */ case 4: stat = asn1PE_H245EncryptionCommand (pctxt, pvalue->u.encryptionCommand); if (stat != ASN_OK) return stat; break; /* flowControlCommand */ case 5: stat = asn1PE_H245FlowControlCommand (pctxt, pvalue->u.flowControlCommand); if (stat != ASN_OK) return stat; break; /* endSessionCommand */ case 6: stat = asn1PE_H245EndSessionCommand (pctxt, pvalue->u.endSessionCommand); if (stat != ASN_OK) return stat; break; /* miscellaneousCommand */ case 7: stat = asn1PE_H245MiscellaneousCommand (pctxt, pvalue->u.miscellaneousCommand); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 8); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* communicationModeCommand */ case 8: stat = asn1PE_H245CommunicationModeCommand (&lctxt, pvalue->u.communicationModeCommand); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* conferenceCommand */ case 9: stat = asn1PE_H245ConferenceCommand (&lctxt, pvalue->u.conferenceCommand); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* h223MultiplexReconfiguration */ case 10: stat = asn1PE_H245H223MultiplexReconfiguration (&lctxt, pvalue->u.h223MultiplexReconfiguration); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* newATMVCCommand */ case 11: stat = asn1PE_H245NewATMVCCommand (&lctxt, pvalue->u.newATMVCCommand); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* mobileMultilinkReconfigurationCommand */ case 12: stat = asn1PE_H245MobileMultilinkReconfigurationCommand (&lctxt, pvalue->u.mobileMultilinkReconfigurationCommand); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* FunctionNotUnderstood */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FunctionNotUnderstood (OOCTXT* pctxt, H245FunctionNotUnderstood* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* request */ case 1: stat = asn1PE_H245RequestMessage (pctxt, pvalue->u.request); if (stat != ASN_OK) return stat; break; /* response */ case 2: stat = asn1PE_H245ResponseMessage (pctxt, pvalue->u.response); if (stat != ASN_OK) return stat; break; /* command */ case 3: stat = asn1PE_H245CommandMessage (pctxt, pvalue->u.command); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* MasterSlaveDeterminationRelease */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MasterSlaveDeterminationRelease (OOCTXT* pctxt, H245MasterSlaveDeterminationRelease* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* TerminalCapabilitySetRelease */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalCapabilitySetRelease (OOCTXT* pctxt, H245TerminalCapabilitySetRelease* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* OpenLogicalChannelConfirm */ /* */ /**************************************************************/ EXTERN int asn1PE_H245OpenLogicalChannelConfirm (OOCTXT* pctxt, H245OpenLogicalChannelConfirm* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestChannelCloseRelease */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestChannelCloseRelease (OOCTXT* pctxt, H245RequestChannelCloseRelease* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardLogicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->forwardLogicalChannelNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendRelease_multiplexTableEntryNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySendRelease_multiplexTableEntryNumber (OOCTXT* pctxt, H245MultiplexEntrySendRelease_multiplexTableEntryNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultiplexEntrySendRelease */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultiplexEntrySendRelease (OOCTXT* pctxt, H245MultiplexEntrySendRelease* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode multiplexTableEntryNumber */ stat = asn1PE_H245MultiplexEntrySendRelease_multiplexTableEntryNumber (pctxt, &pvalue->multiplexTableEntryNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRelease_entryNumbers */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryRelease_entryNumbers (OOCTXT* pctxt, H245RequestMultiplexEntryRelease_entryNumbers* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 15, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* encode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = encodeLength (pctxt, pvalue->n); if (stat < 0) return stat; /* encode elements */ for (xx1 = 0; xx1 < pvalue->n; xx1++) { stat = asn1PE_H245MultiplexTableEntryNumber (pctxt, pvalue->elem[xx1]); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* RequestMultiplexEntryRelease */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestMultiplexEntryRelease (OOCTXT* pctxt, H245RequestMultiplexEntryRelease* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode entryNumbers */ stat = asn1PE_H245RequestMultiplexEntryRelease_entryNumbers (pctxt, &pvalue->entryNumbers); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestModeRelease */ /* */ /**************************************************************/ EXTERN int asn1PE_H245RequestModeRelease (OOCTXT* pctxt, H245RequestModeRelease* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* MiscellaneousIndication_type_videoNotDecodedMBs */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousIndication_type_videoNotDecodedMBs (OOCTXT* pctxt, H245MiscellaneousIndication_type_videoNotDecodedMBs* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode firstMB */ stat = encodeConsUnsigned (pctxt, pvalue->firstMB, 1U, 8192U); if (stat != ASN_OK) return stat; /* encode numberOfMBs */ stat = encodeConsUnsigned (pctxt, pvalue->numberOfMBs, 1U, 8192U); if (stat != ASN_OK) return stat; /* encode temporalReference */ stat = encodeConsUnsigned (pctxt, pvalue->temporalReference, 0U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MiscellaneousIndication_type */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousIndication_type (OOCTXT* pctxt, H245MiscellaneousIndication_type* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 10); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 9); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* logicalChannelActive */ case 1: /* NULL */ break; /* logicalChannelInactive */ case 2: /* NULL */ break; /* multipointConference */ case 3: /* NULL */ break; /* cancelMultipointConference */ case 4: /* NULL */ break; /* multipointZeroComm */ case 5: /* NULL */ break; /* cancelMultipointZeroComm */ case 6: /* NULL */ break; /* multipointSecondaryStatus */ case 7: /* NULL */ break; /* cancelMultipointSecondaryStatus */ case 8: /* NULL */ break; /* videoIndicateReadyToActivate */ case 9: /* NULL */ break; /* videoTemporalSpatialTradeOff */ case 10: stat = encodeConsUnsigned (pctxt, pvalue->u.videoTemporalSpatialTradeOff, 0U, 31U); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 11); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* videoNotDecodedMBs */ case 11: stat = asn1PE_H245MiscellaneousIndication_type_videoNotDecodedMBs (&lctxt, pvalue->u.videoNotDecodedMBs); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* transportCapability */ case 12: stat = asn1PE_H245TransportCapability (&lctxt, pvalue->u.transportCapability); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MiscellaneousIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MiscellaneousIndication (OOCTXT* pctxt, H245MiscellaneousIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; /* encode type */ stat = asn1PE_H245MiscellaneousIndication_type (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* JitterIndication_scope */ /* */ /**************************************************************/ EXTERN int asn1PE_H245JitterIndication_scope (OOCTXT* pctxt, H245JitterIndication_scope* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* logicalChannelNumber */ case 1: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.logicalChannelNumber); if (stat != ASN_OK) return stat; break; /* resourceID */ case 2: stat = encodeConsUnsigned (pctxt, pvalue->u.resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* wholeMultiplex */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* JitterIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245JitterIndication (OOCTXT* pctxt, H245JitterIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.skippedFrameCountPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.additionalDecoderBufferPresent); /* encode scope */ stat = asn1PE_H245JitterIndication_scope (pctxt, &pvalue->scope); if (stat != ASN_OK) return stat; /* encode estimatedReceivedJitterMantissa */ stat = encodeConsUnsigned (pctxt, pvalue->estimatedReceivedJitterMantissa, 0U, 3U); if (stat != ASN_OK) return stat; /* encode estimatedReceivedJitterExponent */ stat = encodeConsUnsigned (pctxt, pvalue->estimatedReceivedJitterExponent, 0U, 7U); if (stat != ASN_OK) return stat; /* encode skippedFrameCount */ if (pvalue->m.skippedFrameCountPresent) { stat = encodeConsUnsigned (pctxt, pvalue->skippedFrameCount, 0U, 15U); if (stat != ASN_OK) return stat; } /* encode additionalDecoderBuffer */ if (pvalue->m.additionalDecoderBufferPresent) { stat = encodeConsUnsigned (pctxt, pvalue->additionalDecoderBuffer, 0U, 262143U); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* H223SkewIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H223SkewIndication (OOCTXT* pctxt, H245H223SkewIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode logicalChannelNumber1 */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber1); if (stat != ASN_OK) return stat; /* encode logicalChannelNumber2 */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber2); if (stat != ASN_OK) return stat; /* encode skew */ stat = encodeConsUnsigned (pctxt, pvalue->skew, 0U, 4095U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1_clockRecovery */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_aal_aal1_clockRecovery (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_clockRecovery* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nullClockRecovery */ case 1: /* NULL */ break; /* srtsClockRecovery */ case 2: /* NULL */ break; /* adaptiveClockRecovery */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1_errorCorrection */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_aal_aal1_errorCorrection (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1_errorCorrection* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nullErrorCorrection */ case 1: /* NULL */ break; /* longInterleaver */ case 2: /* NULL */ break; /* shortInterleaver */ case 3: /* NULL */ break; /* errorCorrectionOnly */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal1 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_aal_aal1 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal1* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode clockRecovery */ stat = asn1PE_H245NewATMVCIndication_aal_aal1_clockRecovery (pctxt, &pvalue->clockRecovery); if (stat != ASN_OK) return stat; /* encode errorCorrection */ stat = asn1PE_H245NewATMVCIndication_aal_aal1_errorCorrection (pctxt, &pvalue->errorCorrection); if (stat != ASN_OK) return stat; /* encode structuredDataTransfer */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->structuredDataTransfer); if (stat != ASN_OK) return stat; /* encode partiallyFilledCells */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->partiallyFilledCells); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal_aal5 */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_aal_aal5 (OOCTXT* pctxt, H245NewATMVCIndication_aal_aal5* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode forwardMaximumSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->forwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode backwardMaximumSDUSize */ stat = encodeConsUnsigned (pctxt, pvalue->backwardMaximumSDUSize, 0U, 65535U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_aal */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_aal (OOCTXT* pctxt, H245NewATMVCIndication_aal* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* aal1 */ case 1: stat = asn1PE_H245NewATMVCIndication_aal_aal1 (pctxt, pvalue->u.aal1); if (stat != ASN_OK) return stat; break; /* aal5 */ case 2: stat = asn1PE_H245NewATMVCIndication_aal_aal5 (pctxt, pvalue->u.aal5); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_multiplex* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noMultiplex */ case 1: /* NULL */ break; /* transportStream */ case 2: /* NULL */ break; /* programStream */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_reverseParameters_multiplex */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_reverseParameters_multiplex (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters_multiplex* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* noMultiplex */ case 1: /* NULL */ break; /* transportStream */ case 2: /* NULL */ break; /* programStream */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication_reverseParameters */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication_reverseParameters (OOCTXT* pctxt, H245NewATMVCIndication_reverseParameters* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; /* encode bitRateLockedToPCRClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; /* encode bitRateLockedToNetworkClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; /* encode multiplex */ stat = asn1PE_H245NewATMVCIndication_reverseParameters_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* NewATMVCIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245NewATMVCIndication (OOCTXT* pctxt, H245NewATMVCIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.reverseParametersPresent); encodeBit (pctxt, extbit); /* encode resourceID */ stat = encodeConsUnsigned (pctxt, pvalue->resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; /* encode bitRate */ stat = encodeConsUnsigned (pctxt, pvalue->bitRate, 1U, 65535U); if (stat != ASN_OK) return stat; /* encode bitRateLockedToPCRClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToPCRClock); if (stat != ASN_OK) return stat; /* encode bitRateLockedToNetworkClock */ stat = encodeBit (pctxt, (ASN1BOOL)pvalue->bitRateLockedToNetworkClock); if (stat != ASN_OK) return stat; /* encode aal */ stat = asn1PE_H245NewATMVCIndication_aal (pctxt, &pvalue->aal); if (stat != ASN_OK) return stat; /* encode multiplex */ stat = asn1PE_H245NewATMVCIndication_multiplex (pctxt, &pvalue->multiplex); if (stat != ASN_OK) return stat; if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.reverseParametersPresent); /* encode extension elements */ if (pvalue->m.reverseParametersPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = asn1PE_H245NewATMVCIndication_reverseParameters (&lctxt, &pvalue->reverseParameters); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_userInputSupportIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputIndication_userInputSupportIndication (OOCTXT* pctxt, H245UserInputIndication_userInputSupportIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* basicString */ case 2: /* NULL */ break; /* iA5String */ case 3: /* NULL */ break; /* generalString */ case 4: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signal_rtp */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputIndication_signal_rtp (OOCTXT* pctxt, H245UserInputIndication_signal_rtp* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.timestampPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.expirationTimePresent); /* encode timestamp */ if (pvalue->m.timestampPresent) { stat = encodeConsUnsigned (pctxt, pvalue->timestamp, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode expirationTime */ if (pvalue->m.expirationTimePresent) { stat = encodeConsUnsigned (pctxt, pvalue->expirationTime, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; } /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signal */ /* */ /**************************************************************/ extern EXTERN const char* gs_MULTIMEDIA_SYSTEM_CONTROL_UserInputIndication_signal_signalType_CharSet; EXTERN int asn1PE_H245UserInputIndication_signal (OOCTXT* pctxt, H245UserInputIndication_signal* pvalue) { static Asn1SizeCnst signalType_lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; ASN1BOOL extbit; ASN1OpenType openType; OOCTXT lctxt; /* extension bit */ extbit = (ASN1BOOL)(pvalue->m.rtpPayloadIndicationPresent); encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.durationPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.rtpPresent); /* encode signalType */ addSizeConstraint (pctxt, &signalType_lsize1); stat = encodeConstrainedStringEx (pctxt, pvalue->signalType, gs_MULTIMEDIA_SYSTEM_CONTROL_UserInputIndication_signal_signalType_CharSet, 8, 5, 7); if (stat != ASN_OK) return stat; /* encode duration */ if (pvalue->m.durationPresent) { stat = encodeConsUnsigned (pctxt, pvalue->duration, 1U, 65535U); if (stat != ASN_OK) return stat; } /* encode rtp */ if (pvalue->m.rtpPresent) { stat = asn1PE_H245UserInputIndication_signal_rtp (pctxt, &pvalue->rtp); if (stat != ASN_OK) return stat; } if (extbit) { /* encode extension optional bits length */ stat = encodeSmallNonNegWholeNumber (pctxt, 0); if (stat != ASN_OK) return stat; /* encode optional bits */ encodeBit (pctxt, (ASN1BOOL)pvalue->m.rtpPayloadIndicationPresent); /* encode extension elements */ if (pvalue->m.rtpPayloadIndicationPresent) { initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; /* NULL */ stat = encodeByteAlign (&lctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signalUpdate_rtp */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputIndication_signalUpdate_rtp (OOCTXT* pctxt, H245UserInputIndication_signalUpdate_rtp* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode logicalChannelNumber */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* UserInputIndication_signalUpdate */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputIndication_signalUpdate (OOCTXT* pctxt, H245UserInputIndication_signalUpdate* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.rtpPresent); /* encode duration */ stat = encodeConsUnsigned (pctxt, pvalue->duration, 1U, 65535U); if (stat != ASN_OK) return stat; /* encode rtp */ if (pvalue->m.rtpPresent) { stat = asn1PE_H245UserInputIndication_signalUpdate_rtp (pctxt, &pvalue->rtp); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* UserInputIndication_extendedAlphanumeric */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputIndication_extendedAlphanumeric (OOCTXT* pctxt, H245UserInputIndication_extendedAlphanumeric* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.rtpPayloadIndicationPresent); /* encode alphanumeric */ stat = encodeVarWidthCharString (pctxt, pvalue->alphanumeric); if (stat != ASN_OK) return stat; /* encode rtpPayloadIndication */ if (pvalue->m.rtpPayloadIndicationPresent) { /* NULL */ } return (stat); } /**************************************************************/ /* */ /* UserInputIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245UserInputIndication (OOCTXT* pctxt, H245UserInputIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 2); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* alphanumeric */ case 2: stat = encodeVarWidthCharString (pctxt, pvalue->u.alphanumeric); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 3); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* userInputSupportIndication */ case 3: stat = asn1PE_H245UserInputIndication_userInputSupportIndication (&lctxt, pvalue->u.userInputSupportIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* signal */ case 4: stat = asn1PE_H245UserInputIndication_signal (&lctxt, pvalue->u.signal); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* signalUpdate */ case 5: stat = asn1PE_H245UserInputIndication_signalUpdate (&lctxt, pvalue->u.signalUpdate); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* extendedAlphanumeric */ case 6: stat = asn1PE_H245UserInputIndication_extendedAlphanumeric (&lctxt, pvalue->u.extendedAlphanumeric); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* H2250MaximumSkewIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245H2250MaximumSkewIndication (OOCTXT* pctxt, H245H2250MaximumSkewIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode logicalChannelNumber1 */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber1); if (stat != ASN_OK) return stat; /* encode logicalChannelNumber2 */ stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->logicalChannelNumber2); if (stat != ASN_OK) return stat; /* encode maximumSkew */ stat = encodeConsUnsigned (pctxt, pvalue->maximumSkew, 0U, 4095U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MCLocationIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MCLocationIndication (OOCTXT* pctxt, H245MCLocationIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode signalAddress */ stat = asn1PE_H245TransportAddress (pctxt, &pvalue->signalAddress); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* TerminalYouAreSeeingInSubPictureNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245TerminalYouAreSeeingInSubPictureNumber (OOCTXT* pctxt, H245TerminalYouAreSeeingInSubPictureNumber* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode terminalNumber */ stat = asn1PE_H245TerminalNumber (pctxt, pvalue->terminalNumber); if (stat != ASN_OK) return stat; /* encode subPictureNumber */ stat = encodeConsUnsigned (pctxt, pvalue->subPictureNumber, 0U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VideoIndicateCompose */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VideoIndicateCompose (OOCTXT* pctxt, H245VideoIndicateCompose* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode compositionNumber */ stat = encodeConsUnsigned (pctxt, pvalue->compositionNumber, 0U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* ConferenceIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245ConferenceIndication (OOCTXT* pctxt, H245ConferenceIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 10); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 9); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* sbeNumber */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.sbeNumber, 0U, 9U); if (stat != ASN_OK) return stat; break; /* terminalNumberAssign */ case 2: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.terminalNumberAssign); if (stat != ASN_OK) return stat; break; /* terminalJoinedConference */ case 3: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.terminalJoinedConference); if (stat != ASN_OK) return stat; break; /* terminalLeftConference */ case 4: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.terminalLeftConference); if (stat != ASN_OK) return stat; break; /* seenByAtLeastOneOther */ case 5: /* NULL */ break; /* cancelSeenByAtLeastOneOther */ case 6: /* NULL */ break; /* seenByAll */ case 7: /* NULL */ break; /* cancelSeenByAll */ case 8: /* NULL */ break; /* terminalYouAreSeeing */ case 9: stat = asn1PE_H245TerminalLabel (pctxt, pvalue->u.terminalYouAreSeeing); if (stat != ASN_OK) return stat; break; /* requestForFloor */ case 10: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 11); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* withdrawChairToken */ case 11: /* NULL */ openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* floorRequested */ case 12: stat = asn1PE_H245TerminalLabel (&lctxt, pvalue->u.floorRequested); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* terminalYouAreSeeingInSubPictureNumber */ case 13: stat = asn1PE_H245TerminalYouAreSeeingInSubPictureNumber (&lctxt, pvalue->u.terminalYouAreSeeingInSubPictureNumber); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* videoIndicateCompose */ case 14: stat = asn1PE_H245VideoIndicateCompose (&lctxt, pvalue->u.videoIndicateCompose); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* VendorIdentification_productNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VendorIdentification_productNumber (OOCTXT* pctxt, H245VendorIdentification_productNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VendorIdentification_versionNumber */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VendorIdentification_versionNumber (OOCTXT* pctxt, H245VendorIdentification_versionNumber* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = encodeOctetString (pctxt, pvalue->numocts, pvalue->data); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* VendorIdentification */ /* */ /**************************************************************/ EXTERN int asn1PE_H245VendorIdentification (OOCTXT* pctxt, H245VendorIdentification* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.productNumberPresent); encodeBit (pctxt, (ASN1BOOL)pvalue->m.versionNumberPresent); /* encode vendor */ stat = asn1PE_H245NonStandardIdentifier (pctxt, &pvalue->vendor); if (stat != ASN_OK) return stat; /* encode productNumber */ if (pvalue->m.productNumberPresent) { stat = asn1PE_H245VendorIdentification_productNumber (pctxt, &pvalue->productNumber); if (stat != ASN_OK) return stat; } /* encode versionNumber */ if (pvalue->m.versionNumberPresent) { stat = asn1PE_H245VendorIdentification_versionNumber (pctxt, &pvalue->versionNumber); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* FunctionNotSupported_cause */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FunctionNotSupported_cause (OOCTXT* pctxt, H245FunctionNotSupported_cause* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* syntaxError */ case 1: /* NULL */ break; /* semanticError */ case 2: /* NULL */ break; /* unknownFunction */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* FunctionNotSupported */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FunctionNotSupported (OOCTXT* pctxt, H245FunctionNotSupported* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); encodeBit (pctxt, (ASN1BOOL)pvalue->m.returnedFunctionPresent); /* encode cause */ stat = asn1PE_H245FunctionNotSupported_cause (pctxt, &pvalue->cause); if (stat != ASN_OK) return stat; /* encode returnedFunction */ if (pvalue->m.returnedFunctionPresent) { stat = encodeOctetString (pctxt, pvalue->returnedFunction.numocts, pvalue->returnedFunction.data); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* MultilinkIndication_crcDesired */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkIndication_crcDesired (OOCTXT* pctxt, H245MultilinkIndication_crcDesired* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* MultilinkIndication_excessiveError */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkIndication_excessiveError (OOCTXT* pctxt, H245MultilinkIndication_excessiveError* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode connectionIdentifier */ stat = asn1PE_H245ConnectionIdentifier (pctxt, &pvalue->connectionIdentifier); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MultilinkIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultilinkIndication (OOCTXT* pctxt, H245MultilinkIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 3); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* crcDesired */ case 2: stat = asn1PE_H245MultilinkIndication_crcDesired (pctxt, pvalue->u.crcDesired); if (stat != ASN_OK) return stat; break; /* excessiveError */ case 3: stat = asn1PE_H245MultilinkIndication_excessiveError (pctxt, pvalue->u.excessiveError); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 4); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } /**************************************************************/ /* */ /* LogicalChannelRateRelease */ /* */ /**************************************************************/ EXTERN int asn1PE_H245LogicalChannelRateRelease (OOCTXT* pctxt, H245LogicalChannelRateRelease* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); return (stat); } /**************************************************************/ /* */ /* FlowControlIndication_scope */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FlowControlIndication_scope (OOCTXT* pctxt, H245FlowControlIndication_scope* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 2); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* logicalChannelNumber */ case 1: stat = asn1PE_H245LogicalChannelNumber (pctxt, pvalue->u.logicalChannelNumber); if (stat != ASN_OK) return stat; break; /* resourceID */ case 2: stat = encodeConsUnsigned (pctxt, pvalue->u.resourceID, 0U, 65535U); if (stat != ASN_OK) return stat; break; /* wholeMultiplex */ case 3: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlIndication_restriction */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FlowControlIndication_restriction (OOCTXT* pctxt, H245FlowControlIndication_restriction* pvalue) { int stat = ASN_OK; /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 1); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* maximumBitRate */ case 1: stat = encodeConsUnsigned (pctxt, pvalue->u.maximumBitRate, 0U, 16777215U); if (stat != ASN_OK) return stat; break; /* noRestriction */ case 2: /* NULL */ break; default: return ASN_E_INVOPT; } return (stat); } /**************************************************************/ /* */ /* FlowControlIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245FlowControlIndication (OOCTXT* pctxt, H245FlowControlIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode scope */ stat = asn1PE_H245FlowControlIndication_scope (pctxt, &pvalue->scope); if (stat != ASN_OK) return stat; /* encode restriction */ stat = asn1PE_H245FlowControlIndication_restriction (pctxt, &pvalue->restriction); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* MobileMultilinkReconfigurationIndication */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MobileMultilinkReconfigurationIndication (OOCTXT* pctxt, H245MobileMultilinkReconfigurationIndication* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = 0; encodeBit (pctxt, extbit); /* encode sampleSize */ stat = encodeConsUnsigned (pctxt, pvalue->sampleSize, 1U, 255U); if (stat != ASN_OK) return stat; /* encode samplesPerFrame */ stat = encodeConsUnsigned (pctxt, pvalue->samplesPerFrame, 1U, 255U); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* IndicationMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H245IndicationMessage (OOCTXT* pctxt, H245IndicationMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 14); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 13); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* nonStandard */ case 1: stat = asn1PE_H245NonStandardMessage (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; break; /* functionNotUnderstood */ case 2: stat = asn1PE_H245FunctionNotUnderstood (pctxt, pvalue->u.functionNotUnderstood); if (stat != ASN_OK) return stat; break; /* masterSlaveDeterminationRelease */ case 3: stat = asn1PE_H245MasterSlaveDeterminationRelease (pctxt, pvalue->u.masterSlaveDeterminationRelease); if (stat != ASN_OK) return stat; break; /* terminalCapabilitySetRelease */ case 4: stat = asn1PE_H245TerminalCapabilitySetRelease (pctxt, pvalue->u.terminalCapabilitySetRelease); if (stat != ASN_OK) return stat; break; /* openLogicalChannelConfirm */ case 5: stat = asn1PE_H245OpenLogicalChannelConfirm (pctxt, pvalue->u.openLogicalChannelConfirm); if (stat != ASN_OK) return stat; break; /* requestChannelCloseRelease */ case 6: stat = asn1PE_H245RequestChannelCloseRelease (pctxt, pvalue->u.requestChannelCloseRelease); if (stat != ASN_OK) return stat; break; /* multiplexEntrySendRelease */ case 7: stat = asn1PE_H245MultiplexEntrySendRelease (pctxt, pvalue->u.multiplexEntrySendRelease); if (stat != ASN_OK) return stat; break; /* requestMultiplexEntryRelease */ case 8: stat = asn1PE_H245RequestMultiplexEntryRelease (pctxt, pvalue->u.requestMultiplexEntryRelease); if (stat != ASN_OK) return stat; break; /* requestModeRelease */ case 9: stat = asn1PE_H245RequestModeRelease (pctxt, pvalue->u.requestModeRelease); if (stat != ASN_OK) return stat; break; /* miscellaneousIndication */ case 10: stat = asn1PE_H245MiscellaneousIndication (pctxt, pvalue->u.miscellaneousIndication); if (stat != ASN_OK) return stat; break; /* jitterIndication */ case 11: stat = asn1PE_H245JitterIndication (pctxt, pvalue->u.jitterIndication); if (stat != ASN_OK) return stat; break; /* h223SkewIndication */ case 12: stat = asn1PE_H245H223SkewIndication (pctxt, pvalue->u.h223SkewIndication); if (stat != ASN_OK) return stat; break; /* newATMVCIndication */ case 13: stat = asn1PE_H245NewATMVCIndication (pctxt, pvalue->u.newATMVCIndication); if (stat != ASN_OK) return stat; break; /* userInput */ case 14: stat = asn1PE_H245UserInputIndication (pctxt, pvalue->u.userInput); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 15); if (stat != ASN_OK) return stat; /* Encode extension element data value */ initContext (&lctxt); stat = setPERBuffer (&lctxt, 0, 0, TRUE); if (stat != ASN_OK) return freeContext (&lctxt), stat; switch (pvalue->t) { /* h2250MaximumSkewIndication */ case 15: stat = asn1PE_H245H2250MaximumSkewIndication (&lctxt, pvalue->u.h2250MaximumSkewIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* mcLocationIndication */ case 16: stat = asn1PE_H245MCLocationIndication (&lctxt, pvalue->u.mcLocationIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* conferenceIndication */ case 17: stat = asn1PE_H245ConferenceIndication (&lctxt, pvalue->u.conferenceIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* vendorIdentification */ case 18: stat = asn1PE_H245VendorIdentification (&lctxt, pvalue->u.vendorIdentification); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* functionNotSupported */ case 19: stat = asn1PE_H245FunctionNotSupported (&lctxt, pvalue->u.functionNotSupported); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* multilinkIndication */ case 20: stat = asn1PE_H245MultilinkIndication (&lctxt, pvalue->u.multilinkIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* logicalChannelRateRelease */ case 21: stat = asn1PE_H245LogicalChannelRateRelease (&lctxt, pvalue->u.logicalChannelRateRelease); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* flowControlIndication */ case 22: stat = asn1PE_H245FlowControlIndication (&lctxt, pvalue->u.flowControlIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; /* mobileMultilinkReconfigurationIndication */ case 23: stat = asn1PE_H245MobileMultilinkReconfigurationIndication (&lctxt, pvalue->u.mobileMultilinkReconfigurationIndication); if (stat != ASN_OK) return freeContext (&lctxt), stat; openType.data = encodeGetMsgPtr (&lctxt, (int*)&openType.numocts); break; default: ; } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return freeContext (&lctxt), stat; stat = encodeOpenType (pctxt, openType.numocts, openType.data); if (stat != ASN_OK) return freeContext (&lctxt), stat; freeContext (&lctxt); } return (stat); } /**************************************************************/ /* */ /* MultimediaSystemControlMessage */ /* */ /**************************************************************/ EXTERN int asn1PE_H245MultimediaSystemControlMessage (OOCTXT* pctxt, H245MultimediaSystemControlMessage* pvalue) { int stat = ASN_OK; ASN1BOOL extbit; /* extension bit */ extbit = (ASN1BOOL)(pvalue->t > 4); encodeBit (pctxt, extbit); if (!extbit) { /* Encode choice index value */ stat = encodeConsUnsigned (pctxt, pvalue->t - 1, 0, 3); if (stat != ASN_OK) return stat; /* Encode root element data value */ switch (pvalue->t) { /* request */ case 1: stat = asn1PE_H245RequestMessage (pctxt, pvalue->u.request); if (stat != ASN_OK) return stat; break; /* response */ case 2: stat = asn1PE_H245ResponseMessage (pctxt, pvalue->u.response); if (stat != ASN_OK) return stat; break; /* command */ case 3: stat = asn1PE_H245CommandMessage (pctxt, pvalue->u.command); if (stat != ASN_OK) return stat; break; /* indication */ case 4: stat = asn1PE_H245IndicationMessage (pctxt, pvalue->u.indication); if (stat != ASN_OK) return stat; break; default: return ASN_E_INVOPT; } } else { /* Encode extension choice index value */ stat = encodeSmallNonNegWholeNumber (pctxt, pvalue->t - 5); if (stat != ASN_OK) return stat; /* Encode extension element data value */ } return (stat); } asterisk-11.7.0/addons/ooh323c/src/h323/H323-MESSAGES.c0000644000175000007640000001023211222440006021220 0ustar sharkyjerryweb/* * 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"; asterisk-11.7.0/addons/ooh323c/src/h323/H323-MESSAGESDec.c0000644000175000007640000300507511274375744021677 0ustar sharkyjerryweb/* * 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 "ooasn1.h" #include "H323-MESSAGES.h" #include "eventHandler.h" /**************************************************************/ /* */ /* ScreeningIndicator */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ScreeningIndicator (OOCTXT* pctxt, H225ScreeningIndicator* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit) { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; *pvalue = ui; } else { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; switch (ui) { case 0: *pvalue = userProvidedNotScreened; break; case 1: *pvalue = userProvidedVerifiedAndPassed; break; case 2: *pvalue = userProvidedVerifiedAndFailed; break; case 3: *pvalue = networkProvided; break; default: return ASN_E_INVENUM; } } invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* NumberDigits */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_NumberDigits_CharSet; EXTERN int asn1PD_H225NumberDigits (OOCTXT* pctxt, H225NumberDigits* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeConstrainedStringEx (pctxt, pvalue, gs_H323_MESSAGES_NumberDigits_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* TBCD_STRING */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_TBCD_STRING_CharSet; EXTERN int asn1PD_H225TBCD_STRING (OOCTXT* pctxt, H225TBCD_STRING* pvalue) { int stat = ASN_OK; stat = decodeConstrainedStringEx (pctxt, pvalue, gs_H323_MESSAGES_TBCD_STRING_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* GloballyUniqueID */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GloballyUniqueID (OOCTXT* pctxt, H225GloballyUniqueID* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ConferenceIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ConferenceIdentifier (OOCTXT* pctxt, H225ConferenceIdentifier* pvalue) { int stat = ASN_OK; stat = asn1PD_H225GloballyUniqueID (pctxt, pvalue); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* RequestSeqNum */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RequestSeqNum (OOCTXT* pctxt, H225RequestSeqNum* pvalue) { int stat = ASN_OK; stat = decodeConsUInt16 (pctxt, pvalue, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* GatekeeperIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatekeeperIdentifier (OOCTXT* pctxt, H225GatekeeperIdentifier* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBMPString (pctxt, pvalue, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->nchars, pvalue->data); return (stat); } /**************************************************************/ /* */ /* BandWidth */ /* */ /**************************************************************/ EXTERN int asn1PD_H225BandWidth (OOCTXT* pctxt, H225BandWidth* pvalue) { int stat = ASN_OK; stat = decodeConsUnsigned (pctxt, pvalue, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* CallReferenceValue */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallReferenceValue (OOCTXT* pctxt, H225CallReferenceValue* pvalue) { int stat = ASN_OK; stat = decodeConsUInt16 (pctxt, pvalue, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* EndpointIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225EndpointIdentifier (OOCTXT* pctxt, H225EndpointIdentifier* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBMPString (pctxt, pvalue, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->nchars, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ProtocolIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ProtocolIdentifier (OOCTXT* pctxt, H225ProtocolIdentifier* pvalue) { int stat = ASN_OK; stat = decodeObjectIdentifier (pctxt, pvalue); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->numids, pvalue->subid); return (stat); } /**************************************************************/ /* */ /* TimeToLive */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TimeToLive (OOCTXT* pctxt, H225TimeToLive* pvalue) { int stat = ASN_OK; stat = decodeConsUnsigned (pctxt, pvalue, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* H248PackagesDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H248PackagesDescriptor (OOCTXT* pctxt, H225H248PackagesDescriptor* pvalue) { int stat = ASN_OK; stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)pvalue); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* H248SignalsDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H248SignalsDescriptor (OOCTXT* pctxt, H225H248SignalsDescriptor* pvalue) { int stat = ASN_OK; stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)pvalue); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* GenericIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GenericIdentifier (OOCTXT* pctxt, H225GenericIdentifier* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* standard */ case 0: invokeStartElement (pctxt, "standard", -1); /* extension bit */ DECODEBIT (pctxt, &extbit); if (extbit == 0) { stat = decodeConsInteger (pctxt, &pvalue->u.standard, 0, 16383); if (stat != ASN_OK) return stat; } else { stat = decodeUnconsInteger (pctxt, &pvalue->u.standard); if (stat != ASN_OK) return stat; } invokeIntValue (pctxt, pvalue->u.standard); invokeEndElement (pctxt, "standard", -1); break; /* oid */ case 1: invokeStartElement (pctxt, "oid", -1); pvalue->u.oid = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.oid); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.oid->numids, pvalue->u.oid->subid); invokeEndElement (pctxt, "oid", -1); break; /* nonStandard */ case 2: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H225GloballyUniqueID); stat = asn1PD_H225GloballyUniqueID (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipAddress_ip */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipAddress_ip (OOCTXT* pctxt, H225TransportAddress_ipAddress_ip* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipAddress (OOCTXT* pctxt, H225TransportAddress_ipAddress* pvalue) { int stat = ASN_OK; /* decode ip */ invokeStartElement (pctxt, "ip", -1); stat = asn1PD_H225TransportAddress_ipAddress_ip (pctxt, &pvalue->ip); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ip", -1); /* decode port */ invokeStartElement (pctxt, "port", -1); stat = decodeConsUInt16 (pctxt, &pvalue->port, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->port); invokeEndElement (pctxt, "port", -1); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_ip */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipSourceRoute_ip (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_ip* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_route_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_route_element* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TransportAddress_ipSourceRoute_route_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225TransportAddress_ipSourceRoute_route_element (OOCTXT* pctxt, H225_SeqOfH225TransportAddress_ipSourceRoute_route_element* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, H225TransportAddress_ipSourceRoute_route_element); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H225TransportAddress_ipSourceRoute_route_element (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute_routing */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipSourceRoute_routing (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute_routing* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* strict */ case 0: invokeStartElement (pctxt, "strict", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "strict", -1); break; /* loose */ case 1: invokeStartElement (pctxt, "loose", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "loose", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipSourceRoute */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipSourceRoute (OOCTXT* pctxt, H225TransportAddress_ipSourceRoute* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode ip */ invokeStartElement (pctxt, "ip", -1); stat = asn1PD_H225TransportAddress_ipSourceRoute_ip (pctxt, &pvalue->ip); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ip", -1); /* decode port */ invokeStartElement (pctxt, "port", -1); stat = decodeConsUInt16 (pctxt, &pvalue->port, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->port); invokeEndElement (pctxt, "port", -1); /* decode route */ invokeStartElement (pctxt, "route", -1); stat = asn1PD_H225_SeqOfH225TransportAddress_ipSourceRoute_route_element (pctxt, &pvalue->route); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "route", -1); /* decode routing */ invokeStartElement (pctxt, "routing", -1); stat = asn1PD_H225TransportAddress_ipSourceRoute_routing (pctxt, &pvalue->routing); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "routing", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress_node */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipxAddress_node (OOCTXT* pctxt, H225TransportAddress_ipxAddress_node* pvalue) { static Asn1SizeCnst lsize1 = { 0, 6, 6, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress_netnum */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipxAddress_netnum (OOCTXT* pctxt, H225TransportAddress_ipxAddress_netnum* pvalue) { static Asn1SizeCnst lsize1 = { 0, 4, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress_port */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipxAddress_port (OOCTXT* pctxt, H225TransportAddress_ipxAddress_port* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 2, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ipxAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ipxAddress (OOCTXT* pctxt, H225TransportAddress_ipxAddress* pvalue) { int stat = ASN_OK; /* decode node */ invokeStartElement (pctxt, "node", -1); stat = asn1PD_H225TransportAddress_ipxAddress_node (pctxt, &pvalue->node); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "node", -1); /* decode netnum */ invokeStartElement (pctxt, "netnum", -1); stat = asn1PD_H225TransportAddress_ipxAddress_netnum (pctxt, &pvalue->netnum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "netnum", -1); /* decode port */ invokeStartElement (pctxt, "port", -1); stat = asn1PD_H225TransportAddress_ipxAddress_port (pctxt, &pvalue->port); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "port", -1); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ip6Address_ip */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ip6Address_ip (OOCTXT* pctxt, H225TransportAddress_ip6Address_ip* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TransportAddress_ip6Address */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_ip6Address (OOCTXT* pctxt, H225TransportAddress_ip6Address* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode ip */ invokeStartElement (pctxt, "ip", -1); stat = asn1PD_H225TransportAddress_ip6Address_ip (pctxt, &pvalue->ip); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ip", -1); /* decode port */ invokeStartElement (pctxt, "port", -1); stat = decodeConsUInt16 (pctxt, &pvalue->port, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->port); invokeEndElement (pctxt, "port", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TransportAddress_netBios */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_netBios (OOCTXT* pctxt, H225TransportAddress_netBios* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TransportAddress_nsap */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress_nsap (OOCTXT* pctxt, H225TransportAddress_nsap* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 20, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* H221NonStandard */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H221NonStandard (OOCTXT* pctxt, H225H221NonStandard* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode t35CountryCode */ invokeStartElement (pctxt, "t35CountryCode", -1); stat = decodeConsUInt8 (pctxt, &pvalue->t35CountryCode, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->t35CountryCode); invokeEndElement (pctxt, "t35CountryCode", -1); /* decode t35Extension */ invokeStartElement (pctxt, "t35Extension", -1); stat = decodeConsUInt8 (pctxt, &pvalue->t35Extension, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->t35Extension); invokeEndElement (pctxt, "t35Extension", -1); /* decode manufacturerCode */ invokeStartElement (pctxt, "manufacturerCode", -1); stat = decodeConsUInt16 (pctxt, &pvalue->manufacturerCode, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->manufacturerCode); invokeEndElement (pctxt, "manufacturerCode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* NonStandardIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225NonStandardIdentifier (OOCTXT* pctxt, H225NonStandardIdentifier* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* object */ case 0: invokeStartElement (pctxt, "object", -1); pvalue->u.object = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.object); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.object->numids, pvalue->u.object->subid); invokeEndElement (pctxt, "object", -1); break; /* h221NonStandard */ case 1: invokeStartElement (pctxt, "h221NonStandard", -1); pvalue->u.h221NonStandard = ALLOC_ASN1ELEM (pctxt, H225H221NonStandard); stat = asn1PD_H225H221NonStandard (pctxt, pvalue->u.h221NonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h221NonStandard", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H225NonStandardParameter (OOCTXT* pctxt, H225NonStandardParameter* pvalue) { int stat = ASN_OK; /* decode nonStandardIdentifier */ invokeStartElement (pctxt, "nonStandardIdentifier", -1); stat = asn1PD_H225NonStandardIdentifier (pctxt, &pvalue->nonStandardIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardIdentifier", -1); /* decode data */ invokeStartElement (pctxt, "data", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->data); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->data.numocts, pvalue->data.data); invokeEndElement (pctxt, "data", -1); return (stat); } /**************************************************************/ /* */ /* TransportAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportAddress (OOCTXT* pctxt, H225TransportAddress* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 6); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* ipAddress */ case 0: invokeStartElement (pctxt, "ipAddress", -1); pvalue->u.ipAddress = ALLOC_ASN1ELEM (pctxt, H225TransportAddress_ipAddress); stat = asn1PD_H225TransportAddress_ipAddress (pctxt, pvalue->u.ipAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ipAddress", -1); break; /* ipSourceRoute */ case 1: invokeStartElement (pctxt, "ipSourceRoute", -1); pvalue->u.ipSourceRoute = ALLOC_ASN1ELEM (pctxt, H225TransportAddress_ipSourceRoute); stat = asn1PD_H225TransportAddress_ipSourceRoute (pctxt, pvalue->u.ipSourceRoute); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ipSourceRoute", -1); break; /* ipxAddress */ case 2: invokeStartElement (pctxt, "ipxAddress", -1); pvalue->u.ipxAddress = ALLOC_ASN1ELEM (pctxt, H225TransportAddress_ipxAddress); stat = asn1PD_H225TransportAddress_ipxAddress (pctxt, pvalue->u.ipxAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ipxAddress", -1); break; /* ip6Address */ case 3: invokeStartElement (pctxt, "ip6Address", -1); pvalue->u.ip6Address = ALLOC_ASN1ELEM (pctxt, H225TransportAddress_ip6Address); stat = asn1PD_H225TransportAddress_ip6Address (pctxt, pvalue->u.ip6Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ip6Address", -1); break; /* netBios */ case 4: invokeStartElement (pctxt, "netBios", -1); pvalue->u.netBios = ALLOC_ASN1ELEM (pctxt, H225TransportAddress_netBios); stat = asn1PD_H225TransportAddress_netBios (pctxt, pvalue->u.netBios); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "netBios", -1); break; /* nsap */ case 5: invokeStartElement (pctxt, "nsap", -1); pvalue->u.nsap = ALLOC_ASN1ELEM (pctxt, H225TransportAddress_nsap); stat = asn1PD_H225TransportAddress_nsap (pctxt, pvalue->u.nsap); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nsap", -1); break; /* nonStandardAddress */ case 6: invokeStartElement (pctxt, "nonStandardAddress", -1); pvalue->u.nonStandardAddress = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandardAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardAddress", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 8; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* PublicTypeOfNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H225PublicTypeOfNumber (OOCTXT* pctxt, H225PublicTypeOfNumber* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unknown */ case 0: invokeStartElement (pctxt, "unknown", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unknown", -1); break; /* internationalNumber */ case 1: invokeStartElement (pctxt, "internationalNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "internationalNumber", -1); break; /* nationalNumber */ case 2: invokeStartElement (pctxt, "nationalNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nationalNumber", -1); break; /* networkSpecificNumber */ case 3: invokeStartElement (pctxt, "networkSpecificNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "networkSpecificNumber", -1); break; /* subscriberNumber */ case 4: invokeStartElement (pctxt, "subscriberNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "subscriberNumber", -1); break; /* abbreviatedNumber */ case 5: invokeStartElement (pctxt, "abbreviatedNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "abbreviatedNumber", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* PublicPartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H225PublicPartyNumber (OOCTXT* pctxt, H225PublicPartyNumber* pvalue) { int stat = ASN_OK; /* decode publicTypeOfNumber */ invokeStartElement (pctxt, "publicTypeOfNumber", -1); stat = asn1PD_H225PublicTypeOfNumber (pctxt, &pvalue->publicTypeOfNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "publicTypeOfNumber", -1); /* decode publicNumberDigits */ invokeStartElement (pctxt, "publicNumberDigits", -1); stat = asn1PD_H225NumberDigits (pctxt, &pvalue->publicNumberDigits); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "publicNumberDigits", -1); return (stat); } /**************************************************************/ /* */ /* PrivateTypeOfNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H225PrivateTypeOfNumber (OOCTXT* pctxt, H225PrivateTypeOfNumber* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unknown */ case 0: invokeStartElement (pctxt, "unknown", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unknown", -1); break; /* level2RegionalNumber */ case 1: invokeStartElement (pctxt, "level2RegionalNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "level2RegionalNumber", -1); break; /* level1RegionalNumber */ case 2: invokeStartElement (pctxt, "level1RegionalNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "level1RegionalNumber", -1); break; /* pISNSpecificNumber */ case 3: invokeStartElement (pctxt, "pISNSpecificNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "pISNSpecificNumber", -1); break; /* localNumber */ case 4: invokeStartElement (pctxt, "localNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "localNumber", -1); break; /* abbreviatedNumber */ case 5: invokeStartElement (pctxt, "abbreviatedNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "abbreviatedNumber", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* PrivatePartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H225PrivatePartyNumber (OOCTXT* pctxt, H225PrivatePartyNumber* pvalue) { int stat = ASN_OK; /* decode privateTypeOfNumber */ invokeStartElement (pctxt, "privateTypeOfNumber", -1); stat = asn1PD_H225PrivateTypeOfNumber (pctxt, &pvalue->privateTypeOfNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "privateTypeOfNumber", -1); /* decode privateNumberDigits */ invokeStartElement (pctxt, "privateNumberDigits", -1); stat = asn1PD_H225NumberDigits (pctxt, &pvalue->privateNumberDigits); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "privateNumberDigits", -1); return (stat); } /**************************************************************/ /* */ /* PartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H225PartyNumber (OOCTXT* pctxt, H225PartyNumber* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* e164Number */ case 0: invokeStartElement (pctxt, "e164Number", -1); pvalue->u.e164Number = ALLOC_ASN1ELEM (pctxt, H225PublicPartyNumber); stat = asn1PD_H225PublicPartyNumber (pctxt, pvalue->u.e164Number); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "e164Number", -1); break; /* dataPartyNumber */ case 1: invokeStartElement (pctxt, "dataPartyNumber", -1); stat = asn1PD_H225NumberDigits (pctxt, &pvalue->u.dataPartyNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataPartyNumber", -1); break; /* telexPartyNumber */ case 2: invokeStartElement (pctxt, "telexPartyNumber", -1); stat = asn1PD_H225NumberDigits (pctxt, &pvalue->u.telexPartyNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "telexPartyNumber", -1); break; /* privateNumber */ case 3: invokeStartElement (pctxt, "privateNumber", -1); pvalue->u.privateNumber = ALLOC_ASN1ELEM (pctxt, H225PrivatePartyNumber); stat = asn1PD_H225PrivatePartyNumber (pctxt, pvalue->u.privateNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "privateNumber", -1); break; /* nationalStandardPartyNumber */ case 4: invokeStartElement (pctxt, "nationalStandardPartyNumber", -1); stat = asn1PD_H225NumberDigits (pctxt, &pvalue->u.nationalStandardPartyNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nationalStandardPartyNumber", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_system_id */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_system_id_sid_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_system_id_mid_CharSet; EXTERN int asn1PD_H225ANSI_41_UIM_system_id (OOCTXT* pctxt, H225ANSI_41_UIM_system_id* pvalue) { static Asn1SizeCnst sid_lsize1 = { 0, 1, 4, 0 }; static Asn1SizeCnst mid_lsize1 = { 0, 1, 4, 0 }; int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* sid */ case 0: invokeStartElement (pctxt, "sid", -1); addSizeConstraint (pctxt, &sid_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.sid, gs_H323_MESSAGES_ANSI_41_UIM_system_id_sid_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.sid); invokeEndElement (pctxt, "sid", -1); break; /* mid */ case 1: invokeStartElement (pctxt, "mid", -1); addSizeConstraint (pctxt, &mid_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.mid, gs_H323_MESSAGES_ANSI_41_UIM_system_id_mid_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.mid); invokeEndElement (pctxt, "mid", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_systemMyTypeCode */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ANSI_41_UIM_systemMyTypeCode (OOCTXT* pctxt, H225ANSI_41_UIM_systemMyTypeCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_systemAccessType */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ANSI_41_UIM_systemAccessType (OOCTXT* pctxt, H225ANSI_41_UIM_systemAccessType* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM_qualificationInformationCode */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ANSI_41_UIM_qualificationInformationCode (OOCTXT* pctxt, H225ANSI_41_UIM_qualificationInformationCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 1, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ANSI_41_UIM */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_imsi_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_min_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_mdn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_msisdn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_esn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_mscid_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_sesn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_soc_CharSet; EXTERN int asn1PD_H225ANSI_41_UIM (OOCTXT* pctxt, H225ANSI_41_UIM* pvalue) { static Asn1SizeCnst imsi_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst min_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst mdn_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst msisdn_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst esn_lsize1 = { 0, 16, 16, 0 }; static Asn1SizeCnst mscid_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst sesn_lsize1 = { 0, 16, 16, 0 }; static Asn1SizeCnst soc_lsize1 = { 0, 3, 16, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.imsiPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.minPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mdnPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.msisdnPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.esnPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mscidPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.systemMyTypeCodePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.systemAccessTypePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.qualificationInformationCodePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.sesnPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.socPresent = optbit; /* decode imsi */ if (pvalue->m.imsiPresent) { invokeStartElement (pctxt, "imsi", -1); addSizeConstraint (pctxt, &imsi_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->imsi, gs_H323_MESSAGES_ANSI_41_UIM_imsi_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->imsi); invokeEndElement (pctxt, "imsi", -1); } /* decode min */ if (pvalue->m.minPresent) { invokeStartElement (pctxt, "min", -1); addSizeConstraint (pctxt, &min_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->min, gs_H323_MESSAGES_ANSI_41_UIM_min_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->min); invokeEndElement (pctxt, "min", -1); } /* decode mdn */ if (pvalue->m.mdnPresent) { invokeStartElement (pctxt, "mdn", -1); addSizeConstraint (pctxt, &mdn_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->mdn, gs_H323_MESSAGES_ANSI_41_UIM_mdn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->mdn); invokeEndElement (pctxt, "mdn", -1); } /* decode msisdn */ if (pvalue->m.msisdnPresent) { invokeStartElement (pctxt, "msisdn", -1); addSizeConstraint (pctxt, &msisdn_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->msisdn, gs_H323_MESSAGES_ANSI_41_UIM_msisdn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->msisdn); invokeEndElement (pctxt, "msisdn", -1); } /* decode esn */ if (pvalue->m.esnPresent) { invokeStartElement (pctxt, "esn", -1); addSizeConstraint (pctxt, &esn_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->esn, gs_H323_MESSAGES_ANSI_41_UIM_esn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->esn); invokeEndElement (pctxt, "esn", -1); } /* decode mscid */ if (pvalue->m.mscidPresent) { invokeStartElement (pctxt, "mscid", -1); addSizeConstraint (pctxt, &mscid_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->mscid, gs_H323_MESSAGES_ANSI_41_UIM_mscid_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->mscid); invokeEndElement (pctxt, "mscid", -1); } /* decode system_id */ invokeStartElement (pctxt, "system_id", -1); stat = asn1PD_H225ANSI_41_UIM_system_id (pctxt, &pvalue->system_id); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "system_id", -1); /* decode systemMyTypeCode */ if (pvalue->m.systemMyTypeCodePresent) { invokeStartElement (pctxt, "systemMyTypeCode", -1); stat = asn1PD_H225ANSI_41_UIM_systemMyTypeCode (pctxt, &pvalue->systemMyTypeCode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "systemMyTypeCode", -1); } /* decode systemAccessType */ if (pvalue->m.systemAccessTypePresent) { invokeStartElement (pctxt, "systemAccessType", -1); stat = asn1PD_H225ANSI_41_UIM_systemAccessType (pctxt, &pvalue->systemAccessType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "systemAccessType", -1); } /* decode qualificationInformationCode */ if (pvalue->m.qualificationInformationCodePresent) { invokeStartElement (pctxt, "qualificationInformationCode", -1); stat = asn1PD_H225ANSI_41_UIM_qualificationInformationCode (pctxt, &pvalue->qualificationInformationCode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "qualificationInformationCode", -1); } /* decode sesn */ if (pvalue->m.sesnPresent) { invokeStartElement (pctxt, "sesn", -1); addSizeConstraint (pctxt, &sesn_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->sesn, gs_H323_MESSAGES_ANSI_41_UIM_sesn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->sesn); invokeEndElement (pctxt, "sesn", -1); } /* decode soc */ if (pvalue->m.socPresent) { invokeStartElement (pctxt, "soc", -1); addSizeConstraint (pctxt, &soc_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->soc, gs_H323_MESSAGES_ANSI_41_UIM_soc_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->soc); invokeEndElement (pctxt, "soc", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* GSM_UIM_tmsi */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GSM_UIM_tmsi (OOCTXT* pctxt, H225GSM_UIM_tmsi* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* GSM_UIM */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_imsi_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_msisdn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_imei_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_hplmn_CharSet; extern EXTERN const char* gs_H323_MESSAGES_GSM_UIM_vplmn_CharSet; EXTERN int asn1PD_H225GSM_UIM (OOCTXT* pctxt, H225GSM_UIM* pvalue) { static Asn1SizeCnst imsi_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst msisdn_lsize1 = { 0, 3, 16, 0 }; static Asn1SizeCnst imei_lsize1 = { 0, 15, 16, 0 }; static Asn1SizeCnst hplmn_lsize1 = { 0, 1, 4, 0 }; static Asn1SizeCnst vplmn_lsize1 = { 0, 1, 4, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.imsiPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tmsiPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.msisdnPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.imeiPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.hplmnPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.vplmnPresent = optbit; /* decode imsi */ if (pvalue->m.imsiPresent) { invokeStartElement (pctxt, "imsi", -1); addSizeConstraint (pctxt, &imsi_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->imsi, gs_H323_MESSAGES_GSM_UIM_imsi_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->imsi); invokeEndElement (pctxt, "imsi", -1); } /* decode tmsi */ if (pvalue->m.tmsiPresent) { invokeStartElement (pctxt, "tmsi", -1); stat = asn1PD_H225GSM_UIM_tmsi (pctxt, &pvalue->tmsi); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tmsi", -1); } /* decode msisdn */ if (pvalue->m.msisdnPresent) { invokeStartElement (pctxt, "msisdn", -1); addSizeConstraint (pctxt, &msisdn_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->msisdn, gs_H323_MESSAGES_GSM_UIM_msisdn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->msisdn); invokeEndElement (pctxt, "msisdn", -1); } /* decode imei */ if (pvalue->m.imeiPresent) { invokeStartElement (pctxt, "imei", -1); addSizeConstraint (pctxt, &imei_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->imei, gs_H323_MESSAGES_GSM_UIM_imei_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->imei); invokeEndElement (pctxt, "imei", -1); } /* decode hplmn */ if (pvalue->m.hplmnPresent) { invokeStartElement (pctxt, "hplmn", -1); addSizeConstraint (pctxt, &hplmn_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->hplmn, gs_H323_MESSAGES_GSM_UIM_hplmn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->hplmn); invokeEndElement (pctxt, "hplmn", -1); } /* decode vplmn */ if (pvalue->m.vplmnPresent) { invokeStartElement (pctxt, "vplmn", -1); addSizeConstraint (pctxt, &vplmn_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->vplmn, gs_H323_MESSAGES_GSM_UIM_vplmn_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->vplmn); invokeEndElement (pctxt, "vplmn", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* MobileUIM */ /* */ /**************************************************************/ EXTERN int asn1PD_H225MobileUIM (OOCTXT* pctxt, H225MobileUIM* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* ansi_41_uim */ case 0: invokeStartElement (pctxt, "ansi_41_uim", -1); pvalue->u.ansi_41_uim = ALLOC_ASN1ELEM (pctxt, H225ANSI_41_UIM); stat = asn1PD_H225ANSI_41_UIM (pctxt, pvalue->u.ansi_41_uim); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ansi_41_uim", -1); break; /* gsm_uim */ case 1: invokeStartElement (pctxt, "gsm_uim", -1); pvalue->u.gsm_uim = ALLOC_ASN1ELEM (pctxt, H225GSM_UIM); stat = asn1PD_H225GSM_UIM (pctxt, pvalue->u.gsm_uim); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gsm_uim", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* AliasAddress */ /* */ /**************************************************************/ extern EXTERN const char* gs_H323_MESSAGES_AliasAddress_dialedDigits_CharSet; EXTERN int asn1PD_H225AliasAddress (OOCTXT* pctxt, H225AliasAddress* pvalue) { static Asn1SizeCnst dialedDigits_lsize1 = { 0, 1, 128, 0 }; static Asn1SizeCnst h323_ID_lsize1 = { 0, 1, 256, 0 }; static Asn1SizeCnst url_ID_lsize1 = { 0, 1, 512, 0 }; static Asn1SizeCnst email_ID_lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* dialedDigits */ case 0: invokeStartElement (pctxt, "dialedDigits", -1); addSizeConstraint (pctxt, &dialedDigits_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.dialedDigits, gs_H323_MESSAGES_AliasAddress_dialedDigits_CharSet, 4, 4, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.dialedDigits); invokeEndElement (pctxt, "dialedDigits", -1); break; /* h323_ID */ case 1: invokeStartElement (pctxt, "h323_ID", -1); addSizeConstraint (pctxt, &h323_ID_lsize1); stat = decodeBMPString (pctxt, &pvalue->u.h323_ID, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->u.h323_ID.nchars, pvalue->u.h323_ID.data); invokeEndElement (pctxt, "h323_ID", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* url_ID */ case 3: invokeStartElement (pctxt, "url_ID", -1); addSizeConstraint (pctxt, &url_ID_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.url_ID, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.url_ID); invokeEndElement (pctxt, "url_ID", -1); break; /* transportID */ case 4: invokeStartElement (pctxt, "transportID", -1); pvalue->u.transportID = ALLOC_ASN1ELEM (pctxt, H225TransportAddress); stat = asn1PD_H225TransportAddress (pctxt, pvalue->u.transportID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transportID", -1); break; /* email_ID */ case 5: invokeStartElement (pctxt, "email_ID", -1); addSizeConstraint (pctxt, &email_ID_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.email_ID, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.email_ID); invokeEndElement (pctxt, "email_ID", -1); break; /* partyNumber */ case 6: invokeStartElement (pctxt, "partyNumber", -1); pvalue->u.partyNumber = ALLOC_ASN1ELEM (pctxt, H225PartyNumber); stat = asn1PD_H225PartyNumber (pctxt, pvalue->u.partyNumber); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "partyNumber", -1); break; /* mobileUIM */ case 7: invokeStartElement (pctxt, "mobileUIM", -1); pvalue->u.mobileUIM = ALLOC_ASN1ELEM (pctxt, H225MobileUIM); stat = asn1PD_H225MobileUIM (pctxt, pvalue->u.mobileUIM); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mobileUIM", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* Content_compound */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Content_compound (OOCTXT* pctxt, H225Content_compound* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; H225EnumeratedParameter* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225EnumeratedParameter); stat = asn1PD_H225EnumeratedParameter (pctxt, (H225EnumeratedParameter*)pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* Content_nested */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Content_nested (OOCTXT* pctxt, H225Content_nested* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 16, 0 }; int stat = ASN_OK; H225GenericData* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225GenericData); stat = asn1PD_H225GenericData (pctxt, (H225GenericData*)pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* Content */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Content (OOCTXT* pctxt, H225Content* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 11); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* raw */ case 0: invokeStartElement (pctxt, "raw", -1); pvalue->u.raw = ALLOC_ASN1ELEM (pctxt, ASN1DynOctStr); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)pvalue->u.raw); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->u.raw->numocts, pvalue->u.raw->data); invokeEndElement (pctxt, "raw", -1); break; /* text */ case 1: invokeStartElement (pctxt, "text", -1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.text, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.text); invokeEndElement (pctxt, "text", -1); break; /* unicode */ case 2: invokeStartElement (pctxt, "unicode", -1); stat = decodeBMPString (pctxt, &pvalue->u.unicode, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->u.unicode.nchars, pvalue->u.unicode.data); invokeEndElement (pctxt, "unicode", -1); break; /* bool_ */ case 3: invokeStartElement (pctxt, "bool_", -1); stat = DECODEBIT (pctxt, &pvalue->u.bool_); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->u.bool_); invokeEndElement (pctxt, "bool_", -1); break; /* number8 */ case 4: invokeStartElement (pctxt, "number8", -1); stat = decodeConsUInt8 (pctxt, &pvalue->u.number8, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.number8); invokeEndElement (pctxt, "number8", -1); break; /* number16 */ case 5: invokeStartElement (pctxt, "number16", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.number16, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.number16); invokeEndElement (pctxt, "number16", -1); break; /* number32 */ case 6: invokeStartElement (pctxt, "number32", -1); stat = decodeConsUnsigned (pctxt, &pvalue->u.number32, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.number32); invokeEndElement (pctxt, "number32", -1); break; /* id */ case 7: invokeStartElement (pctxt, "id", -1); pvalue->u.id = ALLOC_ASN1ELEM (pctxt, H225GenericIdentifier); stat = asn1PD_H225GenericIdentifier (pctxt, pvalue->u.id); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "id", -1); break; /* alias */ case 8: invokeStartElement (pctxt, "alias", -1); pvalue->u.alias = ALLOC_ASN1ELEM (pctxt, H225AliasAddress); stat = asn1PD_H225AliasAddress (pctxt, pvalue->u.alias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alias", -1); break; /* transport */ case 9: invokeStartElement (pctxt, "transport", -1); pvalue->u.transport = ALLOC_ASN1ELEM (pctxt, H225TransportAddress); stat = asn1PD_H225TransportAddress (pctxt, pvalue->u.transport); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transport", -1); break; /* compound */ case 10: invokeStartElement (pctxt, "compound", -1); pvalue->u.compound = ALLOC_ASN1ELEM (pctxt, H225Content_compound); stat = asn1PD_H225Content_compound (pctxt, pvalue->u.compound); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "compound", -1); break; /* nested */ case 11: invokeStartElement (pctxt, "nested", -1); pvalue->u.nested = ALLOC_ASN1ELEM (pctxt, H225Content_nested); stat = asn1PD_H225Content_nested (pctxt, pvalue->u.nested); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nested", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 13; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EnumeratedParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H225EnumeratedParameter (OOCTXT* pctxt, H225EnumeratedParameter* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.contentPresent = optbit; /* decode id */ invokeStartElement (pctxt, "id", -1); stat = asn1PD_H225GenericIdentifier (pctxt, &pvalue->id); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "id", -1); /* decode content */ if (pvalue->m.contentPresent) { invokeStartElement (pctxt, "content", -1); stat = asn1PD_H225Content (pctxt, &pvalue->content); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "content", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* GenericData_parameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GenericData_parameters (OOCTXT* pctxt, H225GenericData_parameters* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; H225EnumeratedParameter* pdata; ASN1UINT count = 0; ASN1UINT xx1; /* decode length determinant */ addSizeConstraint (pctxt, &lsize1); stat = decodeLength (pctxt, &count); if (stat != ASN_OK) return stat; /* decode elements */ dListInit (pvalue); for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225EnumeratedParameter); stat = asn1PD_H225EnumeratedParameter (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } return (stat); } /**************************************************************/ /* */ /* GenericData */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GenericData (OOCTXT* pctxt, H225GenericData* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.parametersPresent = optbit; /* decode id */ invokeStartElement (pctxt, "id", -1); stat = asn1PD_H225GenericIdentifier (pctxt, &pvalue->id); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "id", -1); /* decode parameters */ if (pvalue->m.parametersPresent) { invokeStartElement (pctxt, "parameters", -1); stat = asn1PD_H225GenericData_parameters (pctxt, &pvalue->parameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "parameters", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* FeatureDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H225FeatureDescriptor (OOCTXT* pctxt, H225FeatureDescriptor* pvalue) { int stat = ASN_OK; stat = asn1PD_H225GenericData (pctxt, pvalue); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* FastStartToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H225FastStartToken (OOCTXT* pctxt, H225FastStartToken* pvalue) { int stat = ASN_OK; stat = asn1PD_H235ClearToken (pctxt, pvalue); if (stat != ASN_OK) return stat; return (stat); } /**************************************************************/ /* */ /* EncodedFastStartToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H225EncodedFastStartToken (OOCTXT* pctxt, H225EncodedFastStartToken* pvalue) { int stat = ASN_OK; stat = decodeOpenType (pctxt, &pvalue->data, &pvalue->numocts); if (stat != ASN_OK) return stat; invokeOpenTypeValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* H323_UserInformation_user_data_user_information */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UserInformation_user_data_user_information (OOCTXT* pctxt, H225H323_UserInformation_user_data_user_information* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 131, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* EndpointType_set */ /* */ /**************************************************************/ EXTERN int asn1PD_H225EndpointType_set (OOCTXT* pctxt, H225EndpointType_set* pvalue) { static Asn1SizeCnst lsize1 = { 0, 32, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* VendorIdentifier_productId */ /* */ /**************************************************************/ EXTERN int asn1PD_H225VendorIdentifier_productId (OOCTXT* pctxt, H225VendorIdentifier_productId* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* VendorIdentifier_versionId */ /* */ /**************************************************************/ EXTERN int asn1PD_H225VendorIdentifier_versionId (OOCTXT* pctxt, H225VendorIdentifier_versionId* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 256, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* CicInfo_cic_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CicInfo_cic_element (OOCTXT* pctxt, H225CicInfo_cic_element* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* CicInfo_pointCode */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CicInfo_pointCode (OOCTXT* pctxt, H225CicInfo_pointCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 5, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* CarrierInfo_carrierIdentificationCode */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CarrierInfo_carrierIdentificationCode (OOCTXT* pctxt, H225CarrierInfo_carrierIdentificationCode* pvalue) { static Asn1SizeCnst lsize1 = { 0, 3, 4, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* CallTerminationCause_releaseCompleteCauseIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallTerminationCause_releaseCompleteCauseIE (OOCTXT* pctxt, H225CallTerminationCause_releaseCompleteCauseIE* pvalue) { static Asn1SizeCnst lsize1 = { 0, 2, 32, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AliasAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225AliasAddress (OOCTXT* pctxt, H225_SeqOfH225AliasAddress* pvalue) { int stat = ASN_OK; H225AliasAddress* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225AliasAddress); stat = asn1PD_H225AliasAddress (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* VendorIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225VendorIdentifier (OOCTXT* pctxt, H225VendorIdentifier* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.productIdPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.versionIdPresent = optbit; /* decode vendor */ invokeStartElement (pctxt, "vendor", -1); stat = asn1PD_H225H221NonStandard (pctxt, &pvalue->vendor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "vendor", -1); /* decode productId */ if (pvalue->m.productIdPresent) { invokeStartElement (pctxt, "productId", -1); stat = asn1PD_H225VendorIdentifier_productId (pctxt, &pvalue->productId); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "productId", -1); } /* decode versionId */ if (pvalue->m.versionIdPresent) { invokeStartElement (pctxt, "versionId", -1); stat = asn1PD_H225VendorIdentifier_versionId (pctxt, &pvalue->versionId); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "versionId", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.enterpriseNumberPresent = 1; invokeStartElement (pctxt, "enterpriseNumber", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->enterpriseNumber); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->enterpriseNumber.numids, pvalue->enterpriseNumber.subid); invokeEndElement (pctxt, "enterpriseNumber", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* GatekeeperInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatekeeperInfo (OOCTXT* pctxt, H225GatekeeperInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* DataRate */ /* */ /**************************************************************/ EXTERN int asn1PD_H225DataRate (OOCTXT* pctxt, H225DataRate* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.channelMultiplierPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode channelRate */ invokeStartElement (pctxt, "channelRate", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->channelRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "channelRate", -1); /* decode channelMultiplier */ if (pvalue->m.channelMultiplierPresent) { invokeStartElement (pctxt, "channelMultiplier", -1); stat = decodeConsUInt16 (pctxt, &pvalue->channelMultiplier, 1U, 256U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->channelMultiplier); invokeEndElement (pctxt, "channelMultiplier", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225DataRate */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225DataRate (OOCTXT* pctxt, H225_SeqOfH225DataRate* pvalue) { int stat = ASN_OK; H225DataRate* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225DataRate); stat = asn1PD_H225DataRate (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* SupportedPrefix */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SupportedPrefix (OOCTXT* pctxt, H225SupportedPrefix* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode prefix */ invokeStartElement (pctxt, "prefix", -1); stat = asn1PD_H225AliasAddress (pctxt, &pvalue->prefix); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "prefix", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225SupportedPrefix */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225SupportedPrefix (OOCTXT* pctxt, H225_SeqOfH225SupportedPrefix* pvalue) { int stat = ASN_OK; H225SupportedPrefix* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225SupportedPrefix); stat = asn1PD_H225SupportedPrefix (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* H310Caps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H310Caps (OOCTXT* pctxt, H225H310Caps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H320Caps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H320Caps (OOCTXT* pctxt, H225H320Caps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H321Caps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H321Caps (OOCTXT* pctxt, H225H321Caps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H322Caps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H322Caps (OOCTXT* pctxt, H225H322Caps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H323Caps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323Caps (OOCTXT* pctxt, H225H323Caps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H324Caps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H324Caps (OOCTXT* pctxt, H225H324Caps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* VoiceCaps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225VoiceCaps (OOCTXT* pctxt, H225VoiceCaps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* T120OnlyCaps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225T120OnlyCaps (OOCTXT* pctxt, H225T120OnlyCaps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.dataRatesSupportedPresent = 1; invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); break; case 1: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* NonStandardProtocol */ /* */ /**************************************************************/ EXTERN int asn1PD_H225NonStandardProtocol (OOCTXT* pctxt, H225NonStandardProtocol* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.dataRatesSupportedPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode dataRatesSupported */ if (pvalue->m.dataRatesSupportedPresent) { invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); } /* decode supportedPrefixes */ invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* T38FaxAnnexbOnlyCaps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225T38FaxAnnexbOnlyCaps (OOCTXT* pctxt, H225T38FaxAnnexbOnlyCaps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.dataRatesSupportedPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode dataRatesSupported */ if (pvalue->m.dataRatesSupportedPresent) { invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); } /* decode supportedPrefixes */ invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); /* decode t38FaxProtocol */ invokeStartElement (pctxt, "t38FaxProtocol", -1); stat = asn1PD_H245DataProtocolCapability (pctxt, &pvalue->t38FaxProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxProtocol", -1); /* decode t38FaxProfile */ invokeStartElement (pctxt, "t38FaxProfile", -1); stat = asn1PD_H245T38FaxProfile (pctxt, &pvalue->t38FaxProfile); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxProfile", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SIPCaps */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SIPCaps (OOCTXT* pctxt, H225SIPCaps* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.dataRatesSupportedPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.supportedPrefixesPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode dataRatesSupported */ if (pvalue->m.dataRatesSupportedPresent) { invokeStartElement (pctxt, "dataRatesSupported", -1); stat = asn1PD_H225_SeqOfH225DataRate (pctxt, &pvalue->dataRatesSupported); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dataRatesSupported", -1); } /* decode supportedPrefixes */ if (pvalue->m.supportedPrefixesPresent) { invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SupportedProtocols */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SupportedProtocols (OOCTXT* pctxt, H225SupportedProtocols* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 8); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandardData */ case 0: invokeStartElement (pctxt, "nonStandardData", -1); pvalue->u.nonStandardData = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); break; /* h310 */ case 1: invokeStartElement (pctxt, "h310", -1); pvalue->u.h310 = ALLOC_ASN1ELEM (pctxt, H225H310Caps); stat = asn1PD_H225H310Caps (pctxt, pvalue->u.h310); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h310", -1); break; /* h320 */ case 2: invokeStartElement (pctxt, "h320", -1); pvalue->u.h320 = ALLOC_ASN1ELEM (pctxt, H225H320Caps); stat = asn1PD_H225H320Caps (pctxt, pvalue->u.h320); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h320", -1); break; /* h321 */ case 3: invokeStartElement (pctxt, "h321", -1); pvalue->u.h321 = ALLOC_ASN1ELEM (pctxt, H225H321Caps); stat = asn1PD_H225H321Caps (pctxt, pvalue->u.h321); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h321", -1); break; /* h322 */ case 4: invokeStartElement (pctxt, "h322", -1); pvalue->u.h322 = ALLOC_ASN1ELEM (pctxt, H225H322Caps); stat = asn1PD_H225H322Caps (pctxt, pvalue->u.h322); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h322", -1); break; /* h323 */ case 5: invokeStartElement (pctxt, "h323", -1); pvalue->u.h323 = ALLOC_ASN1ELEM (pctxt, H225H323Caps); stat = asn1PD_H225H323Caps (pctxt, pvalue->u.h323); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h323", -1); break; /* h324 */ case 6: invokeStartElement (pctxt, "h324", -1); pvalue->u.h324 = ALLOC_ASN1ELEM (pctxt, H225H324Caps); stat = asn1PD_H225H324Caps (pctxt, pvalue->u.h324); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h324", -1); break; /* voice */ case 7: invokeStartElement (pctxt, "voice", -1); pvalue->u.voice = ALLOC_ASN1ELEM (pctxt, H225VoiceCaps); stat = asn1PD_H225VoiceCaps (pctxt, pvalue->u.voice); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "voice", -1); break; /* t120_only */ case 8: invokeStartElement (pctxt, "t120_only", -1); pvalue->u.t120_only = ALLOC_ASN1ELEM (pctxt, H225T120OnlyCaps); stat = asn1PD_H225T120OnlyCaps (pctxt, pvalue->u.t120_only); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t120_only", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 10; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* nonStandardProtocol */ case 10: invokeStartElement (pctxt, "nonStandardProtocol", -1); pvalue->u.nonStandardProtocol = ALLOC_ASN1ELEM (pctxt, H225NonStandardProtocol); stat = asn1PD_H225NonStandardProtocol (pctxt, pvalue->u.nonStandardProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardProtocol", -1); break; /* t38FaxAnnexbOnly */ case 11: invokeStartElement (pctxt, "t38FaxAnnexbOnly", -1); pvalue->u.t38FaxAnnexbOnly = ALLOC_ASN1ELEM (pctxt, H225T38FaxAnnexbOnlyCaps); stat = asn1PD_H225T38FaxAnnexbOnlyCaps (pctxt, pvalue->u.t38FaxAnnexbOnly); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxAnnexbOnly", -1); break; /* sip */ case 12: invokeStartElement (pctxt, "sip", -1); pvalue->u.sip = ALLOC_ASN1ELEM (pctxt, H225SIPCaps); stat = asn1PD_H225SIPCaps (pctxt, pvalue->u.sip); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sip", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225SupportedProtocols */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225SupportedProtocols (OOCTXT* pctxt, H225_SeqOfH225SupportedProtocols* pvalue) { int stat = ASN_OK; H225SupportedProtocols* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225SupportedProtocols); stat = asn1PD_H225SupportedProtocols (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* GatewayInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatewayInfo (OOCTXT* pctxt, H225GatewayInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.protocolPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode protocol */ if (pvalue->m.protocolPresent) { invokeStartElement (pctxt, "protocol", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->protocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocol", -1); } /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* McuInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225McuInfo (OOCTXT* pctxt, H225McuInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.protocolPresent = 1; invokeStartElement (pctxt, "protocol", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->protocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocol", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* TerminalInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TerminalInfo (OOCTXT* pctxt, H225TerminalInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TunnelledProtocolAlternateIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TunnelledProtocolAlternateIdentifier (OOCTXT* pctxt, H225TunnelledProtocolAlternateIdentifier* pvalue) { static Asn1SizeCnst protocolType_lsize1 = { 0, 1, 64, 0 }; static Asn1SizeCnst protocolVariant_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.protocolVariantPresent = optbit; /* decode protocolType */ invokeStartElement (pctxt, "protocolType", -1); addSizeConstraint (pctxt, &protocolType_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->protocolType, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->protocolType); invokeEndElement (pctxt, "protocolType", -1); /* decode protocolVariant */ if (pvalue->m.protocolVariantPresent) { invokeStartElement (pctxt, "protocolVariant", -1); addSizeConstraint (pctxt, &protocolVariant_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->protocolVariant, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->protocolVariant); invokeEndElement (pctxt, "protocolVariant", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TunnelledProtocol_id */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TunnelledProtocol_id (OOCTXT* pctxt, H225TunnelledProtocol_id* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* tunnelledProtocolObjectID */ case 0: invokeStartElement (pctxt, "tunnelledProtocolObjectID", -1); pvalue->u.tunnelledProtocolObjectID = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.tunnelledProtocolObjectID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.tunnelledProtocolObjectID->numids, pvalue->u.tunnelledProtocolObjectID->subid); invokeEndElement (pctxt, "tunnelledProtocolObjectID", -1); break; /* tunnelledProtocolAlternateID */ case 1: invokeStartElement (pctxt, "tunnelledProtocolAlternateID", -1); pvalue->u.tunnelledProtocolAlternateID = ALLOC_ASN1ELEM (pctxt, H225TunnelledProtocolAlternateIdentifier); stat = asn1PD_H225TunnelledProtocolAlternateIdentifier (pctxt, pvalue->u.tunnelledProtocolAlternateID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tunnelledProtocolAlternateID", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TunnelledProtocol */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TunnelledProtocol (OOCTXT* pctxt, H225TunnelledProtocol* pvalue) { static Asn1SizeCnst subIdentifier_lsize1 = { 0, 1, 64, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.subIdentifierPresent = optbit; /* decode id */ invokeStartElement (pctxt, "id", -1); stat = asn1PD_H225TunnelledProtocol_id (pctxt, &pvalue->id); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "id", -1); /* decode subIdentifier */ if (pvalue->m.subIdentifierPresent) { invokeStartElement (pctxt, "subIdentifier", -1); addSizeConstraint (pctxt, &subIdentifier_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->subIdentifier, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->subIdentifier); invokeEndElement (pctxt, "subIdentifier", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TunnelledProtocol */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225TunnelledProtocol (OOCTXT* pctxt, H225_SeqOfH225TunnelledProtocol* pvalue) { int stat = ASN_OK; H225TunnelledProtocol* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225TunnelledProtocol); stat = asn1PD_H225TunnelledProtocol (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* EndpointType */ /* */ /**************************************************************/ EXTERN int asn1PD_H225EndpointType (OOCTXT* pctxt, H225EndpointType* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.vendorPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatewayPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mcuPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.terminalPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode vendor */ if (pvalue->m.vendorPresent) { invokeStartElement (pctxt, "vendor", -1); stat = asn1PD_H225VendorIdentifier (pctxt, &pvalue->vendor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "vendor", -1); } /* decode gatekeeper */ if (pvalue->m.gatekeeperPresent) { invokeStartElement (pctxt, "gatekeeper", -1); stat = asn1PD_H225GatekeeperInfo (pctxt, &pvalue->gatekeeper); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeper", -1); } /* decode gateway */ if (pvalue->m.gatewayPresent) { invokeStartElement (pctxt, "gateway", -1); stat = asn1PD_H225GatewayInfo (pctxt, &pvalue->gateway); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gateway", -1); } /* decode mcu */ if (pvalue->m.mcuPresent) { invokeStartElement (pctxt, "mcu", -1); stat = asn1PD_H225McuInfo (pctxt, &pvalue->mcu); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mcu", -1); } /* decode terminal */ if (pvalue->m.terminalPresent) { invokeStartElement (pctxt, "terminal", -1); stat = asn1PD_H225TerminalInfo (pctxt, &pvalue->terminal); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminal", -1); } /* decode mc */ invokeStartElement (pctxt, "mc", -1); stat = DECODEBIT (pctxt, &pvalue->mc); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->mc); invokeEndElement (pctxt, "mc", -1); /* decode undefinedNode */ invokeStartElement (pctxt, "undefinedNode", -1); stat = DECODEBIT (pctxt, &pvalue->undefinedNode); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->undefinedNode); invokeEndElement (pctxt, "undefinedNode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.setPresent = 1; invokeStartElement (pctxt, "set", -1); stat = asn1PD_H225EndpointType_set (pctxt, &pvalue->set); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "set", -1); break; case 1: pvalue->m.supportedTunnelledProtocolsPresent = 1; invokeStartElement (pctxt, "supportedTunnelledProtocols", -1); stat = asn1PD_H225_SeqOfH225TunnelledProtocol (pctxt, &pvalue->supportedTunnelledProtocols); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedTunnelledProtocols", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CallReferenceValue */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225CallReferenceValue (OOCTXT* pctxt, H225_SeqOfH225CallReferenceValue* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, H225CallReferenceValue); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H225CallReferenceValue (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_conferenceGoal */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Setup_UUIE_conferenceGoal (OOCTXT* pctxt, H225Setup_UUIE_conferenceGoal* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* create */ case 0: invokeStartElement (pctxt, "create", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "create", -1); break; /* join */ case 1: invokeStartElement (pctxt, "join", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "join", -1); break; /* invite */ case 2: invokeStartElement (pctxt, "invite", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invite", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* capability_negotiation */ case 4: invokeStartElement (pctxt, "capability_negotiation", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "capability_negotiation", -1); break; /* callIndependentSupplementaryService */ case 5: invokeStartElement (pctxt, "callIndependentSupplementaryService", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "callIndependentSupplementaryService", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* Q954Details */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Q954Details (OOCTXT* pctxt, H225Q954Details* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode conferenceCalling */ invokeStartElement (pctxt, "conferenceCalling", -1); stat = DECODEBIT (pctxt, &pvalue->conferenceCalling); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->conferenceCalling); invokeEndElement (pctxt, "conferenceCalling", -1); /* decode threePartyService */ invokeStartElement (pctxt, "threePartyService", -1); stat = DECODEBIT (pctxt, &pvalue->threePartyService); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->threePartyService); invokeEndElement (pctxt, "threePartyService", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* QseriesOptions */ /* */ /**************************************************************/ EXTERN int asn1PD_H225QseriesOptions (OOCTXT* pctxt, H225QseriesOptions* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode q932Full */ invokeStartElement (pctxt, "q932Full", -1); stat = DECODEBIT (pctxt, &pvalue->q932Full); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->q932Full); invokeEndElement (pctxt, "q932Full", -1); /* decode q951Full */ invokeStartElement (pctxt, "q951Full", -1); stat = DECODEBIT (pctxt, &pvalue->q951Full); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->q951Full); invokeEndElement (pctxt, "q951Full", -1); /* decode q952Full */ invokeStartElement (pctxt, "q952Full", -1); stat = DECODEBIT (pctxt, &pvalue->q952Full); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->q952Full); invokeEndElement (pctxt, "q952Full", -1); /* decode q953Full */ invokeStartElement (pctxt, "q953Full", -1); stat = DECODEBIT (pctxt, &pvalue->q953Full); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->q953Full); invokeEndElement (pctxt, "q953Full", -1); /* decode q955Full */ invokeStartElement (pctxt, "q955Full", -1); stat = DECODEBIT (pctxt, &pvalue->q955Full); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->q955Full); invokeEndElement (pctxt, "q955Full", -1); /* decode q956Full */ invokeStartElement (pctxt, "q956Full", -1); stat = DECODEBIT (pctxt, &pvalue->q956Full); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->q956Full); invokeEndElement (pctxt, "q956Full", -1); /* decode q957Full */ invokeStartElement (pctxt, "q957Full", -1); stat = DECODEBIT (pctxt, &pvalue->q957Full); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->q957Full); invokeEndElement (pctxt, "q957Full", -1); /* decode q954Info */ invokeStartElement (pctxt, "q954Info", -1); stat = asn1PD_H225Q954Details (pctxt, &pvalue->q954Info); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "q954Info", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CallType */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallType (OOCTXT* pctxt, H225CallType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* pointToPoint */ case 0: invokeStartElement (pctxt, "pointToPoint", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "pointToPoint", -1); break; /* oneToN */ case 1: invokeStartElement (pctxt, "oneToN", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "oneToN", -1); break; /* nToOne */ case 2: invokeStartElement (pctxt, "nToOne", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nToOne", -1); break; /* nToN */ case 3: invokeStartElement (pctxt, "nToN", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "nToN", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CallIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallIdentifier (OOCTXT* pctxt, H225CallIdentifier* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode guid */ invokeStartElement (pctxt, "guid", -1); stat = asn1PD_H225GloballyUniqueID (pctxt, &pvalue->guid); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "guid", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SecurityServiceMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SecurityServiceMode (OOCTXT* pctxt, H225SecurityServiceMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* none */ case 1: invokeStartElement (pctxt, "none", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "none", -1); break; /* default_ */ case 2: invokeStartElement (pctxt, "default_", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "default_", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* SecurityCapabilities */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SecurityCapabilities (OOCTXT* pctxt, H225SecurityCapabilities* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } /* decode encryption */ invokeStartElement (pctxt, "encryption", -1); stat = asn1PD_H225SecurityServiceMode (pctxt, &pvalue->encryption); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "encryption", -1); /* decode authenticaton */ invokeStartElement (pctxt, "authenticaton", -1); stat = asn1PD_H225SecurityServiceMode (pctxt, &pvalue->authenticaton); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "authenticaton", -1); /* decode integrity */ invokeStartElement (pctxt, "integrity", -1); stat = asn1PD_H225SecurityServiceMode (pctxt, &pvalue->integrity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrity", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H245Security */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H245Security (OOCTXT* pctxt, H225H245Security* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* noSecurity */ case 1: invokeStartElement (pctxt, "noSecurity", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noSecurity", -1); break; /* tls */ case 2: invokeStartElement (pctxt, "tls", -1); pvalue->u.tls = ALLOC_ASN1ELEM (pctxt, H225SecurityCapabilities); stat = asn1PD_H225SecurityCapabilities (pctxt, pvalue->u.tls); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tls", -1); break; /* ipsec */ case 3: invokeStartElement (pctxt, "ipsec", -1); pvalue->u.ipsec = ALLOC_ASN1ELEM (pctxt, H225SecurityCapabilities); stat = asn1PD_H225SecurityCapabilities (pctxt, pvalue->u.ipsec); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "ipsec", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225H245Security */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225H245Security (OOCTXT* pctxt, H225_SeqOfH225H245Security* pvalue) { int stat = ASN_OK; H225H245Security* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225H245Security); stat = asn1PD_H225H245Security (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ClearToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225ClearToken (OOCTXT* pctxt, H225_SeqOfH225ClearToken* pvalue) { int stat = ASN_OK; H235ClearToken* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H235ClearToken); stat = asn1PD_H235ClearToken (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoEPPwdHash */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CryptoH323Token_cryptoEPPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPPwdHash* pvalue) { int stat = ASN_OK; /* decode alias */ invokeStartElement (pctxt, "alias", -1); stat = asn1PD_H225AliasAddress (pctxt, &pvalue->alias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alias", -1); /* decode timeStamp */ invokeStartElement (pctxt, "timeStamp", -1); stat = asn1PD_H235TimeStamp (pctxt, &pvalue->timeStamp); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "timeStamp", -1); /* decode token */ invokeStartElement (pctxt, "token", -1); stat = asn1PD_H235HASHED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "token", -1); return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoGKPwdHash */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CryptoH323Token_cryptoGKPwdHash (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKPwdHash* pvalue) { int stat = ASN_OK; /* decode gatekeeperId */ invokeStartElement (pctxt, "gatekeeperId", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperId); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperId", -1); /* decode timeStamp */ invokeStartElement (pctxt, "timeStamp", -1); stat = asn1PD_H235TimeStamp (pctxt, &pvalue->timeStamp); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "timeStamp", -1); /* decode token */ invokeStartElement (pctxt, "token", -1); stat = asn1PD_H235HASHED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "token", -1); return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoEPCert */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CryptoH323Token_cryptoEPCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoEPCert* pvalue) { int stat = ASN_OK; /* decode toBeSigned */ invokeStartElement (pctxt, "toBeSigned", -1); stat = asn1PD_H235EncodedPwdCertToken (pctxt, &pvalue->toBeSigned); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "toBeSigned", -1); /* decode algorithmOID */ invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); /* decode paramS */ invokeStartElement (pctxt, "paramS", -1); stat = asn1PD_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "paramS", -1); /* decode signature */ invokeStartElement (pctxt, "signature", -1); stat = decodeDynBitString (pctxt, (ASN1DynBitStr*)&pvalue->signature); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->signature.numbits, pvalue->signature.data); invokeEndElement (pctxt, "signature", -1); return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoGKCert */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CryptoH323Token_cryptoGKCert (OOCTXT* pctxt, H225CryptoH323Token_cryptoGKCert* pvalue) { int stat = ASN_OK; /* decode toBeSigned */ invokeStartElement (pctxt, "toBeSigned", -1); stat = asn1PD_H235EncodedPwdCertToken (pctxt, &pvalue->toBeSigned); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "toBeSigned", -1); /* decode algorithmOID */ invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); /* decode paramS */ invokeStartElement (pctxt, "paramS", -1); stat = asn1PD_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "paramS", -1); /* decode signature */ invokeStartElement (pctxt, "signature", -1); stat = decodeDynBitString (pctxt, (ASN1DynBitStr*)&pvalue->signature); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->signature.numbits, pvalue->signature.data); invokeEndElement (pctxt, "signature", -1); return (stat); } /**************************************************************/ /* */ /* CryptoH323Token_cryptoFastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CryptoH323Token_cryptoFastStart (OOCTXT* pctxt, H225CryptoH323Token_cryptoFastStart* pvalue) { int stat = ASN_OK; /* decode toBeSigned */ invokeStartElement (pctxt, "toBeSigned", -1); stat = asn1PD_H225EncodedFastStartToken (pctxt, &pvalue->toBeSigned); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "toBeSigned", -1); /* decode algorithmOID */ invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); /* decode paramS */ invokeStartElement (pctxt, "paramS", -1); stat = asn1PD_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "paramS", -1); /* decode signature */ invokeStartElement (pctxt, "signature", -1); stat = decodeDynBitString (pctxt, (ASN1DynBitStr*)&pvalue->signature); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->signature.numbits, pvalue->signature.data); invokeEndElement (pctxt, "signature", -1); return (stat); } /**************************************************************/ /* */ /* CryptoH323Token */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CryptoH323Token (OOCTXT* pctxt, H225CryptoH323Token* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 7); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* cryptoEPPwdHash */ case 0: invokeStartElement (pctxt, "cryptoEPPwdHash", -1); pvalue->u.cryptoEPPwdHash = ALLOC_ASN1ELEM (pctxt, H225CryptoH323Token_cryptoEPPwdHash); stat = asn1PD_H225CryptoH323Token_cryptoEPPwdHash (pctxt, pvalue->u.cryptoEPPwdHash); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoEPPwdHash", -1); break; /* cryptoGKPwdHash */ case 1: invokeStartElement (pctxt, "cryptoGKPwdHash", -1); pvalue->u.cryptoGKPwdHash = ALLOC_ASN1ELEM (pctxt, H225CryptoH323Token_cryptoGKPwdHash); stat = asn1PD_H225CryptoH323Token_cryptoGKPwdHash (pctxt, pvalue->u.cryptoGKPwdHash); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoGKPwdHash", -1); break; /* cryptoEPPwdEncr */ case 2: invokeStartElement (pctxt, "cryptoEPPwdEncr", -1); pvalue->u.cryptoEPPwdEncr = ALLOC_ASN1ELEM (pctxt, H235ENCRYPTED); stat = asn1PD_H235ENCRYPTED (pctxt, pvalue->u.cryptoEPPwdEncr); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoEPPwdEncr", -1); break; /* cryptoGKPwdEncr */ case 3: invokeStartElement (pctxt, "cryptoGKPwdEncr", -1); pvalue->u.cryptoGKPwdEncr = ALLOC_ASN1ELEM (pctxt, H235ENCRYPTED); stat = asn1PD_H235ENCRYPTED (pctxt, pvalue->u.cryptoGKPwdEncr); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoGKPwdEncr", -1); break; /* cryptoEPCert */ case 4: invokeStartElement (pctxt, "cryptoEPCert", -1); pvalue->u.cryptoEPCert = ALLOC_ASN1ELEM (pctxt, H225CryptoH323Token_cryptoEPCert); stat = asn1PD_H225CryptoH323Token_cryptoEPCert (pctxt, pvalue->u.cryptoEPCert); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoEPCert", -1); break; /* cryptoGKCert */ case 5: invokeStartElement (pctxt, "cryptoGKCert", -1); pvalue->u.cryptoGKCert = ALLOC_ASN1ELEM (pctxt, H225CryptoH323Token_cryptoGKCert); stat = asn1PD_H225CryptoH323Token_cryptoGKCert (pctxt, pvalue->u.cryptoGKCert); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoGKCert", -1); break; /* cryptoFastStart */ case 6: invokeStartElement (pctxt, "cryptoFastStart", -1); pvalue->u.cryptoFastStart = ALLOC_ASN1ELEM (pctxt, H225CryptoH323Token_cryptoFastStart); stat = asn1PD_H225CryptoH323Token_cryptoFastStart (pctxt, pvalue->u.cryptoFastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoFastStart", -1); break; /* nestedcryptoToken */ case 7: invokeStartElement (pctxt, "nestedcryptoToken", -1); pvalue->u.nestedcryptoToken = ALLOC_ASN1ELEM (pctxt, H235CryptoToken); stat = asn1PD_H235CryptoToken (pctxt, pvalue->u.nestedcryptoToken); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nestedcryptoToken", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 9; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CryptoH323Token */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225CryptoH323Token (OOCTXT* pctxt, H225_SeqOfH225CryptoH323Token* pvalue) { int stat = ASN_OK; H225CryptoH323Token* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225CryptoH323Token); stat = asn1PD_H225CryptoH323Token (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Setup_UUIE_fastStart (OOCTXT* pctxt, H225Setup_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* ScnConnectionType */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ScnConnectionType (OOCTXT* pctxt, H225ScnConnectionType* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 6); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* unknown */ case 0: invokeStartElement (pctxt, "unknown", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unknown", -1); break; /* bChannel */ case 1: invokeStartElement (pctxt, "bChannel", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "bChannel", -1); break; /* hybrid2x64 */ case 2: invokeStartElement (pctxt, "hybrid2x64", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hybrid2x64", -1); break; /* hybrid384 */ case 3: invokeStartElement (pctxt, "hybrid384", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hybrid384", -1); break; /* hybrid1536 */ case 4: invokeStartElement (pctxt, "hybrid1536", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hybrid1536", -1); break; /* hybrid1920 */ case 5: invokeStartElement (pctxt, "hybrid1920", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hybrid1920", -1); break; /* multirate */ case 6: invokeStartElement (pctxt, "multirate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multirate", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 8; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ScnConnectionAggregation */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ScnConnectionAggregation (OOCTXT* pctxt, H225ScnConnectionAggregation* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* auto_ */ case 0: invokeStartElement (pctxt, "auto_", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "auto_", -1); break; /* none */ case 1: invokeStartElement (pctxt, "none", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "none", -1); break; /* h221 */ case 2: invokeStartElement (pctxt, "h221", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "h221", -1); break; /* bonded_mode1 */ case 3: invokeStartElement (pctxt, "bonded_mode1", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "bonded_mode1", -1); break; /* bonded_mode2 */ case 4: invokeStartElement (pctxt, "bonded_mode2", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "bonded_mode2", -1); break; /* bonded_mode3 */ case 5: invokeStartElement (pctxt, "bonded_mode3", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "bonded_mode3", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_connectionParameters */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Setup_UUIE_connectionParameters (OOCTXT* pctxt, H225Setup_UUIE_connectionParameters* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode connectionType */ invokeStartElement (pctxt, "connectionType", -1); stat = asn1PD_H225ScnConnectionType (pctxt, &pvalue->connectionType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectionType", -1); /* decode numberOfScnConnections */ invokeStartElement (pctxt, "numberOfScnConnections", -1); stat = decodeConsUInt16 (pctxt, &pvalue->numberOfScnConnections, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->numberOfScnConnections); invokeEndElement (pctxt, "numberOfScnConnections", -1); /* decode connectionAggregation */ invokeStartElement (pctxt, "connectionAggregation", -1); stat = asn1PD_H225ScnConnectionAggregation (pctxt, &pvalue->connectionAggregation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectionAggregation", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_language */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Setup_UUIE_language (OOCTXT* pctxt, H225Setup_UUIE_language* pvalue) { static Asn1SizeCnst element_lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1IA5String); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); addSizeConstraint (pctxt, &element_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->elem[xx1], 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* PresentationIndicator */ /* */ /**************************************************************/ EXTERN int asn1PD_H225PresentationIndicator (OOCTXT* pctxt, H225PresentationIndicator* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* presentationAllowed */ case 0: invokeStartElement (pctxt, "presentationAllowed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "presentationAllowed", -1); break; /* presentationRestricted */ case 1: invokeStartElement (pctxt, "presentationRestricted", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "presentationRestricted", -1); break; /* addressNotAvailable */ case 2: invokeStartElement (pctxt, "addressNotAvailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "addressNotAvailable", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CallCreditServiceControl_billingMode */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallCreditServiceControl_billingMode (OOCTXT* pctxt, H225CallCreditServiceControl_billingMode* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* credit */ case 0: invokeStartElement (pctxt, "credit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "credit", -1); break; /* debit */ case 1: invokeStartElement (pctxt, "debit", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "debit", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CallCreditServiceControl_callStartingPoint */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallCreditServiceControl_callStartingPoint (OOCTXT* pctxt, H225CallCreditServiceControl_callStartingPoint* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* alerting */ case 0: invokeStartElement (pctxt, "alerting", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "alerting", -1); break; /* connect */ case 1: invokeStartElement (pctxt, "connect", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "connect", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* CallCreditServiceControl */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallCreditServiceControl (OOCTXT* pctxt, H225CallCreditServiceControl* pvalue) { static Asn1SizeCnst amountString_lsize1 = { 0, 1, 512, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.amountStringPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.billingModePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callDurationLimitPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.enforceCallDurationLimitPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callStartingPointPresent = optbit; /* decode amountString */ if (pvalue->m.amountStringPresent) { invokeStartElement (pctxt, "amountString", -1); addSizeConstraint (pctxt, &amountString_lsize1); stat = decodeBMPString (pctxt, &pvalue->amountString, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->amountString.nchars, pvalue->amountString.data); invokeEndElement (pctxt, "amountString", -1); } /* decode billingMode */ if (pvalue->m.billingModePresent) { invokeStartElement (pctxt, "billingMode", -1); stat = asn1PD_H225CallCreditServiceControl_billingMode (pctxt, &pvalue->billingMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "billingMode", -1); } /* decode callDurationLimit */ if (pvalue->m.callDurationLimitPresent) { invokeStartElement (pctxt, "callDurationLimit", -1); stat = decodeConsUnsigned (pctxt, &pvalue->callDurationLimit, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->callDurationLimit); invokeEndElement (pctxt, "callDurationLimit", -1); } /* decode enforceCallDurationLimit */ if (pvalue->m.enforceCallDurationLimitPresent) { invokeStartElement (pctxt, "enforceCallDurationLimit", -1); stat = DECODEBIT (pctxt, &pvalue->enforceCallDurationLimit); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->enforceCallDurationLimit); invokeEndElement (pctxt, "enforceCallDurationLimit", -1); } /* decode callStartingPoint */ if (pvalue->m.callStartingPointPresent) { invokeStartElement (pctxt, "callStartingPoint", -1); stat = asn1PD_H225CallCreditServiceControl_callStartingPoint (pctxt, &pvalue->callStartingPoint); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callStartingPoint", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ServiceControlDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ServiceControlDescriptor (OOCTXT* pctxt, H225ServiceControlDescriptor* pvalue) { static Asn1SizeCnst url_lsize1 = { 0, 0, 512, 0 }; int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* url */ case 0: invokeStartElement (pctxt, "url", -1); addSizeConstraint (pctxt, &url_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->u.url, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->u.url); invokeEndElement (pctxt, "url", -1); break; /* signal */ case 1: invokeStartElement (pctxt, "signal", -1); pvalue->u.signal = ALLOC_ASN1ELEM (pctxt, H225H248SignalsDescriptor); stat = asn1PD_H225H248SignalsDescriptor (pctxt, pvalue->u.signal); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "signal", -1); break; /* nonStandard */ case 2: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* callCreditServiceControl */ case 3: invokeStartElement (pctxt, "callCreditServiceControl", -1); pvalue->u.callCreditServiceControl = ALLOC_ASN1ELEM (pctxt, H225CallCreditServiceControl); stat = asn1PD_H225CallCreditServiceControl (pctxt, pvalue->u.callCreditServiceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callCreditServiceControl", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ServiceControlSession_reason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ServiceControlSession_reason (OOCTXT* pctxt, H225ServiceControlSession_reason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* open */ case 0: invokeStartElement (pctxt, "open", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "open", -1); break; /* refresh */ case 1: invokeStartElement (pctxt, "refresh", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "refresh", -1); break; /* close */ case 2: invokeStartElement (pctxt, "close", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "close", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ServiceControlSession */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ServiceControlSession (OOCTXT* pctxt, H225ServiceControlSession* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.contentsPresent = optbit; /* decode sessionId */ invokeStartElement (pctxt, "sessionId", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sessionId, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sessionId); invokeEndElement (pctxt, "sessionId", -1); /* decode contents */ if (pvalue->m.contentsPresent) { invokeStartElement (pctxt, "contents", -1); stat = asn1PD_H225ServiceControlDescriptor (pctxt, &pvalue->contents); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "contents", -1); } /* decode reason */ invokeStartElement (pctxt, "reason", -1); stat = asn1PD_H225ServiceControlSession_reason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reason", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ServiceControlSession */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225ServiceControlSession (OOCTXT* pctxt, H225_SeqOfH225ServiceControlSession* pvalue) { int stat = ASN_OK; H225ServiceControlSession* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225ServiceControlSession); stat = asn1PD_H225ServiceControlSession (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* CarrierInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CarrierInfo (OOCTXT* pctxt, H225CarrierInfo* pvalue) { static Asn1SizeCnst carrierName_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.carrierIdentificationCodePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.carrierNamePresent = optbit; /* decode carrierIdentificationCode */ if (pvalue->m.carrierIdentificationCodePresent) { invokeStartElement (pctxt, "carrierIdentificationCode", -1); stat = asn1PD_H225CarrierInfo_carrierIdentificationCode (pctxt, &pvalue->carrierIdentificationCode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "carrierIdentificationCode", -1); } /* decode carrierName */ if (pvalue->m.carrierNamePresent) { invokeStartElement (pctxt, "carrierName", -1); addSizeConstraint (pctxt, &carrierName_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->carrierName, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->carrierName); invokeEndElement (pctxt, "carrierName", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CallsAvailable */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallsAvailable (OOCTXT* pctxt, H225CallsAvailable* pvalue) { static Asn1SizeCnst group_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.groupPresent = optbit; /* decode calls */ invokeStartElement (pctxt, "calls", -1); stat = decodeConsUnsigned (pctxt, &pvalue->calls, 0U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->calls); invokeEndElement (pctxt, "calls", -1); /* decode group */ if (pvalue->m.groupPresent) { invokeStartElement (pctxt, "group", -1); addSizeConstraint (pctxt, &group_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->group, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->group); invokeEndElement (pctxt, "group", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.carrierPresent = 1; invokeStartElement (pctxt, "carrier", -1); stat = asn1PD_H225CarrierInfo (pctxt, &pvalue->carrier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "carrier", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CallsAvailable */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225CallsAvailable (OOCTXT* pctxt, H225_SeqOfH225CallsAvailable* pvalue) { int stat = ASN_OK; H225CallsAvailable* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225CallsAvailable); stat = asn1PD_H225CallsAvailable (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* CallCapacityInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallCapacityInfo (OOCTXT* pctxt, H225CallCapacityInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.voiceGwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h310GwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h320GwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h321GwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h322GwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h323GwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h324GwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.t120OnlyGwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.t38FaxAnnexbOnlyGwCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.terminalCallsAvailablePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.mcuCallsAvailablePresent = optbit; /* decode voiceGwCallsAvailable */ if (pvalue->m.voiceGwCallsAvailablePresent) { invokeStartElement (pctxt, "voiceGwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->voiceGwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "voiceGwCallsAvailable", -1); } /* decode h310GwCallsAvailable */ if (pvalue->m.h310GwCallsAvailablePresent) { invokeStartElement (pctxt, "h310GwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h310GwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h310GwCallsAvailable", -1); } /* decode h320GwCallsAvailable */ if (pvalue->m.h320GwCallsAvailablePresent) { invokeStartElement (pctxt, "h320GwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h320GwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h320GwCallsAvailable", -1); } /* decode h321GwCallsAvailable */ if (pvalue->m.h321GwCallsAvailablePresent) { invokeStartElement (pctxt, "h321GwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h321GwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h321GwCallsAvailable", -1); } /* decode h322GwCallsAvailable */ if (pvalue->m.h322GwCallsAvailablePresent) { invokeStartElement (pctxt, "h322GwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h322GwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h322GwCallsAvailable", -1); } /* decode h323GwCallsAvailable */ if (pvalue->m.h323GwCallsAvailablePresent) { invokeStartElement (pctxt, "h323GwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h323GwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h323GwCallsAvailable", -1); } /* decode h324GwCallsAvailable */ if (pvalue->m.h324GwCallsAvailablePresent) { invokeStartElement (pctxt, "h324GwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->h324GwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h324GwCallsAvailable", -1); } /* decode t120OnlyGwCallsAvailable */ if (pvalue->m.t120OnlyGwCallsAvailablePresent) { invokeStartElement (pctxt, "t120OnlyGwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->t120OnlyGwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t120OnlyGwCallsAvailable", -1); } /* decode t38FaxAnnexbOnlyGwCallsAvailable */ if (pvalue->m.t38FaxAnnexbOnlyGwCallsAvailablePresent) { invokeStartElement (pctxt, "t38FaxAnnexbOnlyGwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->t38FaxAnnexbOnlyGwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "t38FaxAnnexbOnlyGwCallsAvailable", -1); } /* decode terminalCallsAvailable */ if (pvalue->m.terminalCallsAvailablePresent) { invokeStartElement (pctxt, "terminalCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->terminalCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalCallsAvailable", -1); } /* decode mcuCallsAvailable */ if (pvalue->m.mcuCallsAvailablePresent) { invokeStartElement (pctxt, "mcuCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->mcuCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "mcuCallsAvailable", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.sipGwCallsAvailablePresent = 1; invokeStartElement (pctxt, "sipGwCallsAvailable", -1); stat = asn1PD_H225_SeqOfH225CallsAvailable (pctxt, &pvalue->sipGwCallsAvailable); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sipGwCallsAvailable", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* CallCapacity */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallCapacity (OOCTXT* pctxt, H225CallCapacity* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.maximumCallCapacityPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.currentCallCapacityPresent = optbit; /* decode maximumCallCapacity */ if (pvalue->m.maximumCallCapacityPresent) { invokeStartElement (pctxt, "maximumCallCapacity", -1); stat = asn1PD_H225CallCapacityInfo (pctxt, &pvalue->maximumCallCapacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "maximumCallCapacity", -1); } /* decode currentCallCapacity */ if (pvalue->m.currentCallCapacityPresent) { invokeStartElement (pctxt, "currentCallCapacity", -1); stat = asn1PD_H225CallCapacityInfo (pctxt, &pvalue->currentCallCapacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "currentCallCapacity", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225CicInfo_cic_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225CicInfo_cic_element (OOCTXT* pctxt, H225_SeqOfH225CicInfo_cic_element* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, H225CicInfo_cic_element); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H225CicInfo_cic_element (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* CicInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CicInfo (OOCTXT* pctxt, H225CicInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode cic */ invokeStartElement (pctxt, "cic", -1); stat = asn1PD_H225_SeqOfH225CicInfo_cic_element (pctxt, &pvalue->cic); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cic", -1); /* decode pointCode */ invokeStartElement (pctxt, "pointCode", -1); stat = asn1PD_H225CicInfo_pointCode (pctxt, &pvalue->pointCode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "pointCode", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* GroupID_member */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GroupID_member (OOCTXT* pctxt, H225GroupID_member* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1USINT); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeConsUInt16 (pctxt, &pvalue->elem[xx1], 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* GroupID */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GroupID (OOCTXT* pctxt, H225GroupID* pvalue) { static Asn1SizeCnst group_lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.memberPresent = optbit; /* decode member */ if (pvalue->m.memberPresent) { invokeStartElement (pctxt, "member", -1); stat = asn1PD_H225GroupID_member (pctxt, &pvalue->member); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "member", -1); } /* decode group */ invokeStartElement (pctxt, "group", -1); addSizeConstraint (pctxt, &group_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->group, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->group); invokeEndElement (pctxt, "group", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CircuitIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CircuitIdentifier (OOCTXT* pctxt, H225CircuitIdentifier* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.cicPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.groupPresent = optbit; /* decode cic */ if (pvalue->m.cicPresent) { invokeStartElement (pctxt, "cic", -1); stat = asn1PD_H225CicInfo (pctxt, &pvalue->cic); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cic", -1); } /* decode group */ if (pvalue->m.groupPresent) { invokeStartElement (pctxt, "group", -1); stat = asn1PD_H225GroupID (pctxt, &pvalue->group); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "group", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.carrierPresent = 1; invokeStartElement (pctxt, "carrier", -1); stat = asn1PD_H225CarrierInfo (pctxt, &pvalue->carrier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "carrier", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225GenericData */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225GenericData (OOCTXT* pctxt, H225_SeqOfH225GenericData* pvalue) { int stat = ASN_OK; H225GenericData* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225GenericData); stat = asn1PD_H225GenericData (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* CircuitInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CircuitInfo (OOCTXT* pctxt, H225CircuitInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.sourceCircuitIDPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destinationCircuitIDPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.genericDataPresent = optbit; /* decode sourceCircuitID */ if (pvalue->m.sourceCircuitIDPresent) { invokeStartElement (pctxt, "sourceCircuitID", -1); stat = asn1PD_H225CircuitIdentifier (pctxt, &pvalue->sourceCircuitID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sourceCircuitID", -1); } /* decode destinationCircuitID */ if (pvalue->m.destinationCircuitIDPresent) { invokeStartElement (pctxt, "destinationCircuitID", -1); stat = asn1PD_H225CircuitIdentifier (pctxt, &pvalue->destinationCircuitID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationCircuitID", -1); } /* decode genericData */ if (pvalue->m.genericDataPresent) { invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225FeatureDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225FeatureDescriptor (OOCTXT* pctxt, H225_SeqOfH225FeatureDescriptor* pvalue) { int stat = ASN_OK; H225FeatureDescriptor* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225FeatureDescriptor); stat = asn1PD_H225FeatureDescriptor (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE_parallelH245Control */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Setup_UUIE_parallelH245Control (OOCTXT* pctxt, H225Setup_UUIE_parallelH245Control* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* ExtendedAliasAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ExtendedAliasAddress (OOCTXT* pctxt, H225ExtendedAliasAddress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.presentationIndicatorPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.screeningIndicatorPresent = optbit; /* decode address */ invokeStartElement (pctxt, "address", -1); stat = asn1PD_H225AliasAddress (pctxt, &pvalue->address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "address", -1); /* decode presentationIndicator */ if (pvalue->m.presentationIndicatorPresent) { invokeStartElement (pctxt, "presentationIndicator", -1); stat = asn1PD_H225PresentationIndicator (pctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "presentationIndicator", -1); } /* decode screeningIndicator */ if (pvalue->m.screeningIndicatorPresent) { invokeStartElement (pctxt, "screeningIndicator", -1); stat = asn1PD_H225ScreeningIndicator (pctxt, &pvalue->screeningIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "screeningIndicator", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ExtendedAliasAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225ExtendedAliasAddress (OOCTXT* pctxt, H225_SeqOfH225ExtendedAliasAddress* pvalue) { int stat = ASN_OK; H225ExtendedAliasAddress* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225ExtendedAliasAddress); stat = asn1PD_H225ExtendedAliasAddress (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* Setup_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Setup_UUIE (OOCTXT* pctxt, H225Setup_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.h245AddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.sourceAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destinationAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destCallSignalAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destExtraCallInfoPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destExtraCRVPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callServicesPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode h245Address */ if (pvalue->m.h245AddressPresent) { invokeStartElement (pctxt, "h245Address", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245Address", -1); } /* decode sourceAddress */ if (pvalue->m.sourceAddressPresent) { invokeStartElement (pctxt, "sourceAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->sourceAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sourceAddress", -1); } /* decode sourceInfo */ invokeStartElement (pctxt, "sourceInfo", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->sourceInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sourceInfo", -1); /* decode destinationAddress */ if (pvalue->m.destinationAddressPresent) { invokeStartElement (pctxt, "destinationAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationAddress", -1); } /* decode destCallSignalAddress */ if (pvalue->m.destCallSignalAddressPresent) { invokeStartElement (pctxt, "destCallSignalAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->destCallSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destCallSignalAddress", -1); } /* decode destExtraCallInfo */ if (pvalue->m.destExtraCallInfoPresent) { invokeStartElement (pctxt, "destExtraCallInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destExtraCallInfo", -1); } /* decode destExtraCRV */ if (pvalue->m.destExtraCRVPresent) { invokeStartElement (pctxt, "destExtraCRV", -1); stat = asn1PD_H225_SeqOfH225CallReferenceValue (pctxt, &pvalue->destExtraCRV); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destExtraCRV", -1); } /* decode activeMC */ invokeStartElement (pctxt, "activeMC", -1); stat = DECODEBIT (pctxt, &pvalue->activeMC); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->activeMC); invokeEndElement (pctxt, "activeMC", -1); /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); /* decode conferenceGoal */ invokeStartElement (pctxt, "conferenceGoal", -1); stat = asn1PD_H225Setup_UUIE_conferenceGoal (pctxt, &pvalue->conferenceGoal); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceGoal", -1); /* decode callServices */ if (pvalue->m.callServicesPresent) { invokeStartElement (pctxt, "callServices", -1); stat = asn1PD_H225QseriesOptions (pctxt, &pvalue->callServices); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callServices", -1); } /* decode callType */ invokeStartElement (pctxt, "callType", -1); stat = asn1PD_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callType", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 27 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.sourceCallSignalAddressPresent = 1; invokeStartElement (pctxt, "sourceCallSignalAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->sourceCallSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sourceCallSignalAddress", -1); break; case 1: pvalue->m.remoteExtensionAddressPresent = 1; invokeStartElement (pctxt, "remoteExtensionAddress", -1); stat = asn1PD_H225AliasAddress (pctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "remoteExtensionAddress", -1); break; case 2: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 3: pvalue->m.h245SecurityCapabilityPresent = 1; invokeStartElement (pctxt, "h245SecurityCapability", -1); stat = asn1PD_H225_SeqOfH225H245Security (pctxt, &pvalue->h245SecurityCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245SecurityCapability", -1); break; case 4: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 5: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 6: pvalue->m.fastStartPresent = 1; invokeStartElement (pctxt, "fastStart", -1); stat = asn1PD_H225Setup_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fastStart", -1); break; case 7: pvalue->m.mediaWaitForConnectPresent = 1; invokeStartElement (pctxt, "mediaWaitForConnect", -1); stat = DECODEBIT (pctxt, &pvalue->mediaWaitForConnect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->mediaWaitForConnect); invokeEndElement (pctxt, "mediaWaitForConnect", -1); break; case 8: pvalue->m.canOverlapSendPresent = 1; invokeStartElement (pctxt, "canOverlapSend", -1); stat = DECODEBIT (pctxt, &pvalue->canOverlapSend); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canOverlapSend); invokeEndElement (pctxt, "canOverlapSend", -1); break; case 9: pvalue->m.endpointIdentifierPresent = 1; invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); break; case 10: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 11: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 12: pvalue->m.connectionParametersPresent = 1; invokeStartElement (pctxt, "connectionParameters", -1); stat = asn1PD_H225Setup_UUIE_connectionParameters (pctxt, &pvalue->connectionParameters); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectionParameters", -1); break; case 13: pvalue->m.languagePresent = 1; invokeStartElement (pctxt, "language", -1); stat = asn1PD_H225Setup_UUIE_language (pctxt, &pvalue->language); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "language", -1); break; case 14: pvalue->m.presentationIndicatorPresent = 1; invokeStartElement (pctxt, "presentationIndicator", -1); stat = asn1PD_H225PresentationIndicator (pctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "presentationIndicator", -1); break; case 15: pvalue->m.screeningIndicatorPresent = 1; invokeStartElement (pctxt, "screeningIndicator", -1); stat = asn1PD_H225ScreeningIndicator (pctxt, &pvalue->screeningIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "screeningIndicator", -1); break; case 16: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 17: pvalue->m.symmetricOperationRequiredPresent = 1; invokeStartElement (pctxt, "symmetricOperationRequired", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "symmetricOperationRequired", -1); break; case 18: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 19: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 20: pvalue->m.desiredProtocolsPresent = 1; invokeStartElement (pctxt, "desiredProtocols", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->desiredProtocols); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "desiredProtocols", -1); break; case 21: pvalue->m.neededFeaturesPresent = 1; invokeStartElement (pctxt, "neededFeatures", -1); stat = asn1PD_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->neededFeatures); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "neededFeatures", -1); break; case 22: pvalue->m.desiredFeaturesPresent = 1; invokeStartElement (pctxt, "desiredFeatures", -1); stat = asn1PD_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->desiredFeatures); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "desiredFeatures", -1); break; case 23: pvalue->m.supportedFeaturesPresent = 1; invokeStartElement (pctxt, "supportedFeatures", -1); stat = asn1PD_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->supportedFeatures); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedFeatures", -1); break; case 24: pvalue->m.parallelH245ControlPresent = 1; invokeStartElement (pctxt, "parallelH245Control", -1); stat = asn1PD_H225Setup_UUIE_parallelH245Control (pctxt, &pvalue->parallelH245Control); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "parallelH245Control", -1); break; case 25: pvalue->m.additionalSourceAddressesPresent = 1; invokeStartElement (pctxt, "additionalSourceAddresses", -1); stat = asn1PD_H225_SeqOfH225ExtendedAliasAddress (pctxt, &pvalue->additionalSourceAddresses); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "additionalSourceAddresses", -1); break; case 26: pvalue->m.hopCountPresent = 1; invokeStartElement (pctxt, "hopCount", -1); stat = decodeConsUInt8 (pctxt, &pvalue->hopCount, 1U, 31U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->hopCount); invokeEndElement (pctxt, "hopCount", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* CallProceeding_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallProceeding_UUIE_fastStart (OOCTXT* pctxt, H225CallProceeding_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* FeatureSet */ /* */ /**************************************************************/ EXTERN int asn1PD_H225FeatureSet (OOCTXT* pctxt, H225FeatureSet* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.neededFeaturesPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.desiredFeaturesPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.supportedFeaturesPresent = optbit; /* decode replacementFeatureSet */ invokeStartElement (pctxt, "replacementFeatureSet", -1); stat = DECODEBIT (pctxt, &pvalue->replacementFeatureSet); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->replacementFeatureSet); invokeEndElement (pctxt, "replacementFeatureSet", -1); /* decode neededFeatures */ if (pvalue->m.neededFeaturesPresent) { invokeStartElement (pctxt, "neededFeatures", -1); stat = asn1PD_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->neededFeatures); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "neededFeatures", -1); } /* decode desiredFeatures */ if (pvalue->m.desiredFeaturesPresent) { invokeStartElement (pctxt, "desiredFeatures", -1); stat = asn1PD_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->desiredFeatures); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "desiredFeatures", -1); } /* decode supportedFeatures */ if (pvalue->m.supportedFeaturesPresent) { invokeStartElement (pctxt, "supportedFeatures", -1); stat = asn1PD_H225_SeqOfH225FeatureDescriptor (pctxt, &pvalue->supportedFeatures); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedFeatures", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CallProceeding_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallProceeding_UUIE (OOCTXT* pctxt, H225CallProceeding_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.h245AddressPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode destinationInfo */ invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); /* decode h245Address */ if (pvalue->m.h245AddressPresent) { invokeStartElement (pctxt, "h245Address", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245Address", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 9 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.h245SecurityModePresent = 1; invokeStartElement (pctxt, "h245SecurityMode", -1); stat = asn1PD_H225H245Security (pctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245SecurityMode", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.fastStartPresent = 1; invokeStartElement (pctxt, "fastStart", -1); stat = asn1PD_H225CallProceeding_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fastStart", -1); break; case 5: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 6: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 7: pvalue->m.fastConnectRefusedPresent = 1; invokeStartElement (pctxt, "fastConnectRefused", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fastConnectRefused", -1); break; case 8: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* Connect_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Connect_UUIE_fastStart (OOCTXT* pctxt, H225Connect_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* Connect_UUIE_language */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Connect_UUIE_language (OOCTXT* pctxt, H225Connect_UUIE_language* pvalue) { static Asn1SizeCnst element_lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1IA5String); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); addSizeConstraint (pctxt, &element_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->elem[xx1], 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* Connect_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Connect_UUIE (OOCTXT* pctxt, H225Connect_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.h245AddressPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode h245Address */ if (pvalue->m.h245AddressPresent) { invokeStartElement (pctxt, "h245Address", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245Address", -1); } /* decode destinationInfo */ invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 15 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.h245SecurityModePresent = 1; invokeStartElement (pctxt, "h245SecurityMode", -1); stat = asn1PD_H225H245Security (pctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245SecurityMode", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.fastStartPresent = 1; invokeStartElement (pctxt, "fastStart", -1); stat = asn1PD_H225Connect_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fastStart", -1); break; case 5: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 6: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 7: pvalue->m.languagePresent = 1; invokeStartElement (pctxt, "language", -1); stat = asn1PD_H225Connect_UUIE_language (pctxt, &pvalue->language); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "language", -1); break; case 8: pvalue->m.connectedAddressPresent = 1; invokeStartElement (pctxt, "connectedAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->connectedAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectedAddress", -1); break; case 9: pvalue->m.presentationIndicatorPresent = 1; invokeStartElement (pctxt, "presentationIndicator", -1); stat = asn1PD_H225PresentationIndicator (pctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "presentationIndicator", -1); break; case 10: pvalue->m.screeningIndicatorPresent = 1; invokeStartElement (pctxt, "screeningIndicator", -1); stat = asn1PD_H225ScreeningIndicator (pctxt, &pvalue->screeningIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "screeningIndicator", -1); break; case 11: pvalue->m.fastConnectRefusedPresent = 1; invokeStartElement (pctxt, "fastConnectRefused", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fastConnectRefused", -1); break; case 12: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 13: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 14: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* Alerting_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Alerting_UUIE_fastStart (OOCTXT* pctxt, H225Alerting_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* Alerting_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Alerting_UUIE (OOCTXT* pctxt, H225Alerting_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.h245AddressPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode destinationInfo */ invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); /* decode h245Address */ if (pvalue->m.h245AddressPresent) { invokeStartElement (pctxt, "h245Address", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245Address", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 14 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.h245SecurityModePresent = 1; invokeStartElement (pctxt, "h245SecurityMode", -1); stat = asn1PD_H225H245Security (pctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245SecurityMode", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.fastStartPresent = 1; invokeStartElement (pctxt, "fastStart", -1); stat = asn1PD_H225Alerting_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fastStart", -1); break; case 5: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 6: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 7: pvalue->m.alertingAddressPresent = 1; invokeStartElement (pctxt, "alertingAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->alertingAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alertingAddress", -1); break; case 8: pvalue->m.presentationIndicatorPresent = 1; invokeStartElement (pctxt, "presentationIndicator", -1); stat = asn1PD_H225PresentationIndicator (pctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "presentationIndicator", -1); break; case 9: pvalue->m.screeningIndicatorPresent = 1; invokeStartElement (pctxt, "screeningIndicator", -1); stat = asn1PD_H225ScreeningIndicator (pctxt, &pvalue->screeningIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "screeningIndicator", -1); break; case 10: pvalue->m.fastConnectRefusedPresent = 1; invokeStartElement (pctxt, "fastConnectRefused", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fastConnectRefused", -1); break; case 11: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 12: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 13: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* Information_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Information_UUIE_fastStart (OOCTXT* pctxt, H225Information_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* Information_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Information_UUIE (OOCTXT* pctxt, H225Information_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 6 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.fastStartPresent = 1; invokeStartElement (pctxt, "fastStart", -1); stat = asn1PD_H225Information_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fastStart", -1); break; case 4: pvalue->m.fastConnectRefusedPresent = 1; invokeStartElement (pctxt, "fastConnectRefused", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fastConnectRefused", -1); break; case 5: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* SecurityErrors */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SecurityErrors (OOCTXT* pctxt, H225SecurityErrors* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 15); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* securityWrongSyncTime */ case 0: invokeStartElement (pctxt, "securityWrongSyncTime", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongSyncTime", -1); break; /* securityReplay */ case 1: invokeStartElement (pctxt, "securityReplay", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityReplay", -1); break; /* securityWrongGeneralID */ case 2: invokeStartElement (pctxt, "securityWrongGeneralID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongGeneralID", -1); break; /* securityWrongSendersID */ case 3: invokeStartElement (pctxt, "securityWrongSendersID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongSendersID", -1); break; /* securityIntegrityFailed */ case 4: invokeStartElement (pctxt, "securityIntegrityFailed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityIntegrityFailed", -1); break; /* securityWrongOID */ case 5: invokeStartElement (pctxt, "securityWrongOID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongOID", -1); break; /* securityDHmismatch */ case 6: invokeStartElement (pctxt, "securityDHmismatch", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDHmismatch", -1); break; /* securityCertificateExpired */ case 7: invokeStartElement (pctxt, "securityCertificateExpired", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityCertificateExpired", -1); break; /* securityCertificateDateInvalid */ case 8: invokeStartElement (pctxt, "securityCertificateDateInvalid", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityCertificateDateInvalid", -1); break; /* securityCertificateRevoked */ case 9: invokeStartElement (pctxt, "securityCertificateRevoked", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityCertificateRevoked", -1); break; /* securityCertificateNotReadable */ case 10: invokeStartElement (pctxt, "securityCertificateNotReadable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityCertificateNotReadable", -1); break; /* securityCertificateSignatureInvalid */ case 11: invokeStartElement (pctxt, "securityCertificateSignatureInvalid", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityCertificateSignatureInvalid", -1); break; /* securityCertificateMissing */ case 12: invokeStartElement (pctxt, "securityCertificateMissing", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityCertificateMissing", -1); break; /* securityCertificateIncomplete */ case 13: invokeStartElement (pctxt, "securityCertificateIncomplete", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityCertificateIncomplete", -1); break; /* securityUnsupportedCertificateAlgOID */ case 14: invokeStartElement (pctxt, "securityUnsupportedCertificateAlgOID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityUnsupportedCertificateAlgOID", -1); break; /* securityUnknownCA */ case 15: invokeStartElement (pctxt, "securityUnknownCA", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityUnknownCA", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 17; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ReleaseCompleteReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ReleaseCompleteReason (OOCTXT* pctxt, H225ReleaseCompleteReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 11); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* noBandwidth */ case 0: invokeStartElement (pctxt, "noBandwidth", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noBandwidth", -1); break; /* gatekeeperResources */ case 1: invokeStartElement (pctxt, "gatekeeperResources", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "gatekeeperResources", -1); break; /* unreachableDestination */ case 2: invokeStartElement (pctxt, "unreachableDestination", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unreachableDestination", -1); break; /* destinationRejection */ case 3: invokeStartElement (pctxt, "destinationRejection", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "destinationRejection", -1); break; /* invalidRevision */ case 4: invokeStartElement (pctxt, "invalidRevision", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidRevision", -1); break; /* noPermission */ case 5: invokeStartElement (pctxt, "noPermission", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noPermission", -1); break; /* unreachableGatekeeper */ case 6: invokeStartElement (pctxt, "unreachableGatekeeper", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unreachableGatekeeper", -1); break; /* gatewayResources */ case 7: invokeStartElement (pctxt, "gatewayResources", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "gatewayResources", -1); break; /* badFormatAddress */ case 8: invokeStartElement (pctxt, "badFormatAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "badFormatAddress", -1); break; /* adaptiveBusy */ case 9: invokeStartElement (pctxt, "adaptiveBusy", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "adaptiveBusy", -1); break; /* inConf */ case 10: invokeStartElement (pctxt, "inConf", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "inConf", -1); break; /* undefinedReason */ case 11: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 13; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* facilityCallDeflection */ case 13: invokeStartElement (pctxt, "facilityCallDeflection", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "facilityCallDeflection", -1); break; /* securityDenied */ case 14: invokeStartElement (pctxt, "securityDenied", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenied", -1); break; /* calledPartyNotRegistered */ case 15: invokeStartElement (pctxt, "calledPartyNotRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "calledPartyNotRegistered", -1); break; /* callerNotRegistered */ case 16: invokeStartElement (pctxt, "callerNotRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "callerNotRegistered", -1); break; /* newConnectionNeeded */ case 17: invokeStartElement (pctxt, "newConnectionNeeded", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "newConnectionNeeded", -1); break; /* nonStandardReason */ case 18: invokeStartElement (pctxt, "nonStandardReason", -1); pvalue->u.nonStandardReason = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandardReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardReason", -1); break; /* replaceWithConferenceInvite */ case 19: invokeStartElement (pctxt, "replaceWithConferenceInvite", -1); pvalue->u.replaceWithConferenceInvite = ALLOC_ASN1ELEM (pctxt, H225ConferenceIdentifier); stat = asn1PD_H225ConferenceIdentifier (pctxt, pvalue->u.replaceWithConferenceInvite); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "replaceWithConferenceInvite", -1); break; /* genericDataReason */ case 20: invokeStartElement (pctxt, "genericDataReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "genericDataReason", -1); break; /* neededFeatureNotSupported */ case 21: invokeStartElement (pctxt, "neededFeatureNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "neededFeatureNotSupported", -1); break; /* tunnelledSignallingRejected */ case 22: invokeStartElement (pctxt, "tunnelledSignallingRejected", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "tunnelledSignallingRejected", -1); break; /* invalidCID */ case 23: invokeStartElement (pctxt, "invalidCID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidCID", -1); break; /* securityError */ case 24: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors); stat = asn1PD_H225SecurityErrors (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; /* hopCountExceeded */ case 25: invokeStartElement (pctxt, "hopCountExceeded", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hopCountExceeded", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* ReleaseComplete_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ReleaseComplete_UUIE (OOCTXT* pctxt, H225ReleaseComplete_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.reasonPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode reason */ if (pvalue->m.reasonPresent) { invokeStartElement (pctxt, "reason", -1); stat = asn1PD_H225ReleaseCompleteReason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reason", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 9 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.busyAddressPresent = 1; invokeStartElement (pctxt, "busyAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->busyAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "busyAddress", -1); break; case 4: pvalue->m.presentationIndicatorPresent = 1; invokeStartElement (pctxt, "presentationIndicator", -1); stat = asn1PD_H225PresentationIndicator (pctxt, &pvalue->presentationIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "presentationIndicator", -1); break; case 5: pvalue->m.screeningIndicatorPresent = 1; invokeStartElement (pctxt, "screeningIndicator", -1); stat = asn1PD_H225ScreeningIndicator (pctxt, &pvalue->screeningIndicator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "screeningIndicator", -1); break; case 6: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 7: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 8: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* FacilityReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225FacilityReason (OOCTXT* pctxt, H225FacilityReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* routeCallToGatekeeper */ case 0: invokeStartElement (pctxt, "routeCallToGatekeeper", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "routeCallToGatekeeper", -1); break; /* callForwarded */ case 1: invokeStartElement (pctxt, "callForwarded", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "callForwarded", -1); break; /* routeCallToMC */ case 2: invokeStartElement (pctxt, "routeCallToMC", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "routeCallToMC", -1); break; /* undefinedReason */ case 3: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* conferenceListChoice */ case 5: invokeStartElement (pctxt, "conferenceListChoice", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "conferenceListChoice", -1); break; /* startH245 */ case 6: invokeStartElement (pctxt, "startH245", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "startH245", -1); break; /* noH245 */ case 7: invokeStartElement (pctxt, "noH245", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noH245", -1); break; /* newTokens */ case 8: invokeStartElement (pctxt, "newTokens", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "newTokens", -1); break; /* featureSetUpdate */ case 9: invokeStartElement (pctxt, "featureSetUpdate", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "featureSetUpdate", -1); break; /* forwardedElements */ case 10: invokeStartElement (pctxt, "forwardedElements", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "forwardedElements", -1); break; /* transportedInformation */ case 11: invokeStartElement (pctxt, "transportedInformation", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transportedInformation", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* ConferenceList */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ConferenceList (OOCTXT* pctxt, H225ConferenceList* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.conferenceIDPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.conferenceAliasPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode conferenceID */ if (pvalue->m.conferenceIDPresent) { invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); } /* decode conferenceAlias */ if (pvalue->m.conferenceAliasPresent) { invokeStartElement (pctxt, "conferenceAlias", -1); stat = asn1PD_H225AliasAddress (pctxt, &pvalue->conferenceAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceAlias", -1); } /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ConferenceList */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225ConferenceList (OOCTXT* pctxt, H225_SeqOfH225ConferenceList* pvalue) { int stat = ASN_OK; H225ConferenceList* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225ConferenceList); stat = asn1PD_H225ConferenceList (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* Facility_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Facility_UUIE_fastStart (OOCTXT* pctxt, H225Facility_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* Facility_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Facility_UUIE (OOCTXT* pctxt, H225Facility_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.alternativeAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.alternativeAliasAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.conferenceIDPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode alternativeAddress */ if (pvalue->m.alternativeAddressPresent) { invokeStartElement (pctxt, "alternativeAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->alternativeAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternativeAddress", -1); } /* decode alternativeAliasAddress */ if (pvalue->m.alternativeAliasAddressPresent) { invokeStartElement (pctxt, "alternativeAliasAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->alternativeAliasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternativeAliasAddress", -1); } /* decode conferenceID */ if (pvalue->m.conferenceIDPresent) { invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); } /* decode reason */ invokeStartElement (pctxt, "reason", -1); stat = asn1PD_H225FacilityReason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reason", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 16 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.destExtraCallInfoPresent = 1; invokeStartElement (pctxt, "destExtraCallInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destExtraCallInfo", -1); break; case 2: pvalue->m.remoteExtensionAddressPresent = 1; invokeStartElement (pctxt, "remoteExtensionAddress", -1); stat = asn1PD_H225AliasAddress (pctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "remoteExtensionAddress", -1); break; case 3: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 4: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 5: pvalue->m.conferencesPresent = 1; invokeStartElement (pctxt, "conferences", -1); stat = asn1PD_H225_SeqOfH225ConferenceList (pctxt, &pvalue->conferences); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferences", -1); break; case 6: pvalue->m.h245AddressPresent = 1; invokeStartElement (pctxt, "h245Address", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245Address", -1); break; case 7: pvalue->m.fastStartPresent = 1; invokeStartElement (pctxt, "fastStart", -1); stat = asn1PD_H225Facility_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fastStart", -1); break; case 8: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 9: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 10: pvalue->m.fastConnectRefusedPresent = 1; invokeStartElement (pctxt, "fastConnectRefused", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fastConnectRefused", -1); break; case 11: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 12: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 13: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 14: pvalue->m.destinationInfoPresent = 1; invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); break; case 15: pvalue->m.h245SecurityModePresent = 1; invokeStartElement (pctxt, "h245SecurityMode", -1); stat = asn1PD_H225H245Security (pctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245SecurityMode", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* Progress_UUIE_fastStart */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Progress_UUIE_fastStart (OOCTXT* pctxt, H225Progress_UUIE_fastStart* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* Progress_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Progress_UUIE (OOCTXT* pctxt, H225Progress_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.h245AddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h245SecurityModePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.fastStartPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode destinationInfo */ invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); /* decode h245Address */ if (pvalue->m.h245AddressPresent) { invokeStartElement (pctxt, "h245Address", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->h245Address); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245Address", -1); } /* decode callIdentifier */ invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); /* decode h245SecurityMode */ if (pvalue->m.h245SecurityModePresent) { invokeStartElement (pctxt, "h245SecurityMode", -1); stat = asn1PD_H225H245Security (pctxt, &pvalue->h245SecurityMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245SecurityMode", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode fastStart */ if (pvalue->m.fastStartPresent) { invokeStartElement (pctxt, "fastStart", -1); stat = asn1PD_H225Progress_UUIE_fastStart (pctxt, &pvalue->fastStart); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fastStart", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 3 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 1: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 2: pvalue->m.fastConnectRefusedPresent = 1; invokeStartElement (pctxt, "fastConnectRefused", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fastConnectRefused", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* Status_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Status_UUIE (OOCTXT* pctxt, H225Status_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode callIdentifier */ invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* StatusInquiry_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225StatusInquiry_UUIE (OOCTXT* pctxt, H225StatusInquiry_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode callIdentifier */ invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SetupAcknowledge_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SetupAcknowledge_UUIE (OOCTXT* pctxt, H225SetupAcknowledge_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode callIdentifier */ invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* Notify_UUIE */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Notify_UUIE (OOCTXT* pctxt, H225Notify_UUIE* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode callIdentifier */ invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_h323_message_body */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UU_PDU_h323_message_body (OOCTXT* pctxt, H225H323_UU_PDU_h323_message_body* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 6); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* setup */ case 0: invokeStartElement (pctxt, "setup", -1); pvalue->u.setup = ALLOC_ASN1ELEM (pctxt, H225Setup_UUIE); stat = asn1PD_H225Setup_UUIE (pctxt, pvalue->u.setup); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "setup", -1); break; /* callProceeding */ case 1: invokeStartElement (pctxt, "callProceeding", -1); pvalue->u.callProceeding = ALLOC_ASN1ELEM (pctxt, H225CallProceeding_UUIE); stat = asn1PD_H225CallProceeding_UUIE (pctxt, pvalue->u.callProceeding); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callProceeding", -1); break; /* connect */ case 2: invokeStartElement (pctxt, "connect", -1); pvalue->u.connect = ALLOC_ASN1ELEM (pctxt, H225Connect_UUIE); stat = asn1PD_H225Connect_UUIE (pctxt, pvalue->u.connect); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connect", -1); break; /* alerting */ case 3: invokeStartElement (pctxt, "alerting", -1); pvalue->u.alerting = ALLOC_ASN1ELEM (pctxt, H225Alerting_UUIE); stat = asn1PD_H225Alerting_UUIE (pctxt, pvalue->u.alerting); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alerting", -1); break; /* information */ case 4: invokeStartElement (pctxt, "information", -1); pvalue->u.information = ALLOC_ASN1ELEM (pctxt, H225Information_UUIE); stat = asn1PD_H225Information_UUIE (pctxt, pvalue->u.information); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "information", -1); break; /* releaseComplete */ case 5: invokeStartElement (pctxt, "releaseComplete", -1); pvalue->u.releaseComplete = ALLOC_ASN1ELEM (pctxt, H225ReleaseComplete_UUIE); stat = asn1PD_H225ReleaseComplete_UUIE (pctxt, pvalue->u.releaseComplete); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "releaseComplete", -1); break; /* facility */ case 6: invokeStartElement (pctxt, "facility", -1); pvalue->u.facility = ALLOC_ASN1ELEM (pctxt, H225Facility_UUIE); stat = asn1PD_H225Facility_UUIE (pctxt, pvalue->u.facility); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "facility", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 8; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* progress */ case 8: invokeStartElement (pctxt, "progress", -1); pvalue->u.progress = ALLOC_ASN1ELEM (pctxt, H225Progress_UUIE); stat = asn1PD_H225Progress_UUIE (pctxt, pvalue->u.progress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "progress", -1); break; /* empty */ case 9: invokeStartElement (pctxt, "empty", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "empty", -1); break; /* status */ case 10: invokeStartElement (pctxt, "status", -1); pvalue->u.status = ALLOC_ASN1ELEM (pctxt, H225Status_UUIE); stat = asn1PD_H225Status_UUIE (pctxt, pvalue->u.status); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "status", -1); break; /* statusInquiry */ case 11: invokeStartElement (pctxt, "statusInquiry", -1); pvalue->u.statusInquiry = ALLOC_ASN1ELEM (pctxt, H225StatusInquiry_UUIE); stat = asn1PD_H225StatusInquiry_UUIE (pctxt, pvalue->u.statusInquiry); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "statusInquiry", -1); break; /* setupAcknowledge */ case 12: invokeStartElement (pctxt, "setupAcknowledge", -1); pvalue->u.setupAcknowledge = ALLOC_ASN1ELEM (pctxt, H225SetupAcknowledge_UUIE); stat = asn1PD_H225SetupAcknowledge_UUIE (pctxt, pvalue->u.setupAcknowledge); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "setupAcknowledge", -1); break; /* notify */ case 13: invokeStartElement (pctxt, "notify", -1); pvalue->u.notify = ALLOC_ASN1ELEM (pctxt, H225Notify_UUIE); stat = asn1PD_H225Notify_UUIE (pctxt, pvalue->u.notify); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "notify", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_h4501SupplementaryService */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UU_PDU_h4501SupplementaryService (OOCTXT* pctxt, H225H323_UU_PDU_h4501SupplementaryService* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_h245Control */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UU_PDU_h245Control (OOCTXT* pctxt, H225H323_UU_PDU_h245Control* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225NonStandardParameter (OOCTXT* pctxt, H225_SeqOfH225NonStandardParameter* pvalue) { int stat = ASN_OK; H225NonStandardParameter* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* CallLinkage */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallLinkage (OOCTXT* pctxt, H225CallLinkage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.globalCallIdPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.threadIdPresent = optbit; /* decode globalCallId */ if (pvalue->m.globalCallIdPresent) { invokeStartElement (pctxt, "globalCallId", -1); stat = asn1PD_H225GloballyUniqueID (pctxt, &pvalue->globalCallId); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "globalCallId", -1); } /* decode threadId */ if (pvalue->m.threadIdPresent) { invokeStartElement (pctxt, "threadId", -1); stat = asn1PD_H225GloballyUniqueID (pctxt, &pvalue->threadId); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "threadId", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_tunnelledSignallingMessage_messageContent */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UU_PDU_tunnelledSignallingMessage_messageContent (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage_messageContent* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1DynOctStr); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->elem[xx1].numocts, pvalue->elem[xx1].data); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU_tunnelledSignallingMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UU_PDU_tunnelledSignallingMessage (OOCTXT* pctxt, H225H323_UU_PDU_tunnelledSignallingMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.tunnellingRequiredPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode tunnelledProtocolID */ invokeStartElement (pctxt, "tunnelledProtocolID", -1); stat = asn1PD_H225TunnelledProtocol (pctxt, &pvalue->tunnelledProtocolID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tunnelledProtocolID", -1); /* decode messageContent */ invokeStartElement (pctxt, "messageContent", -1); stat = asn1PD_H225H323_UU_PDU_tunnelledSignallingMessage_messageContent (pctxt, &pvalue->messageContent); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "messageContent", -1); /* decode tunnellingRequired */ if (pvalue->m.tunnellingRequiredPresent) { invokeStartElement (pctxt, "tunnellingRequired", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "tunnellingRequired", -1); } /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* StimulusControl */ /* */ /**************************************************************/ EXTERN int asn1PD_H225StimulusControl (OOCTXT* pctxt, H225StimulusControl* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.isTextPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.h248MessagePresent = optbit; /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } /* decode isText */ if (pvalue->m.isTextPresent) { invokeStartElement (pctxt, "isText", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "isText", -1); } /* decode h248Message */ if (pvalue->m.h248MessagePresent) { invokeStartElement (pctxt, "h248Message", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->h248Message); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->h248Message.numocts, pvalue->h248Message.data); invokeEndElement (pctxt, "h248Message", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H323_UU_PDU */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UU_PDU (OOCTXT* pctxt, H225H323_UU_PDU* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode h323_message_body */ invokeStartElement (pctxt, "h323_message_body", -1); stat = asn1PD_H225H323_UU_PDU_h323_message_body (pctxt, &pvalue->h323_message_body); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h323_message_body", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 9 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.h4501SupplementaryServicePresent = 1; invokeStartElement (pctxt, "h4501SupplementaryService", -1); stat = asn1PD_H225H323_UU_PDU_h4501SupplementaryService (pctxt, &pvalue->h4501SupplementaryService); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h4501SupplementaryService", -1); break; case 1: pvalue->m.h245TunnelingPresent = 1; invokeStartElement (pctxt, "h245Tunneling", -1); stat = DECODEBIT (pctxt, &pvalue->h245Tunneling); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->h245Tunneling); invokeEndElement (pctxt, "h245Tunneling", -1); break; case 2: pvalue->m.h245ControlPresent = 1; invokeStartElement (pctxt, "h245Control", -1); stat = asn1PD_H225H323_UU_PDU_h245Control (pctxt, &pvalue->h245Control); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245Control", -1); break; case 3: pvalue->m.nonStandardControlPresent = 1; invokeStartElement (pctxt, "nonStandardControl", -1); stat = asn1PD_H225_SeqOfH225NonStandardParameter (pctxt, &pvalue->nonStandardControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardControl", -1); break; case 4: pvalue->m.callLinkagePresent = 1; invokeStartElement (pctxt, "callLinkage", -1); stat = asn1PD_H225CallLinkage (pctxt, &pvalue->callLinkage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callLinkage", -1); break; case 5: pvalue->m.tunnelledSignallingMessagePresent = 1; invokeStartElement (pctxt, "tunnelledSignallingMessage", -1); stat = asn1PD_H225H323_UU_PDU_tunnelledSignallingMessage (pctxt, &pvalue->tunnelledSignallingMessage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tunnelledSignallingMessage", -1); break; case 6: pvalue->m.provisionalRespToH245TunnelingPresent = 1; invokeStartElement (pctxt, "provisionalRespToH245Tunneling", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "provisionalRespToH245Tunneling", -1); break; case 7: pvalue->m.stimulusControlPresent = 1; invokeStartElement (pctxt, "stimulusControl", -1); stat = asn1PD_H225StimulusControl (pctxt, &pvalue->stimulusControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "stimulusControl", -1); break; case 8: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* H323_UserInformation_user_data */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UserInformation_user_data (OOCTXT* pctxt, H225H323_UserInformation_user_data* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode protocol_discriminator */ invokeStartElement (pctxt, "protocol_discriminator", -1); stat = decodeConsUInt8 (pctxt, &pvalue->protocol_discriminator, 0U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->protocol_discriminator); invokeEndElement (pctxt, "protocol_discriminator", -1); /* decode user_information */ invokeStartElement (pctxt, "user_information", -1); stat = asn1PD_H225H323_UserInformation_user_data_user_information (pctxt, &pvalue->user_information); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "user_information", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* H323_UserInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H225H323_UserInformation (OOCTXT* pctxt, H225H323_UserInformation* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.user_dataPresent = optbit; /* decode h323_uu_pdu */ invokeStartElement (pctxt, "h323_uu_pdu", -1); stat = asn1PD_H225H323_UU_PDU (pctxt, &pvalue->h323_uu_pdu); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h323_uu_pdu", -1); /* decode user_data */ if (pvalue->m.user_dataPresent) { invokeStartElement (pctxt, "user_data", -1); stat = asn1PD_H225H323_UserInformation_user_data (pctxt, &pvalue->user_data); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "user_data", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* AddressPattern_range */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AddressPattern_range (OOCTXT* pctxt, H225AddressPattern_range* pvalue) { int stat = ASN_OK; /* decode startOfRange */ invokeStartElement (pctxt, "startOfRange", -1); stat = asn1PD_H225PartyNumber (pctxt, &pvalue->startOfRange); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "startOfRange", -1); /* decode endOfRange */ invokeStartElement (pctxt, "endOfRange", -1); stat = asn1PD_H225PartyNumber (pctxt, &pvalue->endOfRange); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endOfRange", -1); return (stat); } /**************************************************************/ /* */ /* AddressPattern */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AddressPattern (OOCTXT* pctxt, H225AddressPattern* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* wildcard */ case 0: invokeStartElement (pctxt, "wildcard", -1); pvalue->u.wildcard = ALLOC_ASN1ELEM (pctxt, H225AliasAddress); stat = asn1PD_H225AliasAddress (pctxt, pvalue->u.wildcard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "wildcard", -1); break; /* range */ case 1: invokeStartElement (pctxt, "range", -1); pvalue->u.range = ALLOC_ASN1ELEM (pctxt, H225AddressPattern_range); stat = asn1PD_H225AddressPattern_range (pctxt, pvalue->u.range); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "range", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TransportAddress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225TransportAddress (OOCTXT* pctxt, H225_SeqOfH225TransportAddress* pvalue) { int stat = ASN_OK; H225TransportAddress* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225TransportAddress); stat = asn1PD_H225TransportAddress (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* AlternateTransportAddresses */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AlternateTransportAddresses (OOCTXT* pctxt, H225AlternateTransportAddresses* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.annexEPresent = optbit; /* decode annexE */ if (pvalue->m.annexEPresent) { invokeStartElement (pctxt, "annexE", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->annexE); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "annexE", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.sctpPresent = 1; invokeStartElement (pctxt, "sctp", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->sctp); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sctp", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* Endpoint */ /* */ /**************************************************************/ EXTERN int asn1PD_H225Endpoint (OOCTXT* pctxt, H225Endpoint* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.aliasAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callSignalAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.rasAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endpointTypePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.priorityPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.remoteExtensionAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destExtraCallInfoPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode aliasAddress */ if (pvalue->m.aliasAddressPresent) { invokeStartElement (pctxt, "aliasAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->aliasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "aliasAddress", -1); } /* decode callSignalAddress */ if (pvalue->m.callSignalAddressPresent) { invokeStartElement (pctxt, "callSignalAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignalAddress", -1); } /* decode rasAddress */ if (pvalue->m.rasAddressPresent) { invokeStartElement (pctxt, "rasAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rasAddress", -1); } /* decode endpointType */ if (pvalue->m.endpointTypePresent) { invokeStartElement (pctxt, "endpointType", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->endpointType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointType", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode priority */ if (pvalue->m.priorityPresent) { invokeStartElement (pctxt, "priority", -1); stat = decodeConsUInt8 (pctxt, &pvalue->priority, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->priority); invokeEndElement (pctxt, "priority", -1); } /* decode remoteExtensionAddress */ if (pvalue->m.remoteExtensionAddressPresent) { invokeStartElement (pctxt, "remoteExtensionAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "remoteExtensionAddress", -1); } /* decode destExtraCallInfo */ if (pvalue->m.destExtraCallInfoPresent) { invokeStartElement (pctxt, "destExtraCallInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destExtraCallInfo", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 3 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.alternateTransportAddressesPresent = 1; invokeStartElement (pctxt, "alternateTransportAddresses", -1); stat = asn1PD_H225AlternateTransportAddresses (pctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateTransportAddresses", -1); break; case 1: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 2: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UseSpecifiedTransport */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UseSpecifiedTransport (OOCTXT* pctxt, H225UseSpecifiedTransport* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* tcp */ case 0: invokeStartElement (pctxt, "tcp", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "tcp", -1); break; /* annexE */ case 1: invokeStartElement (pctxt, "annexE", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "annexE", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* sctp */ case 3: invokeStartElement (pctxt, "sctp", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "sctp", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* AlternateGK */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AlternateGK (OOCTXT* pctxt, H225AlternateGK* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperIdentifierPresent = optbit; /* decode rasAddress */ invokeStartElement (pctxt, "rasAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rasAddress", -1); /* decode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); } /* decode needToRegister */ invokeStartElement (pctxt, "needToRegister", -1); stat = DECODEBIT (pctxt, &pvalue->needToRegister); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->needToRegister); invokeEndElement (pctxt, "needToRegister", -1); /* decode priority */ invokeStartElement (pctxt, "priority", -1); stat = decodeConsUInt8 (pctxt, &pvalue->priority, 0U, 127U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->priority); invokeEndElement (pctxt, "priority", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AlternateGK */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225AlternateGK (OOCTXT* pctxt, H225_SeqOfH225AlternateGK* pvalue) { int stat = ASN_OK; H225AlternateGK* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225AlternateGK); stat = asn1PD_H225AlternateGK (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* AltGKInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AltGKInfo (OOCTXT* pctxt, H225AltGKInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode alternateGatekeeper */ invokeStartElement (pctxt, "alternateGatekeeper", -1); stat = asn1PD_H225_SeqOfH225AlternateGK (pctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateGatekeeper", -1); /* decode altGKisPermanent */ invokeStartElement (pctxt, "altGKisPermanent", -1); stat = DECODEBIT (pctxt, &pvalue->altGKisPermanent); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->altGKisPermanent); invokeEndElement (pctxt, "altGKisPermanent", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* SecurityErrors2 */ /* */ /**************************************************************/ EXTERN int asn1PD_H225SecurityErrors2 (OOCTXT* pctxt, H225SecurityErrors2* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* securityWrongSyncTime */ case 0: invokeStartElement (pctxt, "securityWrongSyncTime", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongSyncTime", -1); break; /* securityReplay */ case 1: invokeStartElement (pctxt, "securityReplay", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityReplay", -1); break; /* securityWrongGeneralID */ case 2: invokeStartElement (pctxt, "securityWrongGeneralID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongGeneralID", -1); break; /* securityWrongSendersID */ case 3: invokeStartElement (pctxt, "securityWrongSendersID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongSendersID", -1); break; /* securityIntegrityFailed */ case 4: invokeStartElement (pctxt, "securityIntegrityFailed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityIntegrityFailed", -1); break; /* securityWrongOID */ case 5: invokeStartElement (pctxt, "securityWrongOID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityWrongOID", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* EncryptIntAlg */ /* */ /**************************************************************/ EXTERN int asn1PD_H225EncryptIntAlg (OOCTXT* pctxt, H225EncryptIntAlg* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* isoAlgorithm */ case 1: invokeStartElement (pctxt, "isoAlgorithm", -1); pvalue->u.isoAlgorithm = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.isoAlgorithm); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.isoAlgorithm->numids, pvalue->u.isoAlgorithm->subid); invokeEndElement (pctxt, "isoAlgorithm", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* NonIsoIntegrityMechanism */ /* */ /**************************************************************/ EXTERN int asn1PD_H225NonIsoIntegrityMechanism (OOCTXT* pctxt, H225NonIsoIntegrityMechanism* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* hMAC_MD5 */ case 0: invokeStartElement (pctxt, "hMAC_MD5", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hMAC_MD5", -1); break; /* hMAC_iso10118_2_s */ case 1: invokeStartElement (pctxt, "hMAC_iso10118_2_s", -1); pvalue->u.hMAC_iso10118_2_s = ALLOC_ASN1ELEM (pctxt, H225EncryptIntAlg); stat = asn1PD_H225EncryptIntAlg (pctxt, pvalue->u.hMAC_iso10118_2_s); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "hMAC_iso10118_2_s", -1); break; /* hMAC_iso10118_2_l */ case 2: invokeStartElement (pctxt, "hMAC_iso10118_2_l", -1); pvalue->u.hMAC_iso10118_2_l = ALLOC_ASN1ELEM (pctxt, H225EncryptIntAlg); stat = asn1PD_H225EncryptIntAlg (pctxt, pvalue->u.hMAC_iso10118_2_l); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "hMAC_iso10118_2_l", -1); break; /* hMAC_iso10118_3 */ case 3: invokeStartElement (pctxt, "hMAC_iso10118_3", -1); pvalue->u.hMAC_iso10118_3 = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.hMAC_iso10118_3); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.hMAC_iso10118_3->numids, pvalue->u.hMAC_iso10118_3->subid); invokeEndElement (pctxt, "hMAC_iso10118_3", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* IntegrityMechanism */ /* */ /**************************************************************/ EXTERN int asn1PD_H225IntegrityMechanism (OOCTXT* pctxt, H225IntegrityMechanism* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* nonStandard */ case 0: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H225NonStandardParameter); stat = asn1PD_H225NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; /* digSig */ case 1: invokeStartElement (pctxt, "digSig", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "digSig", -1); break; /* iso9797 */ case 2: invokeStartElement (pctxt, "iso9797", -1); pvalue->u.iso9797 = ALLOC_ASN1ELEM (pctxt, ASN1OBJID); stat = decodeObjectIdentifier (pctxt, pvalue->u.iso9797); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->u.iso9797->numids, pvalue->u.iso9797->subid); invokeEndElement (pctxt, "iso9797", -1); break; /* nonIsoIM */ case 3: invokeStartElement (pctxt, "nonIsoIM", -1); pvalue->u.nonIsoIM = ALLOC_ASN1ELEM (pctxt, H225NonIsoIntegrityMechanism); stat = asn1PD_H225NonIsoIntegrityMechanism (pctxt, pvalue->u.nonIsoIM); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonIsoIM", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ICV */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ICV (OOCTXT* pctxt, H225ICV* pvalue) { int stat = ASN_OK; /* decode algorithmOID */ invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); /* decode icv */ invokeStartElement (pctxt, "icv", -1); stat = decodeDynBitString (pctxt, (ASN1DynBitStr*)&pvalue->icv); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->icv.numbits, pvalue->icv.data); invokeEndElement (pctxt, "icv", -1); return (stat); } /**************************************************************/ /* */ /* CapacityReportingCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CapacityReportingCapability (OOCTXT* pctxt, H225CapacityReportingCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode canReportCallCapacity */ invokeStartElement (pctxt, "canReportCallCapacity", -1); stat = DECODEBIT (pctxt, &pvalue->canReportCallCapacity); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canReportCallCapacity); invokeEndElement (pctxt, "canReportCallCapacity", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CapacityReportingSpecification_when */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CapacityReportingSpecification_when (OOCTXT* pctxt, H225CapacityReportingSpecification_when* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.callStartPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callEndPresent = optbit; /* decode callStart */ if (pvalue->m.callStartPresent) { invokeStartElement (pctxt, "callStart", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "callStart", -1); } /* decode callEnd */ if (pvalue->m.callEndPresent) { invokeStartElement (pctxt, "callEnd", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "callEnd", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CapacityReportingSpecification */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CapacityReportingSpecification (OOCTXT* pctxt, H225CapacityReportingSpecification* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode when */ invokeStartElement (pctxt, "when", -1); stat = asn1PD_H225CapacityReportingSpecification_when (pctxt, &pvalue->when); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "when", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RasUsageInfoTypes */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RasUsageInfoTypes (OOCTXT* pctxt, H225RasUsageInfoTypes* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.startTimePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endTimePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.terminationCausePresent = optbit; /* decode nonStandardUsageTypes */ invokeStartElement (pctxt, "nonStandardUsageTypes", -1); stat = asn1PD_H225_SeqOfH225NonStandardParameter (pctxt, &pvalue->nonStandardUsageTypes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardUsageTypes", -1); /* decode startTime */ if (pvalue->m.startTimePresent) { invokeStartElement (pctxt, "startTime", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "startTime", -1); } /* decode endTime */ if (pvalue->m.endTimePresent) { invokeStartElement (pctxt, "endTime", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "endTime", -1); } /* decode terminationCause */ if (pvalue->m.terminationCausePresent) { invokeStartElement (pctxt, "terminationCause", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "terminationCause", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RasUsageSpecification_when */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RasUsageSpecification_when (OOCTXT* pctxt, H225RasUsageSpecification_when* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.startPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.inIrrPresent = optbit; /* decode start */ if (pvalue->m.startPresent) { invokeStartElement (pctxt, "start", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "start", -1); } /* decode end */ if (pvalue->m.endPresent) { invokeStartElement (pctxt, "end", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "end", -1); } /* decode inIrr */ if (pvalue->m.inIrrPresent) { invokeStartElement (pctxt, "inIrr", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "inIrr", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RasUsageSpecification_callStartingPoint */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RasUsageSpecification_callStartingPoint (OOCTXT* pctxt, H225RasUsageSpecification_callStartingPoint* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.alertingPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.connectPresent = optbit; /* decode alerting */ if (pvalue->m.alertingPresent) { invokeStartElement (pctxt, "alerting", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "alerting", -1); } /* decode connect */ if (pvalue->m.connectPresent) { invokeStartElement (pctxt, "connect", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "connect", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RasUsageSpecification */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RasUsageSpecification (OOCTXT* pctxt, H225RasUsageSpecification* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.callStartingPointPresent = optbit; /* decode when */ invokeStartElement (pctxt, "when", -1); stat = asn1PD_H225RasUsageSpecification_when (pctxt, &pvalue->when); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "when", -1); /* decode callStartingPoint */ if (pvalue->m.callStartingPointPresent) { invokeStartElement (pctxt, "callStartingPoint", -1); stat = asn1PD_H225RasUsageSpecification_callStartingPoint (pctxt, &pvalue->callStartingPoint); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callStartingPoint", -1); } /* decode required */ invokeStartElement (pctxt, "required", -1); stat = asn1PD_H225RasUsageInfoTypes (pctxt, &pvalue->required); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "required", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RasUsageInformation */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RasUsageInformation (OOCTXT* pctxt, H225RasUsageInformation* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.alertingTimePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.connectTimePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endTimePresent = optbit; /* decode nonStandardUsageFields */ invokeStartElement (pctxt, "nonStandardUsageFields", -1); stat = asn1PD_H225_SeqOfH225NonStandardParameter (pctxt, &pvalue->nonStandardUsageFields); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardUsageFields", -1); /* decode alertingTime */ if (pvalue->m.alertingTimePresent) { invokeStartElement (pctxt, "alertingTime", -1); stat = asn1PD_H235TimeStamp (pctxt, &pvalue->alertingTime); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alertingTime", -1); } /* decode connectTime */ if (pvalue->m.connectTimePresent) { invokeStartElement (pctxt, "connectTime", -1); stat = asn1PD_H235TimeStamp (pctxt, &pvalue->connectTime); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "connectTime", -1); } /* decode endTime */ if (pvalue->m.endTimePresent) { invokeStartElement (pctxt, "endTime", -1); stat = asn1PD_H235TimeStamp (pctxt, &pvalue->endTime); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endTime", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CallTerminationCause */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallTerminationCause (OOCTXT* pctxt, H225CallTerminationCause* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* releaseCompleteReason */ case 0: invokeStartElement (pctxt, "releaseCompleteReason", -1); pvalue->u.releaseCompleteReason = ALLOC_ASN1ELEM (pctxt, H225ReleaseCompleteReason); stat = asn1PD_H225ReleaseCompleteReason (pctxt, pvalue->u.releaseCompleteReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "releaseCompleteReason", -1); break; /* releaseCompleteCauseIE */ case 1: invokeStartElement (pctxt, "releaseCompleteCauseIE", -1); pvalue->u.releaseCompleteCauseIE = ALLOC_ASN1ELEM (pctxt, H225CallTerminationCause_releaseCompleteCauseIE); stat = asn1PD_H225CallTerminationCause_releaseCompleteCauseIE (pctxt, pvalue->u.releaseCompleteCauseIE); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "releaseCompleteCauseIE", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TransportChannelInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportChannelInfo (OOCTXT* pctxt, H225TransportChannelInfo* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.sendAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.recvAddressPresent = optbit; /* decode sendAddress */ if (pvalue->m.sendAddressPresent) { invokeStartElement (pctxt, "sendAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->sendAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sendAddress", -1); } /* decode recvAddress */ if (pvalue->m.recvAddressPresent) { invokeStartElement (pctxt, "recvAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->recvAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "recvAddress", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* BandwidthDetails */ /* */ /**************************************************************/ EXTERN int asn1PD_H225BandwidthDetails (OOCTXT* pctxt, H225BandwidthDetails* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode sender */ invokeStartElement (pctxt, "sender", -1); stat = DECODEBIT (pctxt, &pvalue->sender); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->sender); invokeEndElement (pctxt, "sender", -1); /* decode multicast */ invokeStartElement (pctxt, "multicast", -1); stat = DECODEBIT (pctxt, &pvalue->multicast); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multicast); invokeEndElement (pctxt, "multicast", -1); /* decode bandwidth */ invokeStartElement (pctxt, "bandwidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandwidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandwidth", -1); /* decode rtcpAddresses */ invokeStartElement (pctxt, "rtcpAddresses", -1); stat = asn1PD_H225TransportChannelInfo (pctxt, &pvalue->rtcpAddresses); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtcpAddresses", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* CallCreditCapability */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallCreditCapability (OOCTXT* pctxt, H225CallCreditCapability* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.canDisplayAmountStringPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.canEnforceDurationLimitPresent = optbit; /* decode canDisplayAmountString */ if (pvalue->m.canDisplayAmountStringPresent) { invokeStartElement (pctxt, "canDisplayAmountString", -1); stat = DECODEBIT (pctxt, &pvalue->canDisplayAmountString); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canDisplayAmountString); invokeEndElement (pctxt, "canDisplayAmountString", -1); } /* decode canEnforceDurationLimit */ if (pvalue->m.canEnforceDurationLimitPresent) { invokeStartElement (pctxt, "canEnforceDurationLimit", -1); stat = DECODEBIT (pctxt, &pvalue->canEnforceDurationLimit); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canEnforceDurationLimit); invokeEndElement (pctxt, "canEnforceDurationLimit", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RTPSession_associatedSessionIds */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RTPSession_associatedSessionIds (OOCTXT* pctxt, H225RTPSession_associatedSessionIds* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1UINT8); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeConsUInt8 (pctxt, &pvalue->elem[xx1], 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RTPSession */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RTPSession (OOCTXT* pctxt, H225RTPSession* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode rtpAddress */ invokeStartElement (pctxt, "rtpAddress", -1); stat = asn1PD_H225TransportChannelInfo (pctxt, &pvalue->rtpAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtpAddress", -1); /* decode rtcpAddress */ invokeStartElement (pctxt, "rtcpAddress", -1); stat = asn1PD_H225TransportChannelInfo (pctxt, &pvalue->rtcpAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rtcpAddress", -1); /* decode cname */ invokeStartElement (pctxt, "cname", -1); stat = decodeConstrainedStringEx (pctxt, &pvalue->cname, 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->cname); invokeEndElement (pctxt, "cname", -1); /* decode ssrc */ invokeStartElement (pctxt, "ssrc", -1); stat = decodeConsUnsigned (pctxt, &pvalue->ssrc, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->ssrc); invokeEndElement (pctxt, "ssrc", -1); /* decode sessionId */ invokeStartElement (pctxt, "sessionId", -1); stat = decodeConsUInt8 (pctxt, &pvalue->sessionId, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->sessionId); invokeEndElement (pctxt, "sessionId", -1); /* decode associatedSessionIds */ invokeStartElement (pctxt, "associatedSessionIds", -1); stat = asn1PD_H225RTPSession_associatedSessionIds (pctxt, &pvalue->associatedSessionIds); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "associatedSessionIds", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.multicastPresent = 1; invokeStartElement (pctxt, "multicast", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "multicast", -1); break; case 1: pvalue->m.bandwidthPresent = 1; invokeStartElement (pctxt, "bandwidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandwidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandwidth", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225Endpoint */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225Endpoint (OOCTXT* pctxt, H225_SeqOfH225Endpoint* pvalue) { int stat = ASN_OK; H225Endpoint* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225Endpoint); stat = asn1PD_H225Endpoint (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AuthenticationMechanism */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225AuthenticationMechanism (OOCTXT* pctxt, H225_SeqOfH225AuthenticationMechanism* pvalue) { int stat = ASN_OK; H235AuthenticationMechanism* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H235AuthenticationMechanism); stat = asn1PD_H235AuthenticationMechanism (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* GatekeeperRequest_algorithmOIDs */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatekeeperRequest_algorithmOIDs (OOCTXT* pctxt, H225GatekeeperRequest_algorithmOIDs* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1OBJID); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = decodeObjectIdentifier (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->elem[xx1].numids, pvalue->elem[xx1].subid); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225IntegrityMechanism */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225IntegrityMechanism (OOCTXT* pctxt, H225_SeqOfH225IntegrityMechanism* pvalue) { int stat = ASN_OK; H225IntegrityMechanism* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225IntegrityMechanism); stat = asn1PD_H225IntegrityMechanism (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* GatekeeperRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatekeeperRequest (OOCTXT* pctxt, H225GatekeeperRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperIdentifierPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callServicesPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endpointAliasPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode rasAddress */ invokeStartElement (pctxt, "rasAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rasAddress", -1); /* decode endpointType */ invokeStartElement (pctxt, "endpointType", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->endpointType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointType", -1); /* decode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); } /* decode callServices */ if (pvalue->m.callServicesPresent) { invokeStartElement (pctxt, "callServices", -1); stat = asn1PD_H225QseriesOptions (pctxt, &pvalue->callServices); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callServices", -1); } /* decode endpointAlias */ if (pvalue->m.endpointAliasPresent) { invokeStartElement (pctxt, "endpointAlias", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->endpointAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointAlias", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 10 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.alternateEndpointsPresent = 1; invokeStartElement (pctxt, "alternateEndpoints", -1); stat = asn1PD_H225_SeqOfH225Endpoint (pctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateEndpoints", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.authenticationCapabilityPresent = 1; invokeStartElement (pctxt, "authenticationCapability", -1); stat = asn1PD_H225_SeqOfH225AuthenticationMechanism (pctxt, &pvalue->authenticationCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "authenticationCapability", -1); break; case 4: pvalue->m.algorithmOIDsPresent = 1; invokeStartElement (pctxt, "algorithmOIDs", -1); stat = asn1PD_H225GatekeeperRequest_algorithmOIDs (pctxt, &pvalue->algorithmOIDs); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "algorithmOIDs", -1); break; case 5: pvalue->m.integrityPresent = 1; invokeStartElement (pctxt, "integrity", -1); stat = asn1PD_H225_SeqOfH225IntegrityMechanism (pctxt, &pvalue->integrity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrity", -1); break; case 6: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 7: pvalue->m.supportsAltGKPresent = 1; invokeStartElement (pctxt, "supportsAltGK", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "supportsAltGK", -1); break; case 8: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 9: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* GatekeeperConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatekeeperConfirm (OOCTXT* pctxt, H225GatekeeperConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperIdentifierPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); } /* decode rasAddress */ invokeStartElement (pctxt, "rasAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rasAddress", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 9 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.alternateGatekeeperPresent = 1; invokeStartElement (pctxt, "alternateGatekeeper", -1); stat = asn1PD_H225_SeqOfH225AlternateGK (pctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateGatekeeper", -1); break; case 1: pvalue->m.authenticationModePresent = 1; invokeStartElement (pctxt, "authenticationMode", -1); stat = asn1PD_H235AuthenticationMechanism (pctxt, &pvalue->authenticationMode); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "authenticationMode", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.algorithmOIDPresent = 1; invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); break; case 5: pvalue->m.integrityPresent = 1; invokeStartElement (pctxt, "integrity", -1); stat = asn1PD_H225_SeqOfH225IntegrityMechanism (pctxt, &pvalue->integrity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrity", -1); break; case 6: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 7: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 8: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* GatekeeperRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatekeeperRejectReason (OOCTXT* pctxt, H225GatekeeperRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* resourceUnavailable */ case 0: invokeStartElement (pctxt, "resourceUnavailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "resourceUnavailable", -1); break; /* terminalExcluded */ case 1: invokeStartElement (pctxt, "terminalExcluded", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "terminalExcluded", -1); break; /* invalidRevision */ case 2: invokeStartElement (pctxt, "invalidRevision", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidRevision", -1); break; /* undefinedReason */ case 3: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* securityDenial */ case 5: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* genericDataReason */ case 6: invokeStartElement (pctxt, "genericDataReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "genericDataReason", -1); break; /* neededFeatureNotSupported */ case 7: invokeStartElement (pctxt, "neededFeatureNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "neededFeatureNotSupported", -1); break; /* securityError */ case 8: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors); stat = asn1PD_H225SecurityErrors (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* GatekeeperReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H225GatekeeperReject (OOCTXT* pctxt, H225GatekeeperReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperIdentifierPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); } /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H225GatekeeperRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 6 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.altGKInfoPresent = 1; invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 4: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 5: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AddressPattern */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225AddressPattern (OOCTXT* pctxt, H225_SeqOfH225AddressPattern* pvalue) { int stat = ASN_OK; H225AddressPattern* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225AddressPattern); stat = asn1PD_H225AddressPattern (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225H248PackagesDescriptor */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225H248PackagesDescriptor (OOCTXT* pctxt, H225_SeqOfH225H248PackagesDescriptor* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, H225H248PackagesDescriptor); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H225H248PackagesDescriptor (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* RegistrationRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RegistrationRequest (OOCTXT* pctxt, H225RegistrationRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.terminalAliasPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperIdentifierPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode discoveryComplete */ invokeStartElement (pctxt, "discoveryComplete", -1); stat = DECODEBIT (pctxt, &pvalue->discoveryComplete); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->discoveryComplete); invokeEndElement (pctxt, "discoveryComplete", -1); /* decode callSignalAddress */ invokeStartElement (pctxt, "callSignalAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignalAddress", -1); /* decode rasAddress */ invokeStartElement (pctxt, "rasAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rasAddress", -1); /* decode terminalType */ invokeStartElement (pctxt, "terminalType", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->terminalType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalType", -1); /* decode terminalAlias */ if (pvalue->m.terminalAliasPresent) { invokeStartElement (pctxt, "terminalAlias", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->terminalAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalAlias", -1); } /* decode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); } /* decode endpointVendor */ invokeStartElement (pctxt, "endpointVendor", -1); stat = asn1PD_H225VendorIdentifier (pctxt, &pvalue->endpointVendor); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointVendor", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 23 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.alternateEndpointsPresent = 1; invokeStartElement (pctxt, "alternateEndpoints", -1); stat = asn1PD_H225_SeqOfH225Endpoint (pctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateEndpoints", -1); break; case 1: pvalue->m.timeToLivePresent = 1; invokeStartElement (pctxt, "timeToLive", -1); stat = asn1PD_H225TimeToLive (pctxt, &pvalue->timeToLive); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "timeToLive", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 5: pvalue->m.keepAlivePresent = 1; invokeStartElement (pctxt, "keepAlive", -1); stat = DECODEBIT (pctxt, &pvalue->keepAlive); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->keepAlive); invokeEndElement (pctxt, "keepAlive", -1); break; case 6: pvalue->m.endpointIdentifierPresent = 1; invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); break; case 7: pvalue->m.willSupplyUUIEsPresent = 1; invokeStartElement (pctxt, "willSupplyUUIEs", -1); stat = DECODEBIT (pctxt, &pvalue->willSupplyUUIEs); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->willSupplyUUIEs); invokeEndElement (pctxt, "willSupplyUUIEs", -1); break; case 8: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 9: pvalue->m.alternateTransportAddressesPresent = 1; invokeStartElement (pctxt, "alternateTransportAddresses", -1); stat = asn1PD_H225AlternateTransportAddresses (pctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateTransportAddresses", -1); break; case 10: pvalue->m.additiveRegistrationPresent = 1; invokeStartElement (pctxt, "additiveRegistration", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "additiveRegistration", -1); break; case 11: pvalue->m.terminalAliasPatternPresent = 1; invokeStartElement (pctxt, "terminalAliasPattern", -1); stat = asn1PD_H225_SeqOfH225AddressPattern (pctxt, &pvalue->terminalAliasPattern); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalAliasPattern", -1); break; case 12: pvalue->m.supportsAltGKPresent = 1; invokeStartElement (pctxt, "supportsAltGK", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "supportsAltGK", -1); break; case 13: pvalue->m.usageReportingCapabilityPresent = 1; invokeStartElement (pctxt, "usageReportingCapability", -1); stat = asn1PD_H225RasUsageInfoTypes (pctxt, &pvalue->usageReportingCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageReportingCapability", -1); break; case 14: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 15: pvalue->m.supportedH248PackagesPresent = 1; invokeStartElement (pctxt, "supportedH248Packages", -1); stat = asn1PD_H225_SeqOfH225H248PackagesDescriptor (pctxt, &pvalue->supportedH248Packages); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedH248Packages", -1); break; case 16: pvalue->m.callCreditCapabilityPresent = 1; invokeStartElement (pctxt, "callCreditCapability", -1); stat = asn1PD_H225CallCreditCapability (pctxt, &pvalue->callCreditCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callCreditCapability", -1); break; case 17: pvalue->m.capacityReportingCapabilityPresent = 1; invokeStartElement (pctxt, "capacityReportingCapability", -1); stat = asn1PD_H225CapacityReportingCapability (pctxt, &pvalue->capacityReportingCapability); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacityReportingCapability", -1); break; case 18: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 19: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 20: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; case 21: pvalue->m.restartPresent = 1; invokeStartElement (pctxt, "restart", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "restart", -1); break; case 22: pvalue->m.supportsACFSequencesPresent = 1; invokeStartElement (pctxt, "supportsACFSequences", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "supportsACFSequences", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* RegistrationConfirm_preGrantedARQ */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RegistrationConfirm_preGrantedARQ (OOCTXT* pctxt, H225RegistrationConfirm_preGrantedARQ* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode makeCall */ invokeStartElement (pctxt, "makeCall", -1); stat = DECODEBIT (pctxt, &pvalue->makeCall); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->makeCall); invokeEndElement (pctxt, "makeCall", -1); /* decode useGKCallSignalAddressToMakeCall */ invokeStartElement (pctxt, "useGKCallSignalAddressToMakeCall", -1); stat = DECODEBIT (pctxt, &pvalue->useGKCallSignalAddressToMakeCall); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->useGKCallSignalAddressToMakeCall); invokeEndElement (pctxt, "useGKCallSignalAddressToMakeCall", -1); /* decode answerCall */ invokeStartElement (pctxt, "answerCall", -1); stat = DECODEBIT (pctxt, &pvalue->answerCall); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->answerCall); invokeEndElement (pctxt, "answerCall", -1); /* decode useGKCallSignalAddressToAnswer */ invokeStartElement (pctxt, "useGKCallSignalAddressToAnswer", -1); stat = DECODEBIT (pctxt, &pvalue->useGKCallSignalAddressToAnswer); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->useGKCallSignalAddressToAnswer); invokeEndElement (pctxt, "useGKCallSignalAddressToAnswer", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 4 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.irrFrequencyInCallPresent = 1; invokeStartElement (pctxt, "irrFrequencyInCall", -1); stat = decodeConsUInt16 (pctxt, &pvalue->irrFrequencyInCall, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->irrFrequencyInCall); invokeEndElement (pctxt, "irrFrequencyInCall", -1); break; case 1: pvalue->m.totalBandwidthRestrictionPresent = 1; invokeStartElement (pctxt, "totalBandwidthRestriction", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->totalBandwidthRestriction); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "totalBandwidthRestriction", -1); break; case 2: pvalue->m.alternateTransportAddressesPresent = 1; invokeStartElement (pctxt, "alternateTransportAddresses", -1); stat = asn1PD_H225AlternateTransportAddresses (pctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateTransportAddresses", -1); break; case 3: pvalue->m.useSpecifiedTransportPresent = 1; invokeStartElement (pctxt, "useSpecifiedTransport", -1); stat = asn1PD_H225UseSpecifiedTransport (pctxt, &pvalue->useSpecifiedTransport); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "useSpecifiedTransport", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225RasUsageSpecification */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225RasUsageSpecification (OOCTXT* pctxt, H225_SeqOfH225RasUsageSpecification* pvalue) { int stat = ASN_OK; H225RasUsageSpecification* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225RasUsageSpecification); stat = asn1PD_H225RasUsageSpecification (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* RegistrationConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RegistrationConfirm (OOCTXT* pctxt, H225RegistrationConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.terminalAliasPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperIdentifierPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode callSignalAddress */ invokeStartElement (pctxt, "callSignalAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignalAddress", -1); /* decode terminalAlias */ if (pvalue->m.terminalAliasPresent) { invokeStartElement (pctxt, "terminalAlias", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->terminalAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalAlias", -1); } /* decode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); } /* decode endpointIdentifier */ invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 17 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.alternateGatekeeperPresent = 1; invokeStartElement (pctxt, "alternateGatekeeper", -1); stat = asn1PD_H225_SeqOfH225AlternateGK (pctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateGatekeeper", -1); break; case 1: pvalue->m.timeToLivePresent = 1; invokeStartElement (pctxt, "timeToLive", -1); stat = asn1PD_H225TimeToLive (pctxt, &pvalue->timeToLive); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "timeToLive", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 5: pvalue->m.willRespondToIRRPresent = 1; invokeStartElement (pctxt, "willRespondToIRR", -1); stat = DECODEBIT (pctxt, &pvalue->willRespondToIRR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->willRespondToIRR); invokeEndElement (pctxt, "willRespondToIRR", -1); break; case 6: pvalue->m.preGrantedARQPresent = 1; invokeStartElement (pctxt, "preGrantedARQ", -1); stat = asn1PD_H225RegistrationConfirm_preGrantedARQ (pctxt, &pvalue->preGrantedARQ); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "preGrantedARQ", -1); break; case 7: pvalue->m.maintainConnectionPresent = 1; invokeStartElement (pctxt, "maintainConnection", -1); stat = DECODEBIT (pctxt, &pvalue->maintainConnection); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->maintainConnection); invokeEndElement (pctxt, "maintainConnection", -1); break; case 8: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 9: pvalue->m.supportsAdditiveRegistrationPresent = 1; invokeStartElement (pctxt, "supportsAdditiveRegistration", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "supportsAdditiveRegistration", -1); break; case 10: pvalue->m.terminalAliasPatternPresent = 1; invokeStartElement (pctxt, "terminalAliasPattern", -1); stat = asn1PD_H225_SeqOfH225AddressPattern (pctxt, &pvalue->terminalAliasPattern); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalAliasPattern", -1); break; case 11: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; case 12: pvalue->m.usageSpecPresent = 1; invokeStartElement (pctxt, "usageSpec", -1); stat = asn1PD_H225_SeqOfH225RasUsageSpecification (pctxt, &pvalue->usageSpec); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageSpec", -1); break; case 13: pvalue->m.featureServerAliasPresent = 1; invokeStartElement (pctxt, "featureServerAlias", -1); stat = asn1PD_H225AliasAddress (pctxt, &pvalue->featureServerAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureServerAlias", -1); break; case 14: pvalue->m.capacityReportingSpecPresent = 1; invokeStartElement (pctxt, "capacityReportingSpec", -1); stat = asn1PD_H225CapacityReportingSpecification (pctxt, &pvalue->capacityReportingSpec); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacityReportingSpec", -1); break; case 15: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 16: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* RegistrationRejectReason_invalidTerminalAliases */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RegistrationRejectReason_invalidTerminalAliases (OOCTXT* pctxt, H225RegistrationRejectReason_invalidTerminalAliases* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.terminalAliasPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.terminalAliasPatternPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.supportedPrefixesPresent = optbit; /* decode terminalAlias */ if (pvalue->m.terminalAliasPresent) { invokeStartElement (pctxt, "terminalAlias", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->terminalAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalAlias", -1); } /* decode terminalAliasPattern */ if (pvalue->m.terminalAliasPatternPresent) { invokeStartElement (pctxt, "terminalAliasPattern", -1); stat = asn1PD_H225_SeqOfH225AddressPattern (pctxt, &pvalue->terminalAliasPattern); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminalAliasPattern", -1); } /* decode supportedPrefixes */ if (pvalue->m.supportedPrefixesPresent) { invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* RegistrationRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RegistrationRejectReason (OOCTXT* pctxt, H225RegistrationRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 7); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* discoveryRequired */ case 0: invokeStartElement (pctxt, "discoveryRequired", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "discoveryRequired", -1); break; /* invalidRevision */ case 1: invokeStartElement (pctxt, "invalidRevision", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidRevision", -1); break; /* invalidCallSignalAddress */ case 2: invokeStartElement (pctxt, "invalidCallSignalAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidCallSignalAddress", -1); break; /* invalidRASAddress */ case 3: invokeStartElement (pctxt, "invalidRASAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidRASAddress", -1); break; /* duplicateAlias */ case 4: invokeStartElement (pctxt, "duplicateAlias", -1); pvalue->u.duplicateAlias = ALLOC_ASN1ELEM (pctxt, H225_SeqOfH225AliasAddress); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, pvalue->u.duplicateAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "duplicateAlias", -1); break; /* invalidTerminalType */ case 5: invokeStartElement (pctxt, "invalidTerminalType", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidTerminalType", -1); break; /* undefinedReason */ case 6: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; /* transportNotSupported */ case 7: invokeStartElement (pctxt, "transportNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transportNotSupported", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 9; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* transportQOSNotSupported */ case 9: invokeStartElement (pctxt, "transportQOSNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "transportQOSNotSupported", -1); break; /* resourceUnavailable */ case 10: invokeStartElement (pctxt, "resourceUnavailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "resourceUnavailable", -1); break; /* invalidAlias */ case 11: invokeStartElement (pctxt, "invalidAlias", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidAlias", -1); break; /* securityDenial */ case 12: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* fullRegistrationRequired */ case 13: invokeStartElement (pctxt, "fullRegistrationRequired", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "fullRegistrationRequired", -1); break; /* additiveRegistrationNotSupported */ case 14: invokeStartElement (pctxt, "additiveRegistrationNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "additiveRegistrationNotSupported", -1); break; /* invalidTerminalAliases */ case 15: invokeStartElement (pctxt, "invalidTerminalAliases", -1); pvalue->u.invalidTerminalAliases = ALLOC_ASN1ELEM (pctxt, H225RegistrationRejectReason_invalidTerminalAliases); stat = asn1PD_H225RegistrationRejectReason_invalidTerminalAliases (pctxt, pvalue->u.invalidTerminalAliases); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "invalidTerminalAliases", -1); break; /* genericDataReason */ case 16: invokeStartElement (pctxt, "genericDataReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "genericDataReason", -1); break; /* neededFeatureNotSupported */ case 17: invokeStartElement (pctxt, "neededFeatureNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "neededFeatureNotSupported", -1); break; /* securityError */ case 18: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors); stat = asn1PD_H225SecurityErrors (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* RegistrationReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RegistrationReject (OOCTXT* pctxt, H225RegistrationReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.gatekeeperIdentifierPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H225RegistrationRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); /* decode gatekeeperIdentifier */ if (pvalue->m.gatekeeperIdentifierPresent) { invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 6 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.altGKInfoPresent = 1; invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 4: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 5: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UnregRequestReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UnregRequestReason (OOCTXT* pctxt, H225UnregRequestReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* reregistrationRequired */ case 0: invokeStartElement (pctxt, "reregistrationRequired", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "reregistrationRequired", -1); break; /* ttlExpired */ case 1: invokeStartElement (pctxt, "ttlExpired", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "ttlExpired", -1); break; /* securityDenial */ case 2: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* undefinedReason */ case 3: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* maintenance */ case 5: invokeStartElement (pctxt, "maintenance", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "maintenance", -1); break; /* securityError */ case 6: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors2); stat = asn1PD_H225SecurityErrors2 (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* UnregistrationRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UnregistrationRequest (OOCTXT* pctxt, H225UnregistrationRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.endpointAliasPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endpointIdentifierPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode callSignalAddress */ invokeStartElement (pctxt, "callSignalAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignalAddress", -1); /* decode endpointAlias */ if (pvalue->m.endpointAliasPresent) { invokeStartElement (pctxt, "endpointAlias", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->endpointAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointAlias", -1); } /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode endpointIdentifier */ if (pvalue->m.endpointIdentifierPresent) { invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 10 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.alternateEndpointsPresent = 1; invokeStartElement (pctxt, "alternateEndpoints", -1); stat = asn1PD_H225_SeqOfH225Endpoint (pctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateEndpoints", -1); break; case 1: pvalue->m.gatekeeperIdentifierPresent = 1; invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 5: pvalue->m.reasonPresent = 1; invokeStartElement (pctxt, "reason", -1); stat = asn1PD_H225UnregRequestReason (pctxt, &pvalue->reason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "reason", -1); break; case 6: pvalue->m.endpointAliasPatternPresent = 1; invokeStartElement (pctxt, "endpointAliasPattern", -1); stat = asn1PD_H225_SeqOfH225AddressPattern (pctxt, &pvalue->endpointAliasPattern); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointAliasPattern", -1); break; case 7: pvalue->m.supportedPrefixesPresent = 1; invokeStartElement (pctxt, "supportedPrefixes", -1); stat = asn1PD_H225_SeqOfH225SupportedPrefix (pctxt, &pvalue->supportedPrefixes); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedPrefixes", -1); break; case 8: pvalue->m.alternateGatekeeperPresent = 1; invokeStartElement (pctxt, "alternateGatekeeper", -1); stat = asn1PD_H225_SeqOfH225AlternateGK (pctxt, &pvalue->alternateGatekeeper); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateGatekeeper", -1); break; case 9: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UnregistrationConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UnregistrationConfirm (OOCTXT* pctxt, H225UnregistrationConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 4 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 1: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 2: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 3: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UnregRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UnregRejectReason (OOCTXT* pctxt, H225UnregRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* notCurrentlyRegistered */ case 0: invokeStartElement (pctxt, "notCurrentlyRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "notCurrentlyRegistered", -1); break; /* callInProgress */ case 1: invokeStartElement (pctxt, "callInProgress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "callInProgress", -1); break; /* undefinedReason */ case 2: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* permissionDenied */ case 4: invokeStartElement (pctxt, "permissionDenied", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "permissionDenied", -1); break; /* securityDenial */ case 5: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* securityError */ case 6: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors2); stat = asn1PD_H225SecurityErrors2 (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* UnregistrationReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UnregistrationReject (OOCTXT* pctxt, H225UnregistrationReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H225UnregRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 5 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.altGKInfoPresent = 1; invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 4: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* CallModel */ /* */ /**************************************************************/ EXTERN int asn1PD_H225CallModel (OOCTXT* pctxt, H225CallModel* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* direct */ case 0: invokeStartElement (pctxt, "direct", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "direct", -1); break; /* gatekeeperRouted */ case 1: invokeStartElement (pctxt, "gatekeeperRouted", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "gatekeeperRouted", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* TransportQOS */ /* */ /**************************************************************/ EXTERN int asn1PD_H225TransportQOS (OOCTXT* pctxt, H225TransportQOS* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* endpointControlled */ case 0: invokeStartElement (pctxt, "endpointControlled", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "endpointControlled", -1); break; /* gatekeeperControlled */ case 1: invokeStartElement (pctxt, "gatekeeperControlled", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "gatekeeperControlled", -1); break; /* noControl */ case 2: invokeStartElement (pctxt, "noControl", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noControl", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* AdmissionRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AdmissionRequest (OOCTXT* pctxt, H225AdmissionRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.callModelPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destinationInfoPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destCallSignalAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.destExtraCallInfoPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.srcCallSignalAddressPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callServicesPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode callType */ invokeStartElement (pctxt, "callType", -1); stat = asn1PD_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callType", -1); /* decode callModel */ if (pvalue->m.callModelPresent) { invokeStartElement (pctxt, "callModel", -1); stat = asn1PD_H225CallModel (pctxt, &pvalue->callModel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callModel", -1); } /* decode endpointIdentifier */ invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); /* decode destinationInfo */ if (pvalue->m.destinationInfoPresent) { invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); } /* decode destCallSignalAddress */ if (pvalue->m.destCallSignalAddressPresent) { invokeStartElement (pctxt, "destCallSignalAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->destCallSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destCallSignalAddress", -1); } /* decode destExtraCallInfo */ if (pvalue->m.destExtraCallInfoPresent) { invokeStartElement (pctxt, "destExtraCallInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destExtraCallInfo", -1); } /* decode srcInfo */ invokeStartElement (pctxt, "srcInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->srcInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "srcInfo", -1); /* decode srcCallSignalAddress */ if (pvalue->m.srcCallSignalAddressPresent) { invokeStartElement (pctxt, "srcCallSignalAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->srcCallSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "srcCallSignalAddress", -1); } /* decode bandWidth */ invokeStartElement (pctxt, "bandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandWidth", -1); /* decode callReferenceValue */ invokeStartElement (pctxt, "callReferenceValue", -1); stat = asn1PD_H225CallReferenceValue (pctxt, &pvalue->callReferenceValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callReferenceValue", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode callServices */ if (pvalue->m.callServicesPresent) { invokeStartElement (pctxt, "callServices", -1); stat = asn1PD_H225QseriesOptions (pctxt, &pvalue->callServices); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callServices", -1); } /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); /* decode activeMC */ invokeStartElement (pctxt, "activeMC", -1); stat = DECODEBIT (pctxt, &pvalue->activeMC); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->activeMC); invokeEndElement (pctxt, "activeMC", -1); /* decode answerCall */ invokeStartElement (pctxt, "answerCall", -1); stat = DECODEBIT (pctxt, &pvalue->answerCall); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->answerCall); invokeEndElement (pctxt, "answerCall", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 19 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.canMapAliasPresent = 1; invokeStartElement (pctxt, "canMapAlias", -1); stat = DECODEBIT (pctxt, &pvalue->canMapAlias); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canMapAlias); invokeEndElement (pctxt, "canMapAlias", -1); break; case 1: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 2: pvalue->m.srcAlternativesPresent = 1; invokeStartElement (pctxt, "srcAlternatives", -1); stat = asn1PD_H225_SeqOfH225Endpoint (pctxt, &pvalue->srcAlternatives); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "srcAlternatives", -1); break; case 3: pvalue->m.destAlternativesPresent = 1; invokeStartElement (pctxt, "destAlternatives", -1); stat = asn1PD_H225_SeqOfH225Endpoint (pctxt, &pvalue->destAlternatives); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destAlternatives", -1); break; case 4: pvalue->m.gatekeeperIdentifierPresent = 1; invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); break; case 5: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 6: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 7: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 8: pvalue->m.transportQOSPresent = 1; invokeStartElement (pctxt, "transportQOS", -1); stat = asn1PD_H225TransportQOS (pctxt, &pvalue->transportQOS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transportQOS", -1); break; case 9: pvalue->m.willSupplyUUIEsPresent = 1; invokeStartElement (pctxt, "willSupplyUUIEs", -1); stat = DECODEBIT (pctxt, &pvalue->willSupplyUUIEs); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->willSupplyUUIEs); invokeEndElement (pctxt, "willSupplyUUIEs", -1); break; case 10: pvalue->m.callLinkagePresent = 1; invokeStartElement (pctxt, "callLinkage", -1); stat = asn1PD_H225CallLinkage (pctxt, &pvalue->callLinkage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callLinkage", -1); break; case 11: pvalue->m.gatewayDataRatePresent = 1; invokeStartElement (pctxt, "gatewayDataRate", -1); stat = asn1PD_H225DataRate (pctxt, &pvalue->gatewayDataRate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatewayDataRate", -1); break; case 12: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 13: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 14: pvalue->m.desiredProtocolsPresent = 1; invokeStartElement (pctxt, "desiredProtocols", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->desiredProtocols); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "desiredProtocols", -1); break; case 15: pvalue->m.desiredTunnelledProtocolPresent = 1; invokeStartElement (pctxt, "desiredTunnelledProtocol", -1); stat = asn1PD_H225TunnelledProtocol (pctxt, &pvalue->desiredTunnelledProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "desiredTunnelledProtocol", -1); break; case 16: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 17: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; case 18: pvalue->m.canMapSrcAliasPresent = 1; invokeStartElement (pctxt, "canMapSrcAlias", -1); stat = DECODEBIT (pctxt, &pvalue->canMapSrcAlias); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canMapSrcAlias); invokeEndElement (pctxt, "canMapSrcAlias", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UUIEsRequested */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UUIEsRequested (OOCTXT* pctxt, H225UUIEsRequested* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode setup */ invokeStartElement (pctxt, "setup", -1); stat = DECODEBIT (pctxt, &pvalue->setup); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->setup); invokeEndElement (pctxt, "setup", -1); /* decode callProceeding */ invokeStartElement (pctxt, "callProceeding", -1); stat = DECODEBIT (pctxt, &pvalue->callProceeding); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->callProceeding); invokeEndElement (pctxt, "callProceeding", -1); /* decode connect */ invokeStartElement (pctxt, "connect", -1); stat = DECODEBIT (pctxt, &pvalue->connect); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->connect); invokeEndElement (pctxt, "connect", -1); /* decode alerting */ invokeStartElement (pctxt, "alerting", -1); stat = DECODEBIT (pctxt, &pvalue->alerting); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->alerting); invokeEndElement (pctxt, "alerting", -1); /* decode information */ invokeStartElement (pctxt, "information", -1); stat = DECODEBIT (pctxt, &pvalue->information); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->information); invokeEndElement (pctxt, "information", -1); /* decode releaseComplete */ invokeStartElement (pctxt, "releaseComplete", -1); stat = DECODEBIT (pctxt, &pvalue->releaseComplete); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->releaseComplete); invokeEndElement (pctxt, "releaseComplete", -1); /* decode facility */ invokeStartElement (pctxt, "facility", -1); stat = DECODEBIT (pctxt, &pvalue->facility); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->facility); invokeEndElement (pctxt, "facility", -1); /* decode progress */ invokeStartElement (pctxt, "progress", -1); stat = DECODEBIT (pctxt, &pvalue->progress); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->progress); invokeEndElement (pctxt, "progress", -1); /* decode empty */ invokeStartElement (pctxt, "empty", -1); stat = DECODEBIT (pctxt, &pvalue->empty); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->empty); invokeEndElement (pctxt, "empty", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 4 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.statusPresent = 1; invokeStartElement (pctxt, "status", -1); stat = DECODEBIT (pctxt, &pvalue->status); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->status); invokeEndElement (pctxt, "status", -1); break; case 1: pvalue->m.statusInquiryPresent = 1; invokeStartElement (pctxt, "statusInquiry", -1); stat = DECODEBIT (pctxt, &pvalue->statusInquiry); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->statusInquiry); invokeEndElement (pctxt, "statusInquiry", -1); break; case 2: pvalue->m.setupAcknowledgePresent = 1; invokeStartElement (pctxt, "setupAcknowledge", -1); stat = DECODEBIT (pctxt, &pvalue->setupAcknowledge); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->setupAcknowledge); invokeEndElement (pctxt, "setupAcknowledge", -1); break; case 3: pvalue->m.notifyPresent = 1; invokeStartElement (pctxt, "notify", -1); stat = DECODEBIT (pctxt, &pvalue->notify); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->notify); invokeEndElement (pctxt, "notify", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* AdmissionConfirm_language */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AdmissionConfirm_language (OOCTXT* pctxt, H225AdmissionConfirm_language* pvalue) { static Asn1SizeCnst element_lsize1 = { 0, 1, 32, 0 }; int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, ASN1IA5String); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); addSizeConstraint (pctxt, &element_lsize1); stat = decodeConstrainedStringEx (pctxt, &pvalue->elem[xx1], 0, 8, 7, 7); if (stat != ASN_OK) return stat; invokeCharStrValue (pctxt, pvalue->elem[xx1]); invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* AdmissionConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AdmissionConfirm (OOCTXT* pctxt, H225AdmissionConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.irrFrequencyPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode bandWidth */ invokeStartElement (pctxt, "bandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandWidth", -1); /* decode callModel */ invokeStartElement (pctxt, "callModel", -1); stat = asn1PD_H225CallModel (pctxt, &pvalue->callModel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callModel", -1); /* decode destCallSignalAddress */ invokeStartElement (pctxt, "destCallSignalAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->destCallSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destCallSignalAddress", -1); /* decode irrFrequency */ if (pvalue->m.irrFrequencyPresent) { invokeStartElement (pctxt, "irrFrequency", -1); stat = decodeConsUInt16 (pctxt, &pvalue->irrFrequency, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->irrFrequency); invokeEndElement (pctxt, "irrFrequency", -1); } /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 22 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.destinationInfoPresent = 1; invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); break; case 1: pvalue->m.destExtraCallInfoPresent = 1; invokeStartElement (pctxt, "destExtraCallInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destExtraCallInfo", -1); break; case 2: pvalue->m.destinationTypePresent = 1; invokeStartElement (pctxt, "destinationType", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->destinationType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationType", -1); break; case 3: pvalue->m.remoteExtensionAddressPresent = 1; invokeStartElement (pctxt, "remoteExtensionAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "remoteExtensionAddress", -1); break; case 4: pvalue->m.alternateEndpointsPresent = 1; invokeStartElement (pctxt, "alternateEndpoints", -1); stat = asn1PD_H225_SeqOfH225Endpoint (pctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateEndpoints", -1); break; case 5: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 6: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 7: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 8: pvalue->m.transportQOSPresent = 1; invokeStartElement (pctxt, "transportQOS", -1); stat = asn1PD_H225TransportQOS (pctxt, &pvalue->transportQOS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "transportQOS", -1); break; case 9: pvalue->m.willRespondToIRRPresent = 1; invokeStartElement (pctxt, "willRespondToIRR", -1); stat = DECODEBIT (pctxt, &pvalue->willRespondToIRR); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->willRespondToIRR); invokeEndElement (pctxt, "willRespondToIRR", -1); break; case 10: pvalue->m.uuiesRequestedPresent = 1; invokeStartElement (pctxt, "uuiesRequested", -1); stat = asn1PD_H225UUIEsRequested (pctxt, &pvalue->uuiesRequested); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "uuiesRequested", -1); break; case 11: pvalue->m.languagePresent = 1; invokeStartElement (pctxt, "language", -1); stat = asn1PD_H225AdmissionConfirm_language (pctxt, &pvalue->language); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "language", -1); break; case 12: pvalue->m.alternateTransportAddressesPresent = 1; invokeStartElement (pctxt, "alternateTransportAddresses", -1); stat = asn1PD_H225AlternateTransportAddresses (pctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateTransportAddresses", -1); break; case 13: pvalue->m.useSpecifiedTransportPresent = 1; invokeStartElement (pctxt, "useSpecifiedTransport", -1); stat = asn1PD_H225UseSpecifiedTransport (pctxt, &pvalue->useSpecifiedTransport); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "useSpecifiedTransport", -1); break; case 14: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 15: pvalue->m.usageSpecPresent = 1; invokeStartElement (pctxt, "usageSpec", -1); stat = asn1PD_H225_SeqOfH225RasUsageSpecification (pctxt, &pvalue->usageSpec); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageSpec", -1); break; case 16: pvalue->m.supportedProtocolsPresent = 1; invokeStartElement (pctxt, "supportedProtocols", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->supportedProtocols); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedProtocols", -1); break; case 17: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 18: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 19: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 20: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; case 21: pvalue->m.modifiedSrcInfoPresent = 1; invokeStartElement (pctxt, "modifiedSrcInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->modifiedSrcInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "modifiedSrcInfo", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225PartyNumber */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225PartyNumber (OOCTXT* pctxt, H225_SeqOfH225PartyNumber* pvalue) { int stat = ASN_OK; H225PartyNumber* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225PartyNumber); stat = asn1PD_H225PartyNumber (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* AdmissionRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AdmissionRejectReason (OOCTXT* pctxt, H225AdmissionRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 7); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* calledPartyNotRegistered */ case 0: invokeStartElement (pctxt, "calledPartyNotRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "calledPartyNotRegistered", -1); break; /* invalidPermission */ case 1: invokeStartElement (pctxt, "invalidPermission", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidPermission", -1); break; /* requestDenied */ case 2: invokeStartElement (pctxt, "requestDenied", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "requestDenied", -1); break; /* undefinedReason */ case 3: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; /* callerNotRegistered */ case 4: invokeStartElement (pctxt, "callerNotRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "callerNotRegistered", -1); break; /* routeCallToGatekeeper */ case 5: invokeStartElement (pctxt, "routeCallToGatekeeper", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "routeCallToGatekeeper", -1); break; /* invalidEndpointIdentifier */ case 6: invokeStartElement (pctxt, "invalidEndpointIdentifier", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidEndpointIdentifier", -1); break; /* resourceUnavailable */ case 7: invokeStartElement (pctxt, "resourceUnavailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "resourceUnavailable", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 9; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* securityDenial */ case 9: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* qosControlNotSupported */ case 10: invokeStartElement (pctxt, "qosControlNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "qosControlNotSupported", -1); break; /* incompleteAddress */ case 11: invokeStartElement (pctxt, "incompleteAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "incompleteAddress", -1); break; /* aliasesInconsistent */ case 12: invokeStartElement (pctxt, "aliasesInconsistent", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "aliasesInconsistent", -1); break; /* routeCallToSCN */ case 13: invokeStartElement (pctxt, "routeCallToSCN", -1); pvalue->u.routeCallToSCN = ALLOC_ASN1ELEM (pctxt, H225_SeqOfH225PartyNumber); stat = asn1PD_H225_SeqOfH225PartyNumber (pctxt, pvalue->u.routeCallToSCN); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "routeCallToSCN", -1); break; /* exceedsCallCapacity */ case 14: invokeStartElement (pctxt, "exceedsCallCapacity", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "exceedsCallCapacity", -1); break; /* collectDestination */ case 15: invokeStartElement (pctxt, "collectDestination", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "collectDestination", -1); break; /* collectPIN */ case 16: invokeStartElement (pctxt, "collectPIN", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "collectPIN", -1); break; /* genericDataReason */ case 17: invokeStartElement (pctxt, "genericDataReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "genericDataReason", -1); break; /* neededFeatureNotSupported */ case 18: invokeStartElement (pctxt, "neededFeatureNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "neededFeatureNotSupported", -1); break; /* securityErrors */ case 19: invokeStartElement (pctxt, "securityErrors", -1); pvalue->u.securityErrors = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors2); stat = asn1PD_H225SecurityErrors2 (pctxt, pvalue->u.securityErrors); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityErrors", -1); break; /* securityDHmismatch */ case 20: invokeStartElement (pctxt, "securityDHmismatch", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDHmismatch", -1); break; /* noRouteToDestination */ case 21: invokeStartElement (pctxt, "noRouteToDestination", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noRouteToDestination", -1); break; /* unallocatedNumber */ case 22: invokeStartElement (pctxt, "unallocatedNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unallocatedNumber", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* AdmissionReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H225AdmissionReject (OOCTXT* pctxt, H225AdmissionReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H225AdmissionRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 8 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.altGKInfoPresent = 1; invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.callSignalAddressPresent = 1; invokeStartElement (pctxt, "callSignalAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignalAddress", -1); break; case 4: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 5: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 6: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 7: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225BandwidthDetails */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225BandwidthDetails (OOCTXT* pctxt, H225_SeqOfH225BandwidthDetails* pvalue) { int stat = ASN_OK; H225BandwidthDetails* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225BandwidthDetails); stat = asn1PD_H225BandwidthDetails (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* BandwidthRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225BandwidthRequest (OOCTXT* pctxt, H225BandwidthRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.callTypePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode endpointIdentifier */ invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); /* decode callReferenceValue */ invokeStartElement (pctxt, "callReferenceValue", -1); stat = asn1PD_H225CallReferenceValue (pctxt, &pvalue->callReferenceValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callReferenceValue", -1); /* decode callType */ if (pvalue->m.callTypePresent) { invokeStartElement (pctxt, "callType", -1); stat = asn1PD_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callType", -1); } /* decode bandWidth */ invokeStartElement (pctxt, "bandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandWidth", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 11 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.gatekeeperIdentifierPresent = 1; invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 5: pvalue->m.answeredCallPresent = 1; invokeStartElement (pctxt, "answeredCall", -1); stat = DECODEBIT (pctxt, &pvalue->answeredCall); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->answeredCall); invokeEndElement (pctxt, "answeredCall", -1); break; case 6: pvalue->m.callLinkagePresent = 1; invokeStartElement (pctxt, "callLinkage", -1); stat = asn1PD_H225CallLinkage (pctxt, &pvalue->callLinkage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callLinkage", -1); break; case 7: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 8: pvalue->m.usageInformationPresent = 1; invokeStartElement (pctxt, "usageInformation", -1); stat = asn1PD_H225RasUsageInformation (pctxt, &pvalue->usageInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageInformation", -1); break; case 9: pvalue->m.bandwidthDetailsPresent = 1; invokeStartElement (pctxt, "bandwidthDetails", -1); stat = asn1PD_H225_SeqOfH225BandwidthDetails (pctxt, &pvalue->bandwidthDetails); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandwidthDetails", -1); break; case 10: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* BandwidthConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225BandwidthConfirm (OOCTXT* pctxt, H225BandwidthConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode bandWidth */ invokeStartElement (pctxt, "bandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandWidth", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 5 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 1: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 2: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 3: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 4: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* BandRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225BandRejectReason (OOCTXT* pctxt, H225BandRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 5); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* notBound */ case 0: invokeStartElement (pctxt, "notBound", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "notBound", -1); break; /* invalidConferenceID */ case 1: invokeStartElement (pctxt, "invalidConferenceID", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidConferenceID", -1); break; /* invalidPermission */ case 2: invokeStartElement (pctxt, "invalidPermission", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidPermission", -1); break; /* insufficientResources */ case 3: invokeStartElement (pctxt, "insufficientResources", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "insufficientResources", -1); break; /* invalidRevision */ case 4: invokeStartElement (pctxt, "invalidRevision", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidRevision", -1); break; /* undefinedReason */ case 5: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 7; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* securityDenial */ case 7: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* securityError */ case 8: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors2); stat = asn1PD_H225SecurityErrors2 (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* BandwidthReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H225BandwidthReject (OOCTXT* pctxt, H225BandwidthReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H225BandRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); /* decode allowedBandWidth */ invokeStartElement (pctxt, "allowedBandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->allowedBandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "allowedBandWidth", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 5 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.altGKInfoPresent = 1; invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 4: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* DisengageReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225DisengageReason (OOCTXT* pctxt, H225DisengageReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* forcedDrop */ case 0: invokeStartElement (pctxt, "forcedDrop", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "forcedDrop", -1); break; /* normalDrop */ case 1: invokeStartElement (pctxt, "normalDrop", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "normalDrop", -1); break; /* undefinedReason */ case 2: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* DisengageRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225DisengageRequest (OOCTXT* pctxt, H225DisengageRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode endpointIdentifier */ invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); /* decode callReferenceValue */ invokeStartElement (pctxt, "callReferenceValue", -1); stat = asn1PD_H225CallReferenceValue (pctxt, &pvalue->callReferenceValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callReferenceValue", -1); /* decode disengageReason */ invokeStartElement (pctxt, "disengageReason", -1); stat = asn1PD_H225DisengageReason (pctxt, &pvalue->disengageReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "disengageReason", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 13 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.gatekeeperIdentifierPresent = 1; invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); break; case 2: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 3: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 4: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 5: pvalue->m.answeredCallPresent = 1; invokeStartElement (pctxt, "answeredCall", -1); stat = DECODEBIT (pctxt, &pvalue->answeredCall); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->answeredCall); invokeEndElement (pctxt, "answeredCall", -1); break; case 6: pvalue->m.callLinkagePresent = 1; invokeStartElement (pctxt, "callLinkage", -1); stat = asn1PD_H225CallLinkage (pctxt, &pvalue->callLinkage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callLinkage", -1); break; case 7: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 8: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 9: pvalue->m.usageInformationPresent = 1; invokeStartElement (pctxt, "usageInformation", -1); stat = asn1PD_H225RasUsageInformation (pctxt, &pvalue->usageInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageInformation", -1); break; case 10: pvalue->m.terminationCausePresent = 1; invokeStartElement (pctxt, "terminationCause", -1); stat = asn1PD_H225CallTerminationCause (pctxt, &pvalue->terminationCause); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "terminationCause", -1); break; case 11: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 12: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* DisengageConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225DisengageConfirm (OOCTXT* pctxt, H225DisengageConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 7 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 1: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 2: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 3: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 4: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 5: pvalue->m.usageInformationPresent = 1; invokeStartElement (pctxt, "usageInformation", -1); stat = asn1PD_H225RasUsageInformation (pctxt, &pvalue->usageInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageInformation", -1); break; case 6: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* DisengageRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225DisengageRejectReason (OOCTXT* pctxt, H225DisengageRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* notRegistered */ case 0: invokeStartElement (pctxt, "notRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "notRegistered", -1); break; /* requestToDropOther */ case 1: invokeStartElement (pctxt, "requestToDropOther", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "requestToDropOther", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* securityDenial */ case 3: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* securityError */ case 4: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors2); stat = asn1PD_H225SecurityErrors2 (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* DisengageReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H225DisengageReject (OOCTXT* pctxt, H225DisengageReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H225DisengageRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 5 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.altGKInfoPresent = 1; invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 4: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* LocationRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225LocationRequest (OOCTXT* pctxt, H225LocationRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.endpointIdentifierPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode endpointIdentifier */ if (pvalue->m.endpointIdentifierPresent) { invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); } /* decode destinationInfo */ invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode replyAddress */ invokeStartElement (pctxt, "replyAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->replyAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "replyAddress", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 16 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.sourceInfoPresent = 1; invokeStartElement (pctxt, "sourceInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->sourceInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sourceInfo", -1); break; case 1: pvalue->m.canMapAliasPresent = 1; invokeStartElement (pctxt, "canMapAlias", -1); stat = DECODEBIT (pctxt, &pvalue->canMapAlias); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canMapAlias); invokeEndElement (pctxt, "canMapAlias", -1); break; case 2: pvalue->m.gatekeeperIdentifierPresent = 1; invokeStartElement (pctxt, "gatekeeperIdentifier", -1); stat = asn1PD_H225GatekeeperIdentifier (pctxt, &pvalue->gatekeeperIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperIdentifier", -1); break; case 3: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 4: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 5: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 6: pvalue->m.desiredProtocolsPresent = 1; invokeStartElement (pctxt, "desiredProtocols", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->desiredProtocols); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "desiredProtocols", -1); break; case 7: pvalue->m.desiredTunnelledProtocolPresent = 1; invokeStartElement (pctxt, "desiredTunnelledProtocol", -1); stat = asn1PD_H225TunnelledProtocol (pctxt, &pvalue->desiredTunnelledProtocol); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "desiredTunnelledProtocol", -1); break; case 8: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 9: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; case 10: pvalue->m.hopCountPresent = 1; invokeStartElement (pctxt, "hopCount", -1); stat = decodeConsUInt8 (pctxt, &pvalue->hopCount, 1U, 255U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->hopCount); invokeEndElement (pctxt, "hopCount", -1); break; case 11: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 12: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 13: pvalue->m.bandWidthPresent = 1; invokeStartElement (pctxt, "bandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandWidth", -1); break; case 14: pvalue->m.sourceEndpointInfoPresent = 1; invokeStartElement (pctxt, "sourceEndpointInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->sourceEndpointInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sourceEndpointInfo", -1); break; case 15: pvalue->m.canMapSrcAliasPresent = 1; invokeStartElement (pctxt, "canMapSrcAlias", -1); stat = DECODEBIT (pctxt, &pvalue->canMapSrcAlias); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->canMapSrcAlias); invokeEndElement (pctxt, "canMapSrcAlias", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* LocationConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225LocationConfirm (OOCTXT* pctxt, H225LocationConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode callSignalAddress */ invokeStartElement (pctxt, "callSignalAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignalAddress", -1); /* decode rasAddress */ invokeStartElement (pctxt, "rasAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rasAddress", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 17 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.destinationInfoPresent = 1; invokeStartElement (pctxt, "destinationInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destinationInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationInfo", -1); break; case 1: pvalue->m.destExtraCallInfoPresent = 1; invokeStartElement (pctxt, "destExtraCallInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->destExtraCallInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destExtraCallInfo", -1); break; case 2: pvalue->m.destinationTypePresent = 1; invokeStartElement (pctxt, "destinationType", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->destinationType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "destinationType", -1); break; case 3: pvalue->m.remoteExtensionAddressPresent = 1; invokeStartElement (pctxt, "remoteExtensionAddress", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->remoteExtensionAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "remoteExtensionAddress", -1); break; case 4: pvalue->m.alternateEndpointsPresent = 1; invokeStartElement (pctxt, "alternateEndpoints", -1); stat = asn1PD_H225_SeqOfH225Endpoint (pctxt, &pvalue->alternateEndpoints); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateEndpoints", -1); break; case 5: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 6: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 7: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 8: pvalue->m.alternateTransportAddressesPresent = 1; invokeStartElement (pctxt, "alternateTransportAddresses", -1); stat = asn1PD_H225AlternateTransportAddresses (pctxt, &pvalue->alternateTransportAddresses); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "alternateTransportAddresses", -1); break; case 9: pvalue->m.supportedProtocolsPresent = 1; invokeStartElement (pctxt, "supportedProtocols", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->supportedProtocols); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "supportedProtocols", -1); break; case 10: pvalue->m.multipleCallsPresent = 1; invokeStartElement (pctxt, "multipleCalls", -1); stat = DECODEBIT (pctxt, &pvalue->multipleCalls); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->multipleCalls); invokeEndElement (pctxt, "multipleCalls", -1); break; case 11: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 12: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; case 13: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; case 14: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; case 15: pvalue->m.modifiedSrcInfoPresent = 1; invokeStartElement (pctxt, "modifiedSrcInfo", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->modifiedSrcInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "modifiedSrcInfo", -1); break; case 16: pvalue->m.bandWidthPresent = 1; invokeStartElement (pctxt, "bandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandWidth", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* LocationRejectReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225LocationRejectReason (OOCTXT* pctxt, H225LocationRejectReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* notRegistered */ case 0: invokeStartElement (pctxt, "notRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "notRegistered", -1); break; /* invalidPermission */ case 1: invokeStartElement (pctxt, "invalidPermission", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidPermission", -1); break; /* requestDenied */ case 2: invokeStartElement (pctxt, "requestDenied", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "requestDenied", -1); break; /* undefinedReason */ case 3: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* securityDenial */ case 5: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* aliasesInconsistent */ case 6: invokeStartElement (pctxt, "aliasesInconsistent", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "aliasesInconsistent", -1); break; /* routeCalltoSCN */ case 7: invokeStartElement (pctxt, "routeCalltoSCN", -1); pvalue->u.routeCalltoSCN = ALLOC_ASN1ELEM (pctxt, H225_SeqOfH225PartyNumber); stat = asn1PD_H225_SeqOfH225PartyNumber (pctxt, pvalue->u.routeCalltoSCN); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "routeCalltoSCN", -1); break; /* resourceUnavailable */ case 8: invokeStartElement (pctxt, "resourceUnavailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "resourceUnavailable", -1); break; /* genericDataReason */ case 9: invokeStartElement (pctxt, "genericDataReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "genericDataReason", -1); break; /* neededFeatureNotSupported */ case 10: invokeStartElement (pctxt, "neededFeatureNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "neededFeatureNotSupported", -1); break; /* hopCountExceeded */ case 11: invokeStartElement (pctxt, "hopCountExceeded", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "hopCountExceeded", -1); break; /* incompleteAddress */ case 12: invokeStartElement (pctxt, "incompleteAddress", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "incompleteAddress", -1); break; /* securityError */ case 13: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors2); stat = asn1PD_H225SecurityErrors2 (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; /* securityDHmismatch */ case 14: invokeStartElement (pctxt, "securityDHmismatch", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDHmismatch", -1); break; /* noRouteToDestination */ case 15: invokeStartElement (pctxt, "noRouteToDestination", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "noRouteToDestination", -1); break; /* unallocatedNumber */ case 16: invokeStartElement (pctxt, "unallocatedNumber", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "unallocatedNumber", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* LocationReject */ /* */ /**************************************************************/ EXTERN int asn1PD_H225LocationReject (OOCTXT* pctxt, H225LocationReject* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode rejectReason */ invokeStartElement (pctxt, "rejectReason", -1); stat = asn1PD_H225LocationRejectReason (pctxt, &pvalue->rejectReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rejectReason", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 7 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.altGKInfoPresent = 1; invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 4: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 5: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; case 6: pvalue->m.serviceControlPresent = 1; invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* InfoRequest */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequest (OOCTXT* pctxt, H225InfoRequest* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.replyAddressPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode callReferenceValue */ invokeStartElement (pctxt, "callReferenceValue", -1); stat = asn1PD_H225CallReferenceValue (pctxt, &pvalue->callReferenceValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callReferenceValue", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode replyAddress */ if (pvalue->m.replyAddressPresent) { invokeStartElement (pctxt, "replyAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->replyAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "replyAddress", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 11 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 4: pvalue->m.uuiesRequestedPresent = 1; invokeStartElement (pctxt, "uuiesRequested", -1); stat = asn1PD_H225UUIEsRequested (pctxt, &pvalue->uuiesRequested); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "uuiesRequested", -1); break; case 5: pvalue->m.callLinkagePresent = 1; invokeStartElement (pctxt, "callLinkage", -1); stat = asn1PD_H225CallLinkage (pctxt, &pvalue->callLinkage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callLinkage", -1); break; case 6: pvalue->m.usageInfoRequestedPresent = 1; invokeStartElement (pctxt, "usageInfoRequested", -1); stat = asn1PD_H225RasUsageInfoTypes (pctxt, &pvalue->usageInfoRequested); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageInfoRequested", -1); break; case 7: pvalue->m.segmentedResponseSupportedPresent = 1; invokeStartElement (pctxt, "segmentedResponseSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "segmentedResponseSupported", -1); break; case 8: pvalue->m.nextSegmentRequestedPresent = 1; invokeStartElement (pctxt, "nextSegmentRequested", -1); stat = decodeConsUInt16 (pctxt, &pvalue->nextSegmentRequested, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->nextSegmentRequested); invokeEndElement (pctxt, "nextSegmentRequested", -1); break; case 9: pvalue->m.capacityInfoRequestedPresent = 1; invokeStartElement (pctxt, "capacityInfoRequested", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "capacityInfoRequested", -1); break; case 10: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225RTPSession */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225RTPSession (OOCTXT* pctxt, H225_SeqOfH225RTPSession* pvalue) { int stat = ASN_OK; H225RTPSession* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225RTPSession); stat = asn1PD_H225RTPSession (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225TransportChannelInfo */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225TransportChannelInfo (OOCTXT* pctxt, H225_SeqOfH225TransportChannelInfo* pvalue) { int stat = ASN_OK; H225TransportChannelInfo* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225TransportChannelInfo); stat = asn1PD_H225TransportChannelInfo (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225ConferenceIdentifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225ConferenceIdentifier (OOCTXT* pctxt, H225_SeqOfH225ConferenceIdentifier* pvalue) { int stat = ASN_OK; ASN1UINT xx1; /* decode length determinant */ stat = decodeLength (pctxt, &pvalue->n); if (stat != ASN_OK) return stat; /* decode elements */ ALLOC_ASN1ARRAY (pctxt, pvalue, H225ConferenceIdentifier); for (xx1 = 0; xx1 < pvalue->n; xx1++) { invokeStartElement (pctxt, "elem", xx1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->elem[xx1]); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponse_perCallInfo_element_pdu_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue) { int stat = ASN_OK; /* decode h323pdu */ invokeStartElement (pctxt, "h323pdu", -1); stat = asn1PD_H225H323_UU_PDU (pctxt, &pvalue->h323pdu); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h323pdu", -1); /* decode sent */ invokeStartElement (pctxt, "sent", -1); stat = DECODEBIT (pctxt, &pvalue->sent); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->sent); invokeEndElement (pctxt, "sent", -1); return (stat); } /**************************************************************/ /* */ /* _SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_el */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element* pvalue) { int stat = ASN_OK; H225InfoRequestResponse_perCallInfo_element_pdu_element* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225InfoRequestResponse_perCallInfo_element_pdu_element); stat = asn1PD_H225InfoRequestResponse_perCallInfo_element_pdu_element (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponse_perCallInfo_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225InfoRequestResponse_perCallInfo_element* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.originatorPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.audioPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.videoPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.dataPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode callReferenceValue */ invokeStartElement (pctxt, "callReferenceValue", -1); stat = asn1PD_H225CallReferenceValue (pctxt, &pvalue->callReferenceValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callReferenceValue", -1); /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); /* decode originator */ if (pvalue->m.originatorPresent) { invokeStartElement (pctxt, "originator", -1); stat = DECODEBIT (pctxt, &pvalue->originator); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->originator); invokeEndElement (pctxt, "originator", -1); } /* decode audio */ if (pvalue->m.audioPresent) { invokeStartElement (pctxt, "audio", -1); stat = asn1PD_H225_SeqOfH225RTPSession (pctxt, &pvalue->audio); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "audio", -1); } /* decode video */ if (pvalue->m.videoPresent) { invokeStartElement (pctxt, "video", -1); stat = asn1PD_H225_SeqOfH225RTPSession (pctxt, &pvalue->video); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "video", -1); } /* decode data */ if (pvalue->m.dataPresent) { invokeStartElement (pctxt, "data", -1); stat = asn1PD_H225_SeqOfH225TransportChannelInfo (pctxt, &pvalue->data); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "data", -1); } /* decode h245 */ invokeStartElement (pctxt, "h245", -1); stat = asn1PD_H225TransportChannelInfo (pctxt, &pvalue->h245); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "h245", -1); /* decode callSignaling */ invokeStartElement (pctxt, "callSignaling", -1); stat = asn1PD_H225TransportChannelInfo (pctxt, &pvalue->callSignaling); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignaling", -1); /* decode callType */ invokeStartElement (pctxt, "callType", -1); stat = asn1PD_H225CallType (pctxt, &pvalue->callType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callType", -1); /* decode bandWidth */ invokeStartElement (pctxt, "bandWidth", -1); stat = asn1PD_H225BandWidth (pctxt, &pvalue->bandWidth); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandWidth", -1); /* decode callModel */ invokeStartElement (pctxt, "callModel", -1); stat = asn1PD_H225CallModel (pctxt, &pvalue->callModel); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callModel", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 8 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.callIdentifierPresent = 1; invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); break; case 1: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 2: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 3: pvalue->m.substituteConfIDsPresent = 1; invokeStartElement (pctxt, "substituteConfIDs", -1); stat = asn1PD_H225_SeqOfH225ConferenceIdentifier (pctxt, &pvalue->substituteConfIDs); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "substituteConfIDs", -1); break; case 4: pvalue->m.pduPresent = 1; invokeStartElement (pctxt, "pdu", -1); stat = asn1PD_H225_SeqOfH225InfoRequestResponse_perCallInfo_element_pdu_element (pctxt, &pvalue->pdu); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "pdu", -1); break; case 5: pvalue->m.callLinkagePresent = 1; invokeStartElement (pctxt, "callLinkage", -1); stat = asn1PD_H225CallLinkage (pctxt, &pvalue->callLinkage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callLinkage", -1); break; case 6: pvalue->m.usageInformationPresent = 1; invokeStartElement (pctxt, "usageInformation", -1); stat = asn1PD_H225RasUsageInformation (pctxt, &pvalue->usageInformation); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "usageInformation", -1); break; case 7: pvalue->m.circuitInfoPresent = 1; invokeStartElement (pctxt, "circuitInfo", -1); stat = asn1PD_H225CircuitInfo (pctxt, &pvalue->circuitInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "circuitInfo", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225InfoRequestResponse_perCallInfo_element */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225InfoRequestResponse_perCallInfo_element (OOCTXT* pctxt, H225_SeqOfH225InfoRequestResponse_perCallInfo_element* pvalue) { int stat = ASN_OK; H225InfoRequestResponse_perCallInfo_element* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225InfoRequestResponse_perCallInfo_element); stat = asn1PD_H225InfoRequestResponse_perCallInfo_element (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponseStatus */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequestResponseStatus (OOCTXT* pctxt, H225InfoRequestResponseStatus* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* complete */ case 0: invokeStartElement (pctxt, "complete", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "complete", -1); break; /* incomplete */ case 1: invokeStartElement (pctxt, "incomplete", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "incomplete", -1); break; /* segment */ case 2: invokeStartElement (pctxt, "segment", -1); stat = decodeConsUInt16 (pctxt, &pvalue->u.segment, 0U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->u.segment); invokeEndElement (pctxt, "segment", -1); break; /* invalidCall */ case 3: invokeStartElement (pctxt, "invalidCall", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "invalidCall", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* InfoRequestResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequestResponse (OOCTXT* pctxt, H225InfoRequestResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endpointAliasPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.perCallInfoPresent = optbit; /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode endpointType */ invokeStartElement (pctxt, "endpointType", -1); stat = asn1PD_H225EndpointType (pctxt, &pvalue->endpointType); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointType", -1); /* decode endpointIdentifier */ invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); /* decode rasAddress */ invokeStartElement (pctxt, "rasAddress", -1); stat = asn1PD_H225TransportAddress (pctxt, &pvalue->rasAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "rasAddress", -1); /* decode callSignalAddress */ invokeStartElement (pctxt, "callSignalAddress", -1); stat = asn1PD_H225_SeqOfH225TransportAddress (pctxt, &pvalue->callSignalAddress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSignalAddress", -1); /* decode endpointAlias */ if (pvalue->m.endpointAliasPresent) { invokeStartElement (pctxt, "endpointAlias", -1); stat = asn1PD_H225_SeqOfH225AliasAddress (pctxt, &pvalue->endpointAlias); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointAlias", -1); } /* decode perCallInfo */ if (pvalue->m.perCallInfoPresent) { invokeStartElement (pctxt, "perCallInfo", -1); stat = asn1PD_H225_SeqOfH225InfoRequestResponse_perCallInfo_element (pctxt, &pvalue->perCallInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "perCallInfo", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 8 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 1: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 2: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 3: pvalue->m.needResponsePresent = 1; invokeStartElement (pctxt, "needResponse", -1); stat = DECODEBIT (pctxt, &pvalue->needResponse); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->needResponse); invokeEndElement (pctxt, "needResponse", -1); break; case 4: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 5: pvalue->m.irrStatusPresent = 1; invokeStartElement (pctxt, "irrStatus", -1); stat = asn1PD_H225InfoRequestResponseStatus (pctxt, &pvalue->irrStatus); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "irrStatus", -1); break; case 6: pvalue->m.unsolicitedPresent = 1; invokeStartElement (pctxt, "unsolicited", -1); stat = DECODEBIT (pctxt, &pvalue->unsolicited); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->unsolicited); invokeEndElement (pctxt, "unsolicited", -1); break; case 7: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* NonStandardMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H225NonStandardMessage (OOCTXT* pctxt, H225NonStandardMessage* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode nonStandardData */ invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 5 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 1: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 2: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 3: pvalue->m.featureSetPresent = 1; invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); break; case 4: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* UnknownMessageResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H225UnknownMessageResponse (OOCTXT* pctxt, H225UnknownMessageResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 4 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.tokensPresent = 1; invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); break; case 1: pvalue->m.cryptoTokensPresent = 1; invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); break; case 2: pvalue->m.integrityCheckValuePresent = 1; invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); break; case 3: pvalue->m.messageNotUnderstoodPresent = 1; invokeStartElement (pctxt, "messageNotUnderstood", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->messageNotUnderstood); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->messageNotUnderstood.numocts, pvalue->messageNotUnderstood.data); invokeEndElement (pctxt, "messageNotUnderstood", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* RequestInProgress */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RequestInProgress (OOCTXT* pctxt, H225RequestInProgress* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCheckValuePresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); } /* decode delay */ invokeStartElement (pctxt, "delay", -1); stat = decodeConsUInt16 (pctxt, &pvalue->delay, 1U, 65535U); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, pvalue->delay); invokeEndElement (pctxt, "delay", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ResourcesAvailableIndicate */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ResourcesAvailableIndicate (OOCTXT* pctxt, H225ResourcesAvailableIndicate* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCheckValuePresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode endpointIdentifier */ invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); /* decode protocols */ invokeStartElement (pctxt, "protocols", -1); stat = asn1PD_H225_SeqOfH225SupportedProtocols (pctxt, &pvalue->protocols); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocols", -1); /* decode almostOutOfResources */ invokeStartElement (pctxt, "almostOutOfResources", -1); stat = DECODEBIT (pctxt, &pvalue->almostOutOfResources); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->almostOutOfResources); invokeEndElement (pctxt, "almostOutOfResources", -1); /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.capacityPresent = 1; invokeStartElement (pctxt, "capacity", -1); stat = asn1PD_H225CallCapacity (pctxt, &pvalue->capacity); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "capacity", -1); break; case 1: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* ResourcesAvailableConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ResourcesAvailableConfirm (OOCTXT* pctxt, H225ResourcesAvailableConfirm* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCheckValuePresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode protocolIdentifier */ invokeStartElement (pctxt, "protocolIdentifier", -1); stat = asn1PD_H225ProtocolIdentifier (pctxt, &pvalue->protocolIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "protocolIdentifier", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.genericDataPresent = 1; invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* InfoRequestAck */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequestAck (OOCTXT* pctxt, H225InfoRequestAck* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCheckValuePresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* InfoRequestNakReason */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequestNakReason (OOCTXT* pctxt, H225InfoRequestNakReason* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 2); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* notRegistered */ case 0: invokeStartElement (pctxt, "notRegistered", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "notRegistered", -1); break; /* securityDenial */ case 1: invokeStartElement (pctxt, "securityDenial", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "securityDenial", -1); break; /* undefinedReason */ case 2: invokeStartElement (pctxt, "undefinedReason", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "undefinedReason", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 4; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* securityError */ case 4: invokeStartElement (pctxt, "securityError", -1); pvalue->u.securityError = ALLOC_ASN1ELEM (pctxt, H225SecurityErrors2); stat = asn1PD_H225SecurityErrors2 (pctxt, pvalue->u.securityError); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "securityError", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* InfoRequestNak */ /* */ /**************************************************************/ EXTERN int asn1PD_H225InfoRequestNak (OOCTXT* pctxt, H225InfoRequestNak* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.altGKInfoPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCheckValuePresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode nakReason */ invokeStartElement (pctxt, "nakReason", -1); stat = asn1PD_H225InfoRequestNakReason (pctxt, &pvalue->nakReason); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nakReason", -1); /* decode altGKInfo */ if (pvalue->m.altGKInfoPresent) { invokeStartElement (pctxt, "altGKInfo", -1); stat = asn1PD_H225AltGKInfo (pctxt, &pvalue->altGKInfo); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "altGKInfo", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ServiceControlIndication_callSpecific */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ServiceControlIndication_callSpecific (OOCTXT* pctxt, H225ServiceControlIndication_callSpecific* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode callIdentifier */ invokeStartElement (pctxt, "callIdentifier", -1); stat = asn1PD_H225CallIdentifier (pctxt, &pvalue->callIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callIdentifier", -1); /* decode conferenceID */ invokeStartElement (pctxt, "conferenceID", -1); stat = asn1PD_H225ConferenceIdentifier (pctxt, &pvalue->conferenceID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "conferenceID", -1); /* decode answeredCall */ invokeStartElement (pctxt, "answeredCall", -1); stat = DECODEBIT (pctxt, &pvalue->answeredCall); if (stat != ASN_OK) return stat; invokeBoolValue (pctxt, pvalue->answeredCall); invokeEndElement (pctxt, "answeredCall", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ServiceControlIndication */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ServiceControlIndication (OOCTXT* pctxt, H225ServiceControlIndication* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.endpointIdentifierPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.callSpecificPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCheckValuePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.featureSetPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.genericDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode serviceControl */ invokeStartElement (pctxt, "serviceControl", -1); stat = asn1PD_H225_SeqOfH225ServiceControlSession (pctxt, &pvalue->serviceControl); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControl", -1); /* decode endpointIdentifier */ if (pvalue->m.endpointIdentifierPresent) { invokeStartElement (pctxt, "endpointIdentifier", -1); stat = asn1PD_H225EndpointIdentifier (pctxt, &pvalue->endpointIdentifier); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "endpointIdentifier", -1); } /* decode callSpecific */ if (pvalue->m.callSpecificPresent) { invokeStartElement (pctxt, "callSpecific", -1); stat = asn1PD_H225ServiceControlIndication_callSpecific (pctxt, &pvalue->callSpecific); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "callSpecific", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); } /* decode featureSet */ if (pvalue->m.featureSetPresent) { invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); } /* decode genericData */ if (pvalue->m.genericDataPresent) { invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ServiceControlResponse_result */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ServiceControlResponse_result (OOCTXT* pctxt, H225ServiceControlResponse_result* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 4); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* started */ case 0: invokeStartElement (pctxt, "started", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "started", -1); break; /* failed */ case 1: invokeStartElement (pctxt, "failed", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "failed", -1); break; /* stopped */ case 2: invokeStartElement (pctxt, "stopped", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "stopped", -1); break; /* notAvailable */ case 3: invokeStartElement (pctxt, "notAvailable", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "notAvailable", -1); break; /* neededFeatureNotSupported */ case 4: invokeStartElement (pctxt, "neededFeatureNotSupported", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "neededFeatureNotSupported", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 6; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ServiceControlResponse */ /* */ /**************************************************************/ EXTERN int asn1PD_H225ServiceControlResponse (OOCTXT* pctxt, H225ServiceControlResponse* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit = 0; ASN1BOOL extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.resultPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardDataPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.tokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.cryptoTokensPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.integrityCheckValuePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.featureSetPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.genericDataPresent = optbit; /* decode requestSeqNum */ invokeStartElement (pctxt, "requestSeqNum", -1); stat = asn1PD_H225RequestSeqNum (pctxt, &pvalue->requestSeqNum); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestSeqNum", -1); /* decode result */ if (pvalue->m.resultPresent) { invokeStartElement (pctxt, "result", -1); stat = asn1PD_H225ServiceControlResponse_result (pctxt, &pvalue->result); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "result", -1); } /* decode nonStandardData */ if (pvalue->m.nonStandardDataPresent) { invokeStartElement (pctxt, "nonStandardData", -1); stat = asn1PD_H225NonStandardParameter (pctxt, &pvalue->nonStandardData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardData", -1); } /* decode tokens */ if (pvalue->m.tokensPresent) { invokeStartElement (pctxt, "tokens", -1); stat = asn1PD_H225_SeqOfH225ClearToken (pctxt, &pvalue->tokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "tokens", -1); } /* decode cryptoTokens */ if (pvalue->m.cryptoTokensPresent) { invokeStartElement (pctxt, "cryptoTokens", -1); stat = asn1PD_H225_SeqOfH225CryptoH323Token (pctxt, &pvalue->cryptoTokens); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoTokens", -1); } /* decode integrityCheckValue */ if (pvalue->m.integrityCheckValuePresent) { invokeStartElement (pctxt, "integrityCheckValue", -1); stat = asn1PD_H225ICV (pctxt, &pvalue->integrityCheckValue); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "integrityCheckValue", -1); } /* decode featureSet */ if (pvalue->m.featureSetPresent) { invokeStartElement (pctxt, "featureSet", -1); stat = asn1PD_H225FeatureSet (pctxt, &pvalue->featureSet); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "featureSet", -1); } /* decode genericData */ if (pvalue->m.genericDataPresent) { invokeStartElement (pctxt, "genericData", -1); stat = asn1PD_H225_SeqOfH225GenericData (pctxt, &pvalue->genericData); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "genericData", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* _SeqOfH225AdmissionConfirm */ /* */ /**************************************************************/ EXTERN int asn1PD_H225_SeqOfH225AdmissionConfirm (OOCTXT* pctxt, H225_SeqOfH225AdmissionConfirm* pvalue) { int stat = ASN_OK; H225AdmissionConfirm* pdata; ASN1UINT count = 0; ASN1UINT xx1; int lstat; dListInit (pvalue); for (;;) { /* decode length determinant */ lstat = decodeLength (pctxt, &count); if (lstat != ASN_OK && lstat != ASN_OK_FRAG) { return lstat; } /* decode elements */ for (xx1 = 0; xx1 < count; xx1++) { invokeStartElement (pctxt, "elem", xx1); pdata = ALLOC_ASN1ELEMDNODE (pctxt, H225AdmissionConfirm); stat = asn1PD_H225AdmissionConfirm (pctxt, pdata); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "elem", xx1); dListAppendNode (pctxt, pvalue, pdata); } if(lstat == ASN_OK) break; } return (stat); } /**************************************************************/ /* */ /* RasMessage */ /* */ /**************************************************************/ EXTERN int asn1PD_H225RasMessage (OOCTXT* pctxt, H225RasMessage* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit = 0; OOCTXT lctxt; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 24); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* gatekeeperRequest */ case 0: invokeStartElement (pctxt, "gatekeeperRequest", -1); pvalue->u.gatekeeperRequest = ALLOC_ASN1ELEM (pctxt, H225GatekeeperRequest); stat = asn1PD_H225GatekeeperRequest (pctxt, pvalue->u.gatekeeperRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperRequest", -1); break; /* gatekeeperConfirm */ case 1: invokeStartElement (pctxt, "gatekeeperConfirm", -1); pvalue->u.gatekeeperConfirm = ALLOC_ASN1ELEM (pctxt, H225GatekeeperConfirm); stat = asn1PD_H225GatekeeperConfirm (pctxt, pvalue->u.gatekeeperConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperConfirm", -1); break; /* gatekeeperReject */ case 2: invokeStartElement (pctxt, "gatekeeperReject", -1); pvalue->u.gatekeeperReject = ALLOC_ASN1ELEM (pctxt, H225GatekeeperReject); stat = asn1PD_H225GatekeeperReject (pctxt, pvalue->u.gatekeeperReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "gatekeeperReject", -1); break; /* registrationRequest */ case 3: invokeStartElement (pctxt, "registrationRequest", -1); pvalue->u.registrationRequest = ALLOC_ASN1ELEM (pctxt, H225RegistrationRequest); stat = asn1PD_H225RegistrationRequest (pctxt, pvalue->u.registrationRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "registrationRequest", -1); break; /* registrationConfirm */ case 4: invokeStartElement (pctxt, "registrationConfirm", -1); pvalue->u.registrationConfirm = ALLOC_ASN1ELEM (pctxt, H225RegistrationConfirm); stat = asn1PD_H225RegistrationConfirm (pctxt, pvalue->u.registrationConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "registrationConfirm", -1); break; /* registrationReject */ case 5: invokeStartElement (pctxt, "registrationReject", -1); pvalue->u.registrationReject = ALLOC_ASN1ELEM (pctxt, H225RegistrationReject); stat = asn1PD_H225RegistrationReject (pctxt, pvalue->u.registrationReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "registrationReject", -1); break; /* unregistrationRequest */ case 6: invokeStartElement (pctxt, "unregistrationRequest", -1); pvalue->u.unregistrationRequest = ALLOC_ASN1ELEM (pctxt, H225UnregistrationRequest); stat = asn1PD_H225UnregistrationRequest (pctxt, pvalue->u.unregistrationRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "unregistrationRequest", -1); break; /* unregistrationConfirm */ case 7: invokeStartElement (pctxt, "unregistrationConfirm", -1); pvalue->u.unregistrationConfirm = ALLOC_ASN1ELEM (pctxt, H225UnregistrationConfirm); stat = asn1PD_H225UnregistrationConfirm (pctxt, pvalue->u.unregistrationConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "unregistrationConfirm", -1); break; /* unregistrationReject */ case 8: invokeStartElement (pctxt, "unregistrationReject", -1); pvalue->u.unregistrationReject = ALLOC_ASN1ELEM (pctxt, H225UnregistrationReject); stat = asn1PD_H225UnregistrationReject (pctxt, pvalue->u.unregistrationReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "unregistrationReject", -1); break; /* admissionRequest */ case 9: invokeStartElement (pctxt, "admissionRequest", -1); pvalue->u.admissionRequest = ALLOC_ASN1ELEM (pctxt, H225AdmissionRequest); stat = asn1PD_H225AdmissionRequest (pctxt, pvalue->u.admissionRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "admissionRequest", -1); break; /* admissionConfirm */ case 10: invokeStartElement (pctxt, "admissionConfirm", -1); pvalue->u.admissionConfirm = ALLOC_ASN1ELEM (pctxt, H225AdmissionConfirm); stat = asn1PD_H225AdmissionConfirm (pctxt, pvalue->u.admissionConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "admissionConfirm", -1); break; /* admissionReject */ case 11: invokeStartElement (pctxt, "admissionReject", -1); pvalue->u.admissionReject = ALLOC_ASN1ELEM (pctxt, H225AdmissionReject); stat = asn1PD_H225AdmissionReject (pctxt, pvalue->u.admissionReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "admissionReject", -1); break; /* bandwidthRequest */ case 12: invokeStartElement (pctxt, "bandwidthRequest", -1); pvalue->u.bandwidthRequest = ALLOC_ASN1ELEM (pctxt, H225BandwidthRequest); stat = asn1PD_H225BandwidthRequest (pctxt, pvalue->u.bandwidthRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandwidthRequest", -1); break; /* bandwidthConfirm */ case 13: invokeStartElement (pctxt, "bandwidthConfirm", -1); pvalue->u.bandwidthConfirm = ALLOC_ASN1ELEM (pctxt, H225BandwidthConfirm); stat = asn1PD_H225BandwidthConfirm (pctxt, pvalue->u.bandwidthConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandwidthConfirm", -1); break; /* bandwidthReject */ case 14: invokeStartElement (pctxt, "bandwidthReject", -1); pvalue->u.bandwidthReject = ALLOC_ASN1ELEM (pctxt, H225BandwidthReject); stat = asn1PD_H225BandwidthReject (pctxt, pvalue->u.bandwidthReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "bandwidthReject", -1); break; /* disengageRequest */ case 15: invokeStartElement (pctxt, "disengageRequest", -1); pvalue->u.disengageRequest = ALLOC_ASN1ELEM (pctxt, H225DisengageRequest); stat = asn1PD_H225DisengageRequest (pctxt, pvalue->u.disengageRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "disengageRequest", -1); break; /* disengageConfirm */ case 16: invokeStartElement (pctxt, "disengageConfirm", -1); pvalue->u.disengageConfirm = ALLOC_ASN1ELEM (pctxt, H225DisengageConfirm); stat = asn1PD_H225DisengageConfirm (pctxt, pvalue->u.disengageConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "disengageConfirm", -1); break; /* disengageReject */ case 17: invokeStartElement (pctxt, "disengageReject", -1); pvalue->u.disengageReject = ALLOC_ASN1ELEM (pctxt, H225DisengageReject); stat = asn1PD_H225DisengageReject (pctxt, pvalue->u.disengageReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "disengageReject", -1); break; /* locationRequest */ case 18: invokeStartElement (pctxt, "locationRequest", -1); pvalue->u.locationRequest = ALLOC_ASN1ELEM (pctxt, H225LocationRequest); stat = asn1PD_H225LocationRequest (pctxt, pvalue->u.locationRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "locationRequest", -1); break; /* locationConfirm */ case 19: invokeStartElement (pctxt, "locationConfirm", -1); pvalue->u.locationConfirm = ALLOC_ASN1ELEM (pctxt, H225LocationConfirm); stat = asn1PD_H225LocationConfirm (pctxt, pvalue->u.locationConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "locationConfirm", -1); break; /* locationReject */ case 20: invokeStartElement (pctxt, "locationReject", -1); pvalue->u.locationReject = ALLOC_ASN1ELEM (pctxt, H225LocationReject); stat = asn1PD_H225LocationReject (pctxt, pvalue->u.locationReject); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "locationReject", -1); break; /* infoRequest */ case 21: invokeStartElement (pctxt, "infoRequest", -1); pvalue->u.infoRequest = ALLOC_ASN1ELEM (pctxt, H225InfoRequest); stat = asn1PD_H225InfoRequest (pctxt, pvalue->u.infoRequest); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "infoRequest", -1); break; /* infoRequestResponse */ case 22: invokeStartElement (pctxt, "infoRequestResponse", -1); pvalue->u.infoRequestResponse = ALLOC_ASN1ELEM (pctxt, H225InfoRequestResponse); stat = asn1PD_H225InfoRequestResponse (pctxt, pvalue->u.infoRequestResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "infoRequestResponse", -1); break; /* nonStandardMessage */ case 23: invokeStartElement (pctxt, "nonStandardMessage", -1); pvalue->u.nonStandardMessage = ALLOC_ASN1ELEM (pctxt, H225NonStandardMessage); stat = asn1PD_H225NonStandardMessage (pctxt, pvalue->u.nonStandardMessage); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandardMessage", -1); break; /* unknownMessageResponse */ case 24: invokeStartElement (pctxt, "unknownMessageResponse", -1); pvalue->u.unknownMessageResponse = ALLOC_ASN1ELEM (pctxt, H225UnknownMessageResponse); stat = asn1PD_H225UnknownMessageResponse (pctxt, pvalue->u.unknownMessageResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "unknownMessageResponse", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 26; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* requestInProgress */ case 26: invokeStartElement (pctxt, "requestInProgress", -1); pvalue->u.requestInProgress = ALLOC_ASN1ELEM (pctxt, H225RequestInProgress); stat = asn1PD_H225RequestInProgress (pctxt, pvalue->u.requestInProgress); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "requestInProgress", -1); break; /* resourcesAvailableIndicate */ case 27: invokeStartElement (pctxt, "resourcesAvailableIndicate", -1); pvalue->u.resourcesAvailableIndicate = ALLOC_ASN1ELEM (pctxt, H225ResourcesAvailableIndicate); stat = asn1PD_H225ResourcesAvailableIndicate (pctxt, pvalue->u.resourcesAvailableIndicate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "resourcesAvailableIndicate", -1); break; /* resourcesAvailableConfirm */ case 28: invokeStartElement (pctxt, "resourcesAvailableConfirm", -1); pvalue->u.resourcesAvailableConfirm = ALLOC_ASN1ELEM (pctxt, H225ResourcesAvailableConfirm); stat = asn1PD_H225ResourcesAvailableConfirm (pctxt, pvalue->u.resourcesAvailableConfirm); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "resourcesAvailableConfirm", -1); break; /* infoRequestAck */ case 29: invokeStartElement (pctxt, "infoRequestAck", -1); pvalue->u.infoRequestAck = ALLOC_ASN1ELEM (pctxt, H225InfoRequestAck); stat = asn1PD_H225InfoRequestAck (pctxt, pvalue->u.infoRequestAck); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "infoRequestAck", -1); break; /* infoRequestNak */ case 30: invokeStartElement (pctxt, "infoRequestNak", -1); pvalue->u.infoRequestNak = ALLOC_ASN1ELEM (pctxt, H225InfoRequestNak); stat = asn1PD_H225InfoRequestNak (pctxt, pvalue->u.infoRequestNak); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "infoRequestNak", -1); break; /* serviceControlIndication */ case 31: invokeStartElement (pctxt, "serviceControlIndication", -1); pvalue->u.serviceControlIndication = ALLOC_ASN1ELEM (pctxt, H225ServiceControlIndication); stat = asn1PD_H225ServiceControlIndication (pctxt, pvalue->u.serviceControlIndication); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControlIndication", -1); break; /* serviceControlResponse */ case 32: invokeStartElement (pctxt, "serviceControlResponse", -1); pvalue->u.serviceControlResponse = ALLOC_ASN1ELEM (pctxt, H225ServiceControlResponse); stat = asn1PD_H225ServiceControlResponse (pctxt, pvalue->u.serviceControlResponse); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "serviceControlResponse", -1); break; /* admissionConfirmSequence */ case 33: invokeStartElement (pctxt, "admissionConfirmSequence", -1); pvalue->u.admissionConfirmSequence = ALLOC_ASN1ELEM (pctxt, H225_SeqOfH225AdmissionConfirm); stat = asn1PD_H225_SeqOfH225AdmissionConfirm (pctxt, pvalue->u.admissionConfirmSequence); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "admissionConfirmSequence", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } asterisk-11.7.0/addons/ooh323c/src/h323/H235-SECURITY-MESSAGESDec.c0000644000175000007640000014563211274375744023147 0ustar sharkyjerryweb/* * 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 "H235-SECURITY-MESSAGES.h" #include "eventHandler.h" /**************************************************************/ /* */ /* ChallengeString */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ChallengeString (OOCTXT* pctxt, H235ChallengeString* pvalue) { static Asn1SizeCnst lsize1 = { 0, 8, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* TimeStamp */ /* */ /**************************************************************/ EXTERN int asn1PD_H235TimeStamp (OOCTXT* pctxt, H235TimeStamp* pvalue) { int stat = ASN_OK; stat = decodeConsUnsigned (pctxt, pvalue, 1U, ASN1UINT_MAX); if (stat != ASN_OK) return stat; invokeUIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* RandomVal */ /* */ /**************************************************************/ EXTERN int asn1PD_H235RandomVal (OOCTXT* pctxt, H235RandomVal* pvalue) { int stat = ASN_OK; stat = decodeUnconsInteger (pctxt, pvalue); if (stat != ASN_OK) return stat; invokeIntValue (pctxt, *pvalue); return (stat); } /**************************************************************/ /* */ /* Password */ /* */ /**************************************************************/ EXTERN int asn1PD_H235Password (OOCTXT* pctxt, H235Password* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBMPString (pctxt, pvalue, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->nchars, pvalue->data); return (stat); } /**************************************************************/ /* */ /* EncodedPwdCertToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H235EncodedPwdCertToken (OOCTXT* pctxt, H235EncodedPwdCertToken* pvalue) { int stat = ASN_OK; stat = decodeOpenType (pctxt, &pvalue->data, &pvalue->numocts); if (stat != ASN_OK) return stat; invokeOpenTypeValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* NonStandardParameter */ /* */ /**************************************************************/ EXTERN int asn1PD_H235NonStandardParameter (OOCTXT* pctxt, H235NonStandardParameter* pvalue) { int stat = ASN_OK; /* decode nonStandardIdentifier */ invokeStartElement (pctxt, "nonStandardIdentifier", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->nonStandardIdentifier); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->nonStandardIdentifier.numids, pvalue->nonStandardIdentifier.subid); invokeEndElement (pctxt, "nonStandardIdentifier", -1); /* decode data */ invokeStartElement (pctxt, "data", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->data); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->data.numocts, pvalue->data.data); invokeEndElement (pctxt, "data", -1); return (stat); } /**************************************************************/ /* */ /* AuthenticationBES */ /* */ /**************************************************************/ EXTERN int asn1PD_H235AuthenticationBES (OOCTXT* pctxt, H235AuthenticationBES* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit; extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* default_ */ case 0: invokeStartElement (pctxt, "default_", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "default_", -1); break; /* radius */ case 1: invokeStartElement (pctxt, "radius", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "radius", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* AuthenticationMechanism */ /* */ /**************************************************************/ EXTERN int asn1PD_H235AuthenticationMechanism (OOCTXT* pctxt, H235AuthenticationMechanism* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit; OOCTXT lctxt; extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 6); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* dhExch */ case 0: invokeStartElement (pctxt, "dhExch", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "dhExch", -1); break; /* pwdSymEnc */ case 1: invokeStartElement (pctxt, "pwdSymEnc", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "pwdSymEnc", -1); break; /* pwdHash */ case 2: invokeStartElement (pctxt, "pwdHash", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "pwdHash", -1); break; /* certSign */ case 3: invokeStartElement (pctxt, "certSign", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "certSign", -1); break; /* ipsec */ case 4: invokeStartElement (pctxt, "ipsec", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "ipsec", -1); break; /* tls */ case 5: invokeStartElement (pctxt, "tls", -1); /* NULL */ invokeNullValue (pctxt); invokeEndElement (pctxt, "tls", -1); break; /* nonStandard */ case 6: invokeStartElement (pctxt, "nonStandard", -1); pvalue->u.nonStandard = ALLOC_ASN1ELEM (pctxt, H235NonStandardParameter); stat = asn1PD_H235NonStandardParameter (pctxt, pvalue->u.nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 8; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; copyContext (&lctxt, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (pvalue->t) { /* authenticationBES */ case 8: invokeStartElement (pctxt, "authenticationBES", -1); pvalue->u.authenticationBES = ALLOC_ASN1ELEM (pctxt, H235AuthenticationBES); stat = asn1PD_H235AuthenticationBES (pctxt, pvalue->u.authenticationBES); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "authenticationBES", -1); break; default:; } copyContext (pctxt, &lctxt); } return (stat); } /**************************************************************/ /* */ /* DHset_halfkey */ /* */ /**************************************************************/ EXTERN int asn1PD_H235DHset_halfkey (OOCTXT* pctxt, H235DHset_halfkey* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 2048, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* DHset_modSize */ /* */ /**************************************************************/ EXTERN int asn1PD_H235DHset_modSize (OOCTXT* pctxt, H235DHset_modSize* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 2048, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* DHset_generator */ /* */ /**************************************************************/ EXTERN int asn1PD_H235DHset_generator (OOCTXT* pctxt, H235DHset_generator* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 2048, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* DHset */ /* */ /**************************************************************/ EXTERN int asn1PD_H235DHset (OOCTXT* pctxt, H235DHset* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit; ASN1BOOL extbit; optbit = extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode halfkey */ invokeStartElement (pctxt, "halfkey", -1); stat = asn1PD_H235DHset_halfkey (pctxt, &pvalue->halfkey); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "halfkey", -1); /* decode modSize */ invokeStartElement (pctxt, "modSize", -1); stat = asn1PD_H235DHset_modSize (pctxt, &pvalue->modSize); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "modSize", -1); /* decode generator */ invokeStartElement (pctxt, "generator", -1); stat = asn1PD_H235DHset_generator (pctxt, &pvalue->generator); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "generator", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* TypedCertificate */ /* */ /**************************************************************/ EXTERN int asn1PD_H235TypedCertificate (OOCTXT* pctxt, H235TypedCertificate* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit; ASN1BOOL extbit; optbit = extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* decode type */ invokeStartElement (pctxt, "type", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->type); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->type.numids, pvalue->type.subid); invokeEndElement (pctxt, "type", -1); /* decode certificate */ invokeStartElement (pctxt, "certificate", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->certificate); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->certificate.numocts, pvalue->certificate.data); invokeEndElement (pctxt, "certificate", -1); if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* Identifier */ /* */ /**************************************************************/ EXTERN int asn1PD_H235Identifier (OOCTXT* pctxt, H235Identifier* pvalue) { static Asn1SizeCnst lsize1 = { 0, 1, 128, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBMPString (pctxt, pvalue, 0); if (stat != ASN_OK) return stat; invokeCharStr16BitValue (pctxt, pvalue->nchars, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECpoint_x */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECpoint_x (OOCTXT* pctxt, H235ECpoint_x* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECpoint_y */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECpoint_y (OOCTXT* pctxt, H235ECpoint_y* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECpoint */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECpoint (OOCTXT* pctxt, H235ECpoint* pvalue) { int stat = ASN_OK; OOCTXT lctxt; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit; ASN1BOOL extbit; optbit = extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.xPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.yPresent = optbit; /* decode x */ if (pvalue->m.xPresent) { invokeStartElement (pctxt, "x", -1); stat = asn1PD_H235ECpoint_x (pctxt, &pvalue->x); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "x", -1); } /* decode y */ if (pvalue->m.yPresent) { invokeStartElement (pctxt, "y", -1); stat = asn1PD_H235ECpoint_y (pctxt, &pvalue->y); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "y", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; pctxt->buffer.byteIndex += openType.numocts; } } } return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp_modulus */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdhp_modulus (OOCTXT* pctxt, H235ECKASDH_eckasdhp_modulus* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp_weierstrassA */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdhp_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassA* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp_weierstrassB */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdhp_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassB* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdhp */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdhp (OOCTXT* pctxt, H235ECKASDH_eckasdhp* pvalue) { int stat = ASN_OK; /* decode public_key */ invokeStartElement (pctxt, "public_key", -1); stat = asn1PD_H235ECpoint (pctxt, &pvalue->public_key); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "public_key", -1); /* decode modulus */ invokeStartElement (pctxt, "modulus", -1); stat = asn1PD_H235ECKASDH_eckasdhp_modulus (pctxt, &pvalue->modulus); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "modulus", -1); /* decode base */ invokeStartElement (pctxt, "base", -1); stat = asn1PD_H235ECpoint (pctxt, &pvalue->base); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "base", -1); /* decode weierstrassA */ invokeStartElement (pctxt, "weierstrassA", -1); stat = asn1PD_H235ECKASDH_eckasdhp_weierstrassA (pctxt, &pvalue->weierstrassA); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "weierstrassA", -1); /* decode weierstrassB */ invokeStartElement (pctxt, "weierstrassB", -1); stat = asn1PD_H235ECKASDH_eckasdhp_weierstrassB (pctxt, &pvalue->weierstrassB); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "weierstrassB", -1); return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2_fieldSize */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdh2_fieldSize (OOCTXT* pctxt, H235ECKASDH_eckasdh2_fieldSize* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2_weierstrassA */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdh2_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassA* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2_weierstrassB */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdh2_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassB* pvalue) { static Asn1SizeCnst lsize1 = { 0, 0, 511, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeBitString (pctxt, &pvalue->numbits, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->numbits, pvalue->data); return (stat); } /**************************************************************/ /* */ /* ECKASDH_eckasdh2 */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH_eckasdh2 (OOCTXT* pctxt, H235ECKASDH_eckasdh2* pvalue) { int stat = ASN_OK; /* decode public_key */ invokeStartElement (pctxt, "public_key", -1); stat = asn1PD_H235ECpoint (pctxt, &pvalue->public_key); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "public_key", -1); /* decode fieldSize */ invokeStartElement (pctxt, "fieldSize", -1); stat = asn1PD_H235ECKASDH_eckasdh2_fieldSize (pctxt, &pvalue->fieldSize); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "fieldSize", -1); /* decode base */ invokeStartElement (pctxt, "base", -1); stat = asn1PD_H235ECpoint (pctxt, &pvalue->base); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "base", -1); /* decode weierstrassA */ invokeStartElement (pctxt, "weierstrassA", -1); stat = asn1PD_H235ECKASDH_eckasdh2_weierstrassA (pctxt, &pvalue->weierstrassA); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "weierstrassA", -1); /* decode weierstrassB */ invokeStartElement (pctxt, "weierstrassB", -1); stat = asn1PD_H235ECKASDH_eckasdh2_weierstrassB (pctxt, &pvalue->weierstrassB); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "weierstrassB", -1); return (stat); } /**************************************************************/ /* */ /* ECKASDH */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ECKASDH (OOCTXT* pctxt, H235ECKASDH* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit; extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 1); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* eckasdhp */ case 0: invokeStartElement (pctxt, "eckasdhp", -1); pvalue->u.eckasdhp = ALLOC_ASN1ELEM (pctxt, H235ECKASDH_eckasdhp); stat = asn1PD_H235ECKASDH_eckasdhp (pctxt, pvalue->u.eckasdhp); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "eckasdhp", -1); break; /* eckasdh2 */ case 1: invokeStartElement (pctxt, "eckasdh2", -1); pvalue->u.eckasdh2 = ALLOC_ASN1ELEM (pctxt, H235ECKASDH_eckasdh2); stat = asn1PD_H235ECKASDH_eckasdh2 (pctxt, pvalue->u.eckasdh2); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "eckasdh2", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 3; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } /**************************************************************/ /* */ /* ClearToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ClearToken (OOCTXT* pctxt, H235ClearToken* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit; ASN1BOOL extbit; optbit = extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.timeStampPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.passwordPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.dhkeyPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.challengePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.randomPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.certificatePresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.generalIDPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.nonStandardPresent = optbit; /* decode tokenOID */ invokeStartElement (pctxt, "tokenOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->tokenOID.numids, pvalue->tokenOID.subid); invokeEndElement (pctxt, "tokenOID", -1); /* decode timeStamp */ if (pvalue->m.timeStampPresent) { invokeStartElement (pctxt, "timeStamp", -1); stat = asn1PD_H235TimeStamp (pctxt, &pvalue->timeStamp); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "timeStamp", -1); } /* decode password */ if (pvalue->m.passwordPresent) { invokeStartElement (pctxt, "password", -1); stat = asn1PD_H235Password (pctxt, &pvalue->password); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "password", -1); } /* decode dhkey */ if (pvalue->m.dhkeyPresent) { invokeStartElement (pctxt, "dhkey", -1); stat = asn1PD_H235DHset (pctxt, &pvalue->dhkey); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "dhkey", -1); } /* decode challenge */ if (pvalue->m.challengePresent) { invokeStartElement (pctxt, "challenge", -1); stat = asn1PD_H235ChallengeString (pctxt, &pvalue->challenge); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "challenge", -1); } /* decode random */ if (pvalue->m.randomPresent) { invokeStartElement (pctxt, "random", -1); stat = asn1PD_H235RandomVal (pctxt, &pvalue->random); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "random", -1); } /* decode certificate */ if (pvalue->m.certificatePresent) { invokeStartElement (pctxt, "certificate", -1); stat = asn1PD_H235TypedCertificate (pctxt, &pvalue->certificate); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "certificate", -1); } /* decode generalID */ if (pvalue->m.generalIDPresent) { invokeStartElement (pctxt, "generalID", -1); stat = asn1PD_H235Identifier (pctxt, &pvalue->generalID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "generalID", -1); } /* decode nonStandard */ if (pvalue->m.nonStandardPresent) { invokeStartElement (pctxt, "nonStandard", -1); stat = asn1PD_H235NonStandardParameter (pctxt, &pvalue->nonStandard); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "nonStandard", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 2 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.eckasdhkeyPresent = 1; invokeStartElement (pctxt, "eckasdhkey", -1); stat = asn1PD_H235ECKASDH (pctxt, &pvalue->eckasdhkey); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "eckasdhkey", -1); break; case 1: pvalue->m.sendersIDPresent = 1; invokeStartElement (pctxt, "sendersID", -1); stat = asn1PD_H235Identifier (pctxt, &pvalue->sendersID); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "sendersID", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* IV8 */ /* */ /**************************************************************/ EXTERN int asn1PD_H235IV8 (OOCTXT* pctxt, H235IV8* pvalue) { static Asn1SizeCnst lsize1 = { 0, 8, 8, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* IV16 */ /* */ /**************************************************************/ EXTERN int asn1PD_H235IV16 (OOCTXT* pctxt, H235IV16* pvalue) { static Asn1SizeCnst lsize1 = { 0, 16, 16, 0 }; int stat = ASN_OK; addSizeConstraint (pctxt, &lsize1); stat = decodeOctetString (pctxt, &pvalue->numocts, pvalue->data, sizeof(pvalue->data)); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* Params */ /* */ /**************************************************************/ EXTERN int asn1PD_H235Params (OOCTXT* pctxt, H235Params* pvalue) { int stat = ASN_OK; OOCTXT lctxt; OOCTXT lctxt2; ASN1OpenType openType; ASN1UINT bitcnt; ASN1UINT i; ASN1BOOL optbit; ASN1BOOL extbit; optbit = extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); DECODEBIT (pctxt, &optbit); pvalue->m.ranIntPresent = optbit; DECODEBIT (pctxt, &optbit); pvalue->m.iv8Present = optbit; /* decode ranInt */ if (pvalue->m.ranIntPresent) { invokeStartElement (pctxt, "ranInt", -1); stat = decodeUnconsInteger (pctxt, &pvalue->ranInt); if (stat != ASN_OK) return stat; invokeIntValue (pctxt, pvalue->ranInt); invokeEndElement (pctxt, "ranInt", -1); } /* decode iv8 */ if (pvalue->m.iv8Present) { invokeStartElement (pctxt, "iv8", -1); stat = asn1PD_H235IV8 (pctxt, &pvalue->iv8); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iv8", -1); } if (extbit) { /* decode extension optional bits length */ stat = decodeSmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != ASN_OK) return stat; bitcnt += 1; ZEROCONTEXT (&lctxt); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) return stat; stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return stat; for (i = 0; i < bitcnt; i++) { DECODEBIT (&lctxt, &optbit); if (optbit) { stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; if (i < 1 && openType.numocts > 0) { /* known element */ copyContext (&lctxt2, pctxt); initContextBuffer (pctxt, openType.data, openType.numocts); switch (i) { case 0: pvalue->m.iv16Present = 1; invokeStartElement (pctxt, "iv16", -1); stat = asn1PD_H235IV16 (pctxt, &pvalue->iv16); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "iv16", -1); break; default: pctxt->buffer.byteIndex += openType.numocts; } copyContext (pctxt, &lctxt2); } else { /* unknown element */ pctxt->buffer.byteIndex += openType.numocts; } } } } return (stat); } /**************************************************************/ /* */ /* ENCRYPTED */ /* */ /**************************************************************/ EXTERN int asn1PD_H235ENCRYPTED (OOCTXT* pctxt, H235ENCRYPTED* pvalue) { int stat = ASN_OK; /* decode algorithmOID */ invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); /* decode paramS */ invokeStartElement (pctxt, "paramS", -1); stat = asn1PD_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "paramS", -1); /* decode encryptedData */ invokeStartElement (pctxt, "encryptedData", -1); stat = decodeDynOctetString (pctxt, (ASN1DynOctStr*)&pvalue->encryptedData); if (stat != ASN_OK) return stat; invokeOctStrValue (pctxt, pvalue->encryptedData.numocts, pvalue->encryptedData.data); invokeEndElement (pctxt, "encryptedData", -1); return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoEncryptedToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H235CryptoToken_cryptoEncryptedToken (OOCTXT* pctxt, H235CryptoToken_cryptoEncryptedToken* pvalue) { int stat = ASN_OK; /* decode tokenOID */ invokeStartElement (pctxt, "tokenOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->tokenOID.numids, pvalue->tokenOID.subid); invokeEndElement (pctxt, "tokenOID", -1); /* decode token */ invokeStartElement (pctxt, "token", -1); stat = asn1PD_H235ENCRYPTED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "token", -1); return (stat); } /**************************************************************/ /* */ /* EncodedGeneralToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H235EncodedGeneralToken (OOCTXT* pctxt, H235EncodedGeneralToken* pvalue) { int stat = ASN_OK; stat = decodeOpenType (pctxt, &pvalue->data, &pvalue->numocts); if (stat != ASN_OK) return stat; invokeOpenTypeValue (pctxt, pvalue->numocts, pvalue->data); return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoSignedToken_token */ /* */ /**************************************************************/ EXTERN int asn1PD_H235CryptoToken_cryptoSignedToken_token (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken_token* pvalue) { int stat = ASN_OK; /* decode toBeSigned */ invokeStartElement (pctxt, "toBeSigned", -1); stat = asn1PD_H235EncodedGeneralToken (pctxt, &pvalue->toBeSigned); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "toBeSigned", -1); /* decode algorithmOID */ invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); /* decode paramS */ invokeStartElement (pctxt, "paramS", -1); stat = asn1PD_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "paramS", -1); /* decode signature */ invokeStartElement (pctxt, "signature", -1); stat = decodeDynBitString (pctxt, (ASN1DynBitStr*)&pvalue->signature); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->signature.numbits, pvalue->signature.data); invokeEndElement (pctxt, "signature", -1); return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoSignedToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H235CryptoToken_cryptoSignedToken (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken* pvalue) { int stat = ASN_OK; /* decode tokenOID */ invokeStartElement (pctxt, "tokenOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->tokenOID.numids, pvalue->tokenOID.subid); invokeEndElement (pctxt, "tokenOID", -1); /* decode token */ invokeStartElement (pctxt, "token", -1); stat = asn1PD_H235CryptoToken_cryptoSignedToken_token (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "token", -1); return (stat); } /**************************************************************/ /* */ /* HASHED */ /* */ /**************************************************************/ EXTERN int asn1PD_H235HASHED (OOCTXT* pctxt, H235HASHED* pvalue) { int stat = ASN_OK; /* decode algorithmOID */ invokeStartElement (pctxt, "algorithmOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->algorithmOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->algorithmOID.numids, pvalue->algorithmOID.subid); invokeEndElement (pctxt, "algorithmOID", -1); /* decode paramS */ invokeStartElement (pctxt, "paramS", -1); stat = asn1PD_H235Params (pctxt, &pvalue->paramS); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "paramS", -1); /* decode hash */ invokeStartElement (pctxt, "hash", -1); stat = decodeDynBitString (pctxt, (ASN1DynBitStr*)&pvalue->hash); if (stat != ASN_OK) return stat; invokeBitStrValue (pctxt, pvalue->hash.numbits, pvalue->hash.data); invokeEndElement (pctxt, "hash", -1); return (stat); } /**************************************************************/ /* */ /* CryptoToken_cryptoHashedToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H235CryptoToken_cryptoHashedToken (OOCTXT* pctxt, H235CryptoToken_cryptoHashedToken* pvalue) { int stat = ASN_OK; /* decode tokenOID */ invokeStartElement (pctxt, "tokenOID", -1); stat = decodeObjectIdentifier (pctxt, &pvalue->tokenOID); if (stat != ASN_OK) return stat; invokeOidValue (pctxt, pvalue->tokenOID.numids, pvalue->tokenOID.subid); invokeEndElement (pctxt, "tokenOID", -1); /* decode hashedVals */ invokeStartElement (pctxt, "hashedVals", -1); stat = asn1PD_H235ClearToken (pctxt, &pvalue->hashedVals); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "hashedVals", -1); /* decode token */ invokeStartElement (pctxt, "token", -1); stat = asn1PD_H235HASHED (pctxt, &pvalue->token); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "token", -1); return (stat); } /**************************************************************/ /* */ /* CryptoToken */ /* */ /**************************************************************/ EXTERN int asn1PD_H235CryptoToken (OOCTXT* pctxt, H235CryptoToken* pvalue) { int stat = ASN_OK; ASN1UINT ui; ASN1OpenType openType; ASN1BOOL extbit; extbit = 0; /* extension bit */ DECODEBIT (pctxt, &extbit); if (!extbit) { stat = decodeConsUnsigned (pctxt, &ui, 0, 3); if (stat != ASN_OK) return stat; else pvalue->t = ui + 1; switch (ui) { /* cryptoEncryptedToken */ case 0: invokeStartElement (pctxt, "cryptoEncryptedToken", -1); pvalue->u.cryptoEncryptedToken = ALLOC_ASN1ELEM (pctxt, H235CryptoToken_cryptoEncryptedToken); stat = asn1PD_H235CryptoToken_cryptoEncryptedToken (pctxt, pvalue->u.cryptoEncryptedToken); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoEncryptedToken", -1); break; /* cryptoSignedToken */ case 1: invokeStartElement (pctxt, "cryptoSignedToken", -1); pvalue->u.cryptoSignedToken = ALLOC_ASN1ELEM (pctxt, H235CryptoToken_cryptoSignedToken); stat = asn1PD_H235CryptoToken_cryptoSignedToken (pctxt, pvalue->u.cryptoSignedToken); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoSignedToken", -1); break; /* cryptoHashedToken */ case 2: invokeStartElement (pctxt, "cryptoHashedToken", -1); pvalue->u.cryptoHashedToken = ALLOC_ASN1ELEM (pctxt, H235CryptoToken_cryptoHashedToken); stat = asn1PD_H235CryptoToken_cryptoHashedToken (pctxt, pvalue->u.cryptoHashedToken); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoHashedToken", -1); break; /* cryptoPwdEncr */ case 3: invokeStartElement (pctxt, "cryptoPwdEncr", -1); pvalue->u.cryptoPwdEncr = ALLOC_ASN1ELEM (pctxt, H235ENCRYPTED); stat = asn1PD_H235ENCRYPTED (pctxt, pvalue->u.cryptoPwdEncr); if (stat != ASN_OK) return stat; invokeEndElement (pctxt, "cryptoPwdEncr", -1); break; default: return ASN_E_INVOPT; } } else { stat = decodeSmallNonNegWholeNumber (pctxt, &ui); if (stat != ASN_OK) return stat; else pvalue->t = ui + 5; stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return stat; stat = decodeOpenType (pctxt, &openType.data, &openType.numocts); if (stat != ASN_OK) return stat; } return (stat); } asterisk-11.7.0/addons/ooh323c/src/h323/H235-SECURITY-MESSAGES.h0000644000175000007640000006460711222440006022513 0ustar sharkyjerryweb/* * 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 #include #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 asterisk-11.7.0/addons/ooh323c/src/h323/MULTIMEDIA-SYSTEM-CONTROL.c0000644000175000007640000000326011222440006023171 0ustar sharkyjerryweb/* * 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"; asterisk-11.7.0/addons/ooh323c/src/ooDateTime.h0000644000175000007640000000351111274375744021005 0ustar sharkyjerryweb/* * 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 #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); EXTERN int ooGetTimeOfDay (struct timeval *tv, struct timezone *tz); EXTERN long ooGetTimeDiff(struct timeval *tv1, struct timeval *tv2); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/ooh245.c0000644000175000007640000053613212211436150017755 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "ooh245.h" #include "ooq931.h" #include "ooCalls.h" #include "printHandler.h" #include "ooh323ep.h" #include "ooCapability.h" #include "ooTimer.h" #ifdef _WIN32 #include #include #define getpid _getpid #endif #include /** Global endpoint structure */ extern ooEndPoint gH323ep; static ASN1OBJID gh245ProtocolID = { 6, { 0, 0, 8, 245, 0, 8 } }; int ooCreateH245Message(OOH323CallData* call, H245Message **pph245msg, int type) { /* OOCTXT* pctxt = &gH323ep.msgctxt; */ OOCTXT* pctxt = call->msgctxt; *pph245msg = (H245Message*) memAlloc (pctxt, sizeof(H245Message)); if(!(*pph245msg)) { OOTRACEERR1("ERROR:Failed to allocate memory for h245 message\n"); return OO_FAILED; } else { (*pph245msg)->h245Msg.t = type; (*pph245msg)->logicalChannelNo = 0; switch(type) { case T_H245MultimediaSystemControlMessage_request: (*pph245msg)->h245Msg.u.request = (H245RequestMessage*) memAllocZ (pctxt, sizeof(H245RequestMessage)); /*Check for successful mem allocation, and if successful initialize mem to zero*/ if(!(*pph245msg)->h245Msg.u.request) { OOTRACEERR1("ERROR:Memory allocation for H.245 request" " message failed\n"); return OO_FAILED; } break; case T_H245MultimediaSystemControlMessage_response: (*pph245msg)->h245Msg.u.response = (H245ResponseMessage*) memAllocZ (pctxt, sizeof(H245ResponseMessage)); /*Check for successful mem allocation, and if successful initialize mem to zero*/ if(!(*pph245msg)->h245Msg.u.response) { OOTRACEERR1("ERROR:Memory allocation for H.245 response" " message failed\n"); return OO_FAILED; } break; case T_H245MultimediaSystemControlMessage_command: (*pph245msg)->h245Msg.u.command = (H245CommandMessage*) memAllocZ (pctxt, sizeof(H245CommandMessage)); /*Check for successful mem allocation, and if successful initialize mem to zero*/ if(!(*pph245msg)->h245Msg.u.command) { OOTRACEERR1("ERROR:Memory allocation for H.245 command" " message failed\n"); return OO_FAILED; } break; case T_H245MultimediaSystemControlMessage_indication: (*pph245msg)->h245Msg.u.indication = (H245IndicationMessage*) memAllocZ (pctxt, sizeof(H245IndicationMessage)); /*Check for successful mem allocation, and if successful initialize mem to zero*/ if(!(*pph245msg)->h245Msg.u.indication) { OOTRACEERR1("ERROR:Memory allocation for H.245 indication" " message failed\n"); return OO_FAILED; } break; default: OOTRACEERR1("ERROR: H245 message type not supported\n"); } return OO_OK; } } int ooFreeH245Message(OOH323CallData *call, H245Message *pmsg) { /* In case of tunneling, memory is freed when corresponding Q931 message is freed.*/ OOTRACEDBGC1("msgCtxt Reset?"); if (0 != pmsg) { if(!OO_TESTFLAG (call->flags, OO_M_TUNNELING)){ /* memReset (&gH323ep.msgctxt); */ memReset (call->msgctxt); OOTRACEDBGC3(" Done (%s, %s)\n", call->callType, call->callToken); return OO_OK; } } OOTRACEDBGC3("Not Done (%s, %s)\n", call->callType, call->callToken); return OO_OK; } #ifndef _COMPACT static void ooPrintH245Message (OOH323CallData* call, ASN1OCTET* msgbuf, ASN1UINT msglen) { OOCTXT ctxt; H245MultimediaSystemControlMessage mmMsg; int ret; initContext (&ctxt); setPERBuffer (&ctxt, msgbuf, msglen, TRUE); initializePrintHandler(&printHandler, "Sending H.245 Message"); /* Set event handler */ setEventHandler (&ctxt, &printHandler); ret = asn1PD_H245MultimediaSystemControlMessage(&ctxt, &mmMsg); if(ret != ASN_OK) { OOTRACEERR3("Error decoding H245 message (%s, %s)\n", call->callType, call->callToken); OOTRACEERR1 (errGetText (&ctxt)); } finishPrint(); freeContext(&ctxt); } #endif int ooEncodeH245Message (OOH323CallData *call, H245Message *ph245Msg, char *msgbuf, int size) { int len=0, encodeLen=0, i=0; int stat=0; ASN1OCTET* encodePtr=NULL; H245MultimediaSystemControlMessage *multimediaMsg; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; multimediaMsg = &(ph245Msg->h245Msg); if(!msgbuf || size<200) { OOTRACEERR3("Error: Invalid message buffer/size for " "ooEncodeH245Message. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } msgbuf[i++] = ph245Msg->msgType; msgbuf[i++] = (ph245Msg->logicalChannelNo>>8); msgbuf[i++] = ph245Msg->logicalChannelNo; /* This will contain the total length of the encoded message */ msgbuf[i++] = 0; msgbuf[i++] = 0; if(!OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { /* Populate message buffer to be returned */ len = 4; msgbuf[i++] = 3; /* TPKT version */ msgbuf[i++] = 0; /* TPKT resevred */ /* 1st octet of length, will be populated once len is determined */ msgbuf[i++] = 0; /* 2nd octet of length, will be populated once len is determined */ msgbuf[i++] = 0; } setPERBuffer (pctxt, (unsigned char*) msgbuf+i, (size-i), TRUE); /* stat = asn1PE_H245MultimediaSystemControlMessage (&gH323ep.msgctxt, */ stat = asn1PE_H245MultimediaSystemControlMessage (call->msgctxt, multimediaMsg); if (stat != ASN_OK) { OOTRACEERR3 ("ERROR: H245 Message encoding failed (%s, %s)\n", call->callType, call->callToken); /* OOTRACEERR1 (errGetText (&gH323ep.msgctxt)); */ OOTRACEERR1 (errGetText (call->msgctxt)); return OO_FAILED; } encodePtr = encodeGetMsgPtr(pctxt, &encodeLen); len +=encodeLen; msgbuf[3] = (len>>8); msgbuf[4] = len; if(!OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { msgbuf[7] = len>>8; msgbuf[8] = len; } #ifndef _COMPACT ooPrintH245Message (call, encodePtr, encodeLen); #endif return OO_OK; } int ooSendH245Msg(OOH323CallData *call, H245Message *msg) { int iRet=0, len=0, msgType=0, logicalChannelNo = 0; ASN1OCTET * encodebuf; if(!call) return OO_FAILED; encodebuf = (ASN1OCTET*) memAlloc (call->pctxt, MAXMSGLEN); if(!encodebuf) { OOTRACEERR3("Error:Failed to allocate memory for encoding H245 " "message(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } iRet = ooEncodeH245Message(call, msg, (char*) encodebuf, MAXMSGLEN); if(iRet != OO_OK) { OOTRACEERR3("Error:Failed to encode H245 message. (%s, %s)\n", call->callType, call->callToken); memFreePtr (call->pctxt, encodebuf); return OO_FAILED; } if(!call->pH245Channel) { call->pH245Channel = (OOH323Channel*) memAllocZ (call->pctxt, sizeof(OOH323Channel)); if(!call->pH245Channel) { OOTRACEERR3("Error:Failed to allocate memory for H245Channel " "structure. (%s, %s)\n", call->callType, call->callToken); memFreePtr (call->pctxt, encodebuf); return OO_FAILED; } } /* We need to send EndSessionCommand immediately.*/ if(!OO_TESTFLAG(call->flags, OO_M_TUNNELING)){ if(encodebuf[0]== OOEndSessionCommand) /* High priority message */ { dListFreeAll(call->pctxt, &call->pH245Channel->outQueue); dListAppend (call->pctxt, &call->pH245Channel->outQueue, encodebuf); ooSendMsg(call, OOH245MSG); } else{ dListAppend (call->pctxt, &call->pH245Channel->outQueue, encodebuf); OOTRACEDBGC4("Queued H245 messages %d. (%s, %s)\n", call->pH245Channel->outQueue.count, call->callType, call->callToken); } } else{ msgType = encodebuf[0]; logicalChannelNo = encodebuf[1]; logicalChannelNo = logicalChannelNo << 8; logicalChannelNo = (logicalChannelNo | encodebuf[2]); len = encodebuf[3]; len = len<<8; len = (len | encodebuf[4]); iRet = ooSendAsTunneledMessage (call, encodebuf+5,len,msgType, logicalChannelNo); if(iRet != OO_OK) { memFreePtr (call->pctxt, encodebuf); OOTRACEERR3("ERROR:Failed to tunnel H.245 message (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } memFreePtr (call->pctxt, encodebuf); return OO_OK; } return OO_OK; } int ooSendTermCapMsg(OOH323CallData *call) { int ret; H245RequestMessage *request=NULL; OOCTXT *pctxt=NULL; ooH323EpCapability *epCap=NULL; H245TerminalCapabilitySet *termCap=NULL; H245AudioCapability *audioCap=NULL; H245DataApplicationCapability *t38Cap, *rtdCap = NULL; H245AudioTelephonyEventCapability *ateCap=NULL; H245UserInputCapability *userInputCap = NULL; H245CapabilityTableEntry *entry=NULL; H245AlternativeCapabilitySet *altSetAudio=NULL, *altSetVideo=NULL, *altSetDtmf=NULL; H245CapabilityDescriptor *capDesc=NULL; H245Message *ph245msg=NULL; H245VideoCapability *videoCap=NULL; int i=0,k=0; if(call->localTermCapState == OO_LocalTermCapSetSent) { OOTRACEINFO3("TerminalCapabilitySet exchange procedure already in " "progress. (%s, %s)\n", call->callType, call->callToken); return OO_OK; } ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if(ret == OO_FAILED) { OOTRACEERR3("Error:Failed to create H245 message for Terminal " "CapabilitySet (%s, %s)\n", call->callType,call->callToken); return OO_FAILED; } /* Set request type as TerminalCapabilitySet */ request = ph245msg->h245Msg.u.request; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; ph245msg->msgType = OOTerminalCapabilitySet; memset(request, 0, sizeof(H245RequestMessage)); if(request == NULL) { OOTRACEERR3("ERROR: No memory allocated for request message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } request->t = T_H245RequestMessage_terminalCapabilitySet; request->u.terminalCapabilitySet = (H245TerminalCapabilitySet*) memAlloc(pctxt, sizeof(H245TerminalCapabilitySet)); termCap = request->u.terminalCapabilitySet; memset(termCap, 0, sizeof(H245TerminalCapabilitySet)); termCap->m.multiplexCapabilityPresent = 0; termCap->m.capabilityTablePresent = 1; termCap->m.capabilityDescriptorsPresent = 1; termCap->sequenceNumber = ++(call->localTermCapSeqNo); termCap->protocolIdentifier = gh245ProtocolID; /* protocol id */ /* Initialize alternate sets */ altSetAudio = (H245AlternativeCapabilitySet*) memAlloc(pctxt, sizeof(H245AlternativeCapabilitySet)); altSetVideo = (H245AlternativeCapabilitySet*) memAlloc(pctxt, sizeof(H245AlternativeCapabilitySet)); altSetDtmf = (H245AlternativeCapabilitySet*) memAlloc(pctxt, sizeof(H245AlternativeCapabilitySet)); if(!altSetAudio || !altSetVideo || !altSetDtmf) { OOTRACEERR3("Error:Memory - ooSendTermCapMsg - altSet." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(altSetDtmf, 0, sizeof(H245AlternativeCapabilitySet)); memset(altSetVideo, 0, sizeof(H245AlternativeCapabilitySet)); memset(altSetAudio, 0, sizeof(H245AlternativeCapabilitySet)); /* Add audio Capabilities */ dListInit(&(termCap->capabilityTable)); for(k=0; k<(int)call->capPrefs.index; k++) { if(call->ourCaps) epCap = call->ourCaps; else epCap = gH323ep.myCaps; while(epCap) { if(epCap->cap == call->capPrefs.order[k]) break; epCap = epCap->next; } if(!epCap) { OOTRACEWARN4("WARN:Preferred capability %d not supported.(%s, %s)\n", call->capPrefs.order[k],call->callType, call->callToken); continue; } if(epCap->capType == OO_CAP_TYPE_AUDIO) { /* Create audio capability. If capability supports receive, we only add it as receive capability in TCS. However, if it supports only transmit, we add it as transmit capability in TCS. */ if((epCap->dir & OORX)) { OOTRACEDBGC4("Sending receive capability %s in TCS.(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); audioCap = ooCapabilityCreateAudioCapability(epCap, pctxt, OORX); if(!audioCap) { OOTRACEWARN4("WARN:Failed to create audio capability %s " "(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); continue; } } else if(epCap->dir & OOTX) { OOTRACEDBGC4("Sending transmit capability %s in TCS.(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); audioCap = ooCapabilityCreateAudioCapability(epCap, pctxt, OOTX); if(!audioCap) { OOTRACEWARN4("WARN:Failed to create audio capability %s " "(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); continue; } } else{ OOTRACEWARN3("Warn:Capability is not RX/TX/RXANDTX. Symmetric " "capabilities are not supported.(%s, %s)\n", call->callType, call->callToken); continue; } /* Add Capabilities to Capability Table */ entry = (H245CapabilityTableEntry*) memAlloc(pctxt, sizeof(H245CapabilityTableEntry)); if(!entry) { OOTRACEERR3("Error:Memory - ooSendTermCapMsg - entry(audio Cap)." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(entry, 0, sizeof(H245CapabilityTableEntry)); entry->m.capabilityPresent = 1; if((epCap->dir & OORX)) { entry->capability.t = T_H245Capability_receiveAudioCapability; entry->capability.u.receiveAudioCapability = audioCap; } else{ entry->capability.t = T_H245Capability_transmitAudioCapability; entry->capability.u.transmitAudioCapability = audioCap; } entry->capabilityTableEntryNumber = i+1; dListAppend(pctxt , &(termCap->capabilityTable), entry); altSetAudio->elem[altSetAudio->n] = i+1; altSetAudio->n++; i++; } else if(epCap->capType == OO_CAP_TYPE_DATA) { /* Create t.38 capability. If capability supports receive, we only add it as receive capability in TCS. However, if it supports only transmit, we add it as transmit capability in TCS. */ if((epCap->dir & OORX) && !(epCap->dir & OOTX)) { OOTRACEDBGC3("Sending receive capability t38 in TCS.(%s, %s)\n", call->callType, call->callToken); t38Cap = ooCapabilityCreateT38Capability(epCap, pctxt, OORX); if(!t38Cap) { OOTRACEWARN3("WARN:Failed to create t38 capability for" "%s, %s\n", call->callType, call->callToken); continue; } } else if((epCap->dir & OOTX) && !(epCap->dir & OORX)) { OOTRACEDBGC3("Sending transmit capability t38 in TCS.(%s, %s)\n", call->callType, call->callToken); t38Cap = ooCapabilityCreateT38Capability(epCap, pctxt, OOTX); if(!t38Cap) { OOTRACEWARN3("WARN:Failed to create capability t38 " "(%s, %s)\n", call->callType, call->callToken); continue; } } else{ OOTRACEDBGC3("Sending transmit&recevie capability t38 in TCS.(%s, %s)\n", call->callType, call->callToken); t38Cap = ooCapabilityCreateT38Capability(epCap, pctxt, OOTX&OORX); if(!t38Cap) { OOTRACEWARN3("WARN:Failed to create capability t38 " "(%s, %s)\n", call->callType, call->callToken); continue; } } /* Add Capabilities to Capability Table */ entry = (H245CapabilityTableEntry*) memAlloc(pctxt, sizeof(H245CapabilityTableEntry)); if(!entry) { OOTRACEERR3("Error:Memory - ooSendTermCapMsg - entry(audio Cap)." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(entry, 0, sizeof(H245CapabilityTableEntry)); entry->m.capabilityPresent = 1; if((epCap->dir & OORX) && (epCap->dir & OOTX)) { entry->capability.t = T_H245Capability_receiveAndTransmitDataApplicationCapability; entry->capability.u.receiveAndTransmitDataApplicationCapability = t38Cap; } else if((epCap->dir & OORX)) { entry->capability.t = T_H245Capability_receiveDataApplicationCapability; entry->capability.u.receiveDataApplicationCapability = t38Cap; }else{ entry->capability.t = T_H245Capability_transmitDataApplicationCapability; entry->capability.u.transmitDataApplicationCapability = t38Cap; } entry->capabilityTableEntryNumber = i+1; dListAppend(pctxt , &(termCap->capabilityTable), entry); altSetAudio->elem[altSetAudio->n] = i+1; altSetAudio->n++; i++; } else if(epCap->capType == OO_CAP_TYPE_VIDEO) { if((epCap->dir & OORX)) { OOTRACEDBGC4("Sending receive capability %s in TCS.(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); videoCap = ooCapabilityCreateVideoCapability(epCap, pctxt, OORX); if(!videoCap) { OOTRACEWARN4("WARN:Failed to create Video capability %s " "(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); continue; } } else if(epCap->dir & OOTX) { OOTRACEDBGC4("Sending transmit capability %s in TCS.(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); videoCap = ooCapabilityCreateVideoCapability(epCap, pctxt, OOTX); if(!videoCap) { OOTRACEWARN4("WARN:Failed to create video capability %s " "(%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); continue; } } else{ OOTRACEWARN3("Warn:Capability is not RX/TX/RXANDTX. Symmetric " "capabilities are not supported.(%s, %s)\n", call->callType, call->callToken); continue; } /* Add Video capabilities to Capability Table */ entry = (H245CapabilityTableEntry*) memAlloc(pctxt, sizeof(H245CapabilityTableEntry)); if(!entry) { OOTRACEERR3("Error:Memory - ooSendTermCapMsg - entry(video Cap)." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(entry, 0, sizeof(H245CapabilityTableEntry)); entry->m.capabilityPresent = 1; if((epCap->dir & OORX)) { entry->capability.t = T_H245Capability_receiveVideoCapability; entry->capability.u.receiveVideoCapability = videoCap; } else{ entry->capability.t = T_H245Capability_transmitVideoCapability; entry->capability.u.transmitVideoCapability = videoCap; } entry->capabilityTableEntryNumber = i+1; dListAppend(pctxt , &(termCap->capabilityTable), entry); altSetVideo->elem[altSetVideo->n] = i+1; altSetVideo->n++; i++; } } /* Add dtmf capability, if any */ if(call->dtmfmode & OO_CAP_DTMF_RFC2833) { ateCap = (H245AudioTelephonyEventCapability*) ooCapabilityCreateDTMFCapability(OO_CAP_DTMF_RFC2833, call->dtmfcodec, pctxt); if(!ateCap) { OOTRACEWARN3("WARN:Failed to add RFC2833 cap to TCS(%s, %s)\n", call->callType, call->callToken); } else { entry = (H245CapabilityTableEntry*) memAlloc(pctxt, sizeof(H245CapabilityTableEntry)); if(!entry) { OOTRACEERR3("Error:Failed to allocate memory for new capability " "table entry. (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } memset(entry, 0, sizeof(H245CapabilityTableEntry)); entry->m.capabilityPresent = 1; entry->capability.t = T_H245Capability_receiveRTPAudioTelephonyEventCapability; entry->capability.u.receiveRTPAudioTelephonyEventCapability = ateCap; entry->capabilityTableEntryNumber = i+1; dListAppend(pctxt , &(termCap->capabilityTable), entry); altSetDtmf->elem[altSetDtmf->n] = i+1; altSetDtmf->n++; i++; } } if(call->dtmfmode & OO_CAP_DTMF_CISCO) { rtdCap = (H245DataApplicationCapability*) ooCapabilityCreateDTMFCapability(OO_CAP_DTMF_CISCO, call->dtmfcodec, pctxt); if(!rtdCap) { OOTRACEWARN3("WARN:Failed to add RTP/CISCO DTMF cap to TCS(%s, %s)\n", call->callType, call->callToken); } else { entry = (H245CapabilityTableEntry*) memAlloc(pctxt, sizeof(H245CapabilityTableEntry)); if(!entry) { OOTRACEERR3("Error:Failed to allocate memory for new capability " "table entry. (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } memset(entry, 0, sizeof(H245CapabilityTableEntry)); entry->m.capabilityPresent = 1; entry->capability.t = T_H245Capability_receiveDataApplicationCapability; entry->capability.u.receiveDataApplicationCapability = rtdCap; entry->capabilityTableEntryNumber = i+1; dListAppend(pctxt , &(termCap->capabilityTable), entry); altSetDtmf->elem[altSetDtmf->n] = i+1; altSetDtmf->n++; i++; } } if(call->dtmfmode & OO_CAP_DTMF_H245_alphanumeric) { userInputCap = (H245UserInputCapability*)ooCapabilityCreateDTMFCapability (OO_CAP_DTMF_H245_alphanumeric, 0, pctxt); if(!userInputCap) { OOTRACEWARN3("WARN:Failed to add H245(alphanumeric) cap to " "TCS(%s, %s)\n", call->callType, call->callToken); } else { entry = (H245CapabilityTableEntry*) memAlloc(pctxt, sizeof(H245CapabilityTableEntry)); if(!entry) { OOTRACEERR3("Error:Failed to allocate memory for new capability " "table entry. (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } memset(entry, 0, sizeof(H245CapabilityTableEntry)); entry->m.capabilityPresent = 1; entry->capability.t = T_H245Capability_receiveUserInputCapability; entry->capability.u.receiveUserInputCapability = userInputCap; entry->capabilityTableEntryNumber = i+1; dListAppend(pctxt , &(termCap->capabilityTable), entry); altSetDtmf->elem[altSetDtmf->n] = i+1; altSetDtmf->n++; i++; } } userInputCap = NULL; if(call->dtmfmode & OO_CAP_DTMF_H245_signal) { userInputCap = (H245UserInputCapability*)ooCapabilityCreateDTMFCapability (OO_CAP_DTMF_H245_signal, 0, pctxt); if(!userInputCap) { OOTRACEWARN3("WARN:Failed to add H245(signal) cap to " "TCS(%s, %s)\n", call->callType, call->callToken); } else { entry = (H245CapabilityTableEntry*) memAlloc(pctxt, sizeof(H245CapabilityTableEntry)); if(!entry) { OOTRACEERR3("Error:Failed to allocate memory for new capability " "table entry. (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } memset(entry, 0, sizeof(H245CapabilityTableEntry)); entry->m.capabilityPresent = 1; entry->capability.t = T_H245Capability_receiveUserInputCapability; entry->capability.u.receiveUserInputCapability = userInputCap; entry->capabilityTableEntryNumber = i+1; dListAppend(pctxt , &(termCap->capabilityTable), entry); altSetDtmf->elem[altSetDtmf->n] = i+1; altSetDtmf->n++; i++; } } /*TODO:Add Video and Data capabilities, if required*/ if(i==0) { OOTRACEERR3("Error:No capabilities found to send in TCS message." " (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call,ph245msg); return OO_FAILED; } /* Define capability descriptior */ capDesc = (H245CapabilityDescriptor*) memAlloc(pctxt, sizeof(H245CapabilityDescriptor)); memset(capDesc, 0, sizeof(H245CapabilityDescriptor)); capDesc->m.simultaneousCapabilitiesPresent = 1; capDesc->capabilityDescriptorNumber = 1; dListInit(&(capDesc->simultaneousCapabilities)); /* Add Alternative Capability Set. TODO: Right now all capabilities are added in separate alternate capabilities set. Need a way for application developer to specify the alternative capability sets. */ /* for(j=0; jn = 1; altSet->elem[0] = j+1; dListAppend(pctxt, &(capDesc->simultaneousCapabilities), altSet); } */ if (altSetAudio->n) dListAppend(pctxt, &(capDesc->simultaneousCapabilities), altSetAudio); if (altSetVideo->n) dListAppend(pctxt, &(capDesc->simultaneousCapabilities), altSetVideo); if (altSetDtmf->n) dListAppend(pctxt, &(capDesc->simultaneousCapabilities), altSetDtmf); dListInit(&(termCap->capabilityDescriptors)); dListAppend(pctxt, &(termCap->capabilityDescriptors), capDesc); OOTRACEDBGA3("Built terminal capability set message (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue TCS message to outbound queue. " "(%s, %s)\n", call->callType, call->callToken); } else { call->localTermCapState = OO_LocalTermCapSetSent; } ooFreeH245Message(call,ph245msg); return ret; } int ooSendEmptyTermCapMsg(OOH323CallData *call) { int ret; H245RequestMessage *request = NULL; OOCTXT *pctxt = NULL; H245TerminalCapabilitySet *termCap = NULL; H245Message *ph245msg = NULL; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if (ret == OO_FAILED) { OOTRACEERR3("Error:Failed to create H245 message for Terminal " "CapabilitySet (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } /* Set request type as TerminalCapabilitySet */ request = ph245msg->h245Msg.u.request; pctxt = call->msgctxt; ph245msg->msgType = OOTerminalCapabilitySet; memset(request, 0, sizeof(H245RequestMessage)); request->t = T_H245RequestMessage_terminalCapabilitySet; request->u.terminalCapabilitySet = (H245TerminalCapabilitySet*) memAlloc(pctxt, sizeof(H245TerminalCapabilitySet)); termCap = request->u.terminalCapabilitySet; memset(termCap, 0, sizeof(H245TerminalCapabilitySet)); termCap->m.multiplexCapabilityPresent = 0; termCap->m.capabilityTablePresent = 0; termCap->m.capabilityDescriptorsPresent = 0; termCap->sequenceNumber = ++(call->localTermCapSeqNo); termCap->protocolIdentifier = gh245ProtocolID; /* protocol id */ OOTRACEDBGA3("Built empty terminal capability set message (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if (ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue empty TCS message to outbound queue. " "(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } ASN1UINT ooGenerateStatusDeterminationNumber() { ASN1UINT statusDeterminationNumber; ASN1UINT random_factor = getpid(); #ifdef _WIN32 SYSTEMTIME systemTime; GetLocalTime(&systemTime); srand((systemTime.wMilliseconds ^ systemTime.wSecond) + random_factor); #else struct timeval tv; gettimeofday(&tv, NULL); srand((tv.tv_usec ^ tv.tv_sec) + random_factor ); #endif statusDeterminationNumber = rand()%16777215; return statusDeterminationNumber; } /* TODO: Should Send MasterSlave Release when no response from Remote endpoint after MasterSlaveDetermination sent within timeout. */ int ooHandleMasterSlave(OOH323CallData *call, void * pmsg, int msgType) { H245MasterSlaveDetermination *masterSlave; H245MasterSlaveDeterminationAck *masterSlaveAck; ASN1UINT statusDeterminationNumber, moduloDiff; switch(msgType) { case OOMasterSlaveDetermination: OOTRACEINFO3("Master Slave Determination received (%s, %s)\n", call->callType, call->callToken); masterSlave = (H245MasterSlaveDetermination*)pmsg; if(call->masterSlaveState != OO_MasterSlave_DetermineSent && OO_TESTFLAG(gH323ep.flags, OO_M_TRYBEMASTER)) { ooSendMasterSlaveDeterminationAck(call, "slave"); call->masterSlaveState = OO_MasterSlave_Master; OOTRACEINFO3("MasterSlaveDetermination done - Master(%s, %s)\n", call->callType, call->callToken); return OO_OK; } if(masterSlave->terminalType < gH323ep.termType) { ooSendMasterSlaveDeterminationAck(call, "slave"); call->masterSlaveState = OO_MasterSlave_Master; OOTRACEINFO3("MasterSlaveDetermination done - Master(%s, %s)\n", call->callType, call->callToken); return OO_OK; } if(masterSlave->terminalType > gH323ep.termType) { ooSendMasterSlaveDeterminationAck(call, "master"); call->masterSlaveState = OO_MasterSlave_Slave; OOTRACEINFO3("MasterSlaveDetermination done - Slave(%s, %s)\n", call->callType, call->callToken); return OO_OK; } /* Since term types are same, master slave determination will be done based on statusdetermination number */ OOTRACEDBGA3("Determining master-slave based on StatusDetermination" "Number (%s, %s)\n", call->callType, call->callToken); if(call->masterSlaveState == OO_MasterSlave_DetermineSent) statusDeterminationNumber = call->statusDeterminationNumber; else if (OO_TESTFLAG(gH323ep.flags, OO_M_TRYBEMASTER)) statusDeterminationNumber = masterSlave->statusDeterminationNumber - 1; else statusDeterminationNumber = ooGenerateStatusDeterminationNumber(); moduloDiff = (masterSlave->statusDeterminationNumber - statusDeterminationNumber) &0xffffff; /* if(masterSlave->statusDeterminationNumber > statusDeterminationNumber) */ if (moduloDiff < 0x800000 && moduloDiff != 0) { ooSendMasterSlaveDeterminationAck(call, "slave"); call->masterSlaveState = OO_MasterSlave_Master; OOTRACEINFO3("MasterSlaveDetermination done - Master(%s, %s)\n", call->callType, call->callToken); return OO_OK; } /* if(masterSlave->statusDeterminationNumber < statusDeterminationNumber) */ if (moduloDiff > 0x800000) { ooSendMasterSlaveDeterminationAck(call, "master"); call->masterSlaveState = OO_MasterSlave_Slave; OOTRACEINFO3("MasterSlaveDetermination done - Slave(%s, %s)\n", call->callType, call->callToken); return OO_OK; } /* if(masterSlave->statusDeterminationNumber == statusDeterminationNumber) */ if (moduloDiff == 0 || moduloDiff == 0x800000) { ooSendMasterSlaveDeterminationReject (call); OOTRACEERR3("ERROR:MasterSlaveDetermination failed- identical " "numbers (%s, %s)\n", call->callType, call->callToken); } break; case OOMasterSlaveAck: masterSlaveAck = (H245MasterSlaveDeterminationAck*)pmsg; if(call->masterSlaveState == OO_MasterSlave_DetermineSent) { if(masterSlaveAck->decision.t == T_H245MasterSlaveDeterminationAck_decision_master) { ooSendMasterSlaveDeterminationAck(call, "slave"); call->masterSlaveState = OO_MasterSlave_Master; OOTRACEINFO3("MasterSlaveDetermination done - Master(%s, %s)\n", call->callType, call->callToken); } else { ooSendMasterSlaveDeterminationAck(call, "master"); call->masterSlaveState = OO_MasterSlave_Slave; OOTRACEINFO3("MasterSlaveDetermination done - Slave(%s, %s)\n", call->callType, call->callToken); } } call->msAckStatus = OO_msAck_remoteReceived; if(call->localTermCapState == OO_LocalTermCapSetAckRecvd && call->remoteTermCapState == OO_RemoteTermCapSetAckSent) { /*Since Cap exchange and MasterSlave Procedures are done */ if(gH323ep.h323Callbacks.openLogicalChannels) gH323ep.h323Callbacks.openLogicalChannels(call); /* ooSendStatusInquiry(call); */ if(!ooGetTransmitLogicalChannel(call)) ooOpenLogicalChannels(call); #if 0 if(!call->logicalChans){ if(!gH323ep.h323Callbacks.openLogicalChannels) ooOpenLogicalChannels(call); else gH323ep.h323Callbacks.openLogicalChannels(call); } #endif } else OOTRACEDBGC1("Not opening logical channels as Cap exchange " "remaining\n"); break; default: OOTRACEWARN3("Warn:Unhandled Master Slave message received - %s - " "%s\n", call->callType, call->callToken); } return OO_OK; } int ooSendMasterSlaveDetermination(OOH323CallData *call) { int ret; H245Message* ph245msg=NULL; H245RequestMessage *request; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; H245MasterSlaveDetermination* pMasterSlave; /* Check whether Master Slave Determination already in progress */ if(call->masterSlaveState != OO_MasterSlave_Idle) { OOTRACEINFO3("MasterSlave determination already in progress (%s, %s)\n", call->callType, call->callToken); return OO_OK; } ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if(ret != OO_OK) { OOTRACEERR3("Error: creating H245 message - MasterSlave Determination " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOMasterSlaveDetermination; request = ph245msg->h245Msg.u.request; request->t = T_H245RequestMessage_masterSlaveDetermination; request->u.masterSlaveDetermination = (H245MasterSlaveDetermination*) ASN1MALLOC(pctxt, sizeof(H245MasterSlaveDetermination)); pMasterSlave = request->u.masterSlaveDetermination; memset(pMasterSlave, 0, sizeof(H245MasterSlaveDetermination)); pMasterSlave->terminalType = gH323ep.termType; pMasterSlave->statusDeterminationNumber = ooGenerateStatusDeterminationNumber(); call->statusDeterminationNumber = pMasterSlave->statusDeterminationNumber; OOTRACEDBGA3("Built MasterSlave Determination (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue MasterSlaveDetermination message to" " outbound queue. (%s, %s)\n", call->callType, call->callToken); } else call->masterSlaveState = OO_MasterSlave_DetermineSent; ooFreeH245Message(call, ph245msg); return ret; } int ooSendMasterSlaveDeterminationAck(OOH323CallData* call, char * status) { int ret=0; H245ResponseMessage * response=NULL; H245Message *ph245msg=NULL; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - MasterSlave " "Determination Ack (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOMasterSlaveAck; response = ph245msg->h245Msg.u.response; memset(response, 0, sizeof(H245ResponseMessage)); response->t = T_H245ResponseMessage_masterSlaveDeterminationAck; response->u.masterSlaveDeterminationAck = (H245MasterSlaveDeterminationAck*) ASN1MALLOC(pctxt, sizeof(H245MasterSlaveDeterminationAck)); memset(response->u.masterSlaveDeterminationAck, 0, sizeof(H245MasterSlaveDeterminationAck)); if(!strcmp("master", status)) response->u.masterSlaveDeterminationAck->decision.t = T_H245MasterSlaveDeterminationAck_decision_master; else response->u.masterSlaveDeterminationAck->decision.t = T_H245MasterSlaveDeterminationAck_decision_slave; OOTRACEDBGA3("Built MasterSlave determination Ack (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue MasterSlaveDeterminationAck message" " to outbound queue. (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); call->msAckStatus = OO_msAck_localSent; return ret; } int ooSendMasterSlaveDeterminationReject (OOH323CallData* call) { int ret=0; H245ResponseMessage* response=NULL; H245Message *ph245msg=NULL; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message (call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if (ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - MasterSlave " "Determination Reject (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOMasterSlaveReject; response = ph245msg->h245Msg.u.response; response->t = T_H245ResponseMessage_masterSlaveDeterminationReject; response->u.masterSlaveDeterminationReject = (H245MasterSlaveDeterminationReject*) memAlloc (pctxt, sizeof(H245MasterSlaveDeterminationReject)); response->u.masterSlaveDeterminationReject->cause.t = T_H245MasterSlaveDeterminationReject_cause_identicalNumbers; OOTRACEDBGA3 ("Built MasterSlave determination reject (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg (call, ph245msg); if (ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue MasterSlaveDeterminationReject " "message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message (call, ph245msg); return ret; } int ooSendMasterSlaveDeterminationRelease(OOH323CallData * call) { int ret=0; H245IndicationMessage* indication=NULL; H245Message *ph245msg=NULL; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message (call, &ph245msg, T_H245MultimediaSystemControlMessage_indication); if (ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - MasterSlave " "Determination Release (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOMasterSlaveRelease; indication = ph245msg->h245Msg.u.indication; indication->t = T_H245IndicationMessage_masterSlaveDeterminationRelease; indication->u.masterSlaveDeterminationRelease = (H245MasterSlaveDeterminationRelease*) memAlloc (pctxt, sizeof(H245MasterSlaveDeterminationRelease)); if(!indication->u.masterSlaveDeterminationRelease) { OOTRACEERR3("Error: Failed to allocate memory for MSDRelease message." " (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } OOTRACEDBGA3 ("Built MasterSlave determination Release (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg (call, ph245msg); if (ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue MasterSlaveDeterminationRelease " "message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message (call, ph245msg); return ret; } int ooHandleMasterSlaveReject (OOH323CallData *call, H245MasterSlaveDeterminationReject* reject) { if(call->msdRetries < DEFAULT_MAX_RETRIES) { call->msdRetries++; OOTRACEDBGA3("Retrying MasterSlaveDetermination. (%s, %s)\n", call->callType, call->callToken); call->masterSlaveState = OO_MasterSlave_Idle; ooSendMasterSlaveDetermination(call); return OO_OK; } OOTRACEERR3("Error:Failed to complete MasterSlaveDetermination - " "Ending call. (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_OK; } /* handling requestmode routines */ int ooSendRequestModeAck(OOH323CallData* call, H245SequenceNumber sequenceNumber) { int ret=0; H245ResponseMessage* response=NULL; H245Message *ph245msg=NULL; OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - RequestMode " "Ack (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OORequestModeAck; response = ph245msg->h245Msg.u.response; memset(response, 0, sizeof(H245ResponseMessage)); response->t = T_H245ResponseMessage_requestModeAck; response->u.requestModeAck = (H245RequestModeAck *) ASN1MALLOC(pctxt, sizeof(H245RequestModeAck)); memset(response->u.requestModeAck, 0, sizeof(H245RequestModeAck)); response->u.requestModeAck->sequenceNumber = sequenceNumber; response->u.requestModeAck->response.t = T_H245RequestModeAck_response_willTransmitMostPreferredMode; OOTRACEDBGA3("Built RequestModeAck (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue RequestModeAck message" " to outbound queue. (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } int ooSendRequestModeReject(OOH323CallData* call, H245SequenceNumber sequenceNumber) { int ret=0; H245ResponseMessage* response=NULL; H245Message *ph245msg=NULL; OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - RequstMode " "Reject (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OORequestModeReject; response = ph245msg->h245Msg.u.response; memset(response, 0, sizeof(H245ResponseMessage)); response->t = T_H245ResponseMessage_requestModeReject; response->u.requestModeReject = (H245RequestModeReject *) ASN1MALLOC(pctxt, sizeof(H245RequestModeReject)); memset(response->u.requestModeReject, 0, sizeof(H245RequestModeReject)); response->u.requestModeReject->sequenceNumber = sequenceNumber; response->u.requestModeReject->cause.t = T_H245RequestModeReject_cause_modeUnavailable; OOTRACEDBGA3("Built RequestModeReject (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue RequestModeReject message" " to outbound queue. (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } int ooSendRequestMode(OOH323CallData* call, int isT38Mode) { int ret=0; H245RequestMessage *request; H245Message *ph245msg=NULL; OOCTXT *pctxt=call->msgctxt; H245ModeDescription pModeDesc; H245ModeElement pModeElem; if (isT38Mode && !OO_TESTFLAG(call->flags, OO_M_T38SUPPORTED)) /* t38 req but we dont support */ return OO_OK; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if(ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - RequstMode " "(%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OORequestMode; request = ph245msg->h245Msg.u.request; memset(request, 0, sizeof(H245RequestMessage)); request->t = T_H245RequestMessage_requestMode; request->u.requestMode = (H245RequestMode *) ASN1MALLOC(pctxt, sizeof(H245RequestMode)); memset(request->u.requestMode, 0, sizeof(H245RequestMode)); call->requestSequence++; call->reqFlags = (isT38Mode) ? OO_M_DATASESSION : OO_M_AUDIOSESSION; request->u.requestMode->sequenceNumber = call->requestSequence; memset(&pModeElem, 0, sizeof(pModeElem)); memset(&pModeDesc, 0, sizeof(pModeDesc)); dListInit(&(request->u.requestMode->requestedModes)); dListInit(&pModeDesc); if (isT38Mode) { pModeElem.type.t = T_H245ModeElementType_dataMode; pModeElem.type.u.dataMode = (H245DataMode *) memAllocZ(pctxt, sizeof(H245DataMode)); pModeElem.type.u.dataMode->bitRate = 144; if (!ooCreateT38ApplicationData(pctxt,&(pModeElem.type.u.dataMode->application))) { OOTRACEERR3("Error:Memory - ooCapabilityCreateT38Capability - (%s, %s)\n", call->callType, call->callToken); } } else { pModeElem.type.t = T_H245ModeElementType_audioMode; pModeElem.type.u.audioMode = (H245AudioMode *) memAllocZ(pctxt, sizeof(H245AudioMode)); pModeElem.type.u.audioMode->t = T_H245AudioMode_genericAudioMode; pModeElem.type.u.audioMode->u.genericAudioMode = (H245GenericCapability *) memAllocZ(pctxt, sizeof(H245GenericCapability)); pModeElem.type.u.audioMode->u.genericAudioMode->capabilityIdentifier.t = T_H245CapabilityIdentifier_domainBased; pModeElem.type.u.audioMode->u.genericAudioMode->capabilityIdentifier.u.domainBased = "H.323"; pModeElem.type.u.audioMode->u.genericAudioMode->m.maxBitRatePresent = TRUE; pModeElem.type.u.audioMode->u.genericAudioMode->maxBitRate = 144; } dListAppend(pctxt, &pModeDesc, &pModeElem); dListAppend(pctxt, &(request->u.requestMode->requestedModes), &pModeDesc); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue RequestMode message" " to outbound queue. (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } void ooOnReceivedRequestModeAck(OOH323CallData* call, H245RequestModeAck * requestModeAck) { int t38mode; if (!call->reqFlags) return; if (OO_TESTFLAG(call->reqFlags, OO_M_AUDIOSESSION)) { OO_SETFLAG(call->flags, OO_M_AUDIOSESSION); OO_CLRFLAG(call->flags, OO_M_DATASESSION); t38mode = 0; } else { OO_CLRFLAG(call->flags, OO_M_AUDIOSESSION); OO_SETFLAG(call->flags, OO_M_DATASESSION); t38mode = 1; } call->reqFlags = 0; /* don't handle duplicate ack packet */ ooCloseAllLogicalChannels(call, "transmit"); if(gH323ep.h323Callbacks.onModeChanged) { OOTRACEDBGA3("Handle RequestModeAck: (%s, %s), calling " "callback onModeChanged\n", call->callType, call->callToken); gH323ep.h323Callbacks.onModeChanged(call, t38mode); } } int ooHandleRequestMode(OOH323CallData* call, H245RequestMode *requestMode) { H245ModeDescription** pModeRef; H245ModeElement** pModeElem; H245ModeElementType* pMode; pModeRef = (H245ModeDescription**)dListFindByIndex(&requestMode->requestedModes, 0); pModeElem = (H245ModeElement **) dListFindByIndex(*pModeRef, 0); pMode = &((*pModeElem)->type); OOTRACEDBGA5("Handle RequestMode: " " modetype: %d/%d for (%s, %s)\n", pMode->t, pMode->u.dataMode->application.t, call->callType, call->callToken); switch (pMode->t) { case T_H245ModeElementType_dataMode: if (pMode->u.dataMode->application.t == T_H245DataMode_application_t38fax && OO_TESTFLAG(call->flags, OO_M_T38SUPPORTED)) { if (ooSendRequestModeAck(call, requestMode->sequenceNumber) == OO_OK && OO_TESTFLAG(call->flags, OO_M_AUDIOSESSION)) { OO_CLRFLAG(call->flags, OO_M_AUDIOSESSION); OO_SETFLAG(call->flags, OO_M_DATASESSION); if(gH323ep.h323Callbacks.onModeChanged) { OOTRACEDBGA3("Handle RequestMode: (%s, %s), calling " "callback onModeChanged\n", call->callType, call->callToken); gH323ep.h323Callbacks.onModeChanged(call, 1); } } } else { ooSendRequestModeReject(call, requestMode->sequenceNumber); } break; case T_H245ModeElementType_audioMode: if (ooSendRequestModeAck(call, requestMode->sequenceNumber) == OO_OK && OO_TESTFLAG(call->flags, OO_M_DATASESSION)) { OO_CLRFLAG(call->flags, OO_M_DATASESSION); OO_SETFLAG(call->flags, OO_M_AUDIOSESSION); if(gH323ep.h323Callbacks.onModeChanged) { OOTRACEDBGA3("Handle RequestMode: (%s, %s), calling " "callback onModeChanged\n", call->callType, call->callToken); gH323ep.h323Callbacks.onModeChanged(call, 0); } } break; default: ; } return OO_OK; } int ooHandleOpenLogicalChannel(OOH323CallData* call, H245OpenLogicalChannel *olc) { H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp = &(olc->forwardLogicalChannelParameters); #if 0 if(!call->logicalChans) ooOpenLogicalChannels(call); #endif /* Check whether channel type is supported. Only supported channel type for now is g711ulaw audio channel. */ switch(flcp->dataType.t) { case T_H245DataType_nonStandard: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_nonStandard' not supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_nullData: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_nullData' not supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_videoData: case T_H245DataType_audioData: case T_H245DataType_data: ooHandleOpenLogicalChannel_helper(call, olc); break; case T_H245DataType_encryptionData: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_encryptionData' not supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_h235Control: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_h235Control' not supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_h235Media: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_h235Media' not supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_multiplexedStream: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_multiplexedStream' not supported(%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_redundancyEncoding: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_redundancyEncoding' not supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_multiplePayloadStream: OOTRACEWARN3("Warn:Media channel data type " "'T_H245DataType_multiplePayloadStream' not supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; case T_H245DataType_fec: OOTRACEWARN3("Warn:Media channel data type 'T_H245DataType_fec' not " "supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); break; default: OOTRACEERR3("ERROR:Unknown media channel data type (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); } return OO_OK; } /*TODO: Need to clean logical channel in case of failure after creating one */ int ooHandleOpenLogicalChannel_helper(OOH323CallData *call, H245OpenLogicalChannel*olc) { int ret=0; H245Message *ph245msg=NULL; H245ResponseMessage *response; H245OpenLogicalChannelAck *olcAck; ooH323EpCapability *epCap=NULL; H245H2250LogicalChannelAckParameters *h2250lcap=NULL; OOCTXT *pctxt; H245UnicastAddress *unicastAddrs, *unicastAddrs1; H245UnicastAddress_iPAddress *iPAddress = NULL, *iPAddress1 = NULL; H245UnicastAddress_iP6Address *iP6Address = NULL, *iP6Address1 = NULL; ooLogicalChannel *pLogicalChannel = NULL; H245H2250LogicalChannelParameters *h2250lcp=NULL; H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp = &(olc->forwardLogicalChannelParameters); if(!flcp || flcp->multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR3("Error:ooHandleOpenLogicalChannel_helper - invalid forward " "logical channel parameters. (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_unspecified); return OO_FAILED; } h2250lcp = flcp->multiplexParameters.u.h2250LogicalChannelParameters; if(!(epCap=ooIsDataTypeSupported(call, &flcp->dataType, OORX))) { OOTRACEERR3("ERROR:HandleOpenLogicalChannel_helper - capability not " "supported (%s, %s)\n", call->callType, call->callToken); ooSendOpenLogicalChannelReject(call, olc->forwardLogicalChannelNumber, T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported); return OO_FAILED; } /* Generate an Ack for the open channel request */ ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR3("Error: H245 message creation failed for - " "OpenLogicalChannel Ack (%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, epCap); epCap = NULL; return OO_FAILED; } ph245msg->msgType = OOOpenLogicalChannelAck; ph245msg->logicalChannelNo = olc->forwardLogicalChannelNumber; response = ph245msg->h245Msg.u.response; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; memset(response, 0, sizeof(H245ResponseMessage)); response->t = T_H245ResponseMessage_openLogicalChannelAck; response->u.openLogicalChannelAck = (H245OpenLogicalChannelAck*) memAlloc(pctxt, sizeof(H245OpenLogicalChannelAck)); olcAck = response->u.openLogicalChannelAck; memset(olcAck, 0, sizeof(H245OpenLogicalChannelAck)); olcAck->forwardLogicalChannelNumber = olc->forwardLogicalChannelNumber; olcAck->m.forwardMultiplexAckParametersPresent = 1; olcAck->forwardMultiplexAckParameters.t = T_H245OpenLogicalChannelAck_forwardMultiplexAckParameters_h2250LogicalChannelAckParameters; olcAck->forwardMultiplexAckParameters.u.h2250LogicalChannelAckParameters = (H245H2250LogicalChannelAckParameters*)ASN1MALLOC(pctxt, sizeof(H245H2250LogicalChannelAckParameters)); h2250lcap = olcAck->forwardMultiplexAckParameters.u.h2250LogicalChannelAckParameters; memset(h2250lcap, 0, sizeof(H245H2250LogicalChannelAckParameters)); h2250lcap->m.mediaChannelPresent = 1; h2250lcap->m.mediaControlChannelPresent = 1; h2250lcap->m.sessionIDPresent = 1; if(h2250lcp->sessionID == 0) h2250lcap->sessionID = ooCallGenerateSessionID(call, epCap->capType, "receive"); else h2250lcap->sessionID = h2250lcp->sessionID; h2250lcap->mediaChannel.t = T_H245TransportAddress_unicastAddress; h2250lcap->mediaChannel.u.unicastAddress = (H245UnicastAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress)); unicastAddrs = h2250lcap->mediaChannel.u.unicastAddress; memset(unicastAddrs, 0, sizeof(H245UnicastAddress)); if (call->versionIP == 6) { unicastAddrs->t = T_H245UnicastAddress_iP6Address; unicastAddrs->u.iP6Address = (H245UnicastAddress_iP6Address*) memAlloc(pctxt, sizeof(H245UnicastAddress_iP6Address)); iP6Address = unicastAddrs->u.iP6Address; memset(iP6Address, 0, sizeof(H245UnicastAddress_iP6Address)); } else { unicastAddrs->t = T_H245UnicastAddress_iPAddress; unicastAddrs->u.iPAddress = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, sizeof(H245UnicastAddress_iPAddress)); iPAddress = unicastAddrs->u.iPAddress; memset(iPAddress, 0, sizeof(H245UnicastAddress_iPAddress)); } pLogicalChannel = ooAddNewLogicalChannel(call, olc->forwardLogicalChannelNumber, h2250lcap->sessionID, "receive", epCap); if(!pLogicalChannel) { OOTRACEERR3("ERROR:Failed to add new logical channel entry to call " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if (call->versionIP == 6) { inet_pton(AF_INET6, pLogicalChannel->localIP, iP6Address->network.data); iP6Address->network.numocts = 16; iP6Address->tsapIdentifier = pLogicalChannel->localRtpPort; } else { inet_pton(AF_INET, pLogicalChannel->localIP, iPAddress->network.data); iPAddress->network.numocts = 4; iPAddress->tsapIdentifier = pLogicalChannel->localRtpPort; } /* media contrcol channel */ h2250lcap->mediaControlChannel.t = T_H245TransportAddress_unicastAddress; h2250lcap->mediaControlChannel.u.unicastAddress = (H245UnicastAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress)); unicastAddrs1 = h2250lcap->mediaControlChannel.u.unicastAddress; memset(unicastAddrs1, 0, sizeof(H245UnicastAddress)); if (call->versionIP == 6) { unicastAddrs1->t = T_H245UnicastAddress_iP6Address; unicastAddrs1->u.iP6Address = (H245UnicastAddress_iP6Address*) memAlloc(pctxt, sizeof(H245UnicastAddress_iP6Address)); iP6Address1 = unicastAddrs1->u.iP6Address; memset(iP6Address1, 0, sizeof(H245UnicastAddress_iP6Address)); inet_pton(AF_INET6, pLogicalChannel->localIP, iP6Address1->network.data); iP6Address1->network.numocts = 16; iP6Address1->tsapIdentifier = pLogicalChannel->localRtcpPort; } else { unicastAddrs1->t = T_H245UnicastAddress_iPAddress; unicastAddrs1->u.iPAddress = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, sizeof(H245UnicastAddress_iPAddress)); iPAddress1 = unicastAddrs1->u.iPAddress; memset(iPAddress1, 0, sizeof(H245UnicastAddress_iPAddress)); inet_pton(AF_INET, pLogicalChannel->localIP, iPAddress1->network.data); iPAddress1->network.numocts = 4; iPAddress1->tsapIdentifier = pLogicalChannel->localRtcpPort; } OOTRACEDBGA3("Built OpenLogicalChannelAck (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue OpenLogicalChannelAck message to " "outbound queue. (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); if(epCap->startReceiveChannel) { epCap->startReceiveChannel(call, pLogicalChannel); OOTRACEINFO6("Receive channel of type %s started at %s:%d(%s, %s)\n", ooGetCapTypeText(epCap->cap), pLogicalChannel->localIP, pLogicalChannel->localRtpPort, call->callType, call->callToken); } else{ OOTRACEERR3("ERROR:No callback registered to start receive audio " "channel (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pLogicalChannel->state = OO_LOGICALCHAN_ESTABLISHED; return ret; } int ooSendOpenLogicalChannelReject (OOH323CallData *call, ASN1UINT channelNum, ASN1UINT cause) { int ret=0; H245ResponseMessage* response=NULL; H245Message *ph245msg=NULL; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message (call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if (ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - OpenLogicalChannel" "Reject (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOOpenLogicalChannelReject; response = ph245msg->h245Msg.u.response; response->t = T_H245ResponseMessage_openLogicalChannelReject; response->u.openLogicalChannelReject = (H245OpenLogicalChannelReject*) memAlloc (pctxt, sizeof(H245OpenLogicalChannelReject)); if(!response->u.openLogicalChannelReject) { OOTRACEERR3("Error: Failed to allocate memory for OpenLogicalChannel" "Reject message. (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } response->u.openLogicalChannelReject->forwardLogicalChannelNumber = channelNum; response->u.openLogicalChannelReject->cause.t = cause; OOTRACEDBGA3 ("Built OpenLogicalChannelReject (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg (call, ph245msg); if (ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue OpenLogicalChannelReject " "message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message (call, ph245msg); return ret; } int ooOnReceivedOpenLogicalChannelAck(OOH323CallData *call, H245OpenLogicalChannelAck *olcAck) { char remoteip[2+8*4+7]; regmatch_t pmatch[1]; ooLogicalChannel *pLogicalChannel; H245H2250LogicalChannelAckParameters *h2250lcap; H245UnicastAddress *unicastAddr; H245UnicastAddress_iPAddress *iPAddress = NULL; H245UnicastAddress_iP6Address *iP6Address = NULL; H245UnicastAddress *unicastAddr1; H245UnicastAddress_iPAddress *iPAddress1 = NULL; H245UnicastAddress_iP6Address *iP6Address1 = NULL; if(!((olcAck->m.forwardMultiplexAckParametersPresent == 1) && (olcAck->forwardMultiplexAckParameters.t == T_H245OpenLogicalChannelAck_forwardMultiplexAckParameters_h2250LogicalChannelAckParameters))) { OOTRACEERR3("Error: Processing open logical channel ack - LogicalChannel" "Ack parameters absent (%s, %s)\n", call->callType, call->callToken); return OO_OK; /* should send CloseLogicalChannel request */ } h2250lcap = olcAck->forwardMultiplexAckParameters.u.h2250LogicalChannelAckParameters; /* Extract media channel address */ if(h2250lcap->m.mediaChannelPresent != 1) { OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media channel " "absent (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if(h2250lcap->mediaChannel.t != T_H245TransportAddress_unicastAddress) { OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media channel " "address type is not unicast (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } unicastAddr = h2250lcap->mediaChannel.u.unicastAddress; if (call->versionIP == 6) { if(unicastAddr->t != T_H245UnicastAddress_iP6Address) { OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media channel " "address type is not IP6 (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } iP6Address = unicastAddr->u.iP6Address; inet_ntop(AF_INET6, iP6Address->network.data, remoteip, sizeof(remoteip)); } else { if(unicastAddr->t != T_H245UnicastAddress_iPAddress) { OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media channel " "address type is not IP (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } iPAddress = unicastAddr->u.iPAddress; inet_ntop(AF_INET, iPAddress->network.data, remoteip, sizeof(remoteip)); } /* Extract media control channel address */ if(h2250lcap->m.mediaControlChannelPresent == 1) { if(h2250lcap->mediaControlChannel.t != T_H245TransportAddress_unicastAddress) { OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media control " "channel addres type is not unicast (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } unicastAddr1 = h2250lcap->mediaControlChannel.u.unicastAddress; if (call->versionIP == 6) { if(unicastAddr1->t != T_H245UnicastAddress_iP6Address) { OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media control " "channel address type is not IP6 (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } iP6Address1 = unicastAddr1->u.iP6Address; } else { if(unicastAddr1->t != T_H245UnicastAddress_iPAddress) { OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media control " "channel address type is not IP (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } iPAddress1 = unicastAddr1->u.iPAddress; } } else { OOTRACEDBGA3("Warning: Processing OpenLogicalChannelAck - Missing media " "control channel (%s, %s)\n", call->callType, call->callToken); } /* Set remote destination address for rtp session */ // strcpy(call->remoteIP, remoteip); /* Start channel here */ pLogicalChannel = ooFindLogicalChannelByLogicalChannelNo(call,olcAck->forwardLogicalChannelNumber); if(!pLogicalChannel) { OOTRACEERR4("ERROR:Logical channel %d not found in the channel list for " "call (%s, %s)\n", olcAck->forwardLogicalChannelNumber, call->callType, call->callToken); return OO_FAILED; } /* Update session id if we were waiting for remote to assign one and remote did assign one. */ if(pLogicalChannel->sessionID == 0 && h2250lcap->m.sessionIDPresent) pLogicalChannel->sessionID = h2250lcap->sessionID; /* Populate ports &ip for channel */ if (call->rtpMaskStr[0]) { if (regexec(&call->rtpMask->regex, remoteip, 1, pmatch, 0)) { OOTRACEERR5("ERROR:H245 Address is not matched with filter %s/%s" "(%s, %s)\n", remoteip, call->rtpMaskStr, call->callType, call->callToken); return OO_FAILED; } } strcpy(pLogicalChannel->remoteIP, remoteip); if (call->versionIP == 6) { pLogicalChannel->remoteMediaPort = iP6Address->tsapIdentifier; if (iP6Address1) pLogicalChannel->remoteMediaControlPort = iP6Address1->tsapIdentifier; } else { pLogicalChannel->remoteMediaPort = iPAddress->tsapIdentifier; if (iPAddress1) pLogicalChannel->remoteMediaControlPort = iPAddress1->tsapIdentifier; } if(pLogicalChannel->chanCap->startTransmitChannel) { pLogicalChannel->chanCap->startTransmitChannel(call, pLogicalChannel); OOTRACEINFO4("TransmitLogical Channel of type %s started (%s, %s)\n", ooGetCapTypeText(pLogicalChannel->chanCap->cap), call->callType, call->callToken); } else{ OOTRACEERR3("ERROR:No callback registered for starting transmit channel " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pLogicalChannel->state = OO_LOGICALCHAN_ESTABLISHED; return OO_OK; } int ooOnReceivedOpenLogicalChannelRejected(OOH323CallData *call, H245OpenLogicalChannelReject *olcReject) { switch(olcReject->cause.t) { case T_H245OpenLogicalChannelReject_cause_unspecified: OOTRACEINFO4("Open logical channel %d rejected - unspecified (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_unsuitableReverseParameters: OOTRACEINFO4("Open logical channel %d rejected - " "unsuitableReverseParameters (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_dataTypeNotSupported: OOTRACEINFO4("Open logical channel %d rejected - dataTypeNotSupported" "(%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_dataTypeNotAvailable: OOTRACEINFO4("Open logical channel %d rejected - dataTypeNotAvailable" "(%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_unknownDataType: OOTRACEINFO4("Open logical channel %d rejected - unknownDataType" "(%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_dataTypeALCombinationNotSupported: OOTRACEINFO4("Open logical channel %d rejected - " "dataTypeALCombinationNotSupported(%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_multicastChannelNotAllowed: OOTRACEINFO4("Open logical channel %d rejected - " "multicastChannelNotAllowed (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_insufficientBandwidth: OOTRACEINFO4("Open logical channel %d rejected - insufficientBandwidth" "(%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_separateStackEstablishmentFailed: OOTRACEINFO4("Open logical channel %d rejected - " "separateStackEstablishmentFailed (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_invalidSessionID: OOTRACEINFO4("Open logical channel %d rejected - " "invalidSessionID (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_masterSlaveConflict: OOTRACEINFO4("Open logical channel %d rejected - " "invalidSessionID (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_waitForCommunicationMode: OOTRACEINFO4("Open logical channel %d rejected - " "waitForCommunicationMode (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_invalidDependentChannel: OOTRACEINFO4("Open logical channel %d rejected - " "invalidDependentChannel (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245OpenLogicalChannelReject_cause_replacementForRejected: OOTRACEINFO4("Open logical channel %d rejected - " "replacementForRejected (%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; default: OOTRACEERR4("Error: OpenLogicalChannel %d rejected - " "invalid cause(%s, %s)\n", olcReject->forwardLogicalChannelNumber, call->callType, call->callToken); } if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_LOCAL_CLEARED; } return OO_OK; } /** * Currently only disconnect end session command is supported. **/ int ooSendEndSessionCommand(OOH323CallData *call) { int ret; H245CommandMessage * command; OOCTXT *pctxt; H245Message *ph245msg=NULL; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_command); if(ret != OO_OK) { OOTRACEERR3("Error: H245 message creation failed for - End Session " "Command (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOEndSessionCommand; command = ph245msg->h245Msg.u.command; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; memset(command, 0, sizeof(H245CommandMessage)); command->t = T_H245CommandMessage_endSessionCommand; command->u.endSessionCommand = (H245EndSessionCommand*) ASN1MALLOC(pctxt, sizeof(H245EndSessionCommand)); memset(command->u.endSessionCommand, 0, sizeof(H245EndSessionCommand)); command->u.endSessionCommand->t = T_H245EndSessionCommand_disconnect; OOTRACEDBGA3("Built EndSession Command (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue EndSession message to outbound " "queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } int ooHandleH245Command(OOH323CallData *call, H245CommandMessage *command) { ASN1UINT i; DListNode *pNode = NULL; OOTimer *pTimer = NULL; OOTRACEDBGC3("Handling H.245 command message. (%s, %s)\n", call->callType, call->callToken); switch(command->t) { case T_H245CommandMessage_endSessionCommand: OOTRACEINFO3("Received EndSession command (%s, %s)\n", call->callType, call->callToken); if(call->h245SessionState == OO_H245SESSION_ENDSENT) { /* Disable Session timer */ for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_SESSION_TIMER) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted Session Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooCloseH245Connection(call); if (call->callState < OO_CALL_CLEAR) call->callState = OO_CALL_CLEAR; } else{ call->h245SessionState = OO_H245SESSION_ENDRECVD; if(call->logicalChans) { OOTRACEINFO3("In response to received EndSessionCommand - " "Clearing all logical channels. (%s, %s)\n", call->callType, call->callToken); ooClearAllLogicalChannels(call); } ooSendEndSessionCommand(call); if (call->callState < OO_CALL_CLEAR) call->callState = OO_CALL_CLEAR; } break; case T_H245CommandMessage_sendTerminalCapabilitySet: OOTRACEWARN3("Warning: Received command Send terminal capability set " "- Not handled (%s, %s)\n", call->callType, call->callToken); break; case T_H245CommandMessage_flowControlCommand: OOTRACEWARN3("Warning: Flow control command received - Not handled " "(%s, %s)\n", call->callType, call->callToken); break; default: OOTRACEWARN3("Warning: Unhandled H245 command message received " "(%s, %s)\n", call->callType, call->callToken); } OOTRACEDBGC3("Handling H.245 command message done. (%s, %s)\n", call->callType, call->callToken); return OO_OK; } int ooOnReceivedTerminalCapabilitySetAck(OOH323CallData* call) { int ret = OO_OK; call->localTermCapState = OO_LocalTermCapSetAckRecvd; if(call->remoteTermCapState != OO_RemoteTermCapSetAckSent) return OO_OK; if(call->masterSlaveState == OO_MasterSlave_Idle) { ret = ooSendMasterSlaveDetermination(call); if(ret != OO_OK) { OOTRACEERR3("ERROR:Sending Master-slave determination message " "(%s, %s)\n", call->callType, call->callToken); return ret; } } if((call->masterSlaveState == OO_MasterSlave_Master || call->masterSlaveState == OO_MasterSlave_Slave) && (call->msAckStatus == OO_msAck_remoteReceived)) { if(gH323ep.h323Callbacks.openLogicalChannels) gH323ep.h323Callbacks.openLogicalChannels(call); /* ooSendStatusInquiry(call); */ if(!ooGetTransmitLogicalChannel(call)) ooOpenLogicalChannels(call); #if 0 if(!call->logicalChans){ if(!gH323ep.h323Callbacks.openLogicalChannels) ooOpenLogicalChannels(call); else gH323ep.h323Callbacks.openLogicalChannels(call); } #endif } return OO_OK; } int ooCloseAllLogicalChannels(OOH323CallData *call, char* dir) { ooLogicalChannel *temp; temp = call->logicalChans; while(temp) { if(temp->state == OO_LOGICALCHAN_ESTABLISHED && (dir == NULL || !strcmp(temp->dir,dir))) { /* Sending closelogicalchannel only for outgoing channels*/ if(!strcmp(temp->dir, "transmit")) { ooSendCloseLogicalChannel(call, temp); } else{ ooSendRequestCloseLogicalChannel(call, temp); } } temp = temp->next; } return OO_OK; } int ooUpdateAllLogicalChannels(OOH323CallData *call, char* localIP, int port) { ooLogicalChannel *temp; OOMediaInfo *pMediaInfo = NULL; char *lIP = localIP; OOBOOL eTCS = FALSE; if (!lIP || !lIP[0]) { lIP = call->localIP; } /* close all log chans */ temp = call->logicalChans; while (temp) { if (temp->state == OO_LOGICALCHAN_ESTABLISHED) { /* Sending closelogicalchannel only for outgoing channels */ if (!strcmp(temp->dir, "transmit")) { if (call->h245SessionState != OO_H245SESSION_IDLE) { ooSendCloseLogicalChannel(call, temp); } else { ooClearLogicalChannel(call, temp->channelNo); } } else if (!eTCS && call->h245SessionState != OO_H245SESSION_IDLE) { ooSendEmptyTermCapMsg(call); eTCS = TRUE; } } temp = temp->next; } /* change media address for all caps */ if (call->mediaInfo) { pMediaInfo = call->mediaInfo; while (pMediaInfo) { strcpy(pMediaInfo->lMediaIP, lIP); pMediaInfo->lMediaRedirPort = port; pMediaInfo->lMediaRedirCPort = port + 1; pMediaInfo = pMediaInfo->next; } } if (call->h245SessionState == OO_H245SESSION_IDLE) { if (call->fsSent) { ooSendFSUpdate(call); } } else { call->TCSPending = TRUE; } /* Restart TCS exchange proc - Paul Cadah do it in chan_h323_exts native bridge code */ /* We must do it after all log channels are closed */ return OO_OK; } int ooSendCloseLogicalChannel(OOH323CallData *call, ooLogicalChannel *logicalChan) { int ret = OO_OK, error=0; H245Message *ph245msg = NULL; OOCTXT *pctxt; H245RequestMessage *request; H245CloseLogicalChannel* clc; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to create H245 message for closeLogicalChannel" " message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOCloseLogicalChannel; ph245msg->logicalChannelNo = logicalChan->channelNo; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; request = ph245msg->h245Msg.u.request; request->t = T_H245RequestMessage_closeLogicalChannel; request->u.closeLogicalChannel = (H245CloseLogicalChannel*)ASN1MALLOC(pctxt, sizeof(H245CloseLogicalChannel)); if(!request->u.closeLogicalChannel) { OOTRACEERR3("ERROR:Memory allocation for CloseLogicalChannel failed " "(%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } clc = request->u.closeLogicalChannel; memset(clc, 0, sizeof(H245CloseLogicalChannel)); clc->forwardLogicalChannelNumber = logicalChan->channelNo; clc->source.t = T_H245CloseLogicalChannel_source_lcse; clc->m.reasonPresent = 1; clc->reason.t = T_H245CloseLogicalChannel_reason_unknown; OOTRACEDBGA4("Built close logical channel for %d (%s, %s)\n", logicalChan->channelNo, call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue CloseLogicalChannel to outbound queue.(%s, %s)\n", call->callType, call->callToken); error++; } ooFreeH245Message(call, ph245msg); /* Stop the media transmission */ /* Moved to OnReceivedClosedChannelAck */ logicalChan->state = OO_LOGICALCHAN_CLOSEPENDING; if (error) { return OO_FAILED; } return ret; } /*TODO: Need to pass reason as a parameter */ int ooSendRequestCloseLogicalChannel(OOH323CallData *call, ooLogicalChannel *logicalChan) { int ret = OO_OK; H245Message *ph245msg = NULL; OOCTXT *pctxt; H245RequestMessage *request; H245RequestChannelClose *rclc; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to create H245 message for " "requestCloseLogicalChannel message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OORequestChannelClose; ph245msg->logicalChannelNo = logicalChan->channelNo; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; request = ph245msg->h245Msg.u.request; request->t = T_H245RequestMessage_requestChannelClose; request->u.requestChannelClose = (H245RequestChannelClose*)ASN1MALLOC(pctxt, sizeof(H245RequestChannelClose)); if(!request->u.requestChannelClose) { OOTRACEERR3("ERROR:Memory allocation for RequestCloseLogicalChannel " " failed (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } rclc = request->u.requestChannelClose; memset(rclc, 0, sizeof(H245RequestChannelClose)); rclc->forwardLogicalChannelNumber = logicalChan->channelNo; rclc->m.reasonPresent = 1; rclc->reason.t = T_H245RequestChannelClose_reason_unknown; OOTRACEDBGA4("Built RequestCloseChannel for %d (%s, %s)\n", logicalChan->channelNo, call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue the RequestCloseChannel to outbound" " queue (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } int ooSendRequestChannelCloseRelease(OOH323CallData *call, int channelNum) { int ret = OO_OK; H245Message *ph245msg = NULL; OOCTXT *pctxt; H245IndicationMessage *indication; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_indication); if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to create H245 message for " "RequestChannelCloseRelease message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OORequestChannelCloseRelease; ph245msg->logicalChannelNo = channelNum; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; indication = ph245msg->h245Msg.u.indication; indication->t = T_H245IndicationMessage_requestChannelCloseRelease; indication->u.requestChannelCloseRelease = (H245RequestChannelCloseRelease*) ASN1MALLOC(pctxt, sizeof(H245RequestChannelCloseRelease)); if(!indication->u.requestChannelCloseRelease) { OOTRACEERR3("Error:Failed to allocate memory for " "RequestChannelCloseRelease message. (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); } indication->u.requestChannelCloseRelease->forwardLogicalChannelNumber = channelNum; OOTRACEDBGA4("Built RequestChannelCloseRelease for %d (%s, %s)\n", channelNum, call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue the RequestChannelCloseRelease to " "outbound queue (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } int ooOnReceivedRequestChannelClose(OOH323CallData *call, H245RequestChannelClose *rclc) { int ret=0, error=0; H245Message *ph245msg=NULL; H245ResponseMessage *response = NULL; OOCTXT *pctxt=NULL; H245RequestChannelCloseAck *rclcAck; ooLogicalChannel * lChannel=NULL; /* Send Ack: TODO: Need to send reject, if doesn't exist */ lChannel = ooFindLogicalChannelByLogicalChannelNo(call, rclc->forwardLogicalChannelNumber); if(!lChannel) { OOTRACEERR4("ERROR:Channel %d requested to be closed not found " "(%s, %s)\n", rclc->forwardLogicalChannelNumber, call->callType, call->callToken); return OO_FAILED; } else{ if(strcmp(lChannel->dir, "transmit")) { OOTRACEERR4("ERROR:Channel %d requested to be closed, Not a forward " "channel (%s, %s)\n", rclc->forwardLogicalChannelNumber, call->callType, call->callToken); return OO_FAILED; } } ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR3("ERROR:Memory allocation for RequestChannelCloseAck message " "failed (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; ph245msg->msgType = OORequestChannelCloseAck; ph245msg->logicalChannelNo = rclc->forwardLogicalChannelNumber; response = ph245msg->h245Msg.u.response; response->t = T_H245ResponseMessage_requestChannelCloseAck; response->u.requestChannelCloseAck = (H245RequestChannelCloseAck*)ASN1MALLOC (pctxt, sizeof(H245RequestChannelCloseAck)); if(!response->u.requestChannelCloseAck) { OOTRACEERR3("ERROR:Failed to allocate memory for RequestChannelCloseAck " "message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } rclcAck = response->u.requestChannelCloseAck; memset(rclcAck, 0, sizeof(H245RequestChannelCloseAck)); rclcAck->forwardLogicalChannelNumber = rclc->forwardLogicalChannelNumber; OOTRACEDBGA3("Built RequestCloseChannelAck message (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue RequestCloseChannelAck to outbound queue. (%s, %s)\n", call->callType, call->callToken); error++; } ooFreeH245Message(call, ph245msg); /* Send Close Logical Channel if LogChan is established */ if (lChannel->state == OO_LOGICALCHAN_ESTABLISHED) { ret = ooSendCloseLogicalChannel(call, lChannel); if (ret != OO_OK) { OOTRACEERR3("ERROR:Failed to build CloseLgicalChannel message(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } } if (error) { return OO_FAILED; } return ret; } int ooSendRoundTripDelayRequest(OOH323CallData *call) { int ret=0; H245Message *ph245msg=NULL; H245RequestMessage *request = NULL; OOCTXT *pctxt=NULL; H245RoundTripDelayRequest *rtdr; ooTimerCallback *cbData=NULL; if (call->rtdrSend > call->rtdrRecv + call->rtdrCount) { if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_UNKNOWN; call->q931cause = Q931RecoveryOnTimerExpiry; } return OO_FAILED; } ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if(ret != OO_OK) { OOTRACEERR3("ERROR:Memory allocation for RoundTripDelayResponse message " "failed (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pctxt = call->msgctxt; ph245msg->msgType = OORequestDelayRequest; request = ph245msg->h245Msg.u.request; request->t = T_H245RequestMessage_roundTripDelayRequest; request->u.roundTripDelayRequest = (H245RoundTripDelayRequest *)ASN1MALLOC (pctxt, sizeof(H245RoundTripDelayRequest)); if(!request->u.roundTripDelayRequest) { OOTRACEERR3("ERROR:Failed to allocate memory for H245RoundTripDelayRequest " "message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } rtdr = request->u.roundTripDelayRequest; memset(rtdr, 0, sizeof(H245RoundTripDelayRequest)); rtdr->sequenceNumber = ++call->rtdrSend; OOTRACEDBGA3("Built RoundTripDelayRequest message (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue RoundTripDelayRequest to outbound queue. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } else { cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback data." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_RTD_TIMER; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooRTDTimerExpired, call->rtdrInterval, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create RTDR timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } } ooFreeH245Message(call, ph245msg); return ret; } int ooOnReceivedRoundTripDelayRequest(OOH323CallData *call, H245SequenceNumber sequenceNumber) { int ret=0; H245Message *ph245msg=NULL; H245ResponseMessage *response = NULL; OOCTXT *pctxt=NULL; H245RoundTripDelayResponse *rtdr; ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR3("ERROR:Memory allocation for RoundTripDelayResponse message " "failed (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pctxt = call->msgctxt; ph245msg->msgType = OORequestDelayResponse; response = ph245msg->h245Msg.u.response; response->t = T_H245ResponseMessage_roundTripDelayResponse; response->u.roundTripDelayResponse = (H245RoundTripDelayResponse *)ASN1MALLOC (pctxt, sizeof(H245RoundTripDelayResponse)); if(!response->u.roundTripDelayResponse) { OOTRACEERR3("ERROR:Failed to allocate memory for H245RoundTripDelayResponse " "message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } rtdr = response->u.roundTripDelayResponse; memset(rtdr, 0, sizeof(H245RoundTripDelayResponse)); rtdr->sequenceNumber = sequenceNumber; OOTRACEDBGA3("Built RoundTripDelayResponse message (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue RoundTripDelayResponse to outbound queue. (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } /* We clear channel here. Ideally the remote endpoint should send CloseLogicalChannel and then the channel should be cleared. But there's no timer for this and if remote endpoint misbehaves, the call will keep waiting for CloseLogicalChannel and hence, wouldn't be cleared. In case when remote endpoint sends CloseLogicalChannel, we call ooClearLogicalChannel again, which simply returns OO_OK as channel was already cleared. Other option is to start a timer for call cleanup and if call is not cleaned up within timeout, we clean call forcefully. Note, no such timer is defined in standards. */ int ooOnReceivedRequestChannelCloseAck (OOH323CallData *call, H245RequestChannelCloseAck *rccAck) { int ret=OO_OK; /* Remote endpoint is ok to close channel. So let's do it */ ret = ooClearLogicalChannel(call, rccAck->forwardLogicalChannelNumber); if(ret != OO_OK) { OOTRACEERR4("Error:Failed to clear logical channel %d. (%s, %s)\n", rccAck->forwardLogicalChannelNumber, call->callType, call->callToken); } return ret; } int ooOnReceivedRequestChannelCloseReject (OOH323CallData *call, H245RequestChannelCloseReject *rccReject) { int ret =0; switch(rccReject->cause.t) { case T_H245RequestChannelCloseReject_cause_unspecified: OOTRACEDBGA4("Remote endpoint has rejected request to close logical " "channel %d - cause unspecified. (%s, %s)\n", rccReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; case T_H245RequestChannelCloseReject_cause_extElem1: OOTRACEDBGA4("Remote endpoint has rejected request to close logical " "channel %d - cause propriatory. (%s, %s)\n", rccReject->forwardLogicalChannelNumber, call->callType, call->callToken); break; default: OOTRACEDBGA4("Remote endpoint has rejected request to close logical " "channel %d - cause INVALID. (%s, %s)\n", rccReject->forwardLogicalChannelNumber, call->callType, call->callToken); } OOTRACEDBGA4("Clearing logical channel %d. (%s, %s)\n", rccReject->forwardLogicalChannelNumber, call->callType, call->callToken); ret = ooClearLogicalChannel(call, rccReject->forwardLogicalChannelNumber); if(ret != OO_OK) { OOTRACEERR4("Error: failed to clear logical channel %d.(%s, %s)\n", rccReject->forwardLogicalChannelNumber, call->callType, call->callToken); } return ret; } /****/ int ooOnReceivedCloseLogicalChannel(OOH323CallData *call, H245CloseLogicalChannel* clc) { int ret=0; H245Message *ph245msg = NULL; OOCTXT *pctxt = NULL; H245CloseLogicalChannelAck * clcAck; H245ResponseMessage *response; OOTRACEINFO4("Closing logical channel number %d (%s, %s)\n", clc->forwardLogicalChannelNumber, call->callType, call->callToken); ret = ooClearLogicalChannel(call, clc->forwardLogicalChannelNumber); if (ret != OO_OK) { OOTRACEERR4("ERROR:Failed to close logical channel %d (%s, %s)\n", clc->forwardLogicalChannelNumber, call->callType, call->callToken); return OO_FAILED; } ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to create H245 message for " "closeLogicalChannelAck (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; ph245msg->msgType = OOCloseLogicalChannelAck; ph245msg->logicalChannelNo = clc->forwardLogicalChannelNumber; response = ph245msg->h245Msg.u.response; response->t = T_H245ResponseMessage_closeLogicalChannelAck; response->u.closeLogicalChannelAck = (H245CloseLogicalChannelAck*) ASN1MALLOC(pctxt, sizeof(H245CloseLogicalChannelAck)); clcAck = response->u.closeLogicalChannelAck; if(!clcAck) { OOTRACEERR3("ERROR:Failed to allocate memory for closeLogicalChannelAck " "(%s, %s)\n", call->callType, call->callToken); return OO_OK; } memset(clcAck, 0, sizeof(H245CloseLogicalChannelAck)); clcAck->forwardLogicalChannelNumber = clc->forwardLogicalChannelNumber; OOTRACEDBGA3("Built CloseLogicalChannelAck message (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue CloseLogicalChannelAck message to " "outbound queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } int ooOnReceivedCloseChannelAck(OOH323CallData* call, H245CloseLogicalChannelAck* clcAck) { int ret = OO_OK; /* Stop the media transmission */ OOTRACEINFO4("Closing logical channel %d (%s, %s)\n", clcAck->forwardLogicalChannelNumber, call->callType, call->callToken); ret = ooClearLogicalChannel(call, clcAck->forwardLogicalChannelNumber); if (ret != OO_OK) { OOTRACEERR4("ERROR:Failed to close logical channel %d (%s, %s)\n", clcAck->forwardLogicalChannelNumber, call->callType, call->callToken); return OO_FAILED; } return ret; } int ooHandleH245Message(OOH323CallData *call, H245Message * pmsg) { ASN1UINT i; DListNode *pNode = NULL; OOTimer *pTimer = NULL; H245Message *pH245 = (H245Message*)pmsg; /* There are four major types of H.245 messages that can be received. Request/Response/Command/Indication. Each one of them need to be handled separately. */ H245RequestMessage *request = NULL; H245ResponseMessage *response = NULL; H245CommandMessage *command = NULL; H245IndicationMessage *indication = NULL; OOTRACEDBGC3("Handling H245 message. (%s, %s)\n", call->callType, call->callToken); switch(pH245->h245Msg.t) { /* H.245 Request message is received */ case (T_H245MultimediaSystemControlMessage_request): request = pH245->h245Msg.u.request; switch(request->t) { case T_H245RequestMessage_terminalCapabilitySet: /* If session isn't marked active yet, do it. possible in case of tunneling */ if(call->h245SessionState == OO_H245SESSION_IDLE) call->h245SessionState = OO_H245SESSION_ACTIVE; ooOnReceivedTerminalCapabilitySet(call, pH245); if(call->localTermCapState == OO_LocalTermCapExchange_Idle) ooSendTermCapMsg(call); break; case T_H245RequestMessage_masterSlaveDetermination: ooHandleMasterSlave(call, request->u.masterSlaveDetermination, OOMasterSlaveDetermination); break; case T_H245RequestMessage_openLogicalChannel: ooHandleOpenLogicalChannel(call, request->u.openLogicalChannel); if(!ooGetTransmitLogicalChannel(call)) ooOpenLogicalChannels(call); break; case T_H245RequestMessage_requestMode: OOTRACEINFO4("Received request mode - %d (%s, %s)\n", request->u.requestMode->sequenceNumber, call->callType, call->callToken); ooHandleRequestMode(call, request->u.requestMode); break; case T_H245RequestMessage_closeLogicalChannel: OOTRACEINFO4("Received close logical Channel - %d (%s, %s)\n", request->u.closeLogicalChannel->forwardLogicalChannelNumber, call->callType, call->callToken); if (ooOnReceivedCloseLogicalChannel(call, request->u.closeLogicalChannel) == OO_OK) { if (call->TCSPending && !ooGetTransmitLogicalChannel(call)) { call->TCSPending = FALSE; call->localTermCapState = OO_LocalTermCapExchange_Idle; ooSendTermCapMsg(call); } else if (!call->TCSPending) { ooCloseAllLogicalChannels(call, NULL); } } break; case T_H245RequestMessage_requestChannelClose: OOTRACEINFO4("Received RequestChannelClose - %d (%s, %s)\n", request->u.requestChannelClose->forwardLogicalChannelNumber, call->callType, call->callToken); ooOnReceivedRequestChannelClose(call, request->u.requestChannelClose); break; case T_H245RequestMessage_roundTripDelayRequest: OOTRACEINFO4("Received roundTripDelayRequest - %d (%s, %s)\n", request->u.roundTripDelayRequest->sequenceNumber, call->callType, call->callToken); ooOnReceivedRoundTripDelayRequest(call, request->u.roundTripDelayRequest->sequenceNumber); break; default: ; } /* End of Request Message */ break; /* H.245 Response message is received */ case (T_H245MultimediaSystemControlMessage_response): response = pH245->h245Msg.u.response; switch(response->t) { case T_H245ResponseMessage_masterSlaveDeterminationAck: /* Disable MSD timer */ for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_MSD_TIMER) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted MSD Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooHandleMasterSlave(call, response->u.masterSlaveDeterminationAck, OOMasterSlaveAck); break; case T_H245ResponseMessage_masterSlaveDeterminationReject: /* Disable MSD timer */ for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_MSD_TIMER) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted MSD Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooHandleMasterSlaveReject(call, response->u.masterSlaveDeterminationReject); break; case T_H245ResponseMessage_terminalCapabilitySetAck: /* Disable TCS timer */ for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_TCS_TIMER) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted TCS Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooOnReceivedTerminalCapabilitySetAck(call); break; case T_H245ResponseMessage_terminalCapabilitySetReject: OOTRACEINFO3("TerminalCapabilitySetReject message received." " (%s, %s)\n", call->callType, call->callToken); if(response->u.terminalCapabilitySetReject->sequenceNumber != call->localTermCapSeqNo) { OOTRACEINFO5("Ignoring TCSReject with mismatched seqno %d " "(local - %d). (%s, %s)\n", response->u.terminalCapabilitySetReject->sequenceNumber, call->localTermCapSeqNo, call->callType, call->callToken); break; } /* Disable TCS timer */ for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_TCS_TIMER) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted TCS Timer. (%s, %s)\n", call->callType, call->callToken); break; } } if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_NOCOMMON_CAPABILITIES; } break; case T_H245ResponseMessage_requestModeAck: if (call->requestSequence == response->u.requestModeAck->sequenceNumber) { /* response to our last request, process it */ ooOnReceivedRequestModeAck(call, response->u.requestModeAck); } break; case T_H245ResponseMessage_requestModeReject: OOTRACEDBGC3("Received requestModeReject, clearing call (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_REMOTE_REJECTED; } break; case T_H245ResponseMessage_openLogicalChannelAck: for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if((((ooTimerCallback*)pTimer->cbData)->timerType & OO_OLC_TIMER) && ((ooTimerCallback*)pTimer->cbData)->channelNumber == response->u.openLogicalChannelAck->forwardLogicalChannelNumber) { memFreePtr(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted OpenLogicalChannel Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooOnReceivedOpenLogicalChannelAck(call, response->u.openLogicalChannelAck); break; case T_H245ResponseMessage_openLogicalChannelReject: OOTRACEINFO3("Open Logical Channel Reject received (%s, %s)\n", call->callType, call->callToken); for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if((((ooTimerCallback*)pTimer->cbData)->timerType & OO_OLC_TIMER) && ((ooTimerCallback*)pTimer->cbData)->channelNumber == response->u.openLogicalChannelAck->forwardLogicalChannelNumber) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted OpenLogicalChannel Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooOnReceivedOpenLogicalChannelRejected(call, response->u.openLogicalChannelReject); break; case T_H245ResponseMessage_closeLogicalChannelAck: OOTRACEINFO4("CloseLogicalChannelAck received for %d (%s, %s)\n", response->u.closeLogicalChannelAck->forwardLogicalChannelNumber, call->callType, call->callToken); for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if((((ooTimerCallback*)pTimer->cbData)->timerType & OO_CLC_TIMER) && ((ooTimerCallback*)pTimer->cbData)->channelNumber == response->u.closeLogicalChannelAck->forwardLogicalChannelNumber) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted CloseLogicalChannel Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooOnReceivedCloseChannelAck(call, response->u.closeLogicalChannelAck); if (call->TCSPending && !ooGetReceiveLogicalChannel(call)) { call->TCSPending = FALSE; call->localTermCapState = OO_LocalTermCapExchange_Idle; ooSendTermCapMsg(call); } else if (!ooGetTransmitLogicalChannel(call)) { ooOpenLogicalChannels(call); } break; case T_H245ResponseMessage_requestChannelCloseAck: OOTRACEINFO4("RequestChannelCloseAck received - %d (%s, %s)\n", response->u.requestChannelCloseAck->forwardLogicalChannelNumber, call->callType, call->callToken); for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if((((ooTimerCallback*)pTimer->cbData)->timerType & OO_RCC_TIMER) && ((ooTimerCallback*)pTimer->cbData)->channelNumber == response->u.requestChannelCloseAck->forwardLogicalChannelNumber) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted RequestChannelClose Timer. (%s, %s)\n", call->callType, call->callToken); break; } } /* Do nothing by receive reqChanCloseAck */ break; case T_H245ResponseMessage_requestChannelCloseReject: OOTRACEINFO4("RequestChannelCloseReject received - %d (%s, %s)\n", response->u.requestChannelCloseReject->forwardLogicalChannelNumber, call->callType, call->callToken); for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if((((ooTimerCallback*)pTimer->cbData)->timerType & OO_RCC_TIMER) && ((ooTimerCallback*)pTimer->cbData)->channelNumber == response->u.requestChannelCloseReject->forwardLogicalChannelNumber) { ASN1MEMFREEPTR(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted RequestChannelClose Timer. (%s, %s)\n", call->callType, call->callToken); break; } } ooOnReceivedRequestChannelCloseReject(call, response->u.requestChannelCloseReject); break; case T_H245ResponseMessage_roundTripDelayResponse: OOTRACEINFO4("Received roundTripDelayResponse - %d (%s, %s)\n", response->u.roundTripDelayResponse->sequenceNumber, call->callType, call->callToken); call->rtdrRecv = response->u.roundTripDelayResponse->sequenceNumber; break; default: ; } break; /* H.245 command message is received */ case (T_H245MultimediaSystemControlMessage_command): command = pH245->h245Msg.u.command; ooHandleH245Command(call, command); break; /* H.245 Indication message received */ case (T_H245MultimediaSystemControlMessage_indication): indication = pH245->h245Msg.u.indication; switch(indication->t) { case T_H245IndicationMessage_userInput: ooOnReceivedUserInputIndication(call, indication->u.userInput); break; default: OOTRACEWARN3("Unhandled indication message received.(%s, %s)\n", call->callType, call->callToken); } break; default: ; } OOTRACEDBGC3("Finished handling H245 message. (%s, %s)\n", call->callType, call->callToken); return OO_OK; } int ooOnReceivedUserInputIndication (OOH323CallData *call, H245UserInputIndication *indication) { if((indication->t == T_H245UserInputIndication_alphanumeric) && (call->dtmfmode & OO_CAP_DTMF_H245_alphanumeric)) { if(gH323ep.h323Callbacks.onReceivedDTMF) gH323ep.h323Callbacks.onReceivedDTMF(call,indication->u.alphanumeric); } else if((indication->t == T_H245UserInputIndication_signal) && (call->dtmfmode & OO_CAP_DTMF_H245_signal)) { if(call->lastDTMF && indication->u.signal->signalType[0] == call->lastDTMF && call->nextDTMFstamp && indication->u.signal->m.rtpPresent && indication->u.signal->rtp.m.timestampPresent) { if(call->nextDTMFstamp > indication->u.signal->rtp.timestamp) { OOTRACEERR4("ERROR:Duplicate dtmf %c on ((%s, %s)\n", call->lastDTMF, call->callType, call->callToken); return OO_OK; } } if (indication->u.signal->m.rtpPresent && indication->u.signal->rtp.m.timestampPresent && indication->u.signal->m.durationPresent) { call->nextDTMFstamp = indication->u.signal->rtp.timestamp + indication->u.signal->duration; call->lastDTMF = indication->u.signal->signalType[0]; } else { call->nextDTMFstamp = 0; call->lastDTMF = 0; } if(gH323ep.h323Callbacks.onReceivedDTMF) gH323ep.h323Callbacks.onReceivedDTMF(call, indication->u.signal->signalType); } else { OOTRACEINFO3("Unsupported userInput message type received - ignoring." "(%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooOnReceivedTerminalCapabilitySet(OOH323CallData *call, H245Message *pmsg) { int ret = 0,k; H245TerminalCapabilitySet *tcs=NULL; DListNode *pNode=NULL; H245CapabilityTableEntry *capEntry = NULL; ooLogicalChannel *temp = NULL; tcs = pmsg->h245Msg.u.request->u.terminalCapabilitySet; if(call->remoteTermCapSeqNo > tcs->sequenceNumber) { OOTRACEINFO4("Rejecting TermCapSet message with SeqNo %d, as already " "acknowledged message with this SeqNo (%s, %s)\n", call->remoteTermCapSeqNo, call->callType, call->callToken); ooSendTerminalCapabilitySetReject(call, tcs->sequenceNumber, T_H245TerminalCapabilitySetReject_cause_unspecified); return OO_OK; } else { /* 20090924 */ /* bogus soft-switch can send more than one request with cap set if it goto to next choice. Right swith don't send but not all are right ;( we can accept new capability set only. We must remember also that new join caps will be previously joined caps with new cap set. */ /* 20111103 */ /* for addition for previous we must check repeated tcs if it's not first tcs i.e. SeqNo is not null */ if(call->remoteTermCapSeqNo && call->remoteTermCapSeqNo == tcs->sequenceNumber) call->localTermCapState = OO_LocalTermCapExchange_Idle; } /* empty tcs - renegotiate logical channels */ if(!tcs->m.capabilityTablePresent) { OOTRACEDBGC3("Empty TCS found. (%s, %s)\n", call->callType, call->callToken); call->remoteTermCapSeqNo = tcs->sequenceNumber; ooH245AcknowledgeTerminalCapabilitySet(call); /* close all transmit chans */ temp = call->logicalChans; while (temp) { if (temp->state == OO_LOGICALCHAN_ESTABLISHED) { /* Sending closelogicalchannel only for outgoing channels */ if (!strcmp(temp->dir, "transmit")) { ooSendCloseLogicalChannel(call, temp); } } temp = temp->next; } call->TCSPending = TRUE; return OO_OK; } call->remoteTermCapSeqNo = tcs->sequenceNumber; if(tcs->m.capabilityTablePresent) { for(k=0; k<(int)tcs->capabilityTable.count; k++) { pNode = dListFindByIndex(&tcs->capabilityTable, k); if(pNode) { OOTRACEDBGC4("Processing CapabilityTable Entry %d (%s, %s)\n", k, call->callType, call->callToken); capEntry = (H245CapabilityTableEntry*) pNode->data; if(capEntry->m.capabilityPresent){ ret = ooAddRemoteCapability(call, &capEntry->capability); if(ret != OO_OK) { OOTRACEERR4("Error:Failed to process remote capability in " "capability table at index %d. (%s, %s)\n", k, call->callType, call->callToken); } ooCapabilityUpdateJointCapabilities(call, &capEntry->capability); } } pNode = NULL; capEntry=NULL; } } if (call->t38sides == 3) /* both side support t.38 */ OO_SETFLAG(call->flags, OO_M_T38SUPPORTED); else OO_CLRFLAG(call->flags, OO_M_T38SUPPORTED); /* Update remoteTermCapSetState */ call->remoteTermCapState = OO_RemoteTermCapSetRecvd; ooH245AcknowledgeTerminalCapabilitySet(call); /* If we haven't yet send TCS then send it now */ if(call->localTermCapState == OO_LocalTermCapExchange_Idle) { ret = ooSendTermCapMsg(call); if(ret != OO_OK) { OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n", call->callType, call->callToken); return ret; } } if(call->remoteTermCapState != OO_RemoteTermCapSetAckSent || call->localTermCapState != OO_LocalTermCapSetAckRecvd) return OO_OK; if(call->masterSlaveState == OO_MasterSlave_Idle) { ret = ooSendMasterSlaveDetermination(call); if(ret != OO_OK) { OOTRACEERR3("ERROR:Sending Master-slave determination message " "(%s, %s)\n", call->callType, call->callToken); return ret; } } /* Check MasterSlave procedure has finished */ if(call->masterSlaveState != OO_MasterSlave_Master && call->masterSlaveState != OO_MasterSlave_Slave) return OO_OK; /* As both MasterSlave and TerminalCapabilitySet procedures have finished, OpenLogicalChannels */ if(gH323ep.h323Callbacks.openLogicalChannels) gH323ep.h323Callbacks.openLogicalChannels(call); /* ooSendStatusInquiry(call); */ if(!ooGetTransmitLogicalChannel(call)) ooOpenLogicalChannels(call); #if 0 if(!call->logicalChans){ if(!gH323ep.h323Callbacks.openLogicalChannels) ret = ooOpenLogicalChannels(call); else gH323ep.h323Callbacks.openLogicalChannels(call); } #endif return OO_OK; } int ooSendTerminalCapabilitySetReject (OOH323CallData *call, int seqNo, ASN1UINT cause) { H245Message *ph245msg=NULL; H245ResponseMessage * response=NULL; OOCTXT *pctxt=NULL; int ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR1("ERROR:H245 message creation failed for - " "TerminalCapabilitySetReject\n"); return OO_FAILED; } ph245msg->msgType = OOTerminalCapabilitySetReject; response = ph245msg->h245Msg.u.response; memset(response, 0, sizeof(H245ResponseMessage)); /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; response->t = T_H245ResponseMessage_terminalCapabilitySetReject; response->u.terminalCapabilitySetReject = (H245TerminalCapabilitySetReject*) ASN1MALLOC(pctxt, sizeof(H245TerminalCapabilitySetReject)); memset(response->u.terminalCapabilitySetReject, 0, sizeof(H245TerminalCapabilitySetReject)); response->u.terminalCapabilitySetReject->sequenceNumber = seqNo; response->u.terminalCapabilitySetReject->cause.t = cause; OOTRACEDBGA3("Built TerminalCapabilitySetReject (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue TCSReject to outbound queue. " "(%s, %s)\n", call->callType, call->callToken); } else call->remoteTermCapState = OO_RemoteTermCapExchange_Idle; ooFreeH245Message(call, ph245msg); return ret; } int ooH245AcknowledgeTerminalCapabilitySet(OOH323CallData *call) { H245Message *ph245msg=NULL; H245ResponseMessage * response=NULL; OOCTXT *pctxt=NULL; int ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_response); if(ret != OO_OK) { OOTRACEERR1("ERROR:H245 message creation failed for - " "TerminalCapability Set Ack\n"); return OO_FAILED; } ph245msg->msgType = OOTerminalCapabilitySetAck; response = ph245msg->h245Msg.u.response; memset(response, 0, sizeof(H245ResponseMessage)); /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; response->t = T_H245ResponseMessage_terminalCapabilitySetAck; response->u.terminalCapabilitySetAck = (H245TerminalCapabilitySetAck*) ASN1MALLOC(pctxt, sizeof(H245TerminalCapabilitySetAck)); memset(response->u.terminalCapabilitySetAck, 0, sizeof(H245TerminalCapabilitySetAck)); response->u.terminalCapabilitySetAck->sequenceNumber = call->remoteTermCapSeqNo; OOTRACEDBGA3("Built TerminalCapabilitySet Ack (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue TCSAck to outbound queue. (%s, %s)\n", call->callType, call->callToken); } else call->remoteTermCapState = OO_RemoteTermCapSetAckSent; ooFreeH245Message(call, ph245msg); return ret; } int ooSendTerminalCapabilitySetRelease(OOH323CallData * call) { int ret=0; H245IndicationMessage* indication=NULL; H245Message *ph245msg=NULL; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message (call, &ph245msg, T_H245MultimediaSystemControlMessage_indication); if (ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - Terminal" "CapabilitySetRelease (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOTerminalCapabilitySetRelease; indication = ph245msg->h245Msg.u.indication; indication->t = T_H245IndicationMessage_terminalCapabilitySetRelease; indication->u.terminalCapabilitySetRelease = (H245TerminalCapabilitySetRelease*) memAlloc (pctxt, sizeof(H245TerminalCapabilitySetRelease)); if(!indication->u.terminalCapabilitySetRelease) { OOTRACEERR3("Error: Failed to allocate memory for TCSRelease message." " (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } OOTRACEDBGA3 ("Built TerminalCapabilitySetRelease (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg (call, ph245msg); if (ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue TerminalCapabilitySetRelease " "message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message (call, ph245msg); return ret; } int ooSendH245UserInputIndication_alphanumeric (OOH323CallData *call, const char *data) { int ret=0; H245IndicationMessage* indication=NULL; H245Message *ph245msg=NULL; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message (call, &ph245msg, T_H245MultimediaSystemControlMessage_indication); if (ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - H245UserInput" "Indication_alphanumeric (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOUserInputIndication; indication = ph245msg->h245Msg.u.indication; indication->t = T_H245IndicationMessage_userInput; indication->u.userInput = (H245UserInputIndication*) memAllocZ (pctxt, sizeof(H245UserInputIndication)); if(!indication->u.userInput) { OOTRACEERR3("Error: Memory - ooH245UserInputIndication_alphanumeric - " " userInput (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } indication->u.userInput->t = T_H245UserInputIndication_alphanumeric; indication->u.userInput->u.alphanumeric = (ASN1GeneralString) memAlloc(pctxt, strlen(data)+1); if(!indication->u.userInput->u.alphanumeric) { OOTRACEERR3("Error: Memory - ooH245UserInputIndication-alphanumeric - " "alphanumeric (%s, %s).\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } strcpy(*(char**)&indication->u.userInput->u.alphanumeric, data); OOTRACEDBGA3 ("Built UserInputIndication_alphanumeric (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg (call, ph245msg); if (ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue UserInputIndication_alphanumeric " "message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message (call, ph245msg); return ret; } int ooSendH245UserInputIndication_signal (OOH323CallData *call, const char *data) { int ret=0; H245IndicationMessage* indication=NULL; H245Message *ph245msg=NULL; /* OOCTXT *pctxt=&gH323ep.msgctxt; */ OOCTXT *pctxt=call->msgctxt; ret = ooCreateH245Message (call, &ph245msg, T_H245MultimediaSystemControlMessage_indication); if (ret != OO_OK) { OOTRACEERR3("Error:H245 message creation failed for - H245UserInput" "Indication_signal (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOUserInputIndication; indication = ph245msg->h245Msg.u.indication; indication->t = T_H245IndicationMessage_userInput; indication->u.userInput = (H245UserInputIndication*) memAllocZ (pctxt, sizeof(H245UserInputIndication)); if(!indication->u.userInput) { OOTRACEERR3("Error: Memory - ooH245UserInputIndication_signal - " " userInput (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } indication->u.userInput->t = T_H245UserInputIndication_signal; indication->u.userInput->u.signal = (H245UserInputIndication_signal*) memAllocZ(pctxt, sizeof(H245UserInputIndication_signal)); indication->u.userInput->u.signal->signalType = (ASN1IA5String) memAlloc(pctxt, strlen(data)+1); if(!indication->u.userInput->u.signal || !indication->u.userInput->u.signal->signalType) { OOTRACEERR3("Error: Memory - ooH245UserInputIndication_signal - " "signal (%s, %s).\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } strcpy(*(char**)&indication->u.userInput->u.signal->signalType, data); OOTRACEDBGA3 ("Built UserInputIndication_signal (%s, %s)\n", call->callType, call->callToken); ret = ooSendH245Msg (call, ph245msg); if (ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue UserInputIndication_signal " "message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message (call, ph245msg); return ret; } int ooOpenLogicalChannels(OOH323CallData *call) { int ret=0; OOTRACEINFO3("Opening logical channels (%s, %s)\n", call->callType, call->callToken); /* Audio channels */ if(gH323ep.callMode == OO_CALLMODE_AUDIOCALL || gH323ep.callMode == OO_CALLMODE_AUDIOTX) { if (OO_TESTFLAG (call->flags, OO_M_AUDIOSESSION)) { ret = ooOpenLogicalChannel(call, OO_CAP_TYPE_AUDIO); } else if (OO_TESTFLAG (call->flags, OO_M_DATASESSION)) { ret = ooOpenLogicalChannel(call, OO_CAP_TYPE_DATA); } if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to open audio/data channels. Clearing call." "(%s, %s)\n", call->callType, call->callToken); if (call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return ret; } } if(gH323ep.callMode == OO_CALLMODE_VIDEOCALL) { /* if (!OO_TESTFLAG (call->flags, OO_M_AUDIOSESSION)) {*/ ret = ooOpenLogicalChannel(call, OO_CAP_TYPE_AUDIO); if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to open audio channel. Clearing call." "(%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return ret; } //} /* if(!OO_TESTFLAG(call->flags, OO_M_VIDEOSESSION)) {*/ ret = ooOpenLogicalChannel(call, OO_CAP_TYPE_VIDEO); if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to open video channel. Clearing call." "(%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return ret; } //} } return OO_OK; } /* CapType indicates whether to Open Audio or Video channel */ int ooOpenLogicalChannel(OOH323CallData *call, enum OOCapType capType ) { ooH323EpCapability *epCap=NULL; int k=0; /* Check whether local endpoint has audio capability */ if(gH323ep.myCaps == 0 && call->ourCaps == 0) { OOTRACEERR3("ERROR:Local endpoint does not have any audio capabilities" " (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } /* Go through local endpoints capabilities sequentially, and find out the first one which has a match in the remote endpoints receive capabilities. */ OOTRACEINFO3("Looking for matching capabilities. (%s, %s)\n", call->callType, call->callToken); /* May */ if(call->masterSlaveState == OO_MasterSlave_Master) { for(k=0; kcapPrefs.index; k++) { /*Search for audio caps only */ if(capType == OO_CAP_TYPE_AUDIO && call->capPrefs.order[k] > OO_CAP_VIDEO_BASE) continue; /* Search for video caps only */ if(capType == OO_CAP_TYPE_VIDEO && call->capPrefs.order[k] <= OO_CAP_VIDEO_BASE) continue; epCap = call->jointCaps; while(epCap){ if(epCap->cap == call->capPrefs.order[k] && (epCap->dir & OOTX)) break; epCap = epCap->next; } if(!epCap) { OOTRACEDBGA4("Prefereed capability %d is not a local transmit " "capability(%s, %s)\n", call->capPrefs.order[k], call->callType, call->callToken); continue; } break; } if(!epCap) { OOTRACEERR4("ERROR:Incompatible capabilities - Can not open " "%s channel (%s, %s)\n", (capType==OO_CAP_TYPE_AUDIO)?"audio":"video", call->callType, call->callToken); return OO_FAILED; } } else { epCap = call->jointCaps; while(epCap){ if(epCap->capType == capType && epCap->dir & OOTX) { break; } epCap = epCap->next; } if(!epCap) { OOTRACEERR4("ERROR:Incompatible audio capabilities - Can not open " "%s channel (%s, %s)\n", (capType==OO_CAP_TYPE_AUDIO)?"audio":"video", call->callType, call->callToken); return OO_FAILED; } } switch(epCap->cap) { case OO_G711ALAW64K: case OO_G711ALAW56K: case OO_G711ULAW64K: case OO_G711ULAW56K: case OO_G726: case OO_G726AAL2: case OO_AMRNB: case OO_SPEEX: case OO_G728: case OO_G729: case OO_G729A: case OO_G729B: case OO_G7231: case OO_GSMFULLRATE: case OO_GSMHALFRATE: case OO_GSMENHANCEDFULLRATE: case OO_H263VIDEO: case OO_T38: ooOpenChannel(call, epCap); break; default: OOTRACEERR3("ERROR:Unknown Audio Capability type (%s, %s)\n", call->callType, call->callToken); } return OO_OK; } int ooOpenChannel(OOH323CallData* call, ooH323EpCapability *epCap) { int ret; H245Message *ph245msg = NULL; H245RequestMessage * request; OOCTXT *pctxt = NULL; H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp = NULL; H245AudioCapability *audioCap = NULL; H245VideoCapability *videoCap = NULL; H245DataApplicationCapability *t38Cap = NULL; H245H2250LogicalChannelParameters *h2250lcp = NULL; H245UnicastAddress *unicastAddrs = NULL; H245UnicastAddress_iPAddress *iPAddress = NULL; H245UnicastAddress_iP6Address *iP6Address = NULL; unsigned session_id=0; ooLogicalChannel *pLogicalChannel = NULL; OOTRACEDBGC4("Doing Open Channel for %s. (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); ret = ooCreateH245Message(call, &ph245msg, T_H245MultimediaSystemControlMessage_request); if(ret != OO_OK) { OOTRACEERR4("Error: H245 message creation failed for - Open %s" "channel (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); return OO_FAILED; } ph245msg->msgType = OOOpenLogicalChannel; ph245msg->logicalChannelNo = call->logicalChanNoCur++; if(call->logicalChanNoCur > call->logicalChanNoMax) call->logicalChanNoCur = call->logicalChanNoBase; request = ph245msg->h245Msg.u.request; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; memset(request, 0, sizeof(H245RequestMessage)); request->t = T_H245RequestMessage_openLogicalChannel; request->u.openLogicalChannel = (H245OpenLogicalChannel*) memAlloc(pctxt, sizeof(H245OpenLogicalChannel)); if(!request->u.openLogicalChannel) { OOTRACEERR3("Error:Memory - ooOpenChannel - openLogicalChannel." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(request->u.openLogicalChannel, 0, sizeof(H245OpenLogicalChannel)); request->u.openLogicalChannel->forwardLogicalChannelNumber = ph245msg->logicalChannelNo; session_id = ooCallGenerateSessionID(call, epCap->capType, "transmit"); pLogicalChannel = ooAddNewLogicalChannel(call, request->u.openLogicalChannel->forwardLogicalChannelNumber, session_id, "transmit", epCap); if(!pLogicalChannel) { OOTRACEERR3("ERROR:Failed to add new logical channel entry (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } /* Populate H245OpenLogicalChannel_ForwardLogicalChannel Parameters*/ flcp = &(request->u.openLogicalChannel->forwardLogicalChannelParameters); flcp->m.portNumberPresent = 0; flcp->m.forwardLogicalChannelDependencyPresent = 0; flcp->m.replacementForPresent = 0; /* data type of channel */ if(epCap->capType == OO_CAP_TYPE_AUDIO) { flcp->dataType.t = T_H245DataType_audioData; /* set audio capability for channel */ audioCap = ooCapabilityCreateAudioCapability(epCap,pctxt, OOTX); if(!audioCap) { OOTRACEERR4("Error:Failed to create duplicate audio capability in " "ooOpenChannel- %s (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } flcp->dataType.u.audioData = audioCap; } else if(epCap->capType == OO_CAP_TYPE_VIDEO) { flcp->dataType.t = T_H245DataType_videoData; videoCap = ooCapabilityCreateVideoCapability(epCap, pctxt, OOTX); if(!videoCap) { OOTRACEERR4("Error:Failed to create duplicate video capability in " "ooOpenChannel- %s (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } flcp->dataType.u.videoData = videoCap; } else if(epCap->capType == OO_CAP_TYPE_DATA) { flcp->dataType.t = T_H245DataType_data; /* set audio capability for channel */ t38Cap = ooCapabilityCreateT38Capability(epCap,pctxt, OOTX); if(!t38Cap) { OOTRACEERR4("Error:Failed to create duplicate T38 capability in " "ooOpenChannel- %s (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); ooFreeH245Message(call, ph245msg); return OO_FAILED; } flcp->dataType.u.data = t38Cap; } else{ OOTRACEERR1("Error: Unhandled media type in ooOpenChannel\n"); return OO_FAILED; } flcp->multiplexParameters.t = T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters; flcp->multiplexParameters.u.h2250LogicalChannelParameters = (H245H2250LogicalChannelParameters*)ASN1MALLOC(pctxt, sizeof(H245H2250LogicalChannelParameters)); h2250lcp = flcp->multiplexParameters.u.h2250LogicalChannelParameters; memset(h2250lcp, 0, sizeof(H245H2250LogicalChannelParameters)); h2250lcp->sessionID = session_id; h2250lcp->mediaGuaranteedDelivery = 0; h2250lcp->silenceSuppression = 0; h2250lcp->m.mediaControlChannelPresent = 1; h2250lcp->mediaControlChannel.t = T_H245TransportAddress_unicastAddress; h2250lcp->mediaControlChannel.u.unicastAddress = (H245UnicastAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress)); unicastAddrs = h2250lcp->mediaControlChannel.u.unicastAddress; memset(unicastAddrs, 0, sizeof(H245UnicastAddress)); if (call->versionIP == 6) { unicastAddrs->t = T_H245UnicastAddress_iP6Address; unicastAddrs->u.iP6Address = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iP6Address)); iP6Address = unicastAddrs->u.iP6Address; memset(iP6Address, 0, sizeof(H245UnicastAddress_iP6Address)); inet_pton(AF_INET6, pLogicalChannel->localIP, iP6Address->network.data); iP6Address->network.numocts = 16; iP6Address->tsapIdentifier = pLogicalChannel->localRtcpPort; } else { unicastAddrs->t = T_H245UnicastAddress_iPAddress; unicastAddrs->u.iPAddress = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iPAddress)); iPAddress = unicastAddrs->u.iPAddress; memset(iPAddress, 0, sizeof(H245UnicastAddress_iPAddress)); inet_pton(AF_INET, pLogicalChannel->localIP, iPAddress->network.data); iPAddress->network.numocts = 4; iPAddress->tsapIdentifier = pLogicalChannel->localRtcpPort; } pLogicalChannel->state = OO_LOGICALCHAN_PROPOSED; OOTRACEDBGA4("Built OpenLogicalChannel-%s (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); ret = ooSendH245Msg(call, ph245msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue OpenLogicalChannel to outbound " "queue. (%s, %s)\n", call->callType, call->callToken); } ooFreeH245Message(call, ph245msg); return ret; } /* Used to build OLCs for fast connect. Keep in mind that forward and reverse are always with respect to the endpoint which proposes channels TODO: Need to clean logical channel in case of failure. */ int ooBuildFastStartOLC (OOH323CallData *call, H245OpenLogicalChannel *olc, ooH323EpCapability *epCap, OOCTXT*pctxt, int dir) { OOBOOL reverse=FALSE, forward=FALSE; unsigned sessionID=0; H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp=NULL; H245OpenLogicalChannel_reverseLogicalChannelParameters *rlcp=NULL; H245H2250LogicalChannelParameters *pH2250lcp1=NULL, *pH2250lcp2=NULL; H245UnicastAddress *pUnicastAddrs=NULL, *pUniAddrs=NULL; H245UnicastAddress_iPAddress *pIpAddrs=NULL, *pUniIpAddrs=NULL; H245UnicastAddress_iP6Address *pIp6Addrs=NULL, *pUniIp6Addrs=NULL; unsigned session_id = 0; ooLogicalChannel *pLogicalChannel = NULL; int outgoing=FALSE; if(!strcmp(call->callType, "outgoing")) outgoing = TRUE; if(dir & OORX) { OOTRACEDBGA3("Building OpenLogicalChannel for Receive Capability " "(%s, %s)\n", call->callType, call->callToken); session_id = ooCallGenerateSessionID(call, epCap->capType, "receive"); pLogicalChannel = ooAddNewLogicalChannel(call, olc->forwardLogicalChannelNumber, session_id, "receive", epCap); if(outgoing) reverse = TRUE; else forward = TRUE; } else if(dir & OOTX) { OOTRACEDBGA3("Building OpenLogicalChannel for transmit Capability " "(%s, %s)\n", call->callType, call->callToken); session_id = ooCallGenerateSessionID(call, epCap->capType, "transmit"); pLogicalChannel = ooAddNewLogicalChannel(call, olc->forwardLogicalChannelNumber, session_id, "transmit", epCap); if(outgoing) forward = TRUE; else reverse = TRUE; } else if(dir & OORXTX) { OOTRACEDBGA3("Building OpenLogicalChannel for ReceiveAndTransmit " "Capability (%s, %s)\n", call->callType, call->callToken); reverse = 1; forward = 1; OOTRACEERR3("Symmetric capability is not supported as of now (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if(forward) { OOTRACEDBGC3("Building forward olc. (%s, %s)\n", call->callType, call->callToken); flcp = &(olc->forwardLogicalChannelParameters); memset(flcp, 0, sizeof(H245OpenLogicalChannel_forwardLogicalChannelParameters)); if(epCap->capType == OO_CAP_TYPE_AUDIO) { sessionID =1; flcp->dataType.t = T_H245DataType_audioData; flcp->dataType.u.audioData = ooCapabilityCreateAudioCapability(epCap, pctxt, dir); } else if(epCap->capType == OO_CAP_TYPE_VIDEO) { sessionID = 2; flcp->dataType.t = T_H245DataType_videoData; flcp->dataType.u.videoData = ooCapabilityCreateVideoCapability(epCap, pctxt, dir); } flcp->multiplexParameters.t = T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters; pH2250lcp1 = (H245H2250LogicalChannelParameters*)ASN1MALLOC(pctxt, sizeof(H245H2250LogicalChannelParameters)); memset(pH2250lcp1, 0, sizeof(H245H2250LogicalChannelParameters)); flcp->multiplexParameters.t = T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters; flcp->multiplexParameters.u.h2250LogicalChannelParameters = pH2250lcp1; pH2250lcp1->sessionID = sessionID; if(!outgoing) { pH2250lcp1->m.mediaChannelPresent = 1; pH2250lcp1->mediaChannel.t = T_H245TransportAddress_unicastAddress; pUniAddrs = (H245UnicastAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress)); memset(pUniAddrs, 0, sizeof(H245UnicastAddress)); pH2250lcp1->mediaChannel.u.unicastAddress = pUniAddrs; if (call->versionIP == 6) { pUniAddrs->t = T_H245UnicastAddress_iP6Address; pUniIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iP6Address)); memset(pUniIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address)); pUniAddrs->u.iP6Address = pUniIp6Addrs; inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data); pUniIp6Addrs->network.numocts = 16; pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtpPort; } else { pUniAddrs->t = T_H245UnicastAddress_iPAddress; pUniIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iPAddress)); memset(pUniIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress)); pUniAddrs->u.iPAddress = pUniIpAddrs; inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data); pUniIpAddrs->network.numocts = 4; pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort; } } pH2250lcp1->m.mediaControlChannelPresent = 1; pH2250lcp1->mediaControlChannel.t = T_H245TransportAddress_unicastAddress; pUnicastAddrs = (H245UnicastAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress)); memset(pUnicastAddrs, 0, sizeof(H245UnicastAddress)); pH2250lcp1->mediaControlChannel.u.unicastAddress = pUnicastAddrs; if (call->versionIP == 6) { pUnicastAddrs->t = T_H245UnicastAddress_iP6Address; pIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iP6Address)); memset(pIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address)); pUnicastAddrs->u.iP6Address = pIp6Addrs; inet_pton(AF_INET6, pLogicalChannel->localIP, pIp6Addrs->network.data); pIp6Addrs->network.numocts = 16; pIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } else { pUnicastAddrs->t = T_H245UnicastAddress_iPAddress; pIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iPAddress)); memset(pIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress)); pUnicastAddrs->u.iPAddress = pIpAddrs; inet_pton(AF_INET, pLogicalChannel->localIP, pIpAddrs->network.data); pIpAddrs->network.numocts = 4; pIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } if(!outgoing) { if(epCap->startReceiveChannel) { epCap->startReceiveChannel(call, pLogicalChannel); OOTRACEINFO4("Receive channel of type %s started (%s, %s)\n", (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", call->callType, call->callToken); } else{ OOTRACEERR4("ERROR:No callback registered to start receive %s" " channel (%s, %s)\n", (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", call->callType, call->callToken); return OO_FAILED; } } } if(reverse) { OOTRACEDBGC3("Building reverse olc. (%s, %s)\n", call->callType, call->callToken); olc->forwardLogicalChannelParameters.dataType.t = T_H245DataType_nullData; olc->forwardLogicalChannelParameters.multiplexParameters.t = T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_none; olc->m.reverseLogicalChannelParametersPresent = 1; rlcp = &(olc->reverseLogicalChannelParameters); memset(rlcp, 0, sizeof(H245OpenLogicalChannel_reverseLogicalChannelParameters)); if(epCap->capType == OO_CAP_TYPE_AUDIO) { sessionID = 1; rlcp->dataType.t = T_H245DataType_audioData; rlcp->dataType.u.audioData = ooCapabilityCreateAudioCapability(epCap, pctxt, dir); } else if(epCap->capType == OO_CAP_TYPE_VIDEO) { sessionID = 2; rlcp->dataType.t = T_H245DataType_videoData; rlcp->dataType.u.videoData = ooCapabilityCreateVideoCapability(epCap, pctxt, dir); } rlcp->m.multiplexParametersPresent = 1; rlcp->multiplexParameters.t = T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters; pH2250lcp2 = (H245H2250LogicalChannelParameters*) ASN1MALLOC(pctxt, sizeof(H245H2250LogicalChannelParameters)); rlcp->multiplexParameters.u.h2250LogicalChannelParameters = pH2250lcp2; memset(pH2250lcp2, 0, sizeof(H245H2250LogicalChannelParameters)); pH2250lcp2->sessionID = sessionID; if(outgoing) { pH2250lcp2->m.mediaChannelPresent = 1; pH2250lcp2->mediaChannel.t = T_H245TransportAddress_unicastAddress; pUnicastAddrs = (H245UnicastAddress*) memAlloc(pctxt, sizeof(H245UnicastAddress)); memset(pUnicastAddrs, 0, sizeof(H245UnicastAddress)); pH2250lcp2->mediaChannel.u.unicastAddress = pUnicastAddrs; /* May 20101022 */ if (call->versionIP == 6) { pUnicastAddrs->t = T_H245UnicastAddress_iP6Address; pIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iP6Address)); memset(pIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address)); pUnicastAddrs->u.iP6Address = pIp6Addrs; inet_pton(AF_INET6, pLogicalChannel->localIP, pIp6Addrs->network.data); pIp6Addrs->network.numocts = 16; pIp6Addrs->tsapIdentifier = pLogicalChannel->localRtpPort; } else { pUnicastAddrs->t = T_H245UnicastAddress_iPAddress; pIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iPAddress)); memset(pIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress)); pUnicastAddrs->u.iPAddress = pIpAddrs; inet_pton(AF_INET, pLogicalChannel->localIP, pIpAddrs->network.data); pIpAddrs->network.numocts = 4; pIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort; } } pH2250lcp2->m.mediaControlChannelPresent = 1; pH2250lcp2->mediaControlChannel.t = T_H245TransportAddress_unicastAddress; pUniAddrs = (H245UnicastAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress)); memset(pUniAddrs, 0, sizeof(H245UnicastAddress)); pH2250lcp2->mediaControlChannel.u.unicastAddress = pUniAddrs; /* May 20101023 */ if (call->versionIP == 6) { pUniAddrs->t = T_H245UnicastAddress_iP6Address; pUniIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iP6Address)); memset(pUniIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address)); pUniAddrs->u.iP6Address = pUniIp6Addrs; inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data); pUniIp6Addrs->network.numocts = 16; pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } else { pUniAddrs->t = T_H245UnicastAddress_iPAddress; pUniIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iPAddress)); memset(pUniIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress)); pUniAddrs->u.iPAddress = pUniIpAddrs; inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data); pUniIpAddrs->network.numocts = 4; pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } /* In case of fast start, the local endpoint need to be ready to receive all the media types proposed in the fast connect, before the actual call is established. */ if(outgoing) { if(epCap->startReceiveChannel) { epCap->startReceiveChannel(call, pLogicalChannel); OOTRACEINFO4("Receive channel of type %s started (%s, %s)\n", (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", call->callType, call->callToken); } else{ OOTRACEERR4("ERROR:No callback registered to start receive %s " "channel (%s, %s)\n", (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", call->callType, call->callToken); return OO_FAILED; } } } /* State of logical channel. for out going calls, as we are sending setup, state of all channels are proposed, for incoming calls, state is established. */ if(!outgoing) { pLogicalChannel->state = OO_LOGICALCHAN_ESTABLISHED; } else { /* Calling other ep, with SETUP message */ /* Call is "outgoing */ pLogicalChannel->state = OO_LOGICALCHAN_PROPOSEDFS; } return OO_OK; } int ooMSDTimerExpired(void *data) { ooTimerCallback *cbData = (ooTimerCallback*)data; OOH323CallData *call = cbData->call; OOTRACEINFO3("MasterSlaveDetermination timeout. (%s, %s)\n", call->callType, call->callToken); ASN1MEMFREEPTR(call->pctxt, cbData); ooSendMasterSlaveDeterminationRelease(call); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_LOCAL_CLEARED; } return OO_OK; } int ooTCSTimerExpired(void *data) { ooTimerCallback *cbData = (ooTimerCallback*)data; OOH323CallData *call = cbData->call; OOTRACEINFO3("TerminalCapabilityExchange timeout. (%s, %s)\n", call->callType, call->callToken); ASN1MEMFREEPTR(call->pctxt, cbData); ooSendTerminalCapabilitySetRelease(call); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_LOCAL_CLEARED; } return OO_OK; } int ooRTDTimerExpired(void *data) { ooTimerCallback *cbData = (ooTimerCallback*)data; OOH323CallData *call = cbData->call; OOTRACEINFO3("Time to send new RTD request. (%s, %s)\n", call->callType, call->callToken); ASN1MEMFREEPTR(call->pctxt, cbData); ooSendRoundTripDelayRequest(call); return OO_OK; } int ooOpenLogicalChannelTimerExpired(void *pdata) { ooTimerCallback *cbData = (ooTimerCallback*)pdata; OOH323CallData *call = cbData->call; ooLogicalChannel *pChannel = NULL; OOTRACEINFO3("OpenLogicalChannelTimer expired. (%s, %s)\n", call->callType, call->callToken); pChannel = ooFindLogicalChannelByLogicalChannelNo(call, cbData->channelNumber); if(pChannel) ooSendCloseLogicalChannel(call, pChannel); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_LOCAL_CLEARED; } ASN1MEMFREEPTR(call->pctxt, cbData); return OO_OK; } int ooCloseLogicalChannelTimerExpired(void *pdata) { ooTimerCallback *cbData = (ooTimerCallback*)pdata; OOH323CallData *call = cbData->call; OOTRACEINFO3("CloseLogicalChannelTimer expired. (%s, %s)\n", call->callType, call->callToken); ooClearLogicalChannel(call, cbData->channelNumber); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_LOCAL_CLEARED; } ASN1MEMFREEPTR(call->pctxt, cbData); return OO_OK; } int ooRequestChannelCloseTimerExpired(void *pdata) { int ret = 0; ooLogicalChannel *pChannel = NULL; ooTimerCallback *cbData = (ooTimerCallback*)pdata; OOH323CallData *call = cbData->call; OOTRACEINFO3("CloseLogicalChannelTimer expired. (%s, %s)\n", call->callType, call->callToken); pChannel = ooFindLogicalChannelByLogicalChannelNo(call, cbData->channelNumber); if(pChannel) ooSendRequestChannelCloseRelease(call, cbData->channelNumber); else return OO_OK; ret = ooClearLogicalChannel(call, cbData->channelNumber); if(ret != OO_OK) { OOTRACEERR4("Error:Failed to clear logical channel %d. (%s, %s)\n", cbData->channelNumber, call->callType, call->callToken); } if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_LOCAL_CLEARED; } ASN1MEMFREEPTR(call->pctxt, cbData); return OO_OK; } int ooSessionTimerExpired(void *pdata) { int ret = 0; ooTimerCallback *cbData = (ooTimerCallback*)pdata; OOH323CallData *call = cbData->call; OOTRACEINFO3("SessionTimer expired. (%s, %s)\n", call->callType, call->callToken); if(call->h245SessionState != OO_H245SESSION_IDLE && call->h245SessionState != OO_H245SESSION_CLOSED && call->h245SessionState != OO_H245SESSION_PAUSED) { ret = ooCloseH245Connection(call); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to close H.245 connection (%s, %s)\n", call->callType, call->callToken); } } memFreePtr(call->pctxt, cbData); if(call->callState == OO_CALL_CLEAR_RELEASESENT) call->callState = OO_CALL_CLEARED; return OO_OK; } int ooGetIpPortFromH245TransportAddress (OOH323CallData *call, H245TransportAddress *h245Address, char *ip, int *port) { H245UnicastAddress *unicastAddress = NULL; H245UnicastAddress_iPAddress *ipAddress = NULL; H245UnicastAddress_iP6Address *ip6Address = NULL; regmatch_t pmatch[1]; if(h245Address->t != T_H245TransportAddress_unicastAddress) { OOTRACEERR3("ERROR:Unsupported H245 address type " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } unicastAddress = h245Address->u.unicastAddress; if (call->versionIP == 6) { if (unicastAddress->t != T_H245UnicastAddress_iP6Address) { OOTRACEERR3("ERROR:H245 Address type is not IP6" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ip6Address = unicastAddress->u.iP6Address; *port = ip6Address->tsapIdentifier; inet_ntop(AF_INET6, ip6Address->network.data, ip, INET6_ADDRSTRLEN); } else { if(unicastAddress->t != T_H245UnicastAddress_iPAddress) { OOTRACEERR3("ERROR:H245 Address type is not IP" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ipAddress = unicastAddress->u.iPAddress; *port = ipAddress->tsapIdentifier; inet_ntop(AF_INET, ipAddress->network.data, ip, INET_ADDRSTRLEN); } if (call->rtpMaskStr[0]) { if (regexec(&call->rtpMask->regex, ip, 1, pmatch, 0)) { OOTRACEERR5("ERROR:H245 Address is not matched with filter %s/%s" "(%s, %s)\n", ip, call->rtpMaskStr, call->callType, call->callToken); return OO_FAILED; } } return OO_OK; } int ooPrepareFastStartResponseOLC (OOH323CallData *call, H245OpenLogicalChannel *olc, ooH323EpCapability *epCap, OOCTXT*pctxt, int dir) { OOBOOL reverse=FALSE, forward=FALSE; H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp=NULL; H245OpenLogicalChannel_reverseLogicalChannelParameters *rlcp=NULL; H245H2250LogicalChannelParameters *pH2250lcp1=NULL, *pH2250lcp2=NULL; H245UnicastAddress *pUnicastAddrs=NULL, *pUniAddrs=NULL; H245UnicastAddress_iPAddress *pIpAddrs=NULL, *pUniIpAddrs=NULL; H245UnicastAddress_iP6Address *pIp6Addrs=NULL, *pUniIp6Addrs=NULL; unsigned session_id = 0; ooLogicalChannel *pLogicalChannel = NULL; if(dir & OORX) { OOTRACEDBGA3("ooPrepareFastStartResponseOLC for Receive Capability " "(%s, %s)\n", call->callType, call->callToken); session_id = ooCallGenerateSessionID(call, epCap->capType, "receive"); pLogicalChannel = ooAddNewLogicalChannel(call, olc->forwardLogicalChannelNumber, session_id, "receive", epCap); forward = TRUE; } else if(dir & OOTX) { OOTRACEDBGA3("ooPrepareFastStartResponseOLC for transmit Capability " "(%s, %s)\n", call->callType, call->callToken); session_id = ooCallGenerateSessionID(call, epCap->capType, "transmit"); pLogicalChannel = ooAddNewLogicalChannel(call, olc->forwardLogicalChannelNumber, session_id, "transmit", epCap); reverse = TRUE; } else if(dir & OORXTX) { OOTRACEDBGA3("ooPrepareFastStartResponseOLC for ReceiveAndTransmit " "Capability (%s, %s)\n", call->callType, call->callToken); reverse = 1; forward = 1; OOTRACEERR3("Symmetric capability is not supported as of now (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if(forward) { OOTRACEDBGC3("Preparing olc for receive channel. (%s, %s)\n", call->callType, call->callToken); flcp = &(olc->forwardLogicalChannelParameters); pH2250lcp1 = flcp->multiplexParameters.u.h2250LogicalChannelParameters; pH2250lcp1->m.mediaChannelPresent = 1; pH2250lcp1->mediaChannel.t = T_H245TransportAddress_unicastAddress; pUniAddrs = (H245UnicastAddress*) memAllocZ(pctxt, sizeof(H245UnicastAddress)); pH2250lcp1->mediaChannel.u.unicastAddress = pUniAddrs; if (call->versionIP == 6) { pUniIp6Addrs = (H245UnicastAddress_iP6Address*) memAllocZ(pctxt, sizeof(H245UnicastAddress_iP6Address)); if(!pUniAddrs || !pUniIpAddrs) { OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - pUniAddrs" "/pUniIpAddrs (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pUniAddrs->t = T_H245UnicastAddress_iP6Address; pUniAddrs->u.iP6Address = pUniIp6Addrs; inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data); pUniIp6Addrs->network.numocts = 16; pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtpPort; } else { pUniIpAddrs = (H245UnicastAddress_iPAddress*) memAllocZ(pctxt, sizeof(H245UnicastAddress_iPAddress)); if(!pUniAddrs || !pUniIpAddrs) { OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - pUniAddrs" "/pUniIpAddrs (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pUniAddrs->t = T_H245UnicastAddress_iPAddress; pUniAddrs->u.iPAddress = pUniIpAddrs; inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data); pUniIpAddrs->network.numocts = 4; pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort; } pH2250lcp1->m.mediaControlChannelPresent = 1; pH2250lcp1->mediaControlChannel.t = T_H245TransportAddress_unicastAddress; pUnicastAddrs = (H245UnicastAddress*) memAllocZ(pctxt, sizeof(H245UnicastAddress)); pH2250lcp1->mediaControlChannel.u.unicastAddress = pUnicastAddrs; if (call->versionIP == 6) { pIp6Addrs = (H245UnicastAddress_iP6Address*) memAllocZ(pctxt, sizeof(H245UnicastAddress_iP6Address)); if(!pUnicastAddrs || !pIp6Addrs) { OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - " "pUnicastAddrs/pIpAddrs (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pUnicastAddrs->t = T_H245UnicastAddress_iP6Address; pUnicastAddrs->u.iP6Address = pIp6Addrs; inet_pton(AF_INET6, pLogicalChannel->localIP, pIp6Addrs->network.data); pIp6Addrs->network.numocts = 16; pIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } else { pIpAddrs = (H245UnicastAddress_iPAddress*) memAllocZ(pctxt, sizeof(H245UnicastAddress_iPAddress)); if(!pUnicastAddrs || !pIpAddrs) { OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - " "pUnicastAddrs/pIpAddrs (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pUnicastAddrs->t = T_H245UnicastAddress_iPAddress; pUnicastAddrs->u.iPAddress = pIpAddrs; inet_pton(AF_INET, pLogicalChannel->localIP, pIpAddrs->network.data); pIpAddrs->network.numocts = 4; pIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } } if(reverse) { OOTRACEDBGC3("Building reverse olc. (%s, %s)\n", call->callType, call->callToken); rlcp = &(olc->reverseLogicalChannelParameters); pH2250lcp2 = rlcp->multiplexParameters.u.h2250LogicalChannelParameters; pH2250lcp2->m.mediaChannelPresent = 0; memset(&pH2250lcp2->mediaChannel, 0, sizeof(H245TransportAddress)); pH2250lcp2->m.mediaControlChannelPresent = 1; pH2250lcp2->mediaControlChannel.t = T_H245TransportAddress_unicastAddress; pUniAddrs = (H245UnicastAddress*) memAlloc(pctxt, sizeof(H245UnicastAddress)); pH2250lcp2->mediaControlChannel.u.unicastAddress = pUniAddrs; if (call->versionIP == 6) { pUniIp6Addrs = (H245UnicastAddress_iP6Address*) memAlloc(pctxt, sizeof(H245UnicastAddress_iP6Address)); if(!pUniAddrs || !pUniIp6Addrs) { OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - " "pUniAddrs/pUniIpAddrs (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pUniAddrs->t = T_H245UnicastAddress_iP6Address; pUniAddrs->u.iP6Address = pUniIp6Addrs; inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data); pUniIp6Addrs->network.numocts = 16; pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } else { pUniIpAddrs = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, sizeof(H245UnicastAddress_iPAddress)); if(!pUniAddrs || !pUniIpAddrs) { OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - " "pUniAddrs/pUniIpAddrs (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pH2250lcp2->mediaControlChannel.u.unicastAddress = pUniAddrs; pUniAddrs->t = T_H245UnicastAddress_iPAddress; pUniAddrs->u.iPAddress = pUniIpAddrs; inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data); pUniIpAddrs->network.numocts = 4; pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort; } } pLogicalChannel->state = OO_LOGICALCHAN_ESTABLISHED; return OO_OK; } asterisk-11.7.0/addons/ooh323c/src/ootrace.c0000644000175000007640000000677011352772022020377 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include #include #include #include #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, ...) __attribute__((format(printf, 2, 3))); 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[10]; 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, 10, "%d", ptime); fprintf(gH323ep.fptraceFile, "---------Date %s---------\n", dateString); } if(printTime) { struct timeval systemTime; gettimeofday(&systemTime, NULL); fprintf(gH323ep.fptraceFile, "%s:%03ld %s", timeString, (long) 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; } asterisk-11.7.0/addons/ooh323c/src/ootrace.h0000644000175000007640000001103511274375744020407 0ustar sharkyjerryweb/* * 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,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 OOTRACEERR5(a,b,c,d,e) ooTrace(OOTRCLVLERR,a,b,c,d,e) #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,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, ...); /** * 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 asterisk-11.7.0/addons/ooh323c/src/encode.c0000644000175000007640000007257311352772022020204 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include #include "ooasn1.h" static int encode16BitConstrainedString (OOCTXT* pctxt, Asn116BitCharString value, Asn116BitCharSet* pCharSet); static int encode2sCompBinInt (OOCTXT* pctxt, ASN1INT value); static int encodeNonNegBinInt (OOCTXT* pctxt, ASN1UINT value); static int encodeUnconsLength (OOCTXT* pctxt, ASN1UINT value); static int getIdentByteCount (ASN1UINT ident); int encodeBitsFromOctet (OOCTXT* pctxt, ASN1OCTET value, ASN1UINT nbits); int encodeGetMsgBitCnt (OOCTXT* pctxt); int encodeIdent (OOCTXT* pctxt, ASN1UINT ident); int encodeBit (OOCTXT* pctxt, ASN1BOOL value) { int stat = ASN_OK; /* If start of new byte, init to zero */ if (pctxt->buffer.bitOffset == 8) { pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; } /* Adjust bit offset and determine if at end of current byte */ if (--pctxt->buffer.bitOffset < 0) { if (++pctxt->buffer.byteIndex >= pctxt->buffer.size) { if ((stat = encodeExpandBuffer (pctxt, 1)) != ASN_OK) { return stat; } } pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; pctxt->buffer.bitOffset = 7; } /* Set single-bit value */ if (value) { pctxt->buffer.data[pctxt->buffer.byteIndex] |= ( 1 << pctxt->buffer.bitOffset ); } /* If last bit in octet, set offsets to start new byte (ED, 9/7/01) */ if (pctxt->buffer.bitOffset == 0) { pctxt->buffer.bitOffset = 8; pctxt->buffer.byteIndex++; pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; } return stat; } int encodeBits (OOCTXT* pctxt, ASN1UINT value, ASN1UINT nbits) { int nbytes = (nbits + 7)/ 8, stat = ASN_OK; if (nbits == 0) return stat; /* If start of new byte, init to zero */ if (pctxt->buffer.bitOffset == 8) { pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; } /* Mask off unused bits from the front of the value */ if (nbits < (sizeof(ASN1UINT) * 8)) value &= ((1 << nbits) - 1); /* If bits will fit in current byte, set them and return */ if (nbits < (unsigned)pctxt->buffer.bitOffset) { pctxt->buffer.bitOffset -= nbits; pctxt->buffer.data[pctxt->buffer.byteIndex] |= ( value << pctxt->buffer.bitOffset ); return stat; } /* Check buffer space and allocate more memory if necessary */ stat = encodeCheckBuffer (pctxt, nbytes); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Set bits in remainder of the current byte and then loop */ /* to set bits in subsequent bytes.. */ nbits -= pctxt->buffer.bitOffset; pctxt->buffer.data[pctxt->buffer.byteIndex++] |= (ASN1OCTET)( value >> nbits ); pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; while (nbits >= 8) { nbits -= 8; pctxt->buffer.data[pctxt->buffer.byteIndex++] = (ASN1OCTET)( value >> nbits ); pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; } /* copy final partial byte */ pctxt->buffer.bitOffset = 8 - nbits; if (nbits > 0) { pctxt->buffer.data[pctxt->buffer.byteIndex] = (ASN1OCTET)((value & ((1 << nbits)-1)) << pctxt->buffer.bitOffset); } else pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; return stat; } int encodeBitsFromOctet (OOCTXT* pctxt, ASN1OCTET value, ASN1UINT nbits) { int lshift = pctxt->buffer.bitOffset; int rshift = 8 - pctxt->buffer.bitOffset; int stat = ASN_OK; ASN1OCTET mask = 0x0; if (nbits == 0) return ASN_OK; /* Mask off unused bits from the end of the value */ if (nbits < 8) { switch (nbits) { case 1: mask = 0x80; break; case 2: mask = 0xC0; break; case 3: mask = 0xE0; break; case 4: mask = 0xF0; break; case 5: mask = 0xF8; break; case 6: mask = 0xFC; break; case 7: mask = 0xFE; break; default:; } value &= mask; } /* If we are on a byte boundary, we can do a direct assignment */ if (pctxt->buffer.bitOffset == 8) { pctxt->buffer.data[pctxt->buffer.byteIndex] = value; if (nbits == 8) { pctxt->buffer.byteIndex++; pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; } else pctxt->buffer.bitOffset -= nbits; } /* Otherwise, need to set some bits in the first octet and */ /* possibly some bits in the following octet.. */ else { pctxt->buffer.data[pctxt->buffer.byteIndex] |= (ASN1OCTET)(value >> rshift); pctxt->buffer.bitOffset -= nbits; if (pctxt->buffer.bitOffset < 0) { pctxt->buffer.byteIndex++; pctxt->buffer.data[pctxt->buffer.byteIndex] = (ASN1OCTET)(value << lshift); pctxt->buffer.bitOffset += 8; } } return stat; } int encodeBitString (OOCTXT* pctxt, ASN1UINT numbits, const ASN1OCTET* data) { int enclen, octidx = 0, stat; Asn1SizeCnst* pSizeList = pctxt->pSizeConstraint; for (;;) { if ((enclen = encodeLength (pctxt, numbits)) < 0) { return LOG_ASN1ERR (pctxt, enclen); } if (enclen > 0) { ASN1BOOL doAlign; stat = bitAndOctetStringAlignmentTest (pSizeList, numbits, TRUE, &doAlign); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (doAlign) { stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } stat = encodeOctets (pctxt, &data[octidx], enclen); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } if (enclen < (int)numbits) { numbits -= enclen; octidx += (enclen/8); } else break; } return ASN_OK; } int encodeBMPString (OOCTXT* pctxt, ASN1BMPString value, Asn116BitCharSet* permCharSet) { Asn116BitCharSet charSet; int stat; /* Set character set */ init16BitCharSet (&charSet, BMP_FIRST, BMP_LAST, BMP_ABITS, BMP_UBITS); if (permCharSet) { set16BitCharSet (pctxt, &charSet, permCharSet); } /* Encode constrained string */ stat = encode16BitConstrainedString (pctxt, value, &charSet); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); return stat; } int encodeByteAlign (OOCTXT* pctxt) { if (pctxt->buffer.bitOffset != 8) { if ((pctxt->buffer.byteIndex + 1) >= pctxt->buffer.size) { int stat = encodeExpandBuffer (pctxt, 1); if (stat != ASN_OK) return (stat); } pctxt->buffer.byteIndex++; pctxt->buffer.bitOffset = 8; pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; } return ASN_OK; } int encodeCheckBuffer (OOCTXT* pctxt, ASN1UINT nbytes) { int stat = ASN_OK; /* Add one to required bytes because increment logic will always */ /* init the byte at the incremented index to zero.. */ if ( ( pctxt->buffer.byteIndex + nbytes + 1 ) >= pctxt->buffer.size ) { if ((stat = encodeExpandBuffer (pctxt, nbytes+1)) != ASN_OK) { return LOG_ASN1ERR (pctxt, stat); } } return (stat); } int encodeConsInteger (OOCTXT* pctxt, ASN1INT value, ASN1INT lower, ASN1INT upper) { ASN1UINT range_value; ASN1UINT adjusted_value; int stat; /* Check value against given range */ if (value < lower || value > upper) { return ASN_E_CONSVIO; } /* Adjust range value based on lower/upper signed values and */ /* other possible conflicts.. */ if ((upper > 0 && lower >= 0) || (upper <= 0 && lower < 0)) { range_value = upper - lower; adjusted_value = value - lower; } else { range_value = upper + abs(lower); adjusted_value = value + abs(lower); } if (range_value != ASN1UINT_MAX) { range_value += 1; } if (range_value == 0 || lower > upper) stat = ASN_E_RANGERR; else if (lower != upper) { stat = encodeConsWholeNumber (pctxt, adjusted_value, range_value); } else stat = ASN_OK; return stat; } int encodeConsUnsigned (OOCTXT* pctxt, ASN1UINT value, ASN1UINT lower, ASN1UINT upper) { ASN1UINT range_value; ASN1UINT adjusted_value; int stat; /* Check for special case: if lower is 0 and upper is ASN1UINT_MAX, */ /* set range to ASN1UINT_MAX; otherwise to upper - lower + 1 */ range_value = (lower == 0 && upper == ASN1UINT_MAX) ? ASN1UINT_MAX : upper - lower + 1; adjusted_value = value - lower; if (lower != upper) { stat = encodeConsWholeNumber (pctxt, adjusted_value, range_value); } else stat = ASN_OK; return stat; } int encodeConsWholeNumber (OOCTXT* pctxt, ASN1UINT adjusted_value, ASN1UINT range_value) { ASN1UINT nocts, range_bitcnt = getUIntBitCount (range_value - 1); int stat; if (adjusted_value >= range_value && range_value != ASN1UINT_MAX) { return LOG_ASN1ERR (pctxt, ASN_E_RANGERR); } /* If range is <= 255, bit-field case (10.5.7a) */ if (range_value <= 255) { return encodeBits (pctxt, adjusted_value, range_bitcnt); } /* If range is exactly 256, one-octet case (10.5.7b) */ else if (range_value == 256) { stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); return encodeBits (pctxt, adjusted_value, 8); } /* If range > 256 and <= 64k (65536), two-octet case (10.5.7c) */ else if (range_value <= 65536) { stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); return encodeBits (pctxt, adjusted_value, 16); } /* If range > 64k, indefinite-length case (10.5.7d) */ else { /* Encode length determinant as a constrained whole number. */ /* Constraint is 1 to max number of bytes needed to hold */ /* the target integer value.. */ if (adjusted_value < 256) nocts = 1; else if (adjusted_value < 65536) nocts = 2; else if (adjusted_value < 0x1000000) nocts = 3; else nocts = 4; stat = encodeBits (pctxt, nocts - 1, 2); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); return encodeNonNegBinInt (pctxt, adjusted_value); } } int encodeConstrainedStringEx (OOCTXT* pctxt, const char* string, const char* charSet, ASN1UINT abits, /* aligned char bits */ ASN1UINT ubits, /* unaligned char bits */ ASN1UINT canSetBits) { ASN1UINT i, len = strlen(string); int stat; /* note: need to save size constraint for use in alignCharStr */ /* because it will be cleared in encodeLength from the context.. */ Asn1SizeCnst* psize = pctxt->pSizeConstraint; /* Encode length */ stat = encodeLength (pctxt, len); if (stat < 0) return LOG_ASN1ERR (pctxt, stat); /* Byte align */ if (alignCharStr (pctxt, len, abits, psize)) { stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } /* Encode data */ if (abits >= canSetBits && canSetBits > 4) { for (i = 0; i < len; i++) { if ((stat = encodeBits (pctxt, string[i], abits)) != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } } else if (0 != charSet) { ASN1UINT nchars = strlen(charSet), pos; const char* ptr; for (i = 0; i < len; i++) { ptr = memchr (charSet, string[i], nchars); if (0 == ptr) return LOG_ASN1ERR (pctxt, ASN_E_CONSVIO); else pos = ptr - charSet; if ((stat = encodeBits (pctxt, pos, abits)) != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } } else return LOG_ASN1ERR (pctxt, ASN_E_INVPARAM); return stat; } int encodeExpandBuffer (OOCTXT* pctxt, ASN1UINT nbytes) { if (pctxt->buffer.dynamic) { /* If dynamic encoding is enabled, expand the current buffer to */ /* allow encoding to continue. */ pctxt->buffer.size += ASN1MAX (ASN_K_ENCBUFSIZ, nbytes); pctxt->buffer.data = (ASN1OCTET*) memHeapRealloc (&pctxt->pMsgMemHeap, pctxt->buffer.data, pctxt->buffer.size); if (!pctxt->buffer.data) return (ASN_E_NOMEM); return (ASN_OK); } return (ASN_E_BUFOVFLW); } int encodeGetMsgBitCnt (OOCTXT* pctxt) { int numBitsInLastByte = 8 - pctxt->buffer.bitOffset; return ((pctxt->buffer.byteIndex * 8) + numBitsInLastByte); } ASN1OCTET* encodeGetMsgPtr (OOCTXT* pctxt, int* pLength) { if (pLength) *pLength = getPERMsgLen (pctxt); return pctxt->buffer.data; } int encodeIdent (OOCTXT* pctxt, ASN1UINT ident) { ASN1UINT mask; int nshifts = 0, stat; if (ident !=0) { ASN1UINT lv; nshifts = getIdentByteCount (ident); while (nshifts > 0) { mask = ((ASN1UINT)0x7f) << (7 * (nshifts - 1)); nshifts--; lv = (ASN1UINT)((ident & mask) >> (nshifts * 7)); if (nshifts != 0) { lv |= 0x80; } if ((stat = encodeBits (pctxt, lv, 8)) != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } } else { /* encode a single zero byte */ if ((stat = encodeBits (pctxt, 0, 8)) != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } return ASN_OK; } int encodeLength (OOCTXT* pctxt, ASN1UINT value) { ASN1BOOL extendable; Asn1SizeCnst* pSize = checkSize (pctxt->pSizeConstraint, value, &extendable); ASN1UINT lower = (pSize) ? pSize->lower : 0; ASN1UINT upper = (pSize) ? pSize->upper : ASN1UINT_MAX; int enclen, stat; /* If size constraints exist and the given length did not fall */ /* within the range of any of them, signal constraint violation */ /* error.. */ if (pctxt->pSizeConstraint && !pSize) return LOG_ASN1ERR (pctxt, ASN_E_CONSVIO); /* Reset the size constraint in the context block structure */ pctxt->pSizeConstraint = 0; /* If size constraint is present and extendable, encode extension */ /* bit.. */ if (extendable) { stat = (pSize) ? encodeBit (pctxt, pSize->extended) : encodeBit (pctxt, 1); if (stat != ASN_OK) return (stat); } /* If upper limit is less than 64k, constrained case */ if (upper < 65536) { stat = (lower == upper) ? ASN_OK : encodeConsWholeNumber (pctxt, value - lower, upper - lower + 1); enclen = (stat == ASN_OK) ? value : stat; } else { /* unconstrained case or Constrained with upper bound >= 64K*/ enclen = encodeUnconsLength (pctxt, value); } return enclen; } int encodeObjectIdentifier (OOCTXT* pctxt, ASN1OBJID* pvalue) { int len, stat; ASN1UINT temp; register int numids, i; /* Calculate length in bytes and encode */ len = 1; /* 1st 2 arcs require 1 byte */ numids = pvalue->numids; for (i = 2; i < numids; i++) { len += getIdentByteCount (pvalue->subid[i]); } /* PER encode length */ if ((stat = encodeLength (pctxt, (ASN1UINT)len)) < 0) { return LOG_ASN1ERR (pctxt, stat); } /* Validate given object ID by applying ASN.1 rules */ if (0 == pvalue) return LOG_ASN1ERR (pctxt, ASN_E_INVOBJID); if (numids < 2) return LOG_ASN1ERR (pctxt, ASN_E_INVOBJID); if (pvalue->subid[0] > 2) return LOG_ASN1ERR (pctxt, ASN_E_INVOBJID); if (pvalue->subid[0] != 2 && pvalue->subid[1] > 39) return LOG_ASN1ERR (pctxt, ASN_E_INVOBJID); /* Passed checks, encode object identifier */ /* Munge first two sub ID's and encode */ temp = ((pvalue->subid[0] * 40) + pvalue->subid[1]); if ((stat = encodeIdent (pctxt, temp)) != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Encode the remainder of the OID value */ for (i = 2; i < numids; i++) { if ((stat = encodeIdent (pctxt, pvalue->subid[i])) != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } return ASN_OK; } int encodebitsFromOctet (OOCTXT* pctxt, ASN1OCTET value, ASN1UINT nbits) { int lshift = pctxt->buffer.bitOffset; int rshift = 8 - pctxt->buffer.bitOffset; int stat = ASN_OK; ASN1OCTET mask = 0x0; if (nbits == 0) return ASN_OK; /* Mask off unused bits from the end of the value */ if (nbits < 8) { switch (nbits) { case 1: mask = 0x80; break; case 2: mask = 0xC0; break; case 3: mask = 0xE0; break; case 4: mask = 0xF0; break; case 5: mask = 0xF8; break; case 6: mask = 0xFC; break; case 7: mask = 0xFE; break; default:; } value &= mask; } /* If we are on a byte boundary, we can do a direct assignment */ if (pctxt->buffer.bitOffset == 8) { pctxt->buffer.data[pctxt->buffer.byteIndex] = value; if (nbits == 8) { pctxt->buffer.byteIndex++; pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; } else pctxt->buffer.bitOffset -= nbits; } /* Otherwise, need to set some bits in the first octet and */ /* possibly some bits in the following octet.. */ else { pctxt->buffer.data[pctxt->buffer.byteIndex] |= (ASN1OCTET)(value >> rshift); pctxt->buffer.bitOffset -= nbits; if (pctxt->buffer.bitOffset < 0) { pctxt->buffer.byteIndex++; pctxt->buffer.data[pctxt->buffer.byteIndex] = (ASN1OCTET)(value << lshift); pctxt->buffer.bitOffset += 8; } } return stat; } int encodeOctets (OOCTXT* pctxt, const ASN1OCTET* pvalue, ASN1UINT nbits) { int i = 0, stat; int numFullOcts = nbits / 8; if (nbits == 0) return 0; /* Check buffer space and allocate more memory if necessary */ stat = encodeCheckBuffer (pctxt, numFullOcts + 1); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (numFullOcts > 0) { /* If the current bit offset is 8 (i.e. we don't have a */ /* byte started), can copy the string directly to the */ /* encode buffer.. */ if (pctxt->buffer.bitOffset == 8) { memcpy (&pctxt->buffer.data[pctxt->buffer.byteIndex], pvalue, numFullOcts); pctxt->buffer.byteIndex += numFullOcts; pctxt->buffer.data[pctxt->buffer.byteIndex] = 0; i = numFullOcts; } /* Else, copy bits */ else { for (i = 0; i < numFullOcts; i++) { stat = encodeBitsFromOctet (pctxt, pvalue[i], 8); if (stat != ASN_OK) return stat; } } } /* Move remaining bits from the last octet to the output buffer */ if (nbits % 8 != 0) { stat = encodeBitsFromOctet (pctxt, pvalue[i], nbits % 8); } return stat; } int encodeOctetString (OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data) { int enclen, octidx = 0, stat; Asn1SizeCnst* pSizeList = pctxt->pSizeConstraint; for (;;) { if ((enclen = encodeLength (pctxt, numocts)) < 0) { return LOG_ASN1ERR (pctxt, enclen); } if (enclen > 0) { ASN1BOOL doAlign; stat = bitAndOctetStringAlignmentTest (pSizeList, numocts, FALSE, &doAlign); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (doAlign) { stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } stat = encodeOctets (pctxt, &data[octidx], enclen * 8); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } if (enclen < (int)numocts) { numocts -= enclen; octidx += enclen; } else break; } return ASN_OK; } int encodeOpenType (OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data) { int enclen, octidx = 0, stat; ASN1OCTET zeroByte = 0x00; ASN1OpenType openType; /* If open type contains length zero, add a single zero byte (10.1) */ if (numocts == 0) { openType.numocts = 1; openType.data = &zeroByte; } else { openType.numocts = numocts; openType.data = data; } /* Encode the open type */ for (;;) { if ((enclen = encodeLength (pctxt, openType.numocts)) < 0) { return LOG_ASN1ERR (pctxt, enclen); } stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = encodeOctets (pctxt, &openType.data[octidx], enclen * 8); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (enclen < (int)openType.numocts) { openType.numocts -= enclen; octidx += enclen; } else break; } return ASN_OK; } int encodeOpenTypeExt (OOCTXT* pctxt, DList* pElemList) { DListNode* pnode; ASN1OpenType* pOpenType; int stat; if (0 != pElemList) { pnode = pElemList->head; while (0 != pnode) { if (0 != pnode->data) { pOpenType = (ASN1OpenType*)pnode->data; if (pOpenType->numocts > 0) { stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = encodeOpenType (pctxt, pOpenType->numocts, pOpenType->data); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } } pnode = pnode->next; } } return ASN_OK; } int encodeOpenTypeExtBits (OOCTXT* pctxt, DList* pElemList) { DListNode* pnode; int stat; if (0 != pElemList) { pnode = pElemList->head; while (0 != pnode) { stat = encodeBit (pctxt, (ASN1BOOL)(0 != pnode->data)); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); pnode = pnode->next; } } return ASN_OK; } int encodeSemiConsInteger (OOCTXT* pctxt, ASN1INT value, ASN1INT lower) { int nbytes, stat; int shift = ((sizeof(value) - 1) * 8) - 1; ASN1UINT tempValue; if (lower > ASN1INT_MIN) value -= lower; /* Calculate signed number value length */ for ( ; shift > 0; shift -= 8) { tempValue = (value >> shift) & 0x1ff; if (tempValue == 0 || tempValue == 0x1ff) continue; else break; } nbytes = (shift + 9) / 8; /* Encode length */ if ((stat = encodeLength (pctxt, nbytes)) < 0) { return stat; } if ((stat = encodeByteAlign (pctxt)) != ASN_OK) return stat; /* Encode signed value */ stat = encode2sCompBinInt (pctxt, value); return stat; } int encodeSemiConsUnsigned (OOCTXT* pctxt, ASN1UINT value, ASN1UINT lower) { int nbytes, stat; int shift = ((sizeof(value) - 1) * 8) - 1; ASN1UINT mask = 1UL << ((sizeof(value) * 8) - 1); ASN1UINT tempValue; value -= lower; /* Calculate unsigned number value length */ for ( ; shift > 0; shift -= 8) { tempValue = (value >> shift) & 0x1ff; if (tempValue == 0) continue; else break; } nbytes = (shift + 9) / 8; /* If MS bit in unsigned number is set, add an extra zero byte */ if ((value & mask) != 0) nbytes++; /* Encode length */ if ((stat = encodeLength (pctxt, nbytes)) < 0) { return stat; } if ((stat = encodeByteAlign (pctxt)) != ASN_OK) return stat; /* Encode additional zero byte if necessary */ if (nbytes > sizeof(value)) { stat = encodebitsFromOctet (pctxt, 0, 8); if (stat != ASN_OK) return (stat); } /* Encode unsigned value */ stat = encodeNonNegBinInt (pctxt, value); return stat; } int encodeSmallNonNegWholeNumber (OOCTXT* pctxt, ASN1UINT value) { int stat; if (value < 64) { stat = encodeBits (pctxt, value, 7); } else { ASN1UINT len; /* Encode a one-byte length determinant value */ if (value < 256) len = 1; else if (value < 65536) len = 2; else if (value < 0x1000000) len = 3; else len = 4; stat = encodeBits (pctxt, len, 8); /* Byte-align and encode the value */ if (stat == ASN_OK) { if ((stat = encodeByteAlign (pctxt)) == ASN_OK) { stat = encodeBits (pctxt, value, len*8); } } } return stat; } int encodeVarWidthCharString (OOCTXT* pctxt, const char* value) { int stat; ASN1UINT len = strlen (value); /* note: need to save size constraint for use in alignCharStr */ /* because it will be cleared in encodeLength from the context.. */ Asn1SizeCnst* psize = pctxt->pSizeConstraint; /* Encode length */ stat = encodeLength (pctxt, len); if (stat < 0) return LOG_ASN1ERR (pctxt, stat); /* Byte align */ if (alignCharStr (pctxt, len, 8, psize)) { stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } /* Encode data */ stat = encodeOctets (pctxt, (const ASN1OCTET*)value, len * 8); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); return ASN_OK; } static int encode16BitConstrainedString (OOCTXT* pctxt, Asn116BitCharString value, Asn116BitCharSet* pCharSet) { ASN1UINT i, pos; ASN1UINT nbits = pCharSet->alignedBits; int stat; /* Encode length */ stat = encodeLength (pctxt, value.nchars); if (stat < 0) return LOG_ASN1ERR (pctxt, stat); /* Byte align */ stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Encode data */ for (i = 0; i < value.nchars; i++) { if (pCharSet->charSet.data == 0) { stat = encodeBits (pctxt, value.data[i] - pCharSet->firstChar, nbits); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } else { for (pos = 0; pos < pCharSet->charSet.nchars; pos++) { if (value.data[i] == pCharSet->charSet.data[pos]) { stat = encodeBits (pctxt, pos, nbits); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); break; } } } } return stat; } int encode2sCompBinInt (OOCTXT* pctxt, ASN1INT value) { /* 10.4.6 A minimum octet 2's-complement-binary-integer encoding */ /* of the whole number has a field width that is a multiple of 8 */ /* bits and also satisifies the condition that the leading 9 bits */ /* field shall not be all zeros and shall not be all ones. */ /* first encode integer value into a local buffer */ ASN1OCTET lbuf[8], lb; ASN1INT i = sizeof(lbuf), temp = value; memset (lbuf, 0, sizeof(lbuf)); do { lb = temp % 256; temp /= 256; if (temp < 0 && lb != 0) temp--; /* two's complement adjustment */ lbuf[--i] = lb; } while (temp != 0 && temp != -1); /* If the value is positive and bit 8 of the leading byte is set, */ /* copy a zero byte to the contents to signal a positive number.. */ if (value > 0 && (lb & 0x80) != 0) { i--; } /* If the value is negative and bit 8 of the leading byte is clear, */ /* copy a -1 byte (0xFF) to the contents to signal a negative */ /* number.. */ else if (value < 0 && ((lb & 0x80) == 0)) { lbuf[--i] = 0xff; } /* Add the data to the encode buffer */ return encodeOctets (pctxt, &lbuf[i], (sizeof(lbuf) - i) * 8); } static int encodeNonNegBinInt (OOCTXT* pctxt, ASN1UINT value) { /* 10.3.6 A minimum octet non-negative binary integer encoding of */ /* the whole number (which does not predetermine the number of */ /* octets to be used for the encoding) has a field which is a */ /* multiple of 8 bits and also satisifies the condition that the */ /* leading eight bits of the field shall not be zero unless the */ /* field is precisely 8 bits long. */ ASN1UINT bitcnt = (value == 0) ? 1 : getUIntBitCount (value); /* round-up to nearest 8-bit boundary */ bitcnt = (bitcnt + 7) & (~7); /* encode bits */ return encodeBits (pctxt, value, bitcnt); } static int encodeUnconsLength (OOCTXT* pctxt, ASN1UINT value) { int enclen, stat; stat = encodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* 1 octet case */ if (value < 128) { stat = encodeBits (pctxt, value, 8); enclen = (stat == ASN_OK) ? value : stat; } /* 2 octet case */ else if (value < 16384) { if ((stat = encodeBit (pctxt, 1)) == ASN_OK) stat = encodeBits (pctxt, value, 15); enclen = (stat == ASN_OK) ? value : stat; } /* fragmentation case */ else { int multiplier = ASN1MIN (value/16384, 4); encodeBit (pctxt, 1); /* set bit 8 of first octet */ encodeBit (pctxt, 1); /* set bit 7 of first octet */ stat = encodeBits (pctxt, multiplier, 6); enclen = (stat == ASN_OK) ? 16384 * multiplier : stat; } return enclen; } static int getIdentByteCount (ASN1UINT ident) { if (ident < (1u << 7)) { /* 7 */ return 1; } else if (ident < (1u << 14)) { /* 14 */ return 2; } else if (ident < (1u << 21)) { /* 21 */ return 3; } else if (ident < (1u << 28)) { /* 28 */ return 4; } return 5; } asterisk-11.7.0/addons/ooh323c/src/oochannels.c0000644000175000007640000020232111656547674021106 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "asterisk/poll-compat.h" #include "asterisk/config.h" #include "asterisk/netsock2.h" #include "ooports.h" #include "oochannels.h" #include "ootrace.h" #include "ooq931.h" #include "ooh245.h" #include "ooh323.h" #include "ooCalls.h" #include "printHandler.h" #include "ooGkClient.h" #include "stdio.h" #include "ooTimer.h" #include "ooh323ep.h" #include "ooStackCmds.h" #include "ooCmdChannel.h" #include "ooSocket.h" #include "ootypes.h" /** Global endpoint structure */ extern OOH323EndPoint gH323ep; extern ast_mutex_t callListLock; extern ast_mutex_t monitorLock; extern DList g_TimerList; static OOBOOL gMonitor = FALSE; int ooSetCmdFDSETs(struct pollfd *pfds, int *nfds); int ooProcessCmdFDSETsAndTimers (struct pollfd *pfds, int nfds, struct timeval *pToMin); int ooSetFDSETs(struct pollfd *pfds, int *nfds); int ooProcessFDSETsAndTimers (struct pollfd* pfds, int nfds, struct timeval *pToMin); int ooProcessCallFDSETsAndTimers (OOH323CallData *call, struct pollfd* pfds, int nfds, struct timeval *pToMin); int ooSetCallFDSETs(OOH323CallData* call, struct pollfd* pfds, int *nfds); int ooCreateH245Listener(OOH323CallData *call) { int ret=0; OOSOCKET channelSocket=0; OOTRACEINFO1("Creating H245 listener\n"); if((ret=ooSocketCreate (&channelSocket, call->versionIP))!=ASN_OK) { OOTRACEERR3("ERROR: Failed to create socket for H245 listener " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ret = ooBindPort (OOTCP, channelSocket, call->localIP); if(ret == OO_FAILED) { OOTRACEERR3("Error:Unable to bind to a TCP port - H245 listener creation" " (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } call->h245listenport = (int*) memAlloc(call->pctxt, sizeof(int)); *(call->h245listenport) = ret; call->h245listener = (OOSOCKET*)memAlloc(call->pctxt, sizeof(OOSOCKET)); *(call->h245listener) = channelSocket; ret = ooSocketListen(*(call->h245listener), 4096); if(ret != ASN_OK) { OOTRACEERR3("Error:Unable to listen on H.245 socket (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } OOTRACEINFO4("H245 listener creation - successful(port %d) (%s, %s)\n", *(call->h245listenport),call->callType, call->callToken); return OO_OK; } int ooCreateH245Connection(OOH323CallData *call) { int ret=0; OOSOCKET channelSocket=0; ooTimerCallback *cbData=NULL; OOTRACEINFO1("Creating H245 Connection\n"); if((ret=ooSocketCreate (&channelSocket, call->versionIP))!=ASN_OK) { OOTRACEERR3("ERROR:Failed to create socket for H245 connection " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } else { if (0 == call->pH245Channel) { call->pH245Channel = (OOH323Channel*) memAllocZ (call->pctxt, sizeof(OOH323Channel)); } /* bind socket to a port before connecting. Thus avoiding implicit bind done by a connect call. */ ret = ooBindPort(OOTCP, channelSocket, call->localIP); if(ret == OO_FAILED) { OOTRACEERR3("Error:Unable to bind to a TCP port - h245 connection " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } call->pH245Channel->port = ret; OOTRACEDBGC4("Local H.245 port is %d (%s, %s)\n", call->pH245Channel->port, call->callType, call->callToken); OOTRACEINFO5("Trying to connect to remote endpoint to setup H245 " "connection %s:%d(%s, %s)\n", call->remoteIP, call->remoteH245Port, call->callType, call->callToken); if((ret=ooSocketConnect(channelSocket, call->remoteIP, call->remoteH245Port))==ASN_OK) { call->pH245Channel->sock = channelSocket; call->h245SessionState = OO_H245SESSION_ACTIVE; OOTRACEINFO3("H245 connection creation successful (%s, %s)\n", call->callType, call->callToken); /*Start terminal capability exchange and master slave determination */ ret = ooSendTermCapMsg(call); if(ret != OO_OK) { OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n", call->callType, call->callToken); return ret; } } else { if(call->h245ConnectionAttempts >= 3) { OOTRACEERR3("Error:Failed to setup an H245 connection with remote " "destination. (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } else{ OOTRACEWARN4("Warn:Failed to connect to remote destination for " "H245 connection - will retry after %d seconds" "(%s, %s)\n", DEFAULT_H245CONNECTION_RETRYTIMEOUT, call->callType, call->callToken); cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer " "callback.(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_H245CONNECT_TIMER; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooCallH245ConnectionRetryTimerExpired, DEFAULT_H245CONNECTION_RETRYTIMEOUT, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create H245 connection retry timer" "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } return OO_OK; } } } return OO_OK; } int ooSendH225Msg(OOH323CallData *call, Q931Message *msg) { int iRet=0; ASN1OCTET * encodebuf; if(!call) return OO_FAILED; encodebuf = (ASN1OCTET*) memAlloc (call->pctxt, MAXMSGLEN); if(!encodebuf) { OOTRACEERR3("Error:Failed to allocate memory for encoding H225 " "message(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } iRet = ooEncodeH225Message(call, msg, (char *)encodebuf, MAXMSGLEN); if(iRet != OO_OK) { OOTRACEERR3("Error:Failed to encode H225 message. (%s, %s)\n", call->callType, call->callToken); memFreePtr (call->pctxt, encodebuf); return OO_FAILED; } /* If high priority messages, send immediately.*/ if(encodebuf[0] == OOReleaseComplete || (encodebuf[0]==OOFacility && encodebuf[1]==OOEndSessionCommand)) { dListFreeAll(call->pctxt, &call->pH225Channel->outQueue); dListAppend (call->pctxt, &call->pH225Channel->outQueue, encodebuf); // ooSendMsg(call, OOQ931MSG); } else{ dListAppend (call->pctxt, &call->pH225Channel->outQueue, encodebuf); OOTRACEDBGC4("Queued H225 messages %d. (%s, %s)\n", call->pH225Channel->outQueue.count, call->callType, call->callToken); } return OO_OK; } int ooCreateH225Connection(OOH323CallData *call) { int ret=0, i; OOSOCKET channelSocket=0; for (i=0;i<3;i++) { if((ret=ooSocketCreate (&channelSocket, call->versionIP))!=ASN_OK) { OOTRACEERR3("Failed to create socket for transmit H2250 channel (%s, %s)" "\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_TRANSPORTFAILURE; } return OO_FAILED; } else { /* bind socket to a port before connecting. Thus avoiding implicit bind done by a connect call. Avoided on windows as 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. */ #ifndef _WIN32 ret = ooBindPort(OOTCP,channelSocket, call->localIP); #else ret = ooBindOSAllocatedPort(channelSocket, call->localIP); #endif if(ret == OO_FAILED) { OOTRACEERR3("Error:Unable to bind to a TCP port (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_TRANSPORTFAILURE; } return OO_FAILED; } if (0 == call->pH225Channel) { call->pH225Channel = (OOH323Channel*) memAllocZ (call->pctxt, sizeof(OOH323Channel)); } call->pH225Channel->port = ret; OOTRACEINFO6("Trying to connect to remote endpoint(%s:%d) (IPv%d) to setup " "H2250 channel (%s, %s)\n", call->remoteIP, call->remotePort, call->versionIP, call->callType, call->callToken); if((ret=ooSocketConnect(channelSocket, call->remoteIP, call->remotePort))==ASN_OK) { call->pH225Channel->sock = channelSocket; OOTRACEINFO3("H2250 transmiter channel creation - successful " "(%s, %s)\n", call->callType, call->callToken); /* If multihomed, get ip from socket */ if(!strcmp(call->localIP, "0.0.0.0") || !strcmp(call->localIP, "::")) { OOTRACEDBGA3("Determining IP address for outgoing call in " "multihomed mode. (%s, %s)\n", call->callType, call->callToken); ret = ooSocketGetIpAndPort(channelSocket, call->localIP, 2+8*4+7, &call->pH225Channel->port, NULL); if(ret != ASN_OK) { OOTRACEERR3("ERROR:Failed to retrieve local ip and port from " "socket for multihomed mode.(%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { /* transport failure */ call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_TRANSPORTFAILURE; } return OO_FAILED; } OOTRACEDBGA4("Using local ip %s for outgoing call(multihomedMode)." " (%s, %s)\n", call->localIP, call->callType, call->callToken); } return OO_OK; } else { OOTRACEERR5("ERROR:Failed to connect to remote destination for " "transmit H2250 channel(%s, %s, %d, %s)\n",call->callType, call->callToken, channelSocket, call->localIP); close(channelSocket); if(call->callState < OO_CALL_CLEAR) { /* No one is listening at remote end */ call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_NOUSER; } if (i>=2) return OO_FAILED; else continue; } return OO_FAILED; } } return OO_FAILED; } int ooCloseH225Connection (OOH323CallData *call) { if (0 != call->pH225Channel) { if(call->pH225Channel->sock != 0) ooSocketClose (call->pH225Channel->sock); if (call->pH225Channel->outQueue.count > 0) { dListFreeAll (call->pctxt, &(call->pH225Channel->outQueue)); } memFreePtr (call->pctxt, call->pH225Channel); call->pH225Channel = NULL; } return OO_OK; } int ooCreateH323Listener() { int ret=0; OOSOCKET channelSocket=0; OOIPADDR ipaddrs; /* Create socket */ ret = ast_parse_arg(gH323ep.signallingIP, PARSE_ADDR, &ipaddrs); if((ret=ooSocketCreate (&channelSocket, ast_sockaddr_is_ipv6(&ipaddrs) ? 6 : 4)) !=ASN_OK) { OOTRACEERR1("Failed to create socket for H323 Listener\n"); return OO_FAILED; } if((ret=ooSocketBind (channelSocket, ipaddrs, gH323ep.listenPort))==ASN_OK) { gH323ep.listener = (OOSOCKET*)memAlloc(&gH323ep.ctxt,sizeof(OOSOCKET)); *(gH323ep.listener) = channelSocket; ooSocketListen(channelSocket,2048); /*listen on socket*/ OOTRACEINFO1("H323 listener creation - successful\n"); return OO_OK; } else { OOTRACEERR1("ERROR:Failed to create H323 listener\n"); return OO_FAILED; } } int ooAcceptH225Connection() { OOH323CallData * call; int ret; char callToken[20]; char remoteIP[2+8*4+7]; OOSOCKET h225Channel=0; memset(remoteIP, 0, sizeof(remoteIP)); ret = ooSocketAccept (*(gH323ep.listener), &h225Channel, remoteIP, NULL); if(ret != ASN_OK) { OOTRACEERR1("Error:Accepting h225 connection\n"); return OO_FAILED; } ooGenerateCallToken(callToken, sizeof(callToken)); call = ooCreateCall("incoming", callToken); if(!call) { OOTRACEERR1("ERROR:Failed to create an incoming call\n"); return OO_FAILED; } ast_mutex_lock(&call->Lock); call->pH225Channel = (OOH323Channel*) memAllocZ (call->pctxt, sizeof(OOH323Channel)); call->pH225Channel->sock = h225Channel; /* If multihomed, get ip from socket */ if(!strcmp(call->localIP, "0.0.0.0") || !strcmp(call->localIP,"::")) { OOTRACEDBGA3("Determining IP address for incoming call in multihomed " "mode (%s, %s)\n", call->callType, call->callToken); } ret = ooSocketGetIpAndPort(h225Channel, call->localIP, 2+8*4+7, &call->pH225Channel->port, &call->versionIP); if(ret != ASN_OK) { OOTRACEERR3("Error:Failed to retrieve local ip and port from " "socket for multihomed mode.(%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { /* transport failure */ call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_TRANSPORTFAILURE; } ast_mutex_unlock(&call->Lock); return OO_FAILED; } OOTRACEDBGA5("Using Local IP address %s (IPv%d) for incoming call " "(%s, %s)\n", call->localIP, call->versionIP, call->callType, call->callToken); if (remoteIP[0]) { strncpy(call->remoteIP, remoteIP, strlen(remoteIP)); } ast_mutex_unlock(&call->Lock); return OO_OK; } int ooAcceptH245Connection(OOH323CallData *call) { int ret; OOSOCKET h245Channel=0; ret = ooSocketAccept (*(call->h245listener), &h245Channel, NULL, NULL); if(ret != ASN_OK) { OOTRACEERR1("Error:Accepting h245 connection\n"); return OO_FAILED; } if (0 == call->pH245Channel) { call->pH245Channel = (OOH323Channel*) memAllocZ (call->pctxt, sizeof(OOH323Channel)); } call->pH245Channel->sock = h245Channel; call->h245SessionState = OO_H245SESSION_ACTIVE; OOTRACEINFO3("H.245 connection established (%s, %s)\n", call->callType, call->callToken); return OO_OK; } int ooSetCmdFDSETs(struct pollfd *pfds, int *nfds) { if(gH323ep.cmdSock) { pfds[*nfds].fd = gH323ep.cmdSock; pfds[*nfds].events = POLLIN; (*nfds)++; } return OO_OK; } int ooProcessCmdFDSETsAndTimers (struct pollfd *pfds, int nfds, struct timeval *pToMin) { if(gH323ep.cmdSock) { if(ooPDRead(pfds, nfds, gH323ep.cmdSock)) { if(ooReadAndProcessStackCommand() != OO_OK) { /* ooReadAndProcessStackCommand prints an error message */ return OO_FAILED; } } } return OO_OK; } int ooSetFDSETs(struct pollfd *pfds, int *nfds) { if(gH323ep.gkClient && gH323ep.gkClient->rasSocket != 0) { pfds[*nfds].fd = gH323ep.gkClient->rasSocket; pfds[*nfds].events = POLLIN; (*nfds)++; } if(gH323ep.listener) { pfds[*nfds].fd = *gH323ep.listener; pfds[*nfds].events = POLLIN; (*nfds)++; } return OO_OK; } int ooSetCallFDSETs(OOH323CallData* call, struct pollfd* pfds, int *nfds) { if(call) { if(call->cmdSock && call->callState < OO_CALL_CLEAR) { pfds[*nfds].fd = call->cmdSock; pfds[*nfds].events = POLLIN; (*nfds)++; } if (0 != call->pH225Channel && 0 != call->pH225Channel->sock) { pfds[*nfds].fd = call->pH225Channel->sock; pfds[*nfds].events = POLLIN; if (call->pH225Channel->outQueue.count > 0 || (OO_TESTFLAG (call->flags, OO_M_TUNNELING) && 0 != call->pH245Channel && call->pH245Channel->outQueue.count>0)) pfds[*nfds].events |= POLLOUT; (*nfds)++; } if (0 != call->pH245Channel && call->pH245Channel->sock != 0) { pfds[*nfds].fd = call->pH245Channel->sock; pfds[*nfds].events = POLLIN; if (call->pH245Channel->outQueue.count>0) pfds[*nfds].events |= POLLOUT; (*nfds)++; } else if(call->h245listener) { OOTRACEINFO3("H.245 Listerner socket being monitored " "(%s, %s)\n", call->callType, call->callToken); pfds[*nfds].fd = *(call->h245listener); pfds[*nfds].events = POLLIN; (*nfds)++; } } return OO_OK; } int ooProcessFDSETsAndTimers (struct pollfd* pfds, int nfds, struct timeval *pToMin) { struct timeval toNext; /* Process gatekeeper client timers */ if(gH323ep.gkClient) { ooTimerFireExpired(&gH323ep.gkClient->ctxt, &gH323ep.gkClient->timerList); if(ooTimerNextTimeout(&gH323ep.gkClient->timerList, &toNext)) { if(ooCompareTimeouts(pToMin, &toNext)>0) { pToMin->tv_sec = toNext.tv_sec; pToMin->tv_usec = toNext.tv_usec; } } if(gH323ep.gkClient->state == GkClientFailed || gH323ep.gkClient->state == GkClientGkErr) { if(ooGkClientHandleClientOrGkFailure(gH323ep.gkClient)!=OO_OK) { //ooStopMonitorCalls(); //Function calling ooProcessFDSETsAndTimers is responsible for this. return OO_FAILED; } } } /* Manage ready descriptors after select */ if(0 != gH323ep.gkClient && 0 != gH323ep.gkClient->rasSocket) { if(ooPDRead(pfds, nfds, gH323ep.gkClient->rasSocket) ) { ooGkClientReceive(gH323ep.gkClient); if(gH323ep.gkClient->state == GkClientFailed || gH323ep.gkClient->state == GkClientGkErr) { ooGkClientHandleClientOrGkFailure(gH323ep.gkClient); } } } if(gH323ep.listener) { if(ooPDRead(pfds, nfds, *(gH323ep.listener))) { OOTRACEDBGA1("New connection at H225 receiver\n"); ooAcceptH225Connection(); } } return OO_OK; } int ooProcessCallFDSETsAndTimers (OOH323CallData *call, struct pollfd* pfds, int nfds, struct timeval *pToMin) { struct timeval toNext; if(call) { if(call->cmdSock) { if(ooPDRead(pfds, nfds, call->cmdSock)) { ast_mutex_lock(&call->Lock); if(ooReadAndProcessCallStackCommand(call) != OO_OK) { /* ooReadAndProcessStackCommand prints an error message */ ast_mutex_unlock(&call->Lock); return OO_FAILED; } ast_mutex_unlock(&call->Lock); } } ooTimerFireExpired(call->pctxt, &call->timerList); if (0 != call->pH225Channel && 0 != call->pH225Channel->sock) { if(ooPDRead(pfds, nfds, call->pH225Channel->sock)) { if(ooH2250Receive(call) != OO_OK) { OOTRACEERR3("ERROR:Failed ooH2250Receive - Clearing call " "(%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { if (!call->callEndReason) call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } } } } if (0 != call->pH245Channel && 0 != call->pH245Channel->sock) if(ooPDRead(pfds, nfds, call->pH245Channel->sock)) ooH245Receive(call); if (0 != call->pH245Channel && 0 != call->pH245Channel->sock) { if(ooPDWrite(pfds, nfds, call->pH245Channel->sock)) { while (call->pH245Channel->outQueue.count>0) { if (ooSendMsg(call, OOH245MSG) != OO_OK) break; } } } else if(call->h245listener) { if(ooPDRead(pfds, nfds, *(call->h245listener))) { OOTRACEDBGC3("Incoming H.245 connection (%s, %s)\n", call->callType, call->callToken); ooAcceptH245Connection(call); } } if (0 != call->pH225Channel && 0 != call->pH225Channel->sock) { if(ooPDWrite(pfds, nfds, call->pH225Channel->sock)) { while (call->pH225Channel->outQueue.count>0) { OOTRACEDBGC3("Sending H225 message (%s, %s)\n", call->callType, call->callToken); if (ooSendMsg(call, OOQ931MSG) != OO_OK) break; } if(call->pH245Channel && call->pH245Channel->outQueue.count>0 && OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { while (call->pH245Channel->outQueue.count>0) { OOTRACEDBGC3("H245 message needs to be tunneled. " "(%s, %s)\n", call->callType, call->callToken); if (ooSendMsg(call, OOH245MSG) != OO_OK) break; } } } } if(ooTimerNextTimeout(&call->timerList, &toNext)) { if(ooCompareTimeouts(pToMin, &toNext) > 0) { pToMin->tv_sec = toNext.tv_sec; pToMin->tv_usec = toNext.tv_usec; } } if(call->callState >= OO_CALL_CLEAR && call->callState < OO_CALL_CLEARED) { ast_mutex_lock(&call->Lock); ooEndCall(call); ast_mutex_unlock(&call->Lock); } else if(call->callState == OO_CALL_CLEARED) { ast_mutex_lock(&call->Lock); ooEndCall(call); ast_mutex_unlock(&call->Lock); } if(call->callState >= OO_CALL_CLEARED) ooStopMonitorCallChannels(call); } return OO_OK; } int ooMonitorCmdChannels() { int ret=0, nfds=0; struct timeval toMin; struct pollfd pfds[1]; gMonitor = TRUE; toMin.tv_sec = 3; toMin.tv_usec = 0; while(1) { nfds = 0; ooSetCmdFDSETs(pfds, &nfds); if(!gMonitor) { OOTRACEINFO1("Ending Monitor thread\n"); break; } if(nfds == 0) #ifdef _WIN32 Sleep(10); #else { toMin.tv_sec = 0; toMin.tv_usec = 10000; ooSocketPoll(pfds, nfds, toMin.tv_usec / 1000); } #endif else ret = ooSocketPoll(pfds, nfds, toMin.tv_sec * 1000 + toMin.tv_usec / 1000); if(ret == -1) { OOTRACEERR1("Error in poll ...exiting\n"); exit(-1); continue; } toMin.tv_sec = 2; /* 2 sec */ toMin.tv_usec = 100000; /* 100ms*/ ast_mutex_lock(&monitorLock); if(ooProcessCmdFDSETsAndTimers(pfds, nfds, &toMin) != OO_OK) { /* ooStopMonitorCalls(); */ ast_mutex_unlock(&monitorLock); continue; } ast_mutex_unlock(&monitorLock); }/* while(1)*/ return OO_OK; } int ooMonitorChannels() { int ret=0, nfds=0; struct timeval toMin, toNext; struct pollfd pfds[2]; gMonitor = TRUE; toMin.tv_sec = 3; toMin.tv_usec = 0; ooH323EpPrintConfig(); if(gH323ep.gkClient) { ooGkClientPrintConfig(gH323ep.gkClient); if(OO_OK != ooGkClientStart(gH323ep.gkClient)) { OOTRACEERR1("Error:Failed to start Gatekeeper client\n"); ooGkClientDestroy(); } } while(1) { nfds = 0; ooSetFDSETs(pfds, &nfds); if(!gMonitor) { OOTRACEINFO1("Ending Monitor thread\n"); break; } if(nfds == 0) #ifdef _WIN32 Sleep(10); #else { toMin.tv_sec = 0; toMin.tv_usec = 10000; ooSocketPoll(pfds, nfds, toMin.tv_usec / 1000); } #endif else ret = ooSocketPoll(pfds, nfds, toMin.tv_sec * 1000 + toMin.tv_usec / 1000); if(ret == -1) { OOTRACEERR1("Error in poll ...exiting\n"); exit(-1); } toMin.tv_sec = 2; /* 2 sec */ toMin.tv_usec = 100000; /* 100ms*/ /*This is for test application. Not part of actual stack */ ast_mutex_lock(&monitorLock); ooTimerFireExpired(&gH323ep.ctxt, &g_TimerList); if(ooTimerNextTimeout(&g_TimerList, &toNext)) { if(ooCompareTimeouts(&toMin, &toNext)>0) { toMin.tv_sec = toNext.tv_sec; toMin.tv_usec = toNext.tv_usec; } } if(ooProcessFDSETsAndTimers(pfds, nfds, &toMin) != OO_OK) { ast_mutex_unlock(&monitorLock); ooStopMonitorCalls(); continue; } ast_mutex_unlock(&monitorLock); }/* while(1)*/ return OO_OK; } int ooMonitorCallChannels(OOH323CallData *call) { int ret=0, nfds=0, zeroloops = 0; #define MAX_ZERO_LOOP 1020 struct timeval toMin; struct pollfd pfds[5]; OOCTXT* pctxt; call->Monitor = TRUE; toMin.tv_sec = 3; toMin.tv_usec = 0; while(1) { if(!call->Monitor) { OOTRACEINFO1("Ending Call Monitor thread\n"); break; } nfds = 0; ooSetCallFDSETs(call, pfds, &nfds); if(nfds == 0) #ifdef _WIN32 Sleep(10); #else { if (zeroloops++ > MAX_ZERO_LOOP) { ooCleanCall(call); ooStopMonitorCallChannels(call); break; } toMin.tv_sec = 0; toMin.tv_usec = 10000; ooSocketPoll(pfds, nfds, toMin.tv_usec / 1000); } #endif else ret = ooSocketPoll(pfds, nfds, toMin.tv_sec * 1000 + toMin.tv_usec / 1000); if(ret == -1) { OOTRACEERR2("Error in poll %d ...exiting\n", errno); call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEARED; ooCleanCall(call); ooStopMonitorCallChannels(call); break; } toMin.tv_sec = 2; /* 2 sec */ toMin.tv_usec = 100000; /* 100ms*/ /*This is for test application. Not part of actual stack */ if(ooProcessCallFDSETsAndTimers(call, pfds, nfds, &toMin) != OO_OK) { ooStopMonitorCallChannels(call); continue; } }/* while(1)*/ if (call->cmdSock) ooCloseCallCmdConnection(call); ast_mutex_lock(&call->Lock); ast_mutex_unlock(&call->Lock); ast_mutex_destroy(&call->Lock); ast_mutex_destroy(&call->GkLock); ast_cond_destroy(&call->gkWait); pctxt = call->pctxt; freeContext(pctxt); free(pctxt); return OO_OK; } int ooH2250Receive(OOH323CallData *call) { int recvLen=0, total=0, ret=0; ASN1OCTET message[MAXMSGLEN], message1[MAXMSGLEN]; int len; Q931Message *pmsg; OOCTXT *pctxt = call->msgctxt; struct timeval timeout; pmsg = (Q931Message*)memAlloc(pctxt, sizeof(Q931Message)); if(!pmsg) { OOTRACEERR3("ERROR:Failed to allocate memory for incoming H.2250 message" " (%s, %s)\n", call->callType, call->callToken); /* memReset(&gH323ep.msgctxt); */ memReset(call->pctxt); return OO_FAILED; } memset(pmsg, 0, sizeof(Q931Message)); /* First read just TPKT header which is four bytes */ recvLen = ooSocketRecv (call->pH225Channel->sock, message, 4); if(recvLen <= 0) { if(recvLen == 0) OOTRACEWARN3("Warn:RemoteEndpoint closed connection (%s, %s)\n", call->callType, call->callToken); else OOTRACEERR3("Error:Transport failure while reading Q931 " "message (%s, %s)\n", call->callType, call->callToken); ooCloseH225Connection(call); if(call->callState < OO_CALL_CLEARED) { if(call->callState < OO_CALL_CLEAR) call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEARED; } ooFreeQ931Message(pctxt, pmsg); return OO_OK; } OOTRACEDBGC3("Receiving H.2250 message (%s, %s)\n", call->callType, call->callToken); /* Since we are working with TCP, need to determine the message boundary. Has to be done at channel level, as channels know the message formats and can determine boundaries */ if(recvLen != 4) { OOTRACEERR4("Error: Reading TPKT header for H225 message " "recvLen= %d (%s, %s)\n", recvLen, call->callType, call->callToken); ooFreeQ931Message(pctxt, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } len = message[2]; len = len<<8; len = len | message[3]; /* Remaining message length is length - tpkt length */ len = len - 4; if(len > MAXMSGLEN - 4) { OOTRACEERR4("Error: Invalid TPKT header for H225 message " "Len = %d (%s, %s)\n", len, call->callType, call->callToken); ooCloseH225Connection(call); ooFreeQ931Message(pctxt, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } /* Now read actual Q931 message body. We should make sure that we receive complete message as indicated by len. If we don't then there is something wrong. The loop below receives message, then checks whether complete message is received. If not received, then uses select to peek for remaining bytes of the message. If message is not received in 3 seconds, then we have a problem. Report an error and exit. */ while(total < len) { struct pollfd pfds; recvLen = ooSocketRecv (call->pH225Channel->sock, message1, len-total); memcpy(message+total, message1, recvLen); total = total + recvLen; if(total == len) break; /* Complete message is received */ pfds.fd = call->pH225Channel->sock; pfds.events = POLLIN; timeout.tv_sec = 3; timeout.tv_usec = 0; ret = ooSocketPoll(&pfds, 1, timeout.tv_sec * 1000); if(ret == -1) { OOTRACEERR3("Error in select while receiving H.2250 message - " "clearing call (%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } /* If remaining part of the message is not received in 3 seconds exit */ if(!ooPDRead(&pfds, 1, call->pH225Channel->sock)) { OOTRACEERR3("Error: Incomplete H.2250 message received - clearing " "call (%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } } OOTRACEDBGC3("Received Q.931 message: (%s, %s)\n", call->callType, call->callToken); initializePrintHandler(&printHandler, "Received H.2250 Message"); setEventHandler (pctxt, &printHandler); setPERBuffer (pctxt, message, len, TRUE); ret = ooQ931Decode (call, pmsg, len, message, 1); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to decode received H.2250 message. (%s, %s)\n", call->callType, call->callToken); } OOTRACEDBGC3("Decoded Q931 message (%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(pctxt); if(ret == OO_OK) { ret = ooHandleH2250Message(call, pmsg); } return ret; } int ooH245Receive(OOH323CallData *call) { int recvLen, ret, len, total=0; ASN1OCTET message[MAXMSGLEN], message1[MAXMSGLEN]; ASN1BOOL aligned = TRUE; H245Message *pmsg; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->pctxt; struct timeval timeout; pmsg = (H245Message*)memAlloc(pctxt, sizeof(H245Message)); /* First read just TPKT header which is four bytes */ recvLen = ooSocketRecv (call->pH245Channel->sock, message, 4); /* Since we are working with TCP, need to determine the message boundary. Has to be done at channel level, as channels know the message formats and can determine boundaries */ if(recvLen<=0 && call->h245SessionState != OO_H245SESSION_PAUSED) { if(recvLen == 0) OOTRACEINFO3("Closing H.245 channels as remote end point closed H.245" " connection (%s, %s)\n", call->callType, call->callToken); else OOTRACEERR3("Error: Transport failure while trying to receive H245" " message (%s, %s)\n", call->callType, call->callToken); ooCloseH245Connection(call); ooFreeH245Message(call, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } if(call->h245SessionState == OO_H245SESSION_PAUSED) { ooLogicalChannel *temp; OOTRACEINFO3("Call Paused, closing logical channels" " (%s, %s)\n", call->callType, call->callToken); temp = call->logicalChans; while(temp) { if(temp->state == OO_LOGICALCHAN_ESTABLISHED) { /* Sending closelogicalchannel only for outgoing channels*/ if(!strcmp(temp->dir, "transmit")) { ooSendCloseLogicalChannel(call, temp); } } temp = temp->next; } call->masterSlaveState = OO_MasterSlave_Idle; call->callState = OO_CALL_PAUSED; call->localTermCapState = OO_LocalTermCapExchange_Idle; call->remoteTermCapState = OO_RemoteTermCapExchange_Idle; call->h245SessionState = OO_H245SESSION_IDLE; call->logicalChans = NULL; } OOTRACEDBGC1("Receiving H245 message\n"); if(recvLen != 4) { OOTRACEERR3("Error: Reading TPKT header for H245 message (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } len = message[2]; len = len<<8; len = (len | message[3]); /* Remaining message length is length - tpkt length */ len = len - 4; /* Now read actual H245 message body. We should make sure that we receive complete message as indicated by len. If we don't then there is something wrong. The loop below receives message, then checks whether complete message is received. If not received, then uses select to peek for remaining bytes of the message. If message is not received in 3 seconds, then we have a problem. Report an error and exit. */ if(len > MAXMSGLEN - 4) { OOTRACEERR4("Error: Invalid TPKT header length %d for H245 message (%s, %s)\n", len, call->callType, call->callToken); ooFreeH245Message(call, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } while(total < len) { struct pollfd pfds; recvLen = ooSocketRecv (call->pH245Channel->sock, message1, len-total); memcpy(message+total, message1, recvLen); total = total + recvLen; if(total == len) break; /* Complete message is received */ pfds.fd = call->pH245Channel->sock; pfds.events = POLLIN; timeout.tv_sec = 3; timeout.tv_usec = 0; ret = ooSocketPoll(&pfds, 1, timeout.tv_sec * 1000); if(ret == -1) { OOTRACEERR3("Error in select...H245 Receive-Clearing call (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } /* If remaining part of the message is not received in 3 seconds exit */ if(!ooPDRead(&pfds, 1, call->pH245Channel->sock)) { OOTRACEERR3("Error: Incomplete h245 message received (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, pmsg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } } OOTRACEDBGC3("Complete H245 message received (%s, %s)\n", call->callType, call->callToken); setPERBuffer(pctxt, message, recvLen, aligned); initializePrintHandler(&printHandler, "Received H.245 Message"); /* Set event handler */ setEventHandler (pctxt, &printHandler); ret = asn1PD_H245MultimediaSystemControlMessage(pctxt, &(pmsg->h245Msg)); if(ret != ASN_OK) { OOTRACEERR3("Error decoding H245 message (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call, pmsg); return OO_FAILED; } finishPrint(); removeEventHandler(pctxt); ooHandleH245Message(call, pmsg); return OO_OK; } /* Generic Send Message functionality. Based on type of message to be sent, it calls the corresponding function to retrieve the message buffer and then transmits on the associated channel Interpreting msgptr: Q931 messages except facility 1st octet - msgType, next 4 octets - tpkt header, followed by encoded msg Q931 message facility 1st octect - OOFacility, 2nd octet - tunneled msg type(in case no tunneled msg - OOFacility), 3rd and 4th octet - associated logical channel of the tunneled msg(0 when no channel is associated. ex. in case of MSD, TCS), next 4 octets - tpkt header, followed by encoded message. H.245 messages no tunneling 1st octet - msg type, next two octets - logical channel number(0, when no channel is associated), next two octets - total length of the message (including tpkt header) H.245 messages - tunneling. 1st octet - msg type, next two octets - logical channel number(0, when no channel is associated), next two octets - total length of the message. Note, no tpkt header is present in this case. */ int ooSendMsg(OOH323CallData *call, int type) { int len=0, ret=0, msgType=0, tunneledMsgType=0, logicalChannelNo = 0; DListNode * p_msgNode=NULL; ASN1OCTET *msgptr, *msgToSend=NULL; if(call->callState == OO_CALL_CLEARED) { OOTRACEDBGA3("Warning:Call marked for cleanup. Can not send message." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if(type == OOQ931MSG) { if(call->pH225Channel->outQueue.count == 0) { OOTRACEWARN3("WARN:No H.2250 message to send. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } OOTRACEDBGA3("Sending Q931 message (%s, %s)\n", call->callType, call->callToken); p_msgNode = call->pH225Channel->outQueue.head; msgptr = (ASN1OCTET*) p_msgNode->data; msgType = msgptr[0]; if(msgType == OOFacility) { tunneledMsgType = msgptr[1]; logicalChannelNo = msgptr[2]; logicalChannelNo = logicalChannelNo << 8; logicalChannelNo = (logicalChannelNo | msgptr[3]); len = msgptr[6]; len = len<<8; len = (len | msgptr[7]); msgToSend = msgptr+4; } else { len = msgptr[3]; len = len<<8; len = (len | msgptr[4]); msgToSend = msgptr+1; } /* Remove the message from rtdlist pH225Channel->outQueue */ dListRemove(&(call->pH225Channel->outQueue), p_msgNode); if(p_msgNode) memFreePtr(call->pctxt, p_msgNode); /*TODO: This is not required ideally. We will see for some time and if we don't face any problems we will delete this code */ #if 0 /* Check whether connection with remote is alright */ if(!ooChannelsIsConnectionOK(call, call->pH225Channel->sock)) { OOTRACEERR3("Error:Transport failure for signalling channel. " "Abandoning message send and marking call for cleanup.(%s" "'%s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEARED; return OO_OK; } #endif /* Send message out via TCP */ ret = ooSocketSend(call->pH225Channel->sock, msgToSend, len); if(ret == ASN_OK) { memFreePtr (call->pctxt, msgptr); OOTRACEDBGC3("H2250/Q931 Message sent successfully (%s, %s)\n", call->callType, call->callToken); ooOnSendMsg(call, msgType, tunneledMsgType, logicalChannelNo); return OO_OK; } else{ OOTRACEERR3("H2250Q931 Message send failed (%s, %s)\n", call->callType, call->callToken); memFreePtr (call->pctxt, msgptr); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } else if (call->callState == OO_CALL_CLEAR) call->callState = OO_CALL_CLEAR_RELEASESENT; return OO_FAILED; } }/* end of type==OOQ931MSG */ if(type == OOH245MSG) { if(call->pH245Channel->outQueue.count == 0) { OOTRACEWARN3("WARN:No H.245 message to send. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } OOTRACEDBGA3("Sending H245 message (%s, %s)\n", call->callType, call->callToken); p_msgNode = call->pH245Channel->outQueue.head; msgptr = (ASN1OCTET*) p_msgNode->data; msgType = msgptr[0]; logicalChannelNo = msgptr[1]; logicalChannelNo = logicalChannelNo << 8; logicalChannelNo = (logicalChannelNo | msgptr[2]); len = msgptr[3]; len = len<<8; len = (len | msgptr[4]); /* Remove the message from queue */ dListRemove(&(call->pH245Channel->outQueue), p_msgNode); if(p_msgNode) memFreePtr(call->pctxt, p_msgNode); /* Send message out */ if (0 == call->pH245Channel && !OO_TESTFLAG(call->flags, OO_M_TUNNELING)) { OOTRACEWARN3("Neither H.245 channel nor tunneling active " "(%s, %s)\n", call->callType, call->callToken); memFreePtr (call->pctxt, msgptr); /*ooCloseH245Session(call);*/ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_OK; } if (0 != call->pH245Channel && 0 != call->pH245Channel->sock) { OOTRACEDBGC4("Sending %s H245 message over H.245 channel. " "(%s, %s)\n", ooGetMsgTypeText(msgType), call->callType, call->callToken); ret = ooSocketSend(call->pH245Channel->sock, msgptr+5, len); if(ret == ASN_OK) { memFreePtr (call->pctxt, msgptr); OOTRACEDBGA3("H245 Message sent successfully (%s, %s)\n", call->callType, call->callToken); ooOnSendMsg(call, msgType, tunneledMsgType, logicalChannelNo); return OO_OK; } else{ memFreePtr (call->pctxt, msgptr); OOTRACEERR3("ERROR:H245 Message send failed (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } } else if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OOTRACEDBGC4("Sending %s H245 message as a tunneled message." "(%s, %s)\n", ooGetMsgTypeText(msgType), call->callType, call->callToken); ret = ooSendAsTunneledMessage (call, msgptr+5,len,msgType, logicalChannelNo); if(ret != OO_OK) { memFreePtr (call->pctxt, msgptr); OOTRACEERR3("ERROR:Failed to tunnel H.245 message (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } memFreePtr (call->pctxt, msgptr); return OO_OK; } } /* Need to add support for other messages such as T38 etc */ OOTRACEWARN3("ERROR:Unknown message type - message not Sent (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } int ooCloseH245Connection(OOH323CallData *call) { OOTRACEINFO3("Closing H.245 connection (%s, %s)\n", call->callType, call->callToken); if (0 != call->pH245Channel) { if(0 != call->pH245Channel->sock) ooSocketClose (call->pH245Channel->sock); if (call->pH245Channel->outQueue.count > 0) dListFreeAll(call->pctxt, &(call->pH245Channel->outQueue)); memFreePtr (call->pctxt, call->pH245Channel); call->pH245Channel = NULL; OOTRACEDBGC3("Closed H245 connection. (%s, %s)\n", call->callType, call->callToken); } call->h245SessionState = OO_H245SESSION_CLOSED; return OO_OK; } int ooCloseH245Listener(OOH323CallData *call) { OOTRACEINFO3("Closing H.245 Listener (%s, %s)\n", call->callType, call->callToken); if(call->h245listener) { ooSocketClose(*(call->h245listener)); memFreePtr(call->pctxt, call->h245listener); call->h245listener = NULL; } return OO_OK; } int ooOnSendMsg (OOH323CallData *call, int msgType, int tunneledMsgType, int associatedChan) { ooTimerCallback *cbData=NULL; switch(msgType) { case OOSetup: OOTRACEINFO3("Sent Message - Setup (%s, %s)\n", call->callType, call->callToken); /* Start call establishment timer */ cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_CALLESTB_TIMER; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooCallEstbTimerExpired, gH323ep.callEstablishmentTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create call establishment timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } /* if(gH323ep.h323Callbacks.onOutgoingCall) gH323ep.h323Callbacks.onOutgoingCall(call); */ break; case OOCallProceeding: OOTRACEINFO3("Sent Message - CallProceeding (%s, %s)\n", call->callType, call->callToken); break; case OOAlert: OOTRACEINFO3("Sent Message - Alerting (%s, %s) \n", call->callType, call->callToken); /* if(gH323ep.h323Callbacks.onAlerting && call->callState < OO_CALL_CLEAR) gH323ep.h323Callbacks.onAlerting(call); */ break; case OOStatus: OOTRACEINFO3("Sent Message - Status (%s, %s) \n", call->callType, call->callToken); break; case OOConnect: OOTRACEINFO3("Sent Message - Connect (%s, %s)\n", call->callType, call->callToken); if(gH323ep.h323Callbacks.onCallEstablished) gH323ep.h323Callbacks.onCallEstablished(call); break; case OOReleaseComplete: OOTRACEINFO3("Sent Message - ReleaseComplete (%s, %s)\n", call->callType, call->callToken); if(call->callState == OO_CALL_CLEAR_RELEASERECVD) call->callState = OO_CALL_CLEARED; else{ call->callState = OO_CALL_CLEAR_RELEASESENT; if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK) && gH323ep.gkClient->state == GkClientRegistered){ OOTRACEDBGA3("Sending DRQ after sending ReleaseComplete." "(%s, %s)\n", call->callType, call->callToken); call->endTime = (H235TimeStamp) time(NULL); ooGkClientSendDisengageRequest(gH323ep.gkClient, call); } } if(call->callState == OO_CALL_CLEAR_RELEASESENT && call->h245SessionState == OO_H245SESSION_IDLE) { cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback " "data.(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_SESSION_TIMER; cbData->channelNumber = 0; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooSessionTimerExpired, gH323ep.sessionTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create EndSession timer- " "ReleaseComplete.(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } } if(call->h245SessionState == OO_H245SESSION_CLOSED) { call->callState = OO_CALL_CLEARED; } break; case OOFacility: if(tunneledMsgType == OOFacility) { OOTRACEINFO3("Sent Message - Facility. (%s, %s)\n", call->callType, call->callToken); } else{ OOTRACEINFO4("Sent Message - Facility(%s) (%s, %s)\n", ooGetMsgTypeText(tunneledMsgType), call->callType, call->callToken); ooOnSendMsg(call, tunneledMsgType, 0, associatedChan); } break; case OOMasterSlaveDetermination: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - MasterSlaveDetermination (%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - MasterSlaveDetermination (%s, %s)\n", call->callType, call->callToken); /* Start MSD timer */ cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback data." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_MSD_TIMER; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooMSDTimerExpired, gH323ep.msdTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create MSD timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } break; case OOMasterSlaveAck: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - MasterSlaveDeterminationAck (%s, %s)" "\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - MasterSlaveDeterminationAck (%s, %s)\n", call->callType, call->callToken); break; case OOMasterSlaveReject: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - MasterSlaveDeterminationReject " "(%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - MasterSlaveDeterminationReject(%s, %s)\n", call->callType, call->callToken); break; case OOMasterSlaveRelease: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - MasterSlaveDeterminationRelease " "(%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - MasterSlaveDeterminationRelease " "(%s, %s)\n", call->callType, call->callToken); break; case OOTerminalCapabilitySet: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { /* If session isn't marked active yet, do it. possible in case of tunneling */ if(call->h245SessionState == OO_H245SESSION_IDLE || call->h245SessionState == OO_H245SESSION_PAUSED) { call->h245SessionState = OO_H245SESSION_ACTIVE; } OOTRACEINFO3("Tunneled Message - TerminalCapabilitySet (%s, %s)\n", call->callType, call->callToken); } else { OOTRACEINFO3("Sent Message - TerminalCapabilitySet (%s, %s)\n", call->callType, call->callToken); } /* Start TCS timer */ cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback data." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_TCS_TIMER; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooTCSTimerExpired, gH323ep.tcsTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create TCS timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } break; case OOTerminalCapabilitySetAck: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - TerminalCapabilitySetAck (%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - TerminalCapabilitySetAck (%s, %s)\n", call->callType, call->callToken); break; case OOTerminalCapabilitySetReject: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - TerminalCapabilitySetReject " "(%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - TerminalCapabilitySetReject (%s, %s)\n", call->callType, call->callToken); break; case OOOpenLogicalChannel: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO4("Tunneled Message - OpenLogicalChannel(%d). (%s, %s)\n", associatedChan, call->callType, call->callToken); else OOTRACEINFO4("Sent Message - OpenLogicalChannel(%d). (%s, %s)\n", associatedChan, call->callType, call->callToken); /* Start LogicalChannel timer */ cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback data." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_OLC_TIMER; cbData->channelNumber = associatedChan; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooOpenLogicalChannelTimerExpired, gH323ep.logicalChannelTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create OpenLogicalChannel timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } break; case OOOpenLogicalChannelAck: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO4("Tunneled Message - OpenLogicalChannelAck(%d) (%s,%s)\n", associatedChan, call->callType, call->callToken); else OOTRACEINFO4("Sent Message - OpenLogicalChannelAck(%d) (%s, %s)\n", associatedChan, call->callType, call->callToken); break; case OOOpenLogicalChannelReject: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO4("Tunneled Message - OpenLogicalChannelReject(%d)" "(%s, %s)\n", associatedChan, call->callType, call->callToken); else OOTRACEINFO4("Sent Message - OpenLogicalChannelReject(%d) (%s, %s)\n", associatedChan, call->callType, call->callToken); break; case OOEndSessionCommand: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - EndSessionCommand(%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - EndSessionCommand (%s, %s)\n", call->callType, call->callToken); if((call->h245SessionState == OO_H245SESSION_ACTIVE)) { /* Start EndSession timer */ call->h245SessionState = OO_H245SESSION_ENDSENT; cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback " "data.(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_SESSION_TIMER; cbData->channelNumber = 0; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooSessionTimerExpired, gH323ep.sessionTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create EndSession timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } } else{ ooCloseH245Connection(call); if(call->callState < OO_CALL_CLEAR) call->callState = OO_CALL_CLEAR; } break; case OOCloseLogicalChannel: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - CloseLogicalChannel (%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - CloseLogicalChannel (%s, %s)\n", call->callType, call->callToken); /* Start LogicalChannel timer */ cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback data." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_CLC_TIMER; cbData->channelNumber = associatedChan; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooCloseLogicalChannelTimerExpired, gH323ep.logicalChannelTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create CloseLogicalChannel timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } break; case OOCloseLogicalChannelAck: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - CloseLogicalChannelAck (%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - CloseLogicalChannelAck (%s, %s)\n", call->callType, call->callToken); break; case OORequestChannelClose: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - RequestChannelClose (%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - RequestChannelClose (%s, %s)\n", call->callType, call->callToken); /* Start RequestChannelClose timer */ cbData = (ooTimerCallback*) memAlloc(call->pctxt, sizeof(ooTimerCallback)); if(!cbData) { OOTRACEERR3("Error:Unable to allocate memory for timer callback data." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } cbData->call = call; cbData->timerType = OO_RCC_TIMER; cbData->channelNumber = associatedChan; if(!ooTimerCreate(call->pctxt, &call->timerList, &ooRequestChannelCloseTimerExpired, gH323ep.logicalChannelTimeout, cbData, FALSE)) { OOTRACEERR3("Error:Unable to create RequestChannelClose timer. " "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); return OO_FAILED; } break; case OORequestChannelCloseAck: if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) OOTRACEINFO3("Tunneled Message - RequestChannelCloseAck (%s, %s)\n", call->callType, call->callToken); else OOTRACEINFO3("Sent Message - RequestChannelCloseAck (%s, %s)\n", call->callType, call->callToken); break; default: ; } return OO_OK; } void ooStopMonitorCallChannels(OOH323CallData * call) { if (call->Monitor) call->Monitor = FALSE; /* if (call->cmdSock) ooCloseCallCmdConnection(call); */ } int ooStopMonitorCalls() { OOH323CallData * call; if(gMonitor) { OOTRACEINFO1("Doing ooStopMonitorCalls\n"); if(gH323ep.cmdSock) { ooCloseCmdConnection(); } if(gH323ep.callList) { OOTRACEWARN1("Warn:Abruptly ending calls as stack going down\n"); call = gH323ep.callList; while(call) { OOTRACEWARN3("Clearing call (%s, %s)\n", call->callType, call->callToken); call->callEndReason = OO_REASON_LOCAL_CLEARED; ooCleanCall(call); call = NULL; call = gH323ep.callList; } gH323ep.callList = NULL; } OOTRACEINFO1("Stopping listener for incoming calls\n"); if(gH323ep.listener) { ooSocketClose(*(gH323ep.listener)); memFreePtr(&gH323ep.ctxt, gH323ep.listener); gH323ep.listener = NULL; } gMonitor = FALSE; OOTRACEINFO1("Done ooStopMonitorCalls\n"); } return OO_OK; } OOBOOL ooChannelsIsConnectionOK(OOH323CallData *call, OOSOCKET sock) { struct timeval to = { .tv_usec = 500 }; struct pollfd pfds = { .fd = sock, .events = POLLIN }; int ret = 0; ret = ast_poll2(&pfds, 1, &to); if(ret == -1) { OOTRACEERR3("Error in select ...broken pipe check(%s, %s)\n", call->callType, call->callToken ); return FALSE; } if (pfds.events & POLLIN) { char buf[2]; if(ooSocketRecvPeek(sock, (ASN1OCTET*) buf, 2) == 0) { OOTRACEWARN3("Broken pipe detected. (%s, %s)", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEARED; return FALSE; } } return TRUE; } asterisk-11.7.0/addons/ooh323c/src/ooh323ep.c0000644000175000007640000006330712011000477020273 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #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; ast_mutex_t monitorLock; ast_mutex_t callListLock; ast_mutex_t newCallLock; ast_mutex_t bindPortLock; 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, "a"); 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; ast_mutex_init(&monitorLock); ast_mutex_init(&callListLock); ast_mutex_init(&newCallLock); ast_mutex_init(&bindPortLock); 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; } EXTERN void ooH323EpSetVersionInfo(int t35cc, int t35ext, int manc, char* prodid, char* verid) { if (t35cc) gH323ep.t35CountryCode = t35cc; if (t35ext) gH323ep.t35Extension = t35ext; if (manc) gH323ep.manufacturerCode = manc; if (prodid != NULL && prodid[0]) gH323ep.productID = prodid; if (verid != NULL && verid[0]) gH323ep.versionID = verid; } 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.onProgress = h323Callbacks.onProgress; 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; gH323ep.h323Callbacks.onModeChanged = h323Callbacks.onModeChanged; gH323ep.h323Callbacks.onMediaChanged = h323Callbacks.onMediaChanged; 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)); freeContext(&(gH323ep.msgctxt)); 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 ooH323EpTryBeMaster(int m) { if (m) OO_SETFLAG(gH323ep.flags, OO_M_TRYBEMASTER); else OO_CLRFLAG(gH323ep.flags, OO_M_TRYBEMASTER); 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 ooH323EpAddG726Capability(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 ooH323EpAddAMRNBCapability(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 ooH323EpAddSpeexCapability(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 ooH323EpEnableDTMFCISCO(int dynamicRTPPayloadType) { return ooCapabilityEnableDTMFCISCO(NULL, dynamicRTPPayloadType); } int ooH323EpDisableDTMFCISCO(void) { return ooCapabilityDisableDTMFCISCO(NULL); } 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 65500) gH323ep.udpPorts.max = 65500; else gH323ep.udpPorts.max = max; if(gH323ep.udpPorts.max 65500) gH323ep.rtpPorts.max = 65500; else gH323ep.rtpPorts.max = max; if(gH323ep.rtpPorts.maxpTypeMemHeap, 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); EXTERN void dListFindAndRemove(struct OOCTXT* pctxt, DList* pList, void* data); /** * @} */ #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/ooCommon.h0000644000175000007640000000657011274375744020551 0ustar sharkyjerryweb/* * 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 #include #include #include #ifdef _WIN32_WCE #include #elif defined(_WIN32) || defined(_WIN64) #include #define INCL_WINSOCK_API_TYPEDEFS 1 #define INCL_WINSOCK_API_PROTOTYPES 0 #include #else #include #include #include #include #include #include #include #endif #include /** * @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_ */ asterisk-11.7.0/addons/ooh323c/src/dlist.c0000644000175000007640000001535511655040762020066 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #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(struct OOCTXT* pctxt, 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); memFreePtr(pctxt, 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; } asterisk-11.7.0/addons/ooh323c/src/ooports.h0000644000175000007640000000517111222440006020435 0ustar sharkyjerryweb/* * 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 asterisk-11.7.0/addons/ooh323c/src/ooSocket.h0000644000175000007640000004005711551145466020541 0ustar sharkyjerryweb/* * 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_ #include "asterisk/poll-compat.h" #include "asterisk/compiler.h" #ifdef _WIN32_WCE #include #elif defined(_WIN32) || defined(_WIN64) #include #define INCL_WINSOCK_API_TYPEDEFS 1 #define INCL_WINSOCK_API_PROTOTYPES 0 #include #else #include #include "sys/time.h" #include #include #include #include #include #include #include #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; */ typedef struct ast_sockaddr 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, char* 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. * @param family Which family socket will created * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */ EXTERN int ooSocketCreate (OOSOCKET* psocket, int family); /** * 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, int family); /** * 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) attribute_deprecated; EXTERN int ooSocketPoll(struct pollfd *pfds, int nfds, int timeout); EXTERN int ooPDRead(struct pollfd *pfds, int nfds, int fd); EXTERN int ooPDWrite(struct pollfd *pfds, int nfds, int fd); /** * 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, unsigned 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, socklen_t *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. * @param family Pointer to integer in which IP family (4 or 6) will be returned * * @return ASN_OK, on success; -ve on failed. */ EXTERN int ooSocketGetIpAndPort(OOSOCKET socket, char *ip, int len, int *port, int *family); EXTERN int ooSocketGetInterfaceList(OOCTXT *pctxt, OOInterface **ifList); /** * @} */ #ifdef __cplusplus } #endif #endif /* _OOSOCKET_H_ */ asterisk-11.7.0/addons/ooh323c/src/ooper.h0000644000175000007640000000122711222440006020052 0ustar sharkyjerryweb/* * 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 asterisk-11.7.0/addons/ooh323c/src/ooports.c0000644000175000007640000000545711551145466020460 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "asterisk/netsock2.h" #include "asterisk/config.h" #include "ooports.h" #include "ooh323ep.h" #include "ootrace.h" /** Global endpoint structure */ extern OOH323EndPoint gH323ep; extern ast_mutex_t bindPortLock; /* 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; ast_mutex_lock(&bindPortLock); initialPort = ooGetNextPort (type); bindPort = initialPort; ret=ast_parse_arg(ip, PARSE_ADDR, &ipAddrs); while(1) { if((ret=ooSocketBind(socket, ipAddrs, bindPort))==0) { ast_mutex_unlock(&bindPortLock); return bindPort; } else { bindPort = ooGetNextPort (type); if (bindPort == initialPort) { ast_mutex_unlock(&bindPortLock); 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 asterisk-11.7.0/addons/ooh323c/src/ooh323.c0000644000175000007640000031035511775134255017766 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "asterisk/time.h" #include #include "ootypes.h" #include "ooq931.h" #include "ootrace.h" #include "oochannels.h" #include "ooh245.h" #include "ooCalls.h" #include "printHandler.h" #include "ooh323.h" #include "ooh323ep.h" #include "ooGkClient.h" #include "ooTimer.h" /** Global endpoint structure */ extern OOH323EndPoint gH323ep; int ooHandleFastStart(OOH323CallData *call, H225Facility_UUIE *facility); int ooOnReceivedReleaseComplete(OOH323CallData *call, Q931Message *q931Msg); int ooOnReceivedCallProceeding(OOH323CallData *call, Q931Message *q931Msg); int ooOnReceivedAlerting(OOH323CallData *call, Q931Message *q931Msg); int ooOnReceivedProgress(OOH323CallData *call, Q931Message *q931Msg); int ooHandleDisplayIE(OOH323CallData *call, Q931Message *q931Msg); int ooHandleH2250ID (OOH323CallData *call, H225ProtocolIdentifier* protocolIdentifier); int ooHandleDisplayIE(OOH323CallData *call, Q931Message *q931Msg) { Q931InformationElement* pDisplayIE; /* check for display ie */ pDisplayIE = ooQ931GetIE(q931Msg, Q931DisplayIE); if(pDisplayIE) { if (call->remoteDisplayName) memFreePtr(call->pctxt, call->remoteDisplayName); call->remoteDisplayName = (char *) memAllocZ(call->pctxt, pDisplayIE->length*sizeof(ASN1OCTET)+1); strncpy(call->remoteDisplayName, (char *)pDisplayIE->data, pDisplayIE->length*sizeof(ASN1OCTET)); } return OO_OK; } int ooHandleH2250ID (OOH323CallData *call, H225ProtocolIdentifier* protocolIdentifier) { if (!call->h225version && (protocolIdentifier->numids >= 6) && (protocolIdentifier->subid[3] == 2250)) { call->h225version = protocolIdentifier->subid[5]; OOTRACEDBGC4("Extract H.225 remote version, it's %d, (%s, %s)\n", call->h225version, call->callType, call->callToken); } return OO_OK; } int ooHandleFastStart(OOH323CallData *call, H225Facility_UUIE *facility) { H245OpenLogicalChannel* olc; ASN1OCTET msgbuf[MAXMSGLEN]; ooLogicalChannel * pChannel = NULL; H245H2250LogicalChannelParameters * h2250lcp = NULL; int i=0, ret=0; /* Handle fast-start */ if(OO_TESTFLAG (call->flags, OO_M_FASTSTART)) { if(facility->m.fastStartPresent) { /* For printing the decoded message to log, initialize handler. */ initializePrintHandler(&printHandler, "FastStart Elements"); /* Set print handler */ setEventHandler (call->pctxt, &printHandler); for(i=0; i<(int)facility->fastStart.n; i++) { olc = NULL; olc = (H245OpenLogicalChannel*)memAlloc(call->pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooHandleFastStart - olc" "(%s, %s)\n", call->callType, call->callToken); /*Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); memcpy(msgbuf, facility->fastStart.elem[i].data, facility->fastStart.elem[i].numocts); setPERBuffer(call->pctxt, msgbuf, facility->fastStart.elem[i].numocts, 1); ret = asn1PD_H245OpenLogicalChannel(call->pctxt, olc); if(ret != ASN_OK) { OOTRACEERR3("ERROR:Failed to decode fast start olc element " "(%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } dListAppend(call->pctxt, &call->remoteFastStartOLCs, olc); pChannel = ooFindLogicalChannelByOLC(call, olc); if(!pChannel) { OOTRACEERR4("ERROR: Logical Channel %d not found, fast start. " "(%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(pChannel->channelNo != olc->forwardLogicalChannelNumber) { OOTRACEINFO5("Remote endpoint changed forwardLogicalChannel" "Number from %d to %d (%s, %s)\n", pChannel->channelNo, olc->forwardLogicalChannelNumber, call->callType, call->callToken); pChannel->channelNo = olc->forwardLogicalChannelNumber; } if(!strcmp(pChannel->dir, "transmit")) { if(olc->forwardLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for " "channel %d (%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); continue; } /* Extract the remote media endpoint address */ h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; if(!h2250lcp) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "forward Logical Channel Parameters found. " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!h2250lcp->m.mediaChannelPresent) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "reverse media channel information found." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ret = ooGetIpPortFromH245TransportAddress(call, &h2250lcp->mediaChannel, pChannel->remoteIP, &pChannel->remoteMediaPort); if(ret != OO_OK) { if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } OOTRACEERR3("ERROR:Unsupported media channel address type " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!pChannel->chanCap->startTransmitChannel) { OOTRACEERR3("ERROR:No callback registered to start transmit " "channel (%s, %s)\n",call->callType, call->callToken); return OO_FAILED; } pChannel->chanCap->startTransmitChannel(call, pChannel); } /* Mark the current channel as established and close all other logical channels with same session id and in same direction. */ ooOnLogicalChannelEstablished(call, pChannel); } finishPrint(); removeEventHandler(call->pctxt); OO_SETFLAG(call->flags, OO_M_FASTSTARTANSWERED); } } if(facility->m.h245AddressPresent) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call as H245 address is " "provided in facility message (%s, %s)\n", call->callType, call->callToken); } ret = ooH323GetIpPortFromH225TransportAddress(call, &facility->h245Address, call->remoteIP, &call->remoteH245Port); if(ret != OO_OK) { OOTRACEERR3("Error: Unknown H245 address type in received " "Facility message (%s, %s)", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } if(call->remoteH245Port != 0 && !call->pH245Channel) { /* Create an H.245 connection. */ if(ooCreateH245Connection(call)== OO_FAILED) { OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } } } else if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { if (call->h225version >= 4) { ret =ooSendTCSandMSD(call); } if (ret != OO_OK) return ret; } return OO_OK; } int ooOnReceivedReleaseComplete(OOH323CallData *call, Q931Message *q931Msg) { int ret = OO_OK; H225ReleaseComplete_UUIE * releaseComplete = NULL; ASN1UINT i; DListNode *pNode = NULL; OOTimer *pTimer = NULL; unsigned reasonCode=T_H225ReleaseCompleteReason_undefinedReason; enum Q931CauseValues cause= Q931ErrorInCauseIE; if(q931Msg->causeIE) { cause = q931Msg->causeIE->data[1]; /* Get rid of the extension bit.For more info, check ooQ931SetCauseIE */ cause = cause & 0x7f; OOTRACEDBGA4("Cause of Release Complete is %x. (%s, %s)\n", cause, call->callType, call->callToken); } /* Remove session timer, if active*/ for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_SESSION_TIMER) { memFreePtr(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted Session Timer. (%s, %s)\n", call->callType, call->callToken); break; } } if(!q931Msg->userInfo) { OOTRACEERR3("ERROR:No User-User IE in received ReleaseComplete message " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } releaseComplete = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.releaseComplete; if(!releaseComplete) { OOTRACEWARN3("WARN: ReleaseComplete UUIE not found in received " "ReleaseComplete message - %s " "%s\n", call->callType, call->callToken); } else{ if(releaseComplete->m.reasonPresent) { OOTRACEINFO4("Release complete reason code %d. (%s, %s)\n", releaseComplete->reason.t, call->callType, call->callToken); reasonCode = releaseComplete->reason.t; } } if(call->callEndReason == OO_REASON_UNKNOWN) call->callEndReason = ooGetCallClearReasonFromCauseAndReasonCode(cause, reasonCode); call->q931cause = cause; #if 0 if (q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && q931Msg->userInfo->h323_uu_pdu.h245Tunneling && OO_TESTFLAG (call->flags, OO_M_TUNNELING) ) { OOTRACEDBGB3("Handling tunneled messages in ReleaseComplete. (%s, %s)\n", call->callType, call->callToken); ret = ooHandleTunneledH245Messages (call, &q931Msg->userInfo->h323_uu_pdu); OOTRACEDBGB3("Finished handling tunneled messages in ReleaseComplete." " (%s, %s)\n", call->callType, call->callToken); } #endif if(call->h245SessionState != OO_H245SESSION_IDLE && call->h245SessionState != OO_H245SESSION_CLOSED) { ooCloseH245Connection(call); } if(call->callState != OO_CALL_CLEAR_RELEASESENT) { if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) { if(gH323ep.gkClient->state == GkClientRegistered){ OOTRACEDBGA3("Sending DRQ after received ReleaseComplete." "(%s, %s)\n", call->callType, call->callToken); ooGkClientSendDisengageRequest(gH323ep.gkClient, call); } } } call->callState = OO_CALL_CLEARED; return ret; } int ooOnReceivedSetup(OOH323CallData *call, Q931Message *q931Msg) { H225Setup_UUIE *setup=NULL; int i=0, ret=0; H245OpenLogicalChannel* olc; ASN1OCTET msgbuf[MAXMSGLEN]; H225TransportAddress_ipAddress_ip *ip = NULL; H225TransportAddress_ip6Address_ip *ip6 = NULL; Q931InformationElement* pDisplayIE=NULL; OOAliases *pAlias=NULL; char remoteIP[2+8*4+7] = ""; call->callReference = q931Msg->callReference; if(!q931Msg->userInfo) { OOTRACEERR3("ERROR:No User-User IE in received SETUP message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } setup = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.setup; if(!setup) { OOTRACEERR3("Error: Setup UUIE not found in received setup message - %s " "%s\n", call->callType, call->callToken); return OO_FAILED; } ooHandleH2250ID(call, &setup->protocolIdentifier); memcpy(call->callIdentifier.guid.data, setup->callIdentifier.guid.data, setup->callIdentifier.guid.numocts); call->callIdentifier.guid.numocts = setup->callIdentifier.guid.numocts; memcpy(call->confIdentifier.data, setup->conferenceID.data, setup->conferenceID.numocts); call->confIdentifier.numocts = setup->conferenceID.numocts; /* check for display ie */ pDisplayIE = ooQ931GetIE(q931Msg, Q931DisplayIE); if(pDisplayIE) { call->remoteDisplayName = (char *) memAllocZ(call->pctxt, pDisplayIE->length*sizeof(ASN1OCTET)+1); strncpy(call->remoteDisplayName, (char *)pDisplayIE->data, pDisplayIE->length*sizeof(ASN1OCTET)); } /*Extract Remote Aliases, if present*/ if(setup->m.sourceAddressPresent) { if(setup->sourceAddress.count>0) { ooH323RetrieveAliases(call, &setup->sourceAddress, &call->remoteAliases); pAlias = call->remoteAliases; while(pAlias) { if(pAlias->type == T_H225AliasAddress_dialedDigits) { if(!call->callingPartyNumber) { call->callingPartyNumber = (char*)memAlloc(call->pctxt, strlen(pAlias->value)*+1); if(call->callingPartyNumber) { strcpy(call->callingPartyNumber, pAlias->value); } } break; } pAlias = pAlias->next; } } } /* Extract, aliases used for us, if present. Also, Populate calledPartyNumber from dialedDigits, if not yet populated using calledPartyNumber Q931 IE. */ if(setup->m.destinationAddressPresent) { if(setup->destinationAddress.count>0) { ooH323RetrieveAliases(call, &setup->destinationAddress, &call->ourAliases); pAlias = call->ourAliases; while(pAlias) { if(pAlias->type == T_H225AliasAddress_dialedDigits) { if(!call->calledPartyNumber) { call->calledPartyNumber = (char*)memAlloc(call->pctxt, strlen(pAlias->value)*+1); if(call->calledPartyNumber) { strcpy(call->calledPartyNumber, pAlias->value); } } break; } pAlias = pAlias->next; } } } /* Check for tunneling */ if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent) { /* Tunneling enabled only when tunneling is set to true and h245 address is absent. In the presence of H.245 address in received SETUP message, tunneling is disabled, irrespective of tunneling flag in the setup message*/ if(q931Msg->userInfo->h323_uu_pdu.h245Tunneling && !setup->m.h245AddressPresent) { if(OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING)) { OO_SETFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Call has tunneling active (%s,%s)\n", call->callType, call->callToken); } else OOTRACEINFO3("ERROR:Remote endpoint wants to use h245Tunneling, " "local endpoint has it disabled (%s,%s)\n", call->callType, call->callToken); } else { if(OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING)) { OOTRACEINFO3("Tunneling disabled by remote endpoint. (%s, %s)\n", call->callType, call->callToken); } OO_CLRFLAG (call->flags, OO_M_TUNNELING); } } else { if(OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING)) { OOTRACEINFO3("Tunneling disabled by remote endpoint. (%s, %s)\n", call->callType, call->callToken); } OO_CLRFLAG (call->flags, OO_M_TUNNELING); } /* Extract Remote IP address */ if(!setup->m.sourceCallSignalAddressPresent) { OOTRACEWARN3("WARNING:Missing source call signal address in received " "setup (%s, %s)\n", call->callType, call->callToken); } else{ if(setup->sourceCallSignalAddress.t == T_H225TransportAddress_ip6Address) { ip6 = &setup->sourceCallSignalAddress.u.ip6Address->ip; inet_ntop(AF_INET6, ip6->data, remoteIP, INET6_ADDRSTRLEN); call->remotePort = setup->sourceCallSignalAddress.u.ip6Address->port; } else if(setup->sourceCallSignalAddress.t == T_H225TransportAddress_ipAddress) { ip = &setup->sourceCallSignalAddress.u.ipAddress->ip; sprintf(remoteIP, "%d.%d.%d.%d", ip->data[0], ip->data[1], ip->data[2], ip->data[3]); call->remotePort = setup->sourceCallSignalAddress.u.ipAddress->port; } else { OOTRACEERR3("ERROR: Source call signalling address type not ip4 nor ip6 " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } } if (strncmp(remoteIP, call->remoteIP, strlen(remoteIP))) { OOTRACEERR5("ERROR: Security denial remote sig IP isn't a socket ip, %s not %s " "(%s, %s)\n", remoteIP, call->remoteIP, call->callType, call->callToken); return OO_FAILED; } /* check for fast start */ if(setup->m.fastStartPresent) { if(!OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART)) { OOTRACEINFO3("Local endpoint does not support fastStart. Ignoring " "fastStart. (%s, %s)\n", call->callType, call->callToken); OO_CLRFLAG (call->flags, OO_M_FASTSTART); } else if(setup->fastStart.n == 0) { OOTRACEINFO3("Empty faststart element received. Ignoring fast start. " "(%s, %s)\n", call->callType, call->callToken); OO_CLRFLAG (call->flags, OO_M_FASTSTART); } else{ OO_SETFLAG (call->flags, OO_M_FASTSTART); OOTRACEINFO3("FastStart enabled for call(%s, %s)\n", call->callType, call->callToken); } } if (OO_TESTFLAG (call->flags, OO_M_FASTSTART)) { /* For printing the decoded message to log, initialize handler. */ initializePrintHandler(&printHandler, "FastStart Elements"); /* Set print handler */ setEventHandler (call->pctxt, &printHandler); for(i=0; i<(int)setup->fastStart.n; i++) { olc = NULL; /* memset(msgbuf, 0, sizeof(msgbuf));*/ olc = (H245OpenLogicalChannel*)memAlloc(call->pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooOnReceivedSetup - olc (%s, %s)\n", call->callType, call->callToken); /*Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); memcpy(msgbuf, setup->fastStart.elem[i].data, setup->fastStart.elem[i].numocts); setPERBuffer(call->pctxt, msgbuf, setup->fastStart.elem[i].numocts, 1); ret = asn1PD_H245OpenLogicalChannel(call->pctxt, olc); if(ret != ASN_OK) { OOTRACEERR3("ERROR:Failed to decode fast start olc element " "(%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } /* For now, just add decoded fast start elemts to list. This list will be processed at the time of sending CONNECT message. */ dListAppend(call->pctxt, &call->remoteFastStartOLCs, olc); } finishPrint(); removeEventHandler(call->pctxt); } return OO_OK; } int ooOnReceivedCallProceeding(OOH323CallData *call, Q931Message *q931Msg) { H225CallProceeding_UUIE *callProceeding=NULL; H245OpenLogicalChannel* olc; ASN1OCTET msgbuf[MAXMSGLEN]; ooLogicalChannel * pChannel = NULL; H245H2250LogicalChannelParameters * h2250lcp = NULL; int i=0, ret=0; if(!q931Msg->userInfo) { OOTRACEERR3("ERROR:No User-User IE in received CallProceeding message." " (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } callProceeding = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.callProceeding; if(callProceeding == NULL) { OOTRACEERR3("Error: Received CallProceeding message does not have " "CallProceeding UUIE (%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } ooHandleH2250ID(call, &callProceeding->protocolIdentifier); /* Handle fast-start */ if(OO_TESTFLAG (call->flags, OO_M_FASTSTART)) { if(callProceeding->m.fastStartPresent) { /* For printing the decoded message to log, initialize handler. */ initializePrintHandler(&printHandler, "FastStart Elements"); /* Set print handler */ setEventHandler (call->pctxt, &printHandler); for(i=0; i<(int)callProceeding->fastStart.n; i++) { olc = NULL; olc = (H245OpenLogicalChannel*)memAlloc(call->pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooOnReceivedCallProceeding - olc" "(%s, %s)\n", call->callType, call->callToken); /*Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); memcpy(msgbuf, callProceeding->fastStart.elem[i].data, callProceeding->fastStart.elem[i].numocts); setPERBuffer(call->pctxt, msgbuf, callProceeding->fastStart.elem[i].numocts, 1); ret = asn1PD_H245OpenLogicalChannel(call->pctxt, olc); if(ret != ASN_OK) { OOTRACEERR3("ERROR:Failed to decode fast start olc element " "(%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } dListAppend(call->pctxt, &call->remoteFastStartOLCs, olc); pChannel = ooFindLogicalChannelByOLC(call, olc); if(!pChannel) { OOTRACEERR4("ERROR: Logical Channel %d not found, fast start. " "(%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(pChannel->channelNo != olc->forwardLogicalChannelNumber) { OOTRACEINFO5("Remote endpoint changed forwardLogicalChannel" "Number from %d to %d (%s, %s)\n", pChannel->channelNo, olc->forwardLogicalChannelNumber, call->callType, call->callToken); pChannel->channelNo = olc->forwardLogicalChannelNumber; } if(!strcmp(pChannel->dir, "transmit")) { if(olc->forwardLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for " "channel %d (%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); continue; } /* Extract the remote media endpoint address */ h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; if(!h2250lcp) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "forward Logical Channel Parameters found. " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!h2250lcp->m.mediaChannelPresent) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "reverse media channel information found." "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } ret = ooGetIpPortFromH245TransportAddress(call, &h2250lcp->mediaChannel, pChannel->remoteIP, &pChannel->remoteMediaPort); if(ret != OO_OK) { if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } OOTRACEERR3("ERROR:Unsupported media channel address type " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!pChannel->chanCap->startTransmitChannel) { OOTRACEERR3("ERROR:No callback registered to start transmit " "channel (%s, %s)\n",call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } pChannel->chanCap->startTransmitChannel(call, pChannel); } /* Mark the current channel as established and close all other logical channels with same session id and in same direction. */ ooOnLogicalChannelEstablished(call, pChannel); } finishPrint(); removeEventHandler(call->pctxt); OO_SETFLAG(call->flags, OO_M_FASTSTARTANSWERED); } } /* Retrieve tunneling info/H.245 control channel address from the connect msg */ if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && !q931Msg->userInfo->h323_uu_pdu.h245Tunneling) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call due to remote reject tunneling" " (%s, %s)\n", call->callType, call->callToken); } } if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && q931Msg->userInfo->h323_uu_pdu.h245Tunneling && OO_TESTFLAG (call->flags, OO_M_TUNNELING) && callProceeding->m.h245AddressPresent) { OOTRACEINFO3("Tunneling and h245address provided." "Using Tunneling for H.245 messages (%s, %s)\n", call->callType, call->callToken); } else if(callProceeding->m.h245AddressPresent) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call as H245 address is " "provided in callProceeding message (%s, %s)\n", call->callType, call->callToken); } ret = ooH323GetIpPortFromH225TransportAddress(call, &callProceeding->h245Address, call->remoteIP, &call->remoteH245Port); if(ret != OO_OK) { OOTRACEERR3("Error: Unknown H245 address type in received " "CallProceeding message (%s, %s)", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } if(call->remoteH245Port != 0 && !call->pH245Channel) { /* Create an H.245 connection. */ if(ooCreateH245Connection(call)== OO_FAILED) { OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } } } return OO_OK; } int ooOnReceivedAlerting(OOH323CallData *call, Q931Message *q931Msg) { H225Alerting_UUIE *alerting=NULL; H245OpenLogicalChannel* olc; ASN1OCTET msgbuf[MAXMSGLEN]; ooLogicalChannel * pChannel = NULL; H245H2250LogicalChannelParameters * h2250lcp = NULL; int i=0, ret=0; ooHandleDisplayIE(call, q931Msg); if(!q931Msg->userInfo) { OOTRACEERR3("ERROR:No User-User IE in received Alerting message." " (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } alerting = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.alerting; if(alerting == NULL) { OOTRACEERR3("Error: Received Alerting message does not have " "alerting UUIE (%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } ooHandleH2250ID(call, &alerting->protocolIdentifier); /*Handle fast-start */ if(OO_TESTFLAG (call->flags, OO_M_FASTSTART) && !OO_TESTFLAG(call->flags, OO_M_FASTSTARTANSWERED)) { if(alerting->m.fastStartPresent) { /* For printing the decoded message to log, initialize handler. */ initializePrintHandler(&printHandler, "FastStart Elements"); /* Set print handler */ setEventHandler (call->pctxt, &printHandler); for(i=0; i<(int)alerting->fastStart.n; i++) { olc = NULL; olc = (H245OpenLogicalChannel*)memAlloc(call->pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooOnReceivedAlerting - olc" "(%s, %s)\n", call->callType, call->callToken); /*Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); memcpy(msgbuf, alerting->fastStart.elem[i].data, alerting->fastStart.elem[i].numocts); setPERBuffer(call->pctxt, msgbuf, alerting->fastStart.elem[i].numocts, 1); ret = asn1PD_H245OpenLogicalChannel(call->pctxt, olc); if(ret != ASN_OK) { OOTRACEERR3("ERROR:Failed to decode fast start olc element " "(%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } dListAppend(call->pctxt, &call->remoteFastStartOLCs, olc); pChannel = ooFindLogicalChannelByOLC(call, olc); if(!pChannel) { OOTRACEERR4("ERROR: Logical Channel %d not found, fast start. " "(%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(pChannel->channelNo != olc->forwardLogicalChannelNumber) { OOTRACEINFO5("Remote endpoint changed forwardLogicalChannel" "Number from %d to %d (%s, %s)\n", pChannel->channelNo, olc->forwardLogicalChannelNumber, call->callType, call->callToken); pChannel->channelNo = olc->forwardLogicalChannelNumber; } if(!strcmp(pChannel->dir, "transmit")) { if(olc->forwardLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for " "channel %d (%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); continue; } /* Extract the remote media endpoint address */ h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; if(!h2250lcp) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "forward Logical Channel Parameters found. " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!h2250lcp->m.mediaChannelPresent) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "reverse media channel information found." "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } ret = ooGetIpPortFromH245TransportAddress(call, &h2250lcp->mediaChannel, pChannel->remoteIP, &pChannel->remoteMediaPort); if(ret != OO_OK) { if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } OOTRACEERR3("ERROR:Unsupported media channel address type " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if(!pChannel->chanCap->startTransmitChannel) { OOTRACEERR3("ERROR:No callback registered to start transmit " "channel (%s, %s)\n",call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } pChannel->chanCap->startTransmitChannel(call, pChannel); /* Mark the current channel as established and close all other logical channels with same session id and in same direction. */ ooOnLogicalChannelEstablished(call, pChannel); } } finishPrint(); removeEventHandler(call->pctxt); OO_SETFLAG(call->flags, OO_M_FASTSTARTANSWERED); } } /* Retrieve tunneling info/H.245 control channel address from the connect msg */ if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && !q931Msg->userInfo->h323_uu_pdu.h245Tunneling) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call due to remote reject tunneling" " (%s, %s)\n", call->callType, call->callToken); } } if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && q931Msg->userInfo->h323_uu_pdu.h245Tunneling && OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { if (alerting->m.h245AddressPresent) OOTRACEINFO3("Tunneling and h245address provided." "Giving preference to Tunneling (%s, %s)\n", call->callType, call->callToken); if (call->h225version >= 4) { ret =ooSendTCSandMSD(call); } if (ret != OO_OK) return ret; } else if(alerting->m.h245AddressPresent) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call as H245 address is " "provided in Alerting message (%s, %s)\n", call->callType, call->callToken); } ret = ooH323GetIpPortFromH225TransportAddress(call, &alerting->h245Address, call->remoteIP, &call->remoteH245Port); if(ret != OO_OK) { OOTRACEERR3("Error: Unknown H245 address type in received " "Alerting message (%s, %s)", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } if(call->remoteH245Port != 0 && !call->pH245Channel) { /* Create an H.245 connection. */ if(ooCreateH245Connection(call)== OO_FAILED) { OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } else { if (call->h225version >= 4) { ret =ooSendTCSandMSD(call); } } } } return OO_OK; } int ooOnReceivedProgress(OOH323CallData *call, Q931Message *q931Msg) { H225Progress_UUIE *progress=NULL; H245OpenLogicalChannel* olc; ASN1OCTET msgbuf[MAXMSGLEN]; ooLogicalChannel * pChannel = NULL; H245H2250LogicalChannelParameters * h2250lcp = NULL; int i=0, ret=0; ooHandleDisplayIE(call, q931Msg); if(!q931Msg->userInfo) { OOTRACEERR3("ERROR:No User-User IE in received Progress message." " (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } progress = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.progress; if(progress == NULL) { OOTRACEERR3("Error: Received Progress message does not have " "progress UUIE (%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } ooHandleH2250ID(call, &progress->protocolIdentifier); /*Handle fast-start */ if(OO_TESTFLAG (call->flags, OO_M_FASTSTART) && !OO_TESTFLAG(call->flags, OO_M_FASTSTARTANSWERED)) { if(progress->m.fastStartPresent) { /* For printing the decoded message to log, initialize handler. */ initializePrintHandler(&printHandler, "FastStart Elements"); /* Set print handler */ setEventHandler (call->pctxt, &printHandler); for(i=0; i<(int)progress->fastStart.n; i++) { olc = NULL; olc = (H245OpenLogicalChannel*)memAlloc(call->pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooOnReceivedProgress - olc" "(%s, %s)\n", call->callType, call->callToken); /*Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); memcpy(msgbuf, progress->fastStart.elem[i].data, progress->fastStart.elem[i].numocts); setPERBuffer(call->pctxt, msgbuf, progress->fastStart.elem[i].numocts, 1); ret = asn1PD_H245OpenLogicalChannel(call->pctxt, olc); if(ret != ASN_OK) { OOTRACEERR3("ERROR:Failed to decode fast start olc element " "(%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } dListAppend(call->pctxt, &call->remoteFastStartOLCs, olc); pChannel = ooFindLogicalChannelByOLC(call, olc); if(!pChannel) { OOTRACEERR4("ERROR: Logical Channel %d not found, fast start. " "(%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(pChannel->channelNo != olc->forwardLogicalChannelNumber) { OOTRACEINFO5("Remote endpoint changed forwardLogicalChannel" "Number from %d to %d (%s, %s)\n", pChannel->channelNo, olc->forwardLogicalChannelNumber, call->callType, call->callToken); pChannel->channelNo = olc->forwardLogicalChannelNumber; } if(!strcmp(pChannel->dir, "transmit")) { if(olc->forwardLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for " "channel %d (%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); continue; } /* Extract the remote media endpoint address */ h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; if(!h2250lcp) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "forward Logical Channel Parameters found. " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!h2250lcp->m.mediaChannelPresent) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "reverse media channel information found." "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } ret = ooGetIpPortFromH245TransportAddress(call, &h2250lcp->mediaChannel, pChannel->remoteIP, &pChannel->remoteMediaPort); if(ret != OO_OK) { if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } OOTRACEERR3("ERROR:Unsupported media channel address type " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!pChannel->chanCap->startTransmitChannel) { OOTRACEERR3("ERROR:No callback registered to start transmit " "channel (%s, %s)\n",call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } pChannel->chanCap->startTransmitChannel(call, pChannel); } /* Mark the current channel as established and close all other logical channels with same session id and in same direction. */ ooOnLogicalChannelEstablished(call, pChannel); } finishPrint(); removeEventHandler(call->pctxt); OO_SETFLAG(call->flags, OO_M_FASTSTARTANSWERED); } } /* Retrieve the H.245 control channel address from the connect msg */ /* Retrieve tunneling info/H.245 control channel address from the connect msg */ if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && !q931Msg->userInfo->h323_uu_pdu.h245Tunneling) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call due to remote reject tunneling" " (%s, %s)\n", call->callType, call->callToken); } } if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && q931Msg->userInfo->h323_uu_pdu.h245Tunneling && OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { if (progress->m.h245AddressPresent) OOTRACEINFO3("Tunneling and h245address provided." "Giving preference to Tunneling (%s, %s)\n", call->callType, call->callToken); if (call->h225version >= 4) { ret =ooSendTCSandMSD(call); } if (ret != OO_OK) return ret; } else if(progress->m.h245AddressPresent) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call as H245 address is " "provided in Progress message (%s, %s)\n", call->callType, call->callToken); } ret = ooH323GetIpPortFromH225TransportAddress(call, &progress->h245Address, call->remoteIP, &call->remoteH245Port); if(ret != OO_OK) { OOTRACEERR3("Error: Unknown H245 address type in received " "Progress message (%s, %s)", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } if(call->remoteH245Port != 0 && !call->pH245Channel) { /* Create an H.245 connection. */ if(ooCreateH245Connection(call)== OO_FAILED) { OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } else { if (call->h225version >= 4) { ret =ooSendTCSandMSD(call); } } } } return OO_OK; } int ooOnReceivedSignalConnect(OOH323CallData* call, Q931Message *q931Msg) { int ret, i; H225Connect_UUIE *connect; H245OpenLogicalChannel* olc; ASN1OCTET msgbuf[MAXMSGLEN]; ooLogicalChannel * pChannel = NULL; H245H2250LogicalChannelParameters * h2250lcp = NULL; ooHandleDisplayIE(call, q931Msg); if(!q931Msg->userInfo) { OOTRACEERR3("Error: UUIE not found in received H.225 Connect message" " (%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } /* Retrieve the connect message from the user-user IE & Q.931 header */ connect = q931Msg->userInfo->h323_uu_pdu.h323_message_body.u.connect; if(connect == NULL) { OOTRACEERR3("Error: Received Connect message does not have Connect UUIE" " (%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } ooHandleH2250ID(call, &connect->protocolIdentifier); /*Handle fast-start */ if(OO_TESTFLAG (call->flags, OO_M_FASTSTART) && !OO_TESTFLAG (call->flags, OO_M_FASTSTARTANSWERED)) { if(!connect->m.fastStartPresent) { OOTRACEINFO3("Remote endpoint has rejected fastStart. (%s, %s)\n", call->callType, call->callToken); OO_CLRFLAG (call->flags, OO_M_FASTSTART); } } if (connect->m.fastStartPresent && !OO_TESTFLAG(call->flags, OO_M_FASTSTARTANSWERED)) { /* For printing the decoded message to log, initialize handler. */ initializePrintHandler(&printHandler, "FastStart Elements"); /* Set print handler */ setEventHandler (call->pctxt, &printHandler); for(i=0; i<(int)connect->fastStart.n; i++) { olc = NULL; /* memset(msgbuf, 0, sizeof(msgbuf));*/ olc = (H245OpenLogicalChannel*)memAlloc(call->pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooOnReceivedSignalConnect - olc" "(%s, %s)\n", call->callType, call->callToken); /*Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); memcpy(msgbuf, connect->fastStart.elem[i].data, connect->fastStart.elem[i].numocts); setPERBuffer(call->pctxt, msgbuf, connect->fastStart.elem[i].numocts, 1); ret = asn1PD_H245OpenLogicalChannel(call->pctxt, olc); if(ret != ASN_OK) { OOTRACEERR3("ERROR:Failed to decode fast start olc element " "(%s, %s)\n", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } dListAppend(call->pctxt, &call->remoteFastStartOLCs, olc); pChannel = ooFindLogicalChannelByOLC(call, olc); if(!pChannel) { OOTRACEERR4("ERROR: Logical Channel %d not found, fasts start " "answered. (%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(pChannel->channelNo != olc->forwardLogicalChannelNumber) { OOTRACEINFO5("Remote endpoint changed forwardLogicalChannelNumber" "from %d to %d (%s, %s)\n", pChannel->channelNo, olc->forwardLogicalChannelNumber, call->callType, call->callToken); pChannel->channelNo = olc->forwardLogicalChannelNumber; } if(!strcmp(pChannel->dir, "transmit")) { if(olc->forwardLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for channel" " %d (%s, %s)\n", olc->forwardLogicalChannelNumber, call->callType, call->callToken); continue; } /* Extract the remote media endpoint address */ h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; if(!h2250lcp) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "forward Logical Channel Parameters found. (%s, %s)" "\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!h2250lcp->m.mediaChannelPresent) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "reverse media channel information found. (%s, %s)" "\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } ret = ooGetIpPortFromH245TransportAddress(call, &h2250lcp->mediaChannel, pChannel->remoteIP, &pChannel->remoteMediaPort); if(ret != OO_OK) { if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } OOTRACEERR3("ERROR:Unsupported media channel address type " "(%s, %s)\n", call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } if(!pChannel->chanCap->startTransmitChannel) { OOTRACEERR3("ERROR:No callback registered to start transmit " "channel (%s, %s)\n",call->callType, call->callToken); finishPrint(); removeEventHandler(call->pctxt); return OO_FAILED; } pChannel->chanCap->startTransmitChannel(call, pChannel); } /* Mark the current channel as established and close all other logical channels with same session id and in same direction. */ ooOnLogicalChannelEstablished(call, pChannel); } finishPrint(); removeEventHandler(call->pctxt); OO_SETFLAG(call->flags, OO_M_FASTSTARTANSWERED); } /* Retrieve tunneling info/H.245 control channel address from the connect msg */ if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && !q931Msg->userInfo->h323_uu_pdu.h245Tunneling) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call due to remote reject tunneling" " (%s, %s)\n", call->callType, call->callToken); } } if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent && q931Msg->userInfo->h323_uu_pdu.h245Tunneling && OO_TESTFLAG (call->flags, OO_M_TUNNELING) && connect->m.h245AddressPresent) { OOTRACEINFO3("Tunneling and h245address provided." "Giving preference to Tunneling (%s, %s)\n", call->callType, call->callToken); } else if(connect->m.h245AddressPresent) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled for call as H245 address is " "provided in connect message (%s, %s)\n", call->callType, call->callToken); } ret = ooH323GetIpPortFromH225TransportAddress(call, &connect->h245Address, call->remoteIP, &call->remoteH245Port); if(ret != OO_OK) { OOTRACEERR3("Error: Unknown H245 address type in received Connect " "message (%s, %s)", call->callType, call->callToken); /* Mark call for clearing */ if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_INVALIDMESSAGE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } } if(call->remoteH245Port != 0 && !call->pH245Channel) { /* Create an H.245 connection. */ if(ooCreateH245Connection(call)== OO_FAILED) { OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_TRANSPORTFAILURE; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } } if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent) { if (!q931Msg->userInfo->h323_uu_pdu.h245Tunneling) { if (OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OO_CLRFLAG (call->flags, OO_M_TUNNELING); OOTRACEINFO3("Tunneling is disabled by remote endpoint.(%s, %s)\n", call->callType, call->callToken); } } } if (OO_TESTFLAG(call->flags, OO_M_TUNNELING)) { OOTRACEDBGB3("Handling tunneled messages in CONNECT. (%s, %s)\n", call->callType, call->callToken); ret = ooHandleTunneledH245Messages (call, &q931Msg->userInfo->h323_uu_pdu); OOTRACEDBGB3("Finished tunneled messages in Connect. (%s, %s)\n", call->callType, call->callToken); } /* Send TCS as call established and no capability exchange has yet started. This will be true only when separate h245 connection is not established and tunneling is being used. */ if(call->localTermCapState == OO_LocalTermCapExchange_Idle) { /*Start terminal capability exchange and master slave determination */ ret = ooSendTermCapMsg(call); if(ret != OO_OK) { OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n", call->callType, call->callToken); return ret; } } call->callState = OO_CALL_CONNECTED; if (call->rtdrCount > 0 && call->rtdrInterval > 0) { return ooSendRoundTripDelayRequest(call); } return OO_OK; } int ooHandleH2250Message(OOH323CallData *call, Q931Message *q931Msg) { int ret=OO_OK; ASN1UINT i; DListNode *pNode = NULL; OOTimer *pTimer=NULL; int type = q931Msg->messageType; struct timeval tv; struct timespec ts; /* checking of message validity for first/next messages of calls */ if (!strcmp(call->callType, "incoming")) { if ((call->callState != OO_CALL_CREATED && type == Q931SetupMsg) || (call->callState == OO_CALL_CREATED && type != Q931SetupMsg)) { ooFreeQ931Message(call->msgctxt, q931Msg); return OO_FAILED; } } switch(type) { case Q931SetupMsg: /* SETUP message is received */ OOTRACEINFO3("Received SETUP message (%s, %s)\n", call->callType, call->callToken); ret = ooOnReceivedSetup(call, q931Msg); if (ret != OO_OK) { call->callState = OO_CALL_CLEAR; } else { /* H225 message callback */ if(gH323ep.h225Callbacks.onReceivedSetup) ret = gH323ep.h225Callbacks.onReceivedSetup(call, q931Msg); } /* Free up the mem used by the received message, as it's processing is done. */ if (ret == OO_OK) { ooFreeQ931Message(call->msgctxt, q931Msg); /* 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 */ if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) { if(gH323ep.gkClient->state == GkClientRegistered) { call->callState = OO_CALL_WAITING_ADMISSION; ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE); tv = ast_tvnow(); ts.tv_sec = tv.tv_sec + 24; ts.tv_nsec = tv.tv_usec * 1000; ast_mutex_lock(&call->GkLock); if (call->callState == OO_CALL_WAITING_ADMISSION) ast_cond_timedwait(&call->gkWait, &call->GkLock, &ts); if (call->callState == OO_CALL_WAITING_ADMISSION) call->callState = OO_CALL_CLEAR; ast_mutex_unlock(&call->GkLock); } else { OOTRACEERR1("Error:Ignoring incoming call as not yet" "registered with Gk\n"); call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_GK_UNREACHABLE; } } if (call->callState < OO_CALL_CLEAR) { ooHandleFastStartChannels(call); ooSendCallProceeding(call);/* Send call proceeding message*/ ret = ooH323CallAdmitted (call); call->callState = OO_CALL_CONNECTING; } } /* end ret == OO_OK */ break; case Q931CallProceedingMsg: /* CALL PROCEEDING message is received */ OOTRACEINFO3("H.225 Call Proceeding message received (%s, %s)\n", call->callType, call->callToken); ooOnReceivedCallProceeding(call, q931Msg); ooFreeQ931Message(call->msgctxt, q931Msg); break; case Q931AlertingMsg:/* ALERTING message received */ OOTRACEINFO3("H.225 Alerting message received (%s, %s)\n", call->callType, call->callToken); call->alertingTime = (H235TimeStamp) time(NULL); ooOnReceivedAlerting(call, q931Msg); if(gH323ep.h323Callbacks.onAlerting && call->callStatemsgctxt, q931Msg); break; case Q931ProgressMsg:/* PROGRESS message received */ OOTRACEINFO3("H.225 Progress message received (%s, %s)\n", call->callType, call->callToken); ooOnReceivedProgress(call, q931Msg); if(gH323ep.h323Callbacks.onProgress && call->callStatemsgctxt, q931Msg); break; case Q931ConnectMsg:/* CONNECT message received */ OOTRACEINFO3("H.225 Connect message received (%s, %s)\n", call->callType, call->callToken); call->connectTime = (H235TimeStamp) time(NULL); /* Disable call establishment timer */ for(i = 0; itimerList.count; i++) { pNode = dListFindByIndex(&call->timerList, i); pTimer = (OOTimer*)pNode->data; if(((ooTimerCallback*)pTimer->cbData)->timerType & OO_CALLESTB_TIMER) { memFreePtr(call->pctxt, pTimer->cbData); ooTimerDelete(call->pctxt, &call->timerList, pTimer); OOTRACEDBGC3("Deleted CallESTB timer. (%s, %s)\n", call->callType, call->callToken); break; } } ret = ooOnReceivedSignalConnect(call, q931Msg); if(ret != OO_OK) OOTRACEERR3("Error:Invalid Connect message received. (%s, %s)\n", call->callType, call->callToken); else{ /* H225 message callback */ if(gH323ep.h225Callbacks.onReceivedConnect) gH323ep.h225Callbacks.onReceivedConnect(call, q931Msg); if(gH323ep.h323Callbacks.onCallEstablished) gH323ep.h323Callbacks.onCallEstablished(call); } ooFreeQ931Message(call->msgctxt, q931Msg); if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) { if(gH323ep.gkClient->state == GkClientRegistered) { ooGkClientSendIRR(gH323ep.gkClient, call); } } break; case Q931InformationMsg: OOTRACEINFO3("H.225 Information msg received (%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(call->msgctxt, q931Msg); break; case Q931ReleaseCompleteMsg:/* RELEASE COMPLETE message received */ OOTRACEINFO3("H.225 Release Complete message received (%s, %s)\n", call->callType, call->callToken); call->endTime = (H235TimeStamp) time(NULL); ooOnReceivedReleaseComplete(call, q931Msg); ooFreeQ931Message(call->msgctxt, q931Msg); break; case Q931FacilityMsg: OOTRACEINFO3("H.225 Facility message Received (%s, %s)\n", call->callType, call->callToken); ooOnReceivedFacility(call, q931Msg); ooFreeQ931Message(call->msgctxt, q931Msg); break; case Q931StatusMsg: OOTRACEINFO3("H.225 Status message received (%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(call->msgctxt, q931Msg); break; case Q931StatusEnquiryMsg: OOTRACEINFO3("H.225 Status Inquiry message Received (%s, %s)\n", call->callType, call->callToken); ooSendStatus(call); ooFreeQ931Message(call->msgctxt, q931Msg); break; case Q931SetupAckMsg: OOTRACEINFO3("H.225 Setup Ack message received (%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(call->msgctxt, q931Msg); break; case Q931NotifyMsg: OOTRACEINFO3("H.225 Notify message Received (%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(call->msgctxt, q931Msg); break; default: OOTRACEWARN3("Invalid H.225 message type received (%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(call->msgctxt, q931Msg); } return ret; } int ooOnReceivedFacility(OOH323CallData *call, Q931Message * pQ931Msg) { H225H323_UU_PDU * pH323UUPdu = NULL; H225Facility_UUIE * facility = NULL; int ret; H225TransportAddress_ipAddress_ip *ip = NULL; H225TransportAddress_ip6Address_ip *ip6 = NULL; OOTRACEDBGC3("Received Facility Message.(%s, %s)\n", call->callType, call->callToken); ooHandleDisplayIE(call, pQ931Msg); /* Get Reference to H323_UU_PDU */ if(!pQ931Msg->userInfo) { OOTRACEERR3("Error: UserInfo not found in received H.225 Facility " "message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pH323UUPdu = &pQ931Msg->userInfo->h323_uu_pdu; if(!pH323UUPdu) { OOTRACEERR1("ERROR: H225H323_UU_PDU absent in incoming facility " "message\n"); return OO_FAILED; } facility = pH323UUPdu->h323_message_body.u.facility; if(facility) { ooHandleH2250ID(call, &facility->protocolIdentifier); /* Depending on the reason of facility message handle the message */ if(facility->reason.t == T_H225FacilityReason_transportedInformation) { if(OO_TESTFLAG (call->flags, OO_M_TUNNELING)) { OOTRACEDBGB3("Handling tunneled messages in Facility. (%s, %s)\n", call->callType, call->callToken); ooHandleTunneledH245Messages(call, pH323UUPdu); OOTRACEDBGB3("Finished handling tunneled messages in Facility." "(%s, %s)\n",call->callType, call->callToken); } else { OOTRACEERR3("ERROR:Tunneled H.245 message received in facility. " "Tunneling is disabled at local for this call (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } } else if(facility->reason.t == T_H225FacilityReason_startH245) { OOTRACEINFO3("Remote wants to start a separate H.245 Channel " "(%s, %s)\n", call->callType, call->callToken); /*start H.245 channel*/ ret = ooHandleStartH245FacilityMessage(call, facility); if(ret != OO_OK) { OOTRACEERR3("ERROR: Handling startH245 facility message " "(%s, %s)\n", call->callType, call->callToken); return ret; } } else if(facility->reason.t == T_H225FacilityReason_callForwarded) { OOTRACEINFO3("Call Forward Facility message received. (%s, %s)\n", call->callType, call->callToken); if(!facility->m.alternativeAddressPresent && !facility->m.alternativeAliasAddressPresent) { OOTRACEERR3("Error:No alternative address provided in call forward" "facility message.(%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_INVALIDMESSAGE; } return OO_OK; } call->pCallFwdData = (OOCallFwdData *) memAlloc(call->pctxt, sizeof(OOCallFwdData)); if(!call->pCallFwdData) { OOTRACEERR3("Error:Memory - ooOnReceivedFacility - pCallFwdData " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } call->pCallFwdData->fwdedByRemote = TRUE; call->pCallFwdData->ip[0]='\0'; call->pCallFwdData->aliases = NULL; if(facility->m.alternativeAddressPresent) { if (call->versionIP == 6) { if(facility->alternativeAddress.t != T_H225TransportAddress_ip6Address) { OOTRACEERR3("ERROR: Source call signalling address type not ip6 " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ip6 = &facility->alternativeAddress.u.ip6Address->ip; inet_ntop(AF_INET6, ip6->data, call->pCallFwdData->ip, INET6_ADDRSTRLEN); call->pCallFwdData->port = facility->alternativeAddress.u.ip6Address->port; } else { if(facility->alternativeAddress.t != T_H225TransportAddress_ipAddress) { OOTRACEERR3("ERROR: Source call signalling address type not ip " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ip = &facility->alternativeAddress.u.ipAddress->ip; sprintf(call->pCallFwdData->ip, "%d.%d.%d.%d", ip->data[0], ip->data[1], ip->data[2], ip->data[3]); call->pCallFwdData->port = facility->alternativeAddress.u.ipAddress->port; } } if(facility->m.alternativeAliasAddressPresent) { ooH323RetrieveAliases(call, &facility->alternativeAliasAddress, &call->pCallFwdData->aliases); } /* Now we have to clear the current call and make a new call to fwded location*/ if(call->callState < OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_REMOTE_FWDED; } else{ OOTRACEERR3("Error:Can't forward call as it is being cleared." " (%s, %s)\n", call->callType, call->callToken); return OO_OK; } } else if(facility->reason.t == T_H225FacilityReason_forwardedElements) { OOTRACEINFO3("Handling fast start in forwardedElem facility for " "(%s, %s)\n", call->callType, call->callToken); /*start H.245 channel*/ ret = ooHandleFastStart(call, facility); if(ret != OO_OK) { OOTRACEERR3("ERROR: Handling transportedInformation facility message " "(%s, %s)\n", call->callType, call->callToken); return ret; } } else{ OOTRACEINFO3("Unhandled Facility reason type received (%s, %s)\n", call->callType, call->callToken); } } else{ /* Empty facility message Check for tunneling */ if (pH323UUPdu->h323_message_body.t == T_H225H323_UU_PDU_h323_message_body_empty) { OOTRACEDBGB3("Handling tunneled messages in empty Facility message." " (%s, %s)\n", call->callType, call->callToken); ooHandleTunneledH245Messages(call, pH323UUPdu); OOTRACEDBGB3("Finished handling tunneled messages in empty Facility " "message. (%s, %s)\n", call->callType, call->callToken); } } return OO_OK; } int ooHandleStartH245FacilityMessage (OOH323CallData *call, H225Facility_UUIE *facility) { H225TransportAddress_ipAddress *ipAddress = NULL; H225TransportAddress_ip6Address *ip6Address = NULL; int ret; /* Extract H245 address */ if(!facility->m.h245AddressPresent) { OOTRACEERR3("ERROR: startH245 facility message received with no h245 " "address (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if (call->versionIP == 6) { if(facility->h245Address.t != T_H225TransportAddress_ip6Address) { OOTRACEERR3("ERROR:Unknown H245 address type in received startH245 " "facility message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ip6Address = facility->h245Address.u.ip6Address; if(!ip6Address) { OOTRACEERR3("ERROR:Invalid startH245 facility message. No H245 ip6 " "address found. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_ntop(AF_INET6, ip6Address->ip.data, call->remoteIP, INET6_ADDRSTRLEN); call->remoteH245Port = ip6Address->port; } else { if(facility->h245Address.t != T_H225TransportAddress_ipAddress) { OOTRACEERR3("ERROR:Unknown H245 address type in received startH245 " "facility message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ipAddress = facility->h245Address.u.ipAddress; if(!ipAddress) { OOTRACEERR3("ERROR:Invalid startH245 facility message. No H245 ip " "address found. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } sprintf(call->remoteIP, "%d.%d.%d.%d", ipAddress->ip.data[0], ipAddress->ip.data[1], ipAddress->ip.data[2], ipAddress->ip.data[3]); call->remoteH245Port = ipAddress->port; } /* disable tunneling for this call */ OO_CLRFLAG (call->flags, OO_M_TUNNELING); /*Establish an H.245 connection */ if (!call->pH245Channel) { ret = ooCreateH245Connection(call); if(ret != OO_OK) { OOTRACEERR3("ERROR: Failed to establish an H.245 connection with remote" " endpoint (%s, %s)\n", call->callType, call->callToken); return ret; } } else { OOTRACEINFO3("INFO: H.245 connection already established with remote" " endpoint (%s, %s)\n", call->callType, call->callToken); } ooSendTCSandMSD(call); return OO_OK; } int ooHandleTunneledH245Messages (OOH323CallData *call, H225H323_UU_PDU * pH323UUPdu) { H245Message *pmsg; OOCTXT *pctxt = call->msgctxt; int ret=0,i=0; OOTRACEDBGC3("Checking for tunneled H.245 messages (%s, %s)\n", call->callType, call->callToken); /* Check whether there are tunneled messages */ if(pH323UUPdu->m.h245TunnelingPresent) { if(pH323UUPdu->h245Tunneling) { OOTRACEDBGB4("Total number of tunneled H245 messages are %d.(%s, %s)" "\n", (int)pH323UUPdu->h245Control.n, call->callType, call->callToken); for(i=0; i< (int)pH323UUPdu->h245Control.n; i++) { OOTRACEDBGC5("Retrieving %d of %d tunneled H.245 messages." "(%s, %s)\n",i+1, pH323UUPdu->h245Control.n, call->callType, call->callToken); pmsg = (H245Message*)memAlloc(pctxt, sizeof(H245Message)); if(!pmsg) { OOTRACEERR3("Error:Memory - ooHandleH245TunneledMessages - pmsg" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } setPERBuffer(pctxt, (ASN1OCTET*)pH323UUPdu->h245Control.elem[i].data, pH323UUPdu->h245Control.elem[i].numocts, 1); initializePrintHandler(&printHandler, "Tunneled H.245 Message"); memset(pmsg, 0, sizeof(H245Message)); /* Set event handler */ setEventHandler (pctxt, &printHandler); OOTRACEDBGC4("Decoding %d tunneled H245 message. (%s, %s)\n", i+1, call->callType, call->callToken); ret = asn1PD_H245MultimediaSystemControlMessage(pctxt, &(pmsg->h245Msg)); if(ret != ASN_OK) { OOTRACEERR3("Error decoding H245 message (%s, %s)\n", call->callType, call->callToken); ooFreeH245Message(call,pmsg); return OO_FAILED; } finishPrint(); removeEventHandler (pctxt); ooHandleH245Message(call, pmsg); memFreePtr(pctxt, pmsg); pmsg = NULL; }/* End of For loop */ }/* End of if(h245Tunneling) */ } return OO_OK; } int ooH323RetrieveAliases (OOH323CallData *call, H225_SeqOfH225AliasAddress *pAddresses, OOAliases **aliasList) { int i=0,j=0,k=0; DListNode* pNode=NULL; H225AliasAddress *pAliasAddress=NULL; OOAliases *newAlias=NULL; H225TransportAddress *pTransportAddrss=NULL; if(!pAddresses) { OOTRACEWARN3("Warn:No Aliases present (%s, %s)\n", call->callType, call->callToken); return OO_OK; } /* check for aliases */ if(pAddresses->count<=0) return OO_OK; for(i=0; i<(int)pAddresses->count; i++) { pNode = dListFindByIndex (pAddresses, i); if(!pNode) continue; pAliasAddress = (H225AliasAddress*)pNode->data; if(!pAliasAddress) continue; newAlias = (OOAliases*)memAlloc(call->pctxt, sizeof(OOAliases)); if(!newAlias) { OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - newAlias " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(newAlias, 0, sizeof(OOAliases)); switch(pAliasAddress->t) { case T_H225AliasAddress_dialedDigits: newAlias->type = T_H225AliasAddress_dialedDigits; newAlias->value = (char*) memAlloc(call->pctxt, strlen(pAliasAddress->u.dialedDigits)*sizeof(char)+1); if(!newAlias->value) { OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - " "newAlias->value(dialedDigits) (%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, newAlias); return OO_FAILED; } memcpy(newAlias->value, pAliasAddress->u.dialedDigits, strlen(pAliasAddress->u.dialedDigits)*sizeof(char)); newAlias->value[strlen(pAliasAddress->u.dialedDigits)*sizeof(char)]='\0'; break; case T_H225AliasAddress_h323_ID: newAlias->type = T_H225AliasAddress_h323_ID; newAlias->value = (char*)memAlloc(call->pctxt, (pAliasAddress->u.h323_ID.nchars+1)*sizeof(char)+1); if(!newAlias->value) { OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - " "newAlias->value(h323id) (%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, newAlias); return OO_FAILED; } for(j=0, k=0; j<(int)pAliasAddress->u.h323_ID.nchars; j++) { if(pAliasAddress->u.h323_ID.data[j] < 256) { newAlias->value[k++] = (char) pAliasAddress->u.h323_ID.data[j]; } } newAlias->value[k] = '\0'; break; case T_H225AliasAddress_url_ID: newAlias->type = T_H225AliasAddress_url_ID; newAlias->value = (char*)memAlloc(call->pctxt, strlen(pAliasAddress->u.url_ID)*sizeof(char)+1); if(!newAlias->value) { OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - " "newAlias->value(urlid) (%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, newAlias); return OO_FAILED; } memcpy(newAlias->value, pAliasAddress->u.url_ID, strlen(pAliasAddress->u.url_ID)*sizeof(char)); newAlias->value[strlen(pAliasAddress->u.url_ID)*sizeof(char)]='\0'; break; case T_H225AliasAddress_transportID: newAlias->type = T_H225AliasAddress_transportID; pTransportAddrss = pAliasAddress->u.transportID; if(pTransportAddrss->t == T_H225TransportAddress_ip6Address) { /* hopefully ip:port value can't exceed more than 30 characters */ newAlias->value = (char*)memAlloc(call->pctxt, INET6_ADDRSTRLEN*sizeof(char)*2); inet_ntop(AF_INET6, pTransportAddrss->u.ip6Address->ip.data, newAlias->value, INET6_ADDRSTRLEN); sprintf(newAlias->value+strlen(newAlias->value), ":%d", pTransportAddrss->u.ip6Address->port); } else if(pTransportAddrss->t == T_H225TransportAddress_ipAddress) { /* hopefully ip:port value can't exceed more than 30 characters */ newAlias->value = (char*)memAlloc(call->pctxt, 30*sizeof(char)); sprintf(newAlias->value, "%d.%d.%d.%d:%d", pTransportAddrss->u.ipAddress->ip.data[0], pTransportAddrss->u.ipAddress->ip.data[1], pTransportAddrss->u.ipAddress->ip.data[2], pTransportAddrss->u.ipAddress->ip.data[3], pTransportAddrss->u.ipAddress->port); } else { OOTRACEERR3("Error:Alias transportID not an IP4 nor IP6 address" "(%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, newAlias); } break; case T_H225AliasAddress_email_ID: newAlias->type = T_H225AliasAddress_email_ID; newAlias->value = (char*)memAlloc(call->pctxt, strlen(pAliasAddress->u.email_ID)*sizeof(char)+1); if(!newAlias->value) { OOTRACEERR3("ERROR:Memory - ooH323RetrieveAliases - " "newAlias->value(emailid) (%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, newAlias); return OO_FAILED; } memcpy(newAlias->value, pAliasAddress->u.email_ID, strlen(pAliasAddress->u.email_ID)*sizeof(char)); newAlias->value[strlen(pAliasAddress->u.email_ID)*sizeof(char)]='\0'; break; default: OOTRACEERR3("Error:Unhandled Alias type (%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, newAlias); continue; } newAlias->next = *aliasList; *aliasList = newAlias; newAlias = NULL; pAliasAddress = NULL; pNode = NULL; }/* endof: for */ return OO_OK; } int ooPopulatePrefixList(OOCTXT *pctxt, OOAliases *pAliases, H225_SeqOfH225SupportedPrefix *pPrefixList ) { H225SupportedPrefix *pPrefixEntry=NULL; OOAliases * pAlias=NULL; ASN1BOOL bValid=FALSE; dListInit(pPrefixList); if(pAliases) { pAlias = pAliases; while(pAlias) { pPrefixEntry = NULL; switch(pAlias->type) { case T_H225AliasAddress_dialedDigits: pPrefixEntry = (H225SupportedPrefix *)memAlloc(pctxt, sizeof(H225SupportedPrefix)); if(!pPrefixEntry) { OOTRACEERR1("ERROR:Memory - ooPopulatePrefixList - pAliasEntry\n"); return OO_FAILED; } pPrefixEntry->prefix.t = T_H225AliasAddress_dialedDigits; pPrefixEntry->prefix.u.dialedDigits = (ASN1IA5String)memAlloc(pctxt, strlen(pAlias->value)+1); if(!pPrefixEntry->prefix.u.dialedDigits) { OOTRACEERR1("ERROR:Memory - ooPopulatePrefixList - " "dialedDigits\n"); memFreePtr(pctxt, pPrefixEntry); return OO_FAILED; } strcpy(*(char**)&pPrefixEntry->prefix.u.dialedDigits, pAlias->value); bValid = TRUE; break; default: bValid = FALSE; } if(bValid) dListAppend( pctxt, pPrefixList, (void*)pPrefixEntry ); pAlias = pAlias->next; } } return OO_OK; } int ooPopulateAliasList(OOCTXT *pctxt, OOAliases *pAliases, H225_SeqOfH225AliasAddress *pAliasList, int pAliasType) { H225AliasAddress *pAliasEntry=NULL; OOAliases * pAlias=NULL; ASN1BOOL bValid=FALSE; int i = 0; dListInit(pAliasList); if(pAliases) { pAlias = pAliases; while(pAlias) { if (pAlias->value[0] == 0) { pAlias = pAlias->next; continue; } pAliasEntry = (H225AliasAddress*)memAlloc(pctxt, sizeof(H225AliasAddress)); if(!pAliasEntry) { OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - pAliasEntry\n"); return OO_FAILED; } if (pAliasType && pAlias->type != pAliasType) { pAlias = pAlias->next; continue; } switch(pAlias->type) { case T_H225AliasAddress_dialedDigits: pAliasEntry->t = T_H225AliasAddress_dialedDigits; pAliasEntry->u.dialedDigits = (ASN1IA5String)memAlloc(pctxt, strlen(pAlias->value)+1); if(!pAliasEntry->u.dialedDigits) { OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - " "dialedDigits\n"); memFreePtr(pctxt, pAliasEntry); return OO_FAILED; } strcpy(*(char**)&pAliasEntry->u.dialedDigits, pAlias->value); bValid = TRUE; break; case T_H225AliasAddress_h323_ID: pAliasEntry->t = T_H225AliasAddress_h323_ID; pAliasEntry->u.h323_ID.nchars = strlen(pAlias->value); pAliasEntry->u.h323_ID.data = (ASN116BITCHAR*)memAllocZ (pctxt, strlen(pAlias->value)*sizeof(ASN116BITCHAR)); if(!pAliasEntry->u.h323_ID.data) { OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - h323_id\n"); memFreePtr(pctxt, pAliasEntry); return OO_FAILED; } for(i=0; *(pAlias->value+i) != '\0'; i++) pAliasEntry->u.h323_ID.data[i] =(ASN116BITCHAR)pAlias->value[i]; bValid = TRUE; break; case T_H225AliasAddress_url_ID: pAliasEntry->t = T_H225AliasAddress_url_ID; pAliasEntry->u.url_ID = (ASN1IA5String)memAlloc(pctxt, strlen(pAlias->value)+1); if(!pAliasEntry->u.url_ID) { OOTRACEERR1("ERROR:Memory - ooPopulateAliasList - url_id\n"); memFreePtr(pctxt, pAliasEntry); return OO_FAILED; } strcpy(*(char**)&pAliasEntry->u.url_ID, pAlias->value); bValid = TRUE; break; case T_H225AliasAddress_email_ID: pAliasEntry->t = T_H225AliasAddress_email_ID; pAliasEntry->u.email_ID = (ASN1IA5String)memAlloc(pctxt, strlen(pAlias->value)+1); if(!pAliasEntry->u.email_ID) { OOTRACEERR1("ERROR: Failed to allocate memory for EmailID " "alias entry \n"); return OO_FAILED; } strcpy(*(char**)&pAliasEntry->u.email_ID, pAlias->value); bValid = TRUE; break; default: OOTRACEERR1("ERROR: Unhandled alias type\n"); bValid = FALSE; } if(bValid) dListAppend( pctxt, pAliasList, (void*)pAliasEntry ); else memFreePtr(pctxt, pAliasEntry); pAlias = pAlias->next; } } return OO_OK; } OOAliases* ooH323GetAliasFromList(OOAliases *aliasList, int type, char *value) { OOAliases *pAlias = NULL; if(!aliasList) { OOTRACEDBGC1("No alias List to search\n"); return NULL; } pAlias = aliasList; while(pAlias) { if(type != 0 && value) { /* Search by type and value */ if(pAlias->type == type && !strcmp(pAlias->value, value)) { return pAlias; } } else if(type != 0 && !value) {/* search by type */ if(pAlias->type == type) return pAlias; } else if(type == 0 && value) {/* search by value */ if(!strcmp(pAlias->value, value)) return pAlias; } else { OOTRACEDBGC1("No criteria to search the alias list\n"); return NULL; } pAlias = pAlias->next; } return NULL; } OOAliases* ooH323AddAliasToList (OOAliases **pAliasList, OOCTXT *pctxt, H225AliasAddress *pAliasAddress) { int j=0,k=0; OOAliases *newAlias=NULL; H225TransportAddress *pTransportAddrss=NULL; newAlias = (OOAliases*) memAlloc(pctxt, sizeof(OOAliases)); if(!newAlias) { OOTRACEERR1("Error: Failed to allocate memory for new alias to be added to the alias list\n"); return NULL; } memset(newAlias, 0, sizeof(OOAliases)); switch(pAliasAddress->t) { case T_H225AliasAddress_dialedDigits: newAlias->type = T_H225AliasAddress_dialedDigits; newAlias->value = (char*) memAlloc(pctxt, strlen(pAliasAddress->u.dialedDigits)*sizeof(char)+1); strcpy(newAlias->value, pAliasAddress->u.dialedDigits); break; case T_H225AliasAddress_h323_ID: newAlias->type = T_H225AliasAddress_h323_ID; newAlias->value = (char*)memAlloc(pctxt, (pAliasAddress->u.h323_ID.nchars+1)*sizeof(char)+1); for(j=0, k=0; j<(int)pAliasAddress->u.h323_ID.nchars; j++) { if(pAliasAddress->u.h323_ID.data[j] < 256) { newAlias->value[k++] = (char) pAliasAddress->u.h323_ID.data[j]; } } newAlias->value[k] = '\0'; break; case T_H225AliasAddress_url_ID: newAlias->type = T_H225AliasAddress_url_ID; newAlias->value = (char*)memAlloc(pctxt, strlen(pAliasAddress->u.url_ID)*sizeof(char)+1); strcpy(newAlias->value, pAliasAddress->u.url_ID); break; case T_H225AliasAddress_transportID: newAlias->type = T_H225AliasAddress_transportID; pTransportAddrss = pAliasAddress->u.transportID; if(pTransportAddrss->t == T_H225TransportAddress_ip6Address) { /* hopefully ip:port value can't exceed more than 30 characters */ newAlias->value = (char*)memAlloc(pctxt, INET6_ADDRSTRLEN*sizeof(char)*2); inet_ntop(AF_INET6, pTransportAddrss->u.ip6Address->ip.data, newAlias->value, INET6_ADDRSTRLEN); sprintf(newAlias->value+strlen(newAlias->value), ":%d", pTransportAddrss->u.ip6Address->port); } else if(pTransportAddrss->t == T_H225TransportAddress_ipAddress) { /* hopefully ip:port value can't exceed more than 30 characters */ newAlias->value = (char*)memAlloc(pctxt, 30*sizeof(char)); sprintf(newAlias->value, "%d.%d.%d.%d:%d", pTransportAddrss->u.ipAddress->ip.data[0], pTransportAddrss->u.ipAddress->ip.data[1], pTransportAddrss->u.ipAddress->ip.data[2], pTransportAddrss->u.ipAddress->ip.data[3], pTransportAddrss->u.ipAddress->port); } else { OOTRACEERR1("Error:Alias transportID not an IP4 nor IP6 address\n"); memFreePtr(pctxt, newAlias); return NULL; } break; case T_H225AliasAddress_email_ID: newAlias->type = T_H225AliasAddress_email_ID; newAlias->value = (char*)memAlloc(pctxt, strlen(pAliasAddress->u.email_ID)*sizeof(char)+1); strcpy(newAlias->value, pAliasAddress->u.email_ID); break; default: OOTRACEERR1("Error:Unhandled Alias type \n"); memFreePtr(pctxt, newAlias); return NULL; } newAlias->next = *pAliasList; *pAliasList= newAlias; return newAlias; } int ooH323GetIpPortFromH225TransportAddress(struct OOH323CallData *call, H225TransportAddress *h225Address, char *ip, int *port) { if (call->versionIP == 6) { if(h225Address->t != T_H225TransportAddress_ip6Address) { OOTRACEERR3("Error: Unknown H225 address type. (%s, %s)", call->callType, call->callToken); return OO_FAILED; } inet_ntop(AF_INET6, h225Address->u.ip6Address->ip.data, ip, INET6_ADDRSTRLEN); *port = h225Address->u.ip6Address->port; return OO_OK; } if(h225Address->t != T_H225TransportAddress_ipAddress) { OOTRACEERR3("Error: Unknown H225 address type. (%s, %s)", call->callType, call->callToken); return OO_FAILED; } sprintf(ip, "%d.%d.%d.%d", h225Address->u.ipAddress->ip.data[0], h225Address->u.ipAddress->ip.data[1], h225Address->u.ipAddress->ip.data[2], h225Address->u.ipAddress->ip.data[3]); *port = h225Address->u.ipAddress->port; return OO_OK; } asterisk-11.7.0/addons/ooh323c/src/ooq931.h0000644000175000007640000006422311775134255020011 0ustar sharkyjerryweb/* * 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 999999 /* 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; Q931InformationElement *callstateIE; 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, int docallbacks); /** * 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(OOCTXT* pctxt, 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(OOCTXT* pctxt, 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(OOCTXT* pctxt, 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(OOCTXT* pctxt, 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); EXTERN int ooSendProgress(struct OOH323CallData *call); EXTERN int ooSendStatus(struct OOH323CallData *call); EXTERN int ooSendStatusInquiry(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, int q931); /** * 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(OOCTXT* pctxt, 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 (OOCTXT* pctxt, 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 (OOCTXT *pctxt, 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 (OOCTXT* pctxt, 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 (OOCTXT *pctxt, Q931Message *pmsg,enum Q931CauseValues cause, unsigned coding, unsigned location); EXTERN int ooQ931SetCallStateIE (OOCTXT *pctxt, Q931Message *pmsg, unsigned char callstate); /** * 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); EXTERN int ooH323NewCall(char *callToken); EXTERN char* ooQ931GetMessageTypeName(int messageType, char* buf); EXTERN char* ooQ931GetIEName(int number, char* buf); EXTERN int ooSendTCSandMSD(struct OOH323CallData *call); EXTERN int ooSendStartH245Facility(struct OOH323CallData *call); EXTERN int ooSendFSUpdate(struct OOH323CallData *call); EXTERN int ooHandleFastStartChannels(struct OOH323CallData *pCall); /** * @} */ #ifdef __cplusplus } #endif #endif /* __Q931HDR_H */ asterisk-11.7.0/addons/ooh323c/src/memheap.c0000644000175000007640000012441711714557754020375 0ustar sharkyjerryweb/* * Copyright (C) 1997-2004 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 "asterisk.h" #include "asterisk/lock.h" #include #include "memheap.h" ASN1UINT g_defBlkSize = XM_K_MEMBLKSIZ; static OSMemLink* memHeapAddBlock (OSMemLink** ppMemLink, void* pMemBlk, int blockType); typedef void OSMemElemDescr; #define pElem_flags(pElem) (*((ASN1OCTET*)pElem)) #define pElem_nunits(pElem) (*((ASN1USINT*)(((ASN1OCTET*)pElem)+2))) #define pElem_prevOff(pElem) (*((ASN1USINT*)(((ASN1OCTET*)pElem)+4))) #define pElem_nextFreeOff(pElem) (*((ASN1USINT*)(((ASN1OCTET*)pElem)+6))) #define pElem_beginOff(pElem) (*((ASN1USINT*)(((ASN1OCTET*)pElem)+6))) #define sizeof_OSMemElemDescr 8 #define pElem_data(pElem) (((ASN1OCTET*)pElem)+sizeof_OSMemElemDescr) typedef struct MemBlk { OSMemLink* plink; ASN1USINT free_x; /* index of free space at end of block */ ASN1USINT freeMem; /* size of free space before free_x */ ASN1USINT nunits; /* size of data */ ASN1USINT lastElemOff; /* last element offset in block */ ASN1USINT freeElemOff; /* first free element offset in block */ ASN1USINT nsaved; /* num of saved elems in the block */ ASN1USINT spare[2]; /* forces alignment on 8-bytes boundary, for 64-bit systems */ char data[8]; } OSMemBlk; /* Macros for operations with memory blocks */ #define QOFFSETOF(pElem, pPrevElem) \ ((ASN1USINT)(((unsigned)((char*)pElem - (char*)pPrevElem)) >> 3u)) #define OFFSETOF(pElem, pPrevElem) \ ((ASN1UINT)((char*)pElem - (char*)pPrevElem)) #define ISFREE(pElem) (pElem_flags(pElem) & 1) #define SET_FREE(pElem) (pElem_flags(pElem) |= 1) #define CLEAR_FREE(pElem) (pElem_flags(pElem) &= (~1)) #define ISLAST(pElem) (pElem_flags(pElem) & 2) #define SET_LAST(pElem) (pElem_flags(pElem) |= 2) #define CLEAR_LAST(pElem) (pElem_flags(pElem) &= (~2)) #define ISSAVED(pElem) (pElem_flags(pElem) & 4) #define SET_SAVED(pMemBlk,pElem) do { \ (pElem_flags (pElem) |= 4); pMemBlk->nsaved++; } while (0) #define CLEAR_SAVED(pMemBlk,pElem) do { \ (pElem_flags (pElem) &= (~4)); pMemBlk->nsaved--; } while (0) #define ISFIRST(pElem) (int)(pElem_prevOff (pElem) == 0) #define GETPREV(pElem) \ ((pElem_prevOff (pElem) == 0) ? 0 : \ ((OSMemElemDescr*) (((char*)pElem) - (pElem_prevOff (pElem) * 8u)))) #define GETNEXT(pElem) \ ((ISLAST (pElem)) ? 0 : \ ((OSMemElemDescr*)(((char*)pElem) + ((pElem_nunits (pElem) + 1) * 8u)))) #define GET_NEXT_FREE(pElem) \ ((pElem_nextFreeOff (pElem) == 0) ? 0 : \ ((OSMemElemDescr*) (((char*)pElem) + (pElem_nextFreeOff (pElem) * 8u)))) #define GET_MEMBLK(pElem) \ ((OSMemBlk*) (((char*)pElem) - (pElem_beginOff (pElem) * 8u) - \ sizeof (OSMemBlk) + sizeof ((OSMemBlk*)0)->data)) #define GET_LAST_ELEM(pMemBlk) \ ((pMemBlk->lastElemOff == 0) ? 0 : \ (OSMemElemDescr*)&pMemBlk->data[(pMemBlk->lastElemOff - 1) * 8u]) #define SET_LAST_ELEM(pMemBlk, pElem) \ pMemBlk->lastElemOff = (ASN1USINT)((pElem == 0) ? 0 : \ (SET_LAST (pElem), (QOFFSETOF (pElem, pMemBlk->data) + 1))) #define GET_FREE_ELEM(pMemBlk) \ ((pMemBlk->freeElemOff == 0) ? 0 : \ (OSMemElemDescr*)&pMemBlk->data[(pMemBlk->freeElemOff - 1) * 8u]) #define FORCE_SET_FREE_ELEM(pMemBlk, pElem) do { \ if (pElem == 0) { pMemBlk->freeElemOff = 0; break; } \ SET_FREE (pElem); \ pMemBlk->freeElemOff = (ASN1USINT)(QOFFSETOF (pElem, pMemBlk->data) + 1); \ } while (0) #define SET_FREE_ELEM(pMemBlk, pElem) setLastElem (pMemBlk, pElem) /* Memory debugging macros */ #define RTMEMDIAG1(msg) #define RTMEMDIAG2(msg,a) #define RTMEMDIAG3(msg,a,b) #define RTMEMDIAG4(msg,a,b,c) #define FILLFREEMEM(mem,size) #define FILLNEWMEM(mem,size) #define CHECKMEMELEM(memblk,elem) #define CHECKMEMBLOCK(memheap,memblk) #define CHECKMEMHEAP(memheap) #define TRACEMEMELEM(memblk, elem, name) #define TRACEFREE(memlink,name) static void setLastElem (OSMemBlk* pMemBlk, OSMemElemDescr* pElem) { if (pElem == 0) { pMemBlk->freeElemOff = 0; return; } else if (ISLAST (pElem)) return; else if (pMemBlk->freeElemOff > QOFFSETOF (pElem, pMemBlk->data) + 1) { pElem_nextFreeOff (pElem) = QOFFSETOF (GET_FREE_ELEM (pMemBlk), pElem); FORCE_SET_FREE_ELEM (pMemBlk, pElem); } else if (pMemBlk->freeElemOff == 0) { pElem_nextFreeOff (pElem) = 0; FORCE_SET_FREE_ELEM (pMemBlk, pElem); } else { SET_FREE (pElem); pElem_nextFreeOff (pElem) = 0; } } void* memHeapAlloc (void** ppvMemHeap, int nbytes) { OSMemHeap* pMemHeap; OSMemLink* pMemLink, **ppMemLink; OSMemBlk* pMemBlk = 0; void* mem_p = NULL; unsigned remUnits; ASN1UINT nunits; if (ppvMemHeap == 0) return 0; if (*ppvMemHeap == 0) if (memHeapCreate (ppvMemHeap) != ASN_OK) return 0; /* Round number of bytes to nearest 8-byte boundary */ nunits = (((unsigned)(nbytes + 7)) >> 3); pMemHeap = (OSMemHeap*) *ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); ppMemLink = &pMemHeap->phead; /* if size is greater than 2**19, then allocate as RAW block */ if (nunits > (1<<16) - 2) { void *data; /* allocate raw block */ data = malloc (nbytes); if (data == NULL) { return NULL; } pMemLink = memHeapAddBlock (ppMemLink, data, RTMEMMALLOC | RTMEMRAW); if (pMemLink == 0) { free (data); return NULL; } /* save size of the RAW memory block behind the pMemLink */ *(int*)(((char*)pMemLink) + sizeof (OSMemLink)) = nbytes; ast_mutex_unlock(&pMemHeap->pLock); return data; } RTMEMDIAG2 ("memHeapAlloc: adjusted nbytes = %d\n", nbytes); /* Try to allocate a slot from an existing block on the list */ for (pMemLink = *ppMemLink; pMemLink != 0; pMemLink = pMemLink->pnext) { if (pMemLink->blockType & RTMEMRAW) continue; else pMemBlk = (OSMemBlk*) pMemLink->pMemBlk; remUnits = pMemBlk->nunits - pMemBlk->free_x; if ((unsigned)(nunits + 1) <= remUnits) { OSMemElemDescr* pElem = (OSMemElemDescr*) &pMemBlk->data [((ASN1UINT)pMemBlk->free_x) * 8u]; OSMemElemDescr* pPrevElem; RTMEMDIAG1 ("memHeapAlloc: found existing slot..\n"); /* if block is clean, set some vars in heap */ if (pMemBlk->free_x == 0) { pMemHeap->freeUnits -= pMemBlk->nunits; pMemHeap->freeBlocks--; } pElem_flags (pElem) = 0; if (pMemBlk->lastElemOff != 0) pElem_prevOff (pElem) = (ASN1USINT)(pMemBlk->free_x - pMemBlk->lastElemOff + 1); else pElem_prevOff (pElem) = 0; pPrevElem = GET_LAST_ELEM (pMemBlk); if (pPrevElem != 0) CLEAR_LAST (pPrevElem); pElem_nunits (pElem) = (ASN1USINT)nunits; pElem_beginOff (pElem) = QOFFSETOF (pElem, pMemBlk->data); pMemBlk->lastElemOff = (ASN1USINT)(pMemBlk->free_x + 1); mem_p = (void*) (pElem_data (pElem)); /* sizeof (OSMemElemDescr) == 1 unit */ pMemBlk->free_x += nunits + 1; SET_LAST_ELEM (pMemBlk, pElem); FILLNEWMEM (mem_p, nunits * 8u); TRACEMEMELEM(pMemBlk, pElem, "Allocated"); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK (pMemHeap, pMemBlk); break; } } /* If not successful, look for empty elements in existing blocks */ if (0 == mem_p) { for (pMemLink = *ppMemLink; pMemLink != 0; pMemLink = pMemLink->pnext) { if (pMemLink->blockType & RTMEMRAW) continue; pMemBlk = (OSMemBlk*) pMemLink->pMemBlk; if (nunits <= (ASN1UINT)pMemBlk->freeMem) { OSMemElemDescr* pElem = GET_FREE_ELEM(pMemBlk), *pPrevFree = 0; RTMEMDIAG2 ("memHeapAlloc: try to reuse empty elems in pMemBlk = 0x%x...\n", pMemBlk); while (pElem != 0) { if (ISFREE (pElem)) { if (nunits <= (ASN1UINT)pElem_nunits (pElem)) { RTMEMDIAG3 ("memHeapAlloc: " "found an exisiting free element 0x%x, size %d\n", pElem, (pElem_nunits (pElem) * 8u)); if (pMemBlk->freeElemOff == QOFFSETOF (pElem, pMemBlk->data) + 1) { /* modify the pMemBlk->freeElemOff value if necsry */ OSMemElemDescr* nextFree = GET_NEXT_FREE (pElem); FORCE_SET_FREE_ELEM (pMemBlk, nextFree); } else if (pPrevFree != 0) { OSMemElemDescr* pNextFree = GET_NEXT_FREE (pElem); if (pNextFree != 0) pElem_nextFreeOff (pPrevFree) = QOFFSETOF (pNextFree, pPrevFree); else pElem_nextFreeOff (pPrevFree) = 0; } CLEAR_FREE (pElem); /* set beginOff value */ pElem_beginOff (pElem) = QOFFSETOF (pElem, pMemBlk->data); pMemBlk->freeMem -= pElem_nunits (pElem); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK (pMemHeap, pMemBlk); mem_p = memHeapRealloc (ppvMemHeap, pElem_data (pElem), nunits * 8u); if (mem_p != 0) { FILLNEWMEM (mem_p, nunits * 8u); TRACEMEMELEM(pMemBlk, pElem, "Allocated"); } break; } } pPrevFree = pElem; pElem = GET_NEXT_FREE (pElem); } if (mem_p != 0) break; } } } /* If not successful, malloc a new block and alloc from it */ if (!mem_p) { ASN1UINT allocSize, dataUnits; ASN1OCTET* pmem; register ASN1UINT defBlkSize = pMemHeap->defBlkSize; RTMEMDIAG1 ("memHeapAlloc: alloc block..\n"); allocSize = (ASN1UINT) ((((ASN1UINT)nunits) * 8u) + sizeof (OSMemBlk) + sizeof_OSMemElemDescr); allocSize = (ASN1UINT) (allocSize < defBlkSize) ? defBlkSize : ((allocSize + defBlkSize - 1) / defBlkSize * defBlkSize); dataUnits = (ASN1UINT)((allocSize - sizeof (OSMemBlk)) >> 3u); if (dataUnits >= (1u<<16)) { dataUnits = (ASN1UINT)((1u<<16) - 1); allocSize = (ASN1UINT) ((((ASN1UINT)dataUnits) * 8u) + sizeof (OSMemBlk)); } pmem = (ASN1OCTET*) malloc (allocSize + sizeof (OSMemLink)); if (0 != pmem) { OSMemElemDescr* pElem; pMemBlk = (OSMemBlk*) (pmem + sizeof (OSMemLink)); pElem = (OSMemElemDescr*)&pMemBlk->data[0]; mem_p = (void*) pElem_data (pElem); pElem_nunits (pElem) = (ASN1USINT)nunits; pElem_flags (pElem) = 0; pElem_prevOff (pElem) = 0; pElem_beginOff (pElem) = QOFFSETOF (pElem, pMemBlk->data); /* sizeof (OSMemElemDescr) == 1 unit */ pMemBlk->free_x = (ASN1USINT)(nunits + 1); pMemBlk->freeMem = 0; pMemBlk->nunits = (ASN1USINT)dataUnits; SET_LAST_ELEM (pMemBlk, pElem); pMemBlk->freeElemOff = 0; pMemBlk->nsaved = 0; if (memHeapAddBlock (ppMemLink, pMemBlk, RTMEMSTD | RTMEMLINK) == 0) { free (pmem); ast_mutex_unlock(&pMemHeap->pLock); return NULL; } /* set vars in heap */ pMemHeap->usedUnits += dataUnits; pMemHeap->usedBlocks++; FILLNEWMEM (mem_p, nunits * 8u); TRACEMEMELEM(pMemBlk, pElem, "Allocated"); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK (pMemHeap, pMemBlk); } else { ast_mutex_unlock(&pMemHeap->pLock); return NULL; } } RTMEMDIAG2 ("memHeapAlloc: pMemBlk = 0x%x\n", pMemBlk); RTMEMDIAG2 ("memHeapAlloc: pMemBlk->free_x = %d\n", pMemBlk->free_x); RTMEMDIAG2 ("memHeapAlloc: pMemBlk->size = %d\n", pMemBlk->nunits * 8u); RTMEMDIAG2 ("memHeapAlloc: mem_p = 0x%x\n", mem_p); RTMEMDIAG2 ("memHeapAlloc: sizeof (short) = %d\n", sizeof(short)); ast_mutex_unlock(&pMemHeap->pLock); return (mem_p); } void* memHeapAllocZ (void** ppvMemHeap, int nbytes) { void* ptr = memHeapAlloc (ppvMemHeap, nbytes); if (0 != ptr) memset (ptr, 0, nbytes); return ptr; } void memHeapFreePtr (void** ppvMemHeap, void* mem_p) { OSMemHeap* pMemHeap; OSMemLink** ppMemLink; OSMemElemDescr* pElem; OSMemBlk* pMemBlk; OSMemLink* pMemLink, *pPrevMemLink = 0; RTMEMDIAG2 ("memHeapFreePtr: freeing mem_p = 0x%x\n", mem_p); if (mem_p == 0 || ppvMemHeap == 0 || *ppvMemHeap == 0) return; pMemHeap = *(OSMemHeap**)ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); ppMemLink = &pMemHeap->phead; /* look for chain of RAW blocks first */ for (pMemLink = *ppMemLink; pMemLink != 0; pMemLink = pMemLink->pnextRaw) { if ((pMemLink->blockType & RTMEMRAW) && pMemLink->pMemBlk == mem_p) { if(pMemLink->pnext != 0) { pMemLink->pnext->pprev = pMemLink->pprev; } if(pMemLink->pprev != 0) { pMemLink->pprev->pnext = pMemLink->pnext; } else { /* head */ *ppMemLink = pMemLink->pnext; } if (pPrevMemLink != 0) pPrevMemLink->pnextRaw = pMemLink->pnextRaw; else if (*ppMemLink != 0 && (*ppMemLink)->pnextRaw == 0 && *ppMemLink != pMemLink->pnextRaw) { (*ppMemLink)->pnextRaw = pMemLink->pnextRaw; } if ((pMemLink->blockType & RTMEMLINK) && (pMemLink->blockType & RTMEMMALLOC)) { free (pMemLink); } else { if (pMemLink->blockType & RTMEMMALLOC) free (pMemLink->pMemBlk); free (pMemLink); } ast_mutex_unlock(&pMemHeap->pLock); return; } pPrevMemLink = pMemLink; } pElem = (OSMemElemDescr*) (((char*)mem_p) - sizeof_OSMemElemDescr); pMemBlk = GET_MEMBLK (pElem); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK(pMemHeap, pMemBlk); if (ISFREE (pElem)) { /* already freed! */ RTMEMDIAG2 ("memHeapFreePtr: " "the element 0x%x is already freed!\n", pElem); ast_mutex_unlock(&pMemHeap->pLock); return; } if (ISSAVED (pElem)) { CLEAR_SAVED (pMemBlk, pElem); if (pMemBlk->nsaved == 0) pMemBlk->plink->blockType &= (~RTMEMSAVED); } TRACEMEMELEM(pMemBlk, pElem, "Freed"); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK(pMemHeap, pMemBlk); RTMEMDIAG2 ("memHeapFreePtr: pMemBlk = 0x%x\n", pMemBlk); RTMEMDIAG2 ("memHeapFreePtr: pMemBlk->size = %d\n", pMemBlk->nunits * 8u); if (ISLAST (pElem)) { /* is it the last? */ OSMemElemDescr* pPrevElem = GETPREV (pElem); CHECKMEMELEM (pMemBlk, pPrevElem); pMemBlk->free_x -= (pElem_nunits (pElem) + 1); FILLFREEMEM (&pMemBlk->data [pMemBlk->free_x * 8u], (pElem_nunits (pElem) + 1) * 8u); if (pPrevElem != 0 && ISFREE (pPrevElem)) { OSMemElemDescr* pFreeElem; pMemBlk->free_x -= (pElem_nunits (pPrevElem) + 1); pMemBlk->freeMem -= pElem_nunits (pPrevElem); SET_LAST_ELEM (pMemBlk, GETPREV (pPrevElem)); /* wasn't it the last elem in block? */ if (pMemBlk->lastElemOff != 0) { /* correct nextFreeOff for previous free element */ pFreeElem = GET_FREE_ELEM (pMemBlk); if (pFreeElem == pPrevElem) { pMemBlk->freeElemOff = 0; /* it was the last free elem */ } else { OSMemElemDescr* pNextFree = 0; while (pFreeElem < pPrevElem) { pNextFree = pFreeElem; pFreeElem = GET_NEXT_FREE (pFreeElem); } pElem_nextFreeOff (pNextFree) = 0; } } } else { SET_LAST_ELEM (pMemBlk, pPrevElem); } RTMEMDIAG2 ("memHeapFreePtr: pMemBlk->free_x = %d\n", pMemBlk->free_x); /* The question is: do we really want to get rid of the */ /* block or should we keep it around for reuse? */ if (pMemBlk->lastElemOff == 0) { /* was it the last elem in block? */ if ((pMemHeap->flags & RT_MH_DONTKEEPFREE) || (pMemHeap->keepFreeUnits > 0 && pMemHeap->freeUnits + pMemBlk->nunits > pMemHeap->keepFreeUnits)) { ASN1OCTET blockType = pMemBlk->plink->blockType; /* we may free the block */ pMemHeap->usedUnits -= pMemBlk->nunits; pMemHeap->usedBlocks --; if(pMemBlk->plink->pnext != 0) { pMemBlk->plink->pnext->pprev = pMemBlk->plink->pprev; } if(pMemBlk->plink->pprev != 0) { pMemBlk->plink->pprev->pnext = pMemBlk->plink->pnext; } else { /* head */ if (pMemBlk->plink->pnext != 0 && !(pMemBlk->plink->pnext->blockType & RTMEMRAW)) { pMemBlk->plink->pnext->pnextRaw = (*ppMemLink)->pnextRaw; } *ppMemLink = pMemBlk->plink->pnext; } FILLFREEMEM (pMemBlk->plink, sizeof (*pMemBlk->plink)); FILLFREEMEM (pMemBlk->data, (pMemBlk->nunits * 8u)); free (pMemBlk->plink); if (!(blockType & RTMEMLINK)) { FILLFREEMEM (pMemBlk, sizeof (*pMemBlk)); free (pMemBlk); } RTMEMDIAG2 ("memHeapFreePtr: pMemBlk = 0x%x was freed\n", pMemBlk); } else { /* reset pMemBlk for re-usage */ pMemBlk->free_x = 0; pMemBlk->freeElemOff = 0; pMemBlk->lastElemOff = 0; pMemBlk->freeMem = 0; pMemBlk->nsaved = 0; pMemHeap->freeUnits += pMemBlk->nunits; pMemHeap->freeBlocks ++; } } else { SET_LAST (GET_LAST_ELEM (pMemBlk)); FILLFREEMEM (((char*) &pMemBlk->data[0]) + (pMemBlk->free_x * 8u), (pMemBlk->nunits - pMemBlk->free_x) * 8u); CHECKMEMBLOCK (pMemHeap, pMemBlk); } } else { /* mark as free elem inside the block */ CHECKMEMBLOCK (pMemHeap, pMemBlk); SET_FREE_ELEM(pMemBlk, pElem); pMemBlk->freeMem += pElem_nunits (pElem); RTMEMDIAG2 ("memHeapFreePtr: element 0x%x marked as free.\n", pElem); /* try to unite free blocks, if possible */ if (!ISFIRST (pElem)) { if (ISFREE (GETPREV (pElem))) { OSMemElemDescr* prevelem_p = GETPREV (pElem); /* +1 because the OSMemElemDescr has size ONE unit (8 bytes) */ pElem_nunits (prevelem_p) += pElem_nunits (pElem) + 1; pElem = prevelem_p; pMemBlk->freeMem ++; /* sizeof (OSMemElemDescr) == 1 unit */ } else { /* look for nearest previous free block to correct nextFreeOff */ OSMemElemDescr* prevelem_p = pElem; do { prevelem_p = GETPREV (prevelem_p); } while (prevelem_p && !ISFREE (prevelem_p)); if (prevelem_p != 0) { OSMemElemDescr* pNextFree = GET_NEXT_FREE (prevelem_p); if (pNextFree != 0) pElem_nextFreeOff (pElem) = QOFFSETOF (pNextFree, pElem); else pElem_nextFreeOff (pElem) = 0; pElem_nextFreeOff (prevelem_p) = QOFFSETOF (pElem, prevelem_p); CHECKMEMELEM (pMemBlk, prevelem_p); } } } if (!ISLAST (pElem) && ISFREE (GETNEXT (pElem))) { OSMemElemDescr* nextelem_p = GETNEXT (pElem); /* +1 because the OSMemElemDescr has size ONE unit (8 bytes) */ pElem_nunits (pElem) += pElem_nunits (nextelem_p) + 1; if (pElem_nextFreeOff (nextelem_p) == 0) pElem_nextFreeOff (pElem) = 0; else pElem_nextFreeOff (pElem) = QOFFSETOF (GET_NEXT_FREE (nextelem_p), pElem); pMemBlk->freeMem ++; } /* correct the prevOff field of next element */ if (!ISLAST (pElem)) { OSMemElemDescr* nextelem_p = GETNEXT (pElem); pElem_prevOff (nextelem_p) = QOFFSETOF (nextelem_p, pElem); } CHECKMEMELEM (pMemBlk, pElem); FILLFREEMEM (pElem_data (pElem), (pElem_nunits (pElem) * 8u)); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK (pMemHeap, pMemBlk); } ast_mutex_unlock(&pMemHeap->pLock); } static void initNewFreeElement (OSMemBlk* pMemBlk, OSMemElemDescr* pNewElem, OSMemElemDescr* pElem) { OSMemElemDescr *pNextElem, *pPrevElem = 0; /* create new free element on the freed place */ pElem_flags (pNewElem) = 0; SET_FREE (pNewElem); pElem_prevOff (pNewElem) = QOFFSETOF (pNewElem, pElem); if (pMemBlk->freeElemOff != 0 && pMemBlk->freeElemOff < QOFFSETOF (pElem, pMemBlk->data) + 1) { /* look for nearest previous free block to correct its nextFreeOff */ pPrevElem = pElem; do { pPrevElem = GETPREV (pPrevElem); } while (pPrevElem && !ISFREE (pPrevElem)); } if (pPrevElem != 0) { /* if it is not first free element... */ /* correct nextFreeOff for prev free element */ pElem_nextFreeOff (pPrevElem) = QOFFSETOF (pNewElem, pPrevElem); } else { /* if it is first free element in the block */ FORCE_SET_FREE_ELEM (pMemBlk, pNewElem); } pNextElem = GETNEXT (pNewElem); if (ISFREE (pNextElem)) { /* if the next elem is free, then unite them together */ pElem_nunits (pNewElem) += pElem_nunits (pNextElem) + 1; if (pElem_nextFreeOff (pNextElem) != 0) pElem_nextFreeOff (pNewElem) = QOFFSETOF (GET_NEXT_FREE (pNextElem), pNewElem); else pElem_nextFreeOff (pNewElem) = 0; pMemBlk->freeMem++; /* +1 because space for MemElemDescr is freed now */ pNextElem = GETNEXT (pNewElem); } pElem_prevOff (pNextElem) = QOFFSETOF (pNextElem, pNewElem); if (pMemBlk->freeElemOff != 0) { /* look for the next nearest free elem */ pNextElem = GETNEXT (pNewElem); while (pNextElem != 0 && !ISFREE (pNextElem)) pNextElem = GETNEXT (pNextElem); /* set nextFreeOff for new element */ if (pNextElem != 0) pElem_nextFreeOff (pNewElem) = QOFFSETOF (pNextElem, pNewElem); else pElem_nextFreeOff (pNewElem) = 0; } else pElem_nextFreeOff (pNewElem) = 0; } void* memHeapRealloc (void** ppvMemHeap, void* mem_p, int nbytes_) { OSMemHeap* pMemHeap; OSMemLink** ppMemLink; OSMemBlk* pMemBlk; OSMemElemDescr* pElem; OSMemLink* pMemLink; void *newMem_p; unsigned nbytes, nunits; /* if mem_p == NULL - do rtMemAlloc */ if (ppvMemHeap == 0 || *ppvMemHeap == 0) return 0; if (mem_p == 0) { return memHeapAlloc (ppvMemHeap, nbytes_); } pMemHeap = *(OSMemHeap**)ppvMemHeap; ppMemLink = &pMemHeap->phead; /* look for chain of RAW blocks first */ for (pMemLink = *ppMemLink; pMemLink != 0; pMemLink = pMemLink->pnextRaw) { if ((pMemLink->blockType & RTMEMRAW) && pMemLink->pMemBlk == mem_p) { if (pMemLink->blockType & RTMEMMALLOC) { void *newMemBlk = realloc (pMemLink->pMemBlk, nbytes_); if (newMemBlk == 0) return 0; pMemLink->pMemBlk = newMemBlk; } else return 0; *(int*)(((char*)pMemLink) + sizeof (OSMemLink)) = nbytes_; return pMemLink->pMemBlk; } } /* Round number of bytes to nearest 8-byte boundary */ nbytes = ((unsigned)(nbytes_ + 7)) & (~7); nunits = nbytes >> 3; pElem = (OSMemElemDescr*) (((char*)mem_p) - sizeof_OSMemElemDescr); RTMEMDIAG3 ("memHeapRealloc: mem_p = 0x%x, old size = %d,", mem_p, pElem_nunits (pElem) * 8u); RTMEMDIAG2 (" new nbytes = %d\n", nbytes); if ((unsigned)pElem_nunits (pElem) == nunits) return mem_p; pMemBlk = GET_MEMBLK (pElem); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK(pMemHeap, pMemBlk); if ((unsigned)pElem_nunits (pElem) < nunits) { /* expanding */ if (nunits - pElem_nunits (pElem) <= (unsigned)pMemBlk->nunits) { /* Try to expand the existing element in the existing block */ if (ISLAST (pElem)) { /* if the last element in the block */ /* if the free space in the block is enough */ if ((int)(nunits - pElem_nunits (pElem)) <= (int)(pMemBlk->nunits - pMemBlk->free_x)) { pMemBlk->free_x += nunits - pElem_nunits (pElem); pElem_nunits (pElem) = (ASN1USINT)nunits; RTMEMDIAG1 ("memHeapRealloc: " "memory element is expanded.\n"); FILLNEWMEM (&pMemBlk->data [(pMemBlk->free_x - (nunits - pElem_nunits (pElem))) * 8u], (nunits - pElem_nunits (pElem)) * 8u); TRACEMEMELEM (pMemBlk, pElem, "Reallocated"); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK (pMemHeap, pMemBlk); return (mem_p); } } else { OSMemElemDescr* pNextElem, *pFreeElem; unsigned sumSize = pElem_nunits (pElem), freeMem = 0; RTMEMDIAG1 ("memHeapRealloc: look for free element after " "current block.\n"); /* look for free element after pElem */ pNextElem = GETNEXT (pElem); if (ISFREE (pNextElem)) { /* +1 'cos sizeof (OSMemElemDescr) == 1 unit */ sumSize += pElem_nunits (pNextElem) + 1; freeMem++; } if (sumSize >= nunits) { RTMEMDIAG1 ("memHeapRealloc: reuse free element.\n"); if (ISFREE (pNextElem)) { pFreeElem = GET_FREE_ELEM (pMemBlk); if (pFreeElem == pNextElem) { FORCE_SET_FREE_ELEM (pMemBlk, GET_NEXT_FREE (pNextElem)); } else if (pFreeElem < pElem) { /* look for previous free elem to correct nextFreeOff */ for (; pFreeElem != 0 && pFreeElem < pNextElem;) { OSMemElemDescr* pNextFreeElem = GET_NEXT_FREE (pFreeElem); if (pNextFreeElem == pNextElem) { if (pElem_nextFreeOff (pNextElem) != 0) pElem_nextFreeOff (pFreeElem) = QOFFSETOF (GET_NEXT_FREE (pNextElem), pFreeElem); else pElem_nextFreeOff (pFreeElem) = 0; CHECKMEMELEM (pMemBlk, pFreeElem); break; } pFreeElem = pNextFreeElem; } } } /* reuse empty elements after the pElem */ pMemBlk->freeMem += freeMem; if (sumSize - nunits > 1) { OSMemElemDescr* pNewElem; /* if sumSize is too large, then create new empty element */ pNewElem = (OSMemElemDescr*) (pElem_data (pElem) + nbytes); pElem_nunits (pNewElem) = (ASN1USINT)(sumSize - nunits - 1); initNewFreeElement (pMemBlk, pNewElem, pElem); pMemBlk->freeMem--; /* sizeof (OSMemElemDescr) == 1 unit */ pMemBlk->freeMem -= (nunits - pElem_nunits (pElem)); pElem_nunits (pElem) = (ASN1USINT)nunits; } else { pMemBlk->freeMem -= (sumSize - pElem_nunits (pElem)); pElem_nunits (pElem) = (ASN1USINT)sumSize; /* modify the prevOff of the next elem */ pNextElem = GETNEXT (pElem); if (pNextElem != 0) pElem_prevOff (pNextElem) = QOFFSETOF (pNextElem, pElem); } TRACEMEMELEM (pMemBlk, pElem, "Reallocated"); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMELEM (pMemBlk, (!ISLAST (pElem)) ? GETNEXT (pElem) : 0); CHECKMEMBLOCK (pMemHeap, pMemBlk); return (mem_p); } } } /* If not successful, allocate a new element and move the data into it */ RTMEMDIAG1 ("memHeapRealloc: allocate new memory...\n"); CHECKMEMHEAP (pMemHeap); newMem_p = memHeapAlloc (ppvMemHeap, nbytes); if (newMem_p == 0) return 0; /* if the old memory block is marked as saved then mark the new block as saved as well. */ if (ISSAVED (pElem)) memHeapMarkSaved (ppvMemHeap, newMem_p, TRUE); CHECKMEMHEAP (pMemHeap); memcpy (newMem_p, mem_p, (((ASN1UINT)pElem_nunits (pElem)) * 8u)); /* free old element */ RTMEMDIAG1 ("memHeapRealloc: free old pointer...\n"); memHeapFreePtr (ppvMemHeap, mem_p); CHECKMEMHEAP (pMemHeap); return (newMem_p); } else { /* shrinking */ RTMEMDIAG1 ("memHeapRealloc: shrinking ...\n"); /* just free the pointer, if nbytes == 0 */ if (nbytes == 0) { RTMEMDIAG1 ("memHeapRealloc: free pointer...\n"); memHeapFreePtr (ppvMemHeap, mem_p); return (NULL); } /* do not shrink, if size diff is too small */ /* sizeof (OSMemElemDescr) == 1 unit */ if (pElem_nunits (pElem) - nunits > 1) { /* if it is the last element in the block, then just change the size and free_x. */ if (ISLAST (pElem)) { pMemBlk->free_x -= (pElem_nunits (pElem) - nunits); FILLFREEMEM (&pMemBlk->data [pMemBlk->free_x * 8u], (pElem_nunits (pElem) - nunits) * 8u); } else { OSMemElemDescr* pNewElem; /* create new free element on the freed place */ pNewElem = (OSMemElemDescr*) (pElem_data (pElem) + nbytes); /* sizeof (OSMemElemDescr) == 1 unit */ pElem_nunits (pNewElem) = (ASN1USINT)(pElem_nunits (pElem) - nunits - 1); initNewFreeElement (pMemBlk, pNewElem, pElem); pMemBlk->freeMem += (pElem_nunits (pElem) - nunits) - 1; } pElem_nunits (pElem) = (ASN1USINT)nunits; TRACEMEMELEM (pMemBlk, pElem, "Reallocated"); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMELEM (pMemBlk, (!ISLAST (pElem)) ? GETNEXT (pElem) : pElem); CHECKMEMBLOCK (pMemHeap, pMemBlk); } return (mem_p); } } /* Clears heap memory (frees all memory, reset all heap's variables) */ void memHeapFreeAll (void** ppvMemHeap) { OSMemHeap* pMemHeap; OSMemLink* pMemLink; OSMemLink* pMemLink2; if (ppvMemHeap == 0 || *ppvMemHeap == 0) return; pMemHeap = *(OSMemHeap**)ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); pMemLink = pMemHeap->phead; RTMEMDIAG2 ("memHeapFreeAll: pMemHeap = 0x%x\n", pMemHeap); TRACEFREE (pMemHeap, "memHeapFreeAll\n\n"); CHECKMEMHEAP (pMemHeap); /* Release any dynamic memory blocks that may have been allocated */ while (pMemLink) { pMemLink2 = pMemLink; pMemLink = pMemLink2->pnext; RTMEMDIAG3 ("memHeapFreeAll: pMemLink2 = 0x%x, pMemLink = 0x%x\n", pMemLink2, pMemLink); #ifdef _MEMDEBUG if (pMemLink2->blockType & RTMEMSTD) { OSMemBlk* pMemBlk = (OSMemBlk*) pMemLink2->pMemBlk; FILLFREEMEM (pMemBlk->data, (pMemBlk->nunits * 8u)); FILLFREEMEM (pMemBlk, sizeof (*pMemBlk)); } #endif if (!(pMemLink2->blockType & RTMEMSAVED)) { OSMemBlk* pMemBlk = (OSMemBlk*) pMemLink2->pMemBlk; /* unlink block first */ if(pMemLink2->pnext != 0) { pMemLink2->pnext->pprev = pMemLink2->pprev; } if(pMemLink2->pprev != 0) { pMemLink2->pprev->pnext = pMemLink2->pnext; } else { /* head */ pMemHeap->phead = pMemLink2->pnext; } /* correct heap's variables */ pMemHeap->usedUnits -= pMemBlk->nunits; if (pMemBlk->free_x == 0) pMemHeap->freeBlocks --; else pMemHeap->usedBlocks --; /* free link and block */ if (((pMemLink2->blockType & RTMEMSTD) || (pMemLink2->blockType & RTMEMMALLOC)) && !(pMemLink2->blockType & RTMEMLINK)) free (pMemLink2->pMemBlk); free (pMemLink2); } } ast_mutex_unlock(&pMemHeap->pLock); } /* increments internal refCnt. use memHeapRelease to decrement and release */ void memHeapAddRef (void** ppvMemHeap) { OSMemHeap* pMemHeap; if (ppvMemHeap == 0 || *ppvMemHeap == 0) return; pMemHeap = *(OSMemHeap**)ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); pMemHeap->refCnt++; ast_mutex_unlock(&pMemHeap->pLock); } /* Frees all memory and heap structure as well (if was allocated) */ void memHeapRelease (void** ppvMemHeap) { OSMemHeap** ppMemHeap = (OSMemHeap**)ppvMemHeap; OSMemHeap* pMemHeap = *ppMemHeap; if (ppMemHeap != 0 && *ppMemHeap != 0 && --(*ppMemHeap)->refCnt == 0) { OSMemLink* pMemLink, *pMemLink2; memHeapFreeAll (ppvMemHeap); /* if there are RTMEMSAVED blocks - release memory for links only */ pMemLink = (*ppMemHeap)->phead; while (pMemLink) { pMemLink2 = pMemLink; pMemLink = pMemLink2->pnext; free (pMemLink2); } if ((*ppMemHeap)->flags & RT_MH_FREEHEAPDESC) { ast_mutex_destroy(&pMemHeap->pLock); free (*ppMemHeap); } *ppMemHeap = 0; } } /* This function is used for marking memory block as "saved". It means * that the memory block containing the specified memory pointer won't be * freed after calls to memHeapFreeAll/memHeapReset. User is responsible * for freeing the marked memory block by call to memFreeBlock */ void* memHeapMarkSaved (void** ppvMemHeap, const void* mem_p, ASN1BOOL saved) { OSMemHeap* pMemHeap; OSMemLink* pMemLink; ASN1UINT nsaved = 1; RTMEMDIAG2 ("memHeapMarkSaved: for mem_p = 0x%x\n", mem_p); if (ppvMemHeap == 0 || *ppvMemHeap == 0 || mem_p == 0) return 0; pMemHeap = *(OSMemHeap**)ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); pMemLink = pMemHeap->phead; /* look for chain of RAW blocks first */ for (; pMemLink != 0; pMemLink = pMemLink->pnextRaw) { if ((pMemLink->blockType & RTMEMRAW) && pMemLink->pMemBlk == mem_p) { break; } } if (pMemLink == 0) { OSMemElemDescr* pElem; OSMemBlk* pMemBlk; /* gain the MemLink from pointer */ pElem = (OSMemElemDescr*) (((char*)mem_p) - sizeof_OSMemElemDescr); if (ISFREE (pElem)) { /* already freed! */ RTMEMDIAG2 ("memHeapMarkSaved: the element 0x%x is " "already free!\n", pElem); ast_mutex_unlock(&pMemHeap->pLock); return 0; } if ((ISSAVED (pElem) && !saved) || (!ISSAVED (pElem) && saved)) { pMemBlk = GET_MEMBLK (pElem); CHECKMEMELEM (pMemBlk, pElem); CHECKMEMBLOCK(pMemHeap, pMemBlk); pMemLink = pMemBlk->plink; if (saved) SET_SAVED (pMemBlk, pElem); else CLEAR_SAVED (pMemBlk, pElem); nsaved = pMemBlk->nsaved; } else ast_mutex_unlock(&pMemHeap->pLock); return 0; } if (saved && nsaved > 0) pMemLink->blockType |= RTMEMSAVED; else if (nsaved == 0) pMemLink->blockType &= (~RTMEMSAVED); ast_mutex_unlock(&pMemHeap->pLock); return pMemLink->pMemBlk; } /* This function will set the free index in all blocks to zero thereby */ /* allowing the blocks to be reused (ED, 3/17/2002).. */ void memHeapReset (void** ppvMemHeap) { OSMemHeap* pMemHeap; OSMemLink *pMemLink; if (ppvMemHeap == 0 || *ppvMemHeap == 0) return; pMemHeap = *(OSMemHeap**)ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); pMemLink = pMemHeap->phead; TRACEFREE (pMemHeap, "memHeapReset\n\n"); while (pMemLink) { if (!(pMemLink->blockType & RTMEMSAVED)) { if (pMemLink->blockType & RTMEMSTD) { OSMemBlk* pMemBlk = (OSMemBlk*) pMemLink->pMemBlk; if (pMemBlk->free_x != 0) { pMemHeap->freeUnits += pMemBlk->nunits; pMemHeap->freeBlocks ++; } pMemBlk->free_x = 0; pMemBlk->freeElemOff = 0; pMemBlk->lastElemOff = 0; pMemBlk->freeMem = 0; FILLFREEMEM (pMemBlk->data, pMemBlk->nunits * 8u); } else if (pMemLink->blockType & RTMEMRAW) { /* if RAW block - free it */ memHeapFreePtr (ppvMemHeap, pMemLink->pMemBlk); } } pMemLink = pMemLink->pnext; } ast_mutex_unlock(&pMemHeap->pLock); } /* add memory block to list */ static OSMemLink* memHeapAddBlock (OSMemLink** ppMemLink, void* pMemBlk, int blockType) { OSMemLink* pMemLink; /* if pMemBlk has RTMEMLINK flags it means that it is allocated * cooperatively with OSMemLink, and we don't need to do additional * allocations for it. Just use pointer's arithemtic. */ if (blockType & RTMEMLINK) pMemLink = (OSMemLink*) (((ASN1OCTET*)pMemBlk) - sizeof (OSMemLink)); else { pMemLink = (OSMemLink*) malloc ( sizeof(OSMemLink) + sizeof (int)); if (pMemLink == 0) return 0; /* An extra integer is necessary to save a size of a RAW memory block to perform rtMemRealloc through malloc/memcpy/free */ *(int*)(((char*)pMemLink) + sizeof (OSMemLink)) = (int)-1; } if (pMemLink == NULL) return NULL; pMemLink->blockType = (ASN1OCTET)blockType; pMemLink->pMemBlk = pMemBlk; pMemLink->pprev = 0; pMemLink->pnext = *ppMemLink; if (*ppMemLink != 0) { if ((*ppMemLink)->blockType & RTMEMRAW) pMemLink->pnextRaw = *ppMemLink; else { pMemLink->pnextRaw = (*ppMemLink)->pnextRaw; (*ppMemLink)->pnextRaw = 0; } } else { pMemLink->pnextRaw = 0; } *ppMemLink = pMemLink; if (pMemLink->pnext != 0) pMemLink->pnext->pprev = pMemLink; ((OSMemBlk*)pMemBlk)->plink = pMemLink; /*!AB */ RTMEMDIAG2 ("memHeapAddBlock: pMemLink = 0x%x\n", pMemLink); RTMEMDIAG2 ("memHeapAddBlock: pMemLink->pnext = 0x%x\n", pMemLink->pnext); RTMEMDIAG2 ("memHeapAddBlock: pMemLink->pprev = 0x%x\n", pMemLink->pprev); return pMemLink; } int memHeapCheckPtr (void** ppvMemHeap, void* mem_p) { OSMemHeap* pMemHeap; OSMemLink* pMemLink; RTMEMDIAG2 ("memHeapCheckPtr: for mem_p = 0x%x\n", mem_p); if (ppvMemHeap == 0 || *ppvMemHeap == 0 || mem_p == 0) return 0; pMemHeap = *(OSMemHeap**)ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); pMemLink = pMemHeap->phead; for (; pMemLink != 0; pMemLink = pMemLink->pnext) { if (pMemLink->blockType & RTMEMRAW) { /* if RAW block, the pointer should be stored in pMemBlk */ if (pMemLink->pMemBlk == mem_p) { ast_mutex_unlock(&pMemHeap->pLock); return 1; } } else { OSMemBlk* pMemBlk = (OSMemBlk*)pMemLink->pMemBlk; /* Check, is the pointer inside this memory page */ if (mem_p > pMemLink->pMemBlk && mem_p < (void*)(((ASN1OCTET*)pMemLink->pMemBlk) + pMemBlk->nunits * 8u)) { /* Check, is the pointer a correct element of the mem page */ OSMemElemDescr* pElem = (OSMemElemDescr*) pMemBlk->data; for (; pElem != 0; pElem = GETNEXT (pElem)) { void* curMem_p = (void*) pElem_data (pElem); if (curMem_p == mem_p && !ISFREE (pElem)) { ast_mutex_unlock(&pMemHeap->pLock); return 1; } } } } } ast_mutex_unlock(&pMemHeap->pLock); return 0; } void memHeapSetProperty (void** ppvMemHeap, ASN1UINT propId, void* pProp) { OSMemHeap* pMemHeap; if (ppvMemHeap == 0) return; if (*ppvMemHeap == 0) memHeapCreate (ppvMemHeap); pMemHeap = *(OSMemHeap**)ppvMemHeap; ast_mutex_lock(&pMemHeap->pLock); switch (propId) { case OSRTMH_PROPID_DEFBLKSIZE: pMemHeap->defBlkSize = *(ASN1UINT*)pProp; break; case OSRTMH_PROPID_SETFLAGS: pMemHeap->flags |= ((*(ASN1UINT*)pProp) & (~RT_MH_INTERNALMASK)); break; case OSRTMH_PROPID_CLEARFLAGS: pMemHeap->flags &= ((~(*(ASN1UINT*)pProp)) | RT_MH_INTERNALMASK); break; } ast_mutex_unlock(&pMemHeap->pLock); } int memHeapCreate (void** ppvMemHeap) { OSMemHeap* pMemHeap; if (ppvMemHeap == 0) return ASN_E_INVPARAM; pMemHeap = (OSMemHeap*) malloc (sizeof (OSMemHeap)); if (pMemHeap == NULL) return ASN_E_NOMEM; memset (pMemHeap, 0, sizeof (OSMemHeap)); pMemHeap->defBlkSize = g_defBlkSize; pMemHeap->refCnt = 1; pMemHeap->flags = RT_MH_FREEHEAPDESC; ast_mutex_init(&pMemHeap->pLock); *ppvMemHeap = (void*)pMemHeap; return ASN_OK; } asterisk-11.7.0/addons/ooh323c/src/ooh245.h0000644000175000007640000006114511775134255017776 0ustar sharkyjerryweb/* * 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(OOH323CallData* call, 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); EXTERN int ooSendEmptyTermCapMsg(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(void); /** * 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, char* dir); EXTERN int ooUpdateAllLogicalChannels(struct OOH323CallData *call, char* localIP, int port); /** * 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); int ooSendRequestMode(OOH323CallData* call, int isT38Mode); /** * 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); /** * @} */ int ooRTDTimerExpired(void *pdata); int ooHandleRequestMode(OOH323CallData* call, H245RequestMode *requestMode); int ooSendRequestModeAck(OOH323CallData* call, H245SequenceNumber sequenceNumber); int ooSendRequestModeReject(OOH323CallData* call, H245SequenceNumber sequenceNumber); void ooOnReceivedRequestModeAck(OOH323CallData* call, H245RequestModeAck * requestModeAck); int ooOnReceivedRoundTripDelayRequest(OOH323CallData *call, H245SequenceNumber sequenceNumber); int ooSendRoundTripDelayRequest(OOH323CallData *call); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/eventHandler.c0000644000175000007640000000603411352772022021353 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #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); } } asterisk-11.7.0/addons/ooh323c/src/eventHandler.h0000644000175000007640000002257511274375744021405 0ustar sharkyjerryweb/* * 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 #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) (void) ; /** * 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 asterisk-11.7.0/addons/ooh323c/src/ooTimer.h0000644000175000007640000001022111222440006020336 0ustar sharkyjerryweb/* * 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 asterisk-11.7.0/addons/ooh323c/src/perutil.c0000644000175000007640000002002411775107640020422 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #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 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); 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; } asterisk-11.7.0/addons/ooh323c/src/decode.c0000644000175000007640000006743211775107640020177 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "ooasn1.h" static int decode16BitConstrainedString (OOCTXT* pctxt, Asn116BitCharString* pString, Asn116BitCharSet* pCharSet); static int decodeOctets (OOCTXT* pctxt, ASN1OCTET* pbuffer, ASN1UINT bufsiz, ASN1UINT nbits); static int getComponentLength (OOCTXT* pctxt, ASN1UINT itemBits); int decodeBits (OOCTXT* pctxt, ASN1UINT* pvalue, ASN1UINT nbits) { unsigned char mask; if (nbits == 0) { *pvalue = 0; return ASN_OK; } /* If the number of bits is less than the current bit offset, mask */ /* off the required number of bits and return.. */ if (nbits < (unsigned)pctxt->buffer.bitOffset) { /* Check if buffer contains number of bits requested */ if (pctxt->buffer.byteIndex >= pctxt->buffer.size) return LOG_ASN1ERR (pctxt, ASN_E_ENDOFBUF); pctxt->buffer.bitOffset -= nbits; *pvalue = ((pctxt->buffer.data[pctxt->buffer.byteIndex]) >> pctxt->buffer.bitOffset) & ((1 << nbits) - 1); return ASN_OK; } /* Otherwise, we first need to mask off the remaining bits in the */ /* current byte, followed by a loop to extract bits from full bytes, */ /* followed by logic to mask of remaining bits from the start of */ /* of the last byte.. */ else { /* Check if buffer contains number of bits requested */ int nbytes = (((nbits - pctxt->buffer.bitOffset) + 7) / 8); if ((pctxt->buffer.byteIndex + nbytes) >= pctxt->buffer.size) { return LOG_ASN1ERR (pctxt, ASN_E_ENDOFBUF); } /* first read current byte remaining bits */ mask = ((1 << pctxt->buffer.bitOffset) - 1); *pvalue = (pctxt->buffer.data[pctxt->buffer.byteIndex]) & mask; nbits -= pctxt->buffer.bitOffset; pctxt->buffer.bitOffset = 8; pctxt->buffer.byteIndex++; /* second read bytes from next byteIndex */ while (nbits >= 8) { *pvalue = (*pvalue << 8) | (pctxt->buffer.data[pctxt->buffer.byteIndex]); pctxt->buffer.byteIndex++; nbits -= 8; } /* third read bits & set bitoffset of the byteIndex */ if (nbits > 0) { pctxt->buffer.bitOffset = 8 - nbits; *pvalue = (*pvalue << nbits) | ((pctxt->buffer.data[pctxt->buffer.byteIndex]) >> pctxt->buffer.bitOffset); } return ASN_OK; } } int decodeBitString (OOCTXT* pctxt, ASN1UINT* numbits_p, ASN1OCTET* buffer, ASN1UINT bufsiz) { ASN1UINT bitcnt; int lstat, octidx = 0, stat; Asn1SizeCnst* pSizeList = pctxt->pSizeConstraint; ASN1BOOL doAlign; for (*numbits_p = 0;;) { lstat = decodeLength (pctxt, &bitcnt); if (lstat < 0) return LOG_ASN1ERR (pctxt, lstat); if (bitcnt > 0) { *numbits_p += bitcnt; stat = bitAndOctetStringAlignmentTest (pSizeList, bitcnt, TRUE, &doAlign); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (doAlign) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } stat = decodeOctets (pctxt, &buffer[octidx], bufsiz - octidx, bitcnt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } if (lstat == ASN_OK_FRAG) { octidx += (bitcnt / 8); } else break; } return ASN_OK; } int decodeBMPString (OOCTXT* pctxt, ASN1BMPString* pvalue, Asn116BitCharSet* permCharSet) { Asn116BitCharSet charSet; int stat; /* Set character set */ init16BitCharSet (&charSet, BMP_FIRST, BMP_LAST, BMP_ABITS, BMP_UBITS); if (permCharSet) { set16BitCharSet (pctxt, &charSet, permCharSet); } /* Decode constrained string */ stat = decode16BitConstrainedString (pctxt, pvalue, &charSet); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); return (stat); } int decodeByteAlign (OOCTXT* pctxt) { if (pctxt->buffer.bitOffset != 8) { pctxt->buffer.byteIndex++; pctxt->buffer.bitOffset = 8; } return ASN_OK; } int decodeConstrainedStringEx (OOCTXT* pctxt, const char** string, const char* charSet, ASN1UINT abits, ASN1UINT ubits, ASN1UINT canSetBits) { int stat; char* tmpstr; ASN1UINT i, idx, len, nbits = abits; /* note: need to save size constraint for use in alignCharStr */ /* because it will be cleared in decodeLength from the context.. */ Asn1SizeCnst* psize = pctxt->pSizeConstraint; /* Decode length */ stat = decodeLength (pctxt, &len); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Byte-align */ if (alignCharStr (pctxt, len, nbits, psize)) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } /* Decode data */ tmpstr = (char*) ASN1MALLOC (pctxt, len+1); if (0 != tmpstr) { if (nbits >= canSetBits && canSetBits > 4) { for (i = 0; i < len; i++) { if ((stat = decodeBits (pctxt, &idx, nbits)) == ASN_OK) { tmpstr[i] = (char) idx; } else break; } } else if (0 != charSet) { ASN1UINT nchars = strlen (charSet); for (i = 0; i < len; i++) { if ((stat = decodeBits (pctxt, &idx, nbits)) == ASN_OK) { if (idx < nchars) { tmpstr[i] = charSet[idx]; } else return LOG_ASN1ERR (pctxt, ASN_E_CONSVIO); } else break; } } else stat = ASN_E_INVPARAM; if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); tmpstr[i] = '\0'; /* add null-terminator */ } else return LOG_ASN1ERR (pctxt, ASN_E_NOMEM); *string = tmpstr; return ASN_OK; } int decodeConsInteger (OOCTXT* pctxt, ASN1INT* pvalue, ASN1INT lower, ASN1INT upper) { ASN1UINT range_value = upper - lower; ASN1UINT adjusted_value; int stat = ASN_OK; if (range_value != ASN1UINT_MAX) { range_value += 1; } if (lower > upper) return ASN_E_RANGERR; else if (lower != upper) { stat = decodeConsWholeNumber (pctxt, &adjusted_value, range_value); if (stat == ASN_OK) { *pvalue = adjusted_value + lower; if (*pvalue < lower || *pvalue > upper) stat = ASN_E_CONSVIO; } } else { *pvalue = lower; } return stat; } int decodeConsUInt8 (OOCTXT* pctxt, ASN1UINT8* pvalue, ASN1UINT lower, ASN1UINT upper) { ASN1UINT range_value, value; ASN1UINT adjusted_value; int stat = ASN_OK; /* Check for special case: if lower is 0 and upper is ASN1UINT_MAX, */ /* set range to ASN1UINT_MAX; otherwise to upper - lower + 1 */ range_value = (lower == 0 && upper == ASN1UINT_MAX) ? ASN1UINT_MAX : upper - lower + 1; if (lower != upper) { ASN1UINT range_bitcnt = 0; /* If range is <= 255, bit-field case (10.5.7a) */ if (range_value <= 255) { range_bitcnt = getUIntBitCount (range_value - 1); } /* If range is exactly 256, one-octet case (10.5.7b) */ else if (range_value == 256) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); range_bitcnt = 8; } stat = decodeBits (pctxt, &adjusted_value, range_bitcnt); if (stat == ASN_OK) { value = adjusted_value + lower; if (value < lower || value > upper) stat = ASN_E_CONSVIO; *pvalue = (ASN1OCTET)value; } } else *pvalue = (ASN1OCTET)lower; return stat; } int decodeConsUInt16 (OOCTXT* pctxt, ASN1USINT* pvalue, ASN1UINT lower, ASN1UINT upper) { ASN1UINT range_value, value; ASN1UINT adjusted_value; int stat = ASN_OK; /* Check for special case: if lower is 0 and upper is ASN1UINT_MAX, */ /* set range to ASN1UINT_MAX; otherwise to upper - lower + 1 */ range_value = (lower == 0 && upper == ASN1UINT_MAX) ? ASN1UINT_MAX : upper - lower + 1; if (lower != upper) { stat = decodeConsWholeNumber (pctxt, &adjusted_value, range_value); if (stat == ASN_OK) { value = adjusted_value + lower; /* Verify value is within given range (ED, 1/15/2002) */ if (value < lower || value > upper) stat = ASN_E_CONSVIO; *pvalue = (ASN1USINT) value; } } else *pvalue = (ASN1USINT) lower; return stat; } int decodeConsUnsigned (OOCTXT* pctxt, ASN1UINT* pvalue, ASN1UINT lower, ASN1UINT upper) { ASN1UINT range_value; ASN1UINT adjusted_value; int stat = ASN_OK; /* Check for special case: if lower is 0 and upper is ASN1UINT_MAX, */ /* set range to ASN1UINT_MAX; otherwise to upper - lower + 1 */ range_value = (lower == 0 && upper == ASN1UINT_MAX) ? ASN1UINT_MAX : upper - lower + 1; if (lower != upper) { stat = decodeConsWholeNumber (pctxt, &adjusted_value, range_value); if (stat == ASN_OK) { *pvalue = adjusted_value + lower; if (*pvalue < lower || *pvalue > upper) stat = ASN_E_CONSVIO; } } else *pvalue = lower; return stat; } int decodeConsWholeNumber (OOCTXT* pctxt, ASN1UINT* padjusted_value, ASN1UINT range_value) { ASN1UINT nocts, range_bitcnt; int stat; /* If unaligned, decode non-negative binary integer in the minimum */ /* number of bits necessary to represent the range (10.5.6) */ if (!TRUE) { range_bitcnt = getUIntBitCount (range_value - 1); } /* If aligned, encoding depended on range value (10.5.7) */ else { /* aligned */ /* If range is <= 255, bit-field case (10.5.7a) */ if (range_value <= 255) { range_bitcnt = getUIntBitCount (range_value - 1); } /* If range is exactly 256, one-octet case (10.5.7b) */ else if (range_value == 256) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); range_bitcnt = 8; } /* If range > 256 and <= 64k (65535), two-octet case (10.5.7c) */ else if (range_value <= 65536) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); range_bitcnt = 16; } /* If range > 64k, indefinite-length case (10.5.7d) */ else { stat = decodeBits (pctxt, &nocts, 2); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); range_bitcnt = (nocts + 1) * 8; } } return decodeBits (pctxt, padjusted_value, range_bitcnt); } int decodeDynBitString (OOCTXT* pctxt, ASN1DynBitStr* pBitStr) { ASN1UINT nocts; ASN1OCTET* ptmp; int nbits, stat = ASN_OK; /* If "fast copy" option is not set (ASN1FATSCOPY) or if constructed, * copy the bit string value into a dynamic memory buffer; * otherwise, store the pointer to the value in the decode * buffer in the data pointer argument. */ if (pctxt->flags & ASN1FASTCOPY) { /* check is it possible to do optimized decoding */ ASN1OCTET bit = 0; ASN1UINT byteIndex = pctxt->buffer.byteIndex; /* save byte index */ ASN1USINT bitOffset = pctxt->buffer.bitOffset; /* save bit offset */ stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = DECODEBIT (pctxt, &bit); /* read first bit of length determinant */ if (bit == 1 && stat == ASN_OK) stat = DECODEBIT (pctxt, &bit); /* read second bit */ pctxt->buffer.byteIndex = byteIndex; /* restore byte index */ pctxt->buffer.bitOffset = bitOffset; /* restore bit offset */ /* if either first or second bit != 0 - not fragmented */ if (bit == 0 && stat == ASN_OK) { ASN1UINT bitcnt; stat = decodeLength (pctxt, &bitcnt); if (stat != 0) return LOG_ASN1ERR (pctxt, stat); pBitStr->numbits = bitcnt; if (bitcnt > 0) { pBitStr->data = ASN1BUFPTR (pctxt); stat = moveBitCursor (pctxt, bitcnt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } else pBitStr->data = 0; return stat; } } nbits = getComponentLength (pctxt, 1); if (nbits < 0) return LOG_ASN1ERR (pctxt, nbits); else if (nbits == 0) { pBitStr->numbits = 0; ptmp = 0; } nocts = (nbits + 7) / 8; /* Allocate memory for the target string */ if (nocts > 0) { ptmp = (ASN1OCTET*) ASN1MALLOC (pctxt, nocts); if (0 == ptmp) return LOG_ASN1ERR (pctxt, ASN_E_NOMEM); /* Call static bit string decode function */ stat = decodeBitString (pctxt, &pBitStr->numbits, ptmp, nocts); } pBitStr->data = ptmp; return stat; } int decodeDynOctetString (OOCTXT* pctxt, ASN1DynOctStr* pOctStr) { ASN1OCTET* ptmp; int nocts, stat; /* If "fast copy" option is not set (ASN1FASTCOPY) or if constructed, * copy the octet string value into a dynamic memory buffer; * otherwise, store the pointer to the value in the decode * buffer in the data pointer argument. */ if (pctxt->flags & ASN1FASTCOPY) { /* check if it is possible to do optimized decoding */ ASN1OCTET bit = 0; ASN1UINT byteIndex = pctxt->buffer.byteIndex; /* save byte index */ ASN1USINT bitOffset = pctxt->buffer.bitOffset; /* save bit offset */ stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = DECODEBIT (pctxt, &bit); /* read first bit of length determinant */ if (bit == 1 && stat == ASN_OK) stat = DECODEBIT (pctxt, &bit); /* read second bit */ pctxt->buffer.byteIndex = byteIndex; /* restore byte index */ pctxt->buffer.bitOffset = bitOffset; /* restore bit offset */ /* if either first or second bit != 0 - not fragmented */ if (bit == 0 && stat == ASN_OK) { ASN1UINT octcnt; stat = decodeLength (pctxt, &octcnt); if (stat != 0) return LOG_ASN1ERR (pctxt, stat); pOctStr->numocts = octcnt; if (octcnt > 0) { pOctStr->data = ASN1BUFPTR (pctxt); stat = moveBitCursor (pctxt, octcnt * 8); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } else pOctStr->data = 0; return stat; } } nocts = getComponentLength (pctxt, 8); if (nocts < 0) return LOG_ASN1ERR (pctxt, nocts); else if (nocts == 0) { pOctStr->numocts = 0; ptmp = 0; } /* Allocate memory for the target string */ else { ptmp = (ASN1OCTET*) ASN1MALLOC (pctxt, nocts); if (0 == ptmp) return LOG_ASN1ERR (pctxt, ASN_E_NOMEM); } /* Call static octet string decode function */ stat = decodeOctetString (pctxt, &pOctStr->numocts, ptmp, nocts); pOctStr->data = ptmp; return stat; } int decodeLength (OOCTXT* pctxt, ASN1UINT* pvalue) { Asn1SizeCnst* pSize; ASN1UINT lower, upper; ASN1BOOL bitValue, extbit; int stat; /* If size constraint is present and extendable, decode extension */ /* bit.. */ if (isExtendableSize(pctxt->pSizeConstraint)) { stat = DECODEBIT (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; /* Reset the size constraint in the context block structure */ pctxt->pSizeConstraint = 0; /* If upper limit is less than 64k, constrained case */ if (upper < 65536) { if (lower == upper) { *pvalue = 0; stat = ASN_OK; } else stat = decodeConsWholeNumber (pctxt, pvalue, (upper - lower + 1)); if (stat == ASN_OK) *pvalue += lower; } else { /* unconstrained case OR constrained with upper bound >= 64K*/ stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = DECODEBIT (pctxt, &bitValue); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (bitValue == 0) { stat = decodeBits (pctxt, pvalue, 7); /* 10.9.3.6 */ if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } else { stat = DECODEBIT (pctxt, &bitValue); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (bitValue == 0) { stat = decodeBits (pctxt, pvalue, 14); /* 10.9.3.7 */ if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } else { ASN1UINT multiplier; stat = decodeBits (pctxt, &multiplier, 6); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); *pvalue = 16384 * multiplier; stat = ASN_OK_FRAG; } } } return stat; } int decodeObjectIdentifier (OOCTXT* pctxt, ASN1OBJID* pvalue) { ASN1UINT len; int stat, j; unsigned subid; ASN1UINT b; /* Decode unconstrained length */ if ((stat = decodeLength (pctxt, &len)) < 0) { return LOG_ASN1ERR (pctxt, stat); } /* Copy contents to a byte-aligned local buffer */ j = 0; while (len > 0 && stat == ASN_OK) { if (j < ASN_K_MAXSUBIDS) { /* Parse a subidentifier out of the contents field */ pvalue->subid[j] = 0; do { if ((stat = decodeBits (pctxt, &b, 8)) == ASN_OK) { pvalue->subid[j] = (pvalue->subid[j] * 128) + (b & 0x7F); len--; } } while (b & 0x80 && stat == ASN_OK); /* Handle the first subidentifier special case: the first two */ /* sub-id's are encoded into one using the formula (x * 40) + y */ if (j == 0) { subid = pvalue->subid[0]; pvalue->subid[0] = ((subid / 40) >= 2) ? 2 : subid / 40; pvalue->subid[1] = (pvalue->subid[0] == 2) ? subid - 80 : subid % 40; j = 2; } else j++; } else stat = ASN_E_INVOBJID; } pvalue->numids = j; if (stat == ASN_OK && len != 0) stat = ASN_E_INVLEN; return (stat); } static int decodeOctets (OOCTXT* pctxt, ASN1OCTET* pbuffer, ASN1UINT bufsiz, ASN1UINT nbits) { ASN1UINT nbytes = (nbits + 7) / 8 ; ASN1UINT i = 0, j; ASN1UINT rshift = pctxt->buffer.bitOffset; ASN1UINT lshift = 8 - rshift; ASN1UINT nbitsInLastOctet; ASN1OCTET mask; int stat; /* Check to make sure buffer contains number of bits requested */ if ((pctxt->buffer.byteIndex + nbytes) > pctxt->buffer.size) { return LOG_ASN1ERR (pctxt, ASN_E_ENDOFBUF); } /* Check to make sure buffer is big enough to hold requested */ /* number of bits.. */ if (nbytes > bufsiz) { return LOG_ASN1ERR (pctxt, ASN_E_STROVFLW); } /* If on a byte boundary, can do a direct memcpy to target buffer */ if (pctxt->buffer.bitOffset == 8) { memcpy (pbuffer, &pctxt->buffer.data[pctxt->buffer.byteIndex], nbytes); stat = moveBitCursor (pctxt, nbits); if (stat != ASN_OK) return stat; i = nbytes - 1; nbits %= 8; } else { while (nbits >= 8) { /* Transfer lower bits from stream octet to upper bits of */ /* target octet.. */ pbuffer[i] = pctxt->buffer.data[pctxt->buffer.byteIndex++] << lshift; /* Transfer upper bits from next stream octet to lower bits */ /* target octet.. */ pbuffer[i++] |= pctxt->buffer.data[pctxt->buffer.byteIndex] >> rshift; nbits -= 8; } /* Copy last partial byte */ if (nbits >= rshift) { pbuffer[i] = pctxt->buffer.data[pctxt->buffer.byteIndex++] << lshift; nbitsInLastOctet = nbits - rshift; if (nbitsInLastOctet > 0) { pbuffer[i] |= pctxt->buffer.data[pctxt->buffer.byteIndex] >> rshift; } pctxt->buffer.bitOffset = 8 - nbitsInLastOctet; } else if (nbits > 0) { /* nbits < rshift */ pbuffer[i] = pctxt->buffer.data[pctxt->buffer.byteIndex] << lshift; pctxt->buffer.bitOffset = rshift - nbits; } } /* Mask unused bits off of last byte */ if (nbits > 0) { mask = 0; for (j = 0; j < nbits; j++) { mask >>= 1; mask |= 0x80; } pbuffer[i] &= mask; } return ASN_OK; } int decodeOctetString (OOCTXT* pctxt, ASN1UINT* numocts_p, ASN1OCTET* buffer, ASN1UINT bufsiz) { ASN1UINT octcnt; int lstat, octidx = 0, stat; Asn1SizeCnst* pSizeList = pctxt->pSizeConstraint; for (*numocts_p = 0;;) { lstat = decodeLength (pctxt, &octcnt); if (lstat < 0) return LOG_ASN1ERR (pctxt, lstat); if (octcnt > 0) { *numocts_p += octcnt; if (TRUE) { ASN1BOOL doAlign; stat = bitAndOctetStringAlignmentTest (pSizeList, octcnt, FALSE, &doAlign); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); if (doAlign) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } } stat = decodeOctets (pctxt, &buffer[octidx], bufsiz - octidx, (octcnt * 8)); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } if (lstat == ASN_OK_FRAG) { octidx += octcnt; } else break; } return ASN_OK; } int decodeOpenType (OOCTXT* pctxt, const ASN1OCTET** object_p2, ASN1UINT* numocts_p) { ASN1DynOctStr octStr; int stat; stat = decodeDynOctetString (pctxt, &octStr); if (stat == ASN_OK) { *numocts_p = octStr.numocts; *object_p2 = octStr.data; } return stat; } int decodeSemiConsInteger (OOCTXT* pctxt, ASN1INT* pvalue, ASN1INT lower) { signed char b; unsigned char ub; ASN1UINT nbytes; int stat; stat = decodeLength (pctxt, &nbytes); if (stat < 0) return LOG_ASN1ERR (pctxt, stat); if (nbytes > 0) { /* Align buffer */ stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Decode first byte into a signed byte value and assign to integer. */ /* This should handle sign extension.. */ stat = decodeOctets (pctxt, (ASN1OCTET*)&b, 1, 8); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); *pvalue = b; nbytes--; /* Decode remaining bytes and add to result */ while (nbytes > 0) { stat = decodeOctets (pctxt, (ASN1OCTET*)&ub, 1, 8); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); *pvalue = (*pvalue * 256) + ub; nbytes--; } } else { /* nbytes == 0 */ *pvalue = 0; } if (lower > ASN1INT_MIN) *pvalue += lower; return ASN_OK; } int decodeSemiConsUnsigned (OOCTXT* pctxt, ASN1UINT* pvalue, ASN1UINT lower) { ASN1UINT nbytes; int stat; stat = decodeLength (pctxt, &nbytes); if (stat < 0) return LOG_ASN1ERR (pctxt, stat); if (nbytes > 0) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = decodeBits (pctxt, pvalue, nbytes * 8); } else *pvalue = 0; *pvalue += lower; return stat; } int decodeSmallNonNegWholeNumber (OOCTXT* pctxt, ASN1UINT* pvalue) { ASN1BOOL bitValue; ASN1UINT len; int ret; if ((ret = DECODEBIT (pctxt, &bitValue)) != ASN_OK) return ret; if (bitValue == 0) { return decodeBits (pctxt, pvalue, 6); /* 10.6.1 */ } else { if ((ret = decodeLength (pctxt, &len)) < 0) return ret; if ((ret = decodeByteAlign (pctxt)) != ASN_OK) return ret; return decodeBits (pctxt, pvalue, len*8); } } int decodeVarWidthCharString (OOCTXT* pctxt, const char** pvalue) { int stat; ASN1OCTET* tmpstr; ASN1UINT len; /* note: need to save size constraint for use in alignCharStr */ /* because it will be cleared in decodeLength from the context.. */ Asn1SizeCnst* psize = pctxt->pSizeConstraint; /* Decode length */ stat = decodeLength (pctxt, &len); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Byte-align */ if (alignCharStr (pctxt, len, 8, psize)) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); } /* Decode data */ tmpstr = (ASN1OCTET*) ASN1MALLOC (pctxt, len + 1); if (0 != tmpstr) { if ((stat = decodeOctets (pctxt, tmpstr, len, len * 8)) != ASN_OK) return LOG_ASN1ERR (pctxt, stat); tmpstr[len] = '\0'; /* add null-terminator */ } else return LOG_ASN1ERR (pctxt, ASN_E_NOMEM); *pvalue = (char*)tmpstr; return ASN_OK; } static int decode16BitConstrainedString (OOCTXT* pctxt, Asn116BitCharString* pString, Asn116BitCharSet* pCharSet) { ASN1UINT i, idx, nbits = pCharSet->alignedBits; int stat; /* Decode length */ stat = decodeLength (pctxt, &pString->nchars); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Byte-align */ stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); /* Decode data */ pString->data = (ASN116BITCHAR*) ASN1MALLOC (pctxt, pString->nchars*sizeof(ASN116BITCHAR)); if (pString->data) { for (i = 0; i < pString->nchars; i++) { stat = decodeBits (pctxt, &idx, nbits); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); pString->data[i] = (pCharSet->charSet.data == 0) ? idx + pCharSet->firstChar : pCharSet->charSet.data[idx]; } } else return LOG_ASN1ERR (pctxt, ASN_E_NOMEM); return ASN_OK; } static int getComponentLength (OOCTXT* pctxt, ASN1UINT itemBits) { OOCTXT lctxt; ASN1UINT len, totalLen = 0; int stat; stat = initSubContext (&lctxt, pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); stat = setPERBufferUsingCtxt (&lctxt, pctxt); if (stat != ASN_OK) { freeContext (&lctxt); return LOG_ASN1ERR (pctxt, stat); } lctxt.pSizeConstraint = pctxt->pSizeConstraint; for (;;) { stat = decodeLength (&lctxt, &len); if (stat < 0) { freeContext (&lctxt); return LOG_ASN1ERR (pctxt, stat); } totalLen += len; if (stat == ASN_OK_FRAG) { stat = moveBitCursor (&lctxt, len * itemBits); if (stat != ASN_OK) { freeContext (&lctxt); return LOG_ASN1ERR (pctxt, stat); } } else break; } freeContext (&lctxt); return totalLen; } int moveBitCursor (OOCTXT* pctxt, int bitOffset) { int currBitOffset = (pctxt->buffer.byteIndex * 8) + (8 - pctxt->buffer.bitOffset); currBitOffset += bitOffset; pctxt->buffer.byteIndex = (currBitOffset / 8); pctxt->buffer.bitOffset = 8 - (currBitOffset % 8); if (pctxt->buffer.byteIndex > pctxt->buffer.size) { return (ASN_E_ENDOFBUF); } return ASN_OK; } asterisk-11.7.0/addons/ooh323c/src/ooasn1.h0000644000175000007640000022243511352772022020146 0ustar sharkyjerryweb/* * 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 ooasn1.h * Common ASN.1 runtime constants, data structure definitions, and run-time * functions to support ASN.1 PER encoding/decoding as defined in the * ITU-T standards. */ #ifndef _OOASN1_H_ #define _OOASN1_H_ #include "asterisk.h" #include "asterisk/lock.h" #include #include #include #include #include "dlist.h" #include "ootrace.h" /** * @defgroup cruntime C Runtime Common Functions * @{ */ /* Error Code Constants */ #define ASN_OK 0 /* normal completion status */ #define ASN_OK_FRAG 2 /* message fragment detected */ #define ASN_E_BUFOVFLW -1 /* encode buffer overflow */ #define ASN_E_ENDOFBUF -2 /* unexpected end of buffer on decode */ #define ASN_E_IDNOTFOU -3 /* identifer not found */ #define ASN_E_INVOBJID -4 /* invalid object identifier */ #define ASN_E_INVLEN -5 /* invalid field length */ #define ASN_E_INVENUM -6 /* enumerated value not in defined set */ #define ASN_E_SETDUPL -7 /* duplicate element in set */ #define ASN_E_SETMISRQ -8 /* missing required element in set */ #define ASN_E_NOTINSET -9 /* element not part of set */ #define ASN_E_SEQOVFLW -10 /* sequence of field overflow */ #define ASN_E_INVOPT -11 /* invalid option encountered in choice */ #define ASN_E_NOMEM -12 /* no dynamic memory available */ #define ASN_E_INVHEXS -14 /* invalid hex string */ #define ASN_E_INVBINS -15 /* invalid binary string */ #define ASN_E_INVREAL -16 /* invalid real value */ #define ASN_E_STROVFLW -17 /* octet or bit string field overflow */ #define ASN_E_BADVALUE -18 /* invalid value specification */ #define ASN_E_UNDEFVAL -19 /* no def found for ref'd defined value */ #define ASN_E_UNDEFTYP -20 /* no def found for ref'd defined type */ #define ASN_E_BADTAG -21 /* invalid tag value */ #define ASN_E_TOODEEP -22 /* nesting level is too deep */ #define ASN_E_CONSVIO -23 /* value constraint violation */ #define ASN_E_RANGERR -24 /* invalid range (lower > upper) */ #define ASN_E_ENDOFFILE -25 /* end of file on file decode */ #define ASN_E_INVUTF8 -26 /* invalid UTF-8 encoding */ #define ASN_E_CONCMODF -27 /* Concurrent list modification */ #define ASN_E_ILLSTATE -28 /* Illegal state error */ #define ASN_E_OUTOFBND -29 /* out of bounds (of array, etc) */ #define ASN_E_INVPARAM -30 /* invalid parameter */ #define ASN_E_INVFORMAT -31 /* invalid time string format */ #define ASN_E_NOTINIT -32 /* not initialized */ #define ASN_E_TOOBIG -33 /* value is too big for given data type */ #define ASN_E_INVCHAR -34 /* invalid character (not in char set) */ #define ASN_E_XMLSTATE -35 /* XML state error */ #define ASN_E_XMLPARSE -36 /* XML parse error */ #define ASN_E_SEQORDER -37 /* SEQUENCE elements not in order */ #define ASN_E_INVINDEX -38 /* invalid index for TC id */ #define ASN_E_INVTCVAL -39 /* invalid value for TC field */ #define ASN_E_FILNOTFOU -40 /* file not found */ #define ASN_E_FILEREAD -41 /* error occurred reading file */ #define ASN_E_FILEWRITE -42 /* error occurred writing file */ #define ASN_E_INVBASE64 -43 /* invalid base64 encoding */ #define ASN_E_INVSOCKET -44 /* invalid socket operation */ #define ASN_E_XMLLIBNFOU -45 /* XML library is not found */ #define ASN_E_XMLLIBINV -46 /* XML library is invalid */ #define ASN_E_NOTSUPP -99 /* non-supported ASN construct */ #define ASN_K_INDEFLEN -9999 /* indefinite length message indicator */ /* universal built-in type ID code value constants */ #define ASN_ID_EOC 0 /* end of contents */ #define ASN_ID_BOOL 1 /* boolean */ #define ASN_ID_INT 2 /* integer */ #define ASN_ID_BITSTR 3 /* bit string */ #define ASN_ID_OCTSTR 4 /* byte (octet) string */ #define ASN_ID_NULL 5 /* null */ #define ASN_ID_OBJID 6 /* object ID */ #define ASN_ID_OBJDSC 7 /* object descriptor */ #define ASN_ID_EXTERN 8 /* external type */ #define ASN_ID_REAL 9 /* real */ #define ASN_ID_ENUM 10 /* enumerated value */ #define ASN_ID_EPDV 11 /* EmbeddedPDV type */ #define ASN_ID_RELOID 13 /* relative object ID */ #define ASN_ID_SEQ 16 /* sequence, sequence of */ #define ASN_ID_SET 17 /* set, set of */ #define ASN_SEQ_TAG 0x30 /* SEQUENCE universal tag byte */ #define ASN_SET_TAG 0x31 /* SET universal tag byte */ /* Restricted character string type ID's */ #define ASN_ID_NumericString 18 #define ASN_ID_PrintableString 19 #define ASN_ID_TeletexString 20 #define ASN_ID_T61String ASN_ID_TeletexString #define ASN_ID_VideotexString 21 #define ASN_ID_IA5String 22 #define ASN_ID_UTCTime 23 #define ASN_ID_GeneralTime 24 #define ASN_ID_GraphicString 25 #define ASN_ID_VisibleString 26 #define ASN_ID_GeneralString 27 #define ASN_ID_UniversalString 28 #define ASN_ID_BMPString 30 /* flag mask values */ #define XM_SEEK 0x01 /* seek match until found or end-of-buf */ #define XM_ADVANCE 0x02 /* advance pointer to contents on match */ #define XM_DYNAMIC 0x04 /* alloc dyn mem for decoded variable */ #define XM_SKIP 0x08 /* skip to next field after parsing tag */ /* Sizing Constants */ #define ASN_K_MAXDEPTH 32 /* maximum nesting depth for messages */ #define ASN_K_MAXSUBIDS 128 /* maximum sub-id's in an object ID */ #define ASN_K_MAXENUM 100 /* maximum enum values in an enum type */ #define ASN_K_MAXERRP 5 /* maximum error parameters */ #define ASN_K_MAXERRSTK 8 /* maximum levels on error ctxt stack */ #define ASN_K_ENCBUFSIZ 2*1024 /* dynamic encode buffer extent size */ #define ASN_K_MEMBUFSEG 1024 /* memory buffer extent size */ /* Canonical character set definitions */ #define NUM_ABITS 4 #define NUM_UBITS 4 #define NUM_CANSET \ " 0123456789" #define PRN_ABITS 8 #define PRN_UBITS 7 #define PRN_CANSET \ " '()+,-./0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" #define VIS_ABITS 8 #define VIS_UBITS 7 #define VIS_CANSET \ " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"\ "^_`abcdefghijklmnopqrstuvwxyz{|}~" #define T61_ABITS 8 #define T61_UBITS 7 #define T61_CANSET \ " !\"%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]"\ "_abcdefghijklmnopqrstuvwxyz" #define IA5_ABITS 8 #define IA5_UBITS 7 #define IA5_CANSET \ "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"\ "\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"\ " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"\ "^_`abcdefghijklmnopqrstuvwxyz{|}~" #define IA5_RANGE1_LOWER 0 #define IA5_RANGE2_LOWER 0x5f #define GEN_ABITS 8 #define GEN_UBITS 7 #define GEN_CANSET \ "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"\ "\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"\ " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"\ "`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207"\ "\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237"\ "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257"\ "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277"\ "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"\ "\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"\ "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357"\ "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" #define BMP_ABITS 16 #define BMP_UBITS 16 #define BMP_FIRST 0 #define BMP_LAST 0xffff #define UCS_ABITS 32 #define UCS_UBITS 32 #define UCS_FIRST 0 #define UCS_LAST 0xfffffffful /* ASN.1 Primitive Type Definitions */ typedef char ASN1CHAR; typedef unsigned char ASN1OCTET; typedef ASN1OCTET ASN1BOOL; typedef signed char ASN1INT8; typedef unsigned char ASN1UINT8; typedef int ASN1INT; typedef unsigned int ASN1UINT; typedef ASN1INT ASN1ENUM; typedef double ASN1REAL; typedef short ASN1SINT; typedef unsigned short ASN1USINT; typedef ASN1UINT ASN1TAG; #define ASN1TAG_LSHIFT 24 typedef ASN1USINT ASN116BITCHAR; typedef ASN1UINT ASN132BITCHAR; typedef void* ASN1ANY; #define ASN1UINT_MAX 4294967295U #define ASN1INT_MAX ((ASN1INT)2147483647L) #define ASN1INT_MIN ((ASN1INT)(-ASN1INT_MAX-1)) #define ASN1UINTCNT(val) val##u #ifndef ASN1INT64 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || \ defined(_WIN32) #define ASN1INT64 __int64 #elif defined(__IBMC__) || defined(__GNUC__) || defined(__SUNPRO_C) || \ defined(__SUNPRO_CC) || defined(__CC_ARM) || \ defined(__HPUX_CC__) || defined(__HP_aCC) #define ASN1INT64 long long #else /* !MSC_VER && !__IBMC__ etc */ #define ASN1INT64 long #endif #endif /* ASN1INT64 */ #ifndef FALSE #define FALSE 0 #define TRUE 1 #endif typedef struct { /* object identifier */ ASN1UINT numids; ASN1UINT subid[ASN_K_MAXSUBIDS]; } ASN1OBJID; typedef struct { /* generic octet string structure */ ASN1UINT numocts; ASN1OCTET data[1]; } ASN1OctStr; typedef struct { /* generic octet string structure (dynamic) */ ASN1UINT numocts; const ASN1OCTET* data; } ASN1DynOctStr; typedef struct { /* generic bit string structure (dynamic) */ ASN1UINT numbits; const ASN1OCTET* data; } ASN1DynBitStr; typedef struct { /* generic sequence of structure */ ASN1UINT n; void* elem; } ASN1SeqOf; typedef struct { /* sequence of OCTET STRING */ ASN1UINT n; ASN1DynOctStr* elem; } ASN1SeqOfOctStr; typedef struct { /* generic open type data structure */ ASN1UINT numocts; const ASN1OCTET* data; } ASN1OpenType; /* ASN.1 useful type definitions */ typedef struct { ASN1UINT nchars; ASN116BITCHAR* data; } Asn116BitCharString; typedef struct { ASN1UINT nchars; ASN132BITCHAR* data; } Asn132BitCharString; typedef const char* ASN1GeneralizedTime; typedef const char* ASN1GeneralString; typedef const char* ASN1GraphicString; typedef const char* ASN1IA5String; typedef const char* ASN1ISO646String; typedef const char* ASN1NumericString; typedef const char* ASN1ObjectDescriptor; typedef const char* ASN1PrintableString; typedef const char* ASN1TeletexString; typedef const char* ASN1T61String; typedef const char* ASN1UTCTime; typedef const char* ASN1UTF8String; typedef const char* ASN1VideotexString; typedef const char* ASN1VisibleString; typedef Asn116BitCharString ASN1BMPString; typedef Asn132BitCharString ASN1UniversalString; /* ASN.1 constrained string structures */ typedef struct { int nchars; char data[255]; } Asn1CharArray; typedef struct { Asn1CharArray charSet; const char* canonicalSet; int canonicalSetSize; unsigned canonicalSetBits; unsigned charSetUnalignedBits; unsigned charSetAlignedBits; } Asn1CharSet; typedef struct { Asn116BitCharString charSet; ASN1USINT firstChar, lastChar; unsigned unalignedBits; unsigned alignedBits; } Asn116BitCharSet; /* ASN.1 size constraint structure */ typedef struct _Asn1SizeCnst { ASN1BOOL extended; ASN1UINT lower; ASN1UINT upper; struct _Asn1SizeCnst* next; } Asn1SizeCnst; /* ASN.1 encode/decode buffer info structure */ typedef struct { ASN1OCTET* data; /* pointer to start of data buffer */ ASN1UINT byteIndex; /* byte index */ ASN1UINT size; /* current buffer size */ ASN1SINT bitOffset; /* current bit offset (8 - 1) */ ASN1BOOL dynamic; /* is buffer dynamic? */ } ASN1BUFFER; /* This structure is used to save the current state of the buffer */ typedef struct { ASN1UINT byteIndex; /* byte index */ ASN1SINT bitOffset; /* current bit offset (8 - 1) */ ASN1USINT flags; /* flag bits */ } ASN1BUFSAVE; /* ASN.1 run-time error info structures */ typedef struct { const char* module; int lineno; } ASN1ErrLocn; typedef struct { ASN1ErrLocn stack[ASN_K_MAXERRSTK]; int stkx; int status; int parmcnt; const char* parms[ASN_K_MAXERRP]; } ASN1ErrInfo; #define XM_K_MEMBLKSIZ (4*1024) /* Flag mask constant values */ #define ASN1DYNCTXT 0x8000 #define ASN1INDEFLEN 0x4000 #define ASN1TRACE 0x2000 #define ASN1LASTEOC 0x1000 #define ASN1FASTCOPY 0x0800 /* turns on the "fast copy" mode */ #define ASN1CONSTAG 0x0400 /* form of last parsed tag */ #define ASN1CANXER 0x0200 /* canonical XER */ #define ASN1SAVEBUF 0x0100 /* do not free dynamic encode buffer */ #define ASN1OPENTYPE 0x0080 /* item is an open type field */ /* ASN.1 encode/decode context block structure */ struct EventHandler; typedef struct OOCTXT { /* context block */ void* pMsgMemHeap; /* internal message memory heap */ void* pTypeMemHeap; /* memory heap */ ASN1BUFFER buffer; /* data buffer */ ASN1ErrInfo errInfo; /* run-time error info */ Asn1SizeCnst* pSizeConstraint; /* Size constraint list */ const char* pCharSet; /* String of permitted characters */ struct EventHandler* pEventHandler; /* event handler object */ ASN1USINT flags; /* flag bits */ ASN1OCTET spare[2]; ast_mutex_t pLock; } OOCTXT; /* macros and function prototypes */ #ifndef ASN1MAX #define ASN1MAX(a,b) (((a)>(b))?(a):(b)) #endif #ifndef ASN1MIN #define ASN1MIN(a,b) (((a)<(b))?(a):(b)) #endif /** * @defgroup mem Memory Allocation Macros and Functions * @ingroup cruntime * * Memory allocation functions and macros handle memory management for the * ASN1C run-time. Special algorithms are used for allocation and deallocation * of memory to improve the run-time performance. @{ */ /** * Allocate a dynamic array. This macro allocates a dynamic array of records of * the given type. This version of the macro will return the ASN_E_NOMEM error * status if the memory request cannot be fulfilled. * * @param pctxt - Pointer to a context block * @param pseqof - Pointer to a generated SEQUENCE OF array structure. * The n member variable must be set to the number * of records to allocate. * @param type - Data type of an array record */ #define ALLOC_ASN1ARRAY(pctxt,pseqof,type) do {\ if (sizeof(type)*(pseqof)->n < (pseqof)->n) return ASN_E_NOMEM; \ if (((pseqof)->elem = (type*) memHeapAlloc \ (&(pctxt)->pTypeMemHeap, sizeof(type)*(pseqof)->n)) == 0) return ASN_E_NOMEM; \ } while (0) /** * Allocate and zero an ASN.1 element. This macro allocates and zeros a single * element of the given type. * * @param pctxt - Pointer to a context block * @param type - Data type of record to allocate */ #define ALLOC_ASN1ELEM(pctxt,type) \ (type*) memHeapAllocZ (&(pctxt)->pTypeMemHeap, sizeof(type)) /** * Allocate memory. This macro allocates the given number of bytes. It is * similar to the C \c malloc run-time function. * * @param pctxt - Pointer to a context block * @param nbytes - Number of bytes of memory to allocate * @return - Void pointer to allocated memory or NULL if * insufficient memory was available to fulfill the * request. */ #define ASN1MALLOC(pctxt,nbytes) \ memHeapAlloc(&(pctxt)->pTypeMemHeap, nbytes) /** * Free memory associated with a context. This macro frees all memory held * within a context. This is all memory allocated using the ASN1MALLOC (and * similar macros) and the mem memory allocation functions using the given * context variable. * * @param pctxt - Pointer to a context block */ #define ASN1MEMFREE(pctxt) \ memHeapFreeAll(&(pctxt)->pTypeMemHeap) /** * Free memory pointer. This macro frees memory at the given pointer. The * memory must have been allocated using the ASN1MALLOC (or similar) macros or * the mem memory allocation functions. This macro is similar to the C \c * free function. * * @param pctxt - Pointer to a context block * @param pmem - Pointer to memory block to free. This must have been * allocated using the ASN1MALLOC macro or the * memHeapAlloc function. */ #define ASN1MEMFREEPTR(pctxt,pmem) \ memHeapFreePtr(&(pctxt)->pTypeMemHeap, (void*)pmem) /** * @} */ #define ASN1BUFCUR(cp) (cp)->buffer.data[(cp)->buffer.byteIndex] #define ASN1BUFPTR(cp) &(cp)->buffer.data[(cp)->buffer.byteIndex] #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 */ #ifndef _NO_MALLOC /*#define ASN1CRTMALLOC0(nbytes) malloc(nbytes) #define ASN1CRTFREE0(ptr) free(ptr) */ #else #ifdef _NO_THREADS extern EXTERN OOCTXT g_ctxt; #define ASN1CRTMALLOC0(nbytes) memAlloc(&g_ctxt,(nbytes)) #define ASN1CRTFREE0(ptr) memFreePtr(&g_ctxt,(ptr)) #else #define ASN1CRTMALLOC0(nbytes) (void*)0 #define ASN1CRTFREE0(ptr) (void*)0 #endif /* _NO_THREADS */ #endif /* _NO_MALLOC */ #define ASN1CRTMALLOC memHeapAlloc #define ASN1CRTFREE ASN1MEMFREEPTR /* Function prototypes */ #define DE_INCRBITIDX(pctxt) \ ((--(pctxt)->buffer.bitOffset < 0) ? \ ((++(pctxt)->buffer.byteIndex >= (pctxt)->buffer.size) ? ASN_E_ENDOFBUF : \ ((pctxt)->buffer.bitOffset = 7, ASN_OK)) : ASN_OK) #define DE_BIT(pctxt,pvalue) \ ((DE_INCRBITIDX (pctxt) != ASN_OK) ? ASN_E_ENDOFBUF : ( \ ((*(pvalue) = (((pctxt)->buffer.data[(pctxt)->buffer.byteIndex]) & \ (1 << (pctxt)->buffer.bitOffset)) != 0), ASN_OK) )) /* #define DE_BIT(pctxt,pvalue) \ ((DE_INCRBITIDX (pctxt) != ASN_OK) ? ASN_E_ENDOFBUF : ((pvalue) ? \ ((*(pvalue) = (((pctxt)->buffer.data[(pctxt)->buffer.byteIndex]) & \ (1 << (pctxt)->buffer.bitOffset)) != 0), ASN_OK) : ASN_OK )) */ #define encodeIA5String(pctxt,value,permCharSet) \ encodeConstrainedStringEx (pctxt, value, permCharSet, 8, 7, 7) #define encodeGeneralizedTime encodeIA5String #define decodeIA5String(pctxt,pvalue,permCharSet) \ decodeConstrainedStringEx (pctxt, pvalue, permCharSet, 8, 7, 7) #define decodeGeneralizedTime decodeIA5String /* run-time error and diagnostic functions */ /* Context management functions */ /** * @defgroup cmfun Context Management Functions * @{ * * Context initialization functions handle the allocation, initialization, and * destruction of ASN.1 context variables (variables of type OOCTXT). These * variables hold all of the working data used during the process of encoding * or decoding a message. The context provides thread safe operation by * isolating what would otherwise be global variables within this structure. * The context variable is passed from function to function as a message is * encoded or decoded and maintains state information on the encoding or * decoding process. */ /** * This function assigns a buffer to a context block. The block should have * been previously initialized by initContext. * * @param pctxt The pointer to the context structure variable to be * initialized. * @param bufaddr For encoding, the address of a memory buffer to receive * and encode a message. For decoding the address of a * buffer that contains the message data to be decoded. * This address will be stored within the context * structure. For encoding it might be zero, the dynamic * buffer will be used in this case. * @param bufsiz The size of the memory buffer. For encoding, it might be * zero; the dynamic buffer will be used in this case. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int initContextBuffer (OOCTXT* pctxt, const ASN1OCTET* bufaddr, ASN1UINT bufsiz); /** * This function initializes a context block. It makes sure that if the block * was not previosly initialized, that all key working parameters are set to * thier correct initial state values (i.e. declared within a function as a * normal working variable), it is required that they invoke this function * before using it. * * @param pctxt The pointer to the context structure variable to be * initialized. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int initContext (OOCTXT* pctxt); /** * This function frees all dynamic memory associated with a context. This * includes all memory inside the block (in particular, the list of memory * blocks used by the mem functions). * * @param pctxt A pointer to a context structure. */ EXTERN void freeContext (OOCTXT* pctxt); /** * This function allocates a new OOCTXT block and initializes it. Although * the block is allocated from the standard heap, it should not be freed using * free. The freeContext function should be used because this frees items * allocated within the block before freeing the block itself. * * @return Pointer to newly created context */ EXTERN OOCTXT* newContext (void); EXTERN void copyContext (OOCTXT* pdest, OOCTXT* psrc); EXTERN int initSubContext (OOCTXT* pctxt, OOCTXT* psrc); EXTERN void setCtxtFlag (OOCTXT* pctxt, ASN1USINT mask); EXTERN void clearCtxtFlag (OOCTXT* pctxt, ASN1USINT mask); EXTERN int setPERBuffer (OOCTXT* pctxt, ASN1OCTET* bufaddr, ASN1UINT bufsiz, ASN1BOOL aligned); EXTERN int setPERBufferUsingCtxt (OOCTXT* pTarget, OOCTXT* pSource); #define ZEROCONTEXT(pctxt) memset(pctxt,0,sizeof(OOCTXT)) /** * @} cmfun */ /** * @defgroup errfp Error Formatting and Print Functions * @{ * * Error formatting and print functions allow information about the * encode/decode errors to be added to a context block structure and then * printed out when the error is propagated to the top level. */ /** * This function adds an integer parameter to an error information structure. * Parameter substitution is done in much the same way as it is done in C * printf statments. The base error message specification that goes along with * a particular status code may have variable fields built in using '%' * modifiers. These would be replaced with actual parameter data. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param errParm The typed error parameter. * @return The status of the operation. */ EXTERN int errAddIntParm (ASN1ErrInfo* pErrInfo, int errParm); /** * This function adds an string parameter to an error information structure. * Parameter substitution is done in much the same way as it is done in C * printf statments. The base error message specification that goes along with * a particular status code may have variable fields built in using '%' * modifiers. These would be replaced with actual parameter data. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param errprm_p The typed error parameter. * @return The status of the operation. */ EXTERN int errAddStrParm (ASN1ErrInfo* pErrInfo, const char* errprm_p); /** * This function adds an unsigned integer parameter to an error information * structure. Parameter substitution is done in much the same way as it is done * in C printf statments. The base error message specification that goes along * with a particular status code may have variable fields built in using '%' * modifiers. These would be replaced with actual parameter data. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param errParm The typed error parameter. * @return The status of the operation. */ EXTERN int errAddUIntParm (ASN1ErrInfo* pErrInfo, unsigned int errParm); EXTERN int errCopyData (ASN1ErrInfo* pSrcErrInfo, ASN1ErrInfo* pDestErrInfo); /** * This function frees memory associated with the storage of parameters * associated with an error message. These parameters are maintained on an * internal linked list maintained within the error information structure. The * list memory must be freed when error processing is complete. This function * is called from within errPrint after teh error has been printed out. It is * also called in teh freeContext function. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). */ EXTERN void errFreeParms (ASN1ErrInfo* pErrInfo); EXTERN char* errFmtMsg (ASN1ErrInfo* pErrInfo, char* bufp); /** * This function gets the text of the error * * @param pctxt A pointer to a context structure. */ EXTERN char* errGetText (OOCTXT* pctxt); /** * This function prints error information to the standard output device. The * error information is stored in a structure of type ASN1ErrInfo. A structure * of the this type is part f the OOCTXT structure. This is where error * information is stored within the ASN1C generated and low-level encode/decode * functions. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). */ EXTERN void errPrint (ASN1ErrInfo* pErrInfo); /** * This function resets the error information in the error information * sturcture. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). */ EXTERN int errReset (ASN1ErrInfo* pErrInfo); /** * This function sets error information in an error information structure. The * information set includes status code, module name, and line number. Location * information (i.e. module name and line number) is pushed onto a stack within * the error information structure to provide a complete stack trace when the * information is printed out. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param status The error status code. This is one of the negative error * status codes. * @param module The name of the module (C or C++ source file) in which * the module occurred. This is typically obtained by * using the _FILE_ macro. * @param lno The line number at which the error occurred. This is * typically obtained by using the _LINE_ macro. * @return The status value passed to the operation in the third * argument. This makes it possible to set the error * information and return the status value in one line of * code. */ EXTERN int errSetData (ASN1ErrInfo* pErrInfo, int status, const char* module, int lno); #ifndef _COMPACT #define LOG_ASN1ERR(ctxt,stat) \ errSetData(&(ctxt)->errInfo,stat,__FILE__,__LINE__) #else #define LOG_ASN1ERR(ctxt,stat) \ ((ctxt)->errInfo.status = stat, stat) #endif #define LOG_ASN1ERR_AND_FREE(pctxt,stat,lctxt) \ freeContext ((lctxt)), LOG_ASN1ERR(pctxt, stat) /** * @} */ #define RT_MH_DONTKEEPFREE 0x1 #define OSRTMH_PROPID_DEFBLKSIZE 1 #define OSRTMH_PROPID_SETFLAGS 2 #define OSRTMH_PROPID_CLEARFLAGS 3 #define OSRTMH_PROPID_USER 10 /** * @addtogroup rtmem * @{ */ /** * Allocate memory. This macro allocates the given number of bytes. It is * similar to the C \c malloc run-time function. * * @param pctxt - Pointer to a context block * @param nbytes - Number of bytes of memory to allocate * @return - Void pointer to allocated memory or NULL if insufficient memory * was available to fulfill the request. */ #define memAlloc(pctxt,nbytes) \ memHeapAlloc(&(pctxt)->pTypeMemHeap,nbytes) /** * Allocate and zero memory. This macro allocates the given number of bytes * and then initializes the memory block to zero. * * @param pctxt - Pointer to a context block * @param nbytes - Number of bytes of memory to allocate * @return - Void pointer to allocated memory or NULL if insufficient memory * was available to fulfill the request. */ #define memAllocZ(pctxt,nbytes) \ memHeapAllocZ(&(pctxt)->pTypeMemHeap,nbytes) /** * Reallocate memory. This macro reallocates a memory block (either * expands or contracts) to the given number of bytes. It is * similar to the C \c realloc run-time function. * * @param pctxt - Pointer to a context block * @param mem_p - Pointer to memory block to reallocate. This must have been * allocated using the memHeapAlloc macro or the memHeapAlloc function. * @param nbytes - Number of bytes of memory to which the block is to be * resized. * @return - Void pointer to allocated memory or NULL if insufficient memory * was available to fulfill the request. This may be the same as the pmem * pointer that was passed in if the block did not need to be relocated. */ #define memRealloc(pctxt,mem_p,nbytes) \ memHeapRealloc(&(pctxt)->pTypeMemHeap, (void*)mem_p, nbytes) /** * Free memory pointer. This macro frees memory at the given pointer. * The memory must have been allocated using the memHeapAlloc (or similar) * macros or the mem memory allocation macros. This macro is * similar to the C \c free function. * * @param pctxt - Pointer to a context block * @param mem_p - Pointer to memory block to free. This must have * been allocated using the memHeapAlloc or memAlloc macro or the * memHeapAlloc function. */ #define memFreePtr(pctxt,mem_p) \ if (memHeapCheckPtr (&(pctxt)->pTypeMemHeap, (void*)mem_p)) \ memHeapFreePtr(&(pctxt)->pTypeMemHeap, (void*)mem_p) /** * Free memory associated with a context. This macro frees all memory * held within a context. This is all memory allocated using the * memHeapAlloc (and similar macros) and the mem memory allocation * functions using the given context variable. * * @param pctxt - Pointer to a context block */ #define memFree(pctxt) \ memHeapFreeAll(&(pctxt)->pTypeMemHeap) /** * Reset memory associated with a context. This macro resets all memory * held within a context. This is all memory allocated using the memHeapAlloc * (and similar macros) and the mem memory allocation functions using the * given context variable. * *

The difference between this and the ASN1MEMFREE macro is that the * memory blocks held within the context are not actually freed. Internal * pointers are reset so the existing blocks can be reused. This can * provide a performace improvement for repetitive tasks such as decoding * messages in a loop. * * @param pctxt - Pointer to a context block */ #define memReset(pctxt) \ memHeapReset(&(pctxt)->pTypeMemHeap) /* Alias for __cdecl modifier; if __cdecl keyword is not supported, * redefine it as empty macro. */ #if !defined(OSCDECL) #if defined(_MSC_VER) || defined(__BORLANDC__) #define OSCDECL __cdecl #else #define OSCDECL #endif #endif /* OSCDECL */ /* Pointers to C Run-Time memory allocation functions * * (See memSetAllocFuncs) */ typedef void *(OSCDECL *OSMallocFunc ) (size_t size); typedef void *(OSCDECL *OSReallocFunc) (void *ptr, size_t size); typedef void (OSCDECL *OSFreeFunc ) (void *ptr); EXTERN void memHeapAddRef (void** ppvMemHeap); EXTERN void* memHeapAlloc (void** ppvMemHeap, int nbytes); EXTERN void* memHeapAllocZ (void** ppvMemHeap, int nbytes); EXTERN int memHeapCheckPtr (void** ppvMemHeap, void* mem_p); EXTERN int memHeapCreate (void** ppvMemHeap); EXTERN void memHeapFreeAll (void** ppvMemHeap); EXTERN void memHeapFreePtr (void** ppvMemHeap, void* mem_p); EXTERN void* memHeapRealloc (void** ppvMemHeap, void* mem_p, int nbytes_); EXTERN void memHeapRelease (void** ppvMemHeap); EXTERN void memHeapReset (void** ppvMemHeap); EXTERN void* memHeapMarkSaved (void** ppvMemHeap, const void* mem_p, ASN1BOOL saved); EXTERN void memHeapSetProperty (void** ppvMemHeap, ASN1UINT propId, void* pProp); /** * This function sets the pointers to standard allocation functions. These * functions are used to allocate/reallocate/free the memory blocks. By * default, standard C functions - 'malloc', 'realloc' and 'free' - are used. * But if some platforms do not support these functions (or some other reasons * exist) they can be overloaded. The functions being overloaded should have * the same prototypes as standard ones. * * @param malloc_func Pointer to the memory allocation function ('malloc' by * default). * @param realloc_func Pointer to the memory reallocation function ('realloc' * by default). * @param free_func Pointer to the memory deallocation function ('free' by * default). */ EXTERN void memSetAllocFuncs (OSMallocFunc malloc_func, OSReallocFunc realloc_func, OSFreeFunc free_func); EXTERN void memFreeOpenSeqExt (OOCTXT* pctxt, DList *pElemList); /* * This function sets flags to a heap. May be used to control the heap's * behavior. * * @param pctxt Pointer to a memory block structure that contains the * list of dynamic memory block maintained by these * functions. * @param flags The flags. */ EXTERN void memHeapSetFlags (OOCTXT* pctxt, ASN1UINT flags); /* * This function clears memory heap flags. * * @param pctxt Pointer to a memory block structure that contains the * list of dynamic memory block maintained by these * functions. * @param flags The flags */ EXTERN void memHeapClearFlags (OOCTXT* pctxt, ASN1UINT flags); /** * This function sets the pointer to standard allocation functions. These * functions are used to allocate/reallocate/free the memory blocks. By * default, standard C functions - malloc, realloc, and free - are used. But if * some platforms do not support these functions or some other reasons exist) * they can be overloaded. The functions being overloaded should have the same * prototypes as standard ones. * * @param pctxt Pointer to a context block. * @param blkSize The currently used minimum size and the granularity of * memory blocks. */ EXTERN void memHeapSetDefBlkSize (OOCTXT* pctxt, ASN1UINT blkSize); /** * This function returns the actual granularity of memory blocks. * * @param pctxt Pointer to a context block. */ EXTERN ASN1UINT memHeapGetDefBlkSize (OOCTXT* pctxt); #ifdef _STATIC_HEAP EXTERN void memSetStaticBuf (void* memHeapBuf, ASN1UINT blkSize); #endif /* PER encode/decode related items */ #define INCRBITIDX(pctxt) \ ((--(pctxt)->buffer.bitOffset < 0) ? \ ((++(pctxt)->buffer.byteIndex >= (pctxt)->buffer.size) ? ASN_E_ENDOFBUF : \ ((pctxt)->buffer.bitOffset = 7, ASN_OK)) : ASN_OK) #define DECODEBIT(pctxt,pvalue) \ ((INCRBITIDX (pctxt) != ASN_OK) ? ASN_E_ENDOFBUF : ( \ ((*(pvalue) = (((pctxt)->buffer.data[(pctxt)->buffer.byteIndex]) & \ (1 << (pctxt)->buffer.bitOffset)) != 0), ASN_OK) )) /* #define DECODEBIT(pctxt,pvalue) \ ((INCRBITIDX (pctxt) != ASN_OK) ? ASN_E_ENDOFBUF : ((pvalue) ? \ ((*(pvalue) = (((pctxt)->buffer.data[(pctxt)->buffer.byteIndex]) & \ (1 << (pctxt)->buffer.bitOffset)) != 0), ASN_OK) : ASN_OK )) */ /* #define SETCHARSET(csetvar, canset, abits, ubits) \ csetvar.charSet.nchars = 0; \ csetvar.canonicalSet = canset; \ csetvar.canonicalSetSize = sizeof(canset)-1; \ csetvar.canonicalSetBits = getUIntBitCount(csetvar.canonicalSetSize); \ csetvar.charSetUnalignedBits = ubits; \ csetvar.charSetAlignedBits = abits; */ /** * This function will decode a series of multiple bits and place the results in * an unsigned integer variable. * * @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 pvalue A pointer to an unsigned integer variable to receive the * decoded result. * @param nbits The number of bits to decode. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeBits (OOCTXT* pctxt, ASN1UINT* pvalue, ASN1UINT nbits); /** * This function will decode a value of the ASN.1 bit string type whose maximum * size is is known in advance. The ASN1C complier generates a call to this * function to decode bit string productions or elements that contain a size * constraint. * * @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 numbits_p Pointer to an unsigned integer variable to receive * decoded number of bits. * @param buffer Pointer to a fixed-size or pre-allocated array of bufsiz * octets to receive a decoded bit string. * @param bufsiz Length (in octets) of the buffer to receive the decoded * bit string. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeBitString (OOCTXT* pctxt, ASN1UINT* numbits_p, ASN1OCTET* buffer, ASN1UINT bufsiz); /** * This function will decode a variable of the ASN.1 BMP character string. This * differs from the decode routines for the character strings previously * described in that the BMP string type is based on 16-bit characters. A * 16-bit character string is modeled using an array of unsigned short * integers. * * @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 pvalue Pointer to character string structure to receive the * decoded result The structure includes a count field * containing the number of characters and an array of * unsigned short integers to hold the 16-bit character * values. * @param permCharSet A pointer to the constraining character set. This * contains an array containing all valid characters in * the set as well as the aligned and unaligned bit * counts required to encode the characters. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeBMPString (OOCTXT* pctxt, ASN1BMPString* pvalue, Asn116BitCharSet* permCharSet); /** * This function will position the decode bit cursor on the next byte boundary. * * @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. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeByteAlign (OOCTXT* pctxt); /** * This function will decode an integer constrained either by a value or value * range constraint. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to integer variable to receive decoded value. * @param lower Lower range value. * @param upper Upper range value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeConsInteger (OOCTXT* pctxt, ASN1INT* pvalue, ASN1INT lower, ASN1INT upper); /** * This function will decode an unsigned integer constrained either by a value * or value range constraint. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to unsigned integer variable to receive decoded * value. * @param lower Lower range value. * @param upper Upper range value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeConsUnsigned (OOCTXT* pctxt, ASN1UINT* pvalue, ASN1UINT lower, ASN1UINT upper); /** * This function will decode an 8-bit unsigned integer constrained either by a * value or value range constraint. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to 8-bit unsigned integer variable to receive * decoded value. * @param lower Lower range value. * @param upper Upper range value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeConsUInt8 (OOCTXT* pctxt, ASN1UINT8* pvalue, ASN1UINT lower, ASN1UINT upper); /** * This function will decode a 16-bit unsigned integer constrained either by a * value or value range constraint. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to 16-bit unsigned integer variable to receive * decoded value. * @param lower Lower range value. * @param upper Upper range value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeConsUInt16 (OOCTXT* pctxt, ASN1USINT* pvalue, ASN1UINT lower, ASN1UINT upper); /** * This function decodes a constrained whole number as specified in Section * 10.5 of the X.691 standard. * * @param pctxt Pointer to context block structure. * @param padjusted_value Pointer to unsigned adjusted integer value to * receive decoded result. To get the final value, * this value is added to the lower boundary of the * range. * @param range_value Unsigned integer value specifying the total size * of the range. This is obtained by subtracting * the lower range value from the upper range * value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeConsWholeNumber (OOCTXT* pctxt, ASN1UINT* padjusted_value, ASN1UINT range_value); /** * This function decodes a constrained string value. This version of the * function allows all of the required permitted alphabet constraint parameters * to be passed in as arguments. * * @param pctxt Pointer to context block structure. * @param string Pointer to const char* to receive decoded string. Memory * will be allocated for this variable using internal * memory management functions. * @param charSet String containing permitted alphabet character set. Can * be null if no character set was specified. * @param abits Number of bits in a character set character (aligned). * @param ubits Number of bits in a character set character (unaligned). * @param canSetBits Number of bits in a character from the canonical set * representing this string. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeConstrainedStringEx (OOCTXT* pctxt, const char** string, const char* charSet, ASN1UINT abits, ASN1UINT ubits, ASN1UINT canSetBits); /** * This function will decode a variable of thr ASN.1 BIT STRING type. This * function allocates dynamic memory t store the decoded result. The ASN1C * complier generates a call to this function to decode an unconstrained bit * string production or element. * * @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 pBitStr Pointer to a dynamic bit string structure to receive the * decoded result. This structure contains a field to * hold the number of decoded bits and a pointer to an * octet string to hold the decoded data. Memory is * allocated by the decoder using the memAlloc * function. This memory is tracked within the context * and released when the freeContext function is * invoked. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeDynBitString (OOCTXT* pctxt, ASN1DynBitStr* pBitStr); /** * This function will decode a value of the ASN.1 octet string type whose * maximum size is known in advance. The ASN1C complier generates a call to * this function to decode octet string productions or elements that contain a * size constraint. * * @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 pOctStr A pointer to a dynamic octet string to receive the * decoded result. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeDynOctetString (OOCTXT* pctxt, ASN1DynOctStr* pOctStr); /** * This function will decode a length determinant value. * * @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 pvalue A pointer to an unsigned integer variable to receive the * decoded length value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeLength (OOCTXT* pctxt, ASN1UINT* pvalue); /** * @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 bitOffset The bit offset inside the message buffer. */ EXTERN int moveBitCursor (OOCTXT* pctxt, int bitOffset); /** * This function decodes a value of the ASN.1 object identifier type. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to value to receive decoded result. The * ASN1OBJID structure contains an integer to hold the * number of subidentifiers and an array to hold the * subidentifier values. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeObjectIdentifier (OOCTXT* pctxt, ASN1OBJID* pvalue); /** * This function will decode a value of the ASN.1 octet string type whose * maximun size is known in advance. The ASN1C compiler generates a call to * this function to decode octet string productions or elements that contain a * size constraint. * * @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 numocts_p A pointer to an unsigned buffer of bufsiz octets to * receive decoded data. * @param buffer A pointer to a pre-allocated buffer of size octets to * receive the decoded data. * @param bufsiz The size of the buffer to receive the decoded result. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeOctetString (OOCTXT* pctxt, ASN1UINT* numocts_p, ASN1OCTET* buffer, ASN1UINT bufsiz); /** * This function will decode an ASN.1 open type. This used to be the ASN.1 ANY * type, but now is used in a variety of applications requiring an encoding * that can be interpreted by a decoder without prior knowledge of the type * of the variable. * * @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 numocts_p A pointer to an unsigned buffer of bufsiz octets to * receive decoded data. * @param object_p2 A pointer to an open type variable to receive the * decoded data. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeOpenType (OOCTXT* pctxt, const ASN1OCTET** object_p2, ASN1UINT* numocts_p); /** * This function will decode a small non-negative whole number as specified in * Section 10.6 of the X.691 standard. This is a number that is expected to be * small, but whose size is potentially unlimited due to the presence of an * extension maker. * * @param pctxt Pointer to a context structure. This provides a storage * area for the function to store all workings variables * that must be maintained between function calls. * @param pvalue Pointer to an unsigned integer value t receive decoded * results. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeSmallNonNegWholeNumber (OOCTXT* pctxt, ASN1UINT* pvalue); /** * This function will decode a semi-constrained integer. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to integer variable to receive decoded value. * @param lower Lower range value, represented as signed * integer. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeSemiConsInteger (OOCTXT* pctxt, ASN1INT* pvalue, ASN1INT lower); /** * This function will decode a semi-constrained unsigned integer. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to unsigned integer variable to receive decoded * value. * @param lower Lower range value, represented as unsigned * integer. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int decodeSemiConsUnsigned (OOCTXT* pctxt, ASN1UINT* pvalue, ASN1UINT lower); /** * This function will decode an unconstrained integer. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to integer variable to receive decoded value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ #define decodeUnconsInteger(pctxt,pvalue) \ decodeSemiConsInteger(pctxt, pvalue, ASN1INT_MIN) /** * This function will decode an unconstrained unsigned integer. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to unsigned integer variable to receive decoded * value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ #define decodeUnconsUnsigned(pctxt,pvalue) \ decodeSemiConsUnsigned(pctxt, pvalue, 0U) EXTERN int decodeVarWidthCharString (OOCTXT* pctxt, const char** pvalue); /** * This function will encode a variable of the ASN.1 BOOLEAN type in * a single bit. * * @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 value The BOOLEAN value to be encoded. */ EXTERN int encodeBit (OOCTXT* pctxt, ASN1BOOL value); /** * This function encodes multiple bits. * * @param pctxt Pointer to context block structure. * @param value Unsigned integer containing the bits to be encoded. * @param nbits Number of bits in value to encode. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeBits (OOCTXT* pctxt, ASN1UINT value, ASN1UINT nbits); /** * This function will encode a value of the ASN.1 bit string type. * * @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 numocts The number of bits n the string to be encoded. * @param data Pointer to the bit string data to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeBitString (OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data); /** * This function will encode a variable of the ASN.1 BMP character string. This * differs from the encode routines for the character strings previously * described in that the BMP string type is based on 16-bit characters. A * 16-bit character string is modeled using an array of unsigned short * integers. * * @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 value Character string to be encoded. This structure includes * a count field containing the number of characters to * encode and an array of unsigned short integers to hold * the 16-bit characters to be encoded. * @param permCharSet Pointer to the constraining character set. This contains * an array containing all valid characters in the set as * well as the aligned and unaligned bit counts required * to encode the characters. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeBMPString (OOCTXT* pctxt, ASN1BMPString value, Asn116BitCharSet* permCharSet); /** * This function will position the encode bit cursor on the next byte boundry. * * @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. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeByteAlign (OOCTXT* pctxt); /** * This function will determine if the given number of bytes will fit in the * encode buffer. If not, either the buffer is expanded (if it is a dynamic * buffer) or an error is signaled. * * @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 nbytes Number of bytes of space required to hold the variable * to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeCheckBuffer (OOCTXT* pctxt, ASN1UINT nbytes); /** * This function encodes a constrained string value. This version of the * function allows all of the required permitted alphabet constraint parameters * to be passed in as arguments. * * @param pctxt Pointer to context block structure. * @param string Pointer to string to be encoded. * @param charSet String containing permitted alphabet character set. Can * be null if no character set was specified. * @param abits Number of bits in a character set character (aligned). * @param ubits Number of bits in a character set character (unaligned). * @param canSetBits Number of bits in a character from the canonical set * representing this string. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeConstrainedStringEx (OOCTXT* pctxt, const char* string, const char* charSet, ASN1UINT abits, ASN1UINT ubits, ASN1UINT canSetBits); /** * This function encodes an integer constrained either by a value or value * range constraint. * * @param pctxt Pointer to context block structure. * @param value Value to be encoded. * @param lower Lower range value. * @param upper Upper range value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeConsInteger (OOCTXT* pctxt, ASN1INT value, ASN1INT lower, ASN1INT upper); /** * This function encodes an unsigned integer constrained either by a value or * value range constraint. The constrained unsigned integer option is used if: * * 1. The lower value of the range is >= 0, and 2. The upper value of the range * is >= MAXINT * * @param pctxt Pointer to context block structure. * @param value Value to be encoded. * @param lower Lower range value. * @param upper Upper range value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeConsUnsigned (OOCTXT* pctxt, ASN1UINT value, ASN1UINT lower, ASN1UINT upper); /** * This function encodes a constrained whole number as specified in Section * 10.5 of the X.691 standard. * * @param pctxt Pointer to context block structure. * @param adjusted_value Unsigned adjusted integer value to be encoded. The * adjustment is done by subtracting the lower value * of the range from the value to be encoded. * @param range_value Unsigned integer value specifying the total size of * the range. This is obtained by subtracting the * lower range value from the upper range value. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeConsWholeNumber (OOCTXT* pctxt, ASN1UINT adjusted_value, ASN1UINT range_value); /** * This function will expand the buffer to hold the given number of bytes. * * @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 nbytes The number of bytes the buffer is to be expanded by. * Note that the buffer will be expanded by * ASN_K_ENCBIFXIZ or nbytes (whichever is larger. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeExpandBuffer (OOCTXT* pctxt, ASN1UINT nbytes); /** * This function will return the message pointer and length of an encoded * message. This function is called after a complier generated encode function * to get the pointer and length of the message. It is normally used when * dynamic encoding is specified because the message pointer is not known until * encoding is complete. If static encoding is used, the message starts at the * beginning of the specified buffer adn the encodeGetMsgLen function can be * used to obtain the lenght of the message. * * @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 pLength Pointer to variable to receive length of the encoded * message. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN ASN1OCTET* encodeGetMsgPtr (OOCTXT* pctxt, int* pLength); /** * This function will encode a length determinant value. * * @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 value Length value to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeLength (OOCTXT* pctxt, ASN1UINT value); /** * This function encodes a value of the ASN.1 object identifier type. * * @param pctxt Pointer to context block structure. * @param pvalue Pointer to value to be encoded. The ASN1OBJID structure * contains a numids fields to hold the number of * subidentifiers and an array to hold the subidentifier * values. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeObjectIdentifier (OOCTXT* pctxt, ASN1OBJID* pvalue); /** * * This function encodes bits from a given octet to the output buffer. * * @param pctxt Pointer to ASN.1 PER context structure * @param value Value of bits to be encoded * @param nbits Number of bits to be encoded * * @return Status of operation */ EXTERN int encodebitsFromOctet (OOCTXT* pctxt, ASN1OCTET value, ASN1UINT nbits); /** * This fuction will encode an array of octets. The Octets will be encoded * unaligned starting at the current bit offset within the encode buffer. * * @param pctxt A pointer to a context structure. The provides a storage * area for the function to store all working variables * that must be maintained between function calls. * @param pvalue A pointer to an array of octets to encode * @param nbits The number of Octets to encode * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeOctets (OOCTXT* pctxt, const ASN1OCTET* pvalue, ASN1UINT nbits); /** * This function will encode a value of the ASN.1 octet string type. * * @param pctxt A pointer to a context structure. The provides a storage * area for the function to store all working variables * that must be maintained between function calls. * @param numocts Number of octets in the string to be encoded. * @param data Pointer to octet string data to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeOctetString (OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data); /** * This function will encode an ASN.1 open type. This used to be the ANY type, * but now is used in a variety of applications requiring an encoding that can * be interpreted by a decoder without a prior knowledge of the type of the * variable. * * @param pctxt A pointer to a context structure. The provides a storage * area for the function to store all working variables * that must be maintained between function calls. * @param numocts Number of octets in the string to be encoded. * @param data Pointer to octet string data to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeOpenType (OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data); /** * This function will encode an ASN.1 open type extension. An open type * extension field is the data that potentially resides after the ... marker in * a version-1 message. The open type structure contains a complete encoded bit * set including option element bits or choice index, length, and data. * Typically, this data is populated when a version-1 system decodes a * version-2 message. The extension fields are retained and can then be * re-encoded if a new message is to be sent out (for example, in a store and * forward system). * * @param pctxt A pointer to a context structure. The provides a storage * area for the function to store all working variables * that must be maintained between function calls. * @param pElemList A pointer to the open type to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeOpenTypeExt (OOCTXT* pctxt, DList* pElemList); EXTERN int encodeOpenTypeExtBits (OOCTXT* pctxt, DList* pElemList); /** * This function will endcode a small, non-negative whole number as specified * in Section 10.6 of teh X.691 standard. This is a number that is expected to * be small, but whose size is potentially unlimited due to the presence of an * extension marker. * * @param pctxt A pointer to a context structure. The provides a storage * area for the function to store all working variables * that must be maintained between function calls. * @param value An unsigned integer value to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeSmallNonNegWholeNumber (OOCTXT* pctxt, ASN1UINT value); /** * This function encodes a semi-constrained integer. * * @param pctxt Pointer to context block structure. * @param value Value to be encoded. * @param lower Lower range value, represented as signed * integer. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeSemiConsInteger (OOCTXT* pctxt, ASN1INT value, ASN1INT lower); /** * This function encodes an semi-constrained unsigned integer. * * @param pctxt Pointer to context block structure. * @param value Value to be encoded. * @param lower Lower range value, represented as unsigned * integer. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ EXTERN int encodeSemiConsUnsigned (OOCTXT* pctxt, ASN1UINT value, ASN1UINT lower); /** * This function encodes an unconstrained integer. * * @param pctxt Pointer to context block structure. * @param value Value to be encoded. * @return Completion status of operation: * - 0 (ASN_OK) = success, * - negative return value is error. */ #define encodeUnconsInteger(pctxt,value) \ encodeSemiConsInteger(pctxt,value,ASN1INT_MIN) EXTERN int encodeVarWidthCharString (OOCTXT* pctxt, const char* value); EXTERN int addSizeConstraint (OOCTXT* pctxt, Asn1SizeCnst* pSize); EXTERN ASN1BOOL alignCharStr (OOCTXT* pctxt, ASN1UINT len, ASN1UINT nbits, Asn1SizeCnst* pSize); EXTERN int bitAndOctetStringAlignmentTest (Asn1SizeCnst* pSizeList, ASN1UINT itemCount, ASN1BOOL bitStrFlag, ASN1BOOL* pAlignFlag); EXTERN int getPERMsgLen (OOCTXT* pctxt); EXTERN int addSizeConstraint (OOCTXT* pctxt, Asn1SizeCnst* pSize); EXTERN Asn1SizeCnst* getSizeConstraint (OOCTXT* pctxt, ASN1BOOL extbit); EXTERN int checkSizeConstraint(OOCTXT* pctxt, int size); EXTERN ASN1UINT getUIntBitCount (ASN1UINT value); EXTERN Asn1SizeCnst* checkSize (Asn1SizeCnst* pSizeList, ASN1UINT value, ASN1BOOL* pExtendable); EXTERN void init16BitCharSet (Asn116BitCharSet* pCharSet, ASN116BITCHAR first, ASN116BITCHAR last, ASN1UINT abits, ASN1UINT ubits); EXTERN ASN1BOOL isExtendableSize (Asn1SizeCnst* pSizeList); EXTERN void set16BitCharSet (OOCTXT* pctxt, Asn116BitCharSet* pCharSet, Asn116BitCharSet* pAlphabet); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/ooCalls.h0000644000175000007640000010727711775134255020361 0ustar sharkyjerryweb/* * 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" #include #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) #define OO_M_TRYBEMASTER ASN1UINTCNT(0x00000010) #define OO_M_AUDIOSESSION ASN1UINTCNT(0x00000100) #define OO_M_DATASESSION ASN1UINTCNT(0x00000200) #define OO_M_T38SUPPORTED ASN1UINTCNT(0x00000400) /** * 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 */ OO_CALL_REMOVED /* call removed */ } 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; int lMediaRedirPort; int lMediaRedirCPort; char lMediaIP[2+8*4+7]; 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; typedef struct OOH323Regex { regex_t regex; int inuse; ast_mutex_t lock; } OOH323Regex; /** * 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; OOCTXT *msgctxt; pthread_t callThread; ast_cond_t gkWait; ast_mutex_t GkLock; ast_mutex_t Lock; OOBOOL Monitor; OOBOOL fsSent; OOSOCKET CmdChan; OOSOCKET cmdSock; ast_mutex_t* CmdChanLock; char callToken[20]; /* ex: ooh323c_call_1 */ char callType[10]; /* incoming/outgoing */ OOCallMode callMode; int transfercap; 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; int q931cause; ASN1UINT h225version; unsigned h245ConnectionAttempts; OOH245SessionState h245SessionState; int dtmfmode; int dtmfcodec; OOMediaInfo *mediaInfo; OOCallFwdData *pCallFwdData; char localIP[2+8*4+7];/* Local IP address */ int versionIP; /* IP Address family 6 or 4 */ OOH323Channel* pH225Channel; OOH323Channel* pH245Channel; OOSOCKET *h245listener; int *h245listenport; char remoteIP[2+8*4+7];/* 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 */ OOMSAckStatus msAckStatus; /* Master-Slave ack's status */ ASN1UINT statusDeterminationNumber; OOCapExchangeState localTermCapState; OOCapExchangeState remoteTermCapState; OOBOOL TCSPending; 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; ASN1UINT8 requestSequence; ASN1UINT reqFlags; ASN1UINT t38sides; int T38FarMaxDatagram; int T38Version; H235TimeStamp alertingTime, connectTime, endTime; /* time data for gatekeeper */ FastStartResponse *pFastStartRes; /* fast start response */ struct OOH323Regex* rtpMask; char rtpMaskStr[120]; char lastDTMF; ASN1UINT nextDTMFstamp; int rtdrInterval, rtdrCount; /* roundTripDelay interval and unreplied count */ ASN1UINT rtdrSend, rtdrRecv; /* last sended/replied RTD request */ void *usrData; /*! 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) ); } asterisk-11.7.0/addons/ooh323c/src/rtctype.h0000644000175000007640000000454111222440006020422 0ustar sharkyjerryweb/* * 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_ */ asterisk-11.7.0/addons/ooh323c/src/ooStackCmds.h0000644000175000007640000001307411775134255021166 0ustar sharkyjerryweb/* * 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_MANUALPROGRESS, /*!< Send progress */ OO_CMD_STOPMONITOR, /*!< Stop the event monitor */ OO_CMD_REQMODE, /*!< Request new mode */ OO_CMD_SETANI, /*! #include "ooq931.h" #include "ootrace.h" #include "ooasn1.h" #include "oochannels.h" #include "printHandler.h" #include "ooCalls.h" #include "ooh323.h" #include "ooh245.h" #include "ooh323ep.h" #include "ooCapability.h" #include "ooGkClient.h" #include "ooUtils.h" #include "ootypes.h" #include #include int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg, ASN1UINT *fsCount, ASN1DynOctStr **fsElem); /** Global endpoint structure */ extern OOH323EndPoint gH323ep; extern ast_mutex_t newCallLock; static ASN1OBJID gProtocolID = { 6, { 0, 0, 8, 2250, 0, 4 } }; EXTERN int ooQ931Decode (OOH323CallData *call, Q931Message* msg, int length, ASN1OCTET *data, int docallbacks) { int offset, x; int rv = ASN_OK; char number[128]; char *display = NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; dListInit (&msg->ies); /* clear information elements list */ if (length < 5) /* Packet too short */ return Q931_E_TOOSHORT; msg->protocolDiscriminator = data[0]; OOTRACEDBGB2(" protocolDiscriminator = %d\n", msg->protocolDiscriminator); if (data[1] != 2) /* Call reference must be 2 bytes long */ return Q931_E_INVCALLREF; msg->callReference = ((data[2] & 0x7f) << 8) | data[3]; OOTRACEDBGB2(" callReference = %d\n", msg->callReference); msg->fromDestination = (data[2] & 0x80) != 0; if(msg->fromDestination) OOTRACEDBGB1(" from = destination\n"); else OOTRACEDBGB1(" from = originator\n"); msg->messageType = data[4]; OOTRACEDBGB2(" messageType = %x\n", msg->messageType); /* Have preamble, start getting the informationElements into buffers */ offset = 5; while (offset < length) { Q931InformationElement *ie; int ieOff = offset; /* Get field discriminator */ int discriminator = data[offset++]; /* For discriminator with high bit set there is no data */ if ((discriminator & 0x80) == 0) { int len = data[offset++], alen; if (discriminator == Q931UserUserIE) { /* Special case of User-user field, there is some confusion here as the Q931 documentation claims the length is a single byte, unfortunately all H.323 based apps have a 16 bit length here, so we allow for said longer length. There is presumably an addendum to Q931 which describes this, and provides a means to discriminate between the old 1 byte and the new 2 byte systems. However, at present we assume it is always 2 bytes until we find something that breaks it. */ len <<= 8; len |= data[offset++]; /* we also have a protocol discriminator, which we ignore */ offset++; len--; } /* watch out for negative lengths! (ED, 11/5/03) */ if (len < 0) { return Q931_E_INVLENGTH; } else if (offset + len > length) { alen = 0; len = -len; rv = Q931_E_INVLENGTH; } else alen = len; ie = (Q931InformationElement*) memAlloc (pctxt, sizeof(*ie) - sizeof(ie->data) + alen); if(!ie) { OOTRACEERR3("Error:Memory - ooQ931Decode - ie(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ie->discriminator = discriminator; ie->offset = ieOff; ie->length = len; if (alen != 0) memcpy(ie->data, data + offset, alen); offset += len; } else { ie = (Q931InformationElement*) memAlloc (pctxt, sizeof(*ie)); if(!ie) { OOTRACEERR3("Error:Memory - ooQ931Decode - ie(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ie->discriminator = discriminator; ie->offset = offset; ie->length = 0; } if(ie->discriminator == Q931BearerCapabilityIE) { OOTRACEDBGB1(" Bearer-Capability IE = {\n"); for(x=0; xlength; x++) { if(x==0) OOTRACEDBGB2(" %x", ie->data[x]); else OOTRACEDBGB2(", %x", ie->data[x]); } OOTRACEDBGB1(" }\n"); } if(ie->discriminator == Q931DisplayIE) { if (!(display = memAllocZ(pctxt, ie->length + 1))) { OOTRACEERR4("Can't alloc DisplayIE buffer for %n bytes, (%s, %s)\n", ie->length, call->callType, call->callToken); } else { memcpy(display, ie->data,ie->length); OOTRACEDBGB1(" Display IE = {\n"); OOTRACEDBGB2(" %s\n", display); OOTRACEDBGB1(" }\n"); } } if(ie->discriminator == Q931KeypadIE) { OOTRACEDBGB1(" Keypad IE = {\n"); OOTRACEDBGB2(" %c\n", ie->data[0]); OOTRACEDBGB1(" }\n"); if(docallbacks && gH323ep.h323Callbacks.onReceivedDTMF) { gH323ep.h323Callbacks.onReceivedDTMF(call, (char *)ie->data); } } /* Extract calling party number TODO:Give respect to presentation and screening indicators ;-) */ if(ie->discriminator == Q931CallingPartyNumberIE) { OOTRACEDBGB1(" CallingPartyNumber IE = {\n"); if(ie->length < OO_MAX_NUMBER_LENGTH) { int numoffset=1; if(!(0x80 & ie->data[0])) numoffset = 2; memcpy(number, ie->data+numoffset,ie->length-numoffset); number[ie->length-numoffset]='\0'; OOTRACEDBGB2(" %s\n", number); if(!call->callingPartyNumber) ooCallSetCallingPartyNumber(call, number); } else{ OOTRACEERR3("Error:Calling party number too long. (%s, %s)\n", call->callType, call->callToken); } OOTRACEDBGB1(" }\n"); } /* Extract called party number */ if(ie->discriminator == Q931CalledPartyNumberIE) { OOTRACEDBGB1(" CalledPartyNumber IE = {\n"); if(ie->length < OO_MAX_NUMBER_LENGTH) { memcpy(number, ie->data+1,ie->length-1); number[ie->length-1]='\0'; OOTRACEDBGB2(" %s\n", number); if(!call->calledPartyNumber) ooCallSetCalledPartyNumber(call, number); } else{ OOTRACEERR3("Error:Calling party number too long. (%s, %s)\n", call->callType, call->callToken); } OOTRACEDBGB1(" }\n"); } /* Handle Cause ie */ if(ie->discriminator == Q931CauseIE) { msg->causeIE = ie; OOTRACEDBGB1(" Cause IE = {\n"); OOTRACEDBGB2(" %s\n", ooGetQ931CauseValueText(ie->data[1]&0x7f)); OOTRACEDBGB1(" }\n"); } /* Handle CallState ie */ if(ie->discriminator == Q931CallStateIE) { msg->causeIE = ie; OOTRACEDBGB1(" CallState IE = {\n"); OOTRACEDBGB2(" %d\n", ie->data[0]); OOTRACEDBGB1(" }\n"); } /* TODO: Get rid of ie list.*/ dListAppend (pctxt, &msg->ies, ie); if (rv != ASN_OK) return rv; } /*cisco router sends Q931Notify without UU ie, we just ignore notify message as of now as handling is optional for end point*/ if(msg->messageType != Q931NotifyMsg && msg->messageType != Q931StatusMsg) rv = ooDecodeUUIE(pctxt, msg); return rv; } EXTERN Q931InformationElement* ooQ931GetIE (const Q931Message* q931msg, int ieCode) { DListNode* curNode; unsigned int i; for(i = 0, curNode = q931msg->ies.head; i < q931msg->ies.count; i++) { Q931InformationElement *ie = (Q931InformationElement*) curNode->data; if (ie->discriminator == ieCode) { return ie; } curNode = curNode->next; } return NULL; } char* ooQ931GetMessageTypeName(int messageType, char* buf) { switch (messageType) { case Q931AlertingMsg : strcpy(buf, "Alerting"); break; case Q931CallProceedingMsg : strcpy(buf, "CallProceeding"); break; case Q931ConnectMsg : strcpy(buf, "Connect"); break; case Q931ConnectAckMsg : strcpy(buf, "ConnectAck"); break; case Q931ProgressMsg : strcpy(buf, "Progress"); break; case Q931SetupMsg : strcpy(buf, "Setup"); break; case Q931SetupAckMsg : strcpy(buf, "SetupAck"); break; case Q931FacilityMsg : strcpy(buf, "Facility"); break; case Q931ReleaseCompleteMsg : strcpy(buf, "ReleaseComplete"); break; case Q931StatusEnquiryMsg : strcpy(buf, "StatusEnquiry"); break; case Q931StatusMsg : strcpy(buf, "Status"); break; case Q931InformationMsg : strcpy(buf, "Information"); break; case Q931NationalEscapeMsg : strcpy(buf, "Escape"); break; default: sprintf(buf, "<%u>", messageType); } return buf; } char* ooQ931GetIEName(int number, char* buf) { switch (number) { case Q931BearerCapabilityIE : strcpy(buf, "Bearer-Capability"); break; case Q931CauseIE : strcpy(buf, "Cause"); break; case Q931FacilityIE : strcpy(buf, "Facility"); break; case Q931ProgressIndicatorIE : strcpy(buf, "Progress-Indicator"); break; case Q931CallStateIE : strcpy(buf, "Call-State"); break; case Q931DisplayIE : strcpy(buf, "Display"); break; case Q931SignalIE : strcpy(buf, "Signal"); break; case Q931CallingPartyNumberIE : strcpy(buf, "Calling-Party-Number"); break; case Q931CalledPartyNumberIE : strcpy(buf, "Called-Party-Number"); break; case Q931RedirectingNumberIE : strcpy(buf, "Redirecting-Number"); break; case Q931UserUserIE : strcpy(buf, "User-User"); break; default: sprintf(buf, "0x%02x", number); } return buf; } EXTERN void ooQ931Print (const Q931Message* q931msg) { char buf[1000]; DListNode* curNode; unsigned int i; printf("Q.931 Message:\n"); printf(" protocolDiscriminator: %i\n", q931msg->protocolDiscriminator); printf(" callReference: %i\n", q931msg->callReference); printf(" from: %s\n", (q931msg->fromDestination ? "destination" : "originator")); printf(" messageType: %s (0x%X)\n\n", ooQ931GetMessageTypeName(q931msg->messageType, buf), q931msg->messageType); for(i = 0, curNode = q931msg->ies.head; i < q931msg->ies.count; i++) { Q931InformationElement *ie = (Q931InformationElement*) curNode->data; int length = (ie->length >= 0) ? ie->length : -ie->length; printf(" IE[%i] (offset 0x%X):\n", i, ie->offset); printf(" discriminator: %s (0x%X)\n", ooQ931GetIEName(ie->discriminator, buf), ie->discriminator); printf(" data length: %i\n", length); curNode = curNode->next; printf("\n"); } } int ooCreateQ931Message(OOCTXT* pctxt, Q931Message **q931msg, int msgType) { /* OOCTXT *pctxt = &gH323ep.msgctxt; */ *q931msg = (Q931Message*)memAllocZ(pctxt, sizeof(Q931Message)); if(!*q931msg) { OOTRACEERR1("Error:Memory - ooCreateQ931Message - q931msg\n"); return OO_FAILED; } else { (*q931msg)->protocolDiscriminator = 8; (*q931msg)->fromDestination = FALSE; (*q931msg)->messageType = msgType; (*q931msg)->tunneledMsgType = msgType; (*q931msg)->logicalChannelNo = 0; (*q931msg)->bearerCapabilityIE = NULL; (*q931msg)->callingPartyNumberIE = NULL; (*q931msg)->calledPartyNumberIE = NULL; (*q931msg)->causeIE = NULL; (*q931msg)->callstateIE = NULL; return OO_OK; } } int ooGenerateCallToken (char *callToken, size_t size) { static int counter = 1; char aCallToken[200]; int ret = 0; ast_mutex_lock(&newCallLock); sprintf (aCallToken, "ooh323c_%d", counter++); if (counter > OO_MAX_CALL_TOKEN) counter = 1; ast_mutex_unlock(&newCallLock); if ((strlen(aCallToken)+1) < size) strcpy (callToken, aCallToken); else { OOTRACEERR1 ("Error: Insufficient buffer size to generate call token"); ret = OO_FAILED; } return ret; } /* CallReference is a two octet field, thus max value can be 0xffff or 65535 decimal. We restrict max value to 32760, however, this should not cause any problems as there won't be those many simultaneous calls CallRef has to be locally unique and generated by caller. */ ASN1USINT ooGenerateCallReference() { static ASN1USINT lastCallRef=0; ASN1USINT newCallRef=0; if(lastCallRef == 0) { /* Generate a new random callRef */ srand((unsigned)time(0)); lastCallRef = (ASN1USINT)(rand()%100); } else lastCallRef++; /* Note callReference can be at the most 15 bits that is from 0 to 32767. if we generate number bigger than that, bring it in range. */ if(lastCallRef>=32766) lastCallRef=1; newCallRef = lastCallRef; OOTRACEDBGC2("Generated callRef %d\n", newCallRef); return newCallRef; } int ooGenerateCallIdentifier(H225CallIdentifier *callid) { ASN1INT64 timestamp; int i=0; #ifdef _WIN32 SYSTEMTIME systemTime; GetLocalTime(&systemTime); SystemTimeToFileTime(&systemTime, (LPFILETIME)×tamp); #else struct timeval systemTime; gettimeofday(&systemTime, NULL); timestamp = systemTime.tv_sec * 10000000 + systemTime.tv_usec*10; #endif callid->guid.numocts = 16; callid->guid.data[0] = 'o'; callid->guid.data[1] = 'o'; callid->guid.data[2] = 'h'; callid->guid.data[3] = '3'; callid->guid.data[4] = '2'; callid->guid.data[5] = '3'; callid->guid.data[6] = 'c'; callid->guid.data[7] = '-'; for (i = 8; i < 16; i++) callid->guid.data[i] = (ASN1OCTET)((timestamp>>((i-8+1)*8))&0xff); return OO_OK; } int ooFreeQ931Message(OOCTXT* pctxt, Q931Message *q931Msg) { if(!q931Msg) { /* memReset(&gH323ep.msgctxt); */ memReset(pctxt); } return OO_OK; } int ooEncodeUUIE(OOCTXT* pctxt, Q931Message *q931msg) { ASN1OCTET msgbuf[ASN_K_ENCBUFSIZ]; ASN1OCTET * msgptr=NULL; int len; ASN1BOOL aligned = TRUE; Q931InformationElement* ie=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ memset(msgbuf, 0, sizeof(msgbuf)); if(!q931msg) { OOTRACEERR1("ERROR: Invalid Q931 message in add user-user IE\n"); return OO_FAILED; } if(!q931msg->userInfo) { OOTRACEERR1("ERROR: No User-User IE to encode\n"); return OO_FAILED; } setPERBuffer(pctxt, msgbuf, sizeof(msgbuf), aligned); if(asn1PE_H225H323_UserInformation (pctxt, q931msg->userInfo)==ASN_OK) { OOTRACEDBGC1("UserInfo encoding - successful\n"); } else{ OOTRACEERR1("ERROR: UserInfo encoding failed\n"); return OO_FAILED; } msgptr = encodeGetMsgPtr(pctxt, &len); /* Allocate memory to hold complete UserUser Information */ ie = (Q931InformationElement*)memAlloc (pctxt, sizeof(*ie) - sizeof(ie->data) + len); if(ie == NULL) { OOTRACEERR1("Error: Memory - ooEncodeUUIE - ie\n"); return OO_FAILED; } ie->discriminator = Q931UserUserIE; ie->length = len; memcpy(ie->data, msgptr, len); /* Add the user to user IE NOTE: ALL IEs SHOULD BE IN ASCENDING ORDER OF THEIR DISCRIMINATOR AS PER SPEC. */ dListInit (&(q931msg->ies)); if((dListAppend (pctxt, &(q931msg->ies), ie)) == NULL) { OOTRACEERR1("Error: Failed to add UUIE in outgoing message\n"); return OO_FAILED; } return OO_OK; } int ooDecodeUUIE(OOCTXT* pctxt, Q931Message *q931Msg) { DListNode* curNode; unsigned int i; ASN1BOOL aligned=TRUE; int stat; Q931InformationElement *ie; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ if(q931Msg ==NULL) { OOTRACEERR1("Error: ooDecodeUUIE failed - NULL q931 message\n"); return OO_FAILED; } /* Search for UserUser IE */ for(i = 0, curNode = q931Msg->ies.head; i < q931Msg->ies.count; i++, curNode = curNode->next) { ie = (Q931InformationElement*) curNode->data; if(ie && ie->discriminator == Q931UserUserIE) break; } if(i == q931Msg->ies.count) { OOTRACEERR1("No UserUser IE found in ooDecodeUUIE\n"); return OO_FAILED; } /* Decode user-user ie */ q931Msg->userInfo = (H225H323_UserInformation *) memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!q931Msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooDecodeUUIE - userInfo\n"); return OO_FAILED; } memset(q931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); setPERBuffer (pctxt, ie->data, ie->length, aligned); stat = asn1PD_H225H323_UserInformation (pctxt, q931Msg->userInfo); if(stat != ASN_OK) { OOTRACEERR1("Error: UserUser IE decode failed\n"); return OO_FAILED; } OOTRACEDBGC1("UUIE decode successful\n"); return OO_OK; } #ifndef _COMPACT static void ooQ931PrintMessage (OOH323CallData* call, ASN1OCTET *msgbuf, ASN1UINT msglen) { /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; Q931Message q931Msg; int ret; initializePrintHandler(&printHandler, "Q931 Message"); /* Set event handler */ setEventHandler (pctxt, &printHandler); setPERBuffer (pctxt, msgbuf, msglen, TRUE); ret = ooQ931Decode (call, &q931Msg, msglen, msgbuf, 0); if(ret != OO_OK) { OOTRACEERR3("Error:Failed decoding Q931 message. (%s, %s)\n", call->callType, call->callToken); } finishPrint(); removeEventHandler(pctxt); } #endif int ooEncodeH225Message(OOH323CallData *call, Q931Message *pq931Msg, char *msgbuf, int size) { int len=0, i=0, j=0, ieLen=0; int stat=0; DListNode* curNode=NULL; if(!msgbuf || size<200) { OOTRACEERR3("Error: Invalid message buffer/size for ooEncodeH245Message." " (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } if(pq931Msg->messageType == Q931SetupMsg){ msgbuf[i++] = OOSetup; } else if(pq931Msg->messageType == Q931ConnectMsg){ msgbuf[i++] = OOConnect; } else if(pq931Msg->messageType == Q931CallProceedingMsg){ msgbuf[i++] = OOCallProceeding; } else if(pq931Msg->messageType == Q931AlertingMsg || pq931Msg->messageType == Q931ProgressMsg){ msgbuf[i++] = OOAlert; } else if(pq931Msg->messageType == Q931ReleaseCompleteMsg){ msgbuf[i++] = OOReleaseComplete; } else if(pq931Msg->messageType == Q931InformationMsg){ msgbuf[i++] = OOInformationMessage; } else if(pq931Msg->messageType == Q931StatusMsg || pq931Msg->messageType == Q931StatusEnquiryMsg){ msgbuf[i++] = OOStatus; } else if(pq931Msg->messageType == Q931FacilityMsg){ msgbuf[i++] = OOFacility; msgbuf[i++] = pq931Msg->tunneledMsgType; msgbuf[i++] = pq931Msg->logicalChannelNo>>8; msgbuf[i++] = pq931Msg->logicalChannelNo; } else{ OOTRACEERR3("Error:Unknow Q931 message type. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } stat = ooEncodeUUIE(call->msgctxt, pq931Msg); if(stat != OO_OK) { OOTRACEERR3("Error:Failed to encode uuie. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } msgbuf[i++] = 3; /* TPKT version */ msgbuf[i++] = 0; /* TPKT resevred */ /* 1st octet of length, will be populated once len is determined */ msgbuf[i++] = 0; /* 2nd octet of length, will be populated once len is determined */ msgbuf[i++] = 0; /* Q931 protocol discriminator */ msgbuf[i++] = pq931Msg->protocolDiscriminator; msgbuf[i++] = 2; /* length of call ref is two octets */ msgbuf[i] = (pq931Msg->callReference >> 8); /* populate 1st octet */ if(!strcmp(call->callType, "incoming")) msgbuf[i++] |= 0x80; /* fromDestination*/ else i++; /* fromOriginator*/ msgbuf[i++] = pq931Msg->callReference; /* populate 2nd octet */ msgbuf[i++] = pq931Msg->messageType; /* type of q931 message */ /* Note: the order in which ies are added is important. It is in the ascending order of ie codes. */ /* Add bearer IE */ if(pq931Msg->bearerCapabilityIE) { msgbuf[i++] = Q931BearerCapabilityIE; /* ie discriminator */ msgbuf[i++] = pq931Msg->bearerCapabilityIE->length; memcpy(msgbuf+i, pq931Msg->bearerCapabilityIE->data, pq931Msg->bearerCapabilityIE->length); i += pq931Msg->bearerCapabilityIE->length; } /* Add cause IE */ if(pq931Msg->causeIE) { msgbuf[i++] = Q931CauseIE; msgbuf[i++] = pq931Msg->causeIE->length; memcpy(msgbuf+i, pq931Msg->causeIE->data, pq931Msg->causeIE->length); i += pq931Msg->causeIE->length; } /*Add progress indicator IE if(pq931Msg->messageType == Q931AlertingMsg || pq931Msg->messageType == Q931CallProceedingMsg) { msgbuf[i++] = Q931ProgressIndicatorIE; msgbuf[i++] = 2; //Length is 2 octet msgbuf[i++] = 0x80; //PI=8 msgbuf[i++] = 0x88; }*/ /*Add display ie. for all but Status message as per ASTERISK-18748 */ if(!ooUtilsIsStrEmpty(call->ourCallerId) && (pq931Msg->messageType != Q931StatusMsg)) { msgbuf[i++] = Q931DisplayIE; ieLen = strlen(call->ourCallerId)+1; msgbuf[i++] = ieLen; memcpy(msgbuf+i, call->ourCallerId, ieLen-1); i += ieLen-1; msgbuf[i++] = '\0'; } /* Add calling Party ie */ if(pq931Msg->callingPartyNumberIE) { msgbuf[i++] = Q931CallingPartyNumberIE; msgbuf[i++] = pq931Msg->callingPartyNumberIE->length; memcpy(msgbuf+i, pq931Msg->callingPartyNumberIE->data, pq931Msg->callingPartyNumberIE->length); i += pq931Msg->callingPartyNumberIE->length; } /* Add called Party ie */ if(pq931Msg->calledPartyNumberIE) { msgbuf[i++] = Q931CalledPartyNumberIE; msgbuf[i++] = pq931Msg->calledPartyNumberIE->length; memcpy(msgbuf+i, pq931Msg->calledPartyNumberIE->data, pq931Msg->calledPartyNumberIE->length); i += pq931Msg->calledPartyNumberIE->length; } /* Add keypad ie */ if(pq931Msg->keypadIE) { msgbuf[i++] = Q931KeypadIE; msgbuf[i++] = pq931Msg->keypadIE->length; memcpy(msgbuf+i, pq931Msg->keypadIE->data, pq931Msg->keypadIE->length); i += pq931Msg->keypadIE->length; } if(pq931Msg->callstateIE) { msgbuf[i++] = Q931CallStateIE; msgbuf[i++] = pq931Msg->callstateIE->length; memcpy(msgbuf+i, pq931Msg->callstateIE->data, pq931Msg->callstateIE->length); i += pq931Msg->callstateIE->length; } /* Note: Have to fix this, though it works. Need to get rid of ie list. Right now we only put UUIE in ie list. Can be easily removed. */ for(j = 0, curNode = pq931Msg->ies.head; j < (int)pq931Msg->ies.count; j++) { Q931InformationElement *ie = (Q931InformationElement*) curNode->data; ieLen = ie->length; /* Add the ie discriminator in message buffer */ msgbuf[i++] = ie->discriminator; /* For user-user IE, we have to add protocol discriminator */ if (ie->discriminator == Q931UserUserIE) { ieLen++; /* length includes protocol discriminator octet. */ msgbuf[i++] = (ieLen>>8); /* 1st octet for length */ msgbuf[i++] = ieLen; /* 2nd octet for length */ ieLen--; msgbuf[i++] = 5; /* protocol discriminator */ memcpy((msgbuf + i), ie->data, ieLen); i += ieLen; } else { OOTRACEWARN1("Warning: Only UUIE is supported currently\n"); return OO_FAILED; } } // len = i+1-4; /* complete message length */ /* Tpkt length octets populated with total length of the message */ if(msgbuf[0] != OOFacility) { len = i-1; msgbuf[3] = (len >> 8); msgbuf[4] = len; /* including tpkt header */ } else{ len = i-4; msgbuf[6] = (len >> 8); msgbuf[7] = len; } #ifndef _COMPACT if(msgbuf[0] != OOFacility) ooQ931PrintMessage (call, (unsigned char *)msgbuf+5, len-4); else ooQ931PrintMessage (call, (unsigned char *)msgbuf+8, len-4); #endif return OO_OK; } /* Handle FS receive channels for early media */ int ooHandleFastStartChannels(OOH323CallData *pCall) { int i = 0, remoteMediaControlPort = 0, dir = 0; char remoteMediaControlIP[2 + 8 * 4 + 7]; DListNode *pNode = NULL; H245OpenLogicalChannel *olc = NULL; ooH323EpCapability *epCap = NULL; H245H2250LogicalChannelParameters *h2250lcp = NULL; /* If fast start supported and remote endpoint has sent faststart element */ if (OO_TESTFLAG(pCall->flags, OO_M_FASTSTART) && pCall->remoteFastStartOLCs.count>0) { /* Go though all the proposed channels */ for (i = 0; i < (int)pCall->remoteFastStartOLCs.count; i++) { pNode = dListFindByIndex(&pCall->remoteFastStartOLCs, i); olc = (H245OpenLogicalChannel*)pNode->data; /* Don't support both direction channel */ if (olc->forwardLogicalChannelParameters.dataType.t != T_H245DataType_nullData && olc->m.reverseLogicalChannelParametersPresent) { continue; } /* Check forward logic channel */ if (olc->forwardLogicalChannelParameters.dataType.t != T_H245DataType_nullData) { /* Forward Channel - remote transmits - local receives */ OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n", olc->forwardLogicalChannelNumber, pCall->callType, pCall->callToken); dir = OORX; epCap = ooIsDataTypeSupported(pCall, &olc->forwardLogicalChannelParameters.dataType, OORX); if (!epCap) { continue; /* Not Supported Channel */ } OOTRACEINFO1("Receive Channel data type supported\n"); if (olc->forwardLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for " "channel %d (%s, %s)\n", olc->forwardLogicalChannelNumber, pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; /* Check session is Not already established */ if (ooIsSessionEstablished(pCall, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive")) { OOTRACEINFO4("Receive channel with sessionID %d already " "established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } /* Extract mediaControlChannel info, if supplied */ if (h2250lcp->m.mediaControlChannelPresent) { if (OO_OK != ooGetIpPortFromH245TransportAddress(pCall, &h2250lcp->mediaControlChannel, remoteMediaControlIP, &remoteMediaControlPort)) { OOTRACEERR3("Error: Invalid media control channel address " "(%s, %s)\n", pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } } else { continue; } } else { /* Don't check reverse channels */ continue; } if (dir & OORX) { remoteMediaControlPort--; if (gH323ep.h323Callbacks.onMediaChanged && pCall->callState < OO_CALL_CLEAR) { gH323ep.h323Callbacks.onMediaChanged(pCall, remoteMediaControlIP, remoteMediaControlPort); } } } } return ASN_OK; } int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg, ASN1UINT *fsCount, ASN1DynOctStr **fsElem) { /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = pCall->msgctxt; int ret = 0, i=0, j=0, remoteMediaPort=0, remoteMediaControlPort = 0, dir=0; char remoteMediaIP[2+8*4+7], remoteMediaControlIP[2+8*4+7]; DListNode *pNode = NULL; H245OpenLogicalChannel *olc = NULL, printOlc; ooH323EpCapability *epCap = NULL; ASN1DynOctStr *pFS=NULL; H245H2250LogicalChannelParameters *h2250lcp = NULL; ooLogicalChannel* pChannel; if(pCall->pFastStartRes) { ASN1UINT k = 0; ASN1OCTET* pData; /* copy the stored fast start response to structure */ *fsCount = pCall->pFastStartRes->n; *fsElem = (ASN1DynOctStr*) memAlloc(pctxt, pCall->pFastStartRes->n * sizeof(ASN1DynOctStr)); for(k = 0; k < pCall->pFastStartRes->n; k ++) { (*fsElem)[k].numocts = pCall->pFastStartRes->elem[k].numocts; pData = (ASN1OCTET*) memAlloc( pctxt, (*fsElem)[k].numocts * sizeof(ASN1OCTET)); memcpy(pData, pCall->pFastStartRes->elem[k].data, pCall->pFastStartRes->elem[k].numocts); (*fsElem)[k].data = pData; } return ASN_OK; } /* If fast start supported and remote endpoint has sent faststart element */ if(OO_TESTFLAG(pCall->flags, OO_M_FASTSTART) && pCall->remoteFastStartOLCs.count>0) { pFS = (ASN1DynOctStr*)memAlloc(pctxt, pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr)); if(!pFS) { OOTRACEERR3("Error:Memory - ooSetFastStartResponse - pFS (%s, %s)\n", pCall->callType, pCall->callToken); return OO_FAILED; } memset(pFS, 0, pCall->remoteFastStartOLCs.count*sizeof(ASN1DynOctStr)); /* Go though all the proposed channels */ for(i=0, j=0; i<(int)pCall->remoteFastStartOLCs.count; i++) { pNode = dListFindByIndex(&pCall->remoteFastStartOLCs, i); olc = (H245OpenLogicalChannel*)pNode->data; /* Don't support both direction channel */ if(olc->forwardLogicalChannelParameters.dataType.t != T_H245DataType_nullData && olc->m.reverseLogicalChannelParametersPresent) { OOTRACEINFO3("Ignoring bidirectional OLC as it is not supported." "(%s, %s)\n", pCall->callType, pCall->callToken); continue; } /* Check forward logic channel */ if(olc->forwardLogicalChannelParameters.dataType.t != T_H245DataType_nullData) { /* Forward Channel - remote transmits - local receives */ OOTRACEDBGC4("Processing received forward olc %d (%s, %s)\n", olc->forwardLogicalChannelNumber, pCall->callType, pCall->callToken); dir = OORX; epCap = ooIsDataTypeSupported(pCall, &olc->forwardLogicalChannelParameters.dataType, OORX); if(!epCap) { continue; } /* Not Supported Channel */ OOTRACEINFO1("Receive Channel data type supported\n"); if(olc->forwardLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for " "channel %d (%s, %s)\n", olc->forwardLogicalChannelNumber, pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } h2250lcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; /* Check session is Not already established */ if(ooIsSessionEstablished(pCall, olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "receive")) { OOTRACEINFO4("Receive channel with sessionID %d already " "established.(%s, %s)\n", olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } /* Extract mediaControlChannel info, if supplied */ if(h2250lcp->m.mediaControlChannelPresent) { if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, &h2250lcp->mediaControlChannel, remoteMediaControlIP, &remoteMediaControlPort)) { OOTRACEERR3("Error: Invalid media control channel address " "(%s, %s)\n", pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } } } /* Check reverse logical channel */ else if(olc->m.reverseLogicalChannelParametersPresent) { /* Reverse channel - remote receives - local transmits */ OOTRACEDBGC4("Processing received reverse olc %d (%s, %s)\n", olc->forwardLogicalChannelNumber, pCall->callType, pCall->callToken); dir = OOTX; epCap = ooIsDataTypeSupported(pCall, &olc->reverseLogicalChannelParameters.dataType, OOTX); if(!epCap) { continue; } /* Capability not supported */ OOTRACEINFO1("Transmit Channel data type supported\n"); if(olc->reverseLogicalChannelParameters.multiplexParameters.t != T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters) { OOTRACEERR4("ERROR:Unknown multiplex parameter type for " "channel %d (%s, %s)\n", olc->forwardLogicalChannelNumber, pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } /* Check session is not established */ if(ooIsSessionEstablished(pCall, olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, "transmit")) { OOTRACEINFO4("Transmit session with sessionID %d already " "established.(%s, %s)\n", olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters->sessionID, pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } /* Extract the remote media endpoint address */ h2250lcp = olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters; if(!h2250lcp) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "reverse Logical Channel Parameters found. " "(%s, %s)\n", pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; return OO_FAILED; } /* Reverse Channel info will be always present, crash proof */ if(!h2250lcp->m.mediaChannelPresent) { OOTRACEERR3("ERROR:Invalid OLC received in fast start. No " "reverse media channel information found. " "(%s, %s)\n", pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; return OO_FAILED; } /* Get IP, PORT of reverse channel */ if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, &h2250lcp->mediaChannel, remoteMediaIP, &remoteMediaPort)) { OOTRACEERR3("Error: Invalid media channel address " "(%s, %s)\n", pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } /* Extract mediaControlChannel info, if supplied */ if(h2250lcp->m.mediaControlChannelPresent) { if(OO_OK != ooGetIpPortFromH245TransportAddress(pCall, &h2250lcp->mediaControlChannel, remoteMediaControlIP, &remoteMediaControlPort)) { OOTRACEERR3("Error: Invalid media control channel address " "(%s, %s)\n", pCall->callType, pCall->callToken); memFreePtr(pCall->pctxt, epCap); epCap = NULL; continue; } } } if(dir & OOTX) { /* According to the spec if we are accepting olc for transmission from called endpoint to calling endpoint, called endpoint should insert a unqiue forwardLogicalChannelNumber into olc */ olc->forwardLogicalChannelNumber = pCall->logicalChanNoCur++; if(pCall->logicalChanNoCur > pCall->logicalChanNoMax) pCall->logicalChanNoCur = pCall->logicalChanNoBase; } ooBuildFastStartOLC(pCall, olc, epCap, pctxt, dir); pChannel = ooFindLogicalChannelByLogicalChannelNo (pCall, olc->forwardLogicalChannelNumber); /* start receive and tramsmit channel listening */ if(dir & OORX) { strcpy(pChannel->remoteIP, remoteMediaControlIP); pChannel->remoteMediaControlPort = remoteMediaControlPort; if(epCap->startReceiveChannel) { epCap->startReceiveChannel(pCall, pChannel); OOTRACEINFO4("Receive channel of type %s started (%s, %s)\n", (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", pCall->callType, pCall->callToken); } else{ OOTRACEERR4("ERROR:No callback registered to start receive %s" " channel (%s, %s)\n", (epCap->capType == OO_CAP_TYPE_AUDIO)?"audio":"video", pCall->callType, pCall->callToken); return OO_FAILED; } } if(dir & OOTX) { pChannel->remoteMediaPort = remoteMediaPort; strcpy(pChannel->remoteIP, remoteMediaIP); pChannel->remoteMediaControlPort = remoteMediaControlPort; if(epCap->startTransmitChannel) { epCap->startTransmitChannel(pCall, pChannel); OOTRACEINFO3("Transmit channel of type audio started " "(%s, %s)\n", pCall->callType, pCall->callToken); /*OO_SETFLAG (pCall->flags, OO_M_AUDIO);*/ } else{ OOTRACEERR3("ERROR:No callback registered to start transmit" " audio channel (%s, %s)\n", pCall->callType, pCall->callToken); return OO_FAILED; } } /* Encode fast start element */ setPERBuffer(pctxt, NULL, 0, 1); if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK) { OOTRACEERR3("ERROR:Encoding of olc failed for faststart " "(%s, %s)\n", pCall->callType, pCall->callToken); ooFreeQ931Message(pctxt, pQ931msg); if(pCall->callState < OO_CALL_CLEAR) { pCall->callEndReason = OO_REASON_LOCAL_CLEARED; pCall->callState = OO_CALL_CLEAR; } return OO_FAILED; } pFS[j].data = (unsigned char *) encodeGetMsgPtr(pctxt, (int *)&(pFS[j].numocts)); /* start print call */ setPERBuffer(pctxt, (unsigned char*)pFS[j].data, pFS[j].numocts, 1); initializePrintHandler(&printHandler, "FastStart Element"); setEventHandler (pctxt, &printHandler); memset(&printOlc, 0, sizeof(printOlc)); ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc)); if(ret != ASN_OK) { OOTRACEERR3("Error: Failed decoding FastStart Element (%s, %s)\n", pCall->callType, pCall->callToken); ooFreeQ931Message(pctxt, pQ931msg); if(pCall->callState < OO_CALL_CLEAR) { pCall->callEndReason = OO_REASON_LOCAL_CLEARED; pCall->callState = OO_CALL_CLEAR; } return OO_FAILED; } finishPrint(); removeEventHandler(pctxt); /* end print call */ olc = NULL; j++; epCap = NULL; } OOTRACEDBGA4("Added %d fast start elements to message " "(%s, %s)\n", j, pCall->callType, pCall->callToken); if(j != 0) { ASN1UINT k = 0; ASN1OCTET* pData; //*fsPresent = TRUE; *fsCount = j; *fsElem = pFS; /* save the fast start response for later use in ALERTING, CONNECT */ pCall->pFastStartRes = (FastStartResponse*) memAlloc(pCall->pctxt, sizeof(FastStartResponse)); pCall->pFastStartRes->n = j; pCall->pFastStartRes->elem = (ASN1DynOctStr*) memAlloc(pCall->pctxt, pCall->pFastStartRes->n * sizeof(ASN1DynOctStr)); for(k = 0; k < pCall->pFastStartRes->n; k ++) { pCall->pFastStartRes->elem[k].numocts = (*fsElem)[k].numocts; pData = (ASN1OCTET*) memAlloc(pCall->pctxt, pCall->pFastStartRes->elem[k].numocts * sizeof(ASN1OCTET)); memcpy(pData, (*fsElem)[k].data, (*fsElem)[k].numocts); pCall->pFastStartRes->elem[k].data = pData; } } else{ OOTRACEINFO3("None of the faststart elements received in setup can be" " supported, rejecting faststart.(%s, %s)\n", pCall->callType, pCall->callToken); //*fsPresent = FALSE; OO_CLRFLAG(pCall->flags, OO_M_FASTSTART); OOTRACEDBGC3("Faststart for pCall is disabled by local endpoint." "(%s, %s)\n", pCall->callType, pCall->callToken); } } return ASN_OK; } /* H225 CapSet/MS determination helper function */ int ooSendTCSandMSD(OOH323CallData *call) { int ret; if(call->localTermCapState == OO_LocalTermCapExchange_Idle) { ret = ooSendTermCapMsg(call); if(ret != OO_OK) { OOTRACEERR3("ERROR:Sending Terminal capability message (%s, %s)\n", call->callType, call->callToken); return ret; } } return OO_OK; } /* */ int ooSendCallProceeding(OOH323CallData *call) { int ret; H225VendorIdentifier *vendor; H225CallProceeding_UUIE *callProceeding; Q931Message *q931msg=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; OOTRACEDBGC3("Building CallProceeding (%s, %s)\n", call->callType, call->callToken); ret = ooCreateQ931Message(pctxt, &q931msg, Q931CallProceedingMsg); if(ret != OO_OK) { OOTRACEERR1("Error: In allocating memory for - H225 Call " "Proceeding message\n"); return OO_FAILED; } q931msg->callReference = call->callReference; q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooSendCallProceeding - userInfo\n"); return OO_FAILED; } memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_callProceeding; callProceeding = (H225CallProceeding_UUIE*)memAlloc(pctxt, sizeof(H225CallProceeding_UUIE)); if(!callProceeding) { OOTRACEERR1("ERROR:Memory - ooSendCallProceeding - callProceeding\n"); return OO_FAILED; } memset(callProceeding, 0, sizeof(H225CallProceeding_UUIE)); q931msg->userInfo->h323_uu_pdu.h323_message_body.u.callProceeding = callProceeding; callProceeding->m.multipleCallsPresent = 1; callProceeding->m.maintainConnectionPresent = 1; callProceeding->multipleCalls = FALSE; callProceeding->maintainConnection = FALSE; callProceeding->m.callIdentifierPresent = 1; callProceeding->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(callProceeding->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); callProceeding->protocolIdentifier = gProtocolID; /* Pose as Terminal or Gateway */ if(gH323ep.isGateway) callProceeding->destinationInfo.m.gatewayPresent = TRUE; else callProceeding->destinationInfo.m.terminalPresent = TRUE; callProceeding->destinationInfo.m.vendorPresent = 1; vendor = &callProceeding->destinationInfo.vendor; if(gH323ep.productID) { vendor->m.productIdPresent = 1; vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), sizeof(vendor->productId.data)); strncpy((char *)vendor->productId.data, gH323ep.productID, vendor->productId.numocts); } if(gH323ep.versionID) { vendor->m.versionIdPresent = 1; vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), sizeof(vendor->versionId.data)); strncpy((char *)vendor->versionId.data, gH323ep.versionID, vendor->versionId.numocts); } vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; vendor->vendor.t35Extension = gH323ep.t35Extension; vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; OOTRACEDBGA3("Built Call Proceeding(%s, %s)\n", call->callType, call->callToken); ret = ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue CallProceeding message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return ret; } int ooSendAlerting(OOH323CallData *call) { int ret; H225Alerting_UUIE *alerting; H225VendorIdentifier *vendor; Q931Message *q931msg=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; ret = ooCreateQ931Message(pctxt, &q931msg, Q931AlertingMsg); if(ret != OO_OK) { OOTRACEERR1("Error: In allocating memory for - H225 " "Alerting message\n"); return OO_FAILED; } call->alertingTime = (H235TimeStamp) time(NULL); q931msg->callReference = call->callReference; q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooSendAlerting - userInfo\n"); return OO_FAILED; } memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_alerting; alerting = (H225Alerting_UUIE*)memAlloc(pctxt, sizeof(H225Alerting_UUIE)); if(!alerting) { OOTRACEERR1("ERROR:Memory - ooSendAlerting - alerting\n"); return OO_FAILED; } memset(alerting, 0, sizeof(H225Alerting_UUIE)); q931msg->userInfo->h323_uu_pdu.h323_message_body.u.alerting = alerting; alerting->m.multipleCallsPresent = 1; alerting->m.maintainConnectionPresent = 1; alerting->multipleCalls = FALSE; alerting->maintainConnection = FALSE; /*Populate aliases */ alerting->m.alertingAddressPresent = TRUE; if(call->ourAliases) ret = ooPopulateAliasList(pctxt, call->ourAliases, &alerting->alertingAddress, 0); else ret = ooPopulateAliasList(pctxt, gH323ep.aliases, &alerting->alertingAddress, 0); if(OO_OK != ret) { OOTRACEERR1("Error:Failed to populate alias list in Alert message\n"); memReset(pctxt); return OO_FAILED; } alerting->m.presentationIndicatorPresent = TRUE; alerting->presentationIndicator.t = T_H225PresentationIndicator_presentationAllowed; alerting->m.screeningIndicatorPresent = TRUE; alerting->screeningIndicator = userProvidedNotScreened; alerting->m.callIdentifierPresent = 1; alerting->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(alerting->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); alerting->protocolIdentifier = gProtocolID; /* Pose as Terminal or Gateway */ if(gH323ep.isGateway) alerting->destinationInfo.m.gatewayPresent = TRUE; else alerting->destinationInfo.m.terminalPresent = TRUE; alerting->destinationInfo.m.vendorPresent = 1; vendor = &alerting->destinationInfo.vendor; if(gH323ep.productID) { vendor->m.productIdPresent = 1; vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), sizeof(vendor->productId.data)); strncpy((char *)vendor->productId.data, gH323ep.productID, vendor->productId.numocts); } if(gH323ep.versionID) { vendor->m.versionIdPresent = 1; vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), sizeof(vendor->versionId.data)); strncpy((char *)vendor->versionId.data, gH323ep.versionID, vendor->versionId.numocts); } vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; vendor->vendor.t35Extension = gH323ep.t35Extension; vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; if (!call->fsSent) { ret = ooSetFastStartResponse(call, q931msg, &alerting->fastStart.n, &alerting->fastStart.elem); if(ret != ASN_OK) { return ret; } if(alerting->fastStart.n > 0) { alerting->m.fastStartPresent = TRUE; call->fsSent = TRUE; } else alerting->m.fastStartPresent = FALSE; } else { alerting->m.fastStartPresent = FALSE; } OOTRACEDBGA3("Built Alerting (%s, %s)\n", call->callType, call->callToken); ret = ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error: Failed to enqueue Alerting message to outbound queue. (%s, %s)\n", call->callType, call->callToken); } if (call->h225version >= 4) { ooSendTCSandMSD(call); } memReset (call->msgctxt); return ret; } int ooSendProgress(OOH323CallData *call) { int ret; H225Progress_UUIE *progress; H225VendorIdentifier *vendor; Q931Message *q931msg=NULL; H225TransportAddress_ipAddress *h245IpAddr; H225TransportAddress_ip6Address *h245Ip6Addr; OOCTXT *pctxt = call->msgctxt; ret = ooCreateQ931Message(pctxt, &q931msg, Q931ProgressMsg); if(ret != OO_OK) { OOTRACEERR1("Error: In allocating memory for - H225 " "Alerting message\n"); return OO_FAILED; } q931msg->callReference = call->callReference; q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooSendAlerting - userInfo\n"); return OO_FAILED; } memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_progress; progress = (H225Progress_UUIE*)memAlloc(pctxt, sizeof(H225Progress_UUIE)); if(!progress) { OOTRACEERR1("ERROR:Memory - ooSendProgress- alerting\n"); return OO_FAILED; } memset(progress, 0, sizeof(H225Progress_UUIE)); q931msg->userInfo->h323_uu_pdu.h323_message_body.u.progress = progress; progress->m.multipleCallsPresent = 1; progress->m.maintainConnectionPresent = 1; progress->multipleCalls = FALSE; progress->maintainConnection = FALSE; progress->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(progress->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); progress->protocolIdentifier = gProtocolID; /* Pose as Terminal or Gateway */ if(gH323ep.isGateway) progress->destinationInfo.m.gatewayPresent = TRUE; else progress->destinationInfo.m.terminalPresent = TRUE; progress->destinationInfo.m.vendorPresent = 1; vendor = &progress->destinationInfo.vendor; if(gH323ep.productID) { vendor->m.productIdPresent = 1; vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), sizeof(vendor->productId.data)); strncpy((char *)vendor->productId.data, gH323ep.productID, vendor->productId.numocts); } if(gH323ep.versionID) { vendor->m.versionIdPresent = 1; vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), sizeof(vendor->versionId.data)); strncpy((char *)vendor->versionId.data, gH323ep.versionID, vendor->versionId.numocts); } vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; vendor->vendor.t35Extension = gH323ep.t35Extension; vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; if (!call->fsSent) { ret = ooSetFastStartResponse(call, q931msg, &progress->fastStart.n, &progress->fastStart.elem); if(ret != ASN_OK) { return ret; } if(progress->fastStart.n > 0) { progress->m.fastStartPresent = TRUE; call->fsSent = TRUE; } else progress->m.fastStartPresent = FALSE; } else { progress->m.fastStartPresent = FALSE; } /* Add h245 listener address. Do not add H245 listener address in case of tunneling. */ if (/* (!OO_TESTFLAG(call->flags, OO_M_FASTSTART) || call->remoteFastStartOLCs.count == 0) && */ !OO_TESTFLAG (call->flags, OO_M_TUNNELING) && !call->h245listener && ooCreateH245Listener(call) == OO_OK) { if (call->versionIP == 6) { progress->m.h245AddressPresent = TRUE; progress->h245Address.t = T_H225TransportAddress_ip6Address; h245Ip6Addr = (H225TransportAddress_ip6Address*) memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address)); if(!h245Ip6Addr) { OOTRACEERR3("Error:Memory - ooSendProgress - h245Ip6Addr" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data); h245Ip6Addr->ip.numocts=16; h245Ip6Addr->port = *(call->h245listenport); progress->h245Address.u.ip6Address = h245Ip6Addr; } else { progress->m.h245AddressPresent = TRUE; progress->h245Address.t = T_H225TransportAddress_ipAddress; h245IpAddr = (H225TransportAddress_ipAddress*) memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress)); if(!h245IpAddr) { OOTRACEERR3("Error:Memory - ooSendProgress - h245IpAddr" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data); h245IpAddr->ip.numocts=4; h245IpAddr->port = *(call->h245listenport); progress->h245Address.u.ipAddress = h245IpAddr; } } OOTRACEDBGA3("Built Progress (%s, %s)\n", call->callType, call->callToken); ret = ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error: Failed to enqueue Alerting message to outbound queue. (%s, %s)\n", call->callType, call->callToken); } if (!OO_TESTFLAG(call->flags, OO_M_TUNNELING) && call->h245listener) ooSendStartH245Facility(call); if (call->h225version >= 4) { ooSendTCSandMSD(call); } memReset (call->msgctxt); return ret; } int ooSendFSUpdate(OOH323CallData *call) { int ret = 0; Q931Message *pQ931Msg = NULL; H225Facility_UUIE *facility = NULL; OOCTXT *pctxt = call->msgctxt; OOTRACEDBGA3("Building FS update message (%s, %s)\n", call->callType, call->callToken); ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); if (ret != OO_OK) { OOTRACEERR3("ERROR: In allocating memory for facility message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pQ931Msg->callReference = call->callReference; pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if (!pQ931Msg->userInfo) { OOTRACEERR3("ERROR:Memory - ooSendFSUpdate - userInfo(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent = 1; pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG (call->flags, OO_M_TUNNELING); pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_facility; facility = (H225Facility_UUIE*) memAllocZ (pctxt, sizeof(H225Facility_UUIE)); if (!facility) { OOTRACEERR3("ERROR:Memory - ooSendFS Update - facility (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; /* Populate Facility UUIE */ facility->protocolIdentifier = gProtocolID; facility->m.callIdentifierPresent = 1; facility->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(facility->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); facility->reason.t = T_H225FacilityReason_forwardedElements; ret = ooSetFastStartResponse(call, pQ931Msg, &facility->fastStart.n, &facility->fastStart.elem); if (ret != ASN_OK) { return ret; } if (facility->fastStart.n > 0) { facility->m.fastStartPresent = TRUE; call->fsSent = TRUE; } else { facility->m.fastStartPresent = FALSE; } OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType, call->callToken); ret = ooSendH225Msg(call, pQ931Msg); if (ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue Facility message to outbound " "queue.(%s, %s)\n", call->callType, call->callToken); } memReset(call->msgctxt); return ret; } int ooSendStartH245Facility(OOH323CallData *call) { int ret=0; Q931Message *pQ931Msg = NULL; H225Facility_UUIE *facility=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; H225TransportAddress_ipAddress *h245IpAddr; H225TransportAddress_ip6Address *h245Ip6Addr; OOTRACEDBGA3("Building Facility message (%s, %s)\n", call->callType, call->callToken); ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); if(ret != OO_OK) { OOTRACEERR3 ("ERROR: In allocating memory for facility message (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pQ931Msg->callReference = call->callReference; pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!pQ931Msg->userInfo) { OOTRACEERR3("ERROR:Memory - ooSendFacility - userInfo(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG (call->flags, OO_M_TUNNELING); pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_facility; facility = (H225Facility_UUIE*) memAllocZ (pctxt, sizeof(H225Facility_UUIE)); if(!facility) { OOTRACEERR3("ERROR:Memory - ooSendFacility - facility (%s, %s)" "\n", call->callType, call->callToken); return OO_FAILED; } pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; /* Populate Facility UUIE */ facility->protocolIdentifier = gProtocolID; facility->m.callIdentifierPresent = 1; facility->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(facility->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); facility->reason.t = T_H225FacilityReason_startH245; if (!call->h245listener && ooCreateH245Listener(call) != OO_OK) { OOTRACEERR3("Error:No H245Listener, can't send startH245 facility (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } facility->m.h245AddressPresent = TRUE; if (call->versionIP == 6) { facility->h245Address.t = T_H225TransportAddress_ip6Address; h245Ip6Addr = (H225TransportAddress_ip6Address*) memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address)); if(!h245Ip6Addr) { OOTRACEERR3("Error:Memory - ooSendFacility - h245Ip6Addr" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data); h245Ip6Addr->ip.numocts=16; h245Ip6Addr->port = *(call->h245listenport); facility->h245Address.u.ip6Address = h245Ip6Addr; } else { facility->h245Address.t = T_H225TransportAddress_ipAddress; h245IpAddr = (H225TransportAddress_ipAddress*) memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress)); if(!h245IpAddr) { OOTRACEERR3("Error:Memory - ooSendFacility - h245IpAddr" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data); h245IpAddr->ip.numocts=4; h245IpAddr->port = *(call->h245listenport); facility->h245Address.u.ipAddress = h245IpAddr; } OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType, call->callToken); ret = ooSendH225Msg(call, pQ931Msg); if(ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue Facility message to outbound " "queue.(%s, %s)\n", call->callType, call->callToken); } /* memReset (&gH323ep.msgctxt); */ memReset (call->msgctxt); return ret; } /* */ int ooSendStatus(OOH323CallData *call) { int ret; H225Status_UUIE *status; Q931Message *q931msg=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; OOTRACEDBGC3("Building StatusMsg (%s, %s)\n", call->callType, call->callToken); ret = ooCreateQ931Message(pctxt, &q931msg, Q931StatusMsg); if(ret != OO_OK) { OOTRACEERR1("Error: In allocating memory for - H225 Status " "message\n"); return OO_FAILED; } q931msg->callReference = call->callReference; q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooSendStatus - userInfo\n"); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_status; status = (H225Status_UUIE*)memAllocZ(pctxt, sizeof(H225Status_UUIE)); if(!status) { OOTRACEERR1("ERROR:Memory - ooSendStatus \n"); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.h323_message_body.u.status = status; status->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(status->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); status->protocolIdentifier = gProtocolID; ooQ931SetCauseIE(pctxt, q931msg, Q931StatusEnquiryResponse, 0, 0); ooQ931SetCallStateIE(pctxt, q931msg, 10); OOTRACEDBGA3("Built Status (%s, %s)\n", call->callType, call->callToken); ret = ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue Status message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return ret; } int ooSendStatusInquiry(OOH323CallData *call) { int ret; H225StatusInquiry_UUIE *statusInq; Q931Message *q931msg=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; OOTRACEDBGC3("Building StatusInquryMsg (%s, %s)\n", call->callType, call->callToken); ret = ooCreateQ931Message(pctxt, &q931msg, Q931StatusEnquiryMsg); if(ret != OO_OK) { OOTRACEERR1("Error: In allocating memory for - H225 Status " "message\n"); return OO_FAILED; } q931msg->callReference = call->callReference; q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooSendStatus - userInfo\n"); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_statusInquiry; statusInq = (H225StatusInquiry_UUIE*)memAllocZ(pctxt, sizeof(H225StatusInquiry_UUIE)); if(!statusInq) { OOTRACEERR1("ERROR:Memory - ooSendStatusInquiry \n"); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.h323_message_body.u.statusInquiry = statusInq; statusInq->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(statusInq->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); statusInq->protocolIdentifier = gProtocolID; OOTRACEDBGA3("Built StatusInquiry (%s, %s)\n", call->callType, call->callToken); ret = ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue Status message to outbound queue.(%s, %s)\n", call->callType, call->callToken); } /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return ret; } int ooSendReleaseComplete(OOH323CallData *call) { int ret; Q931Message *q931msg=NULL; H225ReleaseComplete_UUIE *releaseComplete; enum Q931CauseValues cause = Q931ErrorInCauseIE; unsigned h225ReasonCode = T_H225ReleaseCompleteReason_undefinedReason; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; OOTRACEDBGA3("Building Release Complete message to send(%s, %s)\n", call->callType, call->callToken); ret = ooCreateQ931Message(pctxt, &q931msg, Q931ReleaseCompleteMsg); if(ret != OO_OK) { OOTRACEERR3("Error: In ooCreateQ931Message - H225 Release Complete " "message(%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } q931msg->callReference = call->callReference; q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooSendReleaseComplete - userInfo\n"); return OO_FAILED; } memset (q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); releaseComplete = (H225ReleaseComplete_UUIE*)memAlloc(pctxt, sizeof(H225ReleaseComplete_UUIE)); if(!releaseComplete) { OOTRACEERR3("Error:Memory - ooSendReleaseComplete - releaseComplete" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset(releaseComplete, 0, sizeof(H225ReleaseComplete_UUIE)); q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_releaseComplete; /* Get cause value and h225 reason code corresponding to OOCallClearReason*/ ooQ931GetCauseAndReasonCodeFromCallClearReason(call->callEndReason, &cause, &h225ReasonCode); if (call->q931cause == 0) call->q931cause = cause; /* Set Cause IE */ ooQ931SetCauseIE(pctxt, q931msg, call->q931cause, 0, 0); /* Set H225 releaseComplete reasonCode */ releaseComplete->m.reasonPresent = TRUE; releaseComplete->reason.t = h225ReasonCode; /* Add user-user ie */ q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=TRUE; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG (call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_releaseComplete; q931msg->userInfo->h323_uu_pdu.h323_message_body.u.releaseComplete = releaseComplete; releaseComplete->m.callIdentifierPresent = 1; releaseComplete->protocolIdentifier = gProtocolID; releaseComplete->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(releaseComplete->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); OOTRACEDBGA3("Built Release Complete message (%s, %s)\n", call->callType, call->callToken); /* Send H225 message */ ret = ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue ReleaseComplete message to outbound" " queue.(%s, %s)\n", call->callType, call->callToken); } /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return ret; } int ooSendConnect(OOH323CallData *call) { call->connectTime = (H235TimeStamp) time(NULL); if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) { if(gH323ep.gkClient->state == GkClientRegistered) { ooGkClientSendIRR(gH323ep.gkClient, call); } } ooAcceptCall(call); return OO_OK; } /*TODO: Need to clean logical channel in case of failure after creating one */ int ooAcceptCall(OOH323CallData *call) { int ret = 0, i=0; H225Connect_UUIE *connect; H225TransportAddress_ipAddress *h245IpAddr; H225TransportAddress_ip6Address *h245Ip6Addr; H225VendorIdentifier *vendor; Q931Message *q931msg=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; ret = ooCreateQ931Message(pctxt, &q931msg, Q931ConnectMsg); if(ret != OO_OK) { OOTRACEERR1("Error: In allocating memory for - H225 " "Connect message\n"); return OO_FAILED; } q931msg->callReference = call->callReference; /* Set bearer capability */ if(OO_OK != ooSetBearerCapabilityIE(pctxt, q931msg, Q931CCITTStd, // Q931TransferUnrestrictedDigital, Q931TransferPacketMode, // Q931TransferRatePacketMode, Q931UserInfoLayer1G722G725)) Q931TransferSpeech, Q931TransferCircuitMode, Q931TransferRate64Kbps, Q931UserInfoLayer1G711ALaw)) { OOTRACEERR3("Error: Failed to set bearer capability ie. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } q931msg->userInfo = (H225H323_UserInformation*) memAllocZ (pctxt,sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooAcceptCall - userInfo\n"); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=TRUE; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG (call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_connect; connect = (H225Connect_UUIE*) memAllocZ (pctxt, sizeof(H225Connect_UUIE)); if(!connect) { OOTRACEERR1("ERROR:Memory - ooAcceptCall - connect\n"); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.h323_message_body.u.connect = connect; connect->m.fastStartPresent = 0; connect->m.multipleCallsPresent = 1; connect->m.maintainConnectionPresent = 1; connect->multipleCalls = FALSE; connect->maintainConnection = FALSE; connect->conferenceID.numocts = 16; for (i = 0; i < 16; i++) connect->conferenceID.data[i] = i + 1; connect->m.callIdentifierPresent = 1; connect->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(connect->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); connect->conferenceID.numocts = call->confIdentifier.numocts; memcpy(connect->conferenceID.data, call->confIdentifier.data, call->confIdentifier.numocts); /* Populate alias addresses */ connect->m.connectedAddressPresent = TRUE; if(call->ourAliases) ret = ooPopulateAliasList(pctxt, call->ourAliases, &connect->connectedAddress, 0); else ret = ooPopulateAliasList(pctxt, gH323ep.aliases, &connect->connectedAddress, 0); if(OO_OK != ret) { OOTRACEERR1("Error:Failed to populate alias list in Connect message\n"); memReset(pctxt); return OO_FAILED; } connect->m.presentationIndicatorPresent = TRUE; connect->presentationIndicator.t = T_H225PresentationIndicator_presentationAllowed; connect->m.screeningIndicatorPresent = TRUE; connect->screeningIndicator = userProvidedNotScreened; connect->protocolIdentifier = gProtocolID; /* Pose as Terminal or Gateway */ if(gH323ep.isGateway) connect->destinationInfo.m.gatewayPresent = TRUE; else connect->destinationInfo.m.terminalPresent = TRUE; connect->destinationInfo.m.vendorPresent = 1; vendor = &connect->destinationInfo.vendor; vendor->vendor.t35CountryCode = gH323ep.t35CountryCode; vendor->vendor.t35Extension = gH323ep.t35Extension; vendor->vendor.manufacturerCode = gH323ep.manufacturerCode; if(gH323ep.productID) { vendor->m.productIdPresent = 1; vendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), sizeof(vendor->productId.data)); strncpy((char *)vendor->productId.data, gH323ep.productID, vendor->productId.numocts); } if(gH323ep.versionID) { vendor->m.versionIdPresent = 1; vendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), sizeof(vendor->versionId.data)); strncpy((char *)vendor->versionId.data, gH323ep.versionID, vendor->versionId.numocts); } if (!call->fsSent) { ret = ooSetFastStartResponse(call, q931msg, &connect->fastStart.n, &connect->fastStart.elem); if(ret != ASN_OK) { return ret; } if(connect->fastStart.n > 0) { connect->m.fastStartPresent = TRUE; call->fsSent = TRUE; } else connect->m.fastStartPresent = FALSE; } else { connect->m.fastStartPresent = FALSE; } /* free the stored fast start response */ if(call->pFastStartRes) { int k; for(k = 0; k < call->pFastStartRes->n; k ++) { memFreePtr(call->pctxt, call->pFastStartRes->elem[k].data); } memFreePtr(call->pctxt, call->pFastStartRes->elem); memFreePtr(call->pctxt, call->pFastStartRes); call->pFastStartRes = NULL; } /* Add h245 listener address. */ /* Do not add H245 listener address in case of fast-start. why? */ /* May 20110205 */ /* Send h245 listener addr any case if H245 connection isn't established */ if (/* (!OO_TESTFLAG(call->flags, OO_M_FASTSTART) || call->remoteFastStartOLCs.count == 0) && */ !OO_TESTFLAG (call->flags, OO_M_TUNNELING) && ( (!call->h245listener && ooCreateH245Listener(call) == OO_OK) || !call->pH245Channel)) { connect->m.h245AddressPresent = TRUE; if (call->versionIP == 6) { connect->h245Address.t = T_H225TransportAddress_ip6Address; h245Ip6Addr = (H225TransportAddress_ip6Address*) memAllocZ (pctxt, sizeof(H225TransportAddress_ip6Address)); if(!h245Ip6Addr) { OOTRACEERR3("Error:Memory - ooAcceptCall - h245Ip6Addr" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET6, call->localIP, h245Ip6Addr->ip.data); h245Ip6Addr->ip.numocts=16; h245Ip6Addr->port = *(call->h245listenport); connect->h245Address.u.ip6Address = h245Ip6Addr; } else { connect->h245Address.t = T_H225TransportAddress_ipAddress; h245IpAddr = (H225TransportAddress_ipAddress*) memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress)); if(!h245IpAddr) { OOTRACEERR3("Error:Memory - ooAcceptCall - h245IpAddr" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET, call->localIP, h245IpAddr->ip.data); h245IpAddr->ip.numocts=4; h245IpAddr->port = *(call->h245listenport); connect->h245Address.u.ipAddress = h245IpAddr; } } OOTRACEDBGA3("Built H.225 Connect message (%s, %s)\n", call->callType, call->callToken); /* H225 message callback */ if(gH323ep.h225Callbacks.onBuiltConnect) gH323ep.h225Callbacks.onBuiltConnect(call, q931msg); ret=ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue Connect message to outbound queue.(%s, %s)\n", call->callType, call->callToken); /* memReset(&gH323ep.msgctxt);*/ memReset(call->msgctxt); return OO_FAILED; } /* memReset(&gH323ep.msgctxt); */ ooSendTCSandMSD(call); memReset(call->msgctxt); call->callState = OO_CALL_CONNECTED; if (call->rtdrCount > 0 && call->rtdrInterval > 0) { return ooSendRoundTripDelayRequest(call); } return OO_OK; } int ooH323HandleCallFwdRequest(OOH323CallData *call) { OOH323CallData *fwdedCall=NULL; OOCTXT *pctxt; ooAliases *pNewAlias=NULL, *alias=NULL; struct timespec ts; struct timeval tv; int i=0, irand=0; /* Note: We keep same callToken, for new call which is going to replace an existing call, thus treating it as a single call.*/ fwdedCall = ooCreateCall("outgoing", call->callToken); pctxt = fwdedCall->pctxt; /* Retrieve new destination info from original call */ if(!ooUtilsIsStrEmpty(call->pCallFwdData->ip)) { strcpy(fwdedCall->remoteIP, call->pCallFwdData->ip); } fwdedCall->remotePort = call->pCallFwdData->port; if(call->pCallFwdData->aliases) { alias = call->pCallFwdData->aliases; while(alias) { pNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); pNewAlias->value = (char*) memAlloc(pctxt, strlen(alias->value)+1); if(!pNewAlias || !pNewAlias->value) { OOTRACEERR3("Error:Memory - ooH323HandleCallFwdRequest - " "pNewAlias/pNewAlias->value" "(%s, %s)\n", call->callType, call->callToken); ooCleanCall(fwdedCall); return OO_FAILED; } pNewAlias->type = alias->type; strcpy(pNewAlias->value, alias->value); pNewAlias->next = fwdedCall->remoteAliases; fwdedCall->remoteAliases = pNewAlias; alias = alias->next; pNewAlias = NULL; } } fwdedCall->callReference = ooGenerateCallReference(); ooGenerateCallIdentifier(&fwdedCall->callIdentifier); fwdedCall->confIdentifier.numocts = 16; irand = rand(); for (i = 0; i < 16; i++) { fwdedCall->confIdentifier.data[i] = irand++; } if(gH323ep.gkClient && !OO_TESTFLAG(fwdedCall->flags, OO_M_DISABLEGK)) { /* No need to check registration status here as it is already checked for MakeCall command */ ooGkClientSendAdmissionRequest(gH323ep.gkClient, fwdedCall, FALSE); fwdedCall->callState = OO_CALL_WAITING_ADMISSION; ast_mutex_lock(&fwdedCall->Lock); tv = ast_tvnow(); ts.tv_sec += tv.tv_sec + 24; ts.tv_nsec = tv.tv_usec * 1000; ast_cond_timedwait(&fwdedCall->gkWait, &fwdedCall->Lock, &ts); if (fwdedCall->callState == OO_CALL_WAITING_ADMISSION) /* GK is not responding */ fwdedCall->callState = OO_CALL_CLEAR; ast_mutex_unlock(&fwdedCall->Lock); } if (fwdedCall->callState < OO_CALL_CLEAR) { ast_mutex_lock(&fwdedCall->Lock); ooH323CallAdmitted (fwdedCall); ast_mutex_unlock(&fwdedCall->Lock); } return OO_OK; } int ooH323NewCall(char *callToken) { OOH323CallData* call; if(!callToken) { OOTRACEERR1("ERROR: Invalid callToken parameter to make call\n"); return OO_FAILED; } call = ooCreateCall("outgoing", callToken); if (!call) { OOTRACEERR1("ERROR: Can't create call %s\n"); return OO_FAILED; } return OO_OK; } int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts) { OOH323CallData *call; int ret=OO_OK, i=0, irand=0; char tmp[2+8*4+7]="\0"; char *ip=NULL, *port = NULL; struct timeval tv; struct timespec ts; struct ast_sockaddr m_addr; if(!dest) { OOTRACEERR1("ERROR:Invalid destination for new call\n"); return OO_FAILED; } if(!callToken) { OOTRACEERR1("ERROR: Invalid callToken parameter to make call\n"); return OO_FAILED; } /* call = ooCreateCall("outgoing", callToken); */ call = ooFindCallByToken(callToken); if (!call) { OOTRACEERR1("ERROR: Can't create call %s\n"); return OO_FAILED; } if(opts) { if(opts->fastStart) OO_SETFLAG(call->flags, OO_M_FASTSTART); else OO_CLRFLAG(call->flags, OO_M_FASTSTART); if(opts->tunneling) OO_SETFLAG(call->flags, OO_M_TUNNELING); else OO_CLRFLAG(call->flags, OO_M_TUNNELING); if(opts->disableGk || gH323ep.gkClient == NULL) OO_SETFLAG(call->flags, OO_M_DISABLEGK); else OO_CLRFLAG(call->flags, OO_M_DISABLEGK); call->callMode = opts->callMode; call->transfercap = opts->transfercap; } ret = ooParseDestination(call, dest, tmp, 2+8*4+7, &call->remoteAliases); if(ret != OO_OK) { OOTRACEERR2("Error: Failed to parse the destination string %s for " "new call\n", dest); ooCleanCall(call); return OO_FAILED; } /* Check whether we have ip address */ if(!ooUtilsIsStrEmpty(tmp)) { ip = tmp; port = strrchr(tmp, ':'); *port = '\0'; port++; strcpy(call->remoteIP, ip); ast_parse_arg(ip, PARSE_ADDR, &m_addr); if (ast_sockaddr_is_ipv6(&m_addr)) call->versionIP = 6; else call->versionIP = 4; call->remotePort = atoi(port); } strcpy(callToken, call->callToken); call->callReference = ooGenerateCallReference(); ooGenerateCallIdentifier(&call->callIdentifier); call->confIdentifier.numocts = 16; irand = rand(); for (i = 0; i < 16; i++) { call->confIdentifier.data[i] = irand++; } if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK)) { if(gH323ep.gkClient->state == GkClientRegistered) { call->callState = OO_CALL_WAITING_ADMISSION; ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE); tv = ast_tvnow(); ts.tv_sec = tv.tv_sec + 24; ts.tv_nsec = tv.tv_usec * 1000; ast_mutex_lock(&call->GkLock); if (call->callState == OO_CALL_WAITING_ADMISSION) ast_cond_timedwait(&call->gkWait, &call->GkLock, &ts); if (call->callState == OO_CALL_WAITING_ADMISSION) call->callState = OO_CALL_CLEAR; ast_mutex_unlock(&call->GkLock); } else { OOTRACEERR1("Error:Aborting outgoing call as not yet" "registered with Gk\n"); call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_GK_UNREACHABLE; } } /* Send as H225 message to calling endpoint */ ast_mutex_lock(&call->Lock); if (call->callState < OO_CALL_CLEAR) { if ((ret = ooH323CallAdmitted (call)) != OO_OK) { ast_mutex_unlock(&call->Lock); return ret; } } else ret = OO_FAILED; ast_mutex_unlock(&call->Lock); return ret; } int ooH323CallAdmitted(OOH323CallData *call) { int ret=0; if(!call) { /* Call not supplied. Must locate it in list */ OOTRACEERR1("ERROR: Invalid call parameter to ooH323CallAdmitted"); return OO_FAILED; } if(!strcmp(call->callType, "outgoing")) { ret = ooCreateH225Connection(call); if(ret != OO_OK) { OOTRACEERR3("ERROR:Failed to create H225 connection to %s:%d\n", call->remoteIP, call->remotePort); if(call->callState< OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_UNKNOWN; } return OO_FAILED; } if(gH323ep.h323Callbacks.onOutgoingCall) { /* Outgoing call callback function */ if (gH323ep.h323Callbacks.onOutgoingCall(call) != OO_OK) { OOTRACEERR3("ERROR:Failed to setup media to (%s,%d)\n", call->callType, call->callToken); if(call->callState< OO_CALL_CLEAR) { call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_UNKNOWN; } return OO_FAILED; } } ret = ooH323MakeCall_helper(call); } else { /* incoming call */ if(gH323ep.h323Callbacks.onIncomingCall) { /* Incoming call callback function */ gH323ep.h323Callbacks.onIncomingCall(call); } /* Check for manual ringback generation */ if(!OO_TESTFLAG(gH323ep.flags, OO_M_MANUALRINGBACK)) { ooSendAlerting(call); /* Send alerting message */ if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) { ooSendConnect(call); /* Send connect message - call accepted */ } } } return OO_OK; } int ooH323MakeCall_helper(OOH323CallData *call) { int ret=0,i=0, k; Q931Message *q931msg = NULL; H225Setup_UUIE *setup; ASN1DynOctStr *pFS=NULL; H225TransportAddress_ipAddress *destCallSignalIpAddress,*srcCallSignalIpAddress; H225TransportAddress_ip6Address *destCallSignalIp6Address,*srcCallSignalIp6Address; ooH323EpCapability *epCap=NULL; OOCTXT *pctxt = NULL; H245OpenLogicalChannel *olc, printOlc; ASN1BOOL aligned = 1; ooAliases *pAlias = NULL; /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; ret = ooCreateQ931Message(pctxt, &q931msg, Q931SetupMsg); if(ret != OO_OK) { OOTRACEERR1("ERROR:Failed to Create Q931 SETUP Message\n "); return OO_FAILED; } q931msg->callReference = call->callReference; /* Set bearer capability */ if(OO_OK != ooSetBearerCapabilityIE(pctxt, q931msg, Q931CCITTStd, // Q931TransferUnrestrictedDigital, Q931TransferPacketMode, call->transfercap, Q931TransferCircuitMode, // Q931TransferRatePacketMode, Q931UserInfoLayer1G722G725)) Q931TransferRate64Kbps, Q931UserInfoLayer1G711ALaw)) { OOTRACEERR3("Error: Failed to set bearer capability ie.(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } /* Set calling party number Q931 IE */ if(call->callingPartyNumber && call->callingPartyNumber[0]) ooQ931SetCallingPartyNumberIE(pctxt, q931msg, (const char*)call->callingPartyNumber, 1, 0, 0, 0); /* Set called party number Q931 IE */ if(call->calledPartyNumber) ooQ931SetCalledPartyNumberIE(pctxt, q931msg, (const char*)call->calledPartyNumber, 1, 0); else if(call->remoteAliases) { pAlias = call->remoteAliases; while(pAlias) { if(pAlias->type == T_H225AliasAddress_dialedDigits) break; pAlias = pAlias->next; } if(pAlias) { call->calledPartyNumber = (char*)memAlloc(call->pctxt, strlen(pAlias->value)+1); if(!call->calledPartyNumber) { OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - " "calledPartyNumber(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } strcpy(call->calledPartyNumber, pAlias->value); ooQ931SetCalledPartyNumberIE(pctxt, q931msg, (const char*)call->calledPartyNumber, 1, 0); } } q931msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR1("ERROR:Memory - ooH323MakeCall_helper - userInfo\n"); return OO_FAILED; } memset(q931msg->userInfo, 0, sizeof(H225H323_UserInformation)); setup = (H225Setup_UUIE*) memAlloc(pctxt, sizeof(H225Setup_UUIE)); if(!setup) { OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - setup (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset (setup, 0, sizeof(H225Setup_UUIE)); setup->protocolIdentifier = gProtocolID; /* Populate Alias Address.*/ if(call->ourAliases || gH323ep.aliases) { setup->m.sourceAddressPresent = TRUE; if(call->ourAliases) ret = ooPopulateAliasList(pctxt, call->ourAliases, &setup->sourceAddress, 0); else if(gH323ep.aliases) ret = ooPopulateAliasList(pctxt, gH323ep.aliases, &setup->sourceAddress, 0); if(OO_OK != ret) { OOTRACEERR1("Error:Failed to populate alias list in SETUP message\n"); memReset(pctxt); return OO_FAILED; } } setup->m.presentationIndicatorPresent = TRUE; setup->presentationIndicator.t = T_H225PresentationIndicator_presentationAllowed; setup->m.screeningIndicatorPresent = TRUE; setup->screeningIndicator = userProvidedNotScreened; setup->m.multipleCallsPresent = TRUE; setup->multipleCalls = FALSE; setup->m.maintainConnectionPresent = TRUE; setup->maintainConnection = FALSE; /* Populate Destination aliases */ if(call->remoteAliases) { setup->m.destinationAddressPresent = TRUE; ret = ooPopulateAliasList(pctxt, call->remoteAliases, &setup->destinationAddress, 0); if(OO_OK != ret) { OOTRACEERR1("Error:Failed to populate destination alias list in SETUP" "message\n"); memReset(pctxt); return OO_FAILED; } } /* Populate the vendor information */ if(gH323ep.isGateway) setup->sourceInfo.m.gatewayPresent = TRUE; else setup->sourceInfo.m.terminalPresent = TRUE; setup->sourceInfo.m.vendorPresent=TRUE; setup->sourceInfo.vendor.vendor.t35CountryCode = gH323ep.t35CountryCode; setup->sourceInfo.vendor.vendor.t35Extension = gH323ep.t35Extension; setup->sourceInfo.vendor.vendor.manufacturerCode= gH323ep.manufacturerCode; if(gH323ep.productID) { setup->sourceInfo.vendor.m.productIdPresent=TRUE; setup->sourceInfo.vendor.productId.numocts = ASN1MIN( strlen(gH323ep.productID), sizeof(setup->sourceInfo.vendor.productId.data)); strncpy((char*)setup->sourceInfo.vendor.productId.data, gH323ep.productID, setup->sourceInfo.vendor.productId.numocts); } else setup->sourceInfo.vendor.m.productIdPresent=FALSE; if(gH323ep.versionID) { setup->sourceInfo.vendor.m.versionIdPresent=TRUE; setup->sourceInfo.vendor.versionId.numocts = ASN1MIN( strlen(gH323ep.versionID), sizeof(setup->sourceInfo.vendor.versionId.data)); strncpy((char*)setup->sourceInfo.vendor.versionId.data, gH323ep.versionID, setup->sourceInfo.vendor.versionId.numocts); } else setup->sourceInfo.vendor.m.versionIdPresent=FALSE; setup->sourceInfo.mc = FALSE; setup->sourceInfo.undefinedNode = FALSE; /* Populate the destination Call Signal Address */ setup->m.destCallSignalAddressPresent=TRUE; setup->activeMC=FALSE; if (call->versionIP == 6) { setup->destCallSignalAddress.t=T_H225TransportAddress_ip6Address; destCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt, sizeof(H225TransportAddress_ip6Address)); if(!destCallSignalIp6Address) { OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - " "destCallSignal6Address. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET6, call->remoteIP, destCallSignalIp6Address->ip.data); destCallSignalIp6Address->ip.numocts=16; destCallSignalIp6Address->port = call->remotePort; setup->destCallSignalAddress.u.ip6Address = destCallSignalIp6Address; } else { setup->destCallSignalAddress.t=T_H225TransportAddress_ipAddress; destCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!destCallSignalIpAddress) { OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - " "destCallSignalAddress. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET, call->remoteIP, destCallSignalIpAddress->ip.data); destCallSignalIpAddress->ip.numocts=4; destCallSignalIpAddress->port = call->remotePort; setup->destCallSignalAddress.u.ipAddress = destCallSignalIpAddress; } /* Populate the source Call Signal Address */ setup->m.sourceCallSignalAddressPresent=TRUE; if (call->versionIP == 6) { setup->sourceCallSignalAddress.t=T_H225TransportAddress_ip6Address; srcCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt, sizeof(H225TransportAddress_ip6Address)); if(!srcCallSignalIp6Address) { OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - srcCallSignal6Address" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET6, call->localIP, srcCallSignalIp6Address->ip.data); srcCallSignalIp6Address->ip.numocts=16; srcCallSignalIp6Address->port= call->pH225Channel->port; setup->sourceCallSignalAddress.u.ip6Address = srcCallSignalIp6Address; } else { setup->sourceCallSignalAddress.t=T_H225TransportAddress_ipAddress; srcCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!srcCallSignalIpAddress) { OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - srcCallSignalAddress" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET, call->localIP, srcCallSignalIpAddress->ip.data); srcCallSignalIpAddress->ip.numocts=4; srcCallSignalIpAddress->port= call->pH225Channel->port; setup->sourceCallSignalAddress.u.ipAddress = srcCallSignalIpAddress; } /* No fast start */ if(!OO_TESTFLAG(call->flags, OO_M_FASTSTART)) { setup->m.fastStartPresent = FALSE; } else{ setup->m.fastStartPresent = TRUE; pFS = (ASN1DynOctStr*)memAlloc(pctxt, gH323ep.noOfCaps* sizeof(ASN1DynOctStr)); if(!pFS) { OOTRACEERR3("Error:Memory - ooH323MakeCall_helper - pFS(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } /* Use preference order of codecs */ i=0; for(k=0; k< call->capPrefs.index; k++) { OOTRACEDBGC5("Preffered capability at index %d is %s. (%s, %s)\n", k, ooGetCapTypeText(call->capPrefs.order[k]), call->callType, call->callToken); if(call->ourCaps) { epCap = call->ourCaps; OOTRACEDBGC3("Using call specific capabilities in faststart of " "setup message. (%s, %s)\n", call->callType, call->callToken); } else{ epCap = gH323ep.myCaps; OOTRACEDBGC3("Using end-point capabilities for faststart of setup" "message. (%s, %s)\n", call->callType, call->callToken); } while(epCap){ if(epCap->cap == call->capPrefs.order[k]) break; else epCap = epCap->next; } if(!epCap) { OOTRACEWARN4("Warn:Preferred capability %s is abscent in " "capability list. (%s, %s)\n", ooGetCapTypeText(call->capPrefs.order[k]), call->callType, call->callToken); continue; } /* don't send t38/other data caps in fasstart olcs */ if (epCap->capType == OO_CAP_TYPE_DATA) continue; OOTRACEDBGC4("Building olcs with capability %s. (%s, %s)\n", ooGetCapTypeText(epCap->cap), call->callType, call->callToken); if(epCap->dir & OORX) { olc = (H245OpenLogicalChannel*)memAlloc(pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooH323MakeCall_helper - olc(%s, %s)" "\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, q931msg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); olc->forwardLogicalChannelNumber = call->logicalChanNoCur++; if(call->logicalChanNoCur > call->logicalChanNoMax) call->logicalChanNoCur = call->logicalChanNoBase; ooBuildFastStartOLC(call, olc, epCap, pctxt, OORX); /* Do not specify msg buffer let automatic allocation work */ setPERBuffer(pctxt, NULL, 0, aligned); if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK) { OOTRACEERR3("ERROR:Encoding of olc failed for faststart(%s, %s)" "\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, q931msg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } pFS[i].data = (unsigned char *)encodeGetMsgPtr(pctxt, (int *)&(pFS[i].numocts)); /* Dump faststart element in logfile for debugging purpose */ setPERBuffer(pctxt, (unsigned char*)pFS[i].data, pFS[i].numocts, 1); initializePrintHandler(&printHandler, "FastStart Element"); setEventHandler (pctxt, &printHandler); memset(&printOlc, 0, sizeof(printOlc)); ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc)); if(ret != ASN_OK) { OOTRACEERR3("Error: Failed decoding FastStart Element." "(%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, q931msg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } finishPrint(); removeEventHandler(pctxt); olc = NULL; i++; OOTRACEDBGC5("Added RX fs element %d with capability %s(%s, %s)\n", i, ooGetCapTypeText(epCap->cap), call->callType, call->callToken); } if(epCap->dir & OOTX) { olc = (H245OpenLogicalChannel*)memAlloc(pctxt, sizeof(H245OpenLogicalChannel)); if(!olc) { OOTRACEERR3("ERROR:Memory - ooH323MakeCall_helper - olc(%s, %s)" "\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, q931msg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } memset(olc, 0, sizeof(H245OpenLogicalChannel)); olc->forwardLogicalChannelNumber = call->logicalChanNoCur++; if(call->logicalChanNoCur > call->logicalChanNoMax) call->logicalChanNoCur = call->logicalChanNoBase; ooBuildFastStartOLC(call, olc, epCap, pctxt, OOTX); /* Do not specify msg buffer let automatic allocation work */ setPERBuffer(pctxt, NULL, 0, aligned); if(asn1PE_H245OpenLogicalChannel(pctxt, olc) != ASN_OK) { OOTRACEERR3("ERROR:Encoding of olc failed for faststart(%s, %s)" "\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, q931msg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } pFS[i].data = (unsigned char *)encodeGetMsgPtr(pctxt, (int *)&(pFS[i].numocts)); /* Dump faststart element in logfile for debugging purpose */ setPERBuffer(pctxt, (unsigned char*)pFS[i].data, pFS[i].numocts, 1); initializePrintHandler(&printHandler, "FastStart Element"); setEventHandler (pctxt, &printHandler); memset(&printOlc, 0, sizeof(printOlc)); ret = asn1PD_H245OpenLogicalChannel(pctxt, &(printOlc)); if(ret != ASN_OK) { OOTRACEERR3("Error: Failed decoding FastStart Element." "(%s, %s)\n", call->callType, call->callToken); ooFreeQ931Message(pctxt, q931msg); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = OO_REASON_LOCAL_CLEARED; call->callState = OO_CALL_CLEAR; } return OO_FAILED; } finishPrint(); removeEventHandler(pctxt); olc = NULL; i++; OOTRACEDBGC5("Added TX fs element %d with capability %s(%s, %s)\n", i, ooGetCapTypeText(epCap->cap), call->callType, call->callToken); } } OOTRACEDBGA4("Added %d fast start elements to SETUP message (%s, %s)\n", i, call->callType, call->callToken); setup->fastStart.n = i; setup->fastStart.elem = pFS; } setup->conferenceID.numocts= call->confIdentifier.numocts; memcpy(setup->conferenceID.data, call->confIdentifier.data, call->confIdentifier.numocts); setup->conferenceGoal.t = T_H225Setup_UUIE_conferenceGoal_create; /* H.225 point to point call */ setup->callType.t = T_H225CallType_pointToPoint; /* Populate optional fields */ setup->m.callIdentifierPresent = TRUE; /*ooGenerateCallIdentifier(&setup->callIdentifier);*/ setup->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(setup->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); setup->m.mediaWaitForConnectPresent = TRUE; if(OO_TESTFLAG(call->flags, OO_M_MEDIAWAITFORCONN)) { setup->mediaWaitForConnect = TRUE; } else { setup->mediaWaitForConnect = FALSE; } setup->m.canOverlapSendPresent = TRUE; setup->canOverlapSend = FALSE; /* Populate the userInfo structure with the setup UUIE */ q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_setup; q931msg->userInfo->h323_uu_pdu.h323_message_body.u.setup = setup; q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG (call->flags, OO_M_TUNNELING); /* For H.323 version 4 and higher, if fast connect, tunneling should be supported. why? */ OOTRACEDBGA3("Built SETUP message (%s, %s)\n", call->callType, call->callToken); /* H225 message callback */ if(gH323ep.h225Callbacks.onBuiltSetup) gH323ep.h225Callbacks.onBuiltSetup(call, q931msg); ret=ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue SETUP message to outbound queue. (%s, %s)\n", call->callType, call->callToken); } /* memReset(&gH323ep.msgctxt);*/ memReset(call->msgctxt); return ret; } int ooQ931SendDTMFAsKeyPadIE(OOH323CallData *call, const char* data) { int ret; H225Information_UUIE *information=NULL; Q931Message *q931msg=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; ret = ooCreateQ931Message(pctxt, &q931msg, Q931InformationMsg); if(ret != OO_OK) { OOTRACEERR3("Error: In allocating memory for - H225 Information message." "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } q931msg->callReference = call->callReference; q931msg->userInfo = (H225H323_UserInformation*)memAllocZ(pctxt, sizeof(H225H323_UserInformation)); if(!q931msg->userInfo) { OOTRACEERR3("ERROR:Memory - ooQ931SendDTMFAsKeypadIE - userInfo" "(%s, %s)\n", call->callType, call->callToken); /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; q931msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG(call->flags, OO_M_TUNNELING); q931msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_information; information = (H225Information_UUIE*)memAllocZ(pctxt, sizeof(H225Information_UUIE)); if(!information) { OOTRACEERR3("ERROR:Memory - ooQ931SendDTMFAsKeypadIE - information" "(%s, %s)\n", call->callType, call->callToken); /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return OO_FAILED; } q931msg->userInfo->h323_uu_pdu.h323_message_body.u.information = information; information->m.callIdentifierPresent = 1; information->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(information->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); information->protocolIdentifier = gProtocolID; /*Add keypad IE*/ ret = ooQ931SetKeypadIE(pctxt, q931msg, data); if(ret != OO_OK) { OOTRACEERR3("Error:Creating keypad IE for (%s, %s)\n", call->callType, call->callToken); /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return OO_FAILED; } ret=ooSendH225Msg(call, q931msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue Information message to outbound " "queue. (%s, %s)\n", call->callType, call->callToken); } /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return ret; } int ooH323ForwardCall(char* callToken, char *dest) { int ret=0; Q931Message *pQ931Msg = NULL; H225Facility_UUIE *facility=NULL; OOCTXT *pctxt = &gH323ep.msgctxt; OOH323CallData *call; char ip[2+8*4+7]="\0", *pcPort=NULL; H225TransportAddress_ipAddress *fwdCallSignalIpAddress; H225TransportAddress_ip6Address *fwdCallSignalIp6Address; call= ooFindCallByToken(callToken); if(!call) { OOTRACEERR2("ERROR: Invalid call token for forward - %s\n", callToken); return OO_FAILED; } OOTRACEDBGA3("Building Facility message for call forward (%s, %s)\n", call->callType, call->callToken); call->pCallFwdData = (OOCallFwdData*)memAllocZ(call->pctxt, sizeof(OOCallFwdData)); if(!call->pCallFwdData) { OOTRACEERR3("Error:Memory - ooH323ForwardCall - pCallFwdData (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } ret = ooParseDestination(call, dest, ip, 2+8*4+7, &call->pCallFwdData->aliases); if(ret != OO_OK) { OOTRACEERR4("Error:Failed to parse the destination %s for call fwd." "(%s, %s)\n", dest, call->callType, call->callToken); memFreePtr(call->pctxt, call->pCallFwdData); return OO_FAILED; } if(!ooUtilsIsStrEmpty(ip)) { pcPort = strrchr(ip, ':'); if(pcPort) { *pcPort = '\0'; pcPort++; call->pCallFwdData->port = atoi(pcPort); } strcpy(call->pCallFwdData->ip, ip); } ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); if(ret != OO_OK) { OOTRACEERR3 ("ERROR: In allocating memory for call transfer facility message " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pQ931Msg->callReference = call->callReference; pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!pQ931Msg->userInfo) { OOTRACEERR3("ERROR:Memory - ooH323ForwardCall - userInfo(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG (call->flags, OO_M_TUNNELING); pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_facility; facility = (H225Facility_UUIE*) memAllocZ (pctxt, sizeof(H225Facility_UUIE)); if(!facility) { OOTRACEERR3("ERROR:Memory - ooH323ForwardCall - facility (%s, %s)" "\n", call->callType, call->callToken); return OO_FAILED; } pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; facility->protocolIdentifier = gProtocolID; facility->m.callIdentifierPresent = 1; facility->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(facility->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); facility->reason.t = T_H225FacilityReason_callForwarded; if(!ooUtilsIsStrEmpty(call->pCallFwdData->ip)) { facility->m.alternativeAddressPresent = TRUE; if (call->versionIP == 6) { facility->alternativeAddress.t=T_H225TransportAddress_ip6Address; fwdCallSignalIp6Address = (H225TransportAddress_ip6Address*)memAlloc(pctxt, sizeof(H225TransportAddress_ip6Address)); if(!fwdCallSignalIp6Address) { OOTRACEERR3("Error:Memory - ooH323ForwardCall - fwdCallSignal6Address" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET6, call->pCallFwdData->ip, fwdCallSignalIp6Address->ip.data); fwdCallSignalIp6Address->ip.numocts=16; fwdCallSignalIp6Address->port = call->pCallFwdData->port; facility->alternativeAddress.u.ip6Address = fwdCallSignalIp6Address; } else { facility->alternativeAddress.t=T_H225TransportAddress_ipAddress; fwdCallSignalIpAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!fwdCallSignalIpAddress) { OOTRACEERR3("Error:Memory - ooH323ForwardCall - fwdCallSignalAddress" "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } inet_pton(AF_INET, call->pCallFwdData->ip, fwdCallSignalIpAddress->ip.data); fwdCallSignalIpAddress->ip.numocts=4; fwdCallSignalIpAddress->port = call->pCallFwdData->port; facility->alternativeAddress.u.ipAddress = fwdCallSignalIpAddress; } } if(call->pCallFwdData->aliases) { facility->m.alternativeAliasAddressPresent = TRUE; ret = ooPopulateAliasList(pctxt, call->pCallFwdData->aliases, &facility->alternativeAliasAddress, 0); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to populate alternate aliases in " "ooH323ForwardCall. (%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } } ret = ooSendH225Msg(call, pQ931Msg); if(ret != OO_OK) { OOTRACEERR3 ("Error:Failed to enqueue Forward Facility message to outbound " "queue.(%s, %s)\n", call->callType, call->callToken); } call->callEndReason = OO_REASON_LOCAL_FWDED; memReset (&gH323ep.msgctxt); return ret; } int ooH323HangCall(char * callToken, OOCallClearReason reason, int q931cause) { OOH323CallData *call; call= ooFindCallByToken(callToken); if(!call) { OOTRACEWARN2("WARN: Call hangup failed - Call %s not present\n", callToken); return OO_FAILED; } OOTRACEINFO3("Hanging up call (%s, %s)\n", call->callType, call->callToken); if(call->callState < OO_CALL_CLEAR) { call->callEndReason = reason; call->q931cause = q931cause; call->callState = OO_CALL_CLEAR; } return OO_OK; } int ooSetBearerCapabilityIE (OOCTXT* pctxt, Q931Message *pmsg, enum Q931CodingStandard codingStandard, enum Q931InformationTransferCapability capability, enum Q931TransferMode transferMode, enum Q931TransferRate transferRate, enum Q931UserInfoLayer1Protocol userInfoLayer1) { unsigned size = 3; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ if(pmsg->bearerCapabilityIE) { memFreePtr(pctxt, pmsg->bearerCapabilityIE); pmsg->bearerCapabilityIE = NULL; } pmsg->bearerCapabilityIE = (Q931InformationElement*) memAlloc(pctxt, sizeof(Q931InformationElement)+size-1); if(!pmsg->bearerCapabilityIE) { OOTRACEERR1("Error:Memory - ooSetBearerCapabilityIE - bearerCapabilityIE" "\n"); return OO_FAILED; } pmsg->bearerCapabilityIE->discriminator = Q931BearerCapabilityIE; pmsg->bearerCapabilityIE->length = size; pmsg->bearerCapabilityIE->data[0] = (ASN1OCTET)(0x80 | ((codingStandard&3) << 5) | (capability&31)); pmsg->bearerCapabilityIE->data[1] = (0x80 | ((transferMode & 3) << 5) | (transferRate & 31)); pmsg->bearerCapabilityIE->data[2] = (0x80 | (1<<5) | userInfoLayer1); return OO_OK; } int ooQ931SetKeypadIE(OOCTXT* pctxt, Q931Message *pmsg, const char* data) { unsigned len = 0; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ len = strlen(data); pmsg->keypadIE = (Q931InformationElement*) memAlloc(pctxt, sizeof(Q931InformationElement)+len-1); if(!pmsg->keypadIE) { OOTRACEERR1("Error:Memory - ooQ931SetKeypadIE - keypadIE\n"); return OO_FAILED; } pmsg->keypadIE->discriminator = Q931KeypadIE; pmsg->keypadIE->length = len; memcpy(pmsg->keypadIE->data, data, len); return OO_OK; } int ooQ931SetCallingPartyNumberIE (OOCTXT* pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type, unsigned presentation, unsigned screening) { unsigned len = 0; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ if(pmsg->callingPartyNumberIE) { memFreePtr(pctxt, pmsg->callingPartyNumberIE); pmsg->callingPartyNumberIE = NULL; } len = strlen(number); pmsg->callingPartyNumberIE = (Q931InformationElement*) memAlloc(pctxt, sizeof(Q931InformationElement)+len+2-1); if(!pmsg->callingPartyNumberIE) { OOTRACEERR1("Error:Memory - ooQ931SetCallingPartyNumberIE - " "callingPartyNumberIE\n"); return OO_FAILED; } pmsg->callingPartyNumberIE->discriminator = Q931CallingPartyNumberIE; pmsg->callingPartyNumberIE->length = len+2; pmsg->callingPartyNumberIE->data[0] = (((type&7)<<4)|(plan&15)); pmsg->callingPartyNumberIE->data[1] = (0x80|((presentation&3)<<5)|(screening&3)); memcpy(pmsg->callingPartyNumberIE->data+2, number, len); return OO_OK; } int ooQ931SetCalledPartyNumberIE (OOCTXT* pctxt, Q931Message *pmsg, const char *number, unsigned plan, unsigned type) { unsigned len = 0; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ if(pmsg->calledPartyNumberIE) { memFreePtr(pctxt, pmsg->calledPartyNumberIE); pmsg->calledPartyNumberIE = NULL; } len = strlen(number); pmsg->calledPartyNumberIE = (Q931InformationElement*) memAlloc(pctxt, sizeof(Q931InformationElement)+len+1-1); if(!pmsg->calledPartyNumberIE) { OOTRACEERR1("Error:Memory - ooQ931SetCalledPartyNumberIE - " "calledPartyNumberIE\n"); return OO_FAILED; } pmsg->calledPartyNumberIE->discriminator = Q931CalledPartyNumberIE; pmsg->calledPartyNumberIE->length = len+1; pmsg->calledPartyNumberIE->data[0] = (0x80|((type&7)<<4)|(plan&15)); memcpy(pmsg->calledPartyNumberIE->data+1, number, len); return OO_OK; } int ooQ931SetCallStateIE (OOCTXT* pctxt, Q931Message *pmsg, unsigned char callstate) { if(pmsg->callstateIE){ memFreePtr(pctxt, pmsg->callstateIE); pmsg->callstateIE = NULL; } pmsg->callstateIE = (Q931InformationElement*) memAllocZ(pctxt, sizeof(Q931InformationElement)); if(!pmsg->callstateIE) { OOTRACEERR1("Error:Memory - ooQ931SetCallstateIE - causeIE\n"); return OO_FAILED; } pmsg->callstateIE->discriminator = Q931CallStateIE; pmsg->callstateIE->length = 1; pmsg->callstateIE->data[0] = callstate; return OO_OK; } int ooQ931SetCauseIE (OOCTXT* pctxt, Q931Message *pmsg, enum Q931CauseValues cause, unsigned coding, unsigned location) { /* OOCTXT *pctxt = &gH323ep.msgctxt; */ if(pmsg->causeIE){ memFreePtr(pctxt, pmsg->causeIE); pmsg->causeIE = NULL; } pmsg->causeIE = (Q931InformationElement*) memAlloc(pctxt, sizeof(Q931InformationElement)+1); if(!pmsg->causeIE) { OOTRACEERR1("Error:Memory - ooQ931SetCauseIE - causeIE\n"); return OO_FAILED; } pmsg->causeIE->discriminator = Q931CauseIE; pmsg->causeIE->length = 2; pmsg->causeIE->data[0] = (0x80 | ((coding & 0x03) <<5) | (location & 0x0F)); pmsg->causeIE->data[1] = (0x80 | cause); return OO_OK; } /* Build a Facility message and tunnel H.245 message through it */ int ooSendAsTunneledMessage(OOH323CallData *call, ASN1OCTET* msgbuf, int h245Len, int h245MsgType, int associatedChan) { Q931Message *pQ931Msg = NULL; H225H323_UU_PDU *pH323UUPDU = NULL; H225H323_UU_PDU_h245Control *pH245Control = NULL; ASN1DynOctStr * elem; int ret =0; H225Facility_UUIE *facility=NULL; /* OOCTXT *pctxt = &gH323ep.msgctxt; */ OOCTXT *pctxt = call->msgctxt; OOTRACEDBGA4("Building Facility message for tunneling %s (%s, %s)\n", ooGetMsgTypeText(h245MsgType), call->callType, call->callToken); ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg); if(ret != OO_OK) { OOTRACEERR3("ERROR: In allocating memory for facility message " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } pQ931Msg->callReference = call->callReference; pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt, sizeof(H225H323_UserInformation)); if(!pQ931Msg->userInfo) { OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - userInfo" " (%s, %s)\n", call->callType, call->callToken); /* memReset(&gH323ep.msgctxt);*/ memReset(call->msgctxt); return OO_FAILED; } memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation)); pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = OO_TESTFLAG (call->flags, OO_M_TUNNELING); pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = T_H225H323_UU_PDU_h323_message_body_facility; facility = (H225Facility_UUIE*) memAllocZ (pctxt, sizeof(H225Facility_UUIE)); if(!facility) { OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - facility (%s, %s)" "\n", call->callType, call->callToken); /* memReset(&gH323ep.msgctxt); */ memReset(call->msgctxt); return OO_FAILED; } pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility; /* Populate Facility UUIE */ facility->protocolIdentifier = gProtocolID; facility->m.callIdentifierPresent = 1; facility->callIdentifier.guid.numocts = call->callIdentifier.guid.numocts; memcpy(facility->callIdentifier.guid.data, call->callIdentifier.guid.data, call->callIdentifier.guid.numocts); facility->reason.t = T_H225FacilityReason_transportedInformation; pH323UUPDU = (H225H323_UU_PDU*) &pQ931Msg->userInfo->h323_uu_pdu; pH323UUPDU->m.h245TunnelingPresent = TRUE; pH323UUPDU->m.h245ControlPresent = TRUE; pH323UUPDU->h245Tunneling = TRUE; pH245Control = (H225H323_UU_PDU_h245Control*) &pH323UUPDU->h245Control; elem = (ASN1DynOctStr*) memAlloc(pctxt, sizeof(ASN1DynOctStr)); if(!elem) { OOTRACEERR3("ERROR:Memory - ooSendAsTunneledMessage - elem " "(%s, %s)\n", call->callType, call->callToken); return OO_FAILED; } elem->data = msgbuf; elem->numocts = h245Len; pH245Control->elem = elem; pH245Control->n = 1; pQ931Msg->tunneledMsgType = h245MsgType; pQ931Msg->logicalChannelNo = associatedChan; ret = ooSendH225Msg(call, pQ931Msg); if(ret != OO_OK) { OOTRACEERR3("Error:Failed to enqueue Facility(tunneling) message to " "outbound queue.(%s, %s)\n", call->callType, call->callToken); } /* Can't do memReset here because if we are sending H.245 message as a response to received tunneled h.245 message, we can't reset unless the \ main received H225 message processing is finished. Rule. No reset when tunneling */ /* memFreePtr(&gH323ep.msgctxt, pQ931Msg); */ memFreePtr(call->msgctxt, pQ931Msg); return ret; } int ooCallEstbTimerExpired(void *data) { ooTimerCallback *cbData = (ooTimerCallback*) data; OOH323CallData *call = cbData->call; OOTRACEINFO3("Call Establishment timer expired. (%s, %s)\n", call->callType, call->callToken); memFreePtr(call->pctxt, cbData); if(call->callState < OO_CALL_CLEAR){ call->callState = OO_CALL_CLEAR; call->callEndReason = OO_REASON_LOCAL_CLEARED; } return OO_OK; } int ooQ931GetCauseAndReasonCodeFromCallClearReason (OOCallClearReason clearReason, enum Q931CauseValues *cause, unsigned *reasonCode) { switch(clearReason) { case OO_REASON_INVALIDMESSAGE: case OO_REASON_TRANSPORTFAILURE: *reasonCode = T_H225ReleaseCompleteReason_undefinedReason; *cause = Q931ProtocolErrorUnspecified; break; case OO_REASON_NOBW: *reasonCode = T_H225ReleaseCompleteReason_noBandwidth; *cause = Q931ErrorInCauseIE; break; case OO_REASON_GK_NOCALLEDUSER: *reasonCode = T_H225ReleaseCompleteReason_calledPartyNotRegistered; *cause = Q931SubscriberAbsent; break; case OO_REASON_GK_NOCALLERUSER: *reasonCode = T_H225ReleaseCompleteReason_callerNotRegistered; *cause = Q931SubscriberAbsent; break; case OO_REASON_GK_UNREACHABLE: *reasonCode = T_H225ReleaseCompleteReason_unreachableGatekeeper; *cause = Q931TemporaryFailure; break; case OO_REASON_GK_NORESOURCES: case OO_REASON_GK_CLEARED: *reasonCode = T_H225ReleaseCompleteReason_gatekeeperResources; *cause = Q931Congestion; break; case OO_REASON_NOCOMMON_CAPABILITIES: *reasonCode = T_H225ReleaseCompleteReason_undefinedReason; *cause = Q931IncompatibleDestination; break; case OO_REASON_LOCAL_FWDED: case OO_REASON_REMOTE_FWDED: *reasonCode = T_H225ReleaseCompleteReason_facilityCallDeflection; *cause = Q931Redirection; break; case OO_REASON_REMOTE_CLEARED: case OO_REASON_LOCAL_CLEARED: *reasonCode = T_H225ReleaseCompleteReason_undefinedReason; *cause = Q931NormalCallClearing; break; case OO_REASON_REMOTE_BUSY: case OO_REASON_LOCAL_BUSY: *reasonCode = T_H225ReleaseCompleteReason_inConf; *cause = Q931UserBusy; break; case OO_REASON_REMOTE_NOANSWER: case OO_REASON_LOCAL_NOTANSWERED: *reasonCode = T_H225ReleaseCompleteReason_undefinedReason; *cause = Q931NoAnswer; break; case OO_REASON_REMOTE_REJECTED: case OO_REASON_LOCAL_REJECTED: *reasonCode = T_H225ReleaseCompleteReason_destinationRejection; *cause = Q931CallRejected; break; case OO_REASON_REMOTE_CONGESTED: case OO_REASON_LOCAL_CONGESTED: *reasonCode = T_H225ReleaseCompleteReason_noBandwidth; *cause = Q931Congestion; break; case OO_REASON_NOROUTE: *reasonCode = T_H225ReleaseCompleteReason_unreachableDestination; *cause = Q931NoRouteToDestination; break; case OO_REASON_NOUSER: *reasonCode = T_H225ReleaseCompleteReason_undefinedReason; *cause = Q931SubscriberAbsent; break; case OO_REASON_UNKNOWN: default: *reasonCode = T_H225ReleaseCompleteReason_undefinedReason; *cause = Q931NormalUnspecified; } return OO_OK; } enum OOCallClearReason ooGetCallClearReasonFromCauseAndReasonCode (enum Q931CauseValues cause, unsigned reasonCode) { switch(cause) { case Q931NormalCallClearing: return OO_REASON_REMOTE_CLEARED; case Q931UserBusy: return OO_REASON_REMOTE_BUSY; case Q931NoResponse: case Q931NoAnswer: return OO_REASON_REMOTE_NOANSWER; case Q931CallRejected: return OO_REASON_REMOTE_REJECTED; case Q931Redirection: return OO_REASON_REMOTE_FWDED; case Q931NetworkOutOfOrder: case Q931TemporaryFailure: return OO_REASON_TRANSPORTFAILURE; case Q931NoCircuitChannelAvailable: case Q931Congestion: case Q931RequestedCircuitUnAvailable: case Q931ResourcesUnavailable: return OO_REASON_REMOTE_CONGESTED; case Q931NoRouteToDestination: case Q931NoRouteToNetwork: return OO_REASON_NOROUTE; case Q931NumberChanged: case Q931UnallocatedNumber: case Q931SubscriberAbsent: return OO_REASON_NOUSER; case Q931ChannelUnacceptable: case Q931DestinationOutOfOrder: case Q931InvalidNumberFormat: case Q931NormalUnspecified: case Q931StatusEnquiryResponse: case Q931IncompatibleDestination: case Q931ProtocolErrorUnspecified: case Q931RecoveryOnTimerExpiry: case Q931InvalidCallReference: default: switch(reasonCode) { case T_H225ReleaseCompleteReason_noBandwidth: return OO_REASON_NOBW; case T_H225ReleaseCompleteReason_gatekeeperResources: return OO_REASON_GK_NORESOURCES; case T_H225ReleaseCompleteReason_unreachableDestination: return OO_REASON_NOROUTE; case T_H225ReleaseCompleteReason_destinationRejection: return OO_REASON_REMOTE_REJECTED; case T_H225ReleaseCompleteReason_inConf: return OO_REASON_REMOTE_BUSY; case T_H225ReleaseCompleteReason_facilityCallDeflection: return OO_REASON_REMOTE_FWDED; case T_H225ReleaseCompleteReason_calledPartyNotRegistered: return OO_REASON_GK_NOCALLEDUSER; case T_H225ReleaseCompleteReason_callerNotRegistered: return OO_REASON_GK_NOCALLERUSER; case T_H225ReleaseCompleteReason_gatewayResources: return OO_REASON_GK_NORESOURCES; case T_H225ReleaseCompleteReason_unreachableGatekeeper: return OO_REASON_GK_UNREACHABLE; case T_H225ReleaseCompleteReason_invalidRevision: case T_H225ReleaseCompleteReason_noPermission: case T_H225ReleaseCompleteReason_badFormatAddress: case T_H225ReleaseCompleteReason_adaptiveBusy: case T_H225ReleaseCompleteReason_undefinedReason: case T_H225ReleaseCompleteReason_securityDenied: case T_H225ReleaseCompleteReason_newConnectionNeeded: case T_H225ReleaseCompleteReason_nonStandardReason: case T_H225ReleaseCompleteReason_replaceWithConferenceInvite: case T_H225ReleaseCompleteReason_genericDataReason: case T_H225ReleaseCompleteReason_neededFeatureNotSupported: case T_H225ReleaseCompleteReason_tunnelledSignallingRejected: case T_H225ReleaseCompleteReason_invalidCID: case T_H225ReleaseCompleteReason_securityError: case T_H225ReleaseCompleteReason_hopCountExceeded: case T_H225ReleaseCompleteReason_extElem1: default: return OO_REASON_UNKNOWN; } } return OO_REASON_UNKNOWN; } /** This function is used to parse destination string passed to ooH323MakeCall and ooH323ForwardCall. If the string contains ip address and port, it is returned in the parsedIP buffer and if it contains alias, it is added to aliasList */ int ooParseDestination (struct OOH323CallData *call, char *dest, char* parsedIP, unsigned len, ooAliases** aliasList) { int iEk=-1, iDon=-1, iTeen=-1, iChaar=-1, iPort = -1, i; ooAliases * psNewAlias = NULL; char *cAt = NULL, *host=NULL; char tmp[256], buf[30]; char *alias=NULL; OOCTXT *pctxt = call->pctxt; struct ast_sockaddr tmpaddr; parsedIP[0] = '\0'; OOTRACEINFO2("Parsing destination %s\n", dest); /* Test for an IP address:Note that only supports dotted IPv4. IPv6 won't pass the test and so will numeric IP representation*/ sscanf(dest, "%d.%d.%d.%d:%d", &iEk, &iDon, &iTeen, &iChaar, &iPort); if((iEk > 0 && iEk <= 255) && (iDon >= 0 && iDon <= 255) && (iTeen >=0 && iTeen <= 255) && (iChaar >= 0 && iChaar <= 255) && (!strchr(dest, ':') || iPort != -1)) { if(!strchr(dest, ':')) iPort = 1720; /*Default h.323 port */ sprintf(buf, "%d.%d.%d.%d:%d", iEk, iDon, iTeen, iChaar, iPort); if(strlen(buf)+1>len) { OOTRACEERR1("Error:Insufficient buffer space for parsed ip - " "ooParseDestination\n"); return OO_FAILED; } strcpy(parsedIP, buf); return OO_OK; } /* parse direct IP dest */ if ((strchr(dest, ':') || strchr(dest,'[') || strchr(dest,'.')) && !ast_parse_arg(dest, PARSE_ADDR, &tmpaddr)) { if(strlen(dest)+7>len) { OOTRACEERR1("Error:Insufficient buffer space for parsed ip - " "ooParseDestination\n"); return OO_FAILED; } strcpy(parsedIP, ast_sockaddr_stringify_addr(&tmpaddr)); strcat(parsedIP, ":"); strcat(parsedIP, ast_sockaddr_stringify_port(&tmpaddr)); return OO_OK; } /* alias@host */ strncpy(tmp, dest, sizeof(tmp)-1); tmp[sizeof(tmp)-1]='\0'; if((host=strchr(tmp, '@')) != NULL) { *host = '\0'; host++; sscanf(host, "%d.%d.%d.%d:%d", &iEk, &iDon, &iTeen, &iChaar, &iPort); if((iEk > 0 && iEk <= 255) && (iDon >= 0 && iDon <= 255) && (iTeen >=0 && iTeen <= 255) && (iChaar >= 0 && iChaar <= 255) && (!strchr(host, ':') || iPort != -1)) { if(!strchr(dest, ':')) iPort = 1720; /*Default h.323 port */ sprintf(buf, "%d.%d.%d.%d:%d", iEk, iDon, iTeen, iChaar, iPort); if(strlen(buf)+1>len) { OOTRACEERR1("Error:Insufficient buffer space for parsed ip - " "ooParseDestination\n"); return OO_FAILED; } strncpy(parsedIP, buf, len-1); parsedIP[len-1]='\0'; alias = tmp; } } if(!alias) { alias = dest; } /* url test */ if(alias == strstr(alias, "http://")) { psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); if(!psNewAlias) { OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); return OO_FAILED; } psNewAlias->type = T_H225AliasAddress_url_ID; psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); if(!psNewAlias->value) { OOTRACEERR1("Error:Memory - ooParseDestination - " "psNewAlias->value\n"); memFreePtr(pctxt, psNewAlias); return OO_FAILED; } strcpy(psNewAlias->value, alias); psNewAlias->next = *aliasList; *aliasList = psNewAlias; OOTRACEINFO2("Destination parsed as url %s\n", psNewAlias->value); return OO_OK; } /* E-mail ID test */ if((cAt = strchr(alias, '@')) && alias != strchr(alias, '@')) { if(strchr(cAt, '.')) { psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); if(!psNewAlias) { OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); return OO_FAILED; } psNewAlias->type = T_H225AliasAddress_email_ID; psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); if(!psNewAlias->value) { OOTRACEERR1("Error:Memory - ooParseDestination - " "psNewAlias->value\n"); memFreePtr(pctxt, psNewAlias); return OO_FAILED; } strcpy(psNewAlias->value, alias); psNewAlias->next = *aliasList; *aliasList = psNewAlias; OOTRACEINFO2("Destination is parsed as email %s\n",psNewAlias->value); return OO_OK; } } /* e-164 */ /* strspn(dest, "1234567890*#,") == strlen(dest)*/ /* Dialed digits test*/ for(i=0; *(alias+i) != '\0'; i++) { if(!isdigit(alias[i]) && alias[i] != '#' && alias[i] != '*' && alias[i] != ',') break; } if(*(alias+i) == '\0') { psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); if(!psNewAlias) { OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); return OO_FAILED; } /* memset(psNewAlias, 0, sizeof(ooAliases));*/ psNewAlias->type = T_H225AliasAddress_dialedDigits; psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); if(!psNewAlias->value) { OOTRACEERR1("Error:Memroy - ooParseDestination - " "psNewAlias->value\n"); memFreePtr(pctxt, psNewAlias); return OO_FAILED; } strcpy(psNewAlias->value, alias); psNewAlias->next = *aliasList; *aliasList = psNewAlias; OOTRACEINFO2("Destination is parsed as dialed digits %s\n", psNewAlias->value); /* Also set called party number */ if(!call->calledPartyNumber) { if(ooCallSetCalledPartyNumber(call, alias) != OO_OK) { OOTRACEWARN3("Warning:Failed to set calling party number." "(%s, %s)\n", call->callType, call->callToken); } } return OO_OK; } /* Evrything else is an h323-id for now */ psNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); if(!psNewAlias) { OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias\n"); return OO_FAILED; } psNewAlias->type = T_H225AliasAddress_h323_ID; psNewAlias->value = (char*) memAlloc(pctxt, strlen(alias)+1); if(!psNewAlias->value) { OOTRACEERR1("Error:Memory - ooParseDestination - psNewAlias->value\n"); memFreePtr(pctxt, psNewAlias); return OO_FAILED; } strcpy(psNewAlias->value, alias); psNewAlias->next = *aliasList; *aliasList = psNewAlias; OOTRACEINFO2("Destination for new call is parsed as h323-id %s \n", psNewAlias->value); return OO_OK; } const char* ooGetMsgTypeText (int msgType) { static const char *msgTypeText[]={ "OOQ931MSG", "OOH245MSG", "OOSetup", "OOCallProceeding", "OOAlert", "OOConnect", "OOReleaseComplete", "OOFacility", "OOInformation", "OOMasterSlaveDetermination", "OOMasterSlaveAck", "OOMasterSlaveReject", "OOMasterSlaveRelease", "OOTerminalCapabilitySet", "OOTerminalCapabilitySetAck", "OOTerminalCapabilitySetReject", "OOTerminalCapabilitySetRelease", "OOOpenLogicalChannel", "OOOpenLogicalChannelAck", "OOOpenLogicalChannelReject", "OOOpenLogicalChannelRelease", "OOOpenLogicalChannelConfirm", "OOCloseLogicalChannel", "OOCloseLogicalChannelAck", "OORequestChannelClose", "OORequestChannelCloseAck", "OORequestChannelCloseReject", "OORequestChannelCloseRelease", "OOEndSessionCommand", "OOUserInputIndication", "OORequestModeAck", "OORequestModeReject", "OORequestMode", "OORequestDelayResponse", "OORequestDelayRequest" }; int idx = msgType - OO_MSGTYPE_MIN; return ooUtilsGetText (idx, msgTypeText, OONUMBEROF(msgTypeText)); } const char* ooGetQ931CauseValueText(int val) { switch(val) { case Q931UnallocatedNumber: return "Q931UnallocatedNumber"; case Q931NoRouteToNetwork: return "Q931NoRouteToNetwork"; case Q931NoRouteToDestination: return "Q931NoRouteToDestination"; case Q931ChannelUnacceptable: return "Q931ChannelUnacceptable"; case Q931NormalCallClearing: return "Q931NormalCallClearing"; case Q931UserBusy: return "Q931UserBusy"; case Q931NoResponse: return "Q931NoResponse"; case Q931NoAnswer: return "Q931NoAnswer"; case Q931SubscriberAbsent: return "Q931SubscriberAbsent"; case Q931CallRejected: return "Q931CallRejected"; case Q931NumberChanged: return "Q931NumberChanged"; case Q931Redirection: return "Q931Redirection"; case Q931DestinationOutOfOrder: return "Q931DestinationOutOfOrder"; case Q931InvalidNumberFormat: return "Q931InvalidNumberFormat"; case Q931NormalUnspecified: return "Q931NormalUnspecified"; case Q931StatusEnquiryResponse: return "Q931StatusEnquiryResponse"; case Q931NoCircuitChannelAvailable: return "Q931NoCircuitChannelAvailable"; case Q931NetworkOutOfOrder: return "Q931NetworkOutOfOrder"; case Q931TemporaryFailure: return "Q931TemporaryFailure"; case Q931Congestion: return "Q931Congestion"; case Q931RequestedCircuitUnAvailable: return "Q931RequestedCircuitUnavailable"; case Q931ResourcesUnavailable: return "Q931ResourcesUnavailable"; case Q931IncompatibleDestination: return "Q931IncompatibleDestination"; case Q931ProtocolErrorUnspecified: return "Q931ProtocolErrorUnspecified"; case Q931RecoveryOnTimerExpiry: return "Q931RecoveryOnTimerExpiry"; case Q931InvalidCallReference: return "Q931InvaliedCallReference"; default: return "Unsupported Cause Type"; } return "Unsupported Cause Type"; } asterisk-11.7.0/addons/ooh323c/src/ooLogChan.h0000644000175000007640000001531111775134255020621 0ustar sharkyjerryweb/* * 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, OO_LOGICALCHAN_PROPOSEDFS, OO_LOGICALCHAN_CLOSEPENDING } 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[2+8*4+7]; int remoteMediaPort; int remoteMediaControlPort; int localRtpPort; int localRtcpPort; char localIP[2+8*4+7]; 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); EXTERN OOLogicalChannel* ooGetTransmitLogicalChannel(struct OOH323CallData *call); EXTERN OOLogicalChannel* ooGetReceiveLogicalChannel(struct OOH323CallData *call); /** * @} */ #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/ooLogChan.c0000644000175000007640000003554411775134255020626 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #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->lMediaRedirPort ? pMediaInfo->lMediaRedirPort : pMediaInfo->lMediaPort; /* check MediaRedirPort here because RedirCPort is ReditPort + 1 and can't be 0 ;) */ pNewChannel->localRtcpPort = pMediaInfo->lMediaRedirPort ? pMediaInfo->lMediaRedirCPort : 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") || !strcmp(pMediaInfo->lMediaIP, "::")) strcpy(pNewChannel->localIP, call->localIP); else strcpy(pNewChannel->localIP, pMediaInfo->lMediaIP); OOTRACEDBGC5("Configured media info (%s, %s) %s:%d\n", call->callType, call->callToken, pNewChannel->localIP, pNewChannel->localRtcpPort); } 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) { OOTRACEWARN3("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 || pChannel->sessionID == 0) { 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; } /* function is to get channel with particular direction */ OOLogicalChannel* ooGetTransmitLogicalChannel (OOH323CallData *call) { OOLogicalChannel * pChannel = NULL; pChannel = call->logicalChans; while(pChannel) { OOTRACEINFO6("Listing logical channel %d cap %d state %d for (%s, %s)\n", pChannel->channelNo, pChannel->chanCap->cap, pChannel->state, call->callType, call->callToken); if(!strcmp(pChannel->dir, "transmit") && pChannel->state != OO_LOGICALCHAN_IDLE && pChannel->state != OO_LOGICALCHAN_PROPOSEDFS) return pChannel; else pChannel = pChannel->next; } return NULL; } OOLogicalChannel* ooGetReceiveLogicalChannel (OOH323CallData *call) { OOLogicalChannel * pChannel = NULL; pChannel = call->logicalChans; while (pChannel) { OOTRACEINFO6("Listing logical channel %d cap %d state %d for (%s, %s)\n", pChannel->channelNo, pChannel->chanCap->cap, pChannel->state, call->callType, call->callToken); if (!strcmp(pChannel->dir, "receive") && pChannel->state != OO_LOGICALCHAN_IDLE && pChannel->state != OO_LOGICALCHAN_PROPOSEDFS) { 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); do { 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.*/ } while ((pLogicalChannel = ooFindLogicalChannelByLogicalChannelNo(call, channelNo))); 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; } asterisk-11.7.0/addons/ooh323c/src/oohdr.h0000644000175000007640000000115011222440006020034 0ustar sharkyjerryweb/* * 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. * *****************************************************************************/ asterisk-11.7.0/addons/ooh323c/src/printHandler.c0000644000175000007640000001516611655040762021401 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include /* #ifdef HAVE_MALLOC_H #include #endif */ #include "printHandler.h" #include "ootypes.h" #include "rtctype.h" #include "ootrace.h" EventHandler printHandler; AST_MUTEX_DEFINE_STATIC(printlock); 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 printCharStr32BitValue (ASN1UINT nchars, ASN132BITCHAR* data); void ooPrintOIDValue (ASN1OBJID* pOID); void printRealValue (double value); 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; ast_mutex_lock(&printlock); OOTRACEDBGB2("%s = {\n", pVarName); gIndentSpaces += 3; } void finishPrint() { OOTRACEDBGB1 ("}\n"); gIndentSpaces -= 3; if (gIndentSpaces != 0) { OOTRACEDBGB1 ("ERROR: unbalanced structure\n"); } gIndentSpaces = 0; ast_mutex_unlock(&printlock); } 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; } asterisk-11.7.0/addons/ooh323c/src/ooGkClient.c0000644000175000007640000031331112011223623020760 0ustar sharkyjerryweb/* * 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.c * This file contains functions to support RAS protocol. * */ #include "asterisk.h" #include "asterisk/lock.h" #include "asterisk/netsock2.h" #include "ooGkClient.h" #include "ootypes.h" #include "ootrace.h" #include "ooports.h" #include "ooasn1.h" #include "oochannels.h" #include "printHandler.h" #include "ooCalls.h" #include "H323-MESSAGES.h" #include "ooDateTime.h" #include "ooq931.h" #include "ooh323.h" #include "ooh323ep.h" #include "ooTimer.h" #include "ooSocket.h" #include "ooUtils.h" /** Global endpoint structure */ extern OOH323EndPoint gH323ep; static ASN1OBJID gProtocolID = { 6, { 0, 0, 8, 2250, 0, 4 } }; int ooGkClientInit(enum RasGatekeeperMode eGkMode, char *szGkAddr, int iGkPort ) { ooGkClient *pGkClient=NULL; OOInterface *cur=NULL; pGkClient = (ooGkClient*) memAlloc(&gH323ep.ctxt, sizeof(ooGkClient)); if(!pGkClient) { OOTRACEERR1("Error: Failed to allocate memory to Gatekeeper Client.\n"); return OO_FAILED; } memset(pGkClient, 0, sizeof(ooGkClient)); ast_mutex_init(&pGkClient->Lock); gH323ep.gkClient = pGkClient; initContext(&(pGkClient->ctxt)); initContext(&(pGkClient->msgCtxt)); pGkClient->rrqRetries = 0; pGkClient->grqRetries = 0; strcpy(pGkClient->localRASIP, gH323ep.signallingIP); #ifndef _WIN32 if(!strcmp(pGkClient->localRASIP, "0.0.0.0") || !strcmp(pGkClient->localRASIP, "127.0.0.1")) { if(!gH323ep.ifList) { if(ooSocketGetInterfaceList(&gH323ep.ctxt, &gH323ep.ifList)!= ASN_OK) { OOTRACEERR1("Error:Failed to retrieve interface addresses\n"); return OO_FAILED; } } for(cur = gH323ep.ifList; cur; cur = cur->next) { if(!strcmp(cur->name, "lo") || !strcmp(cur->addr, "127.0.0.1")) continue; break; } if(cur) { OOTRACEINFO2("Using local RAS Ip address %s\n", cur->addr); strcpy(pGkClient->localRASIP, cur->addr); } else{ OOTRACEERR1("Error:Failed to assign a local RAS IP address\n"); return OO_FAILED; } } #endif if(OO_OK != ooGkClientSetGkMode(pGkClient, eGkMode, szGkAddr, iGkPort)) { OOTRACEERR1("Error:Failed to set Gk mode\n"); memReset(&gH323ep.ctxt); return OO_FAILED; } /* Create default parameter set */ pGkClient->grqTimeout = DEFAULT_GRQ_TIMEOUT; pGkClient->rrqTimeout = DEFAULT_RRQ_TIMEOUT; pGkClient->regTimeout = DEFAULT_REG_TTL; pGkClient->arqTimeout = DEFAULT_ARQ_TIMEOUT; pGkClient->drqTimeout = DEFAULT_DRQ_TIMEOUT; dListInit(&pGkClient->callsPendingList); dListInit(&pGkClient->callsAdmittedList); dListInit(&pGkClient->timerList); pGkClient->state = GkClientIdle; return OO_OK; } int ooGkClientSetCallbacks (ooGkClient *pGkClient, OOGKCLIENTCALLBACKS callbacks) { pGkClient->callbacks.onReceivedRegistrationConfirm = callbacks.onReceivedRegistrationConfirm; pGkClient->callbacks.onReceivedUnregistrationConfirm = callbacks.onReceivedUnregistrationConfirm; pGkClient->callbacks.onReceivedUnregistrationRequest = callbacks.onReceivedUnregistrationRequest; return OO_OK; } int ooGkClientReInit(ooGkClient *pGkClient) { ooGkClientCloseChannel(pGkClient); pGkClient->gkRasIP[0]='\0'; pGkClient->gkCallSignallingIP[0]='\0'; pGkClient->gkRasPort = 0; pGkClient->gkCallSignallingPort = 0; pGkClient->rrqRetries = 0; pGkClient->grqRetries = 0; pGkClient->requestSeqNum = 0; dListFreeAll(&pGkClient->ctxt, &pGkClient->callsPendingList); dListFreeAll(&pGkClient->ctxt, &pGkClient->callsAdmittedList); dListFreeAll(&pGkClient->ctxt, &pGkClient->timerList); pGkClient->state = GkClientIdle; return OO_OK; } void ooGkClientPrintConfig(ooGkClient *pGkClient) { OOTRACEINFO1("Gatekeeper Client Configuration:\n"); if(pGkClient->gkMode == RasUseSpecificGatekeeper) { OOTRACEINFO1("\tGatekeeper mode - UseSpecificGatekeeper\n"); OOTRACEINFO3("\tGatekeeper To Use - %s:%d\n", pGkClient->gkRasIP, pGkClient->gkRasPort); } else if(pGkClient->gkMode == RasDiscoverGatekeeper) { OOTRACEINFO1("\tGatekeeper mode - RasDiscoverGatekeeper\n"); } else { OOTRACEERR1("Invalid GatekeeperMode\n"); } } int ooGkClientDestroy(void) { ooGkClient *pGkClient = gH323ep.gkClient; if(gH323ep.gkClient) { ast_mutex_lock(&pGkClient->Lock); gH323ep.gkClient = NULL; if(pGkClient->state == GkClientRegistered) { OOTRACEINFO1("Unregistering from Gatekeeper\n"); if(ooGkClientSendURQ(pGkClient, NULL)!=OO_OK) OOTRACEERR1("Error:Failed to send URQ to gatekeeper\n"); } OOTRACEINFO1("Destroying Gatekeeper Client\n"); ooGkClientCloseChannel(pGkClient); freeContext(&pGkClient->msgCtxt); freeContext(&pGkClient->ctxt); ast_mutex_unlock(&pGkClient->Lock); ast_mutex_destroy(&pGkClient->Lock); memFreePtr(&gH323ep.ctxt, pGkClient); } return OO_OK; } int ooGkClientStart(ooGkClient *pGkClient) { int iRet=0; iRet = ooGkClientCreateChannel(pGkClient); if(iRet != OO_OK) { OOTRACEERR1("Error: GkClient Channel Creation failed\n"); return OO_FAILED; } ast_mutex_lock(&pGkClient->Lock); pGkClient->discoveryComplete = FALSE; iRet = ooGkClientSendGRQ(pGkClient); if(iRet != OO_OK) { OOTRACEERR1("Error:Failed to send GRQ message\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } int ooGkClientSetGkMode(ooGkClient *pGkClient, enum RasGatekeeperMode eGkMode, char *szGkAddr, int iGkPort ) { pGkClient->gkMode = eGkMode; if(eGkMode == RasUseSpecificGatekeeper) { OOTRACEINFO1("Gatekeeper Mode - RasUseSpecificGatekeeper\n"); if(szGkAddr) { if(strlen(szGkAddr)>MAX_IP_LEN) { OOTRACEERR2("Error:Invalid IP address specified - %s\n", szGkAddr); return OO_FAILED; } strcpy(pGkClient->gkRasIP, szGkAddr); } if(iGkPort) pGkClient->gkRasPort = iGkPort; else pGkClient->gkRasPort = DEFAULT_GKPORT; OOTRACEINFO3("Gatekeeper IP:port set to - %s:%d\n", szGkAddr, pGkClient->gkRasPort); } else if(eGkMode == RasDiscoverGatekeeper) { OOTRACEINFO1("Gatekeeper Mode - RasDiscoverGatekeeper\n"); } else if(eGkMode == RasNoGatekeeper) { OOTRACEINFO1("Gatekeeper Mode - RasNoGatekeeper\n"); } return OO_OK; } /** * Create the RAS channel (socket). * */ int ooGkClientCreateChannel(ooGkClient *pGkClient) { int ret=0; OOIPADDR ipaddrs; /* Create socket */ if((ret=ooSocketCreateUDP(&pGkClient->rasSocket, 4))!=ASN_OK) { OOTRACEERR1("Failed to create RAS socket\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } if(pGkClient->localRASPort) { inet_pton(AF_INET, pGkClient->localRASIP, &ipaddrs); if( (ret=ooSocketBind( pGkClient->rasSocket, ipaddrs, pGkClient->localRASPort))!=ASN_OK ) { OOTRACEERR1("ERROR:Failed to create RAS channel\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } } else { ret = ooBindPort (OOUDP, pGkClient->rasSocket, pGkClient->localRASIP); if(ret == OO_FAILED) { OOTRACEERR1("ERROR: Failed to bind port to RAS socket\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } pGkClient->localRASPort = ret; } /* Test Code NOTE- This doesn't work..:(( Have to fix this */ /* If multihomed, get ip from socket */ if(!strcmp(pGkClient->localRASIP, "0.0.0.0")) { OOTRACEDBGA1("Determining ip address for RAS channel " "multihomed mode. \n"); ret = ooSocketGetIpAndPort(pGkClient->rasSocket, pGkClient->localRASIP, 20, &pGkClient->localRASPort, NULL); if(ret != ASN_OK) { OOTRACEERR1("Error:Failed to retrieve local ip and port from " "socket for RAS channel(multihomed).\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } OOTRACEDBGA3("Using local ip %s and port %d for RAS channel" "(multihomedMode).\n", pGkClient->localRASIP, pGkClient->localRASPort); } /* End of Test code */ OOTRACEINFO1("H323 RAS channel creation - successful\n"); return OO_OK; } int ooGkClientCloseChannel(ooGkClient *pGkClient) { int ret; if(pGkClient->rasSocket != 0) { ret = ooSocketClose(pGkClient->rasSocket); if(ret != ASN_OK) { OOTRACEERR1("Error: failed to close RAS channel\n"); pGkClient->rasSocket = 0; return OO_FAILED; } pGkClient->rasSocket = 0; } OOTRACEINFO1("Closed RAS channel\n"); return OO_OK; } /** * Fill vendor data in RAS message structure. */ void ooGkClientFillVendor (ooGkClient *pGkClient, H225VendorIdentifier *pVendor ) { pVendor->vendor.t35CountryCode = gH323ep.t35CountryCode; pVendor->vendor.t35Extension = gH323ep.t35Extension; pVendor->vendor.manufacturerCode = gH323ep.manufacturerCode; pVendor->enterpriseNumber.numids=0; if(gH323ep.productID) { pVendor->m.productIdPresent = TRUE; pVendor->productId.numocts = ASN1MIN(strlen(gH323ep.productID), sizeof(pVendor->productId.data)); memcpy(pVendor->productId.data, gH323ep.productID, pVendor->productId.numocts); } if(gH323ep.versionID) { pVendor->m.versionIdPresent = 1; pVendor->versionId.numocts = ASN1MIN(strlen(gH323ep.versionID), sizeof(pVendor->versionId.data)); memcpy(pVendor->versionId.data, gH323ep.versionID, pVendor->versionId.numocts); } } int ooGkClientReceive(ooGkClient *pGkClient) { ASN1OCTET recvBuf[ASN_K_ENCBUFSIZ]; int recvLen; char remoteHost[32]; int iFromPort=0; OOCTXT *pctxt=NULL; H225RasMessage *pRasMsg=NULL; int iRet=OO_OK; ast_mutex_lock(&pGkClient->Lock); pctxt = &pGkClient->msgCtxt; recvLen = ooSocketRecvFrom(pGkClient->rasSocket, recvBuf, 2048, remoteHost, 32, &iFromPort); if(recvLen <0) { OOTRACEERR1("Error:Failed to receive RAS message\n"); ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } OOTRACEDBGA1("GkClient Received RAS Message\n"); /* Verify the gk */ if(pGkClient->discoveryComplete) { if((strncmp(pGkClient->gkRasIP, remoteHost,strlen(pGkClient->gkRasIP)))|| (pGkClient->gkRasPort!= iFromPort) ) { OOTRACEWARN3("WARN:Ignoring message received from unknown gatekeeper " "%s:%d\n", remoteHost, iFromPort); ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } } if(ASN_OK != setPERBuffer (pctxt, recvBuf, recvLen, TRUE ) ) { OOTRACEERR1("Error:Failed to set PER buffer for RAS message decoding\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); if(!pRasMsg) { OOTRACEERR1("Error: Failed to allocate memory for RAS message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } #ifndef _COMPACT initializePrintHandler(&printHandler, "Received RAS Message"); /* Add event handler to list */ setEventHandler (pctxt, &printHandler); #endif if(ASN_OK == asn1PD_H225RasMessage(pctxt, pRasMsg)) { #ifndef _COMPACT finishPrint(); removeEventHandler(pctxt); #endif iRet=ooGkClientHandleRASMessage( pGkClient, pRasMsg ); if(iRet != OO_OK) { OOTRACEERR1("Error: Failed to handle received RAS message\n"); pGkClient->state = GkClientFailed; } memReset(pctxt); } else{ OOTRACEERR1("ERROR:Failed to decode received RAS message- ignoring" "received message.\n"); #ifndef _COMPACT removeEventHandler(pctxt); #endif memReset(pctxt); ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } ast_mutex_unlock(&pGkClient->Lock); return iRet; } /** * Manage incoming RAS message. */ int ooGkClientHandleRASMessage(ooGkClient *pGkClient, H225RasMessage *pRasMsg) { int iRet = OO_OK; switch( pRasMsg->t) { case T_H225RasMessage_gatekeeperConfirm: OOTRACEINFO1("Gatekeeper Confirmed (GCF) message received.\n"); iRet = ooGkClientHandleGatekeeperConfirm(pGkClient, pRasMsg->u.gatekeeperConfirm); break; case T_H225RasMessage_gatekeeperReject: OOTRACEINFO1("Gatekeeper Reject (GRJ) message received\n"); iRet = ooGkClientHandleGatekeeperReject(pGkClient, pRasMsg->u.gatekeeperReject); break; case T_H225RasMessage_registrationConfirm: OOTRACEINFO1("Registration Confirm (RCF) message received\n"); iRet = ooGkClientHandleRegistrationConfirm(pGkClient, pRasMsg->u.registrationConfirm ); break; case T_H225RasMessage_registrationReject: OOTRACEINFO1("Registration Reject (RRJ) message received.\n"); iRet = ooGkClientHandleRegistrationReject(pGkClient, pRasMsg->u.registrationReject); break; case T_H225RasMessage_infoRequest: //ooRasSendIRR( psRasMsg->sMessage.u.infoRequest->requestSeqNum ); break; case T_H225RasMessage_admissionConfirm: OOTRACEINFO1("Admission Confirm (ACF) message received\n"); iRet = ooGkClientHandleAdmissionConfirm(pGkClient, pRasMsg->u.admissionConfirm); break; case T_H225RasMessage_unregistrationRequest: OOTRACEINFO1("UnRegistration Request (URQ) message received.\n"); iRet = ooGkClientHandleUnregistrationRequest(pGkClient, pRasMsg->u.unregistrationRequest); break; case T_H225RasMessage_unregistrationConfirm: OOTRACEINFO1("UnRegistration Confirm (UCF) message received.\n"); break; case T_H225RasMessage_unregistrationReject: OOTRACEINFO1("UnRegistration Reject (URJ) message received.\n"); break; case T_H225RasMessage_admissionReject: OOTRACEINFO1("Admission Reject (ARJ) message received.\n"); iRet = ooGkClientHandleAdmissionReject(pGkClient, pRasMsg->u.admissionReject); break; case T_H225RasMessage_disengageConfirm: iRet = ooGkClientHandleDisengageConfirm(pGkClient, pRasMsg->u.disengageConfirm); break; case T_H225RasMessage_disengageReject: case T_H225RasMessage_bandwidthConfirm: case T_H225RasMessage_bandwidthReject: case T_H225RasMessage_locationRequest: case T_H225RasMessage_locationConfirm: case T_H225RasMessage_locationReject: case T_H225RasMessage_infoRequestResponse: case T_H225RasMessage_nonStandardMessage: case T_H225RasMessage_unknownMessageResponse: case T_H225RasMessage_requestInProgress: case T_H225RasMessage_resourcesAvailableIndicate: case T_H225RasMessage_resourcesAvailableConfirm: case T_H225RasMessage_infoRequestAck: case T_H225RasMessage_infoRequestNak: case T_H225RasMessage_serviceControlIndication: case T_H225RasMessage_serviceControlResponse: case T_H225RasMessage_admissionConfirmSequence: default: /* Unhandled RAS message */ iRet= OO_OK; } return iRet; } #ifndef _COMPACT void ooGkClientPrintMessage (ooGkClient *pGkClient, ASN1OCTET *msg, ASN1UINT len) { OOCTXT ctxt; H225RasMessage rasMsg; int ret; initContext(&ctxt); setPERBuffer(&ctxt, msg, len, TRUE); initializePrintHandler(&printHandler, "Sending RAS Message"); setEventHandler(&ctxt, &printHandler); ret = asn1PD_H225RasMessage(&ctxt, &rasMsg); if(ret != ASN_OK) { OOTRACEERR1("Error: Failed to decode RAS message\n"); } finishPrint(); freeContext(&ctxt); } #endif /** * Encode and send RAS message. */ int ooGkClientSendMsg(ooGkClient *pGkClient, H225RasMessage *pRasMsg) { ASN1OCTET msgBuf[MAXMSGLEN]; ASN1OCTET *msgPtr=NULL; int iLen; OOCTXT *pctxt = &pGkClient->msgCtxt; setPERBuffer( pctxt, msgBuf, MAXMSGLEN, TRUE ); if ( ASN_OK == asn1PE_H225RasMessage(pctxt, pRasMsg) ) { OOTRACEDBGC1("Ras message encoding - successful\n"); } else { OOTRACEERR1("Error: RAS message encoding failed\n"); return OO_FAILED; } msgPtr = encodeGetMsgPtr( pctxt, &iLen ); /* If gatekeeper specified or have been discovered */ if(pGkClient->gkMode == RasUseSpecificGatekeeper || pGkClient->discoveryComplete) { if(ASN_OK != ooSocketSendTo( pGkClient->rasSocket, msgPtr, iLen, pGkClient->gkRasIP, pGkClient->gkRasPort)) { OOTRACEERR1("Error sending RAS message\n"); return OO_FAILED; } } else if(pGkClient->gkMode == RasDiscoverGatekeeper && !pGkClient->discoveryComplete) { if(ASN_OK != ooSocketSendTo(pGkClient->rasSocket, msgPtr, iLen, MULTICAST_GKADDRESS, MULTICAST_GKPORT)) { OOTRACEERR1("Error sending multicast RAS message\n" ); return OO_FAILED; } } else {/* should never go here */ OOTRACEERR1("Error: GkClient in invalid state.\n"); return OO_FAILED; } #ifndef _COMPACT ooGkClientPrintMessage(pGkClient, msgPtr, iLen); #endif return OO_OK; } int ooGkClientSendGRQ(ooGkClient *pGkClient) { int iRet; H225RasMessage *pRasMsg=NULL; H225GatekeeperRequest *pGkReq=NULL; H225TransportAddress_ipAddress *pRasAddress; OOCTXT *pctxt = &pGkClient->msgCtxt; ooGkClientTimerCb *cbData=NULL; ast_mutex_lock(&pGkClient->Lock); /* Allocate memory for RAS message */ pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); if(!pRasMsg) { OOTRACEERR1("Error: Memory allocation for GRQ RAS message failed\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pGkReq = (H225GatekeeperRequest*)memAlloc(pctxt, sizeof(H225GatekeeperRequest)); if(!pGkReq) { OOTRACEERR1("Error:Memory allocation for GRQ failed\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memset(pGkReq, 0, sizeof(H225GatekeeperRequest)); pRasMsg->t = T_H225RasMessage_gatekeeperRequest; pRasMsg->u.gatekeeperRequest = pGkReq; /* Populate message structure */ pGkReq->requestSeqNum = pGkClient->requestSeqNum++; if ( !pGkReq->requestSeqNum ) pGkReq->requestSeqNum = pGkClient->requestSeqNum++; pGkReq->protocolIdentifier = gProtocolID; pGkReq->m.nonStandardDataPresent=0; pGkReq->rasAddress.t=T_H225TransportAddress_ipAddress; /* IPv4 address */ pRasAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!pRasAddress) { OOTRACEERR1("Error: Memory allocation for Ras Address of GRQ message " "failed\n"); memReset(&pGkClient->msgCtxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } inet_pton(AF_INET, pGkClient->localRASIP, pRasAddress->ip.data); pRasAddress->ip.numocts = 4; pRasAddress->port = pGkClient->localRASPort; pGkReq->rasAddress.u.ipAddress = pRasAddress; /* Pose as gateway or terminal as per config */ if(gH323ep.isGateway) pGkReq->endpointType.m.gatewayPresent = TRUE; else pGkReq->endpointType.m.terminalPresent = TRUE; pGkReq->endpointType.m.nonStandardDataPresent=0; pGkReq->endpointType.m.vendorPresent=1; ooGkClientFillVendor(pGkClient, &pGkReq->endpointType.vendor); pGkReq->m.endpointAliasPresent=TRUE; if(OO_OK != ooPopulateAliasList(&pGkClient->msgCtxt, gH323ep.aliases, &pGkReq->endpointAlias, 0)) { OOTRACEERR1("Error Failed to fill alias information for GRQ message\n"); memReset(&pGkClient->msgCtxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error: Failed to send GRQ message\n"); memReset(&pGkClient->msgCtxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } OOTRACEINFO1("Sent GRQ message\n"); cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory to GRQ timer callback\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } cbData->timerType = OO_GRQ_TIMER; cbData->pGkClient = pGkClient; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientGRQTimerExpired, pGkClient->grqTimeout, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create GRQ timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } int ooGkClientHandleGatekeeperReject (ooGkClient *pGkClient, H225GatekeeperReject *pGatekeeperReject) { unsigned int x=0; DListNode *pNode = NULL; OOTimer *pTimer = NULL; if(pGkClient->gkMode == RasUseSpecificGatekeeper) { /* delete the corresponding GRQ timer */ for(x=0; xtimerList.count; x++) { pNode = dListFindByIndex(&pGkClient->timerList, x); pTimer = (OOTimer*)pNode->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_GRQ_TIMER) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted GRQ Timer.\n"); break; } } pGkClient->state = GkClientGkErr; switch(pGatekeeperReject->rejectReason.t) { case T_H225GatekeeperRejectReason_resourceUnavailable: OOTRACEERR1("Error: Gatekeeper Reject - Resource Unavailable\n"); break; case T_H225GatekeeperRejectReason_terminalExcluded: OOTRACEERR1("Error: Gatekeeper Reject - Terminal Excluded\n"); break; case T_H225GatekeeperRejectReason_invalidRevision: OOTRACEERR1("Error: Gatekeeper Reject - Invalid Revision\n"); break; case T_H225GatekeeperRejectReason_undefinedReason: OOTRACEERR1("Error: Gatekeeper Reject - Undefined Reason\n"); break; case T_H225GatekeeperRejectReason_securityDenial: OOTRACEERR1("Error: Gatekeeper Reject - Security Denial\n"); break; case T_H225GatekeeperRejectReason_genericDataReason: OOTRACEERR1("Error: Gatekeeper Reject - Generic Data Reason\n"); break; case T_H225GatekeeperRejectReason_neededFeatureNotSupported: OOTRACEERR1("Error: Gatekeeper Reject - Needed Feature Not " "Supported\n"); break; case T_H225GatekeeperRejectReason_securityError: OOTRACEERR1("Error:Gatekeeper Reject - Security Error\n"); break; default: OOTRACEERR1("Error: Gatekeeper Reject - Invalid reason\n"); } return OO_OK; } OOTRACEDBGB1("Gatekeeper Reject response received for multicast GRQ " "request\n"); return OO_OK; } int ooGkClientHandleGatekeeperConfirm (ooGkClient *pGkClient, H225GatekeeperConfirm *pGatekeeperConfirm) { int iRet=0; unsigned int x=0; DListNode *pNode = NULL; OOTimer *pTimer = NULL; H225TransportAddress_ipAddress *pRasAddress; if(pGkClient->discoveryComplete) { OOTRACEDBGB1("Ignoring GKConfirm as Gatekeeper has been discovered\n"); return OO_OK; } if(pGatekeeperConfirm->m.gatekeeperIdentifierPresent) { pGkClient->gkId.nchars = pGatekeeperConfirm->gatekeeperIdentifier.nchars; if (pGkClient->gkId.data) { memFreePtr(&pGkClient->ctxt, pGkClient->gkId.data); } pGkClient->gkId.data = (ASN116BITCHAR*)memAlloc(&pGkClient->ctxt, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); if(!pGkClient->gkId.data) { OOTRACEERR1("Error:Failed to allocate memory for GK ID data\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } memcpy(pGkClient->gkId.data, pGatekeeperConfirm->gatekeeperIdentifier.data, sizeof(ASN116BITCHAR)* pGkClient->gkId.nchars); } else{ OOTRACEINFO1("ERROR:No Gatekeeper ID present in received GKConfirmed " "message\n"); pGkClient->gkId.nchars = 0; } /* Extract Gatekeeper's RAS address */ if(pGatekeeperConfirm->rasAddress.t != T_H225TransportAddress_ipAddress) { OOTRACEERR1("ERROR:Unsupported RAS address type in received Gk Confirm" " message.\n"); pGkClient->state = GkClientGkErr; return OO_FAILED; } pRasAddress = pGatekeeperConfirm->rasAddress.u.ipAddress; sprintf(pGkClient->gkRasIP, "%d.%d.%d.%d", pRasAddress->ip.data[0], pRasAddress->ip.data[1], pRasAddress->ip.data[2], pRasAddress->ip.data[3]); pGkClient->gkRasPort = pRasAddress->port; pGkClient->discoveryComplete = TRUE; pGkClient->state = GkClientDiscovered; OOTRACEINFO1("Gatekeeper Confirmed\n"); /* Delete the corresponding GRQ timer */ for(x=0; xtimerList.count; x++) { pNode = dListFindByIndex(&pGkClient->timerList, x); pTimer = (OOTimer*)pNode->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_GRQ_TIMER) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted GRQ Timer.\n"); } } iRet = ooGkClientSendRRQ(pGkClient, FALSE); if(iRet != OO_OK) { OOTRACEERR1("Error:Failed to send initial RRQ\n"); return OO_FAILED; } return OO_OK; } /** * Send RRQ. */ int ooGkClientSendRRQ(ooGkClient *pGkClient, ASN1BOOL keepAlive) { int iRet; H225RasMessage *pRasMsg=NULL; H225RegistrationRequest *pRegReq=NULL; OOCTXT *pctxt=NULL; H225TransportAddress *pTransportAddress=NULL; H225TransportAddress_ipAddress *pIpAddress=NULL; ooGkClientTimerCb *cbData =NULL; H225SupportedProtocols *pProtocol = NULL; H225VoiceCaps *pVoiceCaps = NULL; ast_mutex_lock(&pGkClient->Lock); pctxt = &pGkClient->msgCtxt; pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); if(!pRasMsg) { OOTRACEERR1("Error: Memory allocation for RRQ RAS message failed\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pRegReq = (H225RegistrationRequest*)memAlloc(pctxt, sizeof(H225RegistrationRequest)); if(!pRegReq) { OOTRACEERR1("Error:Memory allocation for RRQ failed\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memset(pRegReq, 0, sizeof(H225RegistrationRequest)); pRasMsg->t = T_H225RasMessage_registrationRequest; pRasMsg->u.registrationRequest = pRegReq; pRegReq->protocolIdentifier = gProtocolID; pRegReq->m.nonStandardDataPresent=0; /* Populate CallSignal Address List*/ pTransportAddress = (H225TransportAddress*) memAlloc(pctxt, sizeof(H225TransportAddress)); pIpAddress = (H225TransportAddress_ipAddress*) memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!pTransportAddress || !pIpAddress) { OOTRACEERR1("Error:Failed to allocate memory for signalling address of " "RRQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pTransportAddress->t = T_H225TransportAddress_ipAddress; pTransportAddress->u.ipAddress = pIpAddress; inet_pton(AF_INET, pGkClient->localRASIP, pIpAddress->ip.data); pIpAddress->ip.numocts = 4; pIpAddress->port = gH323ep.listenPort; dListInit(&pRegReq->callSignalAddress); dListAppend(pctxt, &pRegReq->callSignalAddress, (void*)pTransportAddress); /* Populate RAS Address List*/ pTransportAddress = NULL; pIpAddress = NULL; pTransportAddress = (H225TransportAddress*) memAlloc(pctxt, sizeof(H225TransportAddress)); pIpAddress = (H225TransportAddress_ipAddress*) memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!pTransportAddress || !pIpAddress) { OOTRACEERR1("Error:Failed to allocate memory for RAS address of " "RRQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pTransportAddress->t = T_H225TransportAddress_ipAddress; pTransportAddress->u.ipAddress = pIpAddress; inet_pton(AF_INET, pGkClient->localRASIP, pIpAddress->ip.data); pIpAddress->ip.numocts = 4; pIpAddress->port = pGkClient->localRASPort; dListInit(&pRegReq->rasAddress); dListAppend(pctxt, &pRegReq->rasAddress, (void*)pTransportAddress); /* Pose as gateway or terminal as per config */ if(gH323ep.isGateway) pRegReq->terminalType.m.gatewayPresent = TRUE; else pRegReq->terminalType.m.terminalPresent = TRUE; pRegReq->terminalType.m.vendorPresent=TRUE; ooGkClientFillVendor(pGkClient, &pRegReq->terminalType.vendor ); if (gH323ep.isGateway) { pRegReq->terminalType.gateway.m.protocolPresent = TRUE; pProtocol = (H225SupportedProtocols*) memAlloc(pctxt, sizeof(H225SupportedProtocols)); pVoiceCaps = (H225VoiceCaps*) memAlloc(pctxt, sizeof(H225VoiceCaps)); if(!pProtocol || !pVoiceCaps) { OOTRACEERR1("Error:Failed to allocate memory for protocol info of " "RRQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memset(pVoiceCaps, 0, sizeof(H225VoiceCaps)); memset(pProtocol, 0, sizeof(H225SupportedProtocols)); pVoiceCaps->m.supportedPrefixesPresent = TRUE; ooPopulatePrefixList(pctxt, gH323ep.aliases, &pVoiceCaps->supportedPrefixes); pProtocol->t = T_H225SupportedProtocols_voice; pProtocol->u.voice = pVoiceCaps; dListInit(&pRegReq->terminalType.gateway.protocol); dListAppend(pctxt, &pRegReq->terminalType.gateway.protocol, (void*)pProtocol); } pRegReq->m.terminalAliasPresent=TRUE; if(OO_OK != ooPopulateAliasList(pctxt, gH323ep.aliases, &pRegReq->terminalAlias, 0)) { OOTRACEERR1("Error filling alias for RRQ\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } if (pGkClient->gkId.nchars) { pRegReq->m.gatekeeperIdentifierPresent=TRUE; pRegReq->gatekeeperIdentifier.nchars = pGkClient->gkId.nchars; pRegReq->gatekeeperIdentifier.data = (ASN116BITCHAR*)memAlloc (pctxt, pGkClient->gkId.nchars*sizeof(ASN116BITCHAR)); if(!pRegReq->gatekeeperIdentifier.data) { OOTRACEERR1("Error: Failed to allocate memory for GKIdentifier in RRQ " "message.\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy(pRegReq->gatekeeperIdentifier.data, pGkClient->gkId.data, pGkClient->gkId.nchars*sizeof(ASN116BITCHAR)); } ooGkClientFillVendor(pGkClient, &pRegReq->endpointVendor); pRegReq->m.willSupplyUUIEsPresent=TRUE; pRegReq->willSupplyUUIEs=FALSE; pRegReq->requestSeqNum = pGkClient->requestSeqNum++; if(!pRegReq->requestSeqNum) pRegReq->requestSeqNum = pGkClient->requestSeqNum++; pRegReq->discoveryComplete= pGkClient->discoveryComplete; pRegReq->m.keepAlivePresent=TRUE; pRegReq->keepAlive= keepAlive; /* * Cisco Gatekeeper re-registration fix. Thanks to Mike Tubby (mike@tubby.org) 28feb2007 * Without this patch initial registration works, but re-registration fails! * * For light-weight re-registration, keepalive is set true * GK needs rasAddress, keepAlive, endpointIdentifier, gatekeeperIdentifier, * tokens, and timeToLive * GK will ignore all other params if KeepAlive is set. * */ if(keepAlive) { /* KeepAlive, re-registration message... allocate storage for endpoint-identifier, and populate it from what the GK told us from the previous RCF. Only allocate on the first pass thru here */ pRegReq->endpointIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, pGkClient->endpointId.nchars*sizeof(ASN116BITCHAR)); if (pRegReq->endpointIdentifier.data) { pRegReq->endpointIdentifier.nchars = pGkClient->endpointId.nchars; pRegReq->m.endpointIdentifierPresent = TRUE; memcpy(pRegReq->endpointIdentifier.data, pGkClient->endpointId.data, pGkClient->endpointId.nchars*sizeof(ASN116BITCHAR)); OOTRACEINFO1("Sending RRQ for re-registration (with EndpointID)\n"); } else { OOTRACEERR1("Error: Failed to allocate memory for EndpointIdentifier in RRQ \n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } } pRegReq->m.timeToLivePresent = TRUE; pRegReq->timeToLive = pGkClient->regTimeout; iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error: Failed to send RRQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } OOTRACEINFO1("Sent RRQ message \n"); /* Start RRQ Timer */ cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory to RRQ timer callback\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } cbData->timerType = OO_RRQ_TIMER; cbData->pGkClient = pGkClient; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientRRQTimerExpired, pGkClient->rrqTimeout, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create GRQ timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } /** * Manage incoming RCF message. */ int ooGkClientHandleRegistrationConfirm (ooGkClient *pGkClient, H225RegistrationConfirm *pRegistrationConfirm) { int i=0; unsigned int x=0; OOTimer *pTimer = NULL; DListNode *pNode = NULL; H225TransportAddress *pCallSigAddr=NULL; ooGkClientTimerCb *cbData; ASN1UINT regTTL=0; /* Extract Endpoint Id */ if (pGkClient->endpointId.data) memFreePtr(&pGkClient->ctxt, pGkClient->endpointId.data); pGkClient->endpointId.nchars = pRegistrationConfirm->endpointIdentifier.nchars; pGkClient->endpointId.data = (ASN116BITCHAR*)memAlloc(&pGkClient->ctxt, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); if(!pGkClient->endpointId.data) { OOTRACEERR1("Error:Failed to allocate memory for endpoint Id.\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } memcpy(pGkClient->endpointId.data, pRegistrationConfirm->endpointIdentifier.data, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); /* Extract GK Identifier */ if(pRegistrationConfirm->m.gatekeeperIdentifierPresent && pGkClient->gkId.nchars == 0) { pGkClient->gkId.nchars = pRegistrationConfirm->gatekeeperIdentifier.nchars; pGkClient->gkId.data = (ASN116BITCHAR*)memAlloc(&pGkClient->ctxt, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); if(!pGkClient->gkId.data) { OOTRACEERR1("Error:Failed to allocate memory for GK ID data\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } memcpy(pGkClient->gkId.data, pRegistrationConfirm->gatekeeperIdentifier.data, sizeof(ASN116BITCHAR)* pGkClient->gkId.nchars); } /* Extract CallSignalling Address */ for(i=0; i<(int)pRegistrationConfirm->callSignalAddress.count; i++) { pNode = dListFindByIndex(&pRegistrationConfirm->callSignalAddress, i); if(!pNode) { OOTRACEERR1("Error:Invalid Registration confirmed message\n"); OOTRACEINFO1("Ignoring RCF, will retransmit RRQ after timeout\n"); return OO_FAILED; } pCallSigAddr = (H225TransportAddress*)pNode->data; if(pCallSigAddr->t != T_H225TransportAddress_ipAddress) continue; sprintf(pGkClient->gkCallSignallingIP, "%d.%d.%d.%d", pCallSigAddr->u.ipAddress->ip.data[0], pCallSigAddr->u.ipAddress->ip.data[1], pCallSigAddr->u.ipAddress->ip.data[2], pCallSigAddr->u.ipAddress->ip.data[3]); pGkClient->gkCallSignallingPort = pCallSigAddr->u.ipAddress->port; } /* Update list of registered aliases*/ if(pRegistrationConfirm->m.terminalAliasPresent) { ooGkClientUpdateRegisteredAliases(pGkClient, &pRegistrationConfirm->terminalAlias, TRUE); } else{/* Everything registered*/ ooGkClientUpdateRegisteredAliases(pGkClient, NULL, TRUE); } /* Is keepAlive supported */ if(pRegistrationConfirm->m.timeToLivePresent) { pGkClient->regTimeout = pRegistrationConfirm->timeToLive; OOTRACEINFO2("Gatekeeper supports KeepAlive, Registration TTL is %d\n", pRegistrationConfirm->timeToLive); if(pGkClient->regTimeout > DEFAULT_TTL_OFFSET) regTTL = pGkClient->regTimeout - DEFAULT_TTL_OFFSET; else { regTTL = pGkClient->regTimeout - 1; /* -1 due to some ops expire us few earlier */ if (regTTL <= 0) regTTL = 1; } cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory for Regisration timer." "\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } cbData->timerType = OO_REG_TIMER; cbData->pGkClient = pGkClient; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientREGTimerExpired, regTTL, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create REG timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; return OO_FAILED; } } else{ pGkClient->regTimeout = 0; OOTRACEINFO1("Gatekeeper does not support KeepAlive.\n"); } /* Extract Pre-Granted ARQ */ if(pRegistrationConfirm->m.preGrantedARQPresent) { memcpy(&pGkClient->gkInfo.preGrantedARQ, &pRegistrationConfirm->preGrantedARQ, sizeof(H225RegistrationConfirm_preGrantedARQ)); } /* First delete the corresponding RRQ timer */ pNode = NULL; for(x=0; xtimerList.count; x++) { pNode = dListFindByIndex(&pGkClient->timerList, x); pTimer = (OOTimer*)pNode->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_RRQ_TIMER) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted RRQ Timer.\n"); } } pGkClient->state = GkClientRegistered; if(pGkClient->callbacks.onReceivedRegistrationConfirm) pGkClient->callbacks.onReceivedRegistrationConfirm(pRegistrationConfirm, gH323ep.aliases); return OO_OK; } int ooGkClientHandleRegistrationReject (ooGkClient *pGkClient, H225RegistrationReject *pRegistrationReject) { int iRet=0; unsigned int x=0; DListNode *pNode = NULL; OOTimer *pTimer = NULL; ooGkClientTimerCb *cbData=NULL; /* First delete the corresponding RRQ timer */ for(x=0; xtimerList.count; x++) { pNode = dListFindByIndex(&pGkClient->timerList, x); pTimer = (OOTimer*)pNode->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_RRQ_TIMER) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted RRQ Timer.\n"); } } switch(pRegistrationReject->rejectReason.t) { case T_H225RegistrationRejectReason_discoveryRequired: OOTRACEINFO1("RRQ Rejected - Discovery Required\n"); pGkClient->discoveryComplete = FALSE; pGkClient->state = GkClientIdle; pGkClient->rrqRetries = 0; pGkClient->grqRetries = 0; if(OO_OK != ooGkClientSendGRQ(pGkClient)) { OOTRACEERR1("Error:Failed to send GRQ message\n"); return OO_FAILED; } return OO_OK; case T_H225RegistrationRejectReason_invalidRevision: OOTRACEERR1("RRQ Rejected - Invalid Revision\n"); break; case T_H225RegistrationRejectReason_invalidCallSignalAddress: OOTRACEERR1("RRQ Rejected - Invalid CallSignalAddress\n"); break; case T_H225RegistrationRejectReason_invalidRASAddress: OOTRACEERR1("RRQ Rejected - Invalid RAS Address\n"); break; case T_H225RegistrationRejectReason_duplicateAlias: OOTRACEERR1("RRQ Rejected - Duplicate Alias\n"); break; case T_H225RegistrationRejectReason_invalidTerminalType: OOTRACEERR1("RRQ Rejected - Invalid Terminal Type\n"); break; case T_H225RegistrationRejectReason_undefinedReason: OOTRACEERR1("RRQ Rejected - Undefined Reason\n"); break; case T_H225RegistrationRejectReason_transportNotSupported: OOTRACEERR1("RRQ Rejected - Transport Not supported\n"); break; case T_H225RegistrationRejectReason_transportQOSNotSupported: OOTRACEERR1("RRQ Rejected - Transport QOS Not Supported\n"); break; case T_H225RegistrationRejectReason_resourceUnavailable: OOTRACEERR1("RRQ Rejected - Resource Unavailable\n"); break; case T_H225RegistrationRejectReason_invalidAlias: OOTRACEERR1("RRQ Rejected - Invalid Alias\n"); break; case T_H225RegistrationRejectReason_securityDenial: OOTRACEERR1("RRQ Rejected - Security Denial\n"); break; case T_H225RegistrationRejectReason_fullRegistrationRequired: OOTRACEINFO1("RRQ Rejected - Full Registration Required\n"); pGkClient->state = GkClientDiscovered; pGkClient->rrqRetries = 0; iRet = ooGkClientSendRRQ(pGkClient, 0); /* No keepAlive */ if(iRet != OO_OK){ OOTRACEERR1("\nError: Full Registration transmission failed\n"); return OO_FAILED; } return OO_OK; case T_H225RegistrationRejectReason_additiveRegistrationNotSupported: OOTRACEERR1("RRQ Rejected - Additive Registration Not Supported\n"); break; case T_H225RegistrationRejectReason_invalidTerminalAliases: OOTRACEERR1("RRQ Rejected - Invalid Terminal Aliases\n"); break; case T_H225RegistrationRejectReason_genericDataReason: OOTRACEERR1("RRQ Rejected - Generic Data Reason\n"); break; case T_H225RegistrationRejectReason_neededFeatureNotSupported: OOTRACEERR1("RRQ Rejected - Needed Feature Not Supported\n"); break; case T_H225RegistrationRejectReason_securityError: OOTRACEERR1("RRQ Rejected - Security Error\n"); break; default: OOTRACEINFO1("RRQ Rejected - Invalid Reason\n"); } /* send again GRQ/RRQ's */ ast_mutex_lock(&pGkClient->Lock); pGkClient->state = GkClientUnregistered; pGkClient->rrqRetries = 0; pGkClient->grqRetries = 0; pGkClient->discoveryComplete = FALSE; cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory to GRQ timer callback\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } cbData->timerType = OO_GRQ_TIMER; cbData->pGkClient = pGkClient; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientGRQTimerExpired, pGkClient->grqTimeout, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create GRQ timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } int ooGkClientSendURQ(ooGkClient *pGkClient, ooAliases *aliases) { int iRet; H225RasMessage *pRasMsg=NULL; H225UnregistrationRequest *pUnregReq=NULL; OOCTXT *pctxt=NULL; H225TransportAddress *pTransportAddress=NULL; H225TransportAddress_ipAddress *pIpAddress=NULL; ast_mutex_lock(&pGkClient->Lock); pctxt = &pGkClient->msgCtxt; OOTRACEDBGA1("Building Unregistration Request message\n"); pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); if(!pRasMsg) { OOTRACEERR1("Error: Memory allocation for URQ RAS message failed\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pUnregReq = (H225UnregistrationRequest*)memAlloc(pctxt, sizeof(H225UnregistrationRequest)); if(!pUnregReq) { OOTRACEERR1("Error:Memory allocation for URQ failed\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memset(pUnregReq, 0, sizeof(H225UnregistrationRequest)); pRasMsg->t = T_H225RasMessage_unregistrationRequest; pRasMsg->u.unregistrationRequest = pUnregReq; pUnregReq->requestSeqNum = pGkClient->requestSeqNum++; if(!pUnregReq->requestSeqNum) pUnregReq->requestSeqNum = pGkClient->requestSeqNum++; /* Populate CallSignal Address List*/ pTransportAddress = (H225TransportAddress*) memAlloc(pctxt, sizeof(H225TransportAddress)); pIpAddress = (H225TransportAddress_ipAddress*) memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!pTransportAddress || !pIpAddress) { OOTRACEERR1("Error:Failed to allocate memory for signalling address of " "RRQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pTransportAddress->t = T_H225TransportAddress_ipAddress; pTransportAddress->u.ipAddress = pIpAddress; inet_pton(AF_INET, pGkClient->localRASIP, pIpAddress->ip.data); pIpAddress->ip.numocts = 4; pIpAddress->port = gH323ep.listenPort; dListInit(&pUnregReq->callSignalAddress); dListAppend(pctxt, &pUnregReq->callSignalAddress, (void*)pTransportAddress); /* Populate Endpoint Identifier */ pUnregReq->m.endpointIdentifierPresent = TRUE; pUnregReq->endpointIdentifier.nchars = pGkClient->endpointId.nchars; pUnregReq->endpointIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); if(!pUnregReq->endpointIdentifier.data) { OOTRACEERR1("Error: Failed to allocate memory for EndPoint Id in URQ " "message.\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy((void*)pUnregReq->endpointIdentifier.data, (void*)pGkClient->endpointId.data, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); /* Populate gatekeeper identifier */ if (pGkClient->gkId.nchars) { pUnregReq->m.gatekeeperIdentifierPresent = TRUE; pUnregReq->gatekeeperIdentifier.nchars = pGkClient->gkId.nchars; pUnregReq->gatekeeperIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); if(!pUnregReq->gatekeeperIdentifier.data) { OOTRACEERR1("Error:Failed to allocate memory for GKID of URQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy((void*)pUnregReq->gatekeeperIdentifier.data, (void*)pGkClient->gkId.data, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); } /* Check whether specific aliases are to be unregistered*/ if(aliases) { pUnregReq->m.endpointAliasPresent = TRUE; ooPopulateAliasList(pctxt, aliases, &pUnregReq->endpointAlias, 0); } iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error:Failed to send UnregistrationRequest message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pGkClient->state = GkClientUnregistered; OOTRACEINFO1("Unregistration Request message sent.\n"); ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } int ooGkClientHandleUnregistrationRequest (ooGkClient *pGkClient, H225UnregistrationRequest * punregistrationRequest) { int iRet=0, x; OOTimer *pTimer = NULL; DListNode *pNode = NULL; /* Lets first send unregistration confirm message back to gatekeeper*/ ooGkClientSendUnregistrationConfirm(pGkClient, punregistrationRequest->requestSeqNum); if(punregistrationRequest->m.endpointAliasPresent) { OOTRACEINFO1("Gatekeeper requested a list of aliases be unregistered\n"); ooGkClientUpdateRegisteredAliases(pGkClient, &punregistrationRequest->endpointAlias, FALSE); } else{ OOTRACEINFO1("Gatekeeper requested a all aliases to be unregistered\n"); ooGkClientUpdateRegisteredAliases(pGkClient, NULL, FALSE); /* Send a fresh Registration request and if that fails, go back to Gatekeeper discovery. */ OOTRACEINFO1("Sending fresh RRQ - as unregistration request received\n"); pGkClient->rrqRetries = 0; pGkClient->state = GkClientDiscovered; /* delete the corresponding RRQ & REG timers */ pNode = NULL; for(x=0; xtimerList.count; x++) { pNode = dListFindByIndex(&pGkClient->timerList, x); pTimer = (OOTimer*)pNode->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_RRQ_TIMER) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted RRQ Timer.\n"); } if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_REG_TIMER) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted REG Timer.\n"); } } iRet = ooGkClientSendRRQ(pGkClient, 0); if(iRet != OO_OK) { OOTRACEERR1("Error: Failed to send RRQ message\n"); return OO_FAILED; } } if(pGkClient->callbacks.onReceivedUnregistrationRequest) pGkClient->callbacks.onReceivedUnregistrationRequest( punregistrationRequest, gH323ep.aliases); return OO_OK; } int ooGkClientSendUnregistrationConfirm(ooGkClient *pGkClient, unsigned reqNo) { int iRet = OO_OK; OOCTXT *pctxt = &pGkClient->msgCtxt; H225RasMessage *pRasMsg=NULL; H225UnregistrationConfirm *pUCF=NULL; ast_mutex_lock(&pGkClient->Lock); pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); pUCF = (H225UnregistrationConfirm*)memAlloc(pctxt, sizeof(H225UnregistrationConfirm)); if(!pRasMsg || !pUCF) { OOTRACEERR1("Error: Memory allocation for UCF RAS message failed\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pRasMsg->t = T_H225RasMessage_unregistrationConfirm; pRasMsg->u.unregistrationConfirm = pUCF; memset(pUCF, 0, sizeof(H225UnregistrationConfirm)); pUCF->requestSeqNum = reqNo; iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error:Failed to send UnregistrationConfirm message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } OOTRACEINFO1("Unregistration Confirm message sent for \n"); memReset(pctxt); ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } int ooGkClientSendAdmissionRequest (ooGkClient *pGkClient, OOH323CallData *call, ASN1BOOL retransmit) { int iRet = 0; unsigned int x; DListNode *pNode; ooGkClientTimerCb *cbData=NULL; H225RasMessage *pRasMsg=NULL; OOCTXT* pctxt; H225AdmissionRequest *pAdmReq=NULL; H225TransportAddress_ipAddress *pIpAddressLocal =NULL, *pIpAddressRemote=NULL; ooAliases *destAliases = NULL, *srcAliases=NULL; RasCallAdmissionInfo *pCallAdmInfo=NULL; pctxt = &pGkClient->msgCtxt; ast_mutex_lock(&pGkClient->Lock); OOTRACEDBGA3("Building Admission Request for call (%s, %s)\n", call->callType, call->callToken); pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); if(!pRasMsg) { OOTRACEERR3("Error:Memory - ooGkClientSendAdmissionRequest - " "pRasMsg(%s, %s)\n", call->callType, call->callToken); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pRasMsg->t = T_H225RasMessage_admissionRequest; pAdmReq = (H225AdmissionRequest*) memAlloc(pctxt, sizeof(H225AdmissionRequest)); if(!pAdmReq) { OOTRACEERR3("Error:Memory - ooGkClientSendAdmissionRequest - " "pAdmReq(%s, %s)\n", call->callType, call->callToken); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memset(pAdmReq, 0, sizeof(H225AdmissionRequest)); pRasMsg->u.admissionRequest = pAdmReq; /* Populate call signalling addresses */ pIpAddressLocal = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!ooUtilsIsStrEmpty(call->remoteIP)) pIpAddressRemote = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!pIpAddressLocal || (!ooUtilsIsStrEmpty(call->remoteIP) && (!pIpAddressRemote))) { OOTRACEERR1("Error:Failed to allocate memory for Call Signalling " "Addresses of ARQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } inet_pton(AF_INET, pGkClient->localRASIP, pIpAddressLocal->ip.data); pIpAddressLocal->ip.numocts = 4; pIpAddressLocal->port = gH323ep.listenPort; if(!ooUtilsIsStrEmpty(call->remoteIP)) { inet_pton(AF_INET, call->remoteIP, pIpAddressRemote->ip.data); pIpAddressRemote->ip.numocts = 4; pIpAddressRemote->port = call->remotePort; } if(!strcmp(call->callType, "incoming")) { pAdmReq->m.destCallSignalAddressPresent = TRUE; pAdmReq->destCallSignalAddress.t = T_H225TransportAddress_ipAddress; pAdmReq->destCallSignalAddress.u.ipAddress = pIpAddressLocal; if(!ooUtilsIsStrEmpty(call->remoteIP)) { pAdmReq->m.srcCallSignalAddressPresent = TRUE; pAdmReq->srcCallSignalAddress.t = T_H225TransportAddress_ipAddress; pAdmReq->srcCallSignalAddress.u.ipAddress = pIpAddressRemote; } } else { pAdmReq->m.srcCallSignalAddressPresent = TRUE; pAdmReq->srcCallSignalAddress.t = T_H225TransportAddress_ipAddress; pAdmReq->srcCallSignalAddress.u.ipAddress = pIpAddressLocal; if(!ooUtilsIsStrEmpty(call->remoteIP)) { pAdmReq->m.destCallSignalAddressPresent = TRUE; pAdmReq->destCallSignalAddress.t = T_H225TransportAddress_ipAddress; pAdmReq->destCallSignalAddress.u.ipAddress = pIpAddressRemote; } } /* Populate seq number */ pAdmReq->requestSeqNum = pGkClient->requestSeqNum++; if(!pAdmReq->requestSeqNum) pAdmReq->requestSeqNum = pGkClient->requestSeqNum++; /* Populate call type - For now only PointToPoint supported*/ pAdmReq->callType.t = T_H225CallType_pointToPoint; /* Add call model to message*/ pAdmReq->m.callModelPresent = 1; if(OO_TESTFLAG(call->flags, OO_M_GKROUTED)) pAdmReq->callModel.t = T_H225CallModel_gatekeeperRouted; else pAdmReq->callModel.t = T_H225CallModel_direct; /* Populate Endpoint Identifier */ pAdmReq->endpointIdentifier.nchars = pGkClient->endpointId.nchars; pAdmReq->endpointIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); if(!pAdmReq->endpointIdentifier.data) { OOTRACEERR3("Error:Memory - ooGkClientSendAdmissionRequest - " "endpointIdentifier.data(%s, %s)\n", call->callType, call->callToken); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy((void*)pAdmReq->endpointIdentifier.data, (void*)pGkClient->endpointId.data, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); /* Get Destination And source aliases for call - */ if(!strcmp(call->callType, "incoming")) { if(call->ourAliases) destAliases = call->ourAliases; else destAliases = gH323ep.aliases; srcAliases = call->remoteAliases; } else { if(call->ourAliases) srcAliases = call->ourAliases; else srcAliases = gH323ep.aliases; destAliases = call->remoteAliases; } /* Populate destination info */ if(destAliases) { pAdmReq->m.destinationInfoPresent = 1; if(OO_OK != ooPopulateAliasList(&pGkClient->msgCtxt, destAliases, &pAdmReq->destinationInfo, T_H225AliasAddress_dialedDigits)) { OOTRACEERR1("Error:Failed to populate destination aliases - " "ARQ message\n"); pGkClient->state = GkClientFailed; memReset(pctxt); ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } } /* Populate Source Info */ if(srcAliases) { iRet = ooPopulateAliasList(&pGkClient->msgCtxt, srcAliases, &pAdmReq->srcInfo, 0); if(OO_OK != iRet) { OOTRACEERR1("Error:Failed to populate source aliases -ARQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } } /* Populate bandwidth*/ pAdmReq->bandWidth = DEFAULT_BW_REQUEST; /* Populate call Reference */ pAdmReq->callReferenceValue = call->callReference; /* populate conferenceID */ memcpy((void*)&pAdmReq->conferenceID, (void*)&call->confIdentifier, sizeof(H225ConferenceIdentifier)); /*populate answerCall */ if(!strcmp(call->callType, "incoming")) pAdmReq->answerCall = TRUE; else pAdmReq->answerCall = FALSE; /* Populate CanMapAlias */ pAdmReq->m.canMapAliasPresent = TRUE; pAdmReq->canMapAlias = FALSE; /* Populate call identifier */ pAdmReq->m.callIdentifierPresent = TRUE; memcpy((void*)&pAdmReq->callIdentifier, (void*)&call->callIdentifier, sizeof(H225CallIdentifier)); /* Populate Gatekeeper Id */ if (pGkClient->gkId.nchars) { pAdmReq->m.gatekeeperIdentifierPresent = TRUE; pAdmReq->gatekeeperIdentifier.nchars = pGkClient->gkId.nchars; pAdmReq->gatekeeperIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); if(!pAdmReq->gatekeeperIdentifier.data) { OOTRACEERR1("Error:Failed to allocate memory for GKID of ARQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy((void*)pAdmReq->gatekeeperIdentifier.data, (void*)pGkClient->gkId.data, sizeof(ASN116BITCHAR)*pGkClient->gkId.nchars); } pAdmReq->m.willSupplyUUIEsPresent = 1; pAdmReq->willSupplyUUIEs = FALSE; /* Create RasCallAdmissionInfo */ if(!retransmit) { pCallAdmInfo = (RasCallAdmissionInfo*)memAlloc(&pGkClient->ctxt, sizeof(RasCallAdmissionInfo)); if(!pCallAdmInfo) { OOTRACEERR1("Error: Failed to allocate memory for new CallAdmission" " Info entry\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pCallAdmInfo->call = call; pCallAdmInfo->retries = 0; pCallAdmInfo->requestSeqNum = pAdmReq->requestSeqNum; dListAppend(&pGkClient->ctxt, &pGkClient->callsPendingList,pCallAdmInfo); } else{ for(x=0; xcallsPendingList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsPendingList, x); pCallAdmInfo = (RasCallAdmissionInfo*)pNode->data; if(pCallAdmInfo->call->callReference == call->callReference) { pCallAdmInfo->requestSeqNum = pAdmReq->requestSeqNum; break; } } } iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error:Failed to send AdmissionRequest message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } OOTRACEINFO3("Admission Request message sent for (%s, %s)\n", call->callType, call->callToken); memReset(pctxt); /* Add ARQ timer */ cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory for Regisration timer." "\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } cbData->timerType = OO_ARQ_TIMER; cbData->pGkClient = pGkClient; cbData->pAdmInfo = pCallAdmInfo; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientARQTimerExpired, pGkClient->arqTimeout, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create ARQ timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } /** * Manage incoming ACF message. */ int ooGkClientHandleAdmissionConfirm (ooGkClient *pGkClient, H225AdmissionConfirm *pAdmissionConfirm) { RasCallAdmissionInfo* pCallAdmInfo=NULL; unsigned int x, y; DListNode *pNode, *pNode1=NULL; H225TransportAddress_ipAddress * ipAddress=NULL; OOTimer *pTimer = NULL; char ip[20]; ast_mutex_lock(&pGkClient->Lock); /* Search call in pending calls list */ for(x=0 ; xcallsPendingList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsPendingList, x); pCallAdmInfo = (RasCallAdmissionInfo*) pNode->data; if(pCallAdmInfo->requestSeqNum == pAdmissionConfirm->requestSeqNum) { OOTRACEDBGC3("Found Pending call(%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); ast_mutex_lock(&pCallAdmInfo->call->GkLock); /* Populate Remote IP */ if(pAdmissionConfirm->destCallSignalAddress.t != T_H225TransportAddress_ipAddress) { OOTRACEERR1("Error:Destination Call Signal Address provided by" "Gatekeeper is not an IPv4 address\n"); OOTRACEINFO1("Ignoring ACF, will wait for timeout and retransmit " "ARQ\n"); ast_mutex_unlock(&pCallAdmInfo->call->GkLock); ast_mutex_unlock(&pGkClient->Lock); ast_cond_signal(&pCallAdmInfo->call->gkWait); return OO_FAILED; } ipAddress = pAdmissionConfirm->destCallSignalAddress.u.ipAddress; sprintf(ip, "%d.%d.%d.%d", ipAddress->ip.data[0], ipAddress->ip.data[1], ipAddress->ip.data[2], ipAddress->ip.data[3]); if(strcmp(ip, "0.0.0.0")) { /* fix this when gk client will adopt to work with IPv6 */ pCallAdmInfo->call->versionIP = 4; strcpy(pCallAdmInfo->call->remoteIP, ip); } pCallAdmInfo->call->remotePort = ipAddress->port; /* Update call model */ if(pAdmissionConfirm->callModel.t == T_H225CallModel_direct) { if(OO_TESTFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED)) { OOTRACEINFO3("Gatekeeper changed call model from GkRouted to " "direct. (%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); OO_CLRFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED); } } if(pAdmissionConfirm->callModel.t == T_H225CallModel_gatekeeperRouted) { if(!OO_TESTFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED)) { OOTRACEINFO3("Gatekeeper changed call model from direct to " "GkRouted. (%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); OO_SETFLAG(pCallAdmInfo->call->flags, OO_M_GKROUTED); } } /* Delete ARQ timer */ for(y=0; ytimerList.count; y++) { pNode1 = dListFindByIndex(&pGkClient->timerList, y); pTimer = (OOTimer*)pNode1->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_ARQ_TIMER) { if(((ooGkClientTimerCb*)pTimer->cbData)->pAdmInfo == pCallAdmInfo) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted ARQ Timer.\n"); break; } } } OOTRACEINFO3("Admission Confirm message received for (%s, %s)\n", pCallAdmInfo->call->callType, pCallAdmInfo->call->callToken); pCallAdmInfo->call->callState = OO_CALL_CONNECTING; dListRemove(&pGkClient->callsPendingList, pNode); dListAppend(&pGkClient->ctxt, &pGkClient->callsAdmittedList, pNode->data); memFreePtr(&pGkClient->ctxt, pNode); ast_mutex_unlock(&pCallAdmInfo->call->GkLock); ast_mutex_unlock(&pGkClient->Lock); ast_cond_signal(&pCallAdmInfo->call->gkWait); return OO_OK; } else { pNode = pNode->next; } } OOTRACEERR1("Error: Failed to process ACF as there is no corresponding " "pending call\n"); ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } int ooGkClientHandleAdmissionReject (ooGkClient *pGkClient, H225AdmissionReject *pAdmissionReject) { RasCallAdmissionInfo* pCallAdmInfo=NULL; unsigned int x, y; DListNode *pNode=NULL, *pNode1=NULL; OOH323CallData *call=NULL; OOTimer *pTimer = NULL; ast_mutex_lock(&pGkClient->Lock); /* Search call in pending calls list */ for(x=0 ; xcallsPendingList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsPendingList, x); pCallAdmInfo = (RasCallAdmissionInfo*) pNode->data; if(pCallAdmInfo->requestSeqNum == pAdmissionReject->requestSeqNum) break; pNode = NULL; pCallAdmInfo = NULL; } if(!pCallAdmInfo) { OOTRACEWARN2("Received admission reject with request number %d can not" " be matched with any pending call.\n", pAdmissionReject->requestSeqNum); ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } else{ call = pCallAdmInfo->call; dListRemove(&pGkClient->callsPendingList, pNode); memFreePtr(&pGkClient->ctxt, pCallAdmInfo); memFreePtr(&pGkClient->ctxt, pNode); } ast_mutex_lock(&pCallAdmInfo->call->GkLock); /* Delete ARQ timer */ for(y=0; ytimerList.count; y++) { pNode1 = dListFindByIndex(&pGkClient->timerList, y); pTimer = (OOTimer*)pNode1->data; if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_ARQ_TIMER) { if(((ooGkClientTimerCb*)pTimer->cbData)->pAdmInfo == pCallAdmInfo) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); OOTRACEDBGA1("Deleted ARQ Timer.\n"); break; } } } OOTRACEINFO4("Admission Reject message received with reason code %d for " "(%s, %s)\n", pAdmissionReject->rejectReason.t, call->callType, call->callToken); call->callState = OO_CALL_CLEARED; switch(pAdmissionReject->rejectReason.t) { case T_H225AdmissionRejectReason_calledPartyNotRegistered: call->callEndReason = OO_REASON_GK_NOCALLEDUSER; break; case T_H225AdmissionRejectReason_invalidPermission: case T_H225AdmissionRejectReason_requestDenied: case T_H225AdmissionRejectReason_undefinedReason: call->callEndReason = OO_REASON_GK_CLEARED; break; case T_H225AdmissionRejectReason_callerNotRegistered: call->callEndReason = OO_REASON_GK_NOCALLERUSER; break; case T_H225AdmissionRejectReason_exceedsCallCapacity: case T_H225AdmissionRejectReason_resourceUnavailable: call->callEndReason = OO_REASON_GK_NORESOURCES; break; case T_H225AdmissionRejectReason_noRouteToDestination: case T_H225AdmissionRejectReason_unallocatedNumber: call->callEndReason = OO_REASON_GK_UNREACHABLE; break; case T_H225AdmissionRejectReason_routeCallToGatekeeper: case T_H225AdmissionRejectReason_invalidEndpointIdentifier: case T_H225AdmissionRejectReason_securityDenial: case T_H225AdmissionRejectReason_qosControlNotSupported: case T_H225AdmissionRejectReason_incompleteAddress: case T_H225AdmissionRejectReason_aliasesInconsistent: case T_H225AdmissionRejectReason_routeCallToSCN: case T_H225AdmissionRejectReason_collectDestination: case T_H225AdmissionRejectReason_collectPIN: case T_H225AdmissionRejectReason_genericDataReason: case T_H225AdmissionRejectReason_neededFeatureNotSupported: case T_H225AdmissionRejectReason_securityErrors: case T_H225AdmissionRejectReason_securityDHmismatch: case T_H225AdmissionRejectReason_extElem1: call->callEndReason = OO_REASON_GK_CLEARED; break; } ast_mutex_unlock(&pCallAdmInfo->call->GkLock); ast_mutex_unlock(&pGkClient->Lock); ast_cond_signal(&pCallAdmInfo->call->gkWait); return OO_OK; } int ooGkClientSendIRR (ooGkClient *pGkClient, OOH323CallData *call) { int iRet = 0; H225RasMessage *pRasMsg=NULL; OOCTXT* pctxt; H225InfoRequestResponse *pIRR=NULL; H225TransportAddress_ipAddress *pIpAddressLocal =NULL, *pIpRasAddress, *pLocalAddr, *pRemoteAddr; H225TransportAddress *pTransportAddress; ooAliases *srcAliases=NULL; H225InfoRequestResponse_perCallInfo_element *perCallInfo = NULL; pctxt = &pGkClient->msgCtxt; ast_mutex_lock(&pGkClient->Lock); OOTRACEDBGA3("Building Info Request Resp for call (%s, %s)\n", call->callType, call->callToken); pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); if(!pRasMsg) { OOTRACEERR3("Error:Memory - ooGkClientSendIRR - " "pRasMsg(%s, %s)\n", call->callType, call->callToken); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pRasMsg->t = T_H225RasMessage_infoRequestResponse; pIRR = (H225InfoRequestResponse*) memAlloc(pctxt, sizeof(H225InfoRequestResponse)); if(!pIRR) { OOTRACEERR3("Error:Memory - ooGkClientSendIRR - " "pIRR(%s, %s)\n", call->callType, call->callToken); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memset(pIRR, 0, sizeof(H225InfoRequestResponse)); pRasMsg->u.infoRequestResponse = pIRR; /* Populate call signalling addresses */ pIpAddressLocal = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); pTransportAddress = (H225TransportAddress*) memAlloc(pctxt, sizeof(H225TransportAddress)); if(!pIpAddressLocal || !pTransportAddress) { OOTRACEERR1("Error:Failed to allocate memory for Call Signalling " "Addresses of IRR message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } inet_pton(AF_INET, pGkClient->localRASIP, pIpAddressLocal->ip.data); pIpAddressLocal->ip.numocts = 4; pIpAddressLocal->port = gH323ep.listenPort; pTransportAddress->t = T_H225TransportAddress_ipAddress; pTransportAddress->u.ipAddress = pIpAddressLocal; dListInit(&pIRR->callSignalAddress); dListAppend(pctxt, &pIRR->callSignalAddress, (void*)pTransportAddress); /* Populate seq number */ pIRR->requestSeqNum = pGkClient->requestSeqNum++; if(!pIRR->requestSeqNum) pIRR->requestSeqNum = pGkClient->requestSeqNum++; pIpRasAddress = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!pIpRasAddress) { OOTRACEERR1("Error: Memory allocation for Ras Address of IRR message " "failed\n"); memReset(&pGkClient->msgCtxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pIpRasAddress->ip.numocts = 4; pIpRasAddress->port = pGkClient->localRASPort; inet_pton(AF_INET, pGkClient->localRASIP, pIpRasAddress->ip.data); pIRR->rasAddress.u.ipAddress = pIpRasAddress; pIRR->rasAddress.t=T_H225TransportAddress_ipAddress; /* IPv4 address */ /* Pose as gateway or terminal as per config */ if(gH323ep.isGateway) pIRR->endpointType.m.gatewayPresent = TRUE; else pIRR->endpointType.m.terminalPresent = TRUE; pIRR->endpointType.m.nonStandardDataPresent=FALSE; pIRR->endpointType.m.vendorPresent=TRUE; ooGkClientFillVendor(pGkClient, &pIRR->endpointType.vendor); /* Populate Endpoint Identifier */ pIRR->endpointIdentifier.nchars = pGkClient->endpointId.nchars; pIRR->endpointIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); if(!pIRR->endpointIdentifier.data) { OOTRACEERR3("Error:Memory - ooGkClientSendIRR - " "endpointIdentifier.data(%s, %s)\n", call->callType, call->callToken); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy((void*)pIRR->endpointIdentifier.data, (void*)pGkClient->endpointId.data, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); /* Populate call aliases */ if(call->ourAliases) srcAliases = call->ourAliases; else srcAliases = gH323ep.aliases; /* Populate Source Info */ if(srcAliases) { iRet = ooPopulateAliasList(&pGkClient->msgCtxt, srcAliases, &pIRR->endpointAlias, T_H225AliasAddress_h323_ID); if(OO_OK != iRet) { OOTRACEERR1("Error:Failed to populate source aliases -IRR message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } } pIRR->m.endpointAliasPresent = TRUE; /* Populate need response & unsolicited */ pIRR->needResponse = FALSE; pIRR->m.needResponsePresent = TRUE; pIRR->unsolicited = TRUE; pIRR->m.unsolicitedPresent = TRUE; /* Populate perCallInfo */ pIRR->m.perCallInfoPresent = TRUE; perCallInfo = (H225InfoRequestResponse_perCallInfo_element *)memAlloc(pctxt, sizeof(H225InfoRequestResponse_perCallInfo_element)); memset(perCallInfo, 0, sizeof(H225InfoRequestResponse_perCallInfo_element)); if(!perCallInfo) { OOTRACEERR3("Error:Memory - ooGkClientSendIRR - " "perCallInfo for (%s, %s)\n", call->callType, call->callToken); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } perCallInfo->m.originatorPresent = TRUE; perCallInfo->originator = (!strcmp(call->callType, "incoming")) ? FALSE : TRUE; pLocalAddr = (H225TransportAddress_ipAddress*)memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); pRemoteAddr = (H225TransportAddress_ipAddress*) memAlloc(pctxt, sizeof(H225TransportAddress_ipAddress)); if(!pLocalAddr || !pRemoteAddr) { OOTRACEERR1("Error:Failed to allocate memory for Call Signalling " "Addresses of IRR message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pLocalAddr->ip.numocts = 4; inet_pton(AF_INET, call->localIP, pLocalAddr->ip.data); pLocalAddr->port = (call->pH225Channel->port) ? call->pH225Channel->port : gH323ep.listenPort; pRemoteAddr->ip.numocts = 4; inet_pton(AF_INET, call->remoteIP, pRemoteAddr->ip.data); pRemoteAddr->port = call->remotePort; perCallInfo->callSignaling.m.sendAddressPresent = TRUE; perCallInfo->callSignaling.sendAddress.t = T_H225TransportAddress_ipAddress; perCallInfo->callSignaling.m.recvAddressPresent = TRUE; perCallInfo->callSignaling.recvAddress.t = T_H225TransportAddress_ipAddress; if (!strcmp(call->callType, "incoming")) { // terminator perCallInfo->callSignaling.sendAddress.u.ipAddress = pRemoteAddr; perCallInfo->callSignaling.recvAddress.u.ipAddress = pLocalAddr; } else { // originator perCallInfo->callSignaling.sendAddress.u.ipAddress = pLocalAddr; perCallInfo->callSignaling.recvAddress.u.ipAddress = pRemoteAddr; } /* Populate call Reference */ perCallInfo->callReferenceValue = call->callReference; /* populate conferenceID */ memcpy((void*)&perCallInfo->conferenceID, (void*)&call->confIdentifier, sizeof(H225ConferenceIdentifier)); /* Populate call identifier */ perCallInfo->m.callIdentifierPresent = TRUE; memcpy((void*)&perCallInfo->callIdentifier, (void*)&call->callIdentifier, sizeof(H225CallIdentifier)); /* Populate call type & call model */ perCallInfo->callType.t = T_H225CallType_pointToPoint; /* Add call model to message*/ if(OO_TESTFLAG(call->flags, OO_M_GKROUTED)) perCallInfo->callModel.t = T_H225CallModel_gatekeeperRouted; else perCallInfo->callModel.t = T_H225CallModel_direct; /* Populate usage info */ if (call->alertingTime) { perCallInfo->usageInformation.m.alertingTimePresent = TRUE; perCallInfo->usageInformation.alertingTime = call->alertingTime; } if (call->connectTime) { perCallInfo->usageInformation.m.connectTimePresent = TRUE; perCallInfo->usageInformation.connectTime = call->connectTime; } perCallInfo->usageInformation.m.endTimePresent = FALSE; perCallInfo->m.usageInformationPresent = TRUE; dListInit(&pIRR->perCallInfo); dListAppend(pctxt, &pIRR->perCallInfo, (void*)perCallInfo); iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error:Failed to send IRR message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } OOTRACEINFO3("IRR message sent for (%s, %s)\n", call->callType, call->callToken); memReset(pctxt); ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } /** * This function is invoked to request call disengage to gatekeeper. * * @param szCallToken Call token. * * @return Completion status - 0 on success, -1 on failure */ int ooGkClientSendDisengageRequest(ooGkClient *pGkClient, OOH323CallData *call) { int iRet = 0; unsigned int x; H225RasMessage *pRasMsg=NULL; OOCTXT *pctxt = NULL; DListNode *pNode = NULL; H225DisengageRequest * pDRQ = NULL; RasCallAdmissionInfo* pCallAdmInfo=NULL; pctxt = &pGkClient->msgCtxt; ast_mutex_lock(&pGkClient->Lock); OOTRACEINFO3("Sending disengage Request for call. (%s, %s)\n", call->callType, call->callToken); pRasMsg = (H225RasMessage*)memAlloc(pctxt, sizeof(H225RasMessage)); if(!pRasMsg) { OOTRACEERR1("Error: Memory allocation for DRQ RAS message failed\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pRasMsg->t = T_H225RasMessage_disengageRequest; pDRQ = (H225DisengageRequest*) memAlloc(pctxt, sizeof(H225DisengageRequest)); if(!pDRQ) { OOTRACEERR1("Error: Failed to allocate memory for DRQ message\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memset(pDRQ, 0, sizeof(H225DisengageRequest)); pRasMsg->u.disengageRequest = pDRQ; pDRQ->requestSeqNum = pGkClient->requestSeqNum++; if(!pDRQ->requestSeqNum ) pDRQ->requestSeqNum = pGkClient->requestSeqNum++; pDRQ->endpointIdentifier.nchars = pGkClient->endpointId.nchars; pDRQ->endpointIdentifier.data = (ASN116BITCHAR*)memAlloc(pctxt, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); if(!pDRQ->endpointIdentifier.data) { OOTRACEERR1("Error: Failed to allocate memory for EndPoint Id in DRQ " "message.\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy((void*)pDRQ->endpointIdentifier.data, (void*)pGkClient->endpointId.data, sizeof(ASN116BITCHAR)*pGkClient->endpointId.nchars); memcpy((void*)&pDRQ->conferenceID, (void*)&call->confIdentifier, sizeof(H225ConferenceIdentifier)); pDRQ->callReferenceValue = call->callReference; pDRQ->disengageReason.t = T_H225DisengageReason_normalDrop; pDRQ->m.answeredCallPresent = 1; if(!strcmp(call->callType, "incoming")) pDRQ->answeredCall = 1; else pDRQ->answeredCall = 0; pDRQ->m.callIdentifierPresent = 1; memcpy((void*)&pDRQ->callIdentifier, (void*)&call->callIdentifier, sizeof(H225CallIdentifier)); if (pGkClient->gkId.nchars) { pDRQ->m.gatekeeperIdentifierPresent = 1; pDRQ->gatekeeperIdentifier.nchars = pGkClient->gkId.nchars; pDRQ->gatekeeperIdentifier.data = (ASN116BITCHAR*)memAlloc (pctxt, pGkClient->gkId.nchars*sizeof(ASN116BITCHAR)); if(!pDRQ->gatekeeperIdentifier.data) { OOTRACEERR1("Error:Failed to allocate memory for GKId in DRQ.\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } memcpy(pDRQ->gatekeeperIdentifier.data, pGkClient->gkId.data, pGkClient->gkId.nchars*sizeof(ASN116BITCHAR)); } pDRQ->m.terminationCausePresent = 1; pDRQ->terminationCause.t = T_H225CallTerminationCause_releaseCompleteCauseIE; pDRQ->terminationCause.u.releaseCompleteCauseIE = (H225CallTerminationCause_releaseCompleteCauseIE*)memAlloc(pctxt, sizeof(H225CallTerminationCause_releaseCompleteCauseIE)); if(!pDRQ->terminationCause.u.releaseCompleteCauseIE) { OOTRACEERR1("Error: Failed to allocate memory for cause ie in DRQ.\n"); memReset(pctxt); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } pDRQ->terminationCause.u.releaseCompleteCauseIE->numocts = strlen("Call Ended"); strcpy((char *)pDRQ->terminationCause.u.releaseCompleteCauseIE->data, "Call Ended"); /* populate usage info */ /* Populate usage info */ if (call->alertingTime) { pDRQ->usageInformation.m.alertingTimePresent = TRUE; pDRQ->usageInformation.alertingTime = call->alertingTime; } if (call->connectTime) { pDRQ->usageInformation.m.connectTimePresent = TRUE; pDRQ->usageInformation.connectTime = call->connectTime; } pDRQ->usageInformation.m.endTimePresent = TRUE; if (call->endTime) pDRQ->usageInformation.endTime = call->endTime; else pDRQ->usageInformation.endTime = time(NULL); pDRQ->m.usageInformationPresent = TRUE; iRet = ooGkClientSendMsg(pGkClient, pRasMsg); if(iRet != OO_OK) { OOTRACEERR1("Error: Failed to send DRQ message\n"); pGkClient->state = GkClientFailed; } /* Search call in admitted calls list */ for(x=0 ; xcallsAdmittedList.count ; x++) { pNode = (DListNode*)dListFindByIndex(&pGkClient->callsAdmittedList, x); pCallAdmInfo = (RasCallAdmissionInfo*) pNode->data; if(pCallAdmInfo->call->callReference == call->callReference) { dListRemove( &pGkClient->callsAdmittedList, pNode); memFreePtr(&pGkClient->ctxt, pNode->data); memFreePtr(&pGkClient->ctxt, pNode); break; } } ast_mutex_unlock(&pGkClient->Lock); return iRet; } int ooGkClientHandleDisengageConfirm (ooGkClient *pGkClient, H225DisengageConfirm *pDCF) { OOTRACEINFO1("Received disengage confirm\n"); return OO_OK; } int ooGkClientRRQTimerExpired(void*pdata) { int ret=0; ooGkClientTimerCb *cbData = (ooGkClientTimerCb*)pdata; ooGkClient *pGkClient = cbData->pGkClient; OOTRACEDBGA1("Gatekeeper client RRQ timer expired.\n"); if(pGkClient->rrqRetries < OO_MAX_RRQ_RETRIES) { ret = ooGkClientSendRRQ(pGkClient, 0); if(ret != OO_OK) { OOTRACEERR1("Error:Failed to send RRQ message\n"); return OO_FAILED; } pGkClient->rrqRetries++; memFreePtr(&pGkClient->ctxt, cbData); return OO_OK; } memFreePtr(&pGkClient->ctxt, cbData); OOTRACEERR1("Error:Failed to register with gatekeeper\n"); pGkClient->state = GkClientUnregistered; /* Create timer to re-register after default timeout */ /* network failure is one of cases here */ ast_mutex_lock(&pGkClient->Lock); cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory to RRQ timer callback\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } cbData->timerType = OO_RRQ_TIMER; cbData->pGkClient = pGkClient; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientRRQTimerExpired, pGkClient->regTimeout, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create GRQ timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } /* clear rrq count for re-register after regTimeout */ pGkClient->rrqRetries = 0; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } int ooGkClientGRQTimerExpired(void* pdata) { int ret=0; ooGkClientTimerCb *cbData = (ooGkClientTimerCb*)pdata; ooGkClient *pGkClient = cbData->pGkClient; OOTRACEDBGA1("Gatekeeper client GRQ timer expired.\n"); memFreePtr(&pGkClient->ctxt, cbData); if(pGkClient->grqRetries < OO_MAX_GRQ_RETRIES) { ret = ooGkClientSendGRQ(pGkClient); if(ret != OO_OK) { OOTRACEERR1("Error:Failed to send GRQ message\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } pGkClient->grqRetries++; return OO_OK; } OOTRACEERR1("Error:Gatekeeper could not be found\n"); pGkClient->state = GkClientUnregistered; /* setup timer to re-send grq after timeout */ ast_mutex_lock(&pGkClient->Lock); cbData = (ooGkClientTimerCb*) memAlloc (&pGkClient->ctxt, sizeof(ooGkClientTimerCb)); if(!cbData) { OOTRACEERR1("Error:Failed to allocate memory to GRQ timer callback\n"); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } cbData->timerType = OO_GRQ_TIMER; cbData->pGkClient = pGkClient; if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList, &ooGkClientGRQTimerExpired, pGkClient->grqTimeout, cbData, FALSE)) { OOTRACEERR1("Error:Unable to create GRQ timer.\n "); memFreePtr(&pGkClient->ctxt, cbData); pGkClient->state = GkClientFailed; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } /* clear grq counter */ pGkClient->grqRetries = 0; ast_mutex_unlock(&pGkClient->Lock); return OO_FAILED; } int ooGkClientREGTimerExpired(void *pdata) { int ret=0; ooGkClientTimerCb *cbData = (ooGkClientTimerCb*)pdata; ooGkClient *pGkClient = cbData->pGkClient; OOTRACEDBGA1("Gatekeeper client additive registration timer expired\n"); memFreePtr(&pGkClient->ctxt, cbData); ret = ooGkClientSendRRQ(pGkClient, TRUE); if(ret != OO_OK) { OOTRACEERR1("Error:Failed to send Additive RRQ message\n"); pGkClient->state = GkClientFailed; return OO_FAILED; } return OO_OK; } int ooGkClientARQTimerExpired(void* pdata) { int ret=0; ooGkClientTimerCb *cbData = (ooGkClientTimerCb*)pdata; ooGkClient *pGkClient = cbData->pGkClient; RasCallAdmissionInfo *pAdmInfo = cbData->pAdmInfo; OOTRACEDBGA1("Gatekeeper client ARQ timer expired.\n"); memFreePtr(&pGkClient->ctxt, cbData); if(!pAdmInfo) return OO_OK; if(pAdmInfo->retries < OO_MAX_ARQ_RETRIES) { ret = ooGkClientSendAdmissionRequest(pGkClient, pAdmInfo->call, TRUE); if(ret != OO_OK) { OOTRACEERR1("Error:Failed to send ARQ message\n"); return OO_FAILED; } pAdmInfo->retries++; return OO_OK; } OOTRACEERR1("Error:Gatekeeper not responding to ARQ\n"); pGkClient->state = GkClientGkErr; return OO_FAILED; } int ooGkClientCleanCall(ooGkClient *pGkClient, OOH323CallData *call) { unsigned int x=0; DListNode *pNode=NULL; OOTimer *pTimer; ooGkClientTimerCb *cbData=NULL; RasCallAdmissionInfo *pAdmInfo = NULL; ast_mutex_lock(&pGkClient->Lock); for(x=0; xcallsAdmittedList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsAdmittedList, x); pAdmInfo = (RasCallAdmissionInfo*)pNode->data; if(pAdmInfo->call->callReference == call->callReference) { dListRemove(&pGkClient->callsAdmittedList, pNode); memFreePtr(&pGkClient->ctxt, pAdmInfo); memFreePtr(&pGkClient->ctxt, pNode); break; } } for(x=0; xtimerList.count; x++) { pNode = dListFindByIndex(&pGkClient->timerList, x); pTimer = (OOTimer*)pNode->data; cbData = (ooGkClientTimerCb*)pTimer->cbData; if(cbData->timerType & OO_ARQ_TIMER && cbData->pAdmInfo->call->callReference == call->callReference) { memFreePtr(&pGkClient->ctxt, pTimer->cbData); ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer); break; } } for(x=0; xcallsPendingList.count; x++) { pNode = dListFindByIndex(&pGkClient->callsPendingList, x); pAdmInfo = (RasCallAdmissionInfo*)pNode->data; if(pAdmInfo->call->callReference == call->callReference) { dListRemove(&pGkClient->callsPendingList, pNode); memFreePtr(&pGkClient->ctxt, pAdmInfo); memFreePtr(&pGkClient->ctxt, pNode); break; } } ast_mutex_unlock(&pGkClient->Lock); return OO_OK; } /* * TODO: In case of GkErr, if GkMode is DiscoverGatekeeper, * need to cleanup gkrouted calls, and discover another * gatekeeper. * Note: This function returns OO_FAILED, when we can not recover from * the failure. */ int ooGkClientHandleClientOrGkFailure(ooGkClient *pGkClient) { if(pGkClient->state == GkClientFailed) { OOTRACEERR1("Error: Internal Failure in GkClient. Closing " "GkClient\n"); ooGkClientDestroy(); return OO_FAILED; } else if(pGkClient->state == GkClientGkErr) { OOTRACEERR1("Error: Gatekeeper error. Either Gk not responding or " "Gk sending invalid messages\n"); if(pGkClient->gkMode == RasUseSpecificGatekeeper) { OOTRACEERR1("Error: Gatekeeper error detected. Closing GkClient as " "Gk mode is UseSpecifcGatekeeper\n"); ooGkClientDestroy(); return OO_FAILED; } else{ OOTRACEERR1("Error: Gatekeeper error detected. Closing GkClient. NEED" " to implement recovery by rediscovering another gk\n"); ooGkClientDestroy(); return OO_FAILED; } } return OO_FAILED; } /** * TODO: This fuction might not work properly in case of additive registrations * For example we registrered 10 aliases and gatekeeper accepted 8 of them. * Now we want to register another two new aliases(not out of those first 10). * Gk responds with RCF with empty terminalAlias field thus indicating both * the aliases were accepted. If this function is called, it will even mark * the earlier two unregistered aliases as registered. We will have to * maintain a separete list of aliases being sent in RRQ for this. */ int ooGkClientUpdateRegisteredAliases (ooGkClient *pGkClient, H225_SeqOfH225AliasAddress *pAddresses, OOBOOL registered) { int i=0, j, k; DListNode* pNode=NULL; ooAliases *pAlias=NULL; H225AliasAddress *pAliasAddress=NULL; H225TransportAddress *pTransportAddrss=NULL; char value[MAXFILENAME]; OOBOOL bAdd = FALSE; if(!pAddresses) { /* All aliases registered/unregistsred */ pAlias = gH323ep.aliases; while(pAlias) { pAlias->registered = registered?TRUE:FALSE; pAlias = pAlias->next; } return OO_OK; } /* Mark aliases as registered/unregistered*/ if(pAddresses->count<=0) return OO_FAILED; for(i=0; i<(int)pAddresses->count; i++) { pNode = dListFindByIndex (pAddresses, i); if(!pNode) { OOTRACEERR1("Error:Invalid alias list passed to " "ooGkClientUpdateRegisteredAliases\n"); continue; } pAliasAddress = (H225AliasAddress*)pNode->data; if(!pAliasAddress){ OOTRACEERR1("Error:Invalid alias list passed to " "ooGkClientUpdateRegisteredAliases\n"); continue; } switch(pAliasAddress->t) { case T_H225AliasAddress_dialedDigits: pAlias = ooH323GetAliasFromList(gH323ep.aliases, T_H225AliasAddress_dialedDigits, (char*)pAliasAddress->u.dialedDigits); if(pAlias) { pAlias->registered = registered?TRUE:FALSE; } else{ bAdd = registered?TRUE:FALSE; } break; case T_H225AliasAddress_h323_ID: for(j=0, k=0; j<(int)pAliasAddress->u.h323_ID.nchars && (ku.h323_ID.data[j] < 256) { value[k++] = (char) pAliasAddress->u.h323_ID.data[j]; } } value[k] = '\0'; pAlias = ooH323GetAliasFromList(gH323ep.aliases, T_H225AliasAddress_h323_ID, value); if(pAlias) { pAlias->registered = registered?TRUE:FALSE; } else{ bAdd = registered?TRUE:FALSE; } break; case T_H225AliasAddress_url_ID: pAlias = ooH323GetAliasFromList(gH323ep.aliases, T_H225AliasAddress_url_ID, (char*)pAliasAddress->u.url_ID); if(pAlias) { pAlias->registered = registered?TRUE:FALSE; } else{ bAdd = registered?TRUE:FALSE; } break; case T_H225AliasAddress_transportID: pTransportAddrss = pAliasAddress->u.transportID; if(pTransportAddrss->t != T_H225TransportAddress_ipAddress) { OOTRACEERR1("Error:Alias transportID not IP address\n"); break; } sprintf(value, "%d.%d.%d.%d:%d", pTransportAddrss->u.ipAddress->ip.data[0], pTransportAddrss->u.ipAddress->ip.data[1], pTransportAddrss->u.ipAddress->ip.data[2], pTransportAddrss->u.ipAddress->ip.data[3], pTransportAddrss->u.ipAddress->port); pAlias = ooH323GetAliasFromList(gH323ep.aliases, T_H225AliasAddress_transportID, value); if(pAlias) { pAlias->registered = registered?TRUE:FALSE; } else{ bAdd = registered?TRUE:FALSE; } break; case T_H225AliasAddress_email_ID: pAlias = ooH323GetAliasFromList(gH323ep.aliases, T_H225AliasAddress_email_ID, (char*) pAliasAddress->u.email_ID); if(pAlias) { pAlias->registered = registered?TRUE:FALSE; } else{ bAdd = registered?TRUE:FALSE; } break; default: OOTRACEERR1("Error:Unhandled alias type found in registered " "aliases\n"); } if(bAdd) { pAlias = ooH323AddAliasToList(&gH323ep.aliases, &gH323ep.ctxt, pAliasAddress); if(pAlias){ pAlias->registered = registered?TRUE:FALSE; } else{ OOTRACEERR2("Warning:Could not add registered alias of " "type %d to list.\n", pAliasAddress->t); } bAdd = FALSE; } pAlias = NULL; } return OO_OK; } asterisk-11.7.0/addons/ooh323c/src/ooSocket.c0000644000175000007640000005316111775107640020534 0ustar sharkyjerryweb/* * 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 "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 369602 $") #include "asterisk/io.h" #include "asterisk/lock.h" #include "asterisk/utils.h" #include "asterisk/network.h" #include "asterisk/netsock2.h" #include "asterisk/config.h" #include "ooSocket.h" #include "ootrace.h" #include "ooh323ep.h" /** Global endpoint structure */ extern OOH323EndPoint gH323ep; #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 socklen_t OOSOCKLEN; #endif int ooSocketCreate (OOSOCKET* psocket, int family) { int on; OOSOCKET sock; int keepalive = 1; #ifdef __linux__ int keepcnt = 24, keepidle = 120, keepintvl = 30; #endif struct linger linger; if (family == 6) { sock = socket (AF_INET6, SOCK_STREAM, 0); } else { 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; } setsockopt (sock, SOL_SOCKET, SO_KEEPALIVE, (const char *)&keepalive, sizeof(keepalive)); #ifdef __linux__ setsockopt (sock, SOL_TCP, TCP_KEEPCNT, &keepcnt, sizeof(keepcnt)); setsockopt (sock, SOL_TCP, TCP_KEEPIDLE, &keepidle, sizeof(keepidle)); setsockopt (sock, SOL_TCP, TCP_KEEPINTVL, &keepintvl, sizeof(keepintvl)); #endif *psocket = sock; return ASN_OK; } int ooSocketCreateUDP (OOSOCKET* psocket, int family) { int on; OOSOCKET sock; if (family == 6) sock = socket (AF_INET6, SOCK_DGRAM, 0); else 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; } // may be will use later /* 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 ast_sockaddr m_addr; memset(&m_addr, 0, sizeof(m_addr)); if (socket == OOSOCKET_INVALID) { OOTRACEERR1("Error:Invalid socket passed to bind\n"); return ASN_E_INVSOCKET; } ast_sockaddr_copy(&m_addr, &addr); ast_sockaddr_set_port(&m_addr, port); if (ast_bind(socket, &m_addr) < 0) { if (errno != EADDRINUSE) { perror ("bind"); OOTRACEERR2("Error:Bind failed, error: %d\n", errno); } return ASN_E_INVSOCKET; } return ASN_OK; } int ooSocketGetSockName(OOSOCKET socket, struct sockaddr_in *name, socklen_t *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 *family) { int ret=ASN_OK; struct ast_sockaddr addr; const char *host=NULL; ret = ast_getsockname(socket, &addr); if(ret != 0) return ASN_E_INVSOCKET; host = ast_sockaddr_stringify_addr(&addr); if(host && strlen(host) < (unsigned)len) strcpy(ip, host); else{ OOTRACEERR1("Error:Insufficient buffer for ip address - " "ooSocketGetIpAndPort\n"); return -1; } *port = ast_sockaddr_port(&addr); if (family) { if (ast_sockaddr_is_ipv6(&addr) && !ast_sockaddr_is_ipv4_mapped(&addr)) *family = 6; else *family = 4; } 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, char* destAddr, int* destPort) { struct ast_sockaddr addr; char* host = NULL; if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET; if (pNewSocket == 0) return ASN_E_INVPARAM; *pNewSocket = ast_accept (socket, &addr); if (*pNewSocket <= 0) return ASN_E_INVSOCKET; if (destAddr != 0) { if ((host = ast_sockaddr_stringify_addr(&addr)) != NULL); strncpy(destAddr, host, strlen(host)); } if (destPort != 0) *destPort = ast_sockaddr_port(&addr); return ASN_OK; } int ooSocketConnect (OOSOCKET socket, const char* host, int port) { struct ast_sockaddr m_addr; if (socket == OOSOCKET_INVALID) { return ASN_E_INVSOCKET; } memset (&m_addr, 0, sizeof (m_addr)); ast_parse_arg(host, PARSE_ADDR, &m_addr); ast_sockaddr_set_port(&m_addr, port); if (ast_connect(socket, &m_addr)) { 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; const 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, (socklen_t *) &addrlen)) == -1) return ASN_E_INVSOCKET; if(remoteport) *remoteport = ntohs(m_addr.sin_port); if(remotehost) { host = ast_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 ooSocketPoll(struct pollfd *pfds, int nfds, int timeout) { return ast_poll(pfds, nfds, timeout); } int ooPDRead(struct pollfd *pfds, int nfds, int fd) { int i; for (i=0;ih_addrtype == AF_INET6) { struct in6_addr i; memcpy(&i, hp->h_addr, sizeof(i)); strcpy(pIPAddrs, (inet_ntop(AF_INET6, &i, hostname, sizeof(hostname))) == NULL ? "::1" : inet_ntop(AF_INET6, &i, hostname, sizeof(hostname))); } else { struct in_addr i; memcpy(&i, hp->h_addr, sizeof(i)); strcpy(pIPAddrs, (ast_inet_ntoa(i) == NULL) ? "127.0.0.1" : ast_inet_ntoa(i)); } } else { return -1; } } 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, unsigned 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; struct sockaddr_in sin; OOTRACEDBGA1("Retrieving local interfaces\n"); if(ooSocketCreateUDP(&sock, 4)!= 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; } memcpy(&sin, &ifReq.ifr_addr, sizeof(struct sockaddr_in)); strcpy(addr, ast_inet_ntoa(sin.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; } memcpy(&sin, &ifReq.ifr_netmask, sizeof(struct sockaddr_in)); strcpy(mask, ast_inet_ntoa(sin.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 asterisk-11.7.0/addons/ooh323c/src/ooCmdChannel.h0000644000175000007640000000443411274375744021312 0ustar sharkyjerryweb/* * 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(void); EXTERN int ooCreateCallCmdConnection(OOH323CallData*); /** * 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(void); EXTERN int ooCloseCallCmdConnection(OOH323CallData*); /** * 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); EXTERN int ooWriteCallStackCommand(OOH323CallData* call, 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(void); EXTERN int ooReadAndProcessCallStackCommand(OOH323CallData*); /** * @} */ #ifdef __cplusplus } #endif #endif asterisk-11.7.0/addons/ooh323c/src/ooCmdChannel.c0000644000175000007640000003166311775276637021320 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "asterisk/utils.h" #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; ast_mutex_t gCmdChanLock; int ooCreateCmdConnection() { int ret = 0; int thePipe[2]; if ((ret = pipe(thePipe)) == -1) { return OO_FAILED; } ast_mutex_init(&gCmdChanLock); gH323ep.cmdSock = dup(thePipe[0]); close(thePipe[0]); gCmdChan = dup(thePipe[1]); close(thePipe[1]); return OO_OK; } int ooCreateCallCmdConnection(OOH323CallData* call) { int ret = 0; int thePipe[2]; OOTRACEINFO2("INFO: create cmd connect for call: %lx\n", call); call->CmdChanLock = calloc(1, sizeof(ast_mutex_t)); ast_mutex_init(call->CmdChanLock); if ((ret = socketpair(PF_LOCAL, SOCK_STREAM, 0, thePipe)) == -1) { ast_mutex_destroy(call->CmdChanLock); free(call->CmdChanLock); call->CmdChanLock = NULL; return OO_FAILED; } ast_mutex_lock(call->CmdChanLock); call->cmdSock = thePipe[0]; call->CmdChan = thePipe[1]; ast_mutex_unlock(call->CmdChanLock); return OO_OK; } int ooCloseCmdConnection() { close(gH323ep.cmdSock); gH323ep.cmdSock = 0; close(gCmdChan); gCmdChan = 0; ast_mutex_destroy(&gCmdChanLock); return OO_OK; } int ooCloseCallCmdConnection(OOH323CallData* call) { ast_mutex_lock(call->CmdChanLock); close(call->cmdSock); call->cmdSock = 0; close(call->CmdChan); call->CmdChan = 0; ast_mutex_unlock(call->CmdChanLock); ast_mutex_destroy(call->CmdChanLock); free(call->CmdChanLock); call->CmdChanLock = NULL; return OO_OK; } int ooWriteStackCommand(OOStackCommand *cmd) { ast_mutex_lock(&gCmdChanLock); if (write(gCmdChan, (char*)cmd, sizeof(OOStackCommand)) == -1) { ast_mutex_unlock(&gCmdChanLock); return OO_FAILED; } ast_mutex_unlock(&gCmdChanLock); return OO_OK; } int ooWriteCallStackCommand(OOH323CallData* call, OOStackCommand *cmd) { unsigned char buffer[MAXMSGLEN]; unsigned char* bPoint; memcpy(buffer, cmd, sizeof(OOStackCommand)); bPoint = buffer + sizeof(OOStackCommand); if (cmd->param1 && cmd->plen1 > 0) { if (bPoint + cmd->plen1 >= buffer + MAXMSGLEN) return OO_FAILED; memcpy(bPoint, cmd->param1, cmd->plen1); bPoint += cmd->plen1; } if (cmd->param2 && cmd->plen2 > 0) { if (bPoint + cmd->plen2 >= buffer + MAXMSGLEN) return OO_FAILED; memcpy(bPoint, cmd->param2, cmd->plen2); bPoint += cmd->plen2; } if (cmd->param3 && cmd->plen3 > 0) { if (bPoint + cmd->plen3 >= buffer + MAXMSGLEN) return OO_FAILED; memcpy(bPoint, cmd->param3, cmd->plen3); bPoint += cmd->plen3; } ast_mutex_lock(call->CmdChanLock); if (write(call->CmdChan, buffer, bPoint - buffer) == -1) { ast_mutex_unlock(call->CmdChanLock); return OO_FAILED; } ast_mutex_unlock(call->CmdChanLock); return OO_OK; } int ooReadAndProcessStackCommand() { OOH323CallData *pCall = NULL; unsigned char buffer[MAXMSGLEN]; int i, recvLen = 0; OOStackCommand cmd; memset(&cmd, 0, sizeof(OOStackCommand)); ast_mutex_lock(&gCmdChanLock); recvLen = read(gH323ep.cmdSock, buffer, MAXMSGLEN); ast_mutex_unlock(&gCmdChanLock); 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 && cmd.type != OO_CMD_STOPMONITOR) { 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); ooH323NewCall ((char*)cmd.param2); break; case OO_CMD_MANUALPROGRESS: 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 { ooSendProgress(ooFindCallByToken((char*)cmd.param1)); } 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: OOTRACEINFO3("Processing Hang call command %s with q931 cause %d\n", (char*)cmd.param1, *(int *) cmd.param3); ooH323HangCall((char*)cmd.param1, *(OOCallClearReason*)cmd.param2, *(int *) cmd.param3); 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; } int ooReadAndProcessCallStackCommand(OOH323CallData* call) { unsigned char buffer[MAXMSGLEN]; unsigned char *bPoint; int recvLen = 0; OOStackCommand cmd; memset(&cmd, 0, sizeof(OOStackCommand)); if (call->CmdChanLock) { ast_mutex_lock(call->CmdChanLock); recvLen = read(call->cmdSock, buffer, MAXMSGLEN); ast_mutex_unlock(call->CmdChanLock); } else { recvLen = read(call->cmdSock, buffer, MAXMSGLEN); } if(recvLen <= 0) { OOTRACEERR1("Error:Failed to read CMD message\n"); return OO_FAILED; } bPoint = buffer; while (bPoint < buffer + recvLen - sizeof(OOStackCommand)) { memcpy(&cmd, bPoint, sizeof(OOStackCommand)); bPoint += sizeof(OOStackCommand); if (cmd.plen1 > 0) { cmd.param1 = malloc(cmd.plen1 + 1); if (!cmd.param1) return OO_FAILED; memset(cmd.param1, 0, cmd.plen1 + 1); memcpy(cmd.param1, bPoint, cmd.plen1); bPoint += cmd.plen1; } if (cmd.plen2 > 0) { cmd.param2 = malloc(cmd.plen2 + 1); if (!cmd.param2) return OO_FAILED; memset(cmd.param2, 0, cmd.plen2 + 1); memcpy(cmd.param2, bPoint, cmd.plen2); bPoint += cmd.plen2; } if (cmd.plen3 > 0) { cmd.param3 = malloc(cmd.plen3 + 1); if (!cmd.param3) return OO_FAILED; memset(cmd.param3, 0, cmd.plen3 + 1); memcpy(cmd.param3, bPoint, cmd.plen3); bPoint += cmd.plen3; } 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_MANUALPROGRESS: ooSendProgress(call); break; case OO_CMD_MANUALRINGBACK: if(OO_TESTFLAG(gH323ep.flags, OO_M_MANUALRINGBACK)) { ooSendAlerting(call); if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) { ooSendConnect(call); } } break; case OO_CMD_ANSCALL: ooSendConnect(call); 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 with q931 cause %d\n", (char*)cmd.param1); ooH323HangCall((char*)cmd.param1, *(OOCallClearReason*)cmd.param2, *(int *) cmd.param3); break; case OO_CMD_SENDDIGIT: if(call->jointDtmfMode & OO_CAP_DTMF_H245_alphanumeric) { ooSendH245UserInputIndication_alphanumeric( call, (const char*)cmd.param2); } else if(call->jointDtmfMode & OO_CAP_DTMF_H245_signal) { ooSendH245UserInputIndication_signal( call, (const char*)cmd.param2); } else { ooQ931SendDTMFAsKeyPadIE(call, (const char*)cmd.param2); } break; case OO_CMD_REQMODE: OOTRACEINFO3("Processing RequestMode command %s, requested mode is %d\n", (char *)cmd.param1, *(int *)cmd.param2); ooSendRequestMode(call, *(int *)cmd.param2); break; case OO_CMD_SETANI: OOTRACEINFO3("Processing SetANI command %s, ani is %s\n", (char *)cmd.param1, (char *)cmd.param2); if(cmd.param2) { strncpy(call->ourCallerId, cmd.param2, sizeof(call->ourCallerId)-1); call->ourCallerId[sizeof(call->ourCallerId)-1] = '\0'; } break; case OO_CMD_UPDLC: OOTRACEINFO4("Processing UpdLC command %s, localIP is %s, port is %d\n", (char *)cmd.param1, (char *)cmd.param2, *(int *)cmd.param3); if (cmd.param2) { ooUpdateAllLogicalChannels(call, (char *)cmd.param2, *(int *)cmd.param3); } break; default: OOTRACEERR1("ERROR:Unknown command\n"); } } if (cmd.param1) { ast_free(cmd.param1); } if (cmd.param2) { ast_free(cmd.param2); } if (cmd.param3) { ast_free(cmd.param3); } } return OO_OK; } asterisk-11.7.0/addons/ooh323c/src/ooTimer.c0000644000175000007640000001174312011217215020344 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "ootypes.h" #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 (pctxt, 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 ret = OO_OK; 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); ret = (*pTimer->timeoutCB)(pTimer->cbData); if (!pTimer->reRegister) { ooTimerDelete (pctxt, pList, pTimer); } } else break; } return (void)ret; } 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 (pctxt, 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; } asterisk-11.7.0/addons/ooh323c/src/ooCalls.c0000644000175000007640000007042311770406344020340 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #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; extern ast_mutex_t callListLock; extern ast_mutex_t newCallLock; OOH323CallData* ooCreateCall(char* type, char*callToken) { OOH323CallData *call=NULL; OOCTXT *pctxt=NULL; OOCTXT *msgctxt=NULL; pctxt = newContext(); if(!pctxt) { OOTRACEERR1("ERROR:Failed to create OOCTXT for new call\n"); return NULL; } msgctxt = newContext(); if(!msgctxt) { OOTRACEERR1("ERROR:Failed to create OOCTXT for new call\n"); return NULL; } ast_mutex_lock(&newCallLock); /* call = (OOH323CallData*)memAlloc(&gH323ep.ctxt, sizeof(OOH323CallData)); */ call = (OOH323CallData*)memAlloc(pctxt, sizeof(OOH323CallData)); ast_mutex_unlock(&newCallLock); if(!call) { OOTRACEERR1("ERROR:Memory - ooCreateCall - call\n"); return NULL; } memset(call, 0, sizeof(OOH323CallData)); ast_cond_init(&call->gkWait, NULL); ast_mutex_init(&call->GkLock); ast_mutex_init(&call->Lock); call->pctxt = pctxt; call->msgctxt = msgctxt; 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->fsSent = FALSE; // May 20090713. Fix it for Video session OO_SETFLAG(call->flags, OO_M_AUDIOSESSION); 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) { ast_mutex_lock(&callListLock); 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; } ast_mutex_unlock(&callListLock); 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_REMOVED) { OOTRACEINFO2("Call already removed %s\n", call->callToken); return OO_OK; } if (call->callIdentifier.guid.numocts == 0) call->callState = OO_CALL_CLEARED; if(!call->pH225Channel || call->pH225Channel->sock ==0) { call->callState = OO_CALL_CLEARED; } if(call->callState == OO_CALL_CLEARED || call->callState == OO_CALL_CLEAR_RELEASESENT) { ooCleanCall(call); call->callState = OO_CALL_REMOVED; 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(!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 || !gH323ep.callList) return OO_OK; ast_mutex_lock(&callListLock); OOTRACEINFO3("Removing call %lx: %s\n", call, call->callToken); 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; } ast_mutex_unlock(&callListLock); 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); } if (call->rtpMask) { ast_mutex_lock(&call->rtpMask->lock); call->rtpMask->inuse--; ast_mutex_unlock(&call->rtpMask->lock); if ((call->rtpMask->inuse) == 0) { regfree(&call->rtpMask->regex); ast_mutex_destroy(&call->rtpMask->lock); free(call->rtpMask); } } if ((pctxt = call->msgctxt) != NULL) { freeContext(pctxt); free(pctxt); call->msgctxt = NULL; } /* May !!!! Fix it !! */ /* free(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 ooCallAddG726Capability(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 ooCallAddAMRNBCapability(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 ooCallAddSpeexCapability(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 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 ooCallEnableDTMFCISCO(OOH323CallData *call, int dynamicRTPPayloadType) { return ooCapabilityEnableDTMFCISCO(call, dynamicRTPPayloadType); } int ooCallDisableDTMFCISCO(OOH323CallData *call) { return ooCapabilityDisableDTMFCISCO(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(const char *callToken) { OOH323CallData *call; if(!callToken) { OOTRACEERR1("ERROR:Invalid call token passed - ooFindCallByToken\n"); return NULL; } ast_mutex_lock(&callListLock); if(!gH323ep.callList) { OOTRACEERR1("ERROR: Empty calllist - ooFindCallByToken failed\n"); ast_mutex_unlock(&callListLock); 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); ast_mutex_unlock(&callListLock); return NULL; } ast_mutex_unlock(&callListLock); OOTRACEINFO3("INFO: FinCall returned %lx for call: %s\n", call, callToken); 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); } } } if(type == OO_CAP_TYPE_DATA) { if(!ooGetLogicalChannel(call, 3, dir)) { sessionID = 3; } 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 data 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)); } asterisk-11.7.0/addons/ooh323c/src/ooStackCmds.c0000644000175000007640000003565411775276637021204 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #include "asterisk/utils.h" #include "ooStackCmds.h" #include "ooh323ep.h" #include "ooCalls.h" #include "ooCmdChannel.h" extern OOSOCKET gCmdChan; extern ast_mutex_t newCallLock; static int counter = 1; int ooGenerateOutgoingCallToken (char *callToken, size_t size) { char aCallToken[200]; int ret = 0; ast_mutex_lock(&newCallLock); sprintf (aCallToken, "ooh323c_o_%d", counter++); if (counter > OO_MAX_CALL_TOKEN) counter = 1; ast_mutex_unlock(&newCallLock); if ((strlen(aCallToken)+1) < size) strcpy (callToken, aCallToken); else { ret = OO_FAILED; } return ret; } int isRunning(char *callToken) { OOH323CallData *call; if((call = ooFindCallByToken(callToken))) if (call->Monitor) return 1; return 0; } 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 ooRunCall (const char* dest, char* callToken, size_t bufsiz, ooCallOptions *opts) { OOStackCommand cmd; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != OO_OK) return OO_STKCMD_CONNECTIONERR; } if(!callToken) return OO_STKCMD_INVALIDPARAM; 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.plen1 = strlen(dest); cmd.param2 = (void*) malloc(strlen(callToken)+1); if(!cmd.param2) { free(cmd.param1); return OO_STKCMD_MEMERR; } strcpy((char*)cmd.param2, callToken); cmd.plen2 = strlen(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)); cmd.plen3 = sizeof(ooCallOptions); } if(ooWriteCallStackCommand(call, &cmd) != OO_OK) { free(cmd.param1); free(cmd.param2); if(cmd.param3) free(cmd.param3); return OO_STKCMD_WRITEERR; } free(cmd.param1); free(cmd.param2); if(cmd.param3) free(cmd.param3); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooManualRingback(const char *callToken) { OOStackCommand cmd; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != 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); cmd.plen1 = strlen(callToken); if(ooWriteCallStackCommand(call,&cmd) != OO_OK) { free(cmd.param1); return OO_STKCMD_WRITEERR; } free(cmd.param1); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooManualProgress(const char *callToken) { OOStackCommand cmd; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != OO_OK) return OO_STKCMD_CONNECTIONERR; } if (call->h225version < 4) return OO_STKCMD_SUCCESS; memset(&cmd, 0, sizeof(OOStackCommand)); cmd.type = OO_CMD_MANUALPROGRESS; cmd.param1 = (void*) malloc(strlen(callToken)+1); if(!cmd.param1) { return OO_STKCMD_MEMERR; } strcpy((char*)cmd.param1, callToken); cmd.plen1 = strlen(callToken); if(ooWriteCallStackCommand(call, &cmd) != OO_OK) { free(cmd.param1); return OO_STKCMD_WRITEERR; } free(cmd.param1); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooAnswerCall(const char *callToken) { OOStackCommand cmd; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != 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); cmd.plen1 = strlen(callToken); if(ooWriteCallStackCommand(call, &cmd) != OO_OK) { free(cmd.param1); return OO_STKCMD_WRITEERR; } free(cmd.param1); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooForwardCall(const char* callToken, char *dest) { OOStackCommand cmd; OOH323CallData *call; if(!callToken || !dest) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != 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); cmd.plen1 = strlen(callToken); strcpy((char*)cmd.param2, dest); cmd.plen2 = strlen(dest); if(ooWriteCallStackCommand(call, &cmd) != OO_OK) { free(cmd.param1); free(cmd.param2); return OO_STKCMD_WRITEERR; } free(cmd.param1); free(cmd.param2); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooHangCall(const char* callToken, OOCallClearReason reason, int q931cause) { OOStackCommand cmd; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != 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)); cmd.param3 = (void*) malloc(sizeof(int)); if(!cmd.param1 || !cmd.param2 || !cmd.param3) { if(cmd.param1) free(cmd.param1); /* Release memory */ if(cmd.param2) free(cmd.param2); if(cmd.param3) free(cmd.param3); return OO_STKCMD_MEMERR; } strcpy((char*)cmd.param1, callToken); cmd.plen1 = strlen(callToken); *((OOCallClearReason*)cmd.param2) = reason; cmd.plen2 = sizeof(OOCallClearReason); *(int *)cmd.param3 = q931cause; cmd.plen3 = sizeof(int); if(ooWriteCallStackCommand(call, &cmd) != OO_OK) { free(cmd.param1); free(cmd.param2); free(cmd.param3); return OO_STKCMD_WRITEERR; } free(cmd.param1); free(cmd.param2); free(cmd.param3); 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; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != 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); cmd.plen1 = strlen(callToken); strcpy((char*)cmd.param2, dtmf); cmd.plen2 = strlen(dtmf); if(ooWriteCallStackCommand(call,&cmd) != OO_OK) { free(cmd.param1); free(cmd.param2); return OO_STKCMD_WRITEERR; } free(cmd.param1); free(cmd.param2); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooSetANI(const char *callToken, const char* ani) { OOStackCommand cmd; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != OO_OK) return OO_STKCMD_CONNECTIONERR; } memset(&cmd, 0, sizeof(OOStackCommand)); cmd.type = OO_CMD_SETANI; cmd.param1 = (void*) malloc(strlen(callToken)+1); cmd.param2 = (void*) malloc(strlen(ani)+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); cmd.plen1 = strlen(callToken); strcpy((char*)cmd.param2, ani); cmd.plen2 = strlen(ani); if(ooWriteCallStackCommand(call,&cmd) != OO_OK) { free(cmd.param1); free(cmd.param2); return OO_STKCMD_WRITEERR; } free(cmd.param1); free(cmd.param2); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooUpdateLogChannels(const char *callToken, const char* localIP, int port) { OOStackCommand cmd; OOH323CallData *call; if (!callToken) { return OO_STKCMD_INVALIDPARAM; } if (!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if (localIP == NULL) { return OO_STKCMD_INVALIDPARAM; } if (call->CmdChan == 0) { if (ooCreateCallCmdConnection(call) != OO_OK) { return OO_STKCMD_CONNECTIONERR; } } memset(&cmd, 0, sizeof(OOStackCommand)); cmd.type = OO_CMD_UPDLC; cmd.param1 = ast_malloc(strlen(callToken) + 1); cmd.param2 = ast_malloc(strlen(localIP) + 1); cmd.param3 = ast_malloc(sizeof(int) + 1); if (!cmd.param1 || !cmd.param2 || !cmd.param3) { if (cmd.param1) { ast_free(cmd.param1); /* Release memory */ } if (cmd.param2) { ast_free(cmd.param2); } if (cmd.param3) { ast_free(cmd.param3); } return OO_STKCMD_MEMERR; } strcpy((char*)cmd.param1, callToken); cmd.plen1 = strlen(callToken); strcpy((char*)cmd.param2, localIP); cmd.plen2 = strlen(localIP); *((int *)cmd.param3) = port; cmd.plen3 = sizeof(int) + 1; if (ooWriteCallStackCommand(call, &cmd) != OO_OK) { ast_free(cmd.param1); ast_free(cmd.param2); ast_free(cmd.param3); return OO_STKCMD_WRITEERR; } ast_free(cmd.param1); ast_free(cmd.param2); ast_free(cmd.param3); return OO_STKCMD_SUCCESS; } OOStkCmdStat ooRequestChangeMode(const char *callToken, int isT38Mode) { OOStackCommand cmd; OOH323CallData *call; if(!callToken) { return OO_STKCMD_INVALIDPARAM; } if(!(call = ooFindCallByToken(callToken))) { return OO_STKCMD_INVALIDPARAM; } if(call->CmdChan == 0) { if(ooCreateCallCmdConnection(call) != OO_OK) return OO_STKCMD_CONNECTIONERR; } memset(&cmd, 0, sizeof(OOStackCommand)); cmd.type = OO_CMD_REQMODE; cmd.param1 = (void*) malloc(strlen(callToken)+1); cmd.param2 = (void*) malloc(sizeof(int)); 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); cmd.plen1 = strlen(callToken); *((int *) cmd.param2) = isT38Mode; cmd.plen2 = sizeof(int); if(ooWriteCallStackCommand(call,&cmd) != OO_OK) { free(cmd.param1); free(cmd.param2); return OO_STKCMD_WRITEERR; } free(cmd.param1); free(cmd.param2); 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"; } } asterisk-11.7.0/addons/ooh323c/src/memheap.h0000644000175000007640000000347511274375744020400 0ustar sharkyjerryweb/* * 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; ast_mutex_t pLock; } 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__ */ asterisk-11.7.0/addons/ooh323c/src/rtctype.c0000644000175000007640000001710111352772022020423 0ustar sharkyjerryweb/* * 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 "asterisk.h" #include "asterisk/lock.h" #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 }; asterisk-11.7.0/addons/ooh323c/README0000644000175000007640000000623711222440006016654 0ustar sharkyjerrywebCopyright (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 -duration -interval 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. asterisk-11.7.0/addons/ooh323cDriver.h0000644000175000007640000000330411527334432017326 0ustar sharkyjerryweb/* * 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" #include "asterisk/format.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) #define H323_DTMF_CISCO (1 << 5) #define H323_DTMF_INBANDRELAX (1 << 8) struct h323_pvt; int ooh323c_start_stack_thread(void); int ooh323c_stop_stack_thread(void); int ooh323c_start_call_thread(ooCallData *call); int ooh323c_stop_call_thread(ooCallData *call); int ooh323c_set_capability (struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec); struct ast_format *convertH323CapToAsteriskCap(int cap, struct ast_format *format); int ooh323c_set_capability_for_call (ooCallData *call, struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec, int t38support, int g729onlyA); #endif asterisk-11.7.0/addons/app_saycountpl.c0000644000175000007640000000703611707610231020026 0ustar sharkyjerryweb/* * 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 no deprecated say.conf ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 352348 $") #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 Say Polish counting words. 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. Example: SayCountPL(zloty,zlote,zlotych,122) will give: zlote ***/ 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, ast_channel_language(chan)); d = ast_waitstream(chan,""); } else if (((num % 10) >= 2) && ((num % 10) <= 4 ) && ((num % 100) < 10 || (num % 100) > 20)) { ast_streamfile(chan, word2, ast_channel_language(chan)); d = ast_waitstream(chan, ""); } else { ast_streamfile(chan, word5, ast_channel_language(chan)); 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, "%30d", &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"); asterisk-11.7.0/addons/Makefile0000644000175000007640000000564711426062346016275 0ustar sharkyjerryweb# # 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 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_C_MODS:=app_mysql \ app_saycountpl \ cdr_mysql \ chan_mobile \ chan_ooh323 \ format_mp3 \ res_config_mysql all: check_mp3 _all check_mp3: ifeq ($(filter format_mp3,$(MENUSELECT_ADDONS)),) @if [ ! -f mp3/Makefile ] ; then \ echo ; \ echo "**************************************************************" ; \ echo "*** ***" ; \ echo "*** ---> READ THIS OR YOUR BUILD WILL FAIL <--- ***" ; \ echo "*** ***" ; \ echo "*** format_mp3 has been selected to be installed, but the ***" ; \ echo "*** mp3 decoder library has not yet been downloaded into ***" ; \ echo "*** the source tree. To do so, please run the following ***" ; \ echo "*** command: ***" ; \ echo "*** ***" ; \ echo "*** $$ contrib/scripts/get_mp3_source.sh ***" ; \ echo "*** ***" ; \ echo "**************************************************************" ; \ echo ; \ fi endif include $(ASTTOPDIR)/Makefile.moddir_rules clean:: if [ -f mp3/Makefile ] ; then $(MAKE) -C mp3 clean ; fi 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 $(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_ooh323) .PHONY: check_mp3 asterisk-11.7.0/addons/chan_ooh323.h0000644000175000007640000000722211522553062017000 0ustar sharkyjerryweb/* * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #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_engine.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 "asterisk/format.h" #include "asterisk/format_cap.h" #include "asterisk/udptl.h" #include "ootypes.h" #include "ooUtils.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, struct ast_format *fmt, int txframes); void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt); int ooh323_update_capPrefsOrderForCall (ooCallData *call, struct ast_codec_pref *prefs); int ooh323_convertAsteriskCapToH323Cap(struct ast_format *format); 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); void setup_udptl_connection(ooCallData *call, const char *remoteIp, int remotePort); void close_udptl_connection(ooCallData *call); EXTERN char *handle_cli_ooh323_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); #endif asterisk-11.7.0/addons/ooh323cDriver.c0000644000175000007640000006167611775134255017347 0ustar sharkyjerryweb/* * 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.h" #include "asterisk/lock.h" #include "asterisk/pbx.h" #include "asterisk/logger.h" #undef AST_BACKGROUND_STACKSIZE #define AST_BACKGROUND_STACKSIZE 768 * 1024 #define SEC_TO_HOLD_THREAD 24 extern struct ast_module *myself; extern OOBOOL gH323Debug; extern OOH323EndPoint gH323ep; /* ooh323c stack thread. */ static pthread_t ooh323c_thread = AST_PTHREADT_NULL; static pthread_t ooh323cmd_thread = AST_PTHREADT_NULL; static int grxframes = 240; static int gtxframes = 20; static struct callthread { ast_mutex_t lock; int thePipe[2]; OOBOOL inUse; ooCallData* call; struct callthread *next, *prev; } *callThreads = NULL; AST_MUTEX_DEFINE_STATIC(callThreadsLock); 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); int ooh323c_start_receive_datachannel(ooCallData *call, ooLogicalChannel *pChannel); int ooh323c_start_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChannel); int ooh323c_stop_receive_datachannel(ooCallData *call, ooLogicalChannel *pChannel); int ooh323c_stop_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChannel); void* ooh323c_stack_thread(void* dummy); void* ooh323c_cmd_thread(void* dummy); void* ooh323c_call_thread(void* dummy); int ooh323c_set_aliases(ooAliases * aliases); void* ooh323c_stack_thread(void* dummy) { ooMonitorChannels(); return dummy; } void* ooh323c_cmd_thread(void* dummy) { ooMonitorCmdChannels(); return dummy; } void* ooh323c_call_thread(void* dummy) { struct callthread* mycthread = (struct callthread *)dummy; struct pollfd pfds[1]; char c; int res = 0; do { ooMonitorCallChannels((ooCallData*)mycthread->call); mycthread->call = NULL; mycthread->prev = NULL; mycthread->inUse = FALSE; ast_mutex_lock(&callThreadsLock); mycthread->next = callThreads; callThreads = mycthread; if (mycthread->next) mycthread->next->prev = mycthread; ast_mutex_unlock(&callThreadsLock); pfds[0].fd = mycthread->thePipe[0]; pfds[0].events = POLLIN; ooSocketPoll(pfds, 1, SEC_TO_HOLD_THREAD * 1000); if (ooPDRead(pfds, 1, mycthread->thePipe[0])) res = read(mycthread->thePipe[0], &c, 1); ast_mutex_lock(&callThreadsLock); ast_mutex_lock(&mycthread->lock); if (mycthread->prev) mycthread->prev->next = mycthread->next; else callThreads = mycthread->next; if (mycthread->next) mycthread->next->prev = mycthread->prev; ast_mutex_unlock(&mycthread->lock); ast_mutex_unlock(&callThreadsLock); } while (mycthread->call != NULL && res >= 0); ast_mutex_destroy(&mycthread->lock); close(mycthread->thePipe[0]); close(mycthread->thePipe[1]); free(mycthread); ast_module_unref(myself); ast_update_use_count(); return NULL; } int ooh323c_start_call_thread(ooCallData *call) { char c = 'c'; struct callthread *cur = callThreads; ast_mutex_lock(&callThreadsLock); while (cur != NULL && (cur->inUse || ast_mutex_trylock(&cur->lock))) { cur = cur->next; } ast_mutex_unlock(&callThreadsLock); if (cur != NULL) { if (cur->inUse || write(cur->thePipe[1], &c, 1) < 0) { ast_mutex_unlock(&cur->lock); cur = NULL; } } /* make new thread */ if (cur == NULL) { if (!(cur = ast_calloc(1, sizeof(struct callthread)))) { ast_log(LOG_ERROR, "Unable to allocate thread structure for call %s\n", call->callToken); return -1; } ast_module_ref(myself); if ((socketpair(PF_LOCAL, SOCK_STREAM, 0, cur->thePipe)) == -1) { ast_log(LOG_ERROR, "Can't create thread pipe for call %s\n", call->callToken); free(cur); return -1; } cur->inUse = TRUE; cur->call = call; ast_mutex_init(&cur->lock); if (gH323Debug) ast_debug(1,"new call thread created for call %s\n", call->callToken); if(ast_pthread_create_detached_background(&call->callThread, NULL, ooh323c_call_thread, cur) < 0) { ast_log(LOG_ERROR, "Unable to start ooh323c call thread for call %s\n", call->callToken); ast_mutex_destroy(&cur->lock); close(cur->thePipe[0]); close(cur->thePipe[1]); free(cur); return -1; } } else { if (gH323Debug) ast_debug(1,"using existing call thread for call %s\n", call->callToken); cur->inUse = TRUE; cur->call = call; ast_mutex_unlock(&cur->lock); } return 0; } int ooh323c_stop_call_thread(ooCallData *call) { if (call->callThread != AST_PTHREADT_NULL) { ooStopMonitorCallChannels(call); } return 0; } int ooh323c_start_stack_thread() { if(ast_pthread_create_background(&ooh323c_thread, NULL, ooh323c_stack_thread, NULL) < 0) { ast_log(LOG_ERROR, "Unable to start ooh323c thread.\n"); return -1; } if(ast_pthread_create_background(&ooh323cmd_thread, NULL, ooh323c_cmd_thread, NULL) < 0) { ast_log(LOG_ERROR, "Unable to start ooh323cmd 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; pthread_join(ooh323cmd_thread, NULL); ooh323cmd_thread = AST_PTHREADT_NULL; } return 0; } int ooh323c_set_capability (struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec) { int ret = 0, x; struct ast_format tmpfmt; if (gH323Debug) { ast_verb(0, "\tAdding capabilities to H323 endpoint\n"); } for(x=0; ast_codec_pref_index(prefs, x, &tmpfmt); x++) { if(tmpfmt.id == AST_FORMAT_ULAW) { if (gH323Debug) { ast_verb(0, "\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(tmpfmt.id == AST_FORMAT_ALAW) { if (gH323Debug) { ast_verb(0, "\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(tmpfmt.id == AST_FORMAT_G729A) { if (gH323Debug) { ast_verb(0, "\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_verb(0, "\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 (gH323Debug) { ast_verb(0, "\tAdding g729b capability to H323 endpoint\n"); } ret |= ooH323EpAddG729Capability(OO_G729B, 2, 24, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_G723_1) { if (gH323Debug) { ast_verb(0, "\tAdding g7231 capability to H323 endpoint\n"); } ret = ooH323EpAddG7231Capability(OO_G7231, 1, 1, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_G726) { if (gH323Debug) { ast_verb(0, "\tAdding g726 capability to H323 endpoint\n"); } ret = ooH323EpAddG726Capability(OO_G726, gtxframes, grxframes, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_G726_AAL2) { if (gH323Debug) { ast_verb(0, "\tAdding g726aal2 capability to H323 endpoint\n"); } ret = ooH323EpAddG726Capability(OO_G726AAL2, gtxframes, grxframes, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_H263) { if (gH323Debug) { ast_verb(0, "\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(tmpfmt.id == AST_FORMAT_GSM) { if (gH323Debug) { ast_verb(0, "\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); } #ifdef AST_FORMAT_AMRNB if(tmpfmt.id == AST_FORMAT_AMRNB) { if (gH323Debug) { ast_verb(0, "\tAdding amr nb capability to H323 endpoint\n"); } ret = ooH323EpAddAMRNBCapability(OO_AMRNB, 4, 4, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } #endif #ifdef AST_FORMAT_SPEEX if(tmpfmt.id == AST_FORMAT_SPEEX) { if (gH323Debug) { ast_verb(0, "\tAdding speex capability to H323 endpoint\n"); } ret = ooH323EpAddSpeexCapability(OO_SPEEX, 4, 4, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } #endif } if(dtmf & H323_DTMF_CISCO) ret |= ooH323EpEnableDTMFCISCO(0); 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, struct ast_format_cap *cap, int dtmf, int dtmfcodec, int t38support, int g729onlyA) { int ret = 0, x, txframes; struct ast_format tmpfmt; if (gH323Debug) { ast_verb(0, "\tAdding capabilities to call(%s, %s)\n", call->callType, call->callToken); } if(dtmf & H323_DTMF_CISCO || 1) ret |= ooCallEnableDTMFCISCO(call,dtmfcodec); if(dtmf & H323_DTMF_RFC2833 || 1) ret |= ooCallEnableDTMFRFC2833(call,dtmfcodec); if(dtmf & H323_DTMF_H245ALPHANUMERIC || 1) ret |= ooCallEnableDTMFH245Alphanumeric(call); if(dtmf & H323_DTMF_H245SIGNAL || 1) ret |= ooCallEnableDTMFH245Signal(call); if (t38support) ooCapabilityAddT38Capability(call, OO_T38, OORXANDTX, &ooh323c_start_receive_datachannel, &ooh323c_start_transmit_datachannel, &ooh323c_stop_receive_datachannel, &ooh323c_stop_transmit_datachannel, 0); for(x=0; ast_codec_pref_index(prefs, x, &tmpfmt); x++) { if(tmpfmt.id == AST_FORMAT_ULAW) { if (gH323Debug) { ast_verb(0, "\tAdding g711 ulaw capability to call(%s, %s)\n", call->callType, call->callToken); } txframes = prefs->framing[x]; ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes, txframes, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_ALAW) { if (gH323Debug) { ast_verb(0, "\tAdding g711 alaw capability to call(%s, %s)\n", call->callType, call->callToken); } txframes = prefs->framing[x]; ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes, txframes, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_G726) { if (gH323Debug) { ast_verb(0, "\tAdding g726 capability to call (%s, %s)\n", call->callType, call->callToken); } txframes = prefs->framing[x]; ret = ooCallAddG726Capability(call, OO_G726, txframes, grxframes, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_G726_AAL2) { if (gH323Debug) { ast_verb(0, "\tAdding g726aal2 capability to call (%s, %s)\n", call->callType, call->callToken); } txframes = prefs->framing[x]; ret = ooCallAddG726Capability(call, OO_G726AAL2, txframes, grxframes, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_G729A) { txframes = (prefs->framing[x])/10; if (gH323Debug) { ast_verb(0, "\tAdding g729A capability to call(%s, %s)\n", call->callType, call->callToken); } ret= ooCallAddG729Capability(call, OO_G729A, txframes, txframes, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); if (g729onlyA) continue; if (gH323Debug) { ast_verb(0, "\tAdding g729 capability to call(%s, %s)\n", call->callType, call->callToken); } ret|= ooCallAddG729Capability(call, OO_G729, txframes, txframes, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); if (gH323Debug) { ast_verb(0, "\tAdding g729B capability to call(%s, %s)\n", call->callType, call->callToken); } ret|= ooCallAddG729Capability(call, OO_G729B, txframes, txframes, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_G723_1) { if (gH323Debug) { ast_verb(0, "\tAdding g7231 capability to call (%s, %s)\n", call->callType, call->callToken); } ret = ooCallAddG7231Capability(call, OO_G7231, 1, 1, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } if(tmpfmt.id == AST_FORMAT_H263) { if (gH323Debug) { ast_verb(0, "\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(tmpfmt.id == AST_FORMAT_GSM) { if (gH323Debug) { ast_verb(0, "\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); } #ifdef AST_FORMAT_AMRNB if(tmpfmt.id == AST_FORMAT_AMRNB) { if (gH323Debug) { ast_verb(0, "\tAdding AMR capability to call(%s, %s)\n", call->callType, call->callToken); } ret = ooCallAddAMRNBCapability(call, OO_AMRNB, 4, 4, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } #endif #ifdef AST_FORMAT_SPEEX if(tmpfmt.id == AST_FORMAT_SPEEX) { if (gH323Debug) { ast_verb(0, "\tAdding Speex capability to call(%s, %s)\n", call->callType, call->callToken); } ret = ooCallAddSpeexCapability(call, OO_SPEEX, 4, 4, FALSE, OORXANDTX, &ooh323c_start_receive_channel, &ooh323c_start_transmit_channel, &ooh323c_stop_receive_channel, &ooh323c_stop_transmit_channel); } #endif } return ret; } 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) { struct ast_format tmpfmt; convertH323CapToAsteriskCap(pChannel->chanCap->cap, &tmpfmt); if(tmpfmt.id) { /* 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) { struct ast_format tmpfmt; convertH323CapToAsteriskCap(pChannel->chanCap->cap, &tmpfmt); if(tmpfmt.id) { switch (tmpfmt.id) { case AST_FORMAT_ALAW: case AST_FORMAT_ULAW: ooh323_set_write_format(call, &tmpfmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes); break; case AST_FORMAT_G729A: ooh323_set_write_format(call, &tmpfmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes*10); break; default: ooh323_set_write_format(call, &tmpfmt, 0); } }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 ooh323c_start_receive_datachannel(ooCallData *call, ooLogicalChannel *pChannel) { return 1; } int ooh323c_start_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChannel) { setup_udptl_connection(call, pChannel->remoteIP, pChannel->remoteMediaPort); return 1; } int ooh323c_stop_receive_datachannel(ooCallData *call, ooLogicalChannel *pChannel) { return 1; } int ooh323c_stop_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChannel) { close_udptl_connection(call); return 1; } struct ast_format *convertH323CapToAsteriskCap(int cap, struct ast_format *result) { ast_format_clear(result); switch(cap) { case OO_G711ULAW64K: return ast_format_set(result, AST_FORMAT_ULAW, 0); case OO_G711ALAW64K: return ast_format_set(result, AST_FORMAT_ALAW, 0); case OO_GSMFULLRATE: return ast_format_set(result, AST_FORMAT_GSM, 0); #ifdef AST_FORMAT_AMRNB case OO_AMRNB: return ast_format_set(result, AST_FORMAT_AMRNB, 0); #endif #ifdef AST_FORMAT_SPEEX case OO_SPEEX: return ast_format_set(result, AST_FORMAT_SPEEX, 0); #endif case OO_G729: return ast_format_set(result, AST_FORMAT_G729A, 0); case OO_G729A: return ast_format_set(result, AST_FORMAT_G729A, 0); case OO_G729B: return ast_format_set(result, AST_FORMAT_G729A, 0); case OO_G7231: return ast_format_set(result, AST_FORMAT_G723_1, 0); case OO_G726: return ast_format_set(result, AST_FORMAT_G726, 0); case OO_G726AAL2: return ast_format_set(result, AST_FORMAT_G726_AAL2, 0); case OO_H263VIDEO: return ast_format_set(result, AST_FORMAT_H263, 0); default: ast_debug(1, "Cap %d is not supported by driver yet\n", cap); return NULL; } return NULL; } asterisk-11.7.0/addons/format_mp3.c0000644000175000007640000001660611753324336017050 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Anthony Minessale * * Derived from other asterisk sound formats by * Mark Spencer * * 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 no extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 366298 $") #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 { /*! state for the mp3 decoder */ struct mpstr mp; /*! buffer to hold mp3 data after read from disk */ char sbuf[MP3_SCACHE]; /*! buffer for slinear audio after being decoded out of sbuf */ char dbuf[MP3_DCACHE]; /*! how much data has been written to the output buffer in the ast_filestream */ int buflen; /*! how much data has been written to sbuf */ int sbuflen; /*! how much data is left to be read out of dbuf, starting at dbufoffset */ int dbuflen; /*! current offset for reading data out of dbuf */ int dbufoffset; 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); 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; res = 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; /* Pre-populate the buffer that holds audio to be returned (dbuf) */ if (mp3_queue(s)) { return NULL; } if (p->dbuflen) { /* Read out what's waiting in dbuf */ for (p->buflen = 0; p->buflen < MP3_BUFLEN && p->buflen < p->dbuflen; p->buflen++) { s->buf[p->buflen + AST_FRIENDLY_OFFSET] = p->dbuf[p->buflen + p->dbufoffset]; } p->dbufoffset += p->buflen; p->dbuflen -= p->buflen; } if (p->buflen < MP3_BUFLEN) { /* dbuf didn't have enough, so reset dbuf, fill it back up and continue */ p->dbuflen = p->dbufoffset = 0; if (mp3_queue(s)) { return NULL; } /* Make sure dbuf has enough to complete this read attempt */ if (p->dbuflen >= (MP3_BUFLEN - p->buflen)) { for (save = p->buflen; p->buflen < MP3_BUFLEN; p->buflen++) { s->buf[p->buflen + AST_FRIENDLY_OFFSET] = p->dbuf[(p->buflen - save) + p->dbufoffset]; } p->dbufoffset += (MP3_BUFLEN - save); p->dbuflen -= (MP3_BUFLEN - save); } } p->offset += p->buflen; delay = p->buflen / 2; s->fr.frametype = AST_FRAME_VOICE; ast_format_set(&s->fr.subclass.format, AST_FORMAT_SLINEAR, 0); AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, p->buflen); 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 fseek(s->f, offset, SEEK_SET); } 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 struct ast_format_def mp3_f = { .name = "mp3", .exts = "mp3", .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) { ast_format_set(&mp3_f.format, AST_FORMAT_SLINEAR, 0); InitMP3Constants(); return ast_format_def_register(&mp3_f); } static int unload_module(void) { return ast_format_def_unregister(name); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MP3 format [Any rate but 8000hz mono is optimal]"); asterisk-11.7.0/config.guess0000755000175000007640000012760712036524227015705 0ustar sharkyjerryweb#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-09-25' # This file 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, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: asterisk-11.7.0/makeopts.in0000644000175000007640000001474212131613047015526 0ustar sharkyjerryweb# NOTE: Names of _INCLUDE and _LIB entries in this file must be # the exact uppercase equivalents of the names used for # dependencies in menuselect for the same package. CC=@PTHREAD_CC@ HOST_CC=cc BUILD_CC=cc CXX=@CXX@ INSTALL=@INSTALL@ AWK=@AWK@ BISON=@BISON@ FLEX=@FLEX@ GREP=@GREP@ PYTHON=@PYTHON@ MAKE=@GNU_MAKE@ AR=@AR@ RANLIB=@RANLIB@ FIND=@FIND@ COMPRESS=@COMPRESS@ BASENAME=@BASENAME@ SHELL=@SHELL@ LN=@LN@ DOT=@DOT@ STRIP=@STRIP@ WGET=@WGET@ FETCH=@FETCH@ DOWNLOAD=@DOWNLOAD@ SOUNDS_CACHE_DIR=@SOUNDS_CACHE_DIR@ RUBBER=@RUBBER@ CATDVI=@CATDVI@ KPATHSEA=@KPATHSEA@ XMLLINT=@XMLLINT@ XMLSTARLET=@XMLSTARLET@ MD5=@MD5@ SHA1SUM=@SHA1SUM@ OPENSSL=@OPENSSL@ LDCONFIG=@LDCONFIG@ GIT=@GIT@ BUILD_PLATFORM=@BUILD_PLATFORM@ BUILD_CPU=@BUILD_CPU@ BUILD_VENDOR=@BUILD_VENDOR@ BUILD_OS=@BUILD_OS@ HOST_PLATFORM=@HOST_PLATFORM@ HOST_CPU=@HOST_CPU@ HOST_VENDOR=@HOST_VENDOR@ HOST_OS=@HOST_OS@ OSARCH=@OSARCH@ OSREV=@PBX_OSREV@ GC_CFLAGS=@GC_CFLAGS@ GC_LDFLAGS=@GC_LDFLAGS@ PTHREAD_CFLAGS=@PTHREAD_CFLAGS@ PTHREAD_LIBS=@PTHREAD_LIBS@ CONFIG_CFLAGS=@CONFIG_CFLAGS@ CONFIG_LDFLAGS=@CONFIG_LDFLAGS@ GNU_LD=@GNU_LD@ WEAKREF=@PBX_WEAKREF@ HAVE_DYNAMIC_LIST=@PBX_DYNAMIC_LIST@ prefix = @prefix@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ datadir = @datadir@ includedir = @includedir@ infodir = @infodir@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ mandir = @mandir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ ASTSBINDIR = @astsbindir@ ASTETCDIR = @astetcdir@ ASTHEADERDIR = @astheaderdir@ ASTLIBDIR = @astlibdir@ ASTMODDIR = @astmoddir@ ASTMANDIR = @astmandir@ astvarlibdir = @astvarlibdir@ ASTVARLIBDIR = @astvarlibdir@ ASTDATADIR = @astdatadir@ ASTDBDIR = @astdbdir@ ASTKEYDIR = @astkeydir@ ASTSPOOLDIR = @astspooldir@ ASTLOGDIR = @astlogdir@ ASTVARRUNDIR = @astvarrundir@ AST_DEVMODE=@AST_DEVMODE@ AST_DEVMODE_STRICT=@AST_DEVMODE_STRICT@ NOISY_BUILD=@NOISY_BUILD@ AST_CODE_COVERAGE=@AST_CODE_COVERAGE@ AST_ASTERISKSSL=@AST_ASTERISKSSL@ AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@ AST_TRAMPOLINES=@AST_TRAMPOLINES@ AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@ AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@ AST_NESTED_FUNCTIONS=@AST_NESTED_FUNCTIONS@ AST_RPATH=@AST_RPATH@ AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@ AST_MARCH_NATIVE=@AST_MARCH_NATIVE@ ALSA_INCLUDE=@ALSA_INCLUDE@ ALSA_LIB=@ALSA_LIB@ BFD_INCLUDE=@BFD_INCLUDE@ BFD_LIB=@BFD_LIB@ BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@ BLUETOOTH_LIB=@BLUETOOTH_LIB@ CURL_INCLUDE=@CURL_INCLUDE@ CURL_LIB=@CURL_LIB@ CURSES_INCLUDE=@CURSES_INCLUDE@ CURSES_LIB=@CURSES_LIB@ CURSES_DIR=@CURSES_DIR@ EDITLINE_LIB=@EDITLINE_LIB@ FREETDS_INCLUDE=@FREETDS_INCLUDE@ FREETDS_LIB=@FREETDS_LIB@ GENERIC_ODBC_INCLUDE=@GENERIC_ODBC_INCLUDE@ GENERIC_ODBC_LIB=@GENERIC_ODBC_LIB@ GMIME_INCLUDE=@GMIME_INCLUDE@ GMIME_LIB=@GMIME_LIB@ HOARD_LIB=@HOARD_LIB@ GSM_INTERNAL=@GSM_INTERNAL@ GSM_INCLUDE=@GSM_INCLUDE@ GSM_LIB=@GSM_LIB@ ILBC_INTERNAL=@ILBC_INTERNAL@ ILBC_INCLUDE=@ILBC_INCLUDE@ ILBC_LIB=@ILBC_LIB@ GTK2_INCLUDE=@GTK2_INCLUDE@ GTK2_LIB=@GTK2_LIB@ ICAL_INCLUDE=@ICAL_INCLUDE@ ICAL_LIB=@ICAL_LIB@ ICONV_INCLUDE=@ICONV_INCLUDE@ ICONV_LIB=@ICONV_LIB@ IKSEMEL_INCLUDE=@IKSEMEL_INCLUDE@ IKSEMEL_LIB=@IKSEMEL_LIB@ IMAP_TK_INCLUDE=@IMAP_TK_INCLUDE@ IMAP_TK_LIB=@IMAP_TK_LIB@ IODBC_INCLUDE=@IODBC_INCLUDE@ IODBC_LIB=@IODBC_LIB@ JACK_INCLUDE=@JACK_INCLUDE@ JACK_LIB=@JACK_LIB@ LDAP_INCLUDE=@LDAP_INCLUDE@ LDAP_LIB=@LDAP_LIB@ LIBEDIT_INTERNAL=@LIBEDIT_INTERNAL@ LIBEDIT_INCLUDE=@LIBEDIT_INCLUDE@ LIBEDIT_LIB=@LIBEDIT_LIB@ LUA_INCLUDE=@LUA_INCLUDE@ LUA_LIB=@LUA_LIB@ MYSQLCLIENT_INCLUDE=@MYSQLCLIENT_INCLUDE@ MYSQLCLIENT_LIB=@MYSQLCLIENT_LIB@ NBS_INCLUDE=@NBS_INCLUDE@ NBS_LIB=@NBS_LIB@ NCURSES_INCLUDE=@NCURSES_INCLUDE@ NCURSES_LIB=@NCURSES_LIB@ NCURSES_DIR=@NCURSES_DIR@ NEON_INCLUDE=@NEON_INCLUDE@ NEON_LIB=@NEON_LIB@ NEON29_INCLUDE=@NEON_INCLUDE@ NEON29_LIB=@NEON_LIB@ NETSNMP_INCLUDE=@NETSNMP_INCLUDE@ NETSNMP_LIB=@NETSNMP_LIB@ NEWT_INCLUDE=@NEWT_INCLUDE@ NEWT_LIB=@NEWT_LIB@ OGG_INCLUDE=@OGG_INCLUDE@ OGG_LIB=@OGG_LIB@ OSPTK_INCLUDE=@OSPTK_INCLUDE@ OSPTK_LIB=@OSPTK_LIB@ # ossaudio can optionally use ffmpeg, x11, sdl and sdl_image. # Because sdl_image in turn depends on sdl, we don't duplicate the include OSS_INCLUDE=@OSS_INCLUDE@ @FFMPEG_INCLUDE@ @SDL_INCLUDE@ @X11_INCLUDE@ OSS_LIB=@OSS_LIB@ @FFMPEG_LIB@ @SDL_LIB@ @SDL_IMAGE_LIB@ @X11_LIB@ PGSQL_INCLUDE=@PGSQL_INCLUDE@ PGSQL_LIB=@PGSQL_LIB@ POPT_INCLUDE=@POPT_INCLUDE@ POPT_LIB=@POPT_LIB@ PORTAUDIO_INCLUDE=@PORTAUDIO_INCLUDE@ PORTAUDIO_LIB=@PORTAUDIO_LIB@ PRI_INCLUDE=@PRI_INCLUDE@ PRI_LIB=@PRI_LIB@ RESAMPLE_INCLUDE=@RESAMPLE_INCLUDE@ RESAMPLE_LIB=@RESAMPLE_LIB@ SS7_INCLUDE=@SS7_INCLUDE@ SS7_LIB=@SS7_LIB@ OPENR2_INCLUDE=@OPENR2_INCLUDE@ OPENR2_LIB=@OPENR2_LIB@ PWLIB_INCLUDE=@PWLIB_INCLUDE@ PWLIB_LIB=@PWLIB_LIB@ COROSYNC_INCLUDE=@COROSYNC_INCLUDE@ COROSYNC_LIB=@COROSYNC_LIB@ RADIUS_INCLUDE=@RADIUS_INCLUDE@ RADIUS_LIB=@RADIUS_LIB@ FFMPEG_INCLUDE=@FFMPEG_INCLUDE@ FFMPEG_LIB=@FFMPEG_LIB@ X11_INCLUDE=@X11_INCLUDE@ X11_LIB=@X11_LIB@ SDL_INCLUDE=@SDL_INCLUDE@ SDL_LIB=@SDL_LIB@ SDL_IMAGE_INCLUDE=@SDL_IMAGE_INCLUDE@ SDL_IMAGE_LIB=@SDL_IMAGE_LIB@ SPANDSP_INCLUDE=@SPANDSP_INCLUDE@ SPANDSP_LIB=@SPANDSP_LIB@ SPEEX_INCLUDE=@SPEEX_INCLUDE@ SPEEX_LIB=@SPEEX_LIB@ SPEEXDSP_INCLUDE=@SPEEXDSP_INCLUDE@ SPEEXDSP_LIB=@SPEEXDSP_LIB@ SQLITE_INCLUDE=@SQLITE_INCLUDE@ SQLITE_LIB=@SQLITE_LIB@ SQLITE3_INCLUDE=@SQLITE3_INCLUDE@ SQLITE3_LIB=@SQLITE3_LIB@ SRTP_LIB=@SRTP_LIB@ SRTP_INCLUDE=@SRTP_INCLUDE@ OPENSSL_INCLUDE=@OPENSSL_INCLUDE@ OPENSSL_LIB=@OPENSSL_LIB@ CRYPTO_INCLUDE=@CRYPTO_INCLUDE@ CRYPTO_LIB=@CRYPTO_LIB@ TONEZONE_INCLUDE=@TONEZONE_INCLUDE@ TONEZONE_LIB=@TONEZONE_LIB@ UNIXODBC_INCLUDE=@UNIXODBC_INCLUDE@ UNIXODBC_LIB=@UNIXODBC_LIB@ UUID_INCLUDE=@UUID_INCLUDE@ UUID_LIB=@UUID_LIB@ VORBIS_INCLUDE=@VORBIS_INCLUDE@ VORBIS_LIB=@VORBIS_LIB@ VPB_INCLUDE=@VPB_INCLUDE@ VPB_LIB=@VPB_LIB@ DAHDI_INCLUDE=@DAHDI_INCLUDE@ ZLIB_INCLUDE=@ZLIB_INCLUDE@ ZLIB_LIB=@ZLIB_LIB@ ISDNNET_INCLUDE=@ISDNNET_INCLUDE@ ISDNNET_LIB=@ISDNNET_LIB@ MISDN_INCLUDE=@MISDN_INCLUDE@ MISDN_LIB=@MISDN_LIB@ SUPPSERV_INCLUDE=@SUPPSERV_INCLUDE@ SUPPSERV_LIB=@SUPPSERV_LIB@ CAP_LIB=@CAP_LIB@ CAP_INCLUDE=@CAP_INCLUDE@ BKTR_INCLUDE=@BKTR_INCLUDE@ BKTR_LIB=@BKTR_LIB@ TERMCAP_INCLUDE=@TERMCAP_INCLUDE@ TERMCAP_LIB=@TERMCAP_LIB@ TERMCAP_DIR=@TERMCAP_DIR@ LIBXML2_INCLUDE=@LIBXML2_INCLUDE@ LIBXML2_LIB=@LIBXML2_LIB@ TINFO_INCLUDE=@TINFO_INCLUDE@ TINFO_LIB=@TINFO_LIB@ TINFO_DIR=@TINFO_DIR@ # if poll is not present, let the makefile know. POLL_AVAILABLE=@HAS_POLL@ TIMERFD_INCLUDE=@TIMERFD_INCLUDE@ asterisk-11.7.0/CREDITS0000644000175000007640000002653411634372240014401 0ustar sharkyjerryweb === DEVELOPMENT SUPPORT === We'd like to thank the following companies for helping fund development of Asterisk: Pilosoft, Inc. - for supporting ADSI development in Asterisk Asterlink, Inc. - for supporting broad Asterisk development GFS - for supporting ALSA development Telesthetic - for supporting SIP development Christos Ricudis - for substantial code contributions nic.at - ENUM support in Asterisk Paul Bagyenda, Digital Solutions - for initial Voicetronix driver development John Todd, TalkPlus, Inc. and JR Richardson, Ntegrated Solutions. - for funding the development of SIP Session Timers support. Omnitor AB, Gunnar Hellström, for funding work with videocaps, T.140 RED, originate with video/text and many more contributions. ClearIT AB for work with meetme, res_mutestream, RTCP, manager and tonezones === WISHLIST CONTRIBUTERS === Jeremy McNamara - SpeeX support Nick Seraphin - RDNIS support Gary - Phonejack ADSI (in progress) Wasim - Hangup detect === HARDWARE DONORS === * Thanks to QuickNet Technologies for their donation of an Internet PhoneJack and Linejack card to the project. (http://www.quicknet.net) * Thanks to VoipSupply for their donation of Sipura ATAs to the project for T.38 testing. (http://www.voipsupply.com) * Thanks to Grandstream for their donation of ATAs to the project for T.38 testing. (http://www.grandstream.com) === MISCELLANEOUS PATCHES === Jim Dixon - Zapata Telephony and app_rpt http://www.zapatatelephony.org/app_rpt.html Russell Bryant - Asterisk release manager and countless enhancements and bug fixes. russell(AT)digium.com Anthony Minessale II - Countless big and small fixes, and relentless forward push. ChanSpy, ForkCDR, ControlPlayback, While/EndWhile, DumpChan, Dictate, MacroIf, ExecIf, ExecIfTime, RetryDial, MixMonitor applications; many realtime concepts and implementation pieces, including res_config_odbc; format_slin; cdr_custom; several features in Dial including L(), G() and enhancements to M() and D(); several CDR enhancements including CDR variables; attended transfer; one touch record; native MOH; manager eventmask; command line '-t' flag to allow recording/voicemail on nfs shares; #exec command and multiline comments in config files; setvar in iax and sip configs. anthmct(AT)yahoo.com http://www.asterlink.com James Golovich - Innumerable contributions, including SIP TCP and TLS support. You can find him and asterisk-perl at http://asterisk.gnuinter.net Andre Bierwirth - Extension hints and status Jean-Denis Girard - Various contributions from the South Pacific Islands jd-girard(AT)esoft.pf http://www.esoft.pf William Jordan / Vonage - MySQL enhancements to Voicemail wjordan(AT)vonage.com Jac Kersing - Various fixes Steven Critchfield - Seek and Trunc functions for playback and recording critch(AT)basesys.com Jefferson Noxon - app_lookupcidname, app_db, and various other contributions Klaus-Peter Junghanns - in-band DTMF on SIP and MGCP Ross Finlayson - Dynamic RTP payload support Mahmut Fettahlioglu - Audio recording, music-on-hold changes, alaw file format, and various fixes. Can be contacted at mahmut(AT)oa.com.au James Dennis - Cisco SIP compatibility patches to work with SIP service providers. Can be contacted at asterisk(AT)jdennis.net Tilghman Lesher - ast_localtime(); ast_say_date_with_format(); GotoIfTime, SayUnixTime, HasNewVoicemail applications; CUT, SORT, EVAL, CURL, FIELDQTY, STRFTIME, some QUEUE* functions; func_odbc, cdr_adaptive_odbc, and other innumerable bug fixes. tilghman(AT)digium.com http://asterisk.drunkcoder.com/ Jayson Vantuyl - Manager protocol changes, various other bugs. jvantuyl(AT)computingedge.net Thorsten Lockert - OpenBSD, FreeBSD ports, making MacOS X port run on 10.3, dialplan include verification, route lookup on OpenBSD, SNMP agent support (res_snmp), various other bugs. tholo(AT)sigmasoft.com Josh Roberson - chan_zap reload support, Advanced Voicemail Features, & other misc. patches. - josh(AT)asteriasgi.com, http://www.asteriasgi.com William Waites - syslog support, SIP NAT traversal for SIP-UA. ww(AT)styx.org Rich Murphey - Porting to FreeBSD, NetBSD, OpenBSD, and Darwin. rich(AT)whiteoaklabs.com http://whiteoaklabs.com Simon Lockhart - Porting to Solaris (based on work of Logan ???) simon(AT)slimey.org Olle E. Johansson - SIP RFC compliance, documentation and testing, testing, SIP outbound proxy support, Manager 1.1 update, SIP transfer support, SIP presence support, SIP call state updates (dialog-info), QUEUE_EXISTS function, device state provider architecture, multiparking (together with mvanbaak), meetme and parking device states, MiniVM - the small voicemail system, many documentation updates/corrections, and many bug fixes. oej(AT)edvina.net, http://edvina.net Steve Kann - new jitter buffer for IAX2 stevek(AT)stevek.com Constantine Filin - major contributions to the Asterisk Realtime Architecture Steve Murphy - privacy support, $[ ] parser upgrade, AEL2 parser upgrade. murf(AT)digium.com Claude Patry - bug fixes, feature enhancements, and bug marshalling cpatry(AT)gmail.com Miroslav Nachev, miro(AT)space-comm.com COSMOS Software Enterprises, Ltd. - for Variable for No Answer Timeout for Attended Transfer Slav Klenov & Vanheuverzwijn Joachim - development of the generic jitterbuffer Securax Ltd. info(AT)securax.be Roy Sigurd Karlsbakk - providing funding for generic jitterbuffer development roy(AT)karlsbakk.net, Briiz Telecom AS Voop AS, Nuvio Inc, Inotel S.A and Foniris Telecom A/S - funding for rewrite of SIP transfers Philippe Sultan - RADIUS CDR module, many fixes to res_jabber and gtalk/jingle channel drivers. INRIA, http://www.inria.fr/ John Martin, Aupix - Improved video support in the SIP channel T.140 text support in RTP/SIP Steve Underwood - Provided T.38 pass through support. George Konstantoulakis - Support for Greek in voicemail added by InAccess Networks (work funded by HOL, www.hol.gr) gkon(AT)inaccessnetworks.com Daniel Nylander - Support for Swedish and Norwegian languages in voicemail. http://www.danielnylander.se/ Stojan Sljivic - An option for maximum number of messsages per mailbox in voicemail. Also an issue with voicemail synchronization has been fixed. GDS Partners www.gdspartners.com . stojan.sljivic(AT)gdspartners.com Bartosz Supczinski - Support for Polish added by DIR (www.dir.pl) Bartosz.Supczinski(AT)dir.pl James Rothenberger - Support for IMAP storage integration added by OneBizTone LLC Work funded by University of Pennsylvania jar(AT)onebiztone.com Paul Cadach - Bringing chan_h323 up to date, bug fixes, and more! Voop AS - Financial support for a lot of work with the SIP driver and the IAX trunk MTU patch Cedric Hans - Development of chan_unistim cedric.hans(AT)mlkj.net Takao Takahashi & Mina Naguib - chan_unistim improvements for smaller devices Sergio Fadda - console_video: video support for chan_oss and chan_alsa Marta Carbone - console_video and the astobj2 framework Luigi Rizzo - astobj2, console_video, windows build, chan_oss cleanup, and a bunch of infrastructure work (loader, new_cli, ...) Brett Bryant - digit option for musiconhold selection, ENUMQUERY and ENUMRESULT functions, feature group configuration for features.conf, per-file CLI debug and verbose settings, TCP and TLS support for SIP, and various bug fixes. brettbryant(AT)gmail.com Sergey Tamkovich - Realtime support for MusicOnHold, store and destroy realtime methods and implementations for odbc, sqlite, and pgsql realtime drivers, attended transfer updates, multiple speeds for ControlPlayback, and multiple bug fixes - See http://voip-info.org/users/view/sergee serg(AT)voipsolutions.ru Klaus Darillon - the SIPremoveHeader function in chan_sip Moises Silva (moy) - for writing LibOpenR2, and providing support for it in chan_dahdi moises.silva(AT)gmail.com Eliel C. Sardanons - XML documentation implementation, and various other contributions eliels(AT)gmail.com Sean Bright - Snom call pickup, newt interface for menuselect, cdr_tds rewrite, countless other improvements, fixes, and good ideas. sean(AT)malleable.com Jan Kaláb - Calendaring support for Exchange Server 2007+ via Exchange Web Services. University of Oslo (uio.no), Norway - SIP Max-Forwards setting support (developed by oej) FCCN, Lissabon, Portugal - SIP show channels CLI command (developed by oej) Viagenie, Canada - IPv6 support in socket layers and SIP implementation Developers: Marc Blanchet, Simon Perreault and Jean-Philippe Dionne ClearIT AB, Sweden - res_mutestream, queue_exists and various other patches (developed by oej) Despegar.com, Argentina - AstData API implementation, also sponsored by Google as part of the gsoc/2009 program (developed by Eliel) Philippe Lindheimer - DEV_STATE additions to CCSS === OTHER CONTRIBUTIONS === John Todd - Monkey sounds and associated teletorture prompt Michael Jerris - bug marshaling Leif Madsen, Jared Smith and Jim van Meggelen - the Asterisk book available under a Creative Commons License at http://www.asteriskdocs.org Brian M. Clapper - poll.c emulation This product includes software developed by Brian M. Clapper === HOLD MUSIC === Music provided by www.opsound.org === OTHER SOURCE CODE IN ASTERISK === Asterisk uses libedit, the lightweight readline replacement from NetBSD. The cdr_radius module uses libradiusclient-ng, which is also from NetBSD. They are BSD-licensed and require the following statement: This product includes software developed by the NetBSD Foundation, Inc. and its contributors. Digium did not implement the codecs in Asterisk. Here is the copyright on the GSM source: Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, Technische Universitaet Berlin Any use of this software is permitted provided that this notice is not removed and that neither the authors nor the Technische Universitaet Berlin are deemed to have made any representations as to the suitability of this software for any purpose nor are held responsible for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. As a matter of courtesy, the authors request to be informed about uses this software has found, about bugs in this software, and about any improvements that may be of general interest. Berlin, 28.11.1994 Jutta Degener Carsten Bormann And the copyright on the ADPCM source: Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Stichting Mathematisch Centrum or CWI not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. asterisk-11.7.0/asterisk-11.7.0-summary.txt0000644000175000007640000005367712254071062020171 0ustar sharkyjerryweb Release Summary asterisk-11.7.0 Date: 2013-12-17 ---------------------------------------------------------------------- Table of Contents 1. Summary 2. Contributors 3. Closed Issues 4. Other Changes 5. Diffstat ---------------------------------------------------------------------- Summary [Back to Top] This release includes only bug fixes. The changes included were made only to address problems that have been identified in this release series. Users should be able to safely upgrade to this version if this release series is already in use. Users considering upgrading from a previous release series are strongly encouraged to review the UPGRADE.txt document as well as the CHANGES document for information about upgrading to this release series. The data in this summary reflects changes that have been made since the previous release, asterisk-11.6.0. ---------------------------------------------------------------------- Contributors [Back to Top] This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release. For coders, the number is how many of their patches (of any size) were committed into this release. For testers, the number is the number of times their name was listed as assisting with testing a patch. Finally, for reporters, the number is the number of issues that they reported that were closed by commits that went into this release. Coders Testers Reporters 11 jrose 3 elguero 2 gkelleter 8 rmudgett 1 Ben Smithurst 2 nbansal 5 elguero 1 Dalius M. 2 tsearle 4 bebuild 1 rmudgett 1 abelbeck 4 kmoore 1 wdoekes 1 adomjan 4 wdoekes 1 aragon 3 mjordan 1 arcanos 2 kharwell 1 bensmithurst 2 NITESH BANSAL 1 brianscott 2 sgriepentrog 1 coreyfarrell 1 abelbeck 1 dario 1 adomjan 1 docent 1 coreyfarrell 1 elguero 1 Filip Jenicek 1 frenk77 1 junky 1 jbigelow 1 mmichelson 1 jkister 1 nbougues 1 jllull 1 Oscar Esteve 1 jrose 1 Simone Camporeale 1 kharwell 1 Torrey Searle 1 kmoore 1 tsearle 1 londonnet 1 tzafrir 1 mdalius 1 mjordan 1 nbougues 1 oscares 1 patrickm 1 phill 1 rudolf 1 simone.camporeale 1 skavin 1 tomaso 1 wdoekes ---------------------------------------------------------------------- Closed Issues [Back to Top] This is a list of all issues from the issue tracker that were closed by changes that went into this release. Category: Applications/app_confbridge ASTERISK-19983: ConfBridge does not expose a mechanism to change the language on the Bridging channel, defaulting to 'en' Revision: 400741 Reporter: londonnet Testers: rmudgett Coders: junky Category: Applications/app_queue ASTERISK-21826: [patch] Bad queue_log entry when removed member from queue via CLI Revision: 401433 Reporter: oscares Coders: Oscar Esteve ASTERISK-22197: [patch] Queuelog EXITWITHKEY only two of four parameters Revision: 400623 Reporter: mdalius Testers: Dalius M. Coders: elguero Category: Applications/app_voicemail ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell Category: Bridges/bridge_native_rtp ASTERISK-22424: bridge_native_rtp: Asterisk 12 attempts to remotely bridge on 200OK response to invite when the 200 lacks SDP Revision: 399962 Reporter: jrose Coders: jrose Category: CDR/cdr_adaptive_odbc ASTERISK-22272: [patch] Unexepected behaviour with adaptive odbc filter Revision: 401579 Reporter: jllull Coders: rmudgett Category: Channels/chan_dahdi ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell Category: Channels/chan_mgcp ASTERISK-21190: chan_mgcp crash on chunked m= sdp line Revision: 401538 Reporter: adomjan Coders: adomjan Category: Channels/chan_pjsip ASTERISK-22667: crash: directmedia with both phones placing each other on hold Revision: 401446 Reporter: jbigelow Coders: mjordan Category: Channels/chan_sip/CodecHandling ASTERISK-21131: [patch] - Asterisk creates SDP with (peer) unsupported audio codec Revision: 401498 Reporter: nbougues Coders: nbougues Category: Channels/chan_sip/General ASTERISK-21204: Asterisk increments the session version in 2xx message even if a '183 Session in Progress' with SDP has already been sent in response to initial INVITE. Revision: 400908 Reporter: nbansal Coders: NITESH BANSAL ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell ASTERISK-22477: array calleridname in the function check_user_full is too short Revision: 400014 Reporter: docent Coders: rmudgett ASTERISK-22621: chan_sip can send two BYEs for a single call Revision: 400971 Reporter: kmoore Coders: mmichelson ASTERISK-22667: crash: directmedia with both phones placing each other on hold Revision: 401446 Reporter: jbigelow Coders: mjordan ASTERISK-22729: [patch] Remove Port Restriction When Checking For NAT Revision: 401182 Reporter: elguero Testers: elguero Coders: elguero Category: Channels/chan_sip/Interoperability ASTERISK-22005: Allow a sip peer to accept both AVP and AVPF calls Revision: 401884 Reporter: tsearle Coders: tsearle Category: Channels/chan_sip/Registration ASTERISK-17138: [patch] Asterisk not re-registering after it receives "Forbidden - wrong password on authentication" Revision: 400140 Reporter: rudolf Coders: kmoore ASTERISK-22236: REGISTER reply send to bad port with nat=yes(or force_rport,comedia) in 11.5.0 Revision: 401167 Reporter: frenk77 Testers: elguero Coders: elguero ASTERISK-22428: [patch] SIP unregister does not fully unregister when using Realtime sip peers and Expires not 0 on 200ok Revision: 399795 Reporter: bensmithurst Testers: Ben Smithurst, elguero Coders: elguero ASTERISK-22574: [patch]Value of expires= is ignored in the Contact header Revision: 400470 Reporter: phill Coders: Filip Jenicek Category: Channels/chan_sip/T.38 ASTERISK-17273: [patch] - Incorrect address specified in SIP re-INVITE with T.38 when directmedia enabled Revision: 399457 Reporter: dario Coders: jrose ASTERISK-18706: UDPTL fail while using directmedia Revision: 399457 Reporter: jkister Coders: jrose Category: Codecs/codec_ilbc ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell Category: Core/BuildSystem ASTERISK-22351: Segfault in LIBEDIT_INTERNAL after tgetstr(), when libncurses5-dev isn't installed Revision: 401326 Reporter: arcanos Coders: wdoekes Category: Core/General ASTERISK-22351: Segfault in LIBEDIT_INTERNAL after tgetstr(), when libncurses5-dev isn't installed Revision: 401326 Reporter: arcanos Coders: wdoekes ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell Category: Core/Jitterbuffer ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell Category: Core/Logging ASTERISK-22456: Logger.conf: Logging types ignored after specifying a verbose level Revision: 401833 Reporter: kharwell Coders: kharwell Category: Core/ManagerInterface ASTERISK-22578: Invalid manager logins aren't reported via security events: Invalid IE Specified ERROR Revision: 400421 Reporter: mjordan Coders: kmoore Category: Core/RTP ASTERISK-21464: with directrtpsetup some payload type identifiers from A party's INVITE are not copied to the INVITE for B party Revision: 402042 Reporter: skavin Coders: sgriepentrog ASTERISK-22424: bridge_native_rtp: Asterisk 12 attempts to remotely bridge on 200OK response to invite when the 200 lacks SDP Revision: 399962 Reporter: jrose Coders: jrose Category: Core/UDPTL ASTERISK-18706: UDPTL fail while using directmedia Revision: 399457 Reporter: jkister Coders: jrose Category: Functions/func_config ASTERISK-22483: AST_LIST_INSERT_TAIL doesn't set field.next on added entry Revision: 400697 Reporter: brianscott Coders: kmoore Category: Functions/func_math ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell Category: General ASTERISK-22540: WARNING[2324] asterisk.c: Fork failed: Cannot allocate memory in /var/log/asterisk/messages then segfault Revision: 399513 Reporter: aragon Coders: kharwell Category: Resources/res_jabber ASTERISK-22410: [patch] Change "Error isn't a PubSub error ..." error log to a debug log Revision: 401120 Reporter: abelbeck Coders: abelbeck Category: Resources/res_odbc ASTERISK-22459: Compiling res_odbc against iODBC instead of unixodbc produces runtime errors Revision: 400768 Reporter: patrickm Testers: wdoekes Coders: wdoekes Category: Resources/res_rtp_asterisk ASTERISK-21170: DTMF timestamp issue Revision: 401620 Reporter: nbansal Coders: NITESH BANSAL ASTERISK-21917: [patch] STUN crashes when SIP is bound to ipv4 and ipv6 Revision: 400681 Reporter: tsearle Coders: Torrey Searle ASTERISK-22667: crash: directmedia with both phones placing each other on hold Revision: 401446 Reporter: jbigelow Coders: mjordan Category: Resources/res_rtp_multicast ASTERISK-22567: [patch]MutlicastRTP does not set SSRC. SSRC is always set to 0 Revision: 400394 Reporter: simone.camporeale Coders: Simone Camporeale Category: Resources/res_xmpp ASTERISK-22410: [patch] Change "Error isn't a PubSub error ..." error log to a debug log Revision: 401120 Reporter: abelbeck Coders: abelbeck Category: Tests/General ASTERISK-22467: [patch] memory leaks 1.8+ Revision: 401830 Reporter: coreyfarrell Coders: coreyfarrell ---------------------------------------------------------------------- Commits Not Associated with an Issue [Back to Top] This is a list of all changes that went into this release that did not directly close an issue from the issue tracker. The commits may have been marked as being related to an issue. If that is the case, the issue numbers are listed here, as well. +------------------------------------------------------------------------+ | Revision | Author | Summary | Issues Referenced | |----------+----------+------------------------------+-------------------| | | | Ensure global types in the | | | 399564 | kmoore | config framework are | | | | | initialized | | |----------+----------+------------------------------+-------------------| | | | chan_iax2: Prevent some | | | 399708 | rmudgett | needless breaking of the | | | | | native IAX2 bridge. | | |----------+----------+------------------------------+-------------------| | | | chan_dahdi: CLI "core stop | | | 399834 | rmudgett | gracefully" has needless | | | | | delay for PRI and SS7. | | |----------+----------+------------------------------+-------------------| | 400279 | tzafrir | man pages for astdb2bdb and | | | | | astdb2sqlite3 | | |----------+----------+------------------------------+-------------------| | 400315 | elguero | Cast Integer Argument To | | | | | Unsigned Char | | |----------+----------+------------------------------+-------------------| | | | app_confbridge: Fix | | | 400723 | rmudgett | duplicate default_user | | | | | profile. | | |----------+----------+------------------------------+-------------------| | | | chan_dahdi: Reflect the set | | | 400909 | rmudgett | software gain in the CLI | ASTERISK-22429 | | | | "dahdi show channel" output. | | |----------+----------+------------------------------+-------------------| | | | chan_iax2: Fix channel left | | | 401016 | rmudgett | locked in off nominal code | | | | | path. | | |----------+----------+------------------------------+-------------------| | | | Don't check all realtime | | | 401076 | wdoekes | queues when doing "queue | | | | | show some_queue". | | |----------+----------+------------------------------+-------------------| | | | chan_dahdi: Fix unable to | | | 401379 | rmudgett | get index warning when | | | | | transferring an analog call. | | |----------+----------+------------------------------+-------------------| | | | memory leaks: Memory leak | | | 401661 | jrose | cleanup patch by Corey | | | | | Farrell (first set) | | |----------+----------+------------------------------+-------------------| | | | memory leaks: Memory leak | | | 401705 | jrose | cleanup patch by Corey | ASTERISK-22467 | | | | Farrell (second set) | | |----------+----------+------------------------------+-------------------| | 401744 | jrose | app_voicemail: Memory Leaks | ASTERISK-22467 | | | | against tests | | |----------+----------+------------------------------+-------------------| | 401783 | jrose | astobj2: Unregister debug | ASTERISK-22467 | | | | CLI commands at exit | | |----------+----------+------------------------------+-------------------| | 401787 | jrose | jitterbuf: Fix memory leak | ASTERISK-22467 | | | | on jitter buffer reset | | |----------+----------+------------------------------+-------------------| | 401791 | jrose | test_linkedlists: Fix memory | ASTERISK-22467 | | | | leak | | |----------+----------+------------------------------+-------------------| | 401896 | jrose | revert clicompat-r2.patch | ASTERISK-22467 | | | | from r401704 | | |----------+----------+------------------------------+-------------------| | 401935 | jrose | Put clicompat-r2.patch back | ASTERISK-22467 | | | | in | | |----------+----------+------------------------------+-------------------| | 403844 | bebuild | Create 11.7.0-rc2 | | |----------+----------+------------------------------+-------------------| | 403849 | bebuild | Update version; Remove old | | | | | summaries | | |----------+----------+------------------------------+-------------------| | 403978 | bebuild | Update 11.7.0-rc2 | | |----------+----------+------------------------------+-------------------| | 403984 | bebuild | Importing release summary | | | | | for 11.7.0-rc2 release. | | +------------------------------------------------------------------------+ ---------------------------------------------------------------------- Diffstat Results [Back to Top] This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility. .version | 2 ChangeLog | 29 + Makefile | 1 README-SERIOUSLY.bestpractices.txt | 24 + UPGRADE.txt | 18 + apps/app_confbridge.c | 3 apps/app_queue.c | 37 +- apps/app_sms.c | 3 apps/app_voicemail.c | 6 apps/confbridge/conf_config_parser.c | 4 apps/confbridge/include/confbridge.h | 1 asterisk-11.7.0-rc1-summary.html | 437 ---------------------------- asterisk-11.7.0-rc1-summary.txt | 544 ----------------------------------- asterisk-11.7.0-rc2-summary.html | 73 ++++ asterisk-11.7.0-rc2-summary.txt | 103 ++++++ cdr/cdr_adaptive_odbc.c | 8 channels/chan_dahdi.c | 55 ++- channels/chan_iax2.c | 49 +-- channels/chan_mgcp.c | 6 channels/chan_sip.c | 147 ++++++--- channels/sig_analog.c | 52 +-- channels/sig_ss7.c | 9 channels/sip/include/sip.h | 1 channels/sip/reqresp_parser.c | 6 codecs/ilbc/doCPLC.c | 2 configs/asterisk.conf.sample | 6 configs/confbridge.conf.sample | 3 configs/sip.conf.sample | 3 configure.ac | 14 doc/astdb2bdb.8 | 46 ++ doc/astdb2sqlite3.8 | 39 ++ funcs/func_config.c | 4 funcs/func_db.c | 20 + funcs/func_env.c | 28 + funcs/func_lock.c | 21 + funcs/func_math.c | 3 funcs/func_realtime.c | 60 ++- funcs/func_shell.c | 18 - include/asterisk/pbx.h | 64 ++++ include/asterisk/rtp_engine.h | 6 main/app.c | 4 main/asterisk.c | 11 main/astobj2.c | 6 main/channel.c | 16 + main/config_options.c | 26 + main/data.c | 3 main/editline/readline.c | 7 main/editline/term.c | 6 main/jitterbuf.c | 6 main/logger.c | 3 main/pbx.c | 317 ++++++++++++++++++-- main/rtp_engine.c | 90 ++--- main/security_events.c | 6 main/tcptls.c | 11 main/test.c | 6 main/translate.c | 4 main/utils.c | 20 + res/res_jabber.c | 2 res/res_rtp_asterisk.c | 69 +++- res/res_rtp_multicast.c | 8 res/res_xmpp.c | 2 tests/test_dlinklists.c | 2 tests/test_linkedlists.c | 7 utils/clicompat.c | 10 64 files changed, 1308 insertions(+), 1289 deletions(-) ---------------------------------------------------------------------- asterisk-11.7.0/install-sh0000755000175000007640000001440610427665642015372 0ustar sharkyjerryweb#!/bin/sh # # install - install a program, script, or datafile # # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 asterisk-11.7.0/.cleancount0000644000175000007640000000000311773355370015505 0ustar sharkyjerryweb40 asterisk-11.7.0/config.sub0000755000175000007640000010554712036524227015347 0ustar sharkyjerryweb#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-10-10' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: asterisk-11.7.0/include/0000755000175000007640000000000012254071123014765 5ustar sharkyjerrywebasterisk-11.7.0/include/asterisk.h0000644000175000007640000001706211711604714016776 0ustar sharkyjerryweb/* * Asterisk -- A telephony toolkit for Linux. * * General Definitions for Asterisk top level program * * Copyright (C) 1999-2006, Digium, Inc. * * Mark Spencer * * This program is free software, distributed under the terms of * the GNU General Public License */ /*! \file * \brief Asterisk main include file. File version handling, generic pbx functions. */ #ifndef _ASTERISK_H #define _ASTERISK_H #include "asterisk/autoconfig.h" #if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) && defined(MALLOC_DEBUG) #include "asterisk/astmm.h" #endif #include "asterisk/compat.h" /* Default to allowing the umask or filesystem ACLs to determine actual file * creation permissions */ #ifndef AST_DIR_MODE #define AST_DIR_MODE 0777 #endif #ifndef AST_FILE_MODE #define AST_FILE_MODE 0666 #endif #define DEFAULT_LANGUAGE "en" #define DEFAULT_SAMPLE_RATE 8000 #define DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000) #define setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__ #define sched_setscheduler __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__ #if defined(DEBUG_FD_LEAKS) && !defined(STANDALONE) && !defined(STANDALONE2) && !defined(STANDALONE_AEL) /* These includes are all about ordering */ #include #include #include #include #include #define open(a,...) __ast_fdleak_open(__FILE__,__LINE__,__PRETTY_FUNCTION__, a, __VA_ARGS__) #define pipe(a) __ast_fdleak_pipe(a, __FILE__,__LINE__,__PRETTY_FUNCTION__) #define socket(a,b,c) __ast_fdleak_socket(a, b, c, __FILE__,__LINE__,__PRETTY_FUNCTION__) #define close(a) __ast_fdleak_close(a) #define fopen(a,b) __ast_fdleak_fopen(a, b, __FILE__,__LINE__,__PRETTY_FUNCTION__) #define fclose(a) __ast_fdleak_fclose(a) #define dup2(a,b) __ast_fdleak_dup2(a, b, __FILE__,__LINE__,__PRETTY_FUNCTION__) #define dup(a) __ast_fdleak_dup(a, __FILE__,__LINE__,__PRETTY_FUNCTION__) #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif int __ast_fdleak_open(const char *file, int line, const char *func, const char *path, int flags, ...); int __ast_fdleak_pipe(int *fds, const char *file, int line, const char *func); int __ast_fdleak_socket(int domain, int type, int protocol, const char *file, int line, const char *func); int __ast_fdleak_close(int fd); FILE *__ast_fdleak_fopen(const char *path, const char *mode, const char *file, int line, const char *func); int __ast_fdleak_fclose(FILE *ptr); int __ast_fdleak_dup2(int oldfd, int newfd, const char *file, int line, const char *func); int __ast_fdleak_dup(int oldfd, const char *file, int line, const char *func); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif int ast_set_priority(int); /*!< Provided by asterisk.c */ int ast_fd_init(void); /*!< Provided by astfd.c */ int ast_pbx_init(void); /*!< Provided by pbx.c */ /*! * \brief Register a function to be executed before Asterisk exits. * \param func The callback function to use. * * \retval 0 on success. * \retval -1 on error. */ int ast_register_atexit(void (*func)(void)); /*! * \brief Unregister a function registered with ast_register_atexit(). * \param func The callback function to unregister. */ void ast_unregister_atexit(void (*func)(void)); #if !defined(LOW_MEMORY) /*! * \brief Register the version of a source code file with the core. * \param file the source file name * \param version the version string (typically a SVN revision keyword string) * \return nothing * * This function should not be called directly, but instead the * ASTERISK_FILE_VERSION macro should be used to register a file with the core. */ void ast_register_file_version(const char *file, const char *version); /*! * \brief Unregister a source code file from the core. * \param file the source file name * \return nothing * * This function should not be called directly, but instead the * ASTERISK_FILE_VERSION macro should be used to automatically unregister * the file when the module is unloaded. */ void ast_unregister_file_version(const char *file); /*! \brief Find version for given module name * \param file Module name (i.e. chan_sip.so) * \return version string or NULL if the module is not found */ const char *ast_file_version_find(const char *file); char *ast_complete_source_filename(const char *partial, int n); /*! * \brief Register/unregister a source code file with the core. * \param file the source file name * \param version the version string (typically a SVN revision keyword string) * * This macro will place a file-scope constructor and destructor into the * source of the module using it; this will cause the version of this file * to registered with the Asterisk core (and unregistered) at the appropriate * times. * * Example: * * \code * ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$") * \endcode * * \note The dollar signs above have been protected with backslashes to keep * SVN from modifying them in this file; under normal circumstances they would * not be present and SVN would expand the Revision keyword into the file's * revision number. */ #ifdef MTX_PROFILE #define HAVE_MTX_PROFILE /* used in lock.h */ #define ASTERISK_FILE_VERSION(file, version) \ static int mtx_prof = -1; /* profile mutex */ \ static void __attribute__((constructor)) __register_file_version(void) \ { \ mtx_prof = ast_add_profile("mtx_lock_" file, 0); \ ast_register_file_version(file, version); \ } \ static void __attribute__((destructor)) __unregister_file_version(void) \ { \ ast_unregister_file_version(file); \ } #else /* !MTX_PROFILE */ #define ASTERISK_FILE_VERSION(file, version) \ static void __attribute__((constructor)) __register_file_version(void) \ { \ ast_register_file_version(file, version); \ } \ static void __attribute__((destructor)) __unregister_file_version(void) \ { \ ast_unregister_file_version(file); \ } #endif /* !MTX_PROFILE */ #else /* LOW_MEMORY */ #define ASTERISK_FILE_VERSION(file, x) #endif /* LOW_MEMORY */ #if !defined(LOW_MEMORY) /*! * \brief support for event profiling * * (note, this must be documented a lot more) * ast_add_profile allocates a generic 'counter' with a given name, * which can be shown with the command 'core show profile <name>' * * The counter accumulates positive or negative values supplied by * \see ast_add_profile(), dividing them by the 'scale' value passed in the * create call, and also counts the number of 'events'. * Values can also be taked by the TSC counter on ia32 architectures, * in which case you can mark the start of an event calling ast_mark(id, 1) * and then the end of the event with ast_mark(id, 0). * For non-i386 architectures, these two calls return 0. */ int ast_add_profile(const char *, uint64_t scale); int64_t ast_profile(int, int64_t); int64_t ast_mark(int, int start1_stop0); #else /* LOW_MEMORY */ #define ast_add_profile(a, b) 0 #define ast_profile(a, b) do { } while (0) #define ast_mark(a, b) do { } while (0) #endif /* LOW_MEMORY */ /*! \brief * Definition of various structures that many asterisk files need, * but only because they need to know that the type exists. * */ struct ast_channel; struct ast_frame; struct ast_module; struct ast_variable; struct ast_str; struct ast_sched_context; #ifdef bzero #undef bzero #endif #ifdef bcopy #undef bcopy #endif #define bzero 0x__dont_use_bzero__use_memset_instead"" #define bcopy 0x__dont_use_bcopy__use_memmove_instead() /* Some handy macros for turning a preprocessor token into (effectively) a quoted string */ #define __stringify_1(x) #x #define __stringify(x) __stringify_1(x) #endif /* _ASTERISK_H */ asterisk-11.7.0/include/jitterbuf.h0000644000175000007640000001506611114301223017133 0ustar sharkyjerryweb/* * jitterbuf: an application-independent jitterbuffer * * Copyrights: * Copyright (C) 2004-2005, Horizon Wimba, Inc. * * Contributors: * Steve Kann * * This program is free software, distributed under the terms of * the GNU Lesser (Library) General Public License * * Copyright on this file is disclaimed to Digium for inclusion in Asterisk */ /*! \file * \brief * jitterbuf: an application-independent jitterbuffer * \ref jitterbuf.c */ #ifndef _JITTERBUF_H_ #define _JITTERBUF_H_ #ifdef __cplusplus extern "C" { #endif /*! \name configuration constants */ /*@{ */ /*! Number of historical timestamps to use in calculating jitter and drift */ #define JB_HISTORY_SZ 500 /*! what percentage of timestamps should we drop from the history when we examine it; * this might eventually be something made configurable */ #define JB_HISTORY_DROPPCT 3 /*! the maximum droppct we can handle (say it was configurable). */ #define JB_HISTORY_DROPPCT_MAX 4 /*! the size of the buffer we use to keep the top and botton timestamps for dropping */ #define JB_HISTORY_MAXBUF_SZ JB_HISTORY_SZ * JB_HISTORY_DROPPCT_MAX / 100 /*! amount of additional jitterbuffer adjustment */ #define JB_TARGET_EXTRA 40 /*! ms between growing and shrinking; may not be honored if jitterbuffer runs out of space */ #define JB_ADJUST_DELAY 40 /*@} */ enum jb_return_code { /* return codes */ JB_OK, /* 0 */ JB_EMPTY, /* 1 */ JB_NOFRAME, /* 2 */ JB_INTERP, /* 3 */ JB_DROP, /* 4 */ JB_SCHED /* 5 */ }; enum jb_frame_type { /* frame types */ JB_TYPE_CONTROL, /*!< 0 */ JB_TYPE_VOICE, /*!< 1 */ JB_TYPE_VIDEO, /*!< 2 - reserved */ JB_TYPE_SILENCE /*!< 3 */ }; typedef struct jb_conf { /* settings */ long max_jitterbuf; /*!< defines a hard clamp to use in setting the jitter buffer delay */ long resync_threshold; /*!< the jb will resync when delay increases to (2 * jitter) + this param */ long max_contig_interp; /*!< the max interp frames to return in a row */ long target_extra ; /*!< amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */ } jb_conf; typedef struct jb_info { jb_conf conf; /* statistics */ long frames_in; /*!< number of frames input to the jitterbuffer.*/ long frames_out; /*!< number of frames output from the jitterbuffer.*/ long frames_late; /*!< number of frames which were too late, and dropped.*/ long frames_lost; /*!< number of missing frames.*/ long frames_dropped; /*!< number of frames dropped (shrinkage) */ long frames_ooo; /*!< number of frames received out-of-order */ long frames_cur; /*!< number of frames presently in jb, awaiting delivery.*/ long jitter; /*!< jitter measured within current history interval*/ long min; /*!< minimum lateness within current history interval */ long current; /*!< the present jitterbuffer adjustment */ long target; /*!< the target jitterbuffer adjustment */ long losspct; /*!< recent lost frame percentage (* 1000) */ long next_voice_ts; /*!< the ts of the next frame to be read from the jb - in receiver's time */ long last_voice_ms; /*!< the duration of the last voice frame */ long silence_begin_ts; /*!< the time of the last CNG frame, when in silence */ long last_adjustment; /*!< the time of the last adjustment */ long last_delay; /*!< the last now added to history */ long cnt_delay_discont; /*!< the count of discontinuous delays */ long resync_offset; /*!< the amount to offset ts to support resyncs */ long cnt_contig_interp; /*!< the number of contiguous interp frames returned */ } jb_info; typedef struct jb_frame { void *data; /* the frame data */ long ts; /* the relative delivery time expected */ long ms; /* the time covered by this frame, in sec/8000 */ enum jb_frame_type type; /* the type of frame */ struct jb_frame *next, *prev; } jb_frame; typedef struct jitterbuf { jb_info info; /* history */ long history[JB_HISTORY_SZ]; /*!< history */ int hist_ptr; /*!< points to index in history for next entry */ long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the max delays (highest first) */ long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the min delays (lowest first) */ int hist_maxbuf_valid; /*!< are the "maxbuf"/minbuf valid? */ unsigned int dropem:1; /*!< flag to indicate dropping frames (overload) */ jb_frame *frames; /*!< queued frames */ jb_frame *free; /*!< free frames (avoid malloc?) */ } jitterbuf; /*! \brief new jitterbuf */ jitterbuf * jb_new(void); /*! \brief destroy jitterbuf */ void jb_destroy(jitterbuf *jb); /*! \brief reset jitterbuf * \note The jitterbuffer should be empty before you call this, otherwise * you will leak queued frames, and some internal structures */ void jb_reset(jitterbuf *jb); /*!\brief queue a frame * * data=frame data, timings (in ms): ms=length of frame (for voice), ts=ts (sender's time) * now=now (in receiver's time) return value is one of * JB_OK: Frame added. Last call to jb_next() still valid * JB_DROP: Drop this frame immediately * JB_SCHED: Frame added. Call jb_next() to get a new time for the next frame */ enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now); /*! \brief get a frame for time now (receiver's time) return value is one of * JB_OK: You've got frame! * JB_DROP: Here's an audio frame you should just drop. Ask me again for this time.. * JB_NOFRAME: There's no frame scheduled for this time. * JB_INTERP: Please interpolate an interpl-length frame for this time (either we need to grow, or there was a lost frame) * JB_EMPTY: The jb is empty. */ enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl); /*! \brief unconditionally get frames from jitterbuf until empty */ enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout); /*! \brief when is the next frame due out, in receiver's time (0=EMPTY) * This value may change as frames are added (esp non-audio frames) */ long jb_next(jitterbuf *jb); /*! \brief get jitterbuf info: only "statistics" may be valid */ enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats); /*! \brief set jitterbuf conf */ enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf); typedef void __attribute__((format(printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...); void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/include/asterisk/0000755000175000007640000000000012254071123016612 5ustar sharkyjerrywebasterisk-11.7.0/include/asterisk/security_events_defs.h0000644000175000007640000003255311743106462023236 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Digium, Inc. * * Russell Bryant * * 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 Security Event Reporting Data Structures * * \author Russell Bryant */ #ifndef __AST_SECURITY_EVENTS_DEFS_H__ #define __AST_SECURITY_EVENTS_DEFS_H__ #include "asterisk/network.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! * \brief Security event types * * AST_EVENT_SECURITY is the event type of an ast_event generated as a security * event. The event will have an information element of type * AST_EVENT_IE_SECURITY_EVENT which identifies the security event sub-type. * This enum defines the possible values for this sub-type. */ enum ast_security_event_type { /*! * \brief Failed ACL * * This security event should be generated when an incoming request * was made, but was denied due to configured IP address access control * lists. */ AST_SECURITY_EVENT_FAILED_ACL, /*! * \brief Invalid Account ID * * This event is used when an invalid account identifier is supplied * during authentication. For example, if an invalid username is given, * this event should be used. */ AST_SECURITY_EVENT_INVAL_ACCT_ID, /*! * \brief Session limit reached * * A request has been denied because a configured session limit has been * reached, such as a call limit. */ AST_SECURITY_EVENT_SESSION_LIMIT, /*! * \brief Memory limit reached * * A request has been denied because a configured memory limit has been * reached. */ AST_SECURITY_EVENT_MEM_LIMIT, /*! * \brief Load Average limit reached * * A request has been denied because a configured load average limit has been * reached. */ AST_SECURITY_EVENT_LOAD_AVG, /*! * \brief A request was made that we understand, but do not support */ AST_SECURITY_EVENT_REQ_NO_SUPPORT, /*! * \brief A request was made that is not allowed */ AST_SECURITY_EVENT_REQ_NOT_ALLOWED, /*! * \brief The attempted authentication method is not allowed */ AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED, /*! * \brief Request received with bad formatting */ AST_SECURITY_EVENT_REQ_BAD_FORMAT, /*! * \brief FYI FWIW, Successful authentication has occurred */ AST_SECURITY_EVENT_SUCCESSFUL_AUTH, /*! * \brief An unexpected source address was seen for a session in progress */ AST_SECURITY_EVENT_UNEXPECTED_ADDR, /*! * \brief An attempt at challenge/response authentication failed */ AST_SECURITY_EVENT_CHAL_RESP_FAILED, /*! * \brief An attempt at basic password authentication failed */ AST_SECURITY_EVENT_INVAL_PASSWORD, /*! * \brief Challenge was sent out, informational */ AST_SECURITY_EVENT_CHAL_SENT, /*! * \brief An attempt to contact a peer on an invalid transport. */ AST_SECURITY_EVENT_INVAL_TRANSPORT, /*! * \brief This _must_ stay at the end. */ AST_SECURITY_EVENT_NUM_TYPES }; /*! * \brief the severity of a security event * * This is defined as a bit field to make it easy for consumers of the API to * subscribe to any combination of the defined severity levels. * * XXX \todo Do we need any more levels here? */ enum ast_security_event_severity { /*! \brief Informational event, not something that has gone wrong */ AST_SECURITY_EVENT_SEVERITY_INFO = (1 << 0), /*! \brief Something has gone wrong */ AST_SECURITY_EVENT_SEVERITY_ERROR = (1 << 1), }; /*! * \brief Transport types */ enum ast_security_event_transport_type { AST_SECURITY_EVENT_TRANSPORT_UDP, AST_SECURITY_EVENT_TRANSPORT_TCP, AST_SECURITY_EVENT_TRANSPORT_TLS, }; #define AST_SEC_EVT(e) ((struct ast_security_event_common *) e) struct ast_security_event_ip_addr { const struct ast_sockaddr *addr; enum ast_security_event_transport_type transport; }; /*! * \brief Common structure elements * * This is the structure header for all event descriptor structures defined * below. The contents of this structure are very important and must not * change. Even though these structures are exposed via a public API, we have * a version field that can be used to ensure ABI safety. If the event * descriptors need to be changed or updated in the future, we can safely do * so and can detect ABI changes at runtime. */ struct ast_security_event_common { /*! \brief The security event sub-type */ enum ast_security_event_type event_type; /*! \brief security event version */ uint32_t version; /*! * \brief Service that generated the event * \note Always required * * Examples: "SIP", "AMI" */ const char *service; /*! * \brief Module, Normally the AST_MODULE define * \note Always optional */ const char *module; /*! * \brief Account ID, specific to the service type * \note optional/required, depending on event type */ const char *account_id; /*! * \brief Session ID, specific to the service type * \note Always required */ const char *session_id; /*! * \brief Session timeval, when the session started * \note Always optional */ const struct timeval *session_tv; /*! * \brief Local address the request came in on * \note Always required */ struct ast_security_event_ip_addr local_addr; /*! * \brief Remote address the request came from * \note Always required */ struct ast_security_event_ip_addr remote_addr; }; /*! * \brief Checking against an IP access control list failed */ struct ast_security_event_failed_acl { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_FAILED_ACL_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief ACL name, identifies which ACL was hit * \note optional */ const char *acl_name; }; /*! * \brief Invalid account ID specified (invalid username, for example) */ struct ast_security_event_inval_acct_id { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; }; /*! * \brief Request denied because of a session limit */ struct ast_security_event_session_limit { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_SESSION_LIMIT_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; }; /*! * \brief Request denied because of a memory limit */ struct ast_security_event_mem_limit { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_MEM_LIMIT_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; }; /*! * \brief Request denied because of a load average limit */ struct ast_security_event_load_avg { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_LOAD_AVG_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; }; /*! * \brief Request denied because we don't support it */ struct ast_security_event_req_no_support { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Request type that was made * \note required */ const char *request_type; }; /*! * \brief Request denied because it's not allowed */ struct ast_security_event_req_not_allowed { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Request type that was made * \note required */ const char *request_type; /*! * \brief Request type that was made * \note optional */ const char *request_params; }; /*! * \brief Auth method used not allowed */ struct ast_security_event_auth_method_not_allowed { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_AUTH_METHOD_NOT_ALLOWED_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Auth method attempted * \note required */ const char *auth_method; }; /*! * \brief Invalid formatting of request */ struct ast_security_event_req_bad_format { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID optional */ struct ast_security_event_common common; /*! * \brief Request type that was made * \note required */ const char *request_type; /*! * \brief Request type that was made * \note optional */ const char *request_params; }; /*! * \brief Successful authentication */ struct ast_security_event_successful_auth { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Using password - if a password was used or not * \note required, 0 = no, 1 = yes */ uint32_t *using_password; }; /*! * \brief Unexpected source address for a session in progress */ struct ast_security_event_unexpected_addr { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_UNEXPECTED_ADDR_VERSION 2 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Expected remote address * \note required */ struct ast_security_event_ip_addr expected_addr; }; /*! * \brief An attempt at challenge/response auth failed */ struct ast_security_event_chal_resp_failed { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Challenge provided * \note required */ const char *challenge; /*! * \brief Response received * \note required */ const char *response; /*! * \brief Response expected to be received * \note required */ const char *expected_response; }; /*! * \brief An attempt at basic password auth failed */ struct ast_security_event_inval_password { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION 2 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Challenge provided * \note required */ const char *challenge; /*! * \brief Challenge received * \note required */ const char *received_challenge; /*! * \brief Hash received * \note required */ const char *received_hash; }; /*! * \brief A challenge was sent out */ struct ast_security_event_chal_sent { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_CHAL_SENT_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Challenge sent * \note required */ const char *challenge; }; /*! * \brief Attempt to contact peer on invalid transport */ struct ast_security_event_inval_transport { /*! * \brief Event descriptor version * \note This _must_ be changed if this event descriptor is changed. */ #define AST_SECURITY_EVENT_INVAL_TRANSPORT_VERSION 1 /*! * \brief Common security event descriptor elements * \note Account ID required */ struct ast_security_event_common common; /*! * \brief Attempted transport * \note required */ const char *transport; }; #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* __AST_SECURITY_EVENTS_DEFS_H__ */ asterisk-11.7.0/include/asterisk/dlinkedlists.h0000644000175000007640000012203711667464204021476 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007, Digium, Inc. * * Steve Murphy * * Doubly-Linked List Macros-- * Based on linkedlists.h (to the point of plagiarism!), which is by: * * Mark Spencer * Kevin P. Fleming * * 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. */ #ifndef ASTERISK_DLINKEDLISTS_H #define ASTERISK_DLINKEDLISTS_H #include "asterisk/lock.h" /*! * \file dlinkedlists.h * \brief A set of macros to manage doubly-linked lists. */ /*! * \brief Locks a list. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * \since 1.6.1 */ #define AST_DLLIST_LOCK(head) \ ast_mutex_lock(&(head)->lock) /*! * \brief Write locks a list. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive write lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * \since 1.6.1 */ #define AST_RWDLLIST_WRLOCK(head) \ ast_rwlock_wrlock(&(head)->lock) /*! * \brief Read locks a list. * \param head This is a pointer to the list head structure * * This macro attempts to place a read lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * \since 1.6.1 */ #define AST_RWDLLIST_RDLOCK(head) \ ast_rwlock_rdlock(&(head)->lock) /*! * \brief Locks a list, without blocking if the list is locked. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * \since 1.6.1 */ #define AST_DLLIST_TRYLOCK(head) \ ast_mutex_trylock(&(head)->lock) /*! * \brief Write locks a list, without blocking if the list is locked. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive write lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * \since 1.6.1 */ #define AST_RWDLLIST_TRYWRLOCK(head) \ ast_rwlock_trywrlock(&(head)->lock) /*! * \brief Read locks a list, without blocking if the list is locked. * \param head This is a pointer to the list head structure * * This macro attempts to place a read lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * \since 1.6.1 */ #define AST_RWDLLIST_TRYRDLOCK(head) \ ast_rwlock_tryrdlock(&(head)->lock) /*! * \brief Attempts to unlock a list. * \param head This is a pointer to the list head structure * * This macro attempts to remove an exclusive lock from the * list head structure pointed to by head. If the list * was not locked by this thread, this macro has no effect. * \since 1.6.1 */ #define AST_DLLIST_UNLOCK(head) \ ast_mutex_unlock(&(head)->lock) /*! * \brief Attempts to unlock a read/write based list. * \param head This is a pointer to the list head structure * * This macro attempts to remove a read or write lock from the * list head structure pointed to by head. If the list * was not locked by this thread, this macro has no effect. * \since 1.6.1 */ #define AST_RWDLLIST_UNLOCK(head) \ ast_rwlock_unlock(&(head)->lock) /*! * \brief Defines a structure to be used to hold a list of specified type. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type. It does not actually * declare (allocate) a structure; to do that, either follow this * macro with the desired name of the instance you wish to declare, * or use the specified \a name to declare instances elsewhere. * * Example usage: * \code * static AST_DLLIST_HEAD(entry_list, entry) entries; * \endcode * * This would define \c struct \c entry_list, and declare an instance of it named * \a entries, all intended to hold a list of type \c struct \c entry. * \since 1.6.1 */ #define AST_DLLIST_HEAD(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ } /*! * \brief Defines a structure to be used to hold a read/write list of specified type. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type. It does not actually * declare (allocate) a structure; to do that, either follow this * macro with the desired name of the instance you wish to declare, * or use the specified \a name to declare instances elsewhere. * * Example usage: * \code * static AST_RWDLLIST_HEAD(entry_list, entry) entries; * \endcode * * This would define \c struct \c entry_list, and declare an instance of it named * \a entries, all intended to hold a list of type \c struct \c entry. * \since 1.6.1 */ #define AST_RWDLLIST_HEAD(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_rwlock_t lock; \ } /*! * \brief Defines a structure to be used to hold a list of specified type (with no lock). * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type. It does not actually * declare (allocate) a structure; to do that, either follow this * macro with the desired name of the instance you wish to declare, * or use the specified \a name to declare instances elsewhere. * * Example usage: * \code * static AST_DLLIST_HEAD_NOLOCK(entry_list, entry) entries; * \endcode * * This would define \c struct \c entry_list, and declare an instance of it named * \a entries, all intended to hold a list of type \c struct \c entry. * \since 1.6.1 */ #define AST_DLLIST_HEAD_NOLOCK(name, type) \ struct name { \ struct type *first; \ struct type *last; \ } /*! * \brief Defines initial values for a declaration of AST_DLLIST_HEAD * \since 1.6.1 */ #define AST_DLLIST_HEAD_INIT_VALUE \ { \ .first = NULL, \ .last = NULL, \ .lock = AST_MUTEX_INIT_VALUE, \ } /*! * \brief Defines initial values for a declaration of AST_RWDLLIST_HEAD * \since 1.6.1 */ #define AST_RWDLLIST_HEAD_INIT_VALUE \ { \ .first = NULL, \ .last = NULL, \ .lock = AST_RWLOCK_INIT_VALUE, \ } /*! * \brief Defines initial values for a declaration of AST_DLLIST_HEAD_NOLOCK * \since 1.6.1 */ #define AST_DLLIST_HEAD_NOLOCK_INIT_VALUE \ { \ .first = NULL, \ .last = NULL, \ } /*! * \brief Defines a structure to be used to hold a list of specified type, statically initialized. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type, and allocates an instance * of it, initialized to be empty. * * Example usage: * \code * static AST_DLLIST_HEAD_STATIC(entry_list, entry); * \endcode * * This would define \c struct \c entry_list, intended to hold a list of * type \c struct \c entry. * \since 1.6.1 */ #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) #define AST_DLLIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ } name; \ static void __attribute__((constructor)) __init_##name(void) \ { \ AST_DLLIST_HEAD_INIT(&name); \ } \ static void __attribute__((destructor)) __fini_##name(void) \ { \ AST_DLLIST_HEAD_DESTROY(&name); \ } \ struct __dummy_##name #else #define AST_DLLIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ } name = AST_DLLIST_HEAD_INIT_VALUE #endif /*! * \brief Defines a structure to be used to hold a read/write list of specified type, statically initialized. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type, and allocates an instance * of it, initialized to be empty. * * Example usage: * \code * static AST_RWDLLIST_HEAD_STATIC(entry_list, entry); * \endcode * * This would define \c struct \c entry_list, intended to hold a list of * type \c struct \c entry. * \since 1.6.1 */ #ifndef HAVE_PTHREAD_RWLOCK_INITIALIZER #define AST_RWDLLIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_rwlock_t lock; \ } name; \ static void __attribute__((constructor)) __init_##name(void) \ { \ AST_RWDLLIST_HEAD_INIT(&name); \ } \ static void __attribute__((destructor)) __fini_##name(void) \ { \ AST_RWDLLIST_HEAD_DESTROY(&name); \ } \ struct __dummy_##name #else #define AST_RWDLLIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_rwlock_t lock; \ } name = AST_RWDLLIST_HEAD_INIT_VALUE #endif /*! * \brief Defines a structure to be used to hold a list of specified type, statically initialized. * * This is the same as AST_DLLIST_HEAD_STATIC, except without the lock included. * \since 1.6.1 */ #define AST_DLLIST_HEAD_NOLOCK_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ } name = AST_DLLIST_HEAD_NOLOCK_INIT_VALUE /*! * \brief Initializes a list head structure with a specified first entry. * \param head This is a pointer to the list head structure * \param entry pointer to the list entry that will become the head of the list * * This macro initializes a list head structure by setting the head * entry to the supplied value and recreating the embedded lock. * \since 1.6.1 */ #define AST_DLLIST_HEAD_SET(head, entry) \ do { \ (head)->first = (entry); \ (head)->last = (entry); \ ast_mutex_init(&(head)->lock); \ } while (0) /*! * \brief Initializes an rwlist head structure with a specified first entry. * \param head This is a pointer to the list head structure * \param entry pointer to the list entry that will become the head of the list * * This macro initializes a list head structure by setting the head * entry to the supplied value and recreating the embedded lock. * \since 1.6.1 */ #define AST_RWDLLIST_HEAD_SET(head, entry) \ do { \ (head)->first = (entry); \ (head)->last = (entry); \ ast_rwlock_init(&(head)->lock); \ } while (0) /*! * \brief Initializes a list head structure with a specified first entry. * \param head This is a pointer to the list head structure * \param entry pointer to the list entry that will become the head of the list * * This macro initializes a list head structure by setting the head * entry to the supplied value. * \since 1.6.1 */ #define AST_DLLIST_HEAD_SET_NOLOCK(head, entry) \ do { \ (head)->first = (entry); \ (head)->last = (entry); \ } while (0) /*! * \brief Declare previous/forward links inside a list entry. * \param type This is the type of each list entry. * * This macro declares a structure to be used to doubly link list entries together. * It must be used inside the definition of the structure named in * \a type, as follows: * * \code * struct list_entry { * ... * AST_DLLIST_ENTRY(list_entry) list; * } * \endcode * * The field name \a list here is arbitrary, and can be anything you wish. * \since 1.6.1 */ #define AST_DLLIST_ENTRY(type) AST_DLLIST_HEAD_NOLOCK(, type) #define AST_RWDLLIST_ENTRY AST_DLLIST_ENTRY /*! * \brief Returns the first entry contained in a list. * \param head This is a pointer to the list head structure * \since 1.6.1 */ #define AST_DLLIST_FIRST(head) ((head)->first) #define AST_RWDLLIST_FIRST AST_DLLIST_FIRST /*! * \brief Returns the last entry contained in a list. * \param head This is a pointer to the list head structure * \since 1.6.1 */ #define AST_DLLIST_LAST(head) ((head)->last) #define AST_RWDLLIST_LAST AST_DLLIST_LAST #define AST_DLLIST_NEXT_DIRECTION(elm, field, direction) ((elm)->field.direction) #define AST_RWDLLIST_NEXT_DIRECTION AST_DLLIST_NEXT_DIRECTION /*! * \brief Returns the next entry in the list after the given entry. * \param elm This is a pointer to the current entry. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * \since 1.6.1 */ #define AST_DLLIST_NEXT(elm, field) AST_DLLIST_NEXT_DIRECTION(elm, field, first) #define AST_RWDLLIST_NEXT AST_DLLIST_NEXT /*! * \brief Returns the previous entry in the list before the given entry. * \param elm This is a pointer to the current entry. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * \since 1.6.1 */ #define AST_DLLIST_PREV(elm, field) AST_DLLIST_NEXT_DIRECTION(elm, field, last) #define AST_RWDLLIST_PREV AST_DLLIST_PREV /*! * \brief Checks whether the specified list contains any entries. * \param head This is a pointer to the list head structure * * \return non-zero if the list has entries * \return zero if not. * \since 1.6.1 */ #define AST_DLLIST_EMPTY(head) (AST_DLLIST_FIRST(head) == NULL) #define AST_RWDLLIST_EMPTY AST_DLLIST_EMPTY /*! * \brief Checks whether the specified list contains the element. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the list element to see if in list. * \param field List node field for the next node information. * * \return elm if the list has elm in it. * \return NULL if not. * \since 11 */ #define AST_DLLIST_IS_MEMBER(head, elm, field) \ ({ \ typeof((head)->first) __cur; \ typeof((elm)) __elm = (elm); \ if (!__elm) { \ __cur = NULL; \ } else { \ __cur = (head)->first; \ while (__cur && __cur != __elm) { \ __cur = __cur->field.first; \ } \ } \ __cur; \ }) #define AST_RWDLLIST_IS_MEMBER AST_DLLIST_IS_MEMBER /*! * \brief Traverse a doublly linked list using the specified direction list. * * \param head List head structure pointer. * \param var This is the name of the variable that will hold a pointer to the * current list node on each iteration. It must be declared before calling * this macro. * \param field List node field for the next node information. (declared using AST_DLLIST_ENTRY()) * \param start Specified list node to start traversal: first or last * * This macro is use to loop over (traverse) the nodes in a list. It uses a * \a for loop, and supplies the enclosed code with a pointer to each list * node as it loops. It is typically used as follows: * \code * static AST_DLLIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { * ... * AST_DLLIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_DLLIST_TRAVERSE_DIRECTION(&entries, current, list, first) { * (do something with current here (travers list in forward direction)) * } * ... * AST_DLLIST_TRAVERSE_DIRECTION(&entries, current, list, last) { * (do something with current here (travers list in reverse direction)) * } * \endcode * * \since 11 */ #define AST_DLLIST_TRAVERSE_DIRECTION(head, var, field, start) \ for ((var) = (head)->start; (var); (var) = AST_DLLIST_NEXT_DIRECTION(var, field, start)) #define AST_RWDLLIST_TRAVERSE_DIRECTION AST_DLLIST_TRAVERSE_DIRECTION /*! * \brief Loops over (traverses) the entries in a list. * \param head This is a pointer to the list head structure * \param var This is the name of the variable that will hold a pointer to the * current list entry on each iteration. It must be declared before calling * this macro. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * This macro is use to loop over (traverse) the entries in a list. It uses a * \a for loop, and supplies the enclosed code with a pointer to each list * entry as it loops. It is typically used as follows: * \code * static AST_DLLIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { * ... * AST_DLLIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_DLLIST_TRAVERSE(&entries, current, list) { * (do something with current here) * } * \endcode * \warning If you modify the forward-link pointer contained in the \a current entry while * inside the loop, the behavior will be unpredictable. At a minimum, the following * macros will modify the forward-link pointer, and should not be used inside * AST_DLLIST_TRAVERSE() against the entry pointed to by the \a current pointer without * careful consideration of their consequences: * \li AST_DLLIST_NEXT() (when used as an lvalue) * \li AST_DLLIST_INSERT_AFTER() * \li AST_DLLIST_INSERT_HEAD() * \li AST_DLLIST_INSERT_TAIL() * \since 1.6.1 */ #define AST_DLLIST_TRAVERSE(head,var,field) \ AST_DLLIST_TRAVERSE_DIRECTION(head, var, field, first) #define AST_RWDLLIST_TRAVERSE AST_DLLIST_TRAVERSE /*! * \brief Loops over (traverses) the entries in a list in reverse order, starting at the end. * \param head This is a pointer to the list head structure * \param var This is the name of the variable that will hold a pointer to the * current list entry on each iteration. It must be declared before calling * this macro. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * This macro is use to loop over (traverse) the entries in a list in reverse order. It uses a * \a for loop, and supplies the enclosed code with a pointer to each list * entry as it loops. It is typically used as follows: * \code * static AST_DLLIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { * ... * AST_DLLIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_DLLIST_TRAVERSE_BACKWARDS(&entries, current, list) { * (do something with current here) * } * \endcode * \warning If you modify the forward-link pointer contained in the \a current entry while * inside the loop, the behavior will be unpredictable. At a minimum, the following * macros will modify the forward-link pointer, and should not be used inside * AST_DLLIST_TRAVERSE() against the entry pointed to by the \a current pointer without * careful consideration of their consequences: * \li AST_DLLIST_PREV() (when used as an lvalue) * \li AST_DLLIST_INSERT_BEFORE() * \li AST_DLLIST_INSERT_HEAD() * \li AST_DLLIST_INSERT_TAIL() * \since 1.6.1 */ #define AST_DLLIST_TRAVERSE_BACKWARDS(head,var,field) \ AST_DLLIST_TRAVERSE_DIRECTION(head, var, field, last) #define AST_RWDLLIST_TRAVERSE_BACKWARDS AST_DLLIST_TRAVERSE_BACKWARDS /*! * \brief Safe traversal of a doublly linked list using the specified direction list. * * \param head List head structure pointer. * \param var This is the name of the variable that will hold a pointer to the * current list node on each iteration. It must be declared before calling * this macro. * \param field List node field for the next node information. (declared using AST_DLLIST_ENTRY()) * \param start Specified list node to start traversal: first or last * * This macro is used to safely loop over (traverse) the nodes in a list. It * uses a \a for loop, and supplies the enclosed code with a pointer to each list * node as it loops. It is typically used as follows: * * \code * static AST_DLLIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { * ... * AST_DLLIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_DLLIST_TRAVERSE_DIRECTION_SAFE_BEGIN(&entries, current, list, first) { * (do something with current here (travers list in forward direction)) * } * ... * AST_DLLIST_TRAVERSE_DIRECTION_SAFE_BEGIN(&entries, current, list, last) { * (do something with current here (travers list in reverse direction)) * } * AST_DLLIST_TRAVERSE_DIRECTION_SAFE_END; * \endcode * * It differs from AST_DLLIST_TRAVERSE() in that the code inside the loop can modify * (or even free, after calling AST_DLLIST_REMOVE_CURRENT()) the entry pointed to by * the \a current pointer without affecting the loop traversal. * * \since 11 */ #define AST_DLLIST_TRAVERSE_DIRECTION_SAFE_BEGIN(head, var, field, start) \ do { \ typeof((head)) __list_head = (head); \ typeof(__list_head->first) __list_current; \ typeof(__list_head->first) __list_first; \ typeof(__list_head->first) __list_last; \ typeof(__list_head->first) __list_next; \ for ((var) = __list_head->start, \ __list_current = (var), \ __list_first = (var) ? (var)->field.first : NULL, \ __list_last = (var) ? (var)->field.last : NULL, \ __list_next = (var) ? AST_DLLIST_NEXT_DIRECTION(var, field, start) : NULL; \ (var); \ (void) __list_current,/* To quiet compiler? */ \ (void) __list_first,/* To quiet compiler? */ \ (void) __list_last,/* To quiet compiler? */ \ (var) = __list_next, \ __list_current = (var), \ __list_first = (var) ? (var)->field.first : NULL, \ __list_last = (var) ? (var)->field.last : NULL, \ __list_next = (var) ? AST_DLLIST_NEXT_DIRECTION(var, field, start) : NULL \ ) #define AST_RWDLLIST_TRAVERSE_DIRECTION_SAFE_BEGIN AST_DLLIST_TRAVERSE_DIRECTION_SAFE_BEGIN /*! * \brief Inserts a list node before the current node during a traversal. * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link nodes of this list together. * * \since 1.6.1 */ #define AST_DLLIST_INSERT_BEFORE_CURRENT(elm, field) \ do { \ typeof((elm)) __elm = (elm); \ __elm->field.last = __list_last; \ __elm->field.first = __list_current; \ if (__list_head->first == __list_current) { \ __list_head->first = __elm; \ } else { \ __list_last->field.first = __elm; \ } \ __list_current->field.last = __elm; \ if (__list_next == __list_last) { \ __list_next = __elm; \ } \ __list_last = __elm; \ } while (0) #define AST_RWDLLIST_INSERT_BEFORE_CURRENT AST_DLLIST_INSERT_BEFORE_CURRENT /*! * \brief Inserts a list node after the current node during a traversal. * \param elm This is a pointer to the node to be inserted. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link nodes of this list together. * * \since 11 */ #define AST_DLLIST_INSERT_AFTER_CURRENT(elm, field) \ do { \ typeof((elm)) __elm = (elm); \ __elm->field.first = __list_first; \ __elm->field.last = __list_current; \ if (__list_head->last == __list_current) { \ __list_head->last = __elm; \ } else { \ __list_first->field.last = __elm; \ } \ __list_current->field.first = __elm; \ if (__list_next == __list_first) { \ __list_next = __elm; \ } \ __list_first = __elm; \ } while (0) #define AST_RWDLLIST_INSERT_AFTER_CURRENT AST_DLLIST_INSERT_AFTER_CURRENT /*! * \brief Removes the \a current entry from a list during a traversal. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * \note This macro can \b only be used inside an AST_DLLIST_TRAVERSE_SAFE_BEGIN() * block; it is used to unlink the current entry from the list without affecting * the list traversal (and without having to re-traverse the list to modify the * previous entry, if any). * \since 1.6.1 */ #define AST_DLLIST_REMOVE_CURRENT(field) \ do { \ if (__list_first) { \ __list_first->field.last = __list_last; \ } else { \ __list_head->last = __list_last; \ } \ if (__list_last) { \ __list_last->field.first = __list_first; \ } else { \ __list_head->first = __list_first; \ } \ __list_current->field.first = NULL; \ __list_current->field.last = NULL; \ __list_current = NULL; \ } while (0) #define AST_RWDLLIST_REMOVE_CURRENT AST_DLLIST_REMOVE_CURRENT /*! * \brief Move the current list entry to another list at the tail. * * \note This is a silly macro. It should be done explicitly * otherwise the field parameter must be the same for the two * lists. * * AST_DLLIST_REMOVE_CURRENT(field); * AST_DLLIST_INSERT_TAIL(newhead, var, other_field); */ #define AST_DLLIST_MOVE_CURRENT(newhead, field) \ do { \ typeof ((newhead)->first) __list_cur = __list_current; \ AST_DLLIST_REMOVE_CURRENT(field); \ AST_DLLIST_INSERT_TAIL((newhead), __list_cur, field); \ } while (0) #define AST_RWDLLIST_MOVE_CURRENT AST_DLLIST_MOVE_CURRENT /*! * \brief Move the current list entry to another list at the head. * * \note This is a silly macro. It should be done explicitly * otherwise the field parameter must be the same for the two * lists. * * AST_DLLIST_REMOVE_CURRENT(field); * AST_DLLIST_INSERT_HEAD(newhead, var, other_field); */ #define AST_DLLIST_MOVE_CURRENT_BACKWARDS(newhead, field) \ do { \ typeof ((newhead)->first) __list_cur = __list_current; \ AST_DLLIST_REMOVE_CURRENT(field); \ AST_DLLIST_INSERT_HEAD((newhead), __list_cur, field); \ } while (0) #define AST_RWDLLIST_MOVE_CURRENT_BACKWARDS AST_DLLIST_MOVE_CURRENT_BACKWARDS #define AST_DLLIST_TRAVERSE_DIRECTION_SAFE_END \ } while (0) #define AST_RWDLLIST_TRAVERSE_DIRECTION_SAFE_END AST_DLLIST_TRAVERSE_DIRECTION_SAFE_END /*! * \brief Loops safely over (traverses) the entries in a list. * \param head This is a pointer to the list head structure * \param var This is the name of the variable that will hold a pointer to the * current list entry on each iteration. It must be declared before calling * this macro. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * This macro is used to safely loop over (traverse) the entries in a list. It * uses a \a for loop, and supplies the enclosed code with a pointer to each list * entry as it loops. It is typically used as follows: * * \code * static AST_DLLIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { * ... * AST_DLLIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_DLLIST_TRAVERSE_SAFE_BEGIN(&entries, current, list) { * (do something with current here) * } * AST_DLLIST_TRAVERSE_SAFE_END; * \endcode * * It differs from AST_DLLIST_TRAVERSE() in that the code inside the loop can modify * (or even free, after calling AST_DLLIST_REMOVE_CURRENT()) the entry pointed to by * the \a current pointer without affecting the loop traversal. * \since 1.6.1 */ #define AST_DLLIST_TRAVERSE_SAFE_BEGIN(head, var, field) \ AST_DLLIST_TRAVERSE_DIRECTION_SAFE_BEGIN(head, var, field, first) #define AST_RWDLLIST_TRAVERSE_SAFE_BEGIN AST_DLLIST_TRAVERSE_SAFE_BEGIN /*! * \brief Loops safely over (traverses) the entries in a list. * \param head This is a pointer to the list head structure * \param var This is the name of the variable that will hold a pointer to the * current list entry on each iteration. It must be declared before calling * this macro. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * This macro is used to safely loop over (traverse) the entries in a list. It * uses a \a for loop, and supplies the enclosed code with a pointer to each list * entry as it loops. It is typically used as follows: * * \code * static AST_DLLIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { * ... * AST_DLLIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_DLLIST_TRAVERSE_SAFE_BEGIN(&entries, current, list) { * (do something with current here) * } * AST_DLLIST_TRAVERSE_SAFE_END; * \endcode * * It differs from AST_DLLIST_TRAVERSE() in that the code inside the loop can modify * (or even free, after calling AST_DLLIST_REMOVE_CURRENT()) the entry pointed to by * the \a current pointer without affecting the loop traversal. * \since 1.6.1 */ #define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(head, var, field) \ AST_DLLIST_TRAVERSE_DIRECTION_SAFE_BEGIN(head, var, field, last) #define AST_RWDLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN /*! * \brief Inserts a list entry after the current entry during a backwards traversal. Since * this is a backwards traversal, this will insert the entry AFTER the current * element. Since this is a backwards traveral, though, this would be BEFORE * the current entry in traversal order. Confusing? * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * \since 1.6.1 */ #define AST_DLLIST_INSERT_BEFORE_CURRENT_BACKWARDS(elm, field) \ AST_DLLIST_INSERT_AFTER_CURRENT(elm, field) #define AST_RWDLLIST_INSERT_BEFORE_CURRENT_BACKWARDS AST_DLLIST_INSERT_BEFORE_CURRENT_BACKWARDS /*! * \brief Closes a safe loop traversal block. * \since 1.6.1 */ #define AST_DLLIST_TRAVERSE_SAFE_END AST_DLLIST_TRAVERSE_DIRECTION_SAFE_END #define AST_RWDLLIST_TRAVERSE_SAFE_END AST_DLLIST_TRAVERSE_SAFE_END /*! * \brief Closes a safe loop traversal block. * \since 1.6.1 */ #define AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END AST_DLLIST_TRAVERSE_DIRECTION_SAFE_END #define AST_RWDLLIST_TRAVERSE_BACKWARDS_SAFE_END AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END /*! * \brief Initializes a list head structure. * \param head This is a pointer to the list head structure * * This macro initializes a list head structure by setting the head * entry to \a NULL (empty list) and recreating the embedded lock. * \since 1.6.1 */ #define AST_DLLIST_HEAD_INIT(head) \ { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_mutex_init(&(head)->lock); \ } /*! * \brief Initializes an rwlist head structure. * \param head This is a pointer to the list head structure * * This macro initializes a list head structure by setting the head * entry to \a NULL (empty list) and recreating the embedded lock. * \since 1.6.1 */ #define AST_RWDLLIST_HEAD_INIT(head) \ { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_rwlock_init(&(head)->lock); \ } /*! * \brief Destroys a list head structure. * \param head This is a pointer to the list head structure * * This macro destroys a list head structure by setting the head * entry to \a NULL (empty list) and destroying the embedded lock. * It does not free the structure from memory. * \since 1.6.1 */ #define AST_DLLIST_HEAD_DESTROY(head) \ { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_mutex_destroy(&(head)->lock); \ } /*! * \brief Destroys an rwlist head structure. * \param head This is a pointer to the list head structure * * This macro destroys a list head structure by setting the head * entry to \a NULL (empty list) and destroying the embedded lock. * It does not free the structure from memory. * \since 1.6.1 */ #define AST_RWDLLIST_HEAD_DESTROY(head) \ { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_rwlock_destroy(&(head)->lock); \ } /*! * \brief Initializes a list head structure. * \param head This is a pointer to the list head structure * * This macro initializes a list head structure by setting the head * entry to \a NULL (empty list). There is no embedded lock handling * with this macro. * \since 1.6.1 */ #define AST_DLLIST_HEAD_INIT_NOLOCK(head) \ { \ (head)->first = NULL; \ (head)->last = NULL; \ } /*! * \brief Inserts a list entry after a given entry. * \param head This is a pointer to the list head structure * \param listelm This is a pointer to the entry after which the new entry should * be inserted. * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * \since 1.6.1 */ #define AST_DLLIST_INSERT_AFTER(head, listelm, elm, field) \ do { \ typeof((listelm)) __listelm = (listelm); \ typeof((elm)) __elm = (elm); \ __elm->field.first = __listelm->field.first; \ __elm->field.last = __listelm; \ if ((head)->last == __listelm) { \ (head)->last = __elm; \ } else { \ __listelm->field.first->field.last = __elm; \ } \ __listelm->field.first = __elm; \ } while (0) #define AST_RWDLLIST_INSERT_AFTER AST_DLLIST_INSERT_AFTER /*! * \brief Inserts a list entry before a given entry. * \param head This is a pointer to the list head structure * \param listelm This is a pointer to the entry before which the new entry should * be inserted. * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * \since 1.6.1 */ #define AST_DLLIST_INSERT_BEFORE(head, listelm, elm, field) \ do { \ typeof((listelm)) __listelm = (listelm); \ typeof((elm)) __elm = (elm); \ __elm->field.last = __listelm->field.last; \ __elm->field.first = __listelm; \ if ((head)->first == __listelm) { \ (head)->first = __elm; \ } else { \ __listelm->field.last->field.first = __elm; \ } \ __listelm->field.last = __elm; \ } while (0) #define AST_RWDLLIST_INSERT_BEFORE AST_DLLIST_INSERT_BEFORE /*! * \brief Inserts a list entry at the head of a list. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * \since 1.6.1 */ #define AST_DLLIST_INSERT_HEAD(head, elm, field) \ do { \ typeof((elm)) __elm = (elm); \ __elm->field.last = NULL; \ __elm->field.first = (head)->first; \ if (!(head)->first) { \ (head)->last = __elm; \ } else { \ (head)->first->field.last = __elm; \ } \ (head)->first = __elm; \ } while (0) #define AST_RWDLLIST_INSERT_HEAD AST_DLLIST_INSERT_HEAD /*! * \brief Appends a list entry to the tail of a list. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the entry to be appended. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * Note: The link field in the appended entry is \b not modified, so if it is * actually the head of a list itself, the entire list will be appended * temporarily (until the next AST_DLLIST_INSERT_TAIL is performed). * \since 1.6.1 */ #define AST_DLLIST_INSERT_TAIL(head, elm, field) \ do { \ typeof((elm)) __elm = (elm); \ __elm->field.first = NULL; \ if (!(head)->first) { \ __elm->field.last = NULL; \ (head)->first = __elm; \ } else { \ __elm->field.last = (head)->last; \ (head)->last->field.first = __elm; \ } \ (head)->last = __elm; \ } while (0) #define AST_RWDLLIST_INSERT_TAIL AST_DLLIST_INSERT_TAIL /*! * \brief Appends a whole list to the tail of a list. * \param head This is a pointer to the list head structure * \param list This is a pointer to the list to be appended. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * Note: The source list (the \a list parameter) will be empty after * calling this macro (the list entries are \b moved to the target list). * \since 1.6.1 */ #define AST_DLLIST_APPEND_DLLIST(head, list, field) \ do { \ if (!(head)->first) { \ (head)->first = (list)->first; \ (head)->last = (list)->last; \ } else { \ (head)->last->field.first = (list)->first; \ (list)->first->field.last = (head)->last; \ (head)->last = (list)->last; \ } \ (list)->first = NULL; \ (list)->last = NULL; \ } while (0) #define AST_RWDLLIST_APPEND_DLLIST AST_DLLIST_APPEND_DLLIST /*! * \brief Removes and returns the head entry from a list. * \param head This is a pointer to the list head structure * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * * Removes the head entry from the list, and returns a pointer to it. * This macro is safe to call on an empty list. * \since 1.6.1 */ #define AST_DLLIST_REMOVE_HEAD(head, field) \ ({ \ typeof((head)->first) cur = (head)->first; \ if (cur) { \ (head)->first = cur->field.first; \ if ((head)->first) { \ (head)->first->field.last = NULL; \ } \ cur->field.first = NULL; \ cur->field.last = NULL; \ if ((head)->last == cur) { \ (head)->last = NULL; \ } \ } \ cur; \ }) #define AST_RWDLLIST_REMOVE_HEAD AST_DLLIST_REMOVE_HEAD /*! * \brief Removes and returns the tail node from a list. * \param head This is a pointer to the list head structure * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link nodes of this list together. * * Removes the tail entry from the list, and returns a pointer to it. * This macro is safe to call on an empty list. * \since 11 */ #define AST_DLLIST_REMOVE_TAIL(head, field) \ ({ \ typeof((head)->last) cur = (head)->last; \ if (cur) { \ (head)->last = cur->field.last; \ if ((head)->last) { \ (head)->last->field.first = NULL; \ } \ cur->field.first = NULL; \ cur->field.last = NULL; \ if ((head)->first == cur) { \ (head)->first = NULL; \ } \ } \ cur; \ }) #define AST_RWDLLIST_REMOVE_TAIL AST_DLLIST_REMOVE_TAIL /*! * \brief Removes a specific entry from a list. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the entry to be removed. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link entries of this list together. * \warning The removed entry is \b not freed. * \since 1.6.1 */ #define AST_DLLIST_REMOVE(head, elm, field) \ do { \ typeof((elm)) __elm = (elm); \ if (__elm) { \ if (__elm->field.first) { \ __elm->field.first->field.last = __elm->field.last; \ } else { \ (head)->last = __elm->field.last; \ } \ if (__elm->field.last) { \ __elm->field.last->field.first = __elm->field.first; \ } else { \ (head)->first = __elm->field.first; \ } \ __elm->field.first = NULL; \ __elm->field.last = NULL; \ } \ } while (0) #define AST_RWDLLIST_REMOVE AST_DLLIST_REMOVE /*! * \brief Removes a specific node from a list if it is in the list. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the node to be removed. * \param field This is the name of the field (declared using AST_DLLIST_ENTRY()) * used to link nodes of this list together. * \warning The removed node is \b not freed. * \return elm if the list had elm in it. * \return NULL if not. * \since 11 */ #define AST_DLLIST_REMOVE_VERIFY(head, elm, field) \ ({ \ typeof((elm)) __res = AST_DLLIST_IS_MEMBER(head, elm, field); \ AST_DLLIST_REMOVE(head, __res, field); \ __res; \ }) #define AST_RWDLLIST_REMOVE_VERIFY AST_DLLIST_REMOVE_VERIFY #endif /* _ASTERISK_DLINKEDLISTS_H */ asterisk-11.7.0/include/asterisk/global_datastores.h0000644000175000007640000000212011403352444022452 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2007, Digium, Inc. * * Mark Michelson * * 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 globally accessible channel datastores * \author Mark Michelson */ #ifndef _ASTERISK_GLOBAL_DATASTORE_H #define _ASTERISK_GLOBAL_DATASTORE_H #include "asterisk/channel.h" extern const struct ast_datastore_info dialed_interface_info; extern const struct ast_datastore_info secure_call_info; struct ast_dialed_interface { AST_LIST_ENTRY(ast_dialed_interface) list; char interface[1]; }; struct ast_secure_call_store { unsigned int signaling:1; unsigned int media:1; }; #endif asterisk-11.7.0/include/asterisk/hashtab.h0000644000175000007640000004244112051276404020406 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2006, Digium, Inc. * * Steve Murphy * * 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. */ #ifndef _ASTERISK_HASHTAB_H_ #define _ASTERISK_HASHTAB_H_ #define __USE_UNIX98 1 /* to get the MUTEX_RECURSIVE stuff */ /*! \file * \brief Generic (perhaps overly so) hashtable implementation * \ref AstHash */ #include "asterisk/lock.h" /*! \page AstHash Hash Table support in Asterisk A hash table is a structure that allows for an exact-match search in O(1) (or close to that) time. The method: given: a set of {key,val} pairs. (at a minimum). given: a hash function, which, given a key, will return an integer. Ideally, each key in the set will have its own unique associated hash value. This hash number will index into an array. "buckets" are what the elements of this array are called. To handle possible collisions in hash values, buckets can form a list. The key for a value must be contained in the value, or we won't be able to find it in the bucket list. This implementation is pretty generic, because: 1. The value and key are expected to be in a structure (along with other data, perhaps) and it's address is a "void *". 2. The pointer to a compare function must be passed in at the time of creation, and is stored in the hashtable. 3. The pointer to a resize function, which returns 1 if the hash table is to be grown. A default routine is provided if the pointer is NULL, and uses the java hashtable metric of a 75% load factor. 4. The pointer to a "new size" function, which returns a preferable new size for the hash table bucket array. By default, a function is supplied which roughly doubles the size of the array, is provided. This size should ideally be a prime number. 5. The hashing function pointer must also be supplied. This function must be written by the user to access the keys in the objects being stored. Some helper functions that use a simple "mult by prime, add the next char", sort of string hash, or a simple modulus of the hash table size for ints, is provided; the user can use these simple algorithms to generate a hash, or implement any other algorithms they wish. 6. Recently updated the hash routines to use Doubly-linked lists for buckets, and added a doubly-linked list that threads thru every bucket in the table. The list of all buckets is on the HashTab struct. The Traversal was modified to go thru this list instead of searching the bucket array for buckets. This also should make it safe to remove a bucket during the traversal. Removal and destruction routines will work faster. */ struct ast_hashtab_bucket { const void *object; /*!< whatever it is we are storing in this table */ struct ast_hashtab_bucket *next; /*!< a DLL of buckets in hash collision */ struct ast_hashtab_bucket *prev; /*!< a DLL of buckets in hash collision */ struct ast_hashtab_bucket *tnext; /*!< a DLL of all the hash buckets for traversal */ struct ast_hashtab_bucket *tprev; /*!< a DLL of all the hash buckets for traversal */ }; struct ast_hashtab { struct ast_hashtab_bucket **array; struct ast_hashtab_bucket *tlist; /*!< the head of a DLList of all the hashbuckets in the table (for traversal). */ int (*compare) (const void *a, const void *b); /*!< a ptr to func that returns int, and take two void* ptrs, compares them, rets -1 if a < b; rets 0 if a==b; rets 1 if a>b */ int (*newsize) (struct ast_hashtab *tab); /*!< a ptr to func that returns int, a new size for hash tab, based on curr_size */ int (*resize) (struct ast_hashtab *tab); /*!< a function to decide whether this hashtable should be resized now */ unsigned int (*hash) (const void *obj); /*!< a hash func ptr for this table. Given a raw ptr to an obj, it calcs a hash.*/ int hash_tab_size; /*!< the size of the bucket array */ int hash_tab_elements; /*!< the number of objects currently stored in the table */ int largest_bucket_size; /*!< a stat on the health of the table */ int resize_count; /*!< a count of the number of times this table has been resized */ int do_locking; /*!< if 1 use locks to guarantee safety of insertions/deletions */ /* this spot reserved for the proper lock storage */ ast_rwlock_t lock; /* is this as good as it sounds? */ }; /*! \brief an iterator for traversing the buckets */ struct ast_hashtab_iter { struct ast_hashtab *tab; struct ast_hashtab_bucket *next; }; /* some standard, default routines for general use */ /*! * \brief Determines if the specified number is prime. * * \param num the number to test * \retval 0 if the number is not prime * \retval 1 if the number is prime */ int ast_is_prime(int num); /*! * \brief Compares two strings for equality. * * \param a a character string * \param b a character string * \retval 0 if the strings match * \retval <0 if string a is less than string b * \retval >0 if string a is greather than string b */ int ast_hashtab_compare_strings(const void *a, const void *b); /*! * \brief Compares two strings for equality, ignoring case. * * \param a a character string * \param b a character string * \retval 0 if the strings match * \retval <0 if string a is less than string b * \retval >0 if string a is greather than string b */ int ast_hashtab_compare_strings_nocase(const void *a, const void *b); /*! * \brief Compares two integers for equality. * * \param a an integer pointer (int *) * \param b an integer pointer (int *) * \retval 0 if the integers pointed to are equal * \retval 1 if a is greater than b * \retval -1 if a is less than b */ int ast_hashtab_compare_ints(const void *a, const void *b); /*! * \brief Compares two shorts for equality. * * \param a a short pointer (short *) * \param b a short pointer (short *) * \retval 0 if the shorts pointed to are equal * \retval 1 if a is greater than b * \retval -1 if a is less than b */ int ast_hashtab_compare_shorts(const void *a, const void *b); /*! * \brief Determines if a table resize should occur using the Java algorithm * (if the table load factor is 75% or higher). * * \param tab the hash table to operate on * \retval 0 if the table load factor is less than or equal to 75% * \retval 1 if the table load factor is greater than 75% */ int ast_hashtab_resize_java(struct ast_hashtab *tab); /*! \brief Causes a resize whenever the number of elements stored in the table * exceeds the number of buckets in the table. * * \param tab the hash table to operate on * \retval 0 if the number of elements in the table is less than or equal to * the number of buckets * \retval 1 if the number of elements in the table exceeds the number of * buckets */ int ast_hashtab_resize_tight(struct ast_hashtab *tab); /*! * \brief Effectively disables resizing by always returning 0, regardless of * of load factor. * * \param tab the hash table to operate on * \return 0 is always returned */ int ast_hashtab_resize_none(struct ast_hashtab *tab); /*! \brief Create a prime number roughly 2x the current table size */ int ast_hashtab_newsize_java(struct ast_hashtab *tab); /* not yet specified, probably will return 1.5x the current table size */ int ast_hashtab_newsize_tight(struct ast_hashtab *tab); /*! \brief always return current size -- no resizing */ int ast_hashtab_newsize_none(struct ast_hashtab *tab); /*! * \brief Hashes a string to a number * * \param obj the string to hash * \return Integer hash of the specified string * \sa ast_hashtable_hash_string_nocase * \sa ast_hashtab_hash_string_sax * \note A modulus will be applied to the return value of this function */ unsigned int ast_hashtab_hash_string(const void *obj); /*! * \brief Hashes a string to a number ignoring case * * \param obj the string to hash * \return Integer hash of the specified string * \sa ast_hashtable_hash_string * \sa ast_hashtab_hash_string_sax * \note A modulus will be applied to the return value of this function */ unsigned int ast_hashtab_hash_string_nocase(const void *obj); /*! * \brief Hashes a string to a number using a modified Shift-And-XOR algorithm * * \param obj the string to hash * \return Integer has of the specified string * \sa ast_hastable_hash_string * \sa ast_hastable_hash_string_nocase */ unsigned int ast_hashtab_hash_string_sax(const void *obj); unsigned int ast_hashtab_hash_int(const int num); /* right now, both these funcs are just result = num%modulus; */ unsigned int ast_hashtab_hash_short(const short num); /*! * \brief Create the hashtable list * \param initial_buckets starting number of buckets * \param compare a func ptr to compare two elements in the hash -- cannot be null * \param resize a func ptr to decide if the table needs to be resized, a NULL ptr here will cause a default to be used * \param newsize a func ptr that returns a new size of the array. A NULL will cause a default to be used * \param hash a func ptr to do the hashing * \param do_locking use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) struct ast_hashtab * _ast_hashtab_create(int initial_buckets, int (*compare)(const void *a, const void *b), int (*resize)(struct ast_hashtab *), int (*newsize)(struct ast_hashtab *tab), unsigned int (*hash)(const void *obj), int do_locking, const char *file, int lineno, const char *function); #define ast_hashtab_create(a,b,c,d,e,f) _ast_hashtab_create(a,b,c,d,e,f,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else struct ast_hashtab * ast_hashtab_create(int initial_buckets, int (*compare)(const void *a, const void *b), int (*resize)(struct ast_hashtab *), int (*newsize)(struct ast_hashtab *tab), unsigned int (*hash)(const void *obj), int do_locking ); #endif /*! * \brief This func will free the hash table and all its memory. * \note It doesn't touch the objects stored in it, unless you * specify a destroy func; it will call that func for each * object in the hashtab, remove all the objects, and then * free the hashtab itself. If no destroyfunc is specified * then the routine will assume you will free it yourself. * \param tab * \param objdestroyfunc */ void ast_hashtab_destroy( struct ast_hashtab *tab, void (*objdestroyfunc)(void *obj)); /*! * \brief Insert without checking * \param tab * \param obj * * Normally, you'd insert "safely" by checking to see if the element is * already there; in this case, you must already have checked. If an element * is already in the hashtable, that matches this one, most likely this one * will be found first. * \note will force a resize if the resize func returns 1 * \retval 1 on success * \retval 0 if there's a problem */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func); #define ast_hashtab_insert_immediate(a,b) _ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) #else int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj); #endif /*! * \brief Insert without checking, hashing or locking * \param tab * \param obj * \param h hashed index value * * \note Will force a resize if the resize func returns 1 * \retval 1 on success * \retval 0 if there's a problem */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func); #define ast_hashtab_insert_immediate_bucket(a,b,c) _ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__) #else int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h); #endif /*! * \brief Check and insert new object only if it is not there. * \note Will force a resize if the resize func returns 1 * \retval 1 on success * \retval 0 if there's a problem, or it's already there. */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func); #define ast_hashtab_insert_safe(a,b) _ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #else int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj); #endif /*! * \brief Lookup this object in the hash table. * \param tab * \param obj * \retval a ptr if found * \retval NULL if not found */ void * ast_hashtab_lookup(struct ast_hashtab *tab, const void *obj); /*! * \brief Use this if have the hash val for the object * \note This and avoid the recalc of the hash (the modulus (table_size) is not applied) */ void * ast_hashtab_lookup_with_hash(struct ast_hashtab *tab, const void *obj, unsigned int hashval); /*! * \brief Similar to ast_hashtab_lookup but sets h to the key hash value if the lookup fails. * \note This has the modulus applied, and will not be useful for long term storage if the table is resizable. */ void * ast_hashtab_lookup_bucket(struct ast_hashtab *tab, const void *obj, unsigned int *h); /*! \brief Returns key stats for the table */ void ast_hashtab_get_stats( struct ast_hashtab *tab, int *biggest_bucket_size, int *resize_count, int *num_objects, int *num_buckets); /*! \brief Returns the number of elements stored in the hashtab */ int ast_hashtab_size( struct ast_hashtab *tab); /*! \brief Returns the size of the bucket array in the hashtab */ int ast_hashtab_capacity( struct ast_hashtab *tab); /*! \brief Return a copy of the hash table */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func); #define ast_hashtab_dup(a,b) _ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj)); #endif /*! \brief Gives an iterator to hastable */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func); #define ast_hashtab_start_traversal(a) _ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab); #endif /*! \brief end the traversal, free the iterator, unlock if necc. */ void ast_hashtab_end_traversal(struct ast_hashtab_iter *it); /*! \brief Gets the next object in the list, advances iter one step returns null on end of traversal */ void *ast_hashtab_next(struct ast_hashtab_iter *it); /*! \brief Looks up the object, removes the corresponding bucket */ void *ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj); /*! \brief Hash the object and then compare ptrs in bucket list instead of calling the compare routine, will remove the bucket */ void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj); /* ------------------ */ /* for lock-enabled traversals with ability to remove an object during the traversal*/ /* ------------------ */ /*! \brief Gives an iterator to hastable */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func); #define ast_hashtab_start_write_traversal(a) _ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab); #endif /*! \brief Looks up the object, removes the corresponding bucket */ void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj); /*! \brief Hash the object and then compare ptrs in bucket list instead of calling the compare routine, will remove the bucket */ void *ast_hashtab_remove_this_object_nolock(struct ast_hashtab *tab, void *obj); /* ------------------ */ /* ------------------ */ /* user-controlled hashtab locking. Create a hashtab without locking, then call the following locking routines yourself to lock the table between threads. */ /*! \brief Call this after you create the table to init the lock */ void ast_hashtab_initlock(struct ast_hashtab *tab); /*! \brief Request a write-lock on the table. */ void ast_hashtab_wrlock(struct ast_hashtab *tab); /*! \brief Request a read-lock on the table -- don't change anything! */ void ast_hashtab_rdlock(struct ast_hashtab *tab); /*! \brief release a read- or write- lock. */ void ast_hashtab_unlock(struct ast_hashtab *tab); /*! \brief Call this before you destroy the table. */ void ast_hashtab_destroylock(struct ast_hashtab *tab); #endif asterisk-11.7.0/include/asterisk/astmm.h0000644000175000007640000001006412205704266020114 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Asterisk memory usage debugging * This file provides headers for MALLOC_DEBUG, a define used for tracking down * memory leaks. It should never be \#included directly; always use the * MALLOC_DEBUG definition in menuselect to activate those functions. */ #ifdef __cplusplus extern "C" { #endif #ifndef _ASTERISK_ASTMM_H #define _ASTERISK_ASTMM_H #ifndef STANDALONE #define __AST_DEBUG_MALLOC #include "asterisk.h" /* Include these now to prevent them from being needed later */ #include #include #include #include #include /* Undefine any macros */ #undef malloc #undef calloc #undef realloc #undef strdup #undef strndup #undef asprintf #undef vasprintf #undef free void *ast_std_malloc(size_t size); void *ast_std_calloc(size_t nmemb, size_t size); void *ast_std_realloc(void *ptr, size_t size); void ast_std_free(void *ptr); void ast_free_ptr(void *ptr); void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func); void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func); void *__ast_malloc(size_t size, const char *file, int lineno, const char *func); void __ast_free(void *ptr, const char *file, int lineno, const char *func); void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func); char *__ast_strdup(const char *s, const char *file, int lineno, const char *func); char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func); int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) __attribute__((format(printf, 5, 6))); int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) __attribute__((format(printf, 2, 0))); void __ast_mm_init_phase_1(void); void __ast_mm_init_phase_2(void); /* Provide our own definitions */ #define calloc(a,b) \ __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_calloc(a,b) \ __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_calloc_cache(a,b) \ __ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define malloc(a) \ __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_malloc(a) \ __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define free(a) \ __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_free(a) \ __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define realloc(a,b) \ __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_realloc(a,b) \ __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define strdup(a) \ __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_strdup(a) \ __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define strndup(a,b) \ __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_strndup(a,b) \ __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define asprintf(a, b, c...) \ __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) #define ast_asprintf(a, b, c...) \ __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) #define vasprintf(a,b,c) \ __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__) #define ast_vasprintf(a,b,c) \ __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__) #endif /* !STANDALONE */ #else #error "NEVER INCLUDE astmm.h DIRECTLY!!" #endif /* _ASTERISK_ASTMM_H */ #ifdef __cplusplus } #endif asterisk-11.7.0/include/asterisk/options.h0000644000175000007640000001712711745742245020504 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Options provided by main asterisk program */ #ifndef _ASTERISK_OPTIONS_H #define _ASTERISK_OPTIONS_H #include "asterisk/autoconfig.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define AST_CACHE_DIR_LEN 512 #define AST_FILENAME_MAX 80 #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */ /*! \ingroup main_options */ enum ast_option_flags { /*! Allow \#exec in config files */ AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0), /*! Do not fork() */ AST_OPT_FLAG_NO_FORK = (1 << 1), /*! Keep quiet */ AST_OPT_FLAG_QUIET = (1 << 2), /*! Console mode */ AST_OPT_FLAG_CONSOLE = (1 << 3), /*! Run in realtime Linux priority */ AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4), /*! Initialize keys for RSA authentication */ AST_OPT_FLAG_INIT_KEYS = (1 << 5), /*! Remote console */ AST_OPT_FLAG_REMOTE = (1 << 6), /*! Execute an asterisk CLI command upon startup */ AST_OPT_FLAG_EXEC = (1 << 7), /*! Don't use termcap colors */ AST_OPT_FLAG_NO_COLOR = (1 << 8), /*! Are we fully started yet? */ AST_OPT_FLAG_FULLY_BOOTED = (1 << 9), /*! Trascode via signed linear */ AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10), /*! Invoke the stdexten using the legacy macro method. */ AST_OPT_FLAG_STDEXTEN_MACRO = (1 << 11), /*! Dump core on a seg fault */ AST_OPT_FLAG_DUMP_CORE = (1 << 12), /*! Cache sound files */ AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13), /*! Display timestamp in CLI verbose output */ AST_OPT_FLAG_TIMESTAMP = (1 << 14), /*! Override config */ AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15), /*! Reconnect */ AST_OPT_FLAG_RECONNECT = (1 << 16), /*! Transmit Silence during Record() and DTMF Generation */ AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17), /*! Suppress some warnings */ AST_OPT_FLAG_DONT_WARN = (1 << 18), /*! End CDRs before the 'h' extension */ AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19), /*! Use DAHDI Timing for generators if available */ AST_OPT_FLAG_INTERNAL_TIMING = (1 << 20), /*! Always fork, even if verbose or debug settings are non-zero */ AST_OPT_FLAG_ALWAYS_FORK = (1 << 21), /*! Disable log/verbose output to remote consoles */ AST_OPT_FLAG_MUTE = (1 << 22), /*! There is a per-module debug setting */ AST_OPT_FLAG_DEBUG_MODULE = (1 << 23), /*! There is a per-module verbose setting */ AST_OPT_FLAG_VERBOSE_MODULE = (1 << 24), /*! Terminal colors should be adjusted for a light-colored background */ AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25), /*! Count Initiated seconds in CDR's */ AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26), /*! Force black background */ AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27), /*! Hide remote console connect messages on console */ AST_OPT_FLAG_HIDE_CONSOLE_CONNECT = (1 << 28), /*! Protect the configuration file path with a lock */ AST_OPT_FLAG_LOCK_CONFIG_DIR = (1 << 29), /*! Generic PLC */ AST_OPT_FLAG_GENERIC_PLC = (1 << 30), }; /*! These are the options that set by default when Asterisk starts */ #if (defined(HAVE_DAHDI_VERSION) && HAVE_DAHDI_VERSION >= 230) #define AST_DEFAULT_OPTIONS AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_INTERNAL_TIMING #else #define AST_DEFAULT_OPTIONS AST_OPT_FLAG_TRANSCODE_VIA_SLIN #endif #define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES) #define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK) #define ast_opt_quiet ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET) #define ast_opt_console ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE) #define ast_opt_high_priority ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY) #define ast_opt_init_keys ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS) #define ast_opt_remote ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE) #define ast_opt_exec ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC) #define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR) #define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED) #define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) /*! Invoke the stdexten using the legacy macro method. */ #define ast_opt_stdexten_macro ast_test_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO) #define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE) #define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES) #define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP) #define ast_opt_override_config ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG) #define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT) #define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) #define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN) #define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN) #define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) #define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK) #define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE) #define ast_opt_dbg_module ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_MODULE) #define ast_opt_verb_module ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_MODULE) #define ast_opt_light_background ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND) #define ast_opt_force_black_background ast_test_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND) #define ast_opt_hide_connect ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT) #define ast_opt_lock_confdir ast_test_flag(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR) #define ast_opt_generic_plc ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) extern struct ast_flags ast_options; enum ast_compat_flags { AST_COMPAT_DELIM_PBX_REALTIME = (1 << 0), AST_COMPAT_DELIM_RES_AGI = (1 << 1), AST_COMPAT_APP_SET = (1 << 2), }; #define ast_compat_pbx_realtime ast_test_flag(&ast_compat, AST_COMPAT_DELIM_PBX_REALTIME) #define ast_compat_res_agi ast_test_flag(&ast_compat, AST_COMPAT_DELIM_RES_AGI) #define ast_compat_app_set ast_test_flag(&ast_compat, AST_COMPAT_APP_SET) extern struct ast_flags ast_compat; extern int option_verbose; extern int option_maxfiles; /*!< Max number of open file handles (files, sockets) */ extern int option_debug; /*!< Debugging */ extern int option_maxcalls; /*!< Maximum number of simultaneous channels */ extern unsigned int option_dtmfminduration; /*!< Minimum duration of DTMF (channel.c) in ms */ extern double option_maxload; #if defined(HAVE_SYSINFO) extern long option_minmemfree; /*!< Minimum amount of free system memory - stop accepting calls if free memory falls below this watermark */ #endif extern char defaultlanguage[]; extern struct timeval ast_startuptime; extern struct timeval ast_lastreloadtime; extern pid_t ast_mainpid; extern char record_cache_dir[AST_CACHE_DIR_LEN]; extern char dahdi_chan_name[AST_CHANNEL_NAME]; extern int dahdi_chan_name_len; extern int ast_language_is_prefix; #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_OPTIONS_H */ asterisk-11.7.0/include/asterisk/jingle.h0000644000175000007640000000341311606651717020251 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Matt O'Gorman * * 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 Jingle definitions for chan_jingle * * \ref chan_jingle.c * * \author Matt O'Gorman */ #ifndef _ASTERISK_JINGLE_H #define _ASTERISK_JINGLE_H #include #include "asterisk/astobj.h" /* Jingle Constants */ #define JINGLE_NODE "jingle" #define GOOGLE_NODE "session" #define JINGLE_NS "urn:xmpp:tmp:jingle" #define JINGLE_AUDIO_RTP_NS "urn:xmpp:tmp:jingle:apps:audio-rtp" #define JINGLE_VIDEO_RTP_NS "urn:xmpp:tmp:jingle:apps:video" #define JINGLE_ICE_UDP_NS "urn:xmpp:tmp:jingle:transports:ice-udp" #define JINGLE_DTMF_NS "urn:xmpp:tmp:jingle:dtmf" #define GOOGLE_NS "http://www.google.com/session" #define GOOGLE_JINGLE_NS "urn:xmpp:jingle:1" #define GOOGLE_AUDIO_NS "http://www.google.com/session/phone" #define GOOGLE_VIDEO_NS "http://www.google.com/session/video" #define GOOGLE_TRANSPORT_NS "http://www.google.com/transport/p2p" #define JINGLE_SID "sid" #define GOOGLE_SID "id" #define JINGLE_INITIATE "session-initiate" #define JINGLE_ACCEPT "session-accept" #define GOOGLE_ACCEPT "accept" #define JINGLE_NEGOTIATE "transport-info" #define GOOGLE_NEGOTIATE "candidates" #define JINGLE_INFO "session-info" #define JINGLE_TERMINATE "session-terminate" #endif asterisk-11.7.0/include/asterisk/dns.h0000644000175000007640000000257310472213133017555 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Written by Thorsten Lockert * * Funding provided by Troll Phone Networks AS * * 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 DNS support for Asterisk * \author Thorsten Lockert */ #ifndef _ASTERISK_DNS_H #define _ASTERISK_DNS_H /*! \brief Perform DNS lookup (used by DNS, enum and SRV lookups) \param context \param dname Domain name to lookup (host, SRV domain, TXT record name) \param class Record Class (see "man res_search") \param type Record type (see "man res_search") \param callback Callback function for handling DNS result \note Asterisk DNS is synchronus at this time. This means that if your DNS services does not work, Asterisk may lock while waiting for response. */ int ast_search_dns(void *context, const char *dname, int class, int type, int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer)); #endif /* _ASTERISK_DNS_H */ asterisk-11.7.0/include/asterisk/causes.h0000644000175000007640000001467412073343400020261 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Martin Pycko * * 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 Internal Asterisk hangup causes */ #ifndef _ASTERISK_CAUSES_H #define _ASTERISK_CAUSES_H /*! \page AstCauses Hangup Causes for Asterisk The Asterisk hangup causes are delivered to the dialplan in the ${HANGUPCAUSE} channel variable after a call (after execution of "dial"). In SIP, we have a conversion table to convert between SIP return codes and Q.931 both ways. This is to improve SIP/ISDN compatibility. These are the current codes, based on the Q.850/Q.931 specification: - AST_CAUSE_UNALLOCATED 1 - AST_CAUSE_NO_ROUTE_TRANSIT_NET 2 - AST_CAUSE_NO_ROUTE_DESTINATION 3 - AST_CAUSE_MISDIALLED_TRUNK_PREFIX 5 - AST_CAUSE_CHANNEL_UNACCEPTABLE 6 - AST_CAUSE_CALL_AWARDED_DELIVERED 7 - AST_CAUSE_PRE_EMPTED 8 - AST_CAUSE_NUMBER_PORTED_NOT_HERE 14 - AST_CAUSE_NORMAL_CLEARING 16 - AST_CAUSE_USER_BUSY 17 - AST_CAUSE_NO_USER_RESPONSE 18 - AST_CAUSE_NO_ANSWER 19 - AST_CAUSE_CALL_REJECTED 21 - AST_CAUSE_NUMBER_CHANGED 22 - AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION 23 - AST_CAUSE_ANSWERED_ELSEWHERE 26 - AST_CAUSE_DESTINATION_OUT_OF_ORDER 27 - AST_CAUSE_INVALID_NUMBER_FORMAT 28 - AST_CAUSE_FACILITY_REJECTED 29 - AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY 30 - AST_CAUSE_NORMAL_UNSPECIFIED 31 - AST_CAUSE_NORMAL_CIRCUIT_CONGESTION 34 - AST_CAUSE_NETWORK_OUT_OF_ORDER 38 - AST_CAUSE_NORMAL_TEMPORARY_FAILURE 41 - AST_CAUSE_SWITCH_CONGESTION 42 - AST_CAUSE_ACCESS_INFO_DISCARDED 43 - AST_CAUSE_REQUESTED_CHAN_UNAVAIL 44 - AST_CAUSE_FACILITY_NOT_SUBSCRIBED 50 - AST_CAUSE_OUTGOING_CALL_BARRED 52 - AST_CAUSE_INCOMING_CALL_BARRED 54 - AST_CAUSE_BEARERCAPABILITY_NOTAUTH 57 - AST_CAUSE_BEARERCAPABILITY_NOTAVAIL 58 - AST_CAUSE_BEARERCAPABILITY_NOTIMPL 65 - AST_CAUSE_CHAN_NOT_IMPLEMENTED 66 - AST_CAUSE_FACILITY_NOT_IMPLEMENTED 69 - AST_CAUSE_INVALID_CALL_REFERENCE 81 - AST_CAUSE_INCOMPATIBLE_DESTINATION 88 - AST_CAUSE_INVALID_MSG_UNSPECIFIED 95 - AST_CAUSE_MANDATORY_IE_MISSING 96 - AST_CAUSE_MESSAGE_TYPE_NONEXIST 97 - AST_CAUSE_WRONG_MESSAGE 98 - AST_CAUSE_IE_NONEXIST 99 - AST_CAUSE_INVALID_IE_CONTENTS 100 - AST_CAUSE_WRONG_CALL_STATE 101 - AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE 102 - AST_CAUSE_MANDATORY_IE_LENGTH_ERROR 103 - AST_CAUSE_PROTOCOL_ERROR 111 - AST_CAUSE_INTERWORKING 127 For more information: - \ref app_dial.c */ /*! \name Causes for disconnection (from Q.850/Q.931) * These are the internal cause codes used in Asterisk. * \ref AstCauses */ /*@{ */ #define AST_CAUSE_UNALLOCATED 1 #define AST_CAUSE_NO_ROUTE_TRANSIT_NET 2 #define AST_CAUSE_NO_ROUTE_DESTINATION 3 #define AST_CAUSE_MISDIALLED_TRUNK_PREFIX 5 #define AST_CAUSE_CHANNEL_UNACCEPTABLE 6 #define AST_CAUSE_CALL_AWARDED_DELIVERED 7 #define AST_CAUSE_PRE_EMPTED 8 #define AST_CAUSE_NUMBER_PORTED_NOT_HERE 14 #define AST_CAUSE_NORMAL_CLEARING 16 #define AST_CAUSE_USER_BUSY 17 #define AST_CAUSE_NO_USER_RESPONSE 18 #define AST_CAUSE_NO_ANSWER 19 #define AST_CAUSE_SUBSCRIBER_ABSENT 20 #define AST_CAUSE_CALL_REJECTED 21 #define AST_CAUSE_NUMBER_CHANGED 22 #define AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION 23 #define AST_CAUSE_ANSWERED_ELSEWHERE 26 #define AST_CAUSE_DESTINATION_OUT_OF_ORDER 27 #define AST_CAUSE_INVALID_NUMBER_FORMAT 28 #define AST_CAUSE_FACILITY_REJECTED 29 #define AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY 30 #define AST_CAUSE_NORMAL_UNSPECIFIED 31 #define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION 34 #define AST_CAUSE_NETWORK_OUT_OF_ORDER 38 #define AST_CAUSE_NORMAL_TEMPORARY_FAILURE 41 #define AST_CAUSE_SWITCH_CONGESTION 42 #define AST_CAUSE_ACCESS_INFO_DISCARDED 43 #define AST_CAUSE_REQUESTED_CHAN_UNAVAIL 44 #define AST_CAUSE_FACILITY_NOT_SUBSCRIBED 50 #define AST_CAUSE_OUTGOING_CALL_BARRED 52 #define AST_CAUSE_INCOMING_CALL_BARRED 54 #define AST_CAUSE_BEARERCAPABILITY_NOTAUTH 57 #define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL 58 #define AST_CAUSE_BEARERCAPABILITY_NOTIMPL 65 #define AST_CAUSE_CHAN_NOT_IMPLEMENTED 66 #define AST_CAUSE_FACILITY_NOT_IMPLEMENTED 69 #define AST_CAUSE_INVALID_CALL_REFERENCE 81 #define AST_CAUSE_INCOMPATIBLE_DESTINATION 88 #define AST_CAUSE_INVALID_MSG_UNSPECIFIED 95 #define AST_CAUSE_MANDATORY_IE_MISSING 96 #define AST_CAUSE_MESSAGE_TYPE_NONEXIST 97 #define AST_CAUSE_WRONG_MESSAGE 98 #define AST_CAUSE_IE_NONEXIST 99 #define AST_CAUSE_INVALID_IE_CONTENTS 100 #define AST_CAUSE_WRONG_CALL_STATE 101 #define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE 102 #define AST_CAUSE_MANDATORY_IE_LENGTH_ERROR 103 #define AST_CAUSE_PROTOCOL_ERROR 111 #define AST_CAUSE_INTERWORKING 127 /* Special Asterisk aliases */ #define AST_CAUSE_BUSY AST_CAUSE_USER_BUSY #define AST_CAUSE_FAILURE AST_CAUSE_NETWORK_OUT_OF_ORDER #define AST_CAUSE_NORMAL AST_CAUSE_NORMAL_CLEARING #define AST_CAUSE_NOANSWER AST_CAUSE_NO_ANSWER #define AST_CAUSE_CONGESTION AST_CAUSE_NORMAL_CIRCUIT_CONGESTION #define AST_CAUSE_UNREGISTERED AST_CAUSE_SUBSCRIBER_ABSENT #define AST_CAUSE_NOTDEFINED 0 #define AST_CAUSE_NOSUCHDRIVER AST_CAUSE_CHAN_NOT_IMPLEMENTED /*@} */ #endif /* _ASTERISK_CAUSES_H */ asterisk-11.7.0/include/asterisk/stringfields.h0000644000175000007640000003536111762167325021505 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2006, Digium, Inc. * * Kevin P. Fleming * * 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 String fields in structures This file contains objects and macros used to manage string fields in structures without requiring them to be allocated as fixed-size buffers or requiring individual allocations for for each field. Using this functionality is quite simple. An example structure with three fields is defined like this: \code struct sample_fields { int x1; AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(foo); AST_STRING_FIELD(bar); AST_STRING_FIELD(blah); ); long x2; }; \endcode When an instance of this structure is allocated (either statically or dynamically), the fields and the pool of storage for them must be initialized: \code struct sample_fields *x; x = ast_calloc(1, sizeof(*x)); if (x == NULL || ast_string_field_init(x, 252)) { if (x) ast_free(x); x = NULL; ... handle error } \endcode Fields will default to pointing to an empty string, and will revert to that when ast_string_field_set() is called with a NULL argument. A string field will \b never contain NULL. ast_string_field_init(x, 0) will reset fields to the initial value while keeping the pool allocated. Reading the fields is much like using 'const char * const' fields in the structure: you cannot write to the field or to the memory it points to. Writing to the fields must be done using the wrapper macros listed below; and assignments are always by value (i.e. strings are copied): * ast_string_field_set() stores a simple value; * ast_string_field_build() builds the string using a printf-style format; * ast_string_field_build_va() is the varargs version of the above; * variants of these function allow passing a pointer to the field as an argument. \code ast_string_field_set(x, foo, "infinite loop"); ast_string_field_set(x, foo, NULL); // set to an empty string ast_string_field_ptr_set(x, &x->bar, "right way"); ast_string_field_build(x, blah, "%d %s", zipcode, city); ast_string_field_ptr_build(x, &x->blah, "%d %s", zipcode, city); ast_string_field_build_va(x, bar, fmt, args) ast_string_field_ptr_build_va(x, &x->bar, fmt, args) \endcode When the structure instance is no longer needed, the fields and their storage pool must be freed: \code ast_string_field_free_memory(x); ast_free(x); \endcode This completes the API description. */ #ifndef _ASTERISK_STRINGFIELDS_H #define _ASTERISK_STRINGFIELDS_H #include "asterisk/inline_api.h" /*! \internal \brief An opaque type for managed string fields in structures Don't declare instances of this type directly; use the AST_STRING_FIELD() macro instead. In addition to the string itself, the amount of space allocated for the field is stored in the two bytes immediately preceding it. */ typedef const char * ast_string_field; /* the type of storage used to track how many bytes were allocated for a field */ typedef uint16_t ast_string_field_allocation; /*! \internal \brief A constant empty string used for fields that have no other value */ extern const char *__ast_string_field_empty; /*! \internal \brief Structure used to hold a pool of space for string fields \note base is aligned so base+used can stay aligned by incrementing used with aligned numbers only */ struct ast_string_field_pool { struct ast_string_field_pool *prev; /*!< pointer to the previous pool, if any */ size_t size; /*!< the total size of the pool */ size_t used; /*!< the space used in the pool */ size_t active; /*!< the amount of space actively in use by fields */ char base[0] __attribute__((aligned(__alignof__(ast_string_field_allocation)))); /*!< storage space for the fields */ }; /*! \internal \brief Structure used to manage the storage for a set of string fields. */ struct ast_string_field_mgr { ast_string_field last_alloc; /*!< the last field allocated */ struct ast_string_field_pool *embedded_pool; /*!< pointer to the embedded pool, if any */ #if defined(__AST_DEBUG_MALLOC) const char *owner_file; /*!< filename of owner */ const char *owner_func; /*!< function name of owner */ int owner_line; /*!< line number of owner */ #endif }; /*! \internal \brief Attempt to 'grow' an already allocated field to a larger size \param mgr Pointer to the pool manager structure \param needed Amount of space needed for this field \param ptr Pointer to a field within the structure \return 0 on success, non-zero on failure This function will attempt to increase the amount of space allocated to an existing field to the amount requested; this is only possible if the field was the last field allocated from the current storage pool and the pool has enough space available. If so, the additional space will be allocated to this field and the field's address will not be changed. */ int __ast_string_field_ptr_grow(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, size_t needed, const ast_string_field *ptr); /*! \internal \brief Allocate space for a field \param mgr Pointer to the pool manager structure \param needed Amount of space needed for this field \param fields Pointer to the first entry of the field array \return NULL on failure, an address for the field on success. This function will allocate the requested amount of space from the field pool. If the requested amount of space is not available, an additional pool will be allocated. */ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, size_t needed); /*! \internal \brief Set a field to a complex (built) value \param mgr Pointer to the pool manager structure \param pool_head Pointer to the current pool \param ptr Pointer to a field within the structure \param format printf-style format string \return nothing */ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, ast_string_field *ptr, const char *format, ...) __attribute__((format(printf, 4, 5))); /*! \internal \brief Set a field to a complex (built) value \param mgr Pointer to the pool manager structure \param pool_head Pointer to the current pool \param ptr Pointer to a field within the structure \param format printf-style format string \param args va_list of the args for the format_string \return nothing */ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, ast_string_field *ptr, const char *format, va_list ap) __attribute__((format(printf, 4, 0))); /*! \brief Declare a string field \param name The field name */ #define AST_STRING_FIELD(name) const ast_string_field name /*! \brief Declare the fields needed in a structure \param field_list The list of fields to declare, using AST_STRING_FIELD() for each one. Internally, string fields are stored as a pointer to the head of the pool, followed by individual string fields, and then a struct ast_string_field_mgr which describes the space allocated. We split the two variables so they can be used as markers around the field_list, and this allows us to determine how many entries are in the field, and play with them. In particular, for writing to the fields, we rely on __field_mgr_pool to be a non-const pointer, so we know it has the same size as ast_string_field, and we can use it to locate the fields. */ #define AST_DECLARE_STRING_FIELDS(field_list) \ struct ast_string_field_pool *__field_mgr_pool; \ field_list \ struct ast_string_field_mgr __field_mgr /*! \brief Initialize a field pool and fields \param x Pointer to a structure containing fields \param size Amount of storage to allocate. Use 0 to reset fields to the default value, and release all but the most recent pool. size<0 (used internally) means free all pools. \return 0 on success, non-zero on failure */ #define ast_string_field_init(x, size) \ __ast_string_field_init(&(x)->__field_mgr, &(x)->__field_mgr_pool, size, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief free all memory - to be called before destroying the object */ #define ast_string_field_free_memory(x) \ __ast_string_field_init(&(x)->__field_mgr, &(x)->__field_mgr_pool, -1, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \internal * \brief internal version of ast_string_field_init */ int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, int needed, const char *file, int lineno, const char *func); /*! * \brief Allocate a structure with embedded stringfields in a single allocation * \param n Number of structures to allocate (see ast_calloc) * \param type The type of structure to allocate * \param size The number of bytes of space (minimum) to allocate for stringfields to use * * This function will allocate memory for one or more structures that use stringfields, and * also allocate space for the stringfields and initialize the stringfield management * structure embedded in the outer structure. * * \since 1.8 */ #define ast_calloc_with_stringfields(n, type, size) \ __ast_calloc_with_stringfields(n, sizeof(type), offsetof(type, __field_mgr), offsetof(type, __field_mgr_pool), \ size, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \internal * \brief internal version of ast_calloc_with_stringfields */ void * attribute_malloc __ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_size, size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size, const char *file, int lineno, const char *func); /*! \internal \brief Release a field's allocation from a pool \param pool_head Pointer to the current pool \param ptr Field to be released \return nothing This function will search the pool list to find the pool that contains the allocation for the specified field, then remove the field's allocation from that pool's 'active' count. If the pool's active count reaches zero, and it is not the current pool, then it will be freed. */ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, const ast_string_field ptr); /*! \brief Macro to provide access to the allocation field that lives immediately in front of a string field \param x Pointer to the string field Note that x must be a pointer to a byte-sized type -- normally (char *) -- or this calculation would break horribly */ #define AST_STRING_FIELD_ALLOCATION(x) *((ast_string_field_allocation *) (x - __alignof__(ast_string_field_allocation))) /*! \brief Set a field to a simple string value \param x Pointer to a structure containing fields \param ptr Pointer to a field within the structure \param data String value to be copied into the field \return nothing */ #define ast_string_field_ptr_set(x, ptr, data) ast_string_field_ptr_set_by_fields((x)->__field_mgr_pool, (x)->__field_mgr, ptr, data) #define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) do { \ const char *__d__ = (data); \ size_t __dlen__ = (__d__) ? strlen(__d__) + 1 : 1; \ ast_string_field *__p__ = (ast_string_field *) (ptr); \ if (__dlen__ == 1) { \ __ast_string_field_release_active(field_mgr_pool, *__p__); \ *__p__ = __ast_string_field_empty; \ } else if ((__dlen__ <= AST_STRING_FIELD_ALLOCATION(*__p__)) || \ (!__ast_string_field_ptr_grow(&field_mgr, &field_mgr_pool, __dlen__, __p__)) || \ (*__p__ = __ast_string_field_alloc_space(&field_mgr, &field_mgr_pool, __dlen__))) { \ if (*__p__ != (*ptr)) { \ __ast_string_field_release_active(field_mgr_pool, (*ptr)); \ } \ memcpy(* (void **) __p__, __d__, __dlen__); \ } \ } while (0) /*! \brief Set a field to a simple string value \param x Pointer to a structure containing fields \param field Name of the field to set \param data String value to be copied into the field \return nothing */ #define ast_string_field_set(x, field, data) do { \ ast_string_field_ptr_set(x, &(x)->field, data); \ } while (0) /*! \brief Set a field to a complex (built) value \param x Pointer to a structure containing fields \param ptr Pointer to a field within the structure \param fmt printf-style format string \param args Arguments for format string \return nothing */ #define ast_string_field_ptr_build(x, ptr, fmt, args...) \ __ast_string_field_ptr_build(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args) /*! \brief Set a field to a complex (built) value \param x Pointer to a structure containing fields \param field Name of the field to set \param fmt printf-style format string \param args Arguments for format string \return nothing */ #define ast_string_field_build(x, field, fmt, args...) \ __ast_string_field_ptr_build(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args) /*! \brief Set a field to a complex (built) value with prebuilt va_lists. \param x Pointer to a structure containing fields \param ptr Pointer to a field within the structure \param fmt printf-style format string \param args Arguments for format string in va_list format \return nothing */ #define ast_string_field_ptr_build_va(x, ptr, fmt, args) \ __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args) /*! \brief Set a field to a complex (built) value \param x Pointer to a structure containing fields \param field Name of the field to set \param fmt printf-style format string \param args Arguments for format string in va_list format \return nothing */ #define ast_string_field_build_va(x, field, fmt, args) \ __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args) #endif /* _ASTERISK_STRINGFIELDS_H */ asterisk-11.7.0/include/asterisk/optional_api.h0000644000175000007640000002472211711604714021455 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008, Digium, Inc. * * Kevin P. Fleming * * 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. */ #ifndef __ASTERISK_OPTIONAL_API_H #define __ASTERISK_OPTIONAL_API_H /*! * \file * \brief Optional API function macros * * Some Asterisk API functions are provided by loadable modules, thus, * they may or may not be available at run time depending on whether the * providing module has been loaded or not. In addition, there are some * modules that are consumers of these APIs that *optionally* use them; they * have only a part of their functionality dependent on the APIs, and can * provide the remainder even if the APIs are not available. * * To accomodate this situation, the AST_OPTIONAL_API macro allows an API * function to be declared in a special way, if Asterisk being built on a * platform that supports special compiler and dynamic linker attributes. * If so the API function will actually be a weak symbol, which means if the * provider of the API is not loaded, the symbol can still be referenced (unlike a * strong symbol, which would cause an immediate fault if not defined when * referenced), but it will return NULL signifying the linker/loader was * not able to resolve the symbol. In addition, the macro defines a hidden * 'stub' version of the API call, using a provided function body, and uses * various methods to make the API function symbol actually resolve to * that hidden stub, but only when the *real* provider of the symbol has * not been found. * * An example can be found in agi.h: * * \code * AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd), * { return AST_OPTIONAL_API_UNAVAILABLE; }); * \endcode * * This defines the 'ast_agi_register' function as an optional API; if a * consumer of this API is loaded when there is no provider of it, then * calling this function will actually call the hidden stub, and return * the value AST_OPTIONAL_API_UNAVAILABLE. This allows the consumer to * safely know that the API is not available, and to avoid using any * other APIs from the not-present provider. * * In addition to this declaration in the header file, the actual definition of * the API function must use the AST_OPTIONAL_API_NAME macro to (possibly) * modify the real name of the API function, depending on the specific * implementation requirements. The corresponding example from res_agi.c: * * \code * int AST_OPTIONAL_API_NAME(ast_agi_register)(struct ast_module *mod, agi_command *cmd) * { * ... * } * \endcode * * In the module providing the API, the AST_OPTIONAL_API macro must * be informed that it should not build the hidden stub function or * apply special aliases to the function prototype; this can be done * by defining AST_API_MODULE just before including the header file * containing the AST_OPTIONAL_API macro calls. * * \note If the platform does not provide adequate resources, * then the AST_OPTIONAL_API macro will result in a non-optional function * definition; this means that any consumers of the API functions so * defined will require that the provider of the API functions be * loaded before they can reference the symbols. * * WARNING WARNING WARNING WARNING WARNING * * You MUST add the AST_MODFLAG_GLOBAL_SYMBOLS to the module for which you * are enabling optional_api functionality, or it will fail to work. * * WARNING WARNING WARNING WARNING WARNING */ /*! * \brief A common value for optional API stub functions to return * * This value is defined as INT_MIN, the minimum value for an integer * (maximum negative value), which can be used by any optional API * functions that return a signed integer value and would not be * able to return such a value under normal circumstances. */ #define AST_OPTIONAL_API_UNAVAILABLE INT_MIN #if defined(HAVE_ATTRIBUTE_weak_import) || defined(HAVE_ATTRIBUTE_weak) /* * This is the Darwin (Mac OS/X) implementation, that only provides the 'weak' * or 'weak_import' compiler attribute for weak symbols. On this platform, * * - The module providing the API will only provide a '__' prefixed version * of the API function to other modules (this will be hidden from the other * modules by the macros), so any modules compiled against older versions * of the module that provided a non-prefixed version of the API function * will fail to link at runtime. * - In the API module itself, access to the API function without using a * prefixed name is provided by a static pointer variable that holds the * function address. * - 'Consumer' modules of the API will use a combination of a weak_import or * weak symbol, a local stub function, a pointer variable and a constructor * function (which initializes that pointer variable as the module is being * loaded) to provide safe, optional access to the API function without any * special code being required. */ #if defined(HAVE_ATTRIBUTE_weak_import) #define __default_attribute weak_import /* pre-Lion */ #else #define __default_attribute weak /* Lion-onwards */ #endif #define AST_OPTIONAL_API_NAME(name) __##name #if defined(AST_API_MODULE) #define AST_OPTIONAL_API(result, name, proto, stub) \ result AST_OPTIONAL_API_NAME(name) proto; \ static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name); #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \ static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name); #else #define AST_OPTIONAL_API(result, name, proto, stub) \ static result __stub__##name proto stub; \ __attribute__((__default_attribute)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \ static attribute_unused typeof(__stub__##name) * name; \ static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; } #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ static __attribute__((attr)) result __stub__##name proto stub; \ __attribute__((attr, __default_attribute)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \ static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \ static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; } #endif /* End of Darwin (Mac OS/X) implementation */ #elif defined(HAVE_ATTRIBUTE_weakref) /* * This is the generic GCC implementation, used when the 'weakref' * compiler attribute is available. On these platforms: * * - The module providing the API will provide a '__' prefixed version * of the API function to other modules (this will be hidden from the other * modules by the macros), and also a non-prefixed alias so that modules * compiled against older versions of the module that provided a non-prefixed * version of the API function will continue to link properly. * - In the API module itself, access to the API function without using a * prefixed name is provided by the non-prefixed alias described above. * - 'Consumer' modules of the API will use a combination of a weakref * symbol, a local stub function, a pointer variable and a constructor function * (which initializes that pointer variable as the module is being loaded) * to provide safe, optional access to the API function without any special * code being required. */ #define AST_OPTIONAL_API_NAME(name) __##name #if defined(AST_API_MODULE) #define AST_OPTIONAL_API(result, name, proto, stub) \ result AST_OPTIONAL_API_NAME(name) proto; \ static __attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name; #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \ static __attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name; #else #define AST_OPTIONAL_API(result, name, proto, stub) \ static result __stub__##name proto stub; \ static __attribute__((weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \ static attribute_unused typeof(__stub__##name) * name; \ static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; } #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ static __attribute__((attr)) result __stub__##name proto stub; \ static __attribute__((attr, weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \ static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \ static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; } #endif /* End of GCC implementation */ #else /* This is the non-optional implementation. */ #define AST_OPTIONAL_API_NAME(name) name /*! * \brief Define an optional API function * * \param result The type of result the function returns * \param name The name of the function * \param proto The prototype (arguments) of the function * \param stub The code block that will be used by the hidden stub when needed * * Example usage: * \code * AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd), * { return AST_OPTIONAL_API_UNAVAILABLE; }); * \endcode */ #define AST_OPTIONAL_API(result, name, proto, stub) result AST_OPTIONAL_API_NAME(name) proto /*! * \brief Define an optional API function with compiler attributes * * \param result The type of result the function returns * \param attr Any compiler attributes to be applied to the function (without the __attribute__ wrapper) * \param name The name of the function * \param proto The prototype (arguments) of the function * \param stub The code block that will be used by the hidden stub when needed */ #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto /* End of non-optional implementation */ #endif #undef AST_API_MODULE #endif /* __ASTERISK_OPTIONAL_API_H */ asterisk-11.7.0/include/asterisk/md5.h0000644000175000007640000000202110717373752017462 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 MD5 digest functions */ #ifndef _ASTERISK_MD5_H #define _ASTERISK_MD5_H struct MD5Context { uint32_t buf[4]; uint32_t bits[2]; unsigned char in[64]; }; void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len); void MD5Final(unsigned char digest[16], struct MD5Context *context); void MD5Transform(uint32_t buf[4], uint32_t const in[16]); #endif /* _ASTERISK_MD5_H */ asterisk-11.7.0/include/asterisk/manager.h0000644000175000007640000002770011763214744020417 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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. */ #ifndef _ASTERISK_MANAGER_H #define _ASTERISK_MANAGER_H #include "asterisk/network.h" #include "asterisk/lock.h" #include "asterisk/datastore.h" #include "asterisk/xmldoc.h" /*! \file \brief The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party software. Manager protocol packages are text fields of the form a: b. There is always exactly one space after the colon. \verbatim For Actions replies, the first line of the reply is a "Response:" header with values "success", "error" or "follows". "Follows" implies that the response is coming as separate events with the same ActionID. If the Action request has no ActionID, it will be hard matching events to the Action request in the manager client. The first header type is the "Event" header. Other headers vary from event to event. Headers end with standard \\r\\n termination. The last line of the manager response or event is an empty line. (\\r\\n) \endverbatim \note Please try to \b re-use \b existing \b headers to simplify manager message parsing in clients. Don't re-use an existing header with a new meaning, please. You can find a reference of standard headers in doc/manager.txt - \ref manager.c Main manager code file */ #define AMI_VERSION "1.3" #define DEFAULT_MANAGER_PORT 5038 /* Default port for Asterisk management via TCP */ #define DEFAULT_MANAGER_TLS_PORT 5039 /* Default port for Asterisk management via TCP */ /*! \name Constant return values *\note Currently, returning anything other than zero causes the session to terminate. */ /*@{ */ #define AMI_SUCCESS (0) #define AMI_DESTROY (-1) /*@} */ /*! \name Manager event classes */ /*@{ */ #define EVENT_FLAG_SYSTEM (1 << 0) /* System events such as module load/unload */ #define EVENT_FLAG_CALL (1 << 1) /* Call event, such as state change, etc */ #define EVENT_FLAG_LOG (1 << 2) /* Log events */ #define EVENT_FLAG_VERBOSE (1 << 3) /* Verbose messages */ #define EVENT_FLAG_COMMAND (1 << 4) /* Ability to read/set commands */ #define EVENT_FLAG_AGENT (1 << 5) /* Ability to read/set agent info */ #define EVENT_FLAG_USER (1 << 6) /* Ability to read/set user info */ #define EVENT_FLAG_CONFIG (1 << 7) /* Ability to modify configurations */ #define EVENT_FLAG_DTMF (1 << 8) /* Ability to read DTMF events */ #define EVENT_FLAG_REPORTING (1 << 9) /* Reporting events such as rtcp sent */ #define EVENT_FLAG_CDR (1 << 10) /* CDR events */ #define EVENT_FLAG_DIALPLAN (1 << 11) /* Dialplan events (VarSet, NewExten) */ #define EVENT_FLAG_ORIGINATE (1 << 12) /* Originate a call to an extension */ #define EVENT_FLAG_AGI (1 << 13) /* AGI events */ #define EVENT_FLAG_HOOKRESPONSE (1 << 14) /* Hook Response */ #define EVENT_FLAG_CC (1 << 15) /* Call Completion events */ #define EVENT_FLAG_AOC (1 << 16) /* Advice Of Charge events */ #define EVENT_FLAG_TEST (1 << 17) /* Test event used to signal the Asterisk Test Suite */ /*XXX Why shifted by 30? XXX */ #define EVENT_FLAG_MESSAGE (1 << 30) /* MESSAGE events. */ /*@} */ /*! \brief Export manager structures */ #define AST_MAX_MANHEADERS 128 /*! \brief Manager Helper Function */ typedef int (*manager_hook_t)(int, const char *, char *); struct manager_custom_hook { /*! Identifier */ char *file; /*! helper function */ manager_hook_t helper; /*! Linked list information */ AST_RWLIST_ENTRY(manager_custom_hook) list; }; /*! \brief Check if AMI is enabled */ int check_manager_enabled(void); /*! \brief Check if AMI/HTTP is enabled */ int check_webmanager_enabled(void); /*! Add a custom hook to be called when an event is fired \param hook struct manager_custom_hook object to add */ void ast_manager_register_hook(struct manager_custom_hook *hook); /*! Delete a custom hook to be called when an event is fired \param hook struct manager_custom_hook object to delete */ void ast_manager_unregister_hook(struct manager_custom_hook *hook); /*! \brief Registered hooks can call this function to invoke actions and they will receive responses through registered callback * \param hook the file identifier specified in manager_custom_hook struct when registering a hook * \param msg ami action mesage string e.g. "Action: SipPeers\r\n" * \retval 0 on Success * \retval non-zero on Failure */ int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg); struct mansession; struct message { unsigned int hdrcount; const char *headers[AST_MAX_MANHEADERS]; }; struct manager_action { /*! Name of the action */ const char *action; AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(synopsis); /*!< Synopsis text (short description). */ AST_STRING_FIELD(description); /*!< Description (help text) */ AST_STRING_FIELD(syntax); /*!< Syntax text */ AST_STRING_FIELD(arguments); /*!< Description of each argument. */ AST_STRING_FIELD(seealso); /*!< See also */ ); /*! Permission required for action. EVENT_FLAG_* */ int authority; /*! Function to be called */ int (*func)(struct mansession *s, const struct message *m); struct ast_module *module; /*!< Module this action belongs to */ /*! Where the documentation come from. */ enum ast_doc_src docsrc; /*! For easy linking */ AST_RWLIST_ENTRY(manager_action) list; /*! * \brief TRUE if the AMI action is registered and the callback can be called. * * \note Needed to prevent a race between calling the callback * function and unregestring the AMI action object. */ unsigned int registered:1; }; /*! \brief External routines may register/unregister manager callbacks this way * \note Use ast_manager_register2() to register with help text for new manager commands */ #define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, ast_module_info->self, synopsis, NULL) /*! \brief Register a manager callback using XML documentation to describe the manager. */ #define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, ast_module_info->self, NULL, NULL) /*! * \brief Register a manager callback using XML documentation to describe the manager. * * \note For Asterisk core modules that are not independently * loadable. * * \warning If you use ast_manager_register_xml() instead when * you need to use this function, Asterisk will crash on load. */ #define ast_manager_register_xml_core(action, authority, func) ast_manager_register2(action, authority, func, NULL, NULL, NULL) /*! * \brief Register a manager command with the manager interface * \param action Name of the requested Action: * \param authority Required authority for this command * \param func Function to call for this command * \param module The module containing func. (NULL if module is part of core and not loadable) * \param synopsis Help text (one line, up to 30 chars) for CLI manager show commands * \param description Help text, several lines */ int ast_manager_register2( const char *action, int authority, int (*func)(struct mansession *s, const struct message *m), struct ast_module *module, const char *synopsis, const char *description); /*! * \brief Unregister a registered manager command * \param action Name of registered Action: */ int ast_manager_unregister(const char *action); /*! * \brief Verify a session's read permissions against a permission mask. * \param ident session identity * \param perm permission mask to verify * \retval 1 if the session has the permission mask capabilities * \retval 0 otherwise */ int astman_verify_session_readpermissions(uint32_t ident, int perm); /*! * \brief Verify a session's write permissions against a permission mask. * \param ident session identity * \param perm permission mask to verify * \retval 1 if the session has the permission mask capabilities, otherwise 0 * \retval 0 otherwise */ int astman_verify_session_writepermissions(uint32_t ident, int perm); /*! \brief External routines may send asterisk manager events this way * \param category Event category, matches manager authorization \param event Event name \param contents Contents of event */ /* XXX the parser in gcc 2.95 gets confused if you don't put a space * between the last arg before VA_ARGS and the comma */ #define manager_event(category, event, contents , ...) \ __ast_manager_event_multichan(category, event, 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__) #define ast_manager_event(chan, category, event, contents , ...) \ do { \ struct ast_channel *_chans[] = { chan, }; \ __ast_manager_event_multichan(category, event, 1, _chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); \ } while (0) #define ast_manager_event_multichan(category, event, nchans, chans, contents , ...) \ __ast_manager_event_multichan(category, event, nchans, chans, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__); /*! External routines may send asterisk manager events this way * \param category Event category, matches manager authorization * \param event Event name * \param chancount Number of channels in chans parameter * \param chans A pointer to an array of channels involved in the event * \param contents Format string describing event * \since 1.8 */ int __ast_manager_event_multichan(int category, const char *event, int chancount, struct ast_channel **chans, const char *file, int line, const char *func, const char *contents, ...) __attribute__((format(printf, 8, 9))); /*! \brief Get header from mananger transaction */ const char *astman_get_header(const struct message *m, char *var); /*! \brief Get a linked list of the Variable: headers */ struct ast_variable *astman_get_variables(const struct message *m); /*! \brief Send error in manager transaction */ void astman_send_error(struct mansession *s, const struct message *m, char *error); /*! \brief Send error in manager transaction (with va_args support) */ void __attribute__((format(printf, 3, 4))) astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt, ...); /*! \brief Send response in manager transaction */ void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg); /*! \brief Send ack in manager transaction */ void astman_send_ack(struct mansession *s, const struct message *m, char *msg); /*! \brief Send ack in manager list transaction */ void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag); void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...); /*! \brief Determinie if a manager session ident is authenticated */ int astman_is_authed(uint32_t ident); /*! \brief Called by Asterisk initialization */ int init_manager(void); /*! \brief Called by Asterisk module functions and the CLI command */ int reload_manager(void); /*! * \brief Add a datastore to a session * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int astman_datastore_add(struct mansession *s, struct ast_datastore *datastore); /*! * \brief Remove a datastore from a session * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int astman_datastore_remove(struct mansession *s, struct ast_datastore *datastore); /*! * \brief Find a datastore on a session * * \retval pointer to the datastore if found * \retval NULL if not found * \since 1.6.1 */ struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid); #endif /* _ASTERISK_MANAGER_H */ asterisk-11.7.0/include/asterisk/cli.h0000644000175000007640000002447511440505646017556 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Standard Command Line Interface */ #ifndef _ASTERISK_CLI_H #define _ASTERISK_CLI_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/linkedlists.h" void ast_cli(int fd, const char *fmt, ...) __attribute__((format(printf, 2, 3))); /* dont check permissions while passing this option as a 'uid' * to the cli_has_permissions() function. */ #define CLI_NO_PERMS -1 #define RESULT_SUCCESS 0 #define RESULT_SHOWUSAGE 1 #define RESULT_FAILURE 2 #define CLI_SUCCESS (char *)RESULT_SUCCESS #define CLI_SHOWUSAGE (char *)RESULT_SHOWUSAGE #define CLI_FAILURE (char *)RESULT_FAILURE #define AST_MAX_CMD_LEN 16 #define AST_MAX_ARGS 64 #define AST_CLI_COMPLETE_EOF "_EOF_" /*! * In many cases we need to print singular or plural * words depending on a count. This macro helps us e.g. * printf("we have %d object%s", n, ESS(n)); */ #define ESS(x) ((x) == 1 ? "" : "s") /*! \brief return Yes or No depending on the argument. * This is used in many places in CLI command, having a function to generate * this helps maintaining a consistent output (and possibly emitting the * output in other languages, at some point). */ #define AST_CLI_YESNO(x) (x) ? "Yes" : "No" /*! \brief return On or Off depending on the argument. * This is used in many places in CLI command, having a function to generate * this helps maintaining a consistent output (and possibly emitting the * output in other languages, at some point). */ #define AST_CLI_ONOFF(x) (x) ? "On" : "Off" /*! \page CLI_command_API CLI command API CLI commands are described by a struct ast_cli_entry that contains all the components for their implementation. In the "old-style" format, the record must contain: - a NULL-terminated array of words constituting the command, e.g. { "set", "debug", "on", NULL }, - a summary string (short) and a usage string (longer); - a handler which implements the command itself, invoked with a file descriptor and argc/argv as typed by the user - a 'generator' function which, given a partial string, can generate legal completions for it. An example is int old_setdebug(int fd, int argc, char *argv[]); char *dbg_complete(const char *line, const char *word, int pos, int n); { { "set", "debug", "on", NULL }, do_setdebug, "Enable debugging", set_debug_usage, dbg_complete }, In the "new-style" format, all the above functionalities are implemented by a single function, and the arguments tell which output is required. The prototype is the following: char *new_setdebug(const struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); ... // this is how we create the entry to register AST_CLI_DEFINE(new_setdebug, "short description") ... To help the transition, we make the pointer to the struct ast_cli_entry available to old-style handlers via argv[-1]. An example of new-style handler is the following \code static char *test_new_cli(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { static const char * const choices[] = { "one", "two", "three", NULL }; switch (cmd) { case CLI_INIT: e->command = "do this well"; e->usage = "Usage: do this well \n" " typically multiline with body indented\n"; return NULL; case CLI_GENERATE: if (a->pos > e->args) return NULL; return ast_cli_complete(a->word, choices, a->n); default: // we are guaranteed to be called with argc >= e->args; if (a->argc > e->args + 1) // we accept one extra argument return CLI_SHOWUSAGE; ast_cli(a->fd, "done this well for %s\n", e->args[argc-1]); return CLI_SUCCESS; } } \endcode */ /*! \brief calling arguments for new-style handlers. * \arg \ref CLI_command_API */ enum ast_cli_command { CLI_INIT = -2, /* return the usage string */ CLI_GENERATE = -3, /* behave as 'generator', remap argv to struct ast_cli_args */ CLI_HANDLER = -4, /* run the normal handler */ }; /* argument for new-style CLI handler */ struct ast_cli_args { const int fd; const int argc; const char * const *argv; const char *line; /* the current input line */ const char *word; /* the word we want to complete */ const int pos; /* position of the word to complete */ const int n; /* the iteration count (n-th entry we generate) */ }; /*! \brief descriptor for a cli entry. * \arg \ref CLI_command_API */ struct ast_cli_entry { const char * const cmda[AST_MAX_CMD_LEN]; /*!< words making up the command. * set the first entry to NULL for a new-style entry. */ const char * const summary; /*!< Summary of the command (< 60 characters) */ const char * usage; /*!< Detailed usage information */ int inuse; /*!< For keeping track of usage */ struct module *module; /*!< module this belongs to */ char *_full_cmd; /*!< built at load time from cmda[] */ int cmdlen; /*!< len up to the first invalid char [<{% */ /*! \brief This gets set in ast_cli_register() */ int args; /*!< number of non-null entries in cmda */ char *command; /*!< command, non-null for new-style entries */ char *(*handler)(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); /*! For linking */ AST_LIST_ENTRY(ast_cli_entry) list; }; #if defined(__cplusplus) || defined(c_plusplus) #define AST_CLI_DEFINE(fn, txt) { { "" }, txt, NULL, 0, NULL, NULL, 0, 0, NULL, fn } #else /* XXX the parser in gcc 2.95 gets confused if you don't put a space * between the last arg before VA_ARGS and the comma */ #define AST_CLI_DEFINE(fn, txt , ... ) { .handler = fn, .summary = txt, ## __VA_ARGS__ } #endif /*! * Helper function to generate cli entries from a NULL-terminated array. * Returns the n-th matching entry from the array, or NULL if not found. * Can be used to implement generate() for static entries as below * (in this example we complete the word in position 2): \code char *my_generate(const char *line, const char *word, int pos, int n) { static const char * const choices[] = { "one", "two", "three", NULL }; if (pos == 2) return ast_cli_complete(word, choices, n); else return NULL; } \endcode */ char *ast_cli_complete(const char *word, const char * const choices[], int pos); /*! * \brief Interprets a command * Interpret a command s, sending output to fd if uid:gid has permissions * to run this command. uid = CLI_NO_PERMS to avoid checking user permissions * gid = CLI_NO_PERMS to avoid checking group permissions. * \param uid User ID that is trying to run the command. * \param gid Group ID that is trying to run the command. * \param fd pipe * \param s incoming string * \retval 0 on success * \retval -1 on failure */ int ast_cli_command_full(int uid, int gid, int fd, const char *s); #define ast_cli_command(fd,s) ast_cli_command_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, s) /*! * \brief Executes multiple CLI commands * Interpret strings separated by NULL and execute each one, sending output to fd * if uid has permissions, uid = CLI_NO_PERMS to avoid checking users permissions. * gid = CLI_NO_PERMS to avoid checking group permissions. * \param uid User ID that is trying to run the command. * \param gid Group ID that is trying to run the command. * \param fd pipe * \param size is the total size of the string * \param s incoming string * \retval number of commands executed */ int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const char *s); #define ast_cli_command_multiple(fd,size,s) ast_cli_command_multiple_full(CLI_NO_PERMS, CLI_NO_PERMS, fd, size, s) /*! \brief Registers a command or an array of commands * \param e which cli entry to register. * Register your own command * \retval 0 on success * \retval -1 on failure */ int ast_cli_register(struct ast_cli_entry *e); /*! * \brief Register multiple commands * \param e pointer to first cli entry to register * \param len number of entries to register */ int ast_cli_register_multiple(struct ast_cli_entry *e, int len); /*! * \brief Unregisters a command or an array of commands * \param e which cli entry to unregister * Unregister your own command. You must pass a completed ast_cli_entry structure * \return 0 */ int ast_cli_unregister(struct ast_cli_entry *e); /*! * \brief Unregister multiple commands * \param e pointer to first cli entry to unregister * \param len number of entries to unregister */ int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len); /*! * \brief Readline madness * Useful for readline, that's about it * \retval 0 on success * \retval -1 on failure */ char *ast_cli_generator(const char *, const char *, int); int ast_cli_generatornummatches(const char *, const char *); /*! * \brief Generates a NULL-terminated array of strings that * 1) begin with the string in the second parameter, and * 2) are valid in a command after the string in the first parameter. * * The first entry (offset 0) of the result is the longest common substring * in the results, useful to extend the string that has been completed. * Subsequent entries are all possible values, followed by a NULL. * All strings and the array itself are malloc'ed and must be freed * by the caller. */ char **ast_cli_completion_matches(const char *, const char *); /*! * \brief Command completion for the list of active channels. * * This can be called from a CLI command completion function that wants to * complete from the list of active channels. 'rpos' is the required * position in the command. This function will return NULL immediately if * 'rpos' is not the same as the current position, 'pos'. */ char *ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_CLI_H */ asterisk-11.7.0/include/asterisk/res_odbc.h0000644000175000007640000002314611722757642020571 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * Copyright (C) 2004 - 2005, Anthony Minessale II * Copyright (C) 2006, Tilghman Lesher * * Mark Spencer * Anthony Minessale * Tilghman Lesher * * 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 ODBC resource manager */ #ifndef _ASTERISK_RES_ODBC_H #define _ASTERISK_RES_ODBC_H #include #include #include #include "asterisk/linkedlists.h" #include "asterisk/strings.h" typedef enum { ODBC_SUCCESS=0, ODBC_FAIL=-1} odbc_status; /*! \brief Flags for use with \see ast_odbc_request_obj2 */ enum { RES_ODBC_SANITY_CHECK = (1 << 0), RES_ODBC_INDEPENDENT_CONNECTION = (1 << 1), RES_ODBC_CONNECTED = (1 << 2), }; /*! \brief ODBC container */ struct odbc_obj { SQLHDBC con; /*!< ODBC Connection Handle */ struct odbc_class *parent; /*!< Information about the connection is protected */ struct timeval last_used; /*!< Used by idlecheck to determine if the connection should be renegotiated */ #ifdef DEBUG_THREADS char file[80]; char function[80]; int lineno; #endif unsigned int used:1; /*!< Is this connection currently in use? */ unsigned int up:1; unsigned int tx:1; /*!< Should this connection be unshared, regardless of the class setting? */ struct odbc_txn_frame *txf; /*!< Reference back to the transaction frame, if applicable */ AST_LIST_ENTRY(odbc_obj) list; }; /*!\brief These structures are used for adaptive capabilities */ struct odbc_cache_columns { char *name; SQLSMALLINT type; SQLINTEGER size; SQLSMALLINT decimals; SQLSMALLINT radix; SQLSMALLINT nullable; SQLINTEGER octetlen; AST_RWLIST_ENTRY(odbc_cache_columns) list; }; struct odbc_cache_tables { char *connection; char *table; AST_RWLIST_HEAD(_columns, odbc_cache_columns) columns; AST_RWLIST_ENTRY(odbc_cache_tables) list; }; /* functions */ /*! * \brief Executes a prepared statement handle * \param obj The non-NULL result of odbc_request_obj() * \param stmt The prepared statement handle * \retval 0 on success * \retval -1 on failure * * This function was originally designed simply to execute a prepared * statement handle and to retry if the initial execution failed. * Unfortunately, it did this by disconnecting and reconnecting the database * handle which on most databases causes the statement handle to become * invalid. Therefore, this method has been deprecated in favor of * odbc_prepare_and_execute() which allows the statement to be prepared * multiple times, if necessary, in case of a loss of connection. * * This function really only ever worked with MySQL, where the statement handle is * not prepared on the server. If you are not using MySQL, you should avoid it. */ int ast_odbc_smart_execute(struct odbc_obj *obj, SQLHSTMT stmt) __attribute__((deprecated)); /*! * \brief Retrieves a connected ODBC object * \param name The name of the ODBC class for which a connection is needed. * \param flags One or more of the following flags: * \li RES_ODBC_SANITY_CHECK Whether to ensure that a connection is valid before returning the handle. Usually unnecessary. * \li RES_ODBC_INDEPENDENT_CONNECTION Return a handle which is independent from all others. Usually used when starting a transaction. * \li RES_ODBC_CONNECTED Only return a connected handle. Intended for use with peers which use idlecheck, which are checked periodically for reachability. * \return ODBC object * \retval NULL if there is no connection available with the requested name. * * Connection classes may, in fact, contain multiple connection handles. If * the connection is pooled, then each connection will be dedicated to the * thread which requests it. Note that all connections should be released * when the thread is done by calling ast_odbc_release_obj(), below. */ struct odbc_obj *_ast_odbc_request_obj2(const char *name, struct ast_flags flags, const char *file, const char *function, int lineno); struct odbc_obj *_ast_odbc_request_obj(const char *name, int check, const char *file, const char *function, int lineno); #define ast_odbc_request_obj2(a, b) _ast_odbc_request_obj2(a, b, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define ast_odbc_request_obj(a, b) _ast_odbc_request_obj(a, b, __FILE__, __PRETTY_FUNCTION__, __LINE__) /*! * \brief Retrieve a stored ODBC object, if a transaction has been started. * \param chan Channel associated with the transaction. * \param objname Name of the database handle. This name corresponds to the name passed * to \see ast_odbc_request_obj2 (or formerly, to ast_odbc_request_obj). Note that the * existence of this parameter name explicitly allows for multiple transactions to be open * at once, albeit to different databases. * \retval A stored ODBC object, if a transaction was already started. * \retval NULL, if no transaction yet exists. */ struct odbc_obj *ast_odbc_retrieve_transaction_obj(struct ast_channel *chan, const char *objname); /*! * \brief Releases an ODBC object previously allocated by ast_odbc_request_obj() * \param obj The ODBC object */ void ast_odbc_release_obj(struct odbc_obj *obj); /*! * \brief Checks an ODBC object to ensure it is still connected * \param obj The ODBC object * \retval 0 if connected * \retval -1 otherwise. */ int ast_odbc_sanity_check(struct odbc_obj *obj); /*! \brief Checks if the database natively supports backslash as an escape character. * \param obj The ODBC object * \return Returns 1 if backslash is a native escape character, 0 if an ESCAPE clause is needed to support '\' */ int ast_odbc_backslash_is_escape(struct odbc_obj *obj); /*! \brief Executes an non prepared statement and returns the resulting * statement handle. * \param obj The ODBC object * \param exec_cb A function callback, which, when called, should return a statement handle with result columns bound. * \param data A parameter to be passed to the exec_cb parameter function, indicating which statement handle is to be prepared. * \retval a statement handle * \retval NULL on error */ SQLHSTMT ast_odbc_direct_execute(struct odbc_obj *obj, SQLHSTMT (*exec_cb)(struct odbc_obj *obj, void *data), void *data); /*! * \brief Prepares, executes, and returns the resulting statement handle. * \param obj The ODBC object * \param prepare_cb A function callback, which, when called, should return a statement handle prepared, with any necessary parameters or result columns bound. * \param data A parameter to be passed to the prepare_cb parameter function, indicating which statement handle is to be prepared. * \retval a statement handle * \retval NULL on error */ SQLHSTMT ast_odbc_prepare_and_execute(struct odbc_obj *obj, SQLHSTMT (*prepare_cb)(struct odbc_obj *obj, void *data), void *data); /*! * \brief Find or create an entry describing the table specified. * \param database Name of an ODBC class on which to query the table * \param tablename Tablename to describe * \retval A structure describing the table layout, or NULL, if the table is not found or another error occurs. * When a structure is returned, the contained columns list will be * rdlock'ed, to ensure that it will be retained in memory. The information * will be cached until a reload event or when ast_odbc_clear_cache() is called * with the relevant parameters. * \since 1.6.1 */ struct odbc_cache_tables *ast_odbc_find_table(const char *database, const char *tablename); /*! * \brief Find a column entry within a cached table structure * \param table Cached table structure, as returned from ast_odbc_find_table() * \param colname The column name requested * \retval A structure describing the column type, or NULL, if the column is not found. * \since 1.6.1 */ struct odbc_cache_columns *ast_odbc_find_column(struct odbc_cache_tables *table, const char *colname); /*! * \brief Remove a cache entry from memory * This function may be called to clear entries created and cached by the * ast_odbc_find_table() API call. * \param database Name of an ODBC class (used to ensure like-named tables in different databases are not confused) * \param tablename Tablename for which a cached record should be removed * \retval 0 if the cache entry was removed, or -1 if no matching entry was found. * \since 1.6.1 */ int ast_odbc_clear_cache(const char *database, const char *tablename); /*! * \brief Release a table returned from ast_odbc_find_table */ #define ast_odbc_release_table(ptr) if (ptr) { AST_RWLIST_UNLOCK(&(ptr)->columns); } /*!\brief Wrapper for SQLGetData to use with dynamic strings * \param buf Address of the pointer to the ast_str structure. * \param pmaxlen The maximum size of the resulting string, or 0 for no limit. * \param StatementHandle The statement handle from which to retrieve data. * \param ColumnNumber Column number (1-based offset) for which to retrieve data. * \param TargetType The SQL constant indicating what kind of data is to be retrieved (usually SQL_CHAR) * \param StrLen_or_Ind A pointer to a length indicator, specifying the total length of data. */ SQLRETURN ast_odbc_ast_str_SQLGetData(struct ast_str **buf, int pmaxlen, SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLLEN *StrLen_or_Ind); #endif /* _ASTERISK_RES_ODBC_H */ asterisk-11.7.0/include/asterisk/dial.h0000644000175000007640000001542211726732126017712 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2007, Digium, Inc. * * Joshua Colp * * 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 Dialing API */ #ifndef _ASTERISK_DIAL_H #define _ASTERISK_DIAL_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief Main dialing structure. Contains global options, channels being dialed, and more! */ struct ast_dial; /*! \brief Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more! */ struct ast_dial_channel; typedef void (*ast_dial_state_callback)(struct ast_dial *); /*! \brief List of options that are applicable either globally or per dialed channel */ enum ast_dial_option { AST_DIAL_OPTION_RINGING, /*!< Always indicate ringing to caller */ AST_DIAL_OPTION_ANSWER_EXEC, /*!< Execute application upon answer in async mode */ AST_DIAL_OPTION_MUSIC, /*!< Play music on hold instead of ringing to the calling channel */ AST_DIAL_OPTION_DISABLE_CALL_FORWARDING, /*!< Disable call forwarding on channels */ AST_DIAL_OPTION_MAX, /*!< End terminator -- must always remain last */ }; /*! \brief List of return codes for dial run API calls */ enum ast_dial_result { AST_DIAL_RESULT_INVALID, /*!< Invalid options were passed to run function */ AST_DIAL_RESULT_FAILED, /*!< Attempts to dial failed before reaching critical state */ AST_DIAL_RESULT_TRYING, /*!< Currently trying to dial */ AST_DIAL_RESULT_RINGING, /*!< Dial is presently ringing */ AST_DIAL_RESULT_PROGRESS, /*!< Dial is presently progressing */ AST_DIAL_RESULT_PROCEEDING, /*!< Dial is presently proceeding */ AST_DIAL_RESULT_ANSWERED, /*!< A channel was answered */ AST_DIAL_RESULT_TIMEOUT, /*!< Timeout was tripped, nobody answered */ AST_DIAL_RESULT_HANGUP, /*!< Caller hung up */ AST_DIAL_RESULT_UNANSWERED, /*!< Nobody answered */ }; /*! \brief New dialing structure * \note Create a dialing structure * \return Returns a calloc'd ast_dial structure, NULL on failure */ struct ast_dial *ast_dial_create(void); /*! \brief Append a channel * \note Appends a channel to a dialing structure * \return Returns channel reference number on success, -1 on failure */ int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device); /*! \brief Execute dialing synchronously or asynchronously * \note Dials channels in a dial structure. * \return Returns dial result code. (TRYING/INVALID/FAILED/ANSWERED/TIMEOUT/UNANSWERED). */ enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async); /*! \brief Return channel that answered * \note Returns the Asterisk channel that answered * \param dial Dialing structure */ struct ast_channel *ast_dial_answered(struct ast_dial *dial); /*! \brief Steal the channel that answered * \note Returns the Asterisk channel that answered and removes it from the dialing structure * \param dial Dialing structure */ struct ast_channel *ast_dial_answered_steal(struct ast_dial *dial); /*! \brief Return state of dial * \note Returns the state of the dial attempt * \param dial Dialing structure */ enum ast_dial_result ast_dial_state(struct ast_dial *dial); /*! \brief Cancel async thread * \note Cancel a running async thread * \param dial Dialing structure */ enum ast_dial_result ast_dial_join(struct ast_dial *dial); /*! \brief Hangup channels * \note Hangup all active channels * \param dial Dialing structure */ void ast_dial_hangup(struct ast_dial *dial); /*! \brief Destroys a dialing structure * \note Cancels dialing and destroys (free's) the given ast_dial structure * \param dial Dialing structure to free * \return Returns 0 on success, -1 on failure */ int ast_dial_destroy(struct ast_dial *dial); /*! \brief Enables an option globally * \param dial Dial structure to enable option on * \param option Option to enable * \param data Data to pass to this option (not always needed) * \return Returns 0 on success, -1 on failure */ int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data); /*! \brief Enables an option per channel * \param dial Dial structure * \param num Channel number to enable option on * \param option Option to enable * \param data Data to pass to this option (not always needed) * \return Returns 0 on success, -1 on failure */ int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data); /*! \brief Disables an option globally * \param dial Dial structure to disable option on * \param option Option to disable * \return Returns 0 on success, -1 on failure */ int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option); /*! \brief Disables an option per channel * \param dial Dial structure * \param num Channel number to disable option on * \param option Option to disable * \return Returns 0 on success, -1 on failure */ int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option); /*! \brief Set a callback for state changes * \param dial The dial structure to watch for state changes * \param callback the callback * \return nothing */ void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback); /*! \brief Set user data on a dial structure * \param dial The dial structure to set a user data pointer on * \param user_data The user data pointer * \return nothing */ void ast_dial_set_user_data(struct ast_dial *dial, void *user_data); /*! \brief Return the user data on a dial structure * \param dial The dial structure * \return A pointer to the user data */ void *ast_dial_get_user_data(struct ast_dial *dial); /*! \brief Set the maximum time (globally) allowed for trying to ring phones * \param dial The dial structure to apply the time limit to * \param timeout Maximum time allowed in milliseconds * \return nothing */ void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout); /*! \brief Set the maximum time (per channel) allowed for trying to ring the phone * \param dial The dial structure the channel belongs to * \param num Channel number to set timeout on * \param timeout Maximum time allowed in milliseconds * \return nothing */ void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_DIAL_H */ asterisk-11.7.0/include/asterisk/enum.h0000644000175000007640000000772711155301351017742 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 enum.h \brief DNS and ENUM functions */ #ifndef _ASTERISK_ENUM_H #define _ASTERISK_ENUM_H #include "asterisk/channel.h" struct naptr { unsigned short order; unsigned short pref; } __attribute__((__packed__)); struct enum_naptr_rr { struct naptr naptr; /*!< order and preference of RR */ char *result; /*!< result of naptr parsing,e.g.: tel:+5553 */ char *tech; /*!< Technology (from URL scheme) */ int sort_pos; /*!< sort position */ }; struct enum_context { char *dst; /*!< Destination part of URL from ENUM */ int dstlen; /*!< Length */ char *tech; /*!< Technology (from URL scheme) */ int techlen; /*!< Length */ char *txt; /*!< TXT record in TXT lookup */ int txtlen; /*!< Length */ char *naptrinput; /*!< The number to lookup */ int position; /*!< specifies position of required RR */ int count; /*!< used as counter for RRs */ int options; /*!< options , see ENUMLOOKUP_OPTIONS_* defined above */ struct enum_naptr_rr *naptr_rrs; /*!< array of parsed NAPTR RRs */ int naptr_rrs_count; /*!< Size of array naptr_rrs */ }; /*! \brief Lookup entry in ENUM \param chan Channel \param number E164 number with or without the leading + \param location Number returned (or SIP uri) \param maxloc Max length \param technology Technology (from url scheme in response) You can set it to get particular answer RR, if there are many techs in DNS response, example: "sip" If you need any record, then set it to "ALL" string \param maxtech Max length \param suffix Zone suffix (WARNING: No defaults here any more) \param options Options 'c' - Count number of NAPTR RR number - Position of the requested RR in the answer list 'u' - Full URI return (does not strip URI scheme) 'i' - Infrastructure ENUM lookup 's' - ISN based lookup 'd' - Direct DNS query \param record The position of required RR in the answer list \param argcontext Argument for caching results into an enum_context pointer (NULL is used for not caching) \retval 1 if found \retval 0 if not found \retval -1 on hangup */ int ast_get_enum(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology, int maxtech, char* suffix, char* options, unsigned int record, struct enum_context **argcontext); /*! \brief Lookup DNS TXT record (used by app TXTCIDnum) * * Really has nothing to do with enum, but anyway... * Actually, there is now an internet-draft which describes how callerID should * be stored in ENUM domains: draft-ietf-enum-cnam-04.txt * The algorithm implemented here will thus be obsolete soon. * * \param chan Channel * \param number E164 number with or without the leading + * \param txt Text string (return value) * \param maxtxt Max length of "txt" * \param suffix Zone suffix * \version 1.6.1 new suffix parameter to take into account caller ids that aren't in e164.arpa * \version 1.6.1 removed parameters location, maxloc, technology, maxtech as all the information * is stored the txt string */ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix); int ast_enum_init(void); int ast_enum_reload(void); #endif /* _ASTERISK_ENUM_H */ asterisk-11.7.0/include/asterisk/crypto.h0000644000175000007640000001357711421643144020323 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Digium, Inc. * * Mark Spencer * * 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 Provide cryptographic signature routines */ #ifndef _ASTERISK_CRYPTO_H #define _ASTERISK_CRYPTO_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/optional_api.h" #include "asterisk/logger.h" #ifdef HAVE_CRYPTO #include "openssl/aes.h" typedef AES_KEY ast_aes_encrypt_key; typedef AES_KEY ast_aes_decrypt_key; #else /* !HAVE_CRYPTO */ typedef char ast_aes_encrypt_key; typedef char ast_aes_decrypt_key; #endif /* HAVE_CRYPTO */ #define AST_KEY_PUBLIC (1 << 0) #define AST_KEY_PRIVATE (1 << 1) struct ast_key; /*! * \brief Retrieve a key * \param name of the key we are retrieving * \param int type of key (AST_KEY_PUBLIC or AST_KEY_PRIVATE) * * \retval the key on success. * \retval NULL on failure. */ AST_OPTIONAL_API(struct ast_key *, ast_key_get, (const char *key, int type), { return NULL; }); /*! * \brief Check the authenticity of a message signature using a given public key * \param key a public key to use to verify * \param msg the message that has been signed * \param sig the proposed valid signature in mime64-like encoding * * \retval 0 if the signature is valid. * \retval -1 otherwise. * */ AST_OPTIONAL_API(int, ast_check_signature, (struct ast_key *key, const char *msg, const char *sig), { return -1; }); /*! * \brief Check the authenticity of a message signature using a given public key * \param key a public key to use to verify * \param msg the message that has been signed * \param sig the proposed valid signature in raw binary representation * * \retval 0 if the signature is valid. * \retval -1 otherwise. * */ AST_OPTIONAL_API(int, ast_check_signature_bin, (struct ast_key *key, const char *msg, int msglen, const unsigned char *sig), { return -1; }); /*! * \brief Sign a message signature using a given private key * \param key a private key to use to create the signature * \param msg the message to sign * \param sig a pointer to a buffer of at least 256 bytes in which the * mime64-like encoded signature will be stored * * \retval 0 on success. * \retval -1 on failure. * */ AST_OPTIONAL_API(int, ast_sign, (struct ast_key *key, char *msg, char *sig), { return -1; }); /*! * \brief Sign a message signature using a given private key * \param key a private key to use to create the signature * \param msg the message to sign * \param sig a pointer to a buffer of at least 128 bytes in which the * raw encoded signature will be stored * * \retval 0 on success. * \retval -1 on failure. * */ AST_OPTIONAL_API(int, ast_sign_bin, (struct ast_key *key, const char *msg, int msglen, unsigned char *sig), { return -1; }); /*! * \brief Encrypt a message using a given private key * \param key a private key to use to encrypt * \param src the message to encrypt * \param srclen the length of the message to encrypt * \param dst a pointer to a buffer of at least srclen * 1.5 bytes in which the encrypted * answer will be stored * * \retval length of encrypted data on success. * \retval -1 on failure. * */ AST_OPTIONAL_API(int, ast_encrypt_bin, (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key), { return -1; }); /*! * \brief Decrypt a message using a given private key * \param key a private key to use to decrypt * \param src the message to decrypt * \param srclen the length of the message to decrypt * \param dst a pointer to a buffer of at least srclen bytes in which the decrypted * answer will be stored * * \retval length of dencrypted data on success. * \retval -1 on failure. * */ AST_OPTIONAL_API(int, ast_decrypt_bin, (unsigned char *dst, const unsigned char *src, int srclen, struct ast_key *key), { return -1; }); /*! * \brief Set an encryption key * \param key a 16 char key * \param ctx address of an aes encryption context * * \retval 0 success * \retval nonzero failure */ AST_OPTIONAL_API(int, ast_aes_set_encrypt_key, (const unsigned char *key, ast_aes_encrypt_key *ctx), { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; }); /*! * \brief Set a decryption key * \param key a 16 char key * \param ctx address of an aes encryption context * * \retval 0 success * \retval nonzero failure */ AST_OPTIONAL_API(int, ast_aes_set_decrypt_key, (const unsigned char *key, ast_aes_decrypt_key *ctx), { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n"); return -1; }); /*! * \brief AES encrypt data * \param in data to be encrypted * \param out pointer to a buffer to hold the encrypted output * \param ctx address of an aes encryption context filled in with ast_aes_set_encrypt_key */ AST_OPTIONAL_API(void, ast_aes_encrypt, (const unsigned char *in, unsigned char *out, const ast_aes_encrypt_key *ctx), { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; }); /*! * \brief AES decrypt data * \param in encrypted data * \param out pointer to a buffer to hold the decrypted output * \param ctx address of an aes encryption context filled in with ast_aes_set_decrypt_key */ AST_OPTIONAL_API(void, ast_aes_decrypt, (const unsigned char *in, unsigned char *out, const ast_aes_decrypt_key *ctx), { ast_log(LOG_WARNING, "AES encryption disabled. Install OpenSSL.\n");return; }); AST_OPTIONAL_API(int, ast_crypto_loaded, (void), { return 0; }); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_CRYPTO_H */ asterisk-11.7.0/include/asterisk/http.h0000644000175000007640000001664211403452732017757 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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. */ #ifndef _ASTERISK_HTTP_H #define _ASTERISK_HTTP_H #include "asterisk/config.h" #include "asterisk/tcptls.h" #include "asterisk/linkedlists.h" /*! * \file http.h * \brief Support for Private Asterisk HTTP Servers. * \note Note: The Asterisk HTTP servers are extremely simple and minimal and * only support the "GET" method. * * \author Mark Spencer * * \note In order to have TLS/SSL support, we need the openssl libraries. * Still we can decide whether or not to use them by commenting * in or out the DO_SSL macro. * TLS/SSL support is basically implemented by reading from a config file * (currently http.conf) the names of the certificate and cipher to use, * and then run ssl_setup() to create an appropriate SSL_CTX (ssl_ctx) * If we support multiple domains, presumably we need to read multiple * certificates. * When we are requested to open a TLS socket, we run make_file_from_fd() * on the socket, to do the necessary setup. At the moment the context's name * is hardwired in the function, but we can certainly make it into an extra * parameter to the function. * We declare most of ssl support variables unconditionally, * because their number is small and this simplifies the code. * * \note: the ssl-support variables (ssl_ctx, do_ssl, certfile, cipher) * and their setup should be moved to a more central place, e.g. asterisk.conf * and the source files that processes it. Similarly, ssl_setup() should * be run earlier in the startup process so modules have it available. */ /*! \brief HTTP Request methods known by Asterisk */ enum ast_http_method { AST_HTTP_UNKNOWN = -1, /*!< Unknown response */ AST_HTTP_GET = 0, AST_HTTP_POST, AST_HTTP_HEAD, AST_HTTP_PUT, /*!< Not supported in Asterisk */ }; struct ast_http_uri; /*! \brief HTTP Callbacks * * \note The callback function receives server instance, uri, http method, * get method (if present in URI), and http headers as arguments and should * use the ast_http_send() function for sending content allocated with ast_str * and/or content from an opened file descriptor. * * Status and status text should be sent as arguments to the ast_http_send() * function to reflect the status of the request (200 or 304, for example). * Content length is calculated by ast_http_send() automatically. * * Static content may be indicated to the ast_http_send() function, to indicate * that it may be cached. * * \verbatim * The return value may include additional headers at the front and MUST * include a blank line with \r\n to provide separation between user headers * and content (even if no content is specified) * \endverbatim * * For an error response, the ast_http_error() function may be used. */ typedef int (*ast_http_callback)(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers); /*! \brief Definition of a URI handler */ struct ast_http_uri { AST_LIST_ENTRY(ast_http_uri) entry; const char *description; const char *uri; ast_http_callback callback; unsigned int has_subtree:1; /*! Structure is malloc'd */ unsigned int mallocd:1; /*! Data structure is malloc'd */ unsigned int dmallocd:1; /*! Data to bind to the uri if needed */ void *data; /*! Key to be used for unlinking if multiple URIs registered */ const char *key; }; /*! \brief Get cookie from Request headers */ struct ast_variable *ast_http_get_cookies(struct ast_variable *headers); /*! \brief Register a URI handler */ int ast_http_uri_link(struct ast_http_uri *urihandler); /*! \brief Unregister a URI handler */ void ast_http_uri_unlink(struct ast_http_uri *urihandler); /*! \brief Unregister all handlers with matching key */ void ast_http_uri_unlink_all_with_key(const char *key); /*!\brief Return http method name string * \since 1.8 */ const char *ast_get_http_method(enum ast_http_method method) attribute_pure; /*!\brief Return mime type based on extension * \param ftype filename extension * \return String containing associated MIME type * \since 1.8 */ const char *ast_http_ftype2mtype(const char *ftype) attribute_pure; /*!\brief Return manager id, if exist, from request headers * \param headers List of HTTP headers * \return 32-bit associated manager session identifier * \since 1.8 */ uint32_t ast_http_manid_from_vars(struct ast_variable *headers) attribute_pure; /*! \brief Generic function for sending http/1.1 response. * \param ser TCP/TLS session object * \param method GET/POST/HEAD * \param status_code HTTP response code (200/401/403/404/500) * \param status_title English equivalent to the status_code parameter * \param http_header An ast_str object containing all headers * \param out An ast_str object containing the body of the response * \param fd If out is NULL, a file descriptor where the body of the response is held (otherwise -1) * \param static_content Zero if the content is dynamically generated and should not be cached; nonzero otherwise * * \note Function determines the HTTP response header from status_code, * status_header, and http_header. * * Extra HTTP headers MUST be present only in the http_header argument. The * argument "out" should contain only content of the response (no headers!). * * HTTP content can be constructed from the argument "out", if it is not NULL; * otherwise, the function will read content from FD. * * This function calculates the content-length http header itself. * * Both the http_header and out arguments will be freed by this function; * however, if FD is open, it will remain open. * * \since 1.8 */ void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, struct ast_str *http_header, struct ast_str *out, const int fd, unsigned int static_content); /*!\brief Send http "401 Unauthorized" response and close socket */ void ast_http_auth(struct ast_tcptls_session_instance *ser, const char *realm, const unsigned long nonce, const unsigned long opaque, int stale, const char *text); /*!\brief Send HTTP error message and close socket */ void ast_http_error(struct ast_tcptls_session_instance *ser, int status, const char *title, const char *text); /*! * \brief Return the current prefix * \param[out] buf destination buffer for previous * \param[in] len length of prefix to copy * \since 1.6.1 */ void ast_http_prefix(char *buf, int len); /*!\brief Get post variables from client Request Entity-Body, if content type is application/x-www-form-urlencoded. * \param ser TCP/TLS session object * \param headers List of HTTP headers * \return List of variables within the POST body * \note Since returned list is malloc'd, list should be free'd by the calling function * \since 1.8 */ struct ast_variable *ast_http_get_post_vars(struct ast_tcptls_session_instance *ser, struct ast_variable *headers); #endif /* _ASTERISK_SRV_H */ asterisk-11.7.0/include/asterisk/mod_format.h0000644000175000007640000001230711522553062021121 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Header for providers of file and format handling routines. * Clients of these routines should include "asterisk/file.h" instead. */ #ifndef _ASTERISK_MOD_FORMAT_H #define _ASTERISK_MOD_FORMAT_H #include "asterisk/file.h" #include "asterisk/frame.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief * Each supported file format is described by the following structure. * * Not all are necessary, the support routine implement default * values for some of them. * A handler typically fills a structure initializing the desired * fields, and then calls ast_format_def_register() with the (readonly) * structure as an argument. */ struct ast_format_def { char name[80]; /*!< Name of format */ char exts[80]; /*!< Extensions (separated by | if more than one) this format can read. First is assumed for writing (e.g. .mp3) */ struct ast_format format; /*!< Format of frames it uses/provides (one only) */ /*! * \brief Prepare an input stream for playback. * \return 0 on success, -1 on error. * The FILE is already open (in s->f) so this function only needs to perform * any applicable validity checks on the file. If none is required, the * function can be omitted. */ int (*open)(struct ast_filestream *s); /*! * \brief Prepare a stream for output, and comment it appropriately if applicable. * \return 0 on success, -1 on error. * Same as the open, the FILE is already open so the function just needs to * prepare any header and other fields, if any. * The function can be omitted if nothing is needed. */ int (*rewrite)(struct ast_filestream *s, const char *comment); /*! Write a frame to a channel */ int (*write)(struct ast_filestream *, struct ast_frame *); /*! seek num samples into file, whence - like a normal seek but with offset in samples */ int (*seek)(struct ast_filestream *, off_t, int); int (*trunc)(struct ast_filestream *fs); /*!< trunc file to current position */ off_t (*tell)(struct ast_filestream *fs); /*!< tell current position */ /*! Read the next frame from the filestream (if available) and report * when to get next frame (in samples) */ struct ast_frame * (*read)(struct ast_filestream *, int *whennext); /*! Do any closing actions, if any. The descriptor and structure are closed * and destroyed by the generic routines, so they must not be done here. */ void (*close)(struct ast_filestream *); char * (*getcomment)(struct ast_filestream *); /*!< Retrieve file comment */ AST_LIST_ENTRY(ast_format_def) list; /*!< Link */ /*! * If the handler needs a buffer (for read, typically) * and/or a private descriptor, put here the * required size (in bytes) and the support routine will allocate them * for you, pointed by s->buf and s->private, respectively. * When allocating a buffer, remember to leave AST_FRIENDLY_OFFSET * spare bytes at the bginning. */ int buf_size; /*!< size of frame buffer, if any, aligned to 8 bytes. */ int desc_size; /*!< size of private descriptor, if any */ struct ast_module *module; }; /*! \brief * This structure is allocated by file.c in one chunk, * together with buf_size and desc_size bytes of memory * to be used for private purposes (e.g. buffers etc.) */ struct ast_filestream { /*! Everybody reserves a block of AST_RESERVED_POINTERS pointers for us */ struct ast_format_def *fmt; /* need to write to the lock and usecnt */ int flags; mode_t mode; char *open_filename; char *filename; char *realfilename; /*! Video file stream */ struct ast_filestream *vfs; /*! Transparently translate from another format -- just once */ struct ast_trans_pvt *trans; struct ast_tranlator_pvt *tr; struct ast_format lastwriteformat; int lasttimeout; struct ast_channel *owner; FILE *f; struct ast_frame fr; /*!< frame produced by read, typically */ char *buf; /*!< buffer pointed to by ast_frame; */ void *_private; /*!< pointer to private buffer */ const char *orig_chan_name; char *write_buffer; }; /*! * \brief Register a new file format capability. * Adds a format to Asterisk's format abilities. * \retval 0 on success * \retval -1 on failure */ int __ast_format_def_register(const struct ast_format_def *f, struct ast_module *mod); #define ast_format_def_register(f) __ast_format_def_register(f, ast_module_info->self) /*! * \brief Unregisters a file format * \param name the name of the format you wish to unregister * Unregisters a format based on the name of the format. * \retval 0 on success * \retval -1 on failure to unregister */ int ast_format_def_unregister(const char *name); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_MOD_FORMAT_H */ asterisk-11.7.0/include/asterisk/ast_expr.h0000644000175000007640000000333511176121015020612 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 * * ??????? * \todo Explain this file! */ #ifndef _ASTERISK_EXPR_H #define _ASTERISK_EXPR_H #ifndef STANDALONE #endif #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*!\brief Evaluate the given expression * \param expr An expression * \param buf Result buffer * \param length Size of the result buffer, in bytes * \param chan Channel to use for evaluating included dialplan functions, if any * \return Length of the result string, in bytes */ int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan); /*!\brief Evaluate the given expression * \param str Dynamic result buffer * \param maxlen <0 if the size of the buffer should remain constant, >0 if the size of the buffer should expand to that many bytes, maximum, or 0 for unlimited expansion of the result buffer * \param chan Channel to use for evaluating included dialplan functions, if any * \param expr An expression * \return Length of the result string, in bytes */ int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_EXPR_H */ asterisk-11.7.0/include/asterisk/taskprocessor.h0000644000175000007640000001131611340424040021662 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007-2008, Digium, Inc. * * Dwayne M. Hubbard * * 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 taskprocessor.h * \brief An API for managing task processing threads that can be shared across modules * * \author Dwayne M. Hubbard * * \note A taskprocessor is a named singleton containing a processing thread and * a task queue that serializes tasks pushed into it by [a] module(s) that reference the taskprocessor. * A taskprocessor is created the first time its name is requested via the ast_taskprocessor_get() * function and destroyed when the taskprocessor reference count reaches zero. * * Modules that obtain a reference to a taskprocessor can queue tasks into the taskprocessor * to be processed by the singleton processing thread when the task is popped off the front * of the queue. A task is a wrapper around a task-handling function pointer and a data * pointer. It is the responsibility of the task handling function to free memory allocated for * the task data pointer. A task is pushed into a taskprocessor queue using the * ast_taskprocessor_push(taskprocessor, taskhandler, taskdata) function and freed by the * taskprocessor after the task handling function returns. A module releases its reference to a * taskprocessor using the ast_taskprocessor_unreference() function which may result in the * destruction of the taskprocessor if the taskprocessor's reference count reaches zero. Tasks waiting * to be processed in the taskprocessor queue when the taskprocessor reference count reaches zero * will be purged and released from the taskprocessor queue without being processed. */ #ifndef __AST_TASKPROCESSOR_H__ #define __AST_TASKPROCESSOR_H__ struct ast_taskprocessor; /*! * \brief ast_tps_options for specification of taskprocessor options * * Specify whether a taskprocessor should be created via ast_taskprocessor_get() if the taskprocessor * does not already exist. The default behavior is to create a taskprocessor if it does not already exist * and provide its reference to the calling function. To only return a reference to a taskprocessor if * and only if it exists, use the TPS_REF_IF_EXISTS option in ast_taskprocessor_get(). */ enum ast_tps_options { /*! \brief return a reference to a taskprocessor, create one if it does not exist */ TPS_REF_DEFAULT = 0, /*! \brief return a reference to a taskprocessor ONLY if it already exists */ TPS_REF_IF_EXISTS = (1 << 0), }; /*! * \brief Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary * * The default behavior of instantiating a taskprocessor if one does not already exist can be * disabled by specifying the TPS_REF_IF_EXISTS ast_tps_options as the second argument to ast_taskprocessor_get(). * \param name The name of the taskprocessor * \param create Use 0 by default or specify TPS_REF_IF_EXISTS to return NULL if the taskprocessor does * not already exist * return A pointer to a reference counted taskprocessor under normal conditions, or NULL if the * TPS_REF_IF_EXISTS reference type is specified and the taskprocessor does not exist * \since 1.6.1 */ struct ast_taskprocessor *ast_taskprocessor_get(const char *name, enum ast_tps_options create); /*! * \brief Unreference the specified taskprocessor and its reference count will decrement. * * Taskprocessors use astobj2 and will unlink from the taskprocessor singleton container and destroy * themself when the taskprocessor reference count reaches zero. * \param tps taskprocessor to unreference * \return NULL * \since 1.6.1 */ void *ast_taskprocessor_unreference(struct ast_taskprocessor *tps); /*! * \brief Push a task into the specified taskprocessor queue and signal the taskprocessor thread * \param tps The taskprocessor structure * \param task_exe The task handling function to push into the taskprocessor queue * \param datap The data to be used by the task handling function * \retval 0 success * \retval -1 failure * \since 1.6.1 */ int ast_taskprocessor_push(struct ast_taskprocessor *tps, int (*task_exe)(void *datap), void *datap); /*! * \brief Return the name of the taskprocessor singleton * \since 1.6.1 */ const char *ast_taskprocessor_name(struct ast_taskprocessor *tps); #endif /* __AST_TASKPROCESSOR_H__ */ asterisk-11.7.0/include/asterisk/rtp_engine.h0000644000175000007640000020752012232577603021135 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * Mark Spencer * Joshua Colp * * 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 Pluggable RTP Architecture * \author Joshua Colp * \ref AstRTPEngine */ /*! * \page AstRTPEngine Asterisk RTP Engine API * * The purpose of this API is to provide a way for multiple RTP stacks to be * used inside of Asterisk without any module that uses RTP knowing any * different. To the module each RTP stack behaves the same. * * An RTP session is called an instance and is made up of a combination of codec * information, RTP engine, RTP properties, and address information. An engine * name may be passed in to explicitly choose an RTP stack to be used but a * default one will be used if none is provided. An address to use for RTP may * also be provided but the underlying RTP engine may choose a different address * depending on it's configuration. * * An RTP engine is the layer between the RTP engine core and the RTP stack * itself. The RTP engine core provides a set of callbacks to do various things * (such as write audio out) that the RTP engine has to have implemented. * * Glue is what binds an RTP instance to a channel. It is used to retrieve RTP * instance information when performing remote or local bridging and is used to * have the channel driver tell the remote side to change destination of the RTP * stream. * * Statistics from an RTP instance can be retrieved using the * ast_rtp_instance_get_stats API call. This essentially asks the RTP engine in * use to fill in a structure with the requested values. It is not required for * an RTP engine to support all statistic values. * * Properties allow behavior of the RTP engine and RTP engine core to be * changed. For example, there is a property named AST_RTP_PROPERTY_NAT which is * used to tell the RTP engine to enable symmetric RTP if it supports it. It is * not required for an RTP engine to support all properties. * * Codec information is stored using a separate data structure which has it's * own set of API calls to add/remove/retrieve information. They are used by the * module after an RTP instance is created so that payload information is * available for the RTP engine. */ #ifndef _ASTERISK_RTP_ENGINE_H #define _ASTERISK_RTP_ENGINE_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/astobj2.h" #include "asterisk/frame.h" #include "asterisk/netsock2.h" #include "asterisk/sched.h" #include "asterisk/res_srtp.h" /* Maximum number of payloads supported */ #if defined(LOW_MEMORY) #define AST_RTP_MAX_PT 128 #else #define AST_RTP_MAX_PT 196 #endif /* Maximum number of generations */ #define AST_RED_MAX_GENERATION 5 struct ast_rtp_instance; struct ast_rtp_glue; /*! RTP Properties that can be set on an RTP instance */ enum ast_rtp_property { /*! Enable symmetric RTP support */ AST_RTP_PROPERTY_NAT = 0, /*! RTP instance will be carrying DTMF (using RFC2833) */ AST_RTP_PROPERTY_DTMF, /*! Expect unreliable DTMF from remote party */ AST_RTP_PROPERTY_DTMF_COMPENSATE, /*! Enable STUN support */ AST_RTP_PROPERTY_STUN, /*! Enable RTCP support */ AST_RTP_PROPERTY_RTCP, /*! * \brief Maximum number of RTP properties supported * * \note THIS MUST BE THE LAST ENTRY IN THIS ENUM. */ AST_RTP_PROPERTY_MAX, }; /*! Additional RTP options */ enum ast_rtp_options { /*! Remote side is using non-standard G.726 */ AST_RTP_OPT_G726_NONSTANDARD = (1 << 0), }; /*! RTP DTMF Modes */ enum ast_rtp_dtmf_mode { /*! No DTMF is being carried over the RTP stream */ AST_RTP_DTMF_MODE_NONE = 0, /*! DTMF is being carried out of band using RFC2833 */ AST_RTP_DTMF_MODE_RFC2833, /*! DTMF is being carried inband over the RTP stream */ AST_RTP_DTMF_MODE_INBAND, }; /*! Result codes when RTP glue is queried for information */ enum ast_rtp_glue_result { /*! No remote or local bridging is permitted */ AST_RTP_GLUE_RESULT_FORBID = 0, /*! Move RTP stream to be remote between devices directly */ AST_RTP_GLUE_RESULT_REMOTE, /*! Perform RTP engine level bridging if possible */ AST_RTP_GLUE_RESULT_LOCAL, }; /*! Field statistics that can be retrieved from an RTP instance */ enum ast_rtp_instance_stat_field { /*! Retrieve quality information */ AST_RTP_INSTANCE_STAT_FIELD_QUALITY = 0, /*! Retrieve quality information about jitter */ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, /*! Retrieve quality information about packet loss */ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, /*! Retrieve quality information about round trip time */ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, }; /*! Statistics that can be retrieved from an RTP instance */ enum ast_rtp_instance_stat { /*! Retrieve all statistics */ AST_RTP_INSTANCE_STAT_ALL = 0, /*! Retrieve number of packets transmitted */ AST_RTP_INSTANCE_STAT_TXCOUNT, /*! Retrieve number of packets received */ AST_RTP_INSTANCE_STAT_RXCOUNT, /*! Retrieve ALL statistics relating to packet loss */ AST_RTP_INSTANCE_STAT_COMBINED_LOSS, /*! Retrieve number of packets lost for transmitting */ AST_RTP_INSTANCE_STAT_TXPLOSS, /*! Retrieve number of packets lost for receiving */ AST_RTP_INSTANCE_STAT_RXPLOSS, /*! Retrieve maximum number of packets lost on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS, /*! Retrieve minimum number of packets lost on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS, /*! Retrieve average number of packets lost on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS, /*! Retrieve standard deviation of packets lost on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS, /*! Retrieve maximum number of packets lost on local side */ AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS, /*! Retrieve minimum number of packets lost on local side */ AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS, /*! Retrieve average number of packets lost on local side */ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS, /*! Retrieve standard deviation of packets lost on local side */ AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS, /*! Retrieve ALL statistics relating to jitter */ AST_RTP_INSTANCE_STAT_COMBINED_JITTER, /*! Retrieve jitter on transmitted packets */ AST_RTP_INSTANCE_STAT_TXJITTER, /*! Retrieve jitter on received packets */ AST_RTP_INSTANCE_STAT_RXJITTER, /*! Retrieve maximum jitter on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER, /*! Retrieve minimum jitter on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER, /*! Retrieve average jitter on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER, /*! Retrieve standard deviation jitter on remote side */ AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER, /*! Retrieve maximum jitter on local side */ AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER, /*! Retrieve minimum jitter on local side */ AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER, /*! Retrieve average jitter on local side */ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER, /*! Retrieve standard deviation jitter on local side */ AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER, /*! Retrieve ALL statistics relating to round trip time */ AST_RTP_INSTANCE_STAT_COMBINED_RTT, /*! Retrieve round trip time */ AST_RTP_INSTANCE_STAT_RTT, /*! Retrieve maximum round trip time */ AST_RTP_INSTANCE_STAT_MAX_RTT, /*! Retrieve minimum round trip time */ AST_RTP_INSTANCE_STAT_MIN_RTT, /*! Retrieve average round trip time */ AST_RTP_INSTANCE_STAT_NORMDEVRTT, /*! Retrieve standard deviation round trip time */ AST_RTP_INSTANCE_STAT_STDEVRTT, /*! Retrieve local SSRC */ AST_RTP_INSTANCE_STAT_LOCAL_SSRC, /*! Retrieve remote SSRC */ AST_RTP_INSTANCE_STAT_REMOTE_SSRC, }; /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */ /*! DTMF (RFC2833) */ #define AST_RTP_DTMF (1 << 0) /*! 'Comfort Noise' (RFC3389) */ #define AST_RTP_CN (1 << 1) /*! DTMF (Cisco Proprietary) */ #define AST_RTP_CISCO_DTMF (1 << 2) /*! Maximum RTP-specific code */ #define AST_RTP_MAX AST_RTP_CISCO_DTMF /*! Structure that represents a payload */ struct ast_rtp_payload_type { /*! Is this an Asterisk value */ int asterisk_format; /*! If asterisk_format is set, this is the internal * asterisk format represented by the payload */ struct ast_format format; /*! Actual internal RTP specific value of the payload */ int rtp_code; /*! Actual payload number */ int payload; }; /*! Structure that represents statistics from an RTP instance */ struct ast_rtp_instance_stats { /*! Number of packets transmitted */ unsigned int txcount; /*! Number of packets received */ unsigned int rxcount; /*! Jitter on transmitted packets */ double txjitter; /*! Jitter on received packets */ double rxjitter; /*! Maximum jitter on remote side */ double remote_maxjitter; /*! Minimum jitter on remote side */ double remote_minjitter; /*! Average jitter on remote side */ double remote_normdevjitter; /*! Standard deviation jitter on remote side */ double remote_stdevjitter; /*! Maximum jitter on local side */ double local_maxjitter; /*! Minimum jitter on local side */ double local_minjitter; /*! Average jitter on local side */ double local_normdevjitter; /*! Standard deviation jitter on local side */ double local_stdevjitter; /*! Number of transmitted packets lost */ unsigned int txploss; /*! Number of received packets lost */ unsigned int rxploss; /*! Maximum number of packets lost on remote side */ double remote_maxrxploss; /*! Minimum number of packets lost on remote side */ double remote_minrxploss; /*! Average number of packets lost on remote side */ double remote_normdevrxploss; /*! Standard deviation packets lost on remote side */ double remote_stdevrxploss; /*! Maximum number of packets lost on local side */ double local_maxrxploss; /*! Minimum number of packets lost on local side */ double local_minrxploss; /*! Average number of packets lost on local side */ double local_normdevrxploss; /*! Standard deviation packets lost on local side */ double local_stdevrxploss; /*! Total round trip time */ double rtt; /*! Maximum round trip time */ double maxrtt; /*! Minimum round trip time */ double minrtt; /*! Average round trip time */ double normdevrtt; /*! Standard deviation round trip time */ double stdevrtt; /*! Our SSRC */ unsigned int local_ssrc; /*! Their SSRC */ unsigned int remote_ssrc; }; #define AST_RTP_STAT_SET(current_stat, combined, placement, value) \ if (stat == current_stat || stat == AST_RTP_INSTANCE_STAT_ALL || (combined >= 0 && combined == current_stat)) { \ placement = value; \ if (stat == current_stat) { \ return 0; \ } \ } #define AST_RTP_STAT_TERMINATOR(combined) \ if (stat == combined) { \ return 0; \ } /*! \brief ICE candidate types */ enum ast_rtp_ice_candidate_type { AST_RTP_ICE_CANDIDATE_TYPE_HOST, /*!< ICE host candidate. A host candidate represents the actual local transport address in the host. */ AST_RTP_ICE_CANDIDATE_TYPE_SRFLX, /*!< ICE server reflexive candidate, which represents the public mapped address of the local address. */ AST_RTP_ICE_CANDIDATE_TYPE_RELAYED, /*!< ICE relayed candidate, which represents the address allocated in TURN server. */ }; /*! \brief Structure for an ICE candidate */ struct ast_rtp_engine_ice_candidate { char *foundation; /*!< Foundation identifier */ unsigned int id; /*!< Component identifier */ char *transport; /*!< Transport for the media */ int priority; /*!< Priority which is used if multiple candidates can be used */ struct ast_sockaddr address; /*!< Address of the candidate */ struct ast_sockaddr relay_address; /*!< Relay address for the candidate */ enum ast_rtp_ice_candidate_type type; /*!< Type of candidate */ }; /*! \brief Structure that represents the optional ICE support within an RTP engine */ struct ast_rtp_engine_ice { /*! Callback for setting received authentication information */ void (*set_authentication)(struct ast_rtp_instance *instance, const char *ufrag, const char *password); /*! Callback for adding a remote candidate */ void (*add_remote_candidate)(struct ast_rtp_instance *instance, const struct ast_rtp_engine_ice_candidate *candidate); /*! Callback for starting ICE negotiation */ void (*start)(struct ast_rtp_instance *instance); /*! Callback for stopping ICE support */ void (*stop)(struct ast_rtp_instance *instance); /*! Callback for getting local username */ const char *(*get_ufrag)(struct ast_rtp_instance *instance); /*! Callback for getting local password */ const char *(*get_password)(struct ast_rtp_instance *instance); /*! Callback for getting local candidates */ struct ao2_container *(*get_local_candidates)(struct ast_rtp_instance *instance); /*! Callback for telling the ICE support that it is talking to an ice-lite implementation */ void (*ice_lite)(struct ast_rtp_instance *instance); }; /*! \brief DTLS setup types */ enum ast_rtp_dtls_setup { AST_RTP_DTLS_SETUP_ACTIVE, /*!< Endpoint is willing to inititate connections */ AST_RTP_DTLS_SETUP_PASSIVE, /*!< Endpoint is willing to accept connections */ AST_RTP_DTLS_SETUP_ACTPASS, /*!< Endpoint is willing to both accept and initiate connections */ AST_RTP_DTLS_SETUP_HOLDCONN, /*!< Endpoint does not want the connection to be established right now */ }; /*! \brief DTLS connection states */ enum ast_rtp_dtls_connection { AST_RTP_DTLS_CONNECTION_NEW, /*!< Endpoint wants to use a new connection */ AST_RTP_DTLS_CONNECTION_EXISTING, /*!< Endpoint wishes to use existing connection */ }; /*! \brief DTLS fingerprint hashes */ enum ast_rtp_dtls_hash { AST_RTP_DTLS_HASH_SHA1, /*!< SHA-1 fingerprint hash */ }; /*! \brief DTLS configuration structure */ struct ast_rtp_dtls_cfg { unsigned int enabled:1; /*!< Whether DTLS support is enabled or not */ unsigned int verify:1; /*!< Whether to request and verify a client certificate when acting as server */ unsigned int rekey; /*!< Interval at which to renegotiate and rekey - defaults to 0 (off) */ enum ast_rtp_dtls_setup default_setup; /*!< Default setup type to use for outgoing */ enum ast_srtp_suite suite; /*!< Crypto suite in use */ char *certfile; /*!< Certificate file */ char *pvtfile; /*!< Private key file */ char *cipher; /*!< Cipher to use */ char *cafile; /*!< Certificate authority file */ char *capath; /*!< Path to certificate authority */ }; /*! \brief Structure that represents the optional DTLS SRTP support within an RTP engine */ struct ast_rtp_engine_dtls { /*! Set the configuration of the DTLS support on the instance */ int (*set_configuration)(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg); /*! Get if the DTLS SRTP support is active or not */ int (*active)(struct ast_rtp_instance *instance); /*! Stop and terminate DTLS SRTP support */ void (*stop)(struct ast_rtp_instance *instance); /*! Reset the connection and start fresh */ void (*reset)(struct ast_rtp_instance *instance); /*! Get the current connection state */ enum ast_rtp_dtls_connection (*get_connection)(struct ast_rtp_instance *instance); /*! Get the current setup state */ enum ast_rtp_dtls_setup (*get_setup)(struct ast_rtp_instance *instance); /*! Set the remote setup state */ void (*set_setup)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_setup setup); /*! Set the remote fingerprint */ void (*set_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash, const char *fingerprint); /*! Get the local fingerprint */ const char *(*get_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash); }; /*! Structure that represents an RTP stack (engine) */ struct ast_rtp_engine { /*! Name of the RTP engine, used when explicitly requested */ const char *name; /*! Module this RTP engine came from, used for reference counting */ struct ast_module *mod; /*! Callback for setting up a new RTP instance */ int (*new)(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *sa, void *data); /*! Callback for destroying an RTP instance */ int (*destroy)(struct ast_rtp_instance *instance); /*! Callback for writing out a frame */ int (*write)(struct ast_rtp_instance *instance, struct ast_frame *frame); /*! Callback for stopping the RTP instance */ void (*stop)(struct ast_rtp_instance *instance); /*! Callback for starting RFC2833 DTMF transmission */ int (*dtmf_begin)(struct ast_rtp_instance *instance, char digit); /*! Callback for stopping RFC2833 DTMF transmission */ int (*dtmf_end)(struct ast_rtp_instance *instance, char digit); int (*dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration); /*! Callback to indicate that we should update the marker bit */ void (*update_source)(struct ast_rtp_instance *instance); /*! Callback to indicate that we should update the marker bit and ssrc */ void (*change_source)(struct ast_rtp_instance *instance); /*! Callback for setting an extended RTP property */ int (*extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value); /*! Callback for getting an extended RTP property */ void *(*extended_prop_get)(struct ast_rtp_instance *instance, int property); /*! Callback for setting an RTP property */ void (*prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value); /*! Callback for setting a payload. If asterisk is to be used, asterisk_format will be set, otherwise value in code is used. */ void (*payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code); /*! Callback for setting packetization preferences */ void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref); /*! Callback for setting the remote address that RTP is to be sent to */ void (*remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa); /*! Callback for setting an alternate remote address */ void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa); /*! Callback for changing DTMF mode */ int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode); /*! Callback for getting DTMF mode */ enum ast_rtp_dtmf_mode (*dtmf_mode_get)(struct ast_rtp_instance *instance); /*! Callback for retrieving statistics */ int (*get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat); /*! Callback for setting QoS values */ int (*qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc); /*! Callback for retrieving a file descriptor to poll on, not always required */ int (*fd)(struct ast_rtp_instance *instance, int rtcp); /*! Callback for initializing RED support */ int (*red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations); /*! Callback for buffering a frame using RED */ int (*red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame); /*! Callback for reading a frame from the RTP engine */ struct ast_frame *(*read)(struct ast_rtp_instance *instance, int rtcp); /*! Callback to locally bridge two RTP instances */ int (*local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1); /*! Callback to set the read format */ int (*set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format); /*! Callback to set the write format */ int (*set_write_format)(struct ast_rtp_instance *instance, struct ast_format *format); /*! Callback to make two instances compatible */ int (*make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1); /*! Callback to see if two instances are compatible with DTMF */ int (*dtmf_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1); /*! Callback to indicate that packets will now flow */ int (*activate)(struct ast_rtp_instance *instance); /*! Callback to request that the RTP engine send a STUN BIND request */ void (*stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username); /*! Callback to get the transcodeable formats supported. result returned in ast_format_cap *result */ void (*available_formats)(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result); /*! Callback to send CNG */ int (*sendcng)(struct ast_rtp_instance *instance, int level); /*! Callback to pointer for optional ICE support */ struct ast_rtp_engine_ice *ice; /*! Callback to pointer for optional DTLS SRTP support */ struct ast_rtp_engine_dtls *dtls; /*! Linked list information */ AST_RWLIST_ENTRY(ast_rtp_engine) entry; }; /*! Structure that represents codec and packetization information */ struct ast_rtp_codecs { /*! Payloads present */ struct ao2_container *payloads; /*! Codec packetization preferences */ struct ast_codec_pref pref; }; /*! Structure that represents the glue that binds an RTP instance to a channel */ struct ast_rtp_glue { /*! Name of the channel driver that this glue is responsible for */ const char *type; /*! Module that the RTP glue came from */ struct ast_module *mod; /*! * \brief Callback for retrieving the RTP instance carrying audio * \note This function increases the reference count on the returned RTP instance. */ enum ast_rtp_glue_result (*get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance); /*! * \brief Used to prevent two channels from remotely bridging audio rtp if the channel tech has a * reason for prohibiting it based on qualities that need to be compared from both channels. * \note This function should only be called with two channels of the same technology * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, function this is not used. */ int (*allow_rtp_remote)(struct ast_channel *chan1, struct ast_channel *chan2); /*! * \brief Callback for retrieving the RTP instance carrying video * \note This function increases the reference count on the returned RTP instance. */ enum ast_rtp_glue_result (*get_vrtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance); /*! * \brief Used to prevent two channels from remotely bridging video rtp if the channel tech has a * reason for prohibiting it based on qualities that need to be compared from both channels. * \note This function should only be called with two channels of the same technology * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, this function is not used. */ int (*allow_vrtp_remote)(struct ast_channel *chan1, struct ast_channel *chan2); /*! * \brief Callback for retrieving the RTP instance carrying text * \note This function increases the reference count on the returned RTP instance. */ enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance); /*! Callback for updating the destination that the remote side should send RTP to */ int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, const struct ast_format_cap *cap, int nat_active); /*! Callback for retrieving codecs that the channel can do. Result returned in result_cap*/ void (*get_codec)(struct ast_channel *chan, struct ast_format_cap *result_cap); /*! Linked list information */ AST_RWLIST_ENTRY(ast_rtp_glue) entry; }; #define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, ast_module_info->self) /*! * \brief Register an RTP engine * * \param engine Structure of the RTP engine to register * \param module Module that the RTP engine is part of * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_engine_register2(&example_rtp_engine, NULL); * \endcode * * This registers the RTP engine declared as example_rtp_engine with the RTP engine core, but does not * associate a module with it. * * \note It is recommended that you use the ast_rtp_engine_register macro so that the module is * associated with the RTP engine and use counting is performed. * * \since 1.8 */ int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module); /*! * \brief Unregister an RTP engine * * \param engine Structure of the RTP engine to unregister * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_engine_unregister(&example_rtp_engine); * \endcode * * This unregisters the RTP engine declared as example_rtp_engine from the RTP engine core. If a module * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use. * * \since 1.8 */ int ast_rtp_engine_unregister(struct ast_rtp_engine *engine); int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res); void ast_rtp_engine_unregister_srtp(void); int ast_rtp_engine_srtp_is_registered(void); #define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, ast_module_info->self) /*! * \brief Register RTP glue * * \param glue The glue to register * \param module Module that the RTP glue is part of * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_glue_register2(&example_rtp_glue, NULL); * \endcode * * This registers the RTP glue declared as example_rtp_glue with the RTP engine core, but does not * associate a module with it. * * \note It is recommended that you use the ast_rtp_glue_register macro so that the module is * associated with the RTP glue and use counting is performed. * * \since 1.8 */ int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module); /*! * \brief Unregister RTP glue * * \param glue The glue to unregister * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_glue_unregister(&example_rtp_glue); * \endcode * * This unregisters the RTP glue declared as example_rtp_gkue from the RTP engine core. If a module * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use. * * \since 1.8 */ int ast_rtp_glue_unregister(struct ast_rtp_glue *glue); /*! * \brief Create a new RTP instance * * \param engine_name Name of the engine to use for the RTP instance * \param sched Scheduler context that the RTP engine may want to use * \param sa Address we want to bind to * \param data Unique data for the engine * * \retval non-NULL success * \retval NULL failure * * Example usage: * * \code * struct ast_rtp_instance *instance = NULL; * instance = ast_rtp_instance_new(NULL, sched, &sin, NULL); * \endcode * * This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given * in the address structure. * * \note The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use * another depending on it's own configuration. * * \since 1.8 */ struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data); /*! * \brief Destroy an RTP instance * * \param instance The RTP instance to destroy * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_destroy(instance); * \endcode * * This destroys the RTP instance pointed to by instance. Once this function returns instance no longer points to valid * memory and may not be used again. * * \since 1.8 */ int ast_rtp_instance_destroy(struct ast_rtp_instance *instance); /*! * \brief Set the data portion of an RTP instance * * \param instance The RTP instance to manipulate * \param data Pointer to data * * Example usage: * * \code * ast_rtp_instance_set_data(instance, blob); * \endcode * * This sets the data pointer on the RTP instance pointed to by 'instance' to * blob. * * \since 1.8 */ void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data); /*! * \brief Get the data portion of an RTP instance * * \param instance The RTP instance we want the data portion from * * Example usage: * * \code * struct *blob = ast_rtp_instance_get_data(instance); ( \endcode * * This gets the data pointer on the RTP instance pointed to by 'instance'. * * \since 1.8 */ void *ast_rtp_instance_get_data(struct ast_rtp_instance *instance); /*! * \brief Send a frame out over RTP * * \param instance The RTP instance to send frame out on * \param frame the frame to send out * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_write(instance, frame); * \endcode * * This gives the frame pointed to by frame to the RTP engine being used for the instance * and asks that it be transmitted to the current remote address set on the RTP instance. * * \since 1.8 */ int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame); /*! * \brief Receive a frame over RTP * * \param instance The RTP instance to receive frame on * \param rtcp Whether to read in RTCP or not * * \retval non-NULL success * \retval NULL failure * * Example usage: * * \code * struct ast_frame *frame; * frame = ast_rtp_instance_read(instance, 0); * \endcode * * This asks the RTP engine to read in RTP from the instance and return it as an Asterisk frame. * * \since 1.8 */ struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp); /*! * \brief Set the address of the remote endpoint that we are sending RTP to * * \param instance The RTP instance to change the address on * \param address Address to set it to * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_set_remote_address(instance, &sin); * \endcode * * This changes the remote address that RTP will be sent to on instance to the address given in the sin * structure. * * \since 1.8 */ int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address); /*! * \brief Set the address of an an alternate RTP address to receive from * * \param instance The RTP instance to change the address on * \param address Address to set it to * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_set_alt_remote_address(instance, &address); * \endcode * * This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin * structure. * * \since 1.8 */ int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address); /*! * \brief Set the address that we are expecting to receive RTP on * * \param instance The RTP instance to change the address on * \param address Address to set it to * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_set_local_address(instance, &sin); * \endcode * * This changes the local address that RTP is expected on to the address given in the sin * structure. * * \since 1.8 */ int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address); /*! * \brief Get the local address that we are expecting RTP on * * \param instance The RTP instance to get the address from * \param address The variable to store the address in * * Example usage: * * \code * struct ast_sockaddr address; * ast_rtp_instance_get_local_address(instance, &address); * \endcode * * This gets the local address that we are expecting RTP on and stores it in the 'address' structure. * * \since 1.8 */ void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address); /*! * \brief Get the address of the local endpoint that we are sending RTP to, comparing its address to another * * \param instance The instance that we want to get the local address for * \param address An initialized address that may be overwritten if the local address is different * * \retval 0 address was not changed * \retval 1 address was changed * Example usage: * * \code * struct ast_sockaddr address; * int ret; * ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address); * \endcode * * This retrieves the current local address set on the instance pointed to by instance and puts the value * into the address structure. * * \since 1.8 */ int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address); /*! * \brief Get the address of the remote endpoint that we are sending RTP to * * \param instance The instance that we want to get the remote address for * \param address A structure to put the address into * * Example usage: * * \code * struct ast_sockaddr address; * ast_rtp_instance_get_remote_address(instance, &address); * \endcode * * This retrieves the current remote address set on the instance pointed to by instance and puts the value * into the address structure. * * \since 1.8 */ void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address); /*! * \brief Get the address of the remote endpoint that we are sending RTP to, comparing its address to another * * \param instance The instance that we want to get the remote address for * \param address An initialized address that may be overwritten if the remote address is different * * \retval 0 address was not changed * \retval 1 address was changed * Example usage: * * \code * struct ast_sockaddr address; * int ret; * ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address); * \endcode * * This retrieves the current remote address set on the instance pointed to by instance and puts the value * into the address structure. * * \since 1.8 */ int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address); /*! * \brief Set the value of an RTP instance extended property * * \param instance The RTP instance to set the extended property on * \param property The extended property to set * \param value The value to set the extended property to * * \since 1.8 */ void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value); /*! * \brief Get the value of an RTP instance extended property * * \param instance The RTP instance to get the extended property on * \param property The extended property to get * * \since 1.8 */ void *ast_rtp_instance_get_extended_prop(struct ast_rtp_instance *instance, int property); /*! * \brief Set the value of an RTP instance property * * \param instance The RTP instance to set the property on * \param property The property to modify * \param value The value to set the property to * * Example usage: * * \code * ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 1); * \endcode * * This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance. * * \since 1.8 */ void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value); /*! * \brief Get the value of an RTP instance property * * \param instance The RTP instance to get the property from * \param property The property to get * * \retval Current value of the property * * Example usage: * * \code * ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT); * \endcode * * This returns the current value of the NAT property on the instance pointed to by instance. * * \since 1.8 */ int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property); /*! * \brief Get the codecs structure of an RTP instance * * \param instance The RTP instance to get the codecs structure from * * Example usage: * * \code * struct ast_rtp_codecs *codecs = ast_rtp_instance_get_codecs(instance); * \endcode * * This gets the codecs structure on the RTP instance pointed to by 'instance'. * * \since 1.8 */ struct ast_rtp_codecs *ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance); /*! * \brief Initialize an RTP codecs structure * * \param codecs The codecs structure to initialize * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * struct ast_rtp_codecs codecs; * ast_rtp_codecs_payloads_initialize(&codecs); * \endcode * * \since 11 */ int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs); /*! * \brief Destroy the contents of an RTP codecs structure (but not the structure itself) * * \param codecs The codecs structure to destroy the contents of * * Example usage: * * \code * struct ast_rtp_codecs codecs; * ast_rtp_codecs_payloads_destroy(&codecs); * \endcode * * \since 11 */ void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs); /*! * \brief Clear payload information from an RTP instance * * \param codecs The codecs structure that payloads will be cleared from * \param instance Optionally the instance that the codecs structure belongs to * * Example usage: * * \code * struct ast_rtp_codecs codecs; * ast_rtp_codecs_payloads_clear(&codecs, NULL); * \endcode * * This clears the codecs structure and puts it into a pristine state. * * \since 1.8 */ void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance); /*! * \brief Set payload information on an RTP instance to the default * * \param codecs The codecs structure to set defaults on * \param instance Optionally the instance that the codecs structure belongs to * * Example usage: * * \code * struct ast_rtp_codecs codecs; * ast_rtp_codecs_payloads_default(&codecs, NULL); * \endcode * * This sets the default payloads on the codecs structure. * * \since 1.8 */ void ast_rtp_codecs_payloads_default(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance); /*! * \brief Copy payload information from one RTP instance to another * * \param src The source codecs structure * \param dest The destination codecs structure that the values from src will be copied to * \param instance Optionally the instance that the dst codecs structure belongs to * * Example usage: * * \code * ast_rtp_codecs_payloads_copy(&codecs0, &codecs1, NULL); * \endcode * * This copies the payloads from the codecs0 structure to the codecs1 structure, overwriting any current values. * * \since 1.8 */ void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance); /*! * \brief Record payload information that was seen in an m= SDP line * * \param codecs The codecs structure to muck with * \param instance Optionally the instance that the codecs structure belongs to * \param payload Numerical payload that was seen in the m= SDP line * * Example usage: * * \code * ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, 0); * \endcode * * This records that the numerical payload '0' was seen in the codecs structure. * * \since 1.8 */ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload); /*! * \brief Record payload information that was seen in an a=rtpmap: SDP line * * \param codecs The codecs structure to muck with * \param instance Optionally the instance that the codecs structure belongs to * \param payload Numerical payload that was seen in the a=rtpmap: SDP line * \param mimetype The string mime type that was seen * \param mimesubtype The strin mime sub type that was seen * \param options Optional options that may change the behavior of this specific payload * * \retval 0 success * \retval -1 failure, invalid payload numbe * \retval -2 failure, unknown mimetype * * Example usage: * * \code * ast_rtp_codecs_payloads_set_rtpmap_type(&codecs, NULL, 0, "audio", "PCMU", 0); * \endcode * * This records that the numerical payload '0' was seen with mime type 'audio' and sub mime type 'PCMU' in the codecs structure. * * \since 1.8 */ int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options); /*! * \brief Set payload type to a known MIME media type for a codec with a specific sample rate * * \param codecs RTP structure to modify * \param instance Optionally the instance that the codecs structure belongs to * \param pt Payload type entry to modify * \param mimetype top-level MIME type of media stream (typically "audio", "video", "text", etc.) * \param mimesubtype MIME subtype of media stream (typically a codec name) * \param options Zero or more flags from the ast_rtp_options enum * \param sample_rate The sample rate of the media stream * * This function 'fills in' an entry in the list of possible formats for * a media stream associated with an RTP structure. * * \retval 0 on success * \retval -1 if the payload type is out of range * \retval -2 if the mimeType/mimeSubtype combination was not found * * \since 1.8 */ int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int pt, char *mimetype, char *mimesubtype, enum ast_rtp_options options, unsigned int sample_rate); /*! * \brief Remove payload information * * \param codecs The codecs structure to muck with * \param instance Optionally the instance that the codecs structure belongs to * \param payload Numerical payload to unset * * Example usage: * * \code * ast_rtp_codecs_payloads_unset(&codecs, NULL, 0); * \endcode * * This clears the payload '0' from the codecs structure. It will be as if it was never set. * * \since 1.8 */ void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload); /*! * \brief Retrieve payload information by payload * * \param codecs Codecs structure to look in * \param payload Numerical payload to look up * * \retval Payload information * * Example usage: * * \code * struct ast_rtp_payload_type payload_type; * payload_type = ast_rtp_codecs_payload_lookup(&codecs, 0); * \endcode * * This looks up the information for payload '0' from the codecs structure. * * \since 1.8 */ struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs *codecs, int payload); /*! * \brief Retrieve the actual ast_format stored on the codecs structure for a specific payload * * \param codecs Codecs structure to look in * \param payload Numerical payload to look up * * \retval pointer to format structure on success * \retval NULL on failure * * \since 10.0 */ struct ast_format *ast_rtp_codecs_get_payload_format(struct ast_rtp_codecs *codecs, int payload); /*! * \brief Get the sample rate associated with known RTP payload types * * \param asterisk_format True if the value in format is to be used. * \param An asterisk format * \param code from AST_RTP list * * \return the sample rate if the format was found, zero if it was not found * * \since 1.8 */ unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, struct ast_format *format, int code); /*! * \brief Retrieve all formats that were found * * \param codecs Codecs structure to look in * \param astformats A capabilities structure to put the Asterisk formats in. * \param nonastformats An integer to put the non-Asterisk formats in * * Example usage: * * \code * struct ast_format_cap *astformats = ast_format_cap_alloc_nolock() * int nonastformats; * ast_rtp_codecs_payload_formats(&codecs, &astformats, &nonastformats); * \endcode * * This retrieves all the formats known about in the codecs structure and puts the Asterisk ones in the integer * pointed to by astformats and the non-Asterisk ones in the integer pointed to by nonastformats. * * \since 1.8 */ void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats); /*! * \brief Retrieve a payload based on whether it is an Asterisk format and the code * * \param codecs Codecs structure to look in * \param asterisk_format Non-zero if the given Asterisk format is present * \param format Asterisk format to look for * \param code The format to look for * * \retval Numerical payload * * Example usage: * * \code * int payload = ast_rtp_codecs_payload_code(&codecs, 1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0); * \endcode * * This looks for the numerical payload for ULAW in the codecs structure. * * \since 1.8 */ int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code); /*! * \brief Search for a payload code in the ast_rtp_codecs structure * * \param codecs Codecs structure to look in * \param code The format to look for * * \retval Numerical payload or -1 if unable to find payload in codecs * * Example usage: * * \code * int payload = ast_rtp_codecs_payload_code(&codecs, 0); * \endcode * * This looks for the numerical payload for ULAW in the codecs structure. * */ int ast_rtp_codecs_find_payload_code(struct ast_rtp_codecs *codecs, int code); /*! * \brief Retrieve mime subtype information on a payload * * \param asterisk_format Non-zero to look up using Asterisk format * \param format Asterisk format to look up * \param code RTP code to look up * \param options Additional options that may change the result * * \retval Mime subtype success * \retval NULL failure * * Example usage: * * \code * const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0, 0); * \endcode * * This looks up the mime subtype for the ULAW format. * * \since 1.8 */ const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, struct ast_format *format, int code, enum ast_rtp_options options); /*! * \brief Convert formats into a string and put them into a buffer * * \param buf Buffer to put the mime output into * \param ast_format_capability Asterisk Formats we are looking up. * \param rtp_capability RTP codes that we are looking up * \param asterisk_format Non-zero if the ast_format_capability structure is to be used, 0 if rtp_capability is to be used * \param options Additional options that may change the result * * \retval non-NULL success * \retval NULL failure * * Example usage: * * \code * char buf[256] = ""; * struct ast_format tmp_fmt; * struct ast_format_cap *cap = ast_format_cap_alloc_nolock(); * ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0)); * ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0)); * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0); * ast_format_cap_destroy(cap); * \endcode * * This returns the mime values for ULAW and ALAW in the buffer pointed to by buf. * * \since 1.8 */ char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, struct ast_format_cap *ast_format_capability, int rtp_capability, const int asterisk_format, enum ast_rtp_options options); /*! * \brief Set codec packetization preferences * * \param codecs Codecs structure to muck with * \param instance Optionally the instance that the codecs structure belongs to * \param prefs Codec packetization preferences * * Example usage: * * \code * ast_rtp_codecs_packetization_set(&codecs, NULL, &prefs); * \endcode * * This sets the packetization preferences pointed to by prefs on the codecs structure pointed to by codecs. * * \since 1.8 */ void ast_rtp_codecs_packetization_set(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, struct ast_codec_pref *prefs); /*! * \brief Begin sending a DTMF digit * * \param instance The RTP instance to send the DTMF on * \param digit What DTMF digit to send * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_dtmf_begin(instance, '1'); * \endcode * * This starts sending the DTMF '1' on the RTP instance pointed to by instance. It will * continue being sent until it is ended. * * \since 1.8 */ int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit); /*! * \brief Stop sending a DTMF digit * * \param instance The RTP instance to stop the DTMF on * \param digit What DTMF digit to stop * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_dtmf_end(instance, '1'); * \endcode * * This stops sending the DTMF '1' on the RTP instance pointed to by instance. * * \since 1.8 */ int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit); int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration); /*! * \brief Set the DTMF mode that should be used * * \param instance the RTP instance to set DTMF mode on * \param dtmf_mode The DTMF mode that is in use * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_dtmf_mode_set(instance, AST_RTP_DTMF_MODE_RFC2833); * \endcode * * This sets the RTP instance to use RFC2833 for DTMF transmission and receiving. * * \since 1.8 */ int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode); /*! * \brief Get the DTMF mode of an RTP instance * * \param instance The RTP instance to get the DTMF mode of * * \retval DTMF mode * * Example usage: * * \code * enum ast_rtp_dtmf_mode dtmf_mode = ast_rtp_instance_dtmf_mode_get(instance); * \endcode * * This gets the DTMF mode set on the RTP instance pointed to by 'instance'. * * \since 1.8 */ enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance); /*! * \brief Indicate that the RTP marker bit should be set on an RTP stream * * \param instance Instance that the new media source is feeding into * * Example usage: * * \code * ast_rtp_instance_update_source(instance); * \endcode * * This indicates that the source of media that is feeding the instance pointed to by * instance has been updated and that the marker bit should be set. * * \since 1.8 */ void ast_rtp_instance_update_source(struct ast_rtp_instance *instance); /*! * \brief Indicate a new source of audio has dropped in and the ssrc should change * * \param instance Instance that the new media source is feeding into * * Example usage: * * \code * ast_rtp_instance_change_source(instance); * \endcode * * This indicates that the source of media that is feeding the instance pointed to by * instance has changed and that the marker bit should be set and the SSRC updated. * * \since 1.8 */ void ast_rtp_instance_change_source(struct ast_rtp_instance *instance); /*! * \brief Set QoS parameters on an RTP session * * \param instance Instance to set the QoS parameters on * \param tos Terms of service value * \param cos Class of service value * \param desc What is setting the QoS values * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_set_qos(instance, 0, 0, "Example"); * \endcode * * This sets the TOS and COS values to 0 on the instance pointed to by instance. * * \since 1.8 */ int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc); /*! * \brief Stop an RTP instance * * \param instance Instance that media is no longer going to at this time * * Example usage: * * \code * ast_rtp_instance_stop(instance); * \endcode * * This tells the RTP engine being used for the instance pointed to by instance * that media is no longer going to it at this time, but may in the future. * * \since 1.8 */ void ast_rtp_instance_stop(struct ast_rtp_instance *instance); /*! * \brief Get the file descriptor for an RTP session (or RTCP) * * \param instance Instance to get the file descriptor for * \param rtcp Whether to retrieve the file descriptor for RTCP or not * * \retval fd success * \retval -1 failure * * Example usage: * * \code * int rtp_fd = ast_rtp_instance_fd(instance, 0); * \endcode * * This retrieves the file descriptor for the socket carrying media on the instance * pointed to by instance. * * \since 1.8 */ int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp); /*! * \brief Get the RTP glue that binds a channel to the RTP engine * * \param type Name of the glue we want * * \retval non-NULL success * \retval NULL failure * * Example usage: * * \code * struct ast_rtp_glue *glue = ast_rtp_instance_get_glue("Example"); * \endcode * * This retrieves the RTP glue that has the name 'Example'. * * \since 1.8 */ struct ast_rtp_glue *ast_rtp_instance_get_glue(const char *type); /*! * \brief Bridge two channels that use RTP instances * * \param c0 First channel part of the bridge * \param c1 Second channel part of the bridge * \param flags Bridging flags * \param fo If a frame needs to be passed up it is stored here * \param rc Channel that passed the above frame up * \param timeoutms How long the channels should be bridged for * * \retval Bridge result * * \note This should only be used by channel drivers in their technology declaration. * * \since 1.8 */ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms); /*! * \brief Get the other RTP instance that an instance is bridged to * * \param instance The RTP instance that we want * * \retval non-NULL success * \retval NULL failure * * Example usage: * * \code * struct ast_rtp_instance *bridged = ast_rtp_instance_get_bridged(instance0); * \endcode * * This gets the RTP instance that instance0 is bridged to. * * \since 1.8 */ struct ast_rtp_instance *ast_rtp_instance_get_bridged(struct ast_rtp_instance *instance); /*! * \brief Make two channels compatible for early bridging * * \param c_dst Destination channel to copy to * \param c_src Source channel to copy from * * \since 1.8 */ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src); /*! * \brief Early bridge two channels that use RTP instances * * \param c0 First channel part of the bridge * \param c1 Second channel part of the bridge * * \retval 0 success * \retval -1 failure * * \note This should only be used by channel drivers in their technology declaration. * * \since 1.8 */ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1); /*! * \brief Initialize RED support on an RTP instance * * \param instance The instance to initialize RED support on * \param buffer_time How long to buffer before sending * \param payloads Payload values * \param generations Number of generations * * \retval 0 success * \retval -1 failure * * \since 1.8 */ int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations); /*! * \brief Buffer a frame in an RTP instance for RED * * \param instance The instance to buffer the frame on * \param frame Frame that we want to buffer * * \retval 0 success * \retval -1 failure * * \since 1.8 */ int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame); /*! * \brief Retrieve statistics about an RTP instance * * \param instance Instance to get statistics on * \param stats Structure to put results into * \param stat What statistic(s) to retrieve * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * struct ast_rtp_instance_stats stats; * ast_rtp_instance_get_stats(instance, &stats, AST_RTP_INSTANCE_STAT_ALL); * \endcode * * This retrieves all statistics the underlying RTP engine supports and puts the values into the * stats structure. * * \since 1.8 */ int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat); /*! * \brief Set standard statistics from an RTP instance on a channel * * \param chan Channel to set the statistics on * \param instance The RTP instance that statistics will be retrieved from * * Example usage: * * \code * ast_rtp_instance_set_stats_vars(chan, rtp); * \endcode * * This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to * by chan. * * \since 1.8 */ void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance); /*! * \brief Retrieve quality statistics about an RTP instance * * \param instance Instance to get statistics on * \param field What quality statistic to retrieve * \param buf What buffer to put the result into * \param size Size of the above buffer * * \retval non-NULL success * \retval NULL failure * * Example usage: * * \code * char quality[AST_MAX_USER_FIELD]; * ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, &buf, sizeof(buf)); * \endcode * * This retrieves general quality statistics and places a text representation into the buf pointed to by buf. * * \since 1.8 */ char *ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size); /*! * \brief Request that the underlying RTP engine provide audio frames in a specific format * * \param instance The RTP instance to change read format on * \param format Format that frames are wanted in * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * struct ast_format tmp_fmt; * ast_rtp_instance_set_read_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0)); * \endcode * * This requests that the RTP engine provide audio frames in the ULAW format. * * \since 1.8 */ int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format); /*! * \brief Tell underlying RTP engine that audio frames will be provided in a specific format * * \param instance The RTP instance to change write format on * \param format Format that frames will be provided in * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * struct ast_format tmp_fmt; * ast_rtp_instance_set_write_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0)); * \endcode * * This tells the underlying RTP engine that audio frames will be provided to it in ULAW format. * * \since 1.8 */ int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, struct ast_format *format); /*! * \brief Request that the underlying RTP engine make two RTP instances compatible with eachother * * \param chan Our own Asterisk channel * \param instance The first RTP instance * \param peer The peer Asterisk channel * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_make_compatible(instance, peer); * \endcode * * This makes the RTP instance for 'peer' compatible with 'instance' and vice versa. * * \since 1.8 */ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer); /*! \brief Request the formats that can be transcoded * * \param instance The RTP instance * \param to_endpoint Formats being sent/received towards the endpoint * \param to_asterisk Formats being sent/received towards Asterisk * \param result capabilities structure to store and return supported formats in. * * Example usage: * * \code * ast_rtp_instance_available_formats(instance, to_capabilities, from_capabilities, result_capabilities); * \endcode * * This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk. * * \since 1.8 */ void ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result); /*! * \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance * * \param instance The RTP instance * * \retval 0 success * \retval -1 failure * * Example usage: * * \code * ast_rtp_instance_activate(instance); * \endcode * * This tells the underlying RTP engine of instance that packets will now flow. * * \since 1.8 */ int ast_rtp_instance_activate(struct ast_rtp_instance *instance); /*! * \brief Request that the underlying RTP engine send a STUN BIND request * * \param instance The RTP instance * \param suggestion The suggested destination * \param username Optionally a username for the request * * Example usage: * * \code * ast_rtp_instance_stun_request(instance, NULL, NULL); * \endcode * * This requests that the RTP engine send a STUN BIND request on the session pointed to by * 'instance'. * * \since 1.8 */ void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username); /*! * \brief Set the RTP timeout value * * \param instance The RTP instance * \param timeout Value to set the timeout to * * Example usage: * * \code * ast_rtp_instance_set_timeout(instance, 5000); * \endcode * * This sets the RTP timeout value on 'instance' to be 5000. * * \since 1.8 */ void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout); /*! * \brief Set the RTP timeout value for when the instance is on hold * * \param instance The RTP instance * \param timeout Value to set the timeout to * * Example usage: * * \code * ast_rtp_instance_set_hold_timeout(instance, 5000); * \endcode * * This sets the RTP hold timeout value on 'instance' to be 5000. * * \since 1.8 */ void ast_rtp_instance_set_hold_timeout(struct ast_rtp_instance *instance, int timeout); /*! * \brief Set the RTP keepalive interval * * \param instance The RTP instance * \param period Value to set the keepalive interval to * * Example usage: * * \code * ast_rtp_instance_set_keepalive(instance, 5000); * \endcode * * This sets the RTP keepalive interval on 'instance' to be 5000. * * \since 1.8 */ void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout); /*! * \brief Get the RTP timeout value * * \param instance The RTP instance * * \retval timeout value * * Example usage: * * \code * int timeout = ast_rtp_instance_get_timeout(instance); * \endcode * * This gets the RTP timeout value for the RTP instance pointed to by 'instance'. * * \since 1.8 */ int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance); /*! * \brief Get the RTP timeout value for when an RTP instance is on hold * * \param instance The RTP instance * * \retval timeout value * * Example usage: * * \code * int timeout = ast_rtp_instance_get_hold_timeout(instance); * \endcode * * This gets the RTP hold timeout value for the RTP instance pointed to by 'instance'. * * \since 1.8 */ int ast_rtp_instance_get_hold_timeout(struct ast_rtp_instance *instance); /*! * \brief Get the RTP keepalive interval * * \param instance The RTP instance * * \retval period Keepalive interval value * * Example usage: * * \code * int interval = ast_rtp_instance_get_keepalive(instance); * \endcode * * This gets the RTP keepalive interval value for the RTP instance pointed to by 'instance'. * * \since 1.8 */ int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance); /*! * \brief Get the RTP engine in use on an RTP instance * * \param instance The RTP instance * * \retval pointer to the engine * * Example usage: * * \code * struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance); * \endcode * * This gets the RTP engine currently in use on the RTP instance pointed to by 'instance'. * * \since 1.8 */ struct ast_rtp_engine *ast_rtp_instance_get_engine(struct ast_rtp_instance *instance); /*! * \brief Get the RTP glue in use on an RTP instance * * \param instance The RTP instance * * \retval pointer to the glue * * Example: * * \code * struct ast_rtp_glue *glue = ast_rtp_instance_get_active_glue(instance); * \endcode * * This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'. * * \since 1.8 */ struct ast_rtp_glue *ast_rtp_instance_get_active_glue(struct ast_rtp_instance *instance); /*! * \brief Get the channel that is associated with an RTP instance while in a bridge * * \param instance The RTP instance * * \retval pointer to the channel * * Example: * * \code * struct ast_channel *chan = ast_rtp_instance_get_chan(instance); * \endcode * * This gets the channel associated with the RTP instance pointed to by 'instance'. * * \note This will only return a channel while in a local or remote bridge. * * \since 1.8 */ struct ast_channel *ast_rtp_instance_get_chan(struct ast_rtp_instance *instance); /*! * \brief Send a comfort noise packet to the RTP instance * * \param instance The RTP instance * \param level Magnitude of the noise level * * \retval 0 Success * \retval non-zero Failure */ int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level); /*! * \brief Add or replace the SRTP policies for the given RTP instance * * \param instance the RTP instance * \param remote_policy the remote endpoint's policy * \param local_policy our policy for this RTP instance's remote endpoint * * \retval 0 Success * \retval non-zero Failure */ int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy* remote_policy, struct ast_srtp_policy *local_policy); /*! * \brief Obtain the SRTP instance associated with an RTP instance * * \param instance the RTP instance * \retval the SRTP instance on success * \retval NULL if no SRTP instance exists */ struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance); /*! \brief Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine * so their mime type can payload number can be initialized. */ int ast_rtp_engine_load_format(const struct ast_format *format); /*! \brief Formats requiring the use of a format attribute interface must have that * interface registered in order for the rtp engine to handle it correctly. If an * attribute interface is unloaded, this function must be called to notify the rtp_engine. */ int ast_rtp_engine_unload_format(const struct ast_format *format); /*! * \brief Obtain a pointer to the ICE support present on an RTP instance * * \param instance the RTP instance * * \retval ICE support if present * \retval NULL if no ICE support available */ struct ast_rtp_engine_ice *ast_rtp_instance_get_ice(struct ast_rtp_instance *instance); /*! * \brief Obtain a pointer to the DTLS support present on an RTP instance * * \param instance the RTP instance * * \retval DTLS support if present * \retval NULL if no DTLS support available */ struct ast_rtp_engine_dtls *ast_rtp_instance_get_dtls(struct ast_rtp_instance *instance); /*! * \brief Parse DTLS related configuration options * * \param dtls_cfg a DTLS configuration structure * \param name name of the configuration option * \param value value of the configuration option * * \retval 0 if handled * \retval -1 if not handled */ int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value); /*! * \brief Copy contents of a DTLS configuration structure * * \param src_cfg source DTLS configuration structure * \param dst_cfg destination DTLS configuration structure */ void ast_rtp_dtls_cfg_copy(const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg); /*! * \brief Free contents of a DTLS configuration structure * * \param dtls_cfg a DTLS configuration structure */ void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_RTP_ENGINE_H */ asterisk-11.7.0/include/asterisk/inline_api.h0000644000175000007640000000420010374426007021074 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Kevin P. Fleming * * 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. */ #ifndef __ASTERISK_INLINEAPI_H #define __ASTERISK_INLINEAPI_H /*! \file * \brief Inlinable API function macro Small API functions that are candidates for inlining need to be specially declared and defined, to ensure that the 'right thing' always happens. For example: - there must _always_ be a non-inlined version of the function available for modules compiled out of the tree to link to - references to a function that cannot be inlined (for any reason that the compiler deems proper) must devolve into an 'extern' reference, instead of 'static', so that multiple copies of the function body are not built in different modules - when LOW_MEMORY is defined, inlining should be disabled completely, even if the compiler is configured to support it The AST_INLINE_API macro allows this to happen automatically, when used to define your function. Proper usage is as follows: - define your function one place, in a header file, using the macro to wrap the function (see strings.h or time.h for examples) - choose a module to 'host' the function body for non-inline usages, and in that module _only_, define AST_API_MODULE before including the header file */ #if !defined(LOW_MEMORY) #if !defined(AST_API_MODULE) #define AST_INLINE_API(hdr, body) hdr; extern inline hdr body #else #define AST_INLINE_API(hdr, body) hdr; hdr body #endif #else /* defined(LOW_MEMORY) */ #if !defined(AST_API_MODULE) #define AST_INLINE_API(hdr, body) hdr; #else #define AST_INLINE_API(hdr, body) hdr; hdr body #endif #endif #undef AST_API_MODULE #endif /* __ASTERISK_INLINEAPI_H */ asterisk-11.7.0/include/asterisk/features.h0000644000175000007640000002124612046257025020614 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Call Parking and Pickup API * Includes code and algorithms from the Zapata library. */ #ifndef _AST_FEATURES_H #define _AST_FEATURES_H #include "asterisk/pbx.h" #include "asterisk/linkedlists.h" #define FEATURE_MAX_LEN 11 #define FEATURE_APP_LEN 64 #define FEATURE_APP_ARGS_LEN 256 #define FEATURE_SNAME_LEN 32 #define FEATURE_EXTEN_LEN 32 #define FEATURE_MOH_LEN 80 /* same as MAX_MUSICCLASS from channel.h */ #define DEFAULT_PARKINGLOT "default" /*!< Default parking lot */ #define AST_FEATURE_RETURN_HANGUP -1 #define AST_FEATURE_RETURN_SUCCESSBREAK 0 #define AST_FEATURE_RETURN_PBX_KEEPALIVE AST_PBX_KEEPALIVE #define AST_FEATURE_RETURN_NO_HANGUP_PEER AST_PBX_NO_HANGUP_PEER #define AST_FEATURE_RETURN_PASSDIGITS 21 #define AST_FEATURE_RETURN_STOREDIGITS 22 #define AST_FEATURE_RETURN_SUCCESS 23 #define AST_FEATURE_RETURN_KEEPTRYING 24 #define AST_FEATURE_RETURN_PARKFAILED 25 #define FEATURE_SENSE_CHAN (1 << 0) #define FEATURE_SENSE_PEER (1 << 1) typedef int (*ast_feature_operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, const char *code, int sense, void *data); /*! \brief main call feature structure */ enum { AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0), AST_FEATURE_FLAG_ONPEER = (1 << 1), AST_FEATURE_FLAG_ONSELF = (1 << 2), AST_FEATURE_FLAG_BYCALLEE = (1 << 3), AST_FEATURE_FLAG_BYCALLER = (1 << 4), AST_FEATURE_FLAG_BYBOTH = (3 << 3), }; struct ast_call_feature { int feature_mask; char *fname; char sname[FEATURE_SNAME_LEN]; char exten[FEATURE_MAX_LEN]; char default_exten[FEATURE_MAX_LEN]; ast_feature_operation operation; unsigned int flags; char app[FEATURE_APP_LEN]; char app_args[FEATURE_APP_ARGS_LEN]; char moh_class[FEATURE_MOH_LEN]; AST_LIST_ENTRY(ast_call_feature) feature_entry; }; /*! * \brief Park a call and read back parked location * * \param park_me Channel to be parked. * \param parker Channel parking the call. * \param timeout is a timeout in milliseconds * \param park_exten Parking lot access extension (Not used) * \param extout is a parameter to an int that will hold the parked location, or NULL if you want. * * \details * Park the park_me channel, and read back the parked location * to the parker channel. If the call is not picked up within a * specified period of time, then the call will return to the * last step that it was in (in terms of exten, priority and * context). * * \note Use ast_park_call_exten() instead. * * \retval 0 on success. * \retval -1 on failure. */ int ast_park_call(struct ast_channel *park_me, struct ast_channel *parker, int timeout, const char *park_exten, int *extout); /*! * \brief Park a call and read back parked location * \since 1.8.9 * * \param park_me Channel to be parked. * \param parker Channel parking the call. * \param park_exten Parking lot access extension * \param park_context Parking lot context * \param timeout is a timeout in milliseconds * \param extout is a parameter to an int that will hold the parked location, or NULL if you want. * * \details * Park the park_me channel, and read back the parked location * to the parker channel. If the call is not picked up within a * specified period of time, then the call will return to the * last step that it was in (in terms of exten, priority and * context). * * \retval 0 on success. * \retval -1 on failure. */ int ast_park_call_exten(struct ast_channel *park_me, struct ast_channel *parker, const char *park_exten, const char *park_context, int timeout, int *extout); /*! * \brief Park a call via a masqueraded channel * * \param park_me Channel to be parked. * \param parker Channel parking the call. * \param timeout is a timeout in milliseconds * \param extout is a parameter to an int that will hold the parked location, or NULL if you want. * * \details * Masquerade the park_me channel into a new, empty channel which is then parked. * * \note Use ast_masq_park_call_exten() instead. * * \retval 0 on success. * \retval -1 on failure. */ int ast_masq_park_call(struct ast_channel *park_me, struct ast_channel *parker, int timeout, int *extout); /*! * \brief Park a call via a masqueraded channel * \since 1.8.9 * * \param park_me Channel to be parked. * \param parker Channel parking the call. * \param park_exten Parking lot access extension * \param park_context Parking lot context * \param timeout is a timeout in milliseconds * \param extout is a parameter to an int that will hold the parked location, or NULL if you want. * * \details * Masquerade the park_me channel into a new, empty channel which is then parked. * * \retval 0 on success. * \retval -1 on failure. */ int ast_masq_park_call_exten(struct ast_channel *park_me, struct ast_channel *parker, const char *park_exten, const char *park_context, int timeout, int *extout); /*! * \brief Determine if parking extension exists in a given context * \retval 0 if extension does not exist * \retval 1 if extension does exist */ int ast_parking_ext_valid(const char *exten_str, struct ast_channel *chan, const char *context); /*! \brief Determine system call pickup extension */ const char *ast_pickup_ext(void); /*! * \brief Simulate a DTMF end on a broken bridge channel. * * \param chan Channel sending DTMF that has not ended. * \param digit DTMF digit to stop. * \param start DTMF digit start time. * \param why Reason bridge broken. * * \return Nothing */ void ast_bridge_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why); /*! \brief Bridge a call, optionally allowing redirection */ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct ast_bridge_config *config); /*! * \brief Test if a channel can be picked up. * * \param chan Channel to test if can be picked up. * * \note This function assumes that chan is locked. * * \return TRUE if channel can be picked up. */ int ast_can_pickup(struct ast_channel *chan); /*! * \brief Find a pickup channel target by group. * * \param chan channel that initiated pickup. * * \retval target on success. The returned channel is locked and reffed. * \retval NULL on error. */ struct ast_channel *ast_pickup_find_by_group(struct ast_channel *chan); /*! \brief Pickup a call */ int ast_pickup_call(struct ast_channel *chan); /*! * \brief Pickup a call target. * * \param chan channel that initiated pickup. * \param target channel to be picked up. * * \note This function assumes that target is locked. * * \retval 0 on success. * \retval -1 on failure. */ int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target); /*! * \brief register new feature into feature_set * \param feature an ast_call_feature object which contains a keysequence * and a callback function which is called when this keysequence is pressed * during a call. */ void ast_register_feature(struct ast_call_feature *feature); /*! * \brief unregister feature from feature_set * \param feature the ast_call_feature object which was registered before */ void ast_unregister_feature(struct ast_call_feature *feature); /*! * \brief detect a feature before bridging * \param chan * \param features an ast_flags ptr * \param code ptr of input code * \param feature * \retval ast_call_feature ptr to be set if found */ int ast_feature_detect(struct ast_channel *chan, struct ast_flags *features, const char *code, struct ast_call_feature *feature); /*! * \brief look for a call feature entry by its sname * \param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. */ struct ast_call_feature *ast_find_call_feature(const char *name); void ast_rdlock_call_features(void); void ast_unlock_call_features(void); /*! \brief Reload call features from features.conf */ int ast_features_reload(void); /*! * \brief parse L option and read associated channel variables to set warning, warning frequency, and timelimit * \note caller must be aware of freeing memory for warning_sound, end_sound, and start_sound */ int ast_bridge_timelimit(struct ast_channel *chan, struct ast_bridge_config *config, char *parse, struct timeval *calldurationlimit); #endif /* _AST_FEATURES_H */ asterisk-11.7.0/include/asterisk/adsi.h0000644000175000007640000003544411772104755017731 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 ADSI Support (built upon Caller*ID) */ #ifndef _ASTERISK_ADSI_H #define _ASTERISK_ADSI_H #include "asterisk/callerid.h" /*! \name ADSI parameters */ /*@{ */ /* ADSI Message types */ #define ADSI_MSG_DISPLAY 132 #define ADSI_MSG_DOWNLOAD 133 /* ADSI Parameters (display) */ #define ADSI_LOAD_SOFTKEY 128 #define ADSI_INIT_SOFTKEY_LINE 129 #define ADSI_LOAD_VIRTUAL_DISP 130 #define ADSI_LINE_CONTROL 131 #define ADSI_INFORMATION 132 #define ADSI_DISC_SESSION 133 #define ADSI_SWITCH_TO_DATA 134 #define ADSI_SWITCH_TO_VOICE 135 #define ADSI_CLEAR_SOFTKEY 136 #define ADSI_INPUT_CONTROL 137 #define ADSI_INPUT_FORMAT 138 #define ADSI_SWITCH_TO_PERIPH 139 #define ADSI_MOVE_DATA 140 #define ADSI_LOAD_DEFAULT 141 #define ADSI_CONNECT_SESSION 142 #define ADSI_CLEAR_TYPE_AHEAD 143 #define ADSI_DISPLAY_CALL_BUF 144 #define ADSI_CLEAR_CALL_BUF 145 #define ADSI_SWITCH_TO_ALT 146 #define ADSI_SWITCH_TO_GRAPHICS 147 #define ADSI_CLEAR_SCREEN 148 #define ADSI_QUERY_CONFIG 149 #define ADSI_QUERY_CPEID 150 #define ADSI_SWITCH_TO_APP 151 /* Feature download messages */ #define ADSI_LOAD_SOFTKEY_TABLE 128 /* Conveniently identical to the soft version */ #define ADSI_LOAD_PREDEF_DISP 129 /* Load predefined display */ #define ADSI_LOAD_SCRIPT 130 #define ADSI_DOWNLOAD_CONNECT 131 #define ADSI_DOWNLOAD_DISC 132 /* Special return string codes */ #define ADSI_ENCODED_DTMF 0x80 /* Transmit following chars with encoded dtmf */ #define ADSI_ON_HOOK 0x81 /* Open switch-hook */ #define ADSI_OFF_HOOK 0x82 /* Close switch-hook */ #define ADSI_FLASH 0x83 /* Flash switch-hook */ #define ADSI_DIAL_TONE_DETECT 0x84 /* Wait for dialtone */ #define ADSI_LINE_NUMBER 0x85 /* Send current line number using DTMF/encoded DTMF */ #define ADSI_BLANK 0x86 /* Blank (does nothing) */ #define ADSI_SEND_CHARS 0x87 /* Send collected digits/characters */ #define ADSI_CLEAR_CHARS 0x88 /* Clear characters/digits collected */ #define ADSI_BACKSPACE 0x89 /* Erase last collected digit */ #define ADSI_TAB_COLUMN 0x8A /* Display specified display column of current line */ #define ADSI_GOTO_LINE 0x8B /* Go to given page and line number */ #define ADSI_GOTO_LINE_REL 0x8C /* Go to given line (relative to current) */ #define ADSI_PAGE_UP 0x8D /* Go up one page */ #define ADSI_PAGE_DOWN 0x8E /* Go down one page */ #define ADSI_EXTENDED_DTMF 0x8F /* Send DTMF tones for 250ms instead of 60 ms */ #define ADSI_DELAY 0x90 /* Delay for given # (times 10) of ms */ #define ADSI_DIAL_PULSE_ONE 0x91 /* Send a dial pulse "1" */ #define ADSI_SWITCH_TO_DATA2 0x92 /* Switch CPE to data mode */ #define ADSI_SWITCH_TO_VOICE2 0x93 /* Switch CPE to voice mode */ #define ADSI_DISP_CALL_BUF 0x94 /* Display specified call buffer */ #define ADSI_CLEAR_CALL_B 0x95 /* Clear specified call buffer */ #ifdef __ADSI_CPE /* These messages are reserved for the ADSI CPE only */ #define ADSI_DISPLAY_CONTROL 0x98 /* Store predefined display identified next / Display status display page */ #define ADSI_DISPLAY_SOFT_KEYS 0x99 /* Display the script soft keys identified next */ #define ADSI_CHANGE_STATE 0x9A /* Change state of service script */ #define ADSI_START_CLEAR_TIMER 0x9B /* Start / Clear timer */ #define ADSI_SET_SCRIPT_FLAG 0x9C /* Set / clear a script flag */ #define ADSI_JUMP_TO_SUBSCRIPT 0x9D /* Jump to specified subscript */ #define ADSI_EVENT_22_TRIGGER 0x9E /* Trigger an occurance of event 22 */ #define ADSI_EVENT_23_TRIGGER 0x9f /* Trigger an occurance of event 23 */ #define ADSI_EXIT 0xA0 /* Exit the service script interpreter */ #endif /* Display pages */ #define ADSI_INFO_PAGE 0x0 #define ADSI_COMM_PAGE 0x1 #define ADSI_KEY_APPS 16 /* 16 to 33 reserved for applications */ /* Justification */ #define ADSI_JUST_LEFT 0x2 #define ADSI_JUST_RIGHT 0x1 #define ADSI_JUST_CENT 0x0 /* Center */ #define ADSI_JUST_IND 0x3 /* Indent */ #define ADSI_KEY_SKT 0x80 /* Load from SKT */ #define ADSI_KEY_HILITE 0x40 /* Highlight key */ #define ADSI_DIR_FROM_LEFT (0) #define ADSI_DIR_FROM_RIGHT (1) #define AST_ADSI_VERSION 1 /*@} */ int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version); int ast_adsi_end_download(struct ast_channel *chan); /*! Restore ADSI initialization (for applications that play with ADSI * and want to restore it to normal. If you touch "INFO" then you * have to use the ast_adsi_channel_init again instead. * \param chan Channel to restore * * \retval 0 on success (or adsi unavailable) * \retval -1 on hangup */ int ast_adsi_channel_restore(struct ast_channel *chan); /*! * \brief Display some stuff on the screen * \param chan Channel to display on * \param lines NULL-terminated list of things to print (no more than 4 recommended) * \param align list of alignments to use (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CEN, etc..) * \param voice whether to jump into voice mode when finished * * \retval 0 on success (or adsi unavailable) * \retval -1 on hangup */ int ast_adsi_print(struct ast_channel *chan, char **lines, int *align, int voice); /*! * \brief Check if scripts for a given app are already loaded. * Version may be -1, if any version is okay, or 0-255 for a specific version. * \param chan Channel to test for loaded app * \param app Four character app name (must be unique to your application) * \param ver optional version number * \param data Non-zero if you want to be put in data mode * * \retval 0 if scripts is not loaded or not an ADSI CPE * \retval -1 on hangup * \retval 1 if script already loaded. */ int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data); int ast_adsi_unload_session(struct ast_channel *chan); /* ADSI Layer 2 transmission functions */ int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype); int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait); /*! Read some encoded DTMF data. * Returns number of bytes received */ int ast_adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen); /* ADSI Layer 3 creation functions */ /*! * \brief Connects an ADSI Display Session * \param buf Character buffer to create parameter in (must have at least 256 free) * \param fdn Optional 4 byte Feature Download Number (for loading soft keys) * \param ver Optional version number (0-255, or -1 to omit) * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver); /*! Build Query CPE ID of equipment. * Returns number of bytes added to message */ int ast_adsi_query_cpeid(unsigned char *buf); int ast_adsi_query_cpeinfo(unsigned char *buf); /*! Get CPE ID from an attached ADSI compatible CPE. * Returns 1 on success, storing 4 bytes of CPE ID at buf * or -1 on hangup, or 0 if there was no hangup but it failed to find the * device ID. Returns to voice mode if "voice" is non-zero. */ int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice); int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice); /*! * \brief Begin an ADSI script download * \param buf Character buffer to create parameter in (must have at least 256 free) * \param service a 1-18 byte name of the feature * \param fdn 4 byte Feature Download Number (for loading soft keys) * \param sec 4 byte vendor security code * \param ver version number (0-255, or -1 to omit) * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver); /*! * \brief Disconnects a running session. * \param buf Character buffer to create parameter in (must have at least 256 free) * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_disconnect_session(unsigned char *buf); /*! * \brief Disconnects (and hopefully saves) a downloaded script * \param buf Character buffer to create parameter in (must have at least 256 free) * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_download_disconnect(unsigned char *buf); /*! * \brief Puts CPE in data mode. * \param buf Character buffer to create parameter in (must have at least 256 free) * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_data_mode(unsigned char *buf); int ast_adsi_clear_soft_keys(unsigned char *buf); int ast_adsi_clear_screen(unsigned char *buf); /*! * \brief Puts CPE in voice mode. * \param buf Character buffer to create parameter in (must have at least 256 free) * \param when (a time in seconds) to make the switch * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_voice_mode(unsigned char *buf, int when); /*! * \brief Returns non-zero if Channel does or might support ADSI * \param chan Channel to check */ int ast_adsi_available(struct ast_channel *chan); /*! * \brief Loads a line of info into the display. * \param buf Character buffer to create parameter in (must have at least 256 free) * \param page Page to load (ADSI_COMM_PAGE or ADSI_INFO_PAGE) * \param line Line number to load (1-4 for Comm page, 1-33 for info page) * \param just Line justification (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CENT, ADSI_JUST_IND) * \param wrap Wrap (1 = yes, 0 = no) * \param col1 Text to place in first column * \param col2 Text to place in second column * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2); /*! * \brief Sets the current line and page. * \param buf Character buffer to create parameter in (must have at least 256 free) * \param page Which page (ADSI_COMM_PAGE or ADSI_INFO_PAGE) * \param line Line number (1-33 for info page, 1-4 for comm page) * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_set_line(unsigned char *buf, int page, int line); /*! * \brief Creates "load soft key" parameters * \param buf Character buffer to create parameter in (must have at least 256 free) * \param key Key code from 2 to 33, for which key we are loading * \param llabel Long label for key (1-18 bytes) * \param slabel Short label for key (1-7 bytes) * \param ret Optional return sequence (NULL for none) * \param data whether to put CPE in data mode before sending digits * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data); /*! * \brief Set which soft keys should be displayed * \param buf Character buffer to create parameter in (must have at least 256 free) * \param keys Array of 8 unsigned chars with the key numbers, may be OR'd with ADSI_KEY_HILITE * But remember, the last two keys aren't real keys, they're for scrolling * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys); /*! * \brief Set input information * \param buf Character buffer to create parameter in (must have at least 256 free) * \param page Which page to input on (ADSI_COMM_PAGE or ADSI_INFO_PAGE) * \param line Line number to input on * \param display Set to zero to obscure input, or 1 to leave visible * \param format Format number to use (0-7) * \param just Justification (left, right center, indent) * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just); /*! * \brief Set input format * \param buf Character buffer to create parameter in (must have at least 256 free) * \param num Which format we are setting * \param dir Which direction (ADSI_DIR_FROM_LEFT or ADSI_DIR_FROM_RIGHT) * \param wrap Set to 1 to permit line wrap, or 0 if not * \param format1 Format for column 1 * \param format2 Format for column 2 * * \retval number of bytes added to buffer * \retval -1 on error. */ int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2); struct adsi_funcs { unsigned int version; int (*begin_download)(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version); int (*end_download)(struct ast_channel *chan); int (*channel_restore) (struct ast_channel *chan); int (*print) (struct ast_channel *chan, char **lines, int *align, int voice); int (*load_session) (struct ast_channel *chan, unsigned char *app, int ver, int data); int (*unload_session) (struct ast_channel *chan); int (*transmit_message) (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype); int (*transmit_message_full) (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait); int (*read_encoded_dtmf) (struct ast_channel *chan, unsigned char *buf, int maxlen); int (*connect_session) (unsigned char *buf, unsigned char *fdn, int ver); int (*query_cpeid) (unsigned char *buf); int (*query_cpeinfo) (unsigned char *buf); int (*get_cpeid) (struct ast_channel *chan, unsigned char *cpeid, int voice); int (*get_cpeinfo) (struct ast_channel *chan, int *width, int *height, int *buttons, int voice); int (*download_connect) (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver); int (*disconnect_session) (unsigned char *buf); int (*download_disconnect) (unsigned char *buf); int (*data_mode) (unsigned char *buf); int (*clear_soft_keys) (unsigned char *buf); int (*clear_screen) (unsigned char *buf); int (*voice_mode) (unsigned char *buf, int when); int (*available) (struct ast_channel *chan); int (*display) (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2); int (*set_line) (unsigned char *buf, int page, int line); int (*load_soft_key) (unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data); int (*set_keys) (unsigned char *buf, unsigned char *keys); int (*input_control) (unsigned char *buf, int page, int line, int display, int format, int just); int (*input_format) (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2); }; void ast_adsi_install_funcs(const struct adsi_funcs *funcs); #endif /* _ASTERISK_ADSI_H */ asterisk-11.7.0/include/asterisk/plc.h0000644000175000007640000001540610717373752017566 0ustar sharkyjerryweb/*! \file * \brief SpanDSP - a series of DSP components for telephony * * plc.h * * \author Steve Underwood * * Copyright (C) 2004 Steve Underwood * * All rights reserved. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * This version may be optionally licenced under the GNU LGPL licence. * * A license has been granted to Digium (via disclaimer) for the use of * this code. */ #if !defined(_PLC_H_) #define _PLC_H_ /* solaris used to #include */ /*! \page plc_page Packet loss concealment \section plc_page_sec_1 What does it do? The packet loss concealment module provides a suitable synthetic fill-in signal, to minimise the audible effect of lost packets in VoIP applications. It is not tied to any particular codec, and could be used with almost any codec which does not specify its own procedure for packet loss concealment. Where a codec specific concealment procedure exists, the algorithm is usually built around knowledge of the characteristics of the particular codec. It will, therefore, generally give better results for that particular codec than this generic concealer will. \section plc_page_sec_2 How does it work? While good packets are being received, the plc_rx() routine keeps a record of the trailing section of the known speech signal. If a packet is missed, plc_fillin() is called to produce a synthetic replacement for the real speech signal. The average mean difference function (AMDF) is applied to the last known good signal, to determine its effective pitch. Based on this, the last pitch period of signal is saved. Essentially, this cycle of speech will be repeated over and over until the real speech resumes. However, several refinements are needed to obtain smooth pleasant sounding results. - The two ends of the stored cycle of speech will not always fit together smoothly. This can cause roughness, or even clicks, at the joins between cycles. To soften this, the 1/4 pitch period of real speech preceeding the cycle to be repeated is blended with the last 1/4 pitch period of the cycle to be repeated, using an overlap-add (OLA) technique (i.e. in total, the last 5/4 pitch periods of real speech are used). - The start of the synthetic speech will not always fit together smoothly with the tail of real speech passed on before the erasure was identified. Ideally, we would like to modify the last 1/4 pitch period of the real speech, to blend it into the synthetic speech. However, it is too late for that. We could have delayed the real speech a little, but that would require more buffer manipulation, and hurt the efficiency of the no-lost-packets case (which we hope is the dominant case). Instead we use a degenerate form of OLA to modify the start of the synthetic data. The last 1/4 pitch period of real speech is time reversed, and OLA is used to blend it with the first 1/4 pitch period of synthetic speech. The result seems quite acceptable. - As we progress into the erasure, the chances of the synthetic signal being anything like correct steadily fall. Therefore, the volume of the synthesized signal is made to decay linearly, such that after 50ms of missing audio it is reduced to silence. - When real speech resumes, an extra 1/4 pitch period of sythetic speech is blended with the start of the real speech. If the erasure is small, this smoothes the transition. If the erasure is long, and the synthetic signal has faded to zero, the blending softens the start up of the real signal, avoiding a kind of "click" or "pop" effect that might occur with a sudden onset. \section plc_page_sec_3 How do I use it? Before audio is processed, call plc_init() to create an instance of the packet loss concealer. For each received audio packet that is acceptable (i.e. not including those being dropped for being too late) call plc_rx() to record the content of the packet. Note this may modify the packet a little after a period of packet loss, to blend real synthetic data smoothly. When a real packet is not available in time, call plc_fillin() to create a sythetic substitute. That's it! */ /*! Minimum allowed pitch (66 Hz) */ #define PLC_PITCH_MIN 120 /*! Maximum allowed pitch (200 Hz) */ #define PLC_PITCH_MAX 40 /*! Maximum pitch OLA window */ #define PLC_PITCH_OVERLAP_MAX (PLC_PITCH_MIN >> 2) /*! The length over which the AMDF function looks for similarity (20 ms) */ #define CORRELATION_SPAN 160 /*! History buffer length. The buffer much also be at leat 1.25 times PLC_PITCH_MIN, but that is much smaller than the buffer needs to be for the pitch assessment. */ #define PLC_HISTORY_LEN (CORRELATION_SPAN + PLC_PITCH_MIN) typedef struct { /*! Consecutive erased samples */ int missing_samples; /*! Current offset into pitch period */ int pitch_offset; /*! Pitch estimate */ int pitch; /*! Buffer for a cycle of speech */ float pitchbuf[PLC_PITCH_MIN]; /*! History buffer */ int16_t history[PLC_HISTORY_LEN]; /*! Current pointer into the history buffer */ int buf_ptr; } plc_state_t; #ifdef __cplusplus extern "C" { #endif /*! Process a block of received audio samples. \brief Process a block of received audio samples. \param s The packet loss concealer context. \param amp The audio sample buffer. \param len The number of samples in the buffer. \return The number of samples in the buffer. */ int plc_rx(plc_state_t *s, int16_t amp[], int len); /*! Fill-in a block of missing audio samples. \brief Fill-in a block of missing audio samples. \param s The packet loss concealer context. \param amp The audio sample buffer. \param len The number of samples to be synthesised. \return The number of samples synthesized. */ int plc_fillin(plc_state_t *s, int16_t amp[], int len); /*! Process a block of received V.29 modem audio samples. \brief Process a block of received V.29 modem audio samples. \param s The packet loss concealer context. \return A pointer to the he packet loss concealer context. */ plc_state_t *plc_init(plc_state_t *s); #ifdef __cplusplus } #endif #endif /*- End of file ------------------------------------------------------------*/ asterisk-11.7.0/include/asterisk/bridging_technology.h0000644000175000007640000001701112133015136023001 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Digium, Inc. * * Joshua Colp * * 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 Channel Bridging API * \author Joshua Colp */ #ifndef _ASTERISK_BRIDGING_TECHNOLOGY_H #define _ASTERISK_BRIDGING_TECHNOLOGY_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief Preference for choosing the bridge technology */ enum ast_bridge_preference { /*! Bridge technology should have high precedence over other bridge technologies */ AST_BRIDGE_PREFERENCE_HIGH = 0, /*! Bridge technology is decent, not the best but should still be considered over low */ AST_BRIDGE_PREFERENCE_MEDIUM, /*! Bridge technology is low, it should not be considered unless it is absolutely needed */ AST_BRIDGE_PREFERENCE_LOW, }; /*! * \brief Structure that is the essence of a bridge technology */ struct ast_bridge_technology { /*! Unique name to this bridge technology */ const char *name; /*! The capabilities that this bridge technology is capable of. This has nothing to do with * format capabilities. */ uint32_t capabilities; /*! Preference level that should be used when determining whether to use this bridge technology or not */ enum ast_bridge_preference preference; /*! Callback for when a bridge is being created */ int (*create)(struct ast_bridge *bridge); /*! Callback for when a bridge is being destroyed */ int (*destroy)(struct ast_bridge *bridge); /*! Callback for when a channel is being added to a bridge */ int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel); /*! Callback for when a channel is leaving a bridge */ int (*leave)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel); /*! Callback for when a channel is suspended from the bridge */ void (*suspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel); /*! Callback for when a channel is unsuspended from the bridge */ void (*unsuspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel); /*! Callback to see if a channel is compatible with the bridging technology */ int (*compatible)(struct ast_bridge_channel *bridge_channel); /*! Callback for writing a frame into the bridging technology */ enum ast_bridge_write_result (*write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridged_channel, struct ast_frame *frame); /*! Callback for when a file descriptor trips */ int (*fd)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int fd); /*! Callback for replacement thread function */ int (*thread)(struct ast_bridge *bridge); /*! Callback for poking a bridge thread */ int (*poke)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel); /*! Formats that the bridge technology supports */ struct ast_format_cap *format_capabilities; /*! Bit to indicate whether the bridge technology is currently suspended or not */ unsigned int suspended:1; /*! Module this bridge technology belongs to. Is used for reference counting when creating/destroying a bridge. */ struct ast_module *mod; /*! Linked list information */ AST_RWLIST_ENTRY(ast_bridge_technology) entry; }; /*! \brief Register a bridge technology for use * * \param technology The bridge technology to register * \param mod The module that is registering the bridge technology * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_technology_register(&simple_bridge_tech); * \endcode * * This registers a bridge technology declared as the structure * simple_bridge_tech with the bridging core and makes it available for * use when creating bridges. */ int __ast_bridge_technology_register(struct ast_bridge_technology *technology, struct ast_module *mod); /*! \brief See \ref __ast_bridge_technology_register() */ #define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, ast_module_info->self) /*! \brief Unregister a bridge technology from use * * \param technology The bridge technology to unregister * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_technology_unregister(&simple_bridge_tech); * \endcode * * This unregisters a bridge technlogy declared as the structure * simple_bridge_tech with the bridging core. It will no longer be * considered when creating a new bridge. */ int ast_bridge_technology_unregister(struct ast_bridge_technology *technology); /*! \brief Feed notification that a frame is waiting on a channel into the bridging core * * \param bridge The bridge that the notification should influence * \param bridge_channel Bridge channel the notification was received on (if known) * \param chan Channel the notification was received on (if known) * \param outfd File descriptor that the notification was received on (if known) * * Example usage: * * \code * ast_bridge_handle_trip(bridge, NULL, chan, -1); * \endcode * * This tells the bridging core that a frame has been received on * the channel pointed to by chan and that it should be read and handled. * * \note This should only be used by bridging technologies. */ void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd); /*! \brief Lets the bridging indicate when a bridge channel has stopped or started talking. * * \note All DSP functionality on the bridge has been pushed down to the lowest possible * layer, which in this case is the specific bridging technology being used. Since it * is necessary for the knowledge of which channels are talking to make its way up to the * application, this function has been created to allow the bridging technology to communicate * that information with the bridging core. * * \param bridge The bridge that the channel is a part of. * \param bridge_channel The bridge channel that has either started or stopped talking. * \param started_talking, set to 1 when this indicates the channel has started talking, set to 0 * when this indicates the channel has stopped talking. */ void ast_bridge_notify_talking(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int started_talking); /*! \brief Suspend a bridge technology from consideration * * \param technology The bridge technology to suspend * * Example usage: * * \code * ast_bridge_technology_suspend(&simple_bridge_tech); * \endcode * * This suspends the bridge technology simple_bridge_tech from being considered * when creating a new bridge. Existing bridges using the bridge technology * are not affected. */ void ast_bridge_technology_suspend(struct ast_bridge_technology *technology); /*! \brief Unsuspend a bridge technology * * \param technology The bridge technology to unsuspend * * Example usage: * * \code * ast_bridge_technology_unsuspend(&simple_bridge_tech); * \endcode * * This makes the bridge technology simple_bridge_tech considered when * creating a new bridge again. */ void ast_bridge_technology_unsuspend(struct ast_bridge_technology *technology); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_BRIDGING_TECHNOLOGY_H */ asterisk-11.7.0/include/asterisk/fskmodem_float.h0000644000175000007640000000453311041174227021764 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 FSK Modem Support * \note Includes code and algorithms from the Zapata library. */ #ifndef _ASTERISK_FSKMODEM_H #define _ASTERISK_FSKMODEM_H #define PARITY_NONE 0 #define PARITY_EVEN 1 #define PARITY_ODD 2 #define NCOLA 0x4000 typedef struct { float spb; /*!< Samples / Bit */ int nbit; /*!< Number of Data Bits (5,7,8) */ float nstop; /*!< Number of Stop Bits 1,1.5,2 */ int parity; /*!< Parity 0=none 1=even 2=odd */ int hdlc; /*!< Modo Packet */ float x0; float x1; float x2; float cont; int bw; /*!< Bandwidth */ double fmxv[8],fmyv[8]; /*!< filter stuff for M filter */ int fmp; /*!< pointer for M filter */ double fsxv[8],fsyv[8]; /*!< filter stuff for S filter */ int fsp; /*!< pointer for S filter */ double flxv[8],flyv[8]; /*!< filter stuff for L filter */ int flp; /*!< pointer for L filter */ int f_mark_idx; /*!< Mark frequency index (f_M-500)/5 */ int f_space_idx; /*!< Space frequency index (f_S-500)/5 */ int state; int pcola; /*!< Pointer to data queues */ float cola_in[NCOLA]; /*!< Queue of input samples */ float cola_filter[NCOLA]; /*!< Queue of samples after filters */ float cola_demod[NCOLA]; /*!< Queue of demodulated samples */ } fsk_data; /* \brief Retrieve a serial byte into outbyte. Buffer is a pointer into a series of shorts and len records the number of bytes in the buffer. len will be overwritten with the number of bytes left that were not consumed. \return return value is as follows: \arg 0: Still looking for something... \arg 1: An output byte was received and stored in outbyte \arg -1: An error occured in the transmission He must be called with at least 80 bytes of buffer. */ int fsk_serial(fsk_data *fskd, short *buffer, int *len, int *outbyte); #endif /* _ASTERISK_FSKMODEM_H */ asterisk-11.7.0/include/asterisk/smdi.h0000644000175000007640000001713411403452732017731 0ustar sharkyjerryweb/* * Asterisk -- A telephony toolkit for Linux. * * Copyright (C) 2005-2008, Digium, Inc. * * Matthew A. Nicholson * Russell Bryant * * 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 SMDI support for Asterisk. * \author Matthew A. Nicholson * \author Russell Bryant */ /* C is simply a ego booster for those who want to do objects the hard way. */ #ifndef ASTERISK_SMDI_H #define ASTERISK_SMDI_H #include #include #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/astobj.h" #include "asterisk/optional_api.h" #define SMDI_MESG_DESK_NUM_LEN 3 #define SMDI_MESG_DESK_TERM_LEN 4 #define SMDI_MWI_FAIL_CAUSE_LEN 3 #define SMDI_MAX_STATION_NUM_LEN 10 #define SMDI_MAX_FILENAME_LEN 256 /*! * \brief An SMDI message waiting indicator message. * * The ast_smdi_mwi_message structure contains the parsed out parts of an smdi * message. Each ast_smdi_interface structure has a message queue consisting * ast_smdi_mwi_message structures. */ struct ast_smdi_mwi_message { ASTOBJ_COMPONENTS(struct ast_smdi_mwi_message); char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */ char cause[SMDI_MWI_FAIL_CAUSE_LEN + 1]; /* the type of failure */ struct timeval timestamp; /* a timestamp for the message */ }; /*! * \brief An SMDI message desk message. * * The ast_smdi_md_message structure contains the parsed out parts of an smdi * message. Each ast_smdi_interface structure has a message queue consisting * ast_smdi_md_message structures. */ struct ast_smdi_md_message { ASTOBJ_COMPONENTS(struct ast_smdi_md_message); char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN + 1]; /* message desk number */ char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN + 1]; /* message desk terminal */ char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */ char calling_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* calling station number */ char type; /* the type of the call */ struct timeval timestamp; /* a timestamp for the message */ }; /*! * \brief SMDI interface structure. * * The ast_smdi_interface structure holds information on a serial port that * should be monitored for SMDI activity. The structure contains a message * queue of messages that have been received on the interface. */ struct ast_smdi_interface; AST_OPTIONAL_API(void, ast_smdi_interface_unref, (struct ast_smdi_interface *iface), { return; }); /*! * \brief Get the next SMDI message from the queue. * \param iface a pointer to the interface to use. * * This function pulls the first unexpired message from the SMDI message queue * on the specified interface. It will purge all expired SMDI messages before * returning. * * \return the next SMDI message, or NULL if there were no pending messages. */ AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_pop, (struct ast_smdi_interface *iface), { return NULL; }); /*! * \brief Get the next SMDI message from the queue. * \param iface a pointer to the interface to use. * \param timeout the time to wait before returning in milliseconds. * * This function pulls a message from the SMDI message queue on the specified * interface. If no message is available this function will wait the specified * amount of time before returning. * * \return the next SMDI message, or NULL if there were no pending messages and * the timeout has expired. */ AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_wait, (struct ast_smdi_interface *iface, int timeout), { return NULL; }); /*! * \brief Put an SMDI message back in the front of the queue. * \param iface a pointer to the interface to use. * \param msg a pointer to the message to use. * * This function puts a message back in the front of the specified queue. It * should be used if a message was popped but is not going to be processed for * some reason, and the message needs to be returned to the queue. */ AST_OPTIONAL_API(void, ast_smdi_md_message_putback, (struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg), { return; }); /*! * \brief Get the next SMDI message from the queue. * \param iface a pointer to the interface to use. * * This function pulls the first unexpired message from the SMDI message queue * on the specified interface. It will purge all expired SMDI messages before * returning. * * \return the next SMDI message, or NULL if there were no pending messages. */ AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_pop, (struct ast_smdi_interface *iface), { return NULL; }); /*! * \brief Get the next SMDI message from the queue. * \param iface a pointer to the interface to use. * \param timeout the time to wait before returning in milliseconds. * * This function pulls a message from the SMDI message queue on the specified * interface. If no message is available this function will wait the specified * amount of time before returning. * * \return the next SMDI message, or NULL if there were no pending messages and * the timeout has expired. */ AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_wait, (struct ast_smdi_interface *iface, int timeout), { return NULL; }); AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_wait_station, (struct ast_smdi_interface *iface, int timeout, const char *station), { return NULL; }); /*! * \brief Put an SMDI message back in the front of the queue. * \param iface a pointer to the interface to use. * \param msg a pointer to the message to use. * * This function puts a message back in the front of the specified queue. It * should be used if a message was popped but is not going to be processed for * some reason, and the message needs to be returned to the queue. */ AST_OPTIONAL_API(void, ast_smdi_mwi_message_putback, (struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg), { return; }); /*! * \brief Find an SMDI interface with the specified name. * \param iface_name the name/port of the interface to search for. * * \return a pointer to the interface located or NULL if none was found. This * actually returns an ASTOBJ reference and should be released using * #ASTOBJ_UNREF(iface, ast_smdi_interface_destroy). */ AST_OPTIONAL_API(struct ast_smdi_interface *, ast_smdi_interface_find, (const char *iface_name), { return NULL; }); /*! * \brief Set the MWI indicator for a mailbox. * \param iface the interface to use. * \param mailbox the mailbox to use. */ AST_OPTIONAL_API(int, ast_smdi_mwi_set, (struct ast_smdi_interface *iface, const char *mailbox), { return -1; }); /*! * \brief Unset the MWI indicator for a mailbox. * \param iface the interface to use. * \param mailbox the mailbox to use. */ AST_OPTIONAL_API(int, ast_smdi_mwi_unset, (struct ast_smdi_interface *iface, const char *mailbox), { return -1; }); /*! \brief ast_smdi_md_message destructor. */ AST_OPTIONAL_API(void, ast_smdi_md_message_destroy, (struct ast_smdi_md_message *msg), { return; }); /*! \brief ast_smdi_mwi_message destructor. */ AST_OPTIONAL_API(void, ast_smdi_mwi_message_destroy, (struct ast_smdi_mwi_message *msg), { return; }); #endif /* !ASTERISK_SMDI_H */ asterisk-11.7.0/include/asterisk/xmldoc.h0000644000175000007640000001151511772123406020262 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008, Eliel C. Sardanons (LU1ALY) * * 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. */ #ifndef _ASTERISK_XMLDOC_H #define _ASTERISK_XMLDOC_H /*! \file * \brief Asterisk XML Documentation API */ #include "asterisk/xml.h" #include "asterisk/stringfields.h" #include "asterisk/strings.h" /*! \brief From where the documentation come from, this structure is useful for * use it inside application/functions/manager actions structure. */ enum ast_doc_src { AST_XML_DOC, /*!< From XML documentation */ AST_STATIC_DOC /*!< From application/function registration */ }; #ifdef AST_XML_DOCS struct ao2_container; /*! \brief Struct that contains the XML documentation for a particular item. Note * that this is an ao2 ref counted object. * * \note * Each of the ast_str objects are built from the corresponding ast_xmldoc_build_* * calls * * \since 11 */ struct ast_xml_doc_item { /*! The syntax of the item */ struct ast_str *syntax; /*! Seealso tagged information, if it exists */ struct ast_str *seealso; /*! The arguments to the item */ struct ast_str *arguments; /*! A synopsis of the item */ struct ast_str *synopsis; /*! A description of the item */ struct ast_str *description; AST_DECLARE_STRING_FIELDS( /*! The name of the item */ AST_STRING_FIELD(name); /*! The type of the item */ AST_STRING_FIELD(type); ); /*! The next XML documentation item that matches the same name/item type */ struct ast_xml_doc_item *next; }; /*! * \brief Get the syntax for a specified application or function. * \param type Application, Function or AGI ? * \param name Name of the application or function. * \param module The module the item is in (optional, can be NULL) * \retval NULL on error. * \retval The generated syntax in a ast_malloc'ed string. */ char *ast_xmldoc_build_syntax(const char *type, const char *name, const char *module); /*! * \brief Parse the node content. * \param type 'application', 'function' or 'agi'. * \param name Application or functions name. * \param module The module the item is in (optional, can be NULL) * \retval NULL on error. * \retval Content of the see-also node. */ char *ast_xmldoc_build_seealso(const char *type, const char *name, const char *module); /*! * \brief Generate the [arguments] tag based on type of node ('application', * 'function' or 'agi') and name. * \param type 'application', 'function' or 'agi' ? * \param name Name of the application or function to build the 'arguments' tag. * \param module The module the item is in (optional, can be NULL) * \retval NULL on error. * \retval Output buffer with the [arguments] tag content. */ char *ast_xmldoc_build_arguments(const char *type, const char *name, const char *module); /*! * \brief Colorize and put delimiters (instead of tags) to the xmldoc output. * \param bwinput Not colorized input with tags. * \param withcolors Result output with colors. * \retval NULL on error. * \retval New malloced buffer colorized and with delimiters. */ char *ast_xmldoc_printable(const char *bwinput, int withcolors); /*! * \brief Generate synopsis documentation from XML. * \param type The source of documentation (application, function, etc). * \param name The name of the application, function, etc. * \param module The module the item is in (optional, can be NULL) * \retval NULL on error. * \retval A malloc'ed string with the synopsis. */ char *ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module); /*! * \brief Generate description documentation from XML. * \param type The source of documentation (application, function, etc). * \param name The name of the application, function, etc. * \param module The module the item is in (optional, can be NULL) * \retval NULL on error. * \retval A malloc'ed string with the formatted description. */ char *ast_xmldoc_build_description(const char *type, const char *name, const char *module); /*! * \brief Build the documentation for a particular source type * \param type The source of the documentation items (application, function, etc.) * * \retval NULL on error * \retval An ao2_container populated with ast_xml_doc instances for each item * that exists for the specified source type * * \since 11 */ struct ao2_container *ast_xmldoc_build_documentation(const char *type); #endif /* AST_XML_DOCS */ #endif /* _ASTERISK_XMLDOC_H */ asterisk-11.7.0/include/asterisk/acl.h0000644000175000007640000003330711777343400017541 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2012, Digium, Inc. * * Mark Spencer * * 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 Access Control of various sorts */ #ifndef _ASTERISK_ACL_H #define _ASTERISK_ACL_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/network.h" #include "asterisk/linkedlists.h" #include "asterisk/netsock2.h" #include "asterisk/io.h" enum ast_acl_sense { AST_SENSE_DENY, AST_SENSE_ALLOW }; /* Host based access control */ /*! \brief internal representation of ACL entries * In principle user applications would have no need for this, * but there is sometimes a need to extract individual items, * e.g. to print them, and rather than defining iterators to * navigate the list, and an externally visible 'struct ast_ha_entry', * at least in the short term it is more convenient to make the whole * thing public and let users play with them. */ struct ast_ha { /* Host access rule */ struct ast_sockaddr addr; struct ast_sockaddr netmask; enum ast_acl_sense sense; struct ast_ha *next; }; #define ACL_NAME_LENGTH 80 /*! * \brief an ast_acl is a linked list node of ast_ha structs which may have names. * * \note These shouldn't be used directly by ACL consumers. Consumers should handle * ACLs via ast_acl_list structs. */ struct ast_acl { struct ast_ha *acl; /*!< Rules contained by the ACL */ int is_realtime; /*!< If raised, this named ACL was retrieved from realtime storage */ int is_invalid; /*!< If raised, this is an invalid ACL which will automatically reject everything. */ char name[ACL_NAME_LENGTH]; /*!< If this was retrieved from the named ACL subsystem, this is the name of the ACL. */ AST_LIST_ENTRY(ast_acl) list; }; /*! \brief Wrapper for an ast_acl linked list. */ AST_LIST_HEAD(ast_acl_list, ast_acl); /*! * \brief Free a list of HAs * * \details * Given the head of a list of HAs, it and all appended * HAs are freed * * \param ha The head of the list of HAs to free * \retval void */ void ast_free_ha(struct ast_ha *ha); /*! * \brief Free a list of ACLs * * \details * Given the head of a list of ast_acl structs, it and all appended * acl structs will be freed. This includes the ast_ha structs within * the individual nodes. * \param acl The list of ACLs to free * \retval NULL */ struct ast_acl_list *ast_free_acl_list(struct ast_acl_list *acl); /*! * \brief Copy the contents of one HA to another * * \details * This copies the internals of the 'from' HA to the 'to' * HA. It is important that the 'to' HA has been allocated * prior to calling this function * * \param from Source HA to copy * \param to Destination HA to copy to * \retval void */ void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to); /*! * \brief Add a new rule to a list of HAs * * \details * This adds the new host access rule to the end of the list * whose head is specified by the path parameter. Rules are * evaluated in a way such that if multiple rules apply to * a single IP address/subnet mask, then the rule latest * in the list will be used. * * \param sense Either "permit" or "deny" (Actually any 'p' word will result * in permission, and any other word will result in denial) * \param stuff The IP address and subnet mask, separated with a '/'. The subnet * mask can either be in dotted-decimal format or in CIDR notation (i.e. 0-32). * \param path The head of the HA list to which we wish to append our new rule. If * NULL is passed, then the new rule will become the head of the list * \param[out] error The integer error points to will be set non-zero if an error occurs * \return The head of the HA list */ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error); /*! * \brief Add a rule to an ACL struct * * \details * This adds a named ACL or an ACL rule to an ast_acl container. * It works in a similar way to ast_append_ha. * * \param sense Can be any among "permit", "deny", or "acl" * this controls whether the rule being added will simply modify the unnamed ACL at the head of the list * or if a new named ACL will be added to that ast_acl. * \param stuff If sense is 'permit'/'deny', this is the ip address and subnet mask separated with a '/' like in ast_append ha. * If it sense is 'acl', then this will be the name of the ACL being appended to the container. * \param path Address of the ACL list being appended * \param[out] error The int that error points to will be set to 1 if an error occurs. * \param[out] named_acl_flag This will raise a flag under certain conditions to indicate that a named ACL has been added by this * operation. This may be used to indicate that an event subscription should be made against the named ACL subsystem. * Note: This flag may be raised by this function, but it will never be lowered by it. */ void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag); /*! * \brief Determines if an ACL is empty or if it contains entries * * \param acl_list The ACL list being checked * \retval 0 - the list is not empty * \retval 1 - the list is empty */ int ast_acl_list_is_empty(struct ast_acl_list *acl_list); /*! * \brief Apply a set of rules to a given IP address * * \details * The list of host access rules is traversed, beginning with the * input rule. If the IP address given matches a rule, the "sense" * of that rule is used as the return value. Note that if an IP * address matches multiple rules that the last one matched will be * the one whose sense will be returned. * * \param ha The head of the list of host access rules to follow * \param addr An ast_sockaddr whose address is considered when matching rules * \retval AST_SENSE_ALLOW The IP address passes our ACL * \retval AST_SENSE_DENY The IP address fails our ACL */ enum ast_acl_sense ast_apply_ha(const struct ast_ha *ha, const struct ast_sockaddr *addr); /*! * \brief Apply a set of rules to a given IP address * * \details * Similar to the above, only uses an acl container, which is a whole slew * of ast_ha lists. It runs ast_apply_ha on each of the ast_ha structs * contained in the acl container. It will deny if any of the ast_ha lists * fail, and it will pass only if all of the rules pass. * * \param acl The head of the list of ACLs to evaluate * \param addr An ast_sockaddr whose address is considered when matching rules * \param purpose Context for which the ACL is being applied - Establishes purpose of a notice when rejected * * \retval AST_SENSE_ALLOW The IP address passes our ACLs * \retval AST_SENSE_DENY The IP address fails our ACLs */ enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose); /*! * \brief Get the IP address given a hostname * * \details * Similar in nature to ast_gethostbyname, except that instead * of getting an entire hostent structure, you instead are given * only the IP address inserted into a ast_sockaddr structure. * * \param addr The IP address found. The address family is used * as an input parameter to filter the returned addresses. If * it is 0, both IPv4 and IPv6 addresses can be returned. * \param hostname The hostname to look up * * \retval 0 Success * \retval -1 Failure */ int ast_get_ip(struct ast_sockaddr *addr, const char *hostname); /*! * \brief Get the IP address given a hostname and optional service * * \details * If the service parameter is non-NULL, then an SRV lookup will be made by * prepending the service to the hostname parameter, separated by a '.' * For example, if hostname is "example.com" and service is "_sip._udp" then * an SRV lookup will be done for "_sip._udp.example.com". If service is NULL, * then this function acts exactly like a call to ast_get_ip. * * \param addr The IP address found. The address family is used * as an input parameter to filter the returned addresses. If * it is 0, both IPv4 and IPv6 addresses can be returned. * * \param hostname The hostname to look up * \param service A specific service provided by the host. A NULL service results * in an A-record lookup instead of an SRV lookup * \retval 0 Success * \retval -1 Failure */ int ast_get_ip_or_srv(struct ast_sockaddr *addr, const char *hostname, const char *service); /*! * \brief Get our local IP address when contacting a remote host * * \details * This function will attempt to connect(2) to them over UDP using a source * port of 5060. If the connect(2) call is successful, then we inspect the * sockaddr_in output parameter of connect(2) to determine the IP address * used to connect to them. This IP address is then copied into us. * * \param them The IP address to which we wish to attempt to connect * \param[out] us The source IP address used to connect to them * \retval -1 Failure * \retval 0 Success */ int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us); /*! * \brief Find an IP address associated with a specific interface * * \details * Given an interface such as "eth0" we find the primary IP address * associated with it using the SIOCGIFADDR ioctl. If the ioctl call * should fail, we populate address with 0s. * * \note * This function is not actually used anywhere * * \param iface The interface name whose IP address we wish to find * \param[out] address The interface's IP address is placed into this param * \retval -1 Failure. address is filled with 0s * \retval 0 Success */ int ast_lookup_iface(char *iface, struct ast_sockaddr *address); /*! * \brief Duplicate the contents of a list of host access rules * * \details * A deep copy of all ast_has in the list is made. The returned * value is allocated on the heap and must be freed independently * of the input parameter when finished. * * \param original The ast_ha to copy * \retval The head of the list of duplicated ast_has */ struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original); /*! * \brief Duplicates the contests of a list of lists of host access rules. * * \details * A deep copy of an ast_acl list is made (which in turn means a deep copy of * each of the ast_ha structs contained within). The returned value is allocated * on the heap and must be freed independently of the input paramater when * finished. * * \param original The ast_acl_list to copy * \retval The new duplicated ast_acl_list */ struct ast_acl_list *ast_duplicate_acl_list(struct ast_acl_list *original); /*! * \brief Find our IP address * * \details * This function goes through many iterations in an attempt to find * our IP address. If any step along the way should fail, we move to the * next item in the list. Here are the steps taken: * - If bindaddr has a non-zero IP address, that is copied into ourip * - We use a combination of gethostname and ast_gethostbyname to find our * IP address. * - We use ast_ouraddrfor with 198.41.0.4 as the destination IP address * - We try some platform-specific socket operations to find the IP address * * \param[out] ourip Our IP address is written here when it is found * \param bindaddr A hint used for finding our IP. See the steps above for * more details * \param family Only addresses of the given family will be returned. Use 0 * or AST_SOCKADDR_UNSPEC to get addresses of all families. * \retval 0 Success * \retval -1 Failure */ int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr, int family); /*! * \brief Convert a string to the appropriate COS value * * \param value The COS string to convert * \param[out] cos The integer representation of that COS value * \retval -1 Failure * \retval 0 Success */ int ast_str2cos(const char *value, unsigned int *cos); /*! * \brief Convert a string to the appropriate TOS value * * \param value The TOS string to convert * \param[out] tos The integer representation of that TOS value * \retval -1 Failure * \retval 0 Success */ int ast_str2tos(const char *value, unsigned int *tos); /*! * \brief Convert a TOS value into its string representation * * \param tos The TOS value to look up * \return The string equivalent of the TOS value */ const char *ast_tos2str(unsigned int tos); /*! * \brief Retrieve a named ACL * * \details * This function attempts to find a named ACL. If found, a copy * of the requested ACL will be made which must be freed by * the caller. * * \param name Name of the ACL sought * \param[out] is_realtime will be true if the ACL being returned is from realtime * \param[out] is_undefined will be true if no ACL profile can be found for the requested name * * \retval A copy of the named ACL as an ast_ha * \retval NULL if no ACL could be found. */ struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined); /*! * \brief Initialize and configure the named ACL system. * * \details * This function will prepare the named ACL system for use. * For this reason, it needs to be called before other things that use ACLs are initialized. */ int ast_named_acl_init(void); /*! * \brief reload/reconfigure the named ACL system. * * \details * This function is designed to trigger an event upon a successful reload that may update * ACL consumers. */ int ast_named_acl_reload(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_ACL_H */ asterisk-11.7.0/include/asterisk/bridging_features.h0000644000175000007640000002630012133015136022445 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Digium, Inc. * * Joshua Colp * * 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 Channel Bridging API * \author Joshua Colp */ #ifndef _ASTERISK_BRIDGING_FEATURES_H #define _ASTERISK_BRIDGING_FEATURES_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief Flags used for bridge features */ enum ast_bridge_feature_flags { /*! Upon hangup the bridge should be discontinued */ AST_BRIDGE_FLAG_DISSOLVE = (1 << 0), /*! Move between bridging technologies as needed. */ AST_BRIDGE_FLAG_SMART = (1 << 1), }; /*! \brief Built in features */ enum ast_bridge_builtin_feature { /*! DTMF Based Blind Transfer */ AST_BRIDGE_BUILTIN_BLINDTRANSFER = 0, /*! DTMF Based Attended Transfer */ AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, /*! DTMF Based Hangup Feature */ AST_BRIDGE_BUILTIN_HANGUP, /*! End terminator for list of built in features. Must remain last. */ AST_BRIDGE_BUILTIN_END, }; struct ast_bridge; struct ast_bridge_channel; /*! * \brief Features hook callback type * * \param bridge The bridge that the channel is part of * \param bridge_channel Channel executing the feature * \param hook_pvt Private data passed in when the hook was created * * \retval 0 success * \retval -1 failure */ typedef int (*ast_bridge_features_hook_callback)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt); /*! * \brief Features hook pvt destructor callback * * \param hook_pvt Private data passed in when the hook was create to destroy */ typedef void (*ast_bridge_features_hook_pvt_destructor)(void *hook_pvt); /*! * \brief Talking indicator callback * * \details This callback can be registered with the bridge in order * to receive updates on when a bridge_channel has started and stopped * talking * * \param bridge The bridge that the channel is part of * \param bridge_channel Channel executing the feature * * \retval 0 success * \retval -1 failure */ typedef void (*ast_bridge_talking_indicate_callback)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *pvt_data); typedef void (*ast_bridge_talking_indicate_destructor)(void *pvt_data); /*! * \brief Maximum length of a DTMF feature string */ #define MAXIMUM_DTMF_FEATURE_STRING 8 /*! * \brief Structure that is the essence of a features hook */ struct ast_bridge_features_hook { /*! DTMF String that is examined during a feature hook lookup */ char dtmf[MAXIMUM_DTMF_FEATURE_STRING]; /*! Callback that is called when DTMF string is matched */ ast_bridge_features_hook_callback callback; /*! Callback to destroy hook_pvt data right before destruction. */ ast_bridge_features_hook_pvt_destructor destructor; /*! Unique data that was passed into us */ void *hook_pvt; /*! Linked list information */ AST_LIST_ENTRY(ast_bridge_features_hook) entry; }; /*! * \brief Structure that contains features information */ struct ast_bridge_features { /*! Attached DTMF based feature hooks */ AST_LIST_HEAD_NOLOCK(, ast_bridge_features_hook) hooks; /*! Callback to indicate when a bridge channel has started and stopped talking */ ast_bridge_talking_indicate_callback talker_cb; /*! Callback to destroy any pvt data stored for the talker. */ ast_bridge_talking_indicate_destructor talker_destructor_cb; /*! Talker callback pvt data */ void *talker_pvt_data; /*! Feature flags that are enabled */ struct ast_flags feature_flags; /*! Bit to indicate that the hook list is useful and should be considered when looking for DTMF features */ unsigned int usable:1; /*! Bit to indicate whether the channel/bridge is muted or not */ unsigned int mute:1; /*! Bit to indicate whether DTMF should be passed into the bridge tech or not. */ unsigned int dtmf_passthrough:1; }; /*! * \brief Structure that contains configuration information for the blind transfer built in feature */ struct ast_bridge_features_blind_transfer { /*! Context to use for transfers */ char context[AST_MAX_CONTEXT]; }; /*! * \brief Structure that contains configuration information for the attended transfer built in feature */ struct ast_bridge_features_attended_transfer { /*! DTMF string used to abort the transfer */ char abort[MAXIMUM_DTMF_FEATURE_STRING]; /*! DTMF string used to turn the transfer into a three way conference */ char threeway[MAXIMUM_DTMF_FEATURE_STRING]; /*! DTMF string used to complete the transfer */ char complete[MAXIMUM_DTMF_FEATURE_STRING]; /*! Context to use for transfers */ char context[AST_MAX_CONTEXT]; }; /*! \brief Register a handler for a built in feature * * \param feature The feature that the handler will be responsible for * \param callback The callback function that will handle it * \param dtmf Default DTMF string used to activate the feature * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_features_register(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER, bridge_builtin_attended_transfer, "*1"); * \endcode * * This registers the function bridge_builtin_attended_transfer as the function responsible for the built in * attended transfer feature. */ int ast_bridge_features_register(enum ast_bridge_builtin_feature feature, ast_bridge_features_hook_callback callback, const char *dtmf); /*! \brief Unregister a handler for a built in feature * * \param feature The feature to unregister * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER); * \endcode * * This unregisters the function that is handling the built in attended transfer feature. */ int ast_bridge_features_unregister(enum ast_bridge_builtin_feature feature); /*! \brief Attach a custom hook to a bridge features structure * * \param features Bridge features structure * \param dtmf DTMF string to be activated upon * \param callback Function to execute upon activation * \param hook_pvt Unique data * \param Optional destructor callback for hook_pvt data * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * struct ast_bridge_features features; * ast_bridge_features_init(&features); * ast_bridge_features_hook(&features, "#", pound_callback, NULL, NULL); * \endcode * * This makes the bridging core call pound_callback if a channel that has this * feature structure inputs the DTMF string '#'. A pointer to useful data may be * provided to the hook_pvt parameter. * * \note It is important that the callback set the bridge channel state back to * AST_BRIDGE_CHANNEL_STATE_WAIT or the bridge thread will not service the channel. */ int ast_bridge_features_hook(struct ast_bridge_features *features, const char *dtmf, ast_bridge_features_hook_callback callback, void *hook_pvt, ast_bridge_features_hook_pvt_destructor destructor); /*! \brief Set a callback on the features structure to receive talking notifications on. * * \param features Bridge features structure * \param talker_cb, Callback function to execute when talking events occur in the bridge core. * \param pvt_data Optional unique data that will be passed with the talking events. * \param Optional destructor callback for pvt data. * * \retval 0, success * \retval -1, failure */ int ast_bridge_features_set_talk_detector(struct ast_bridge_features *features, ast_bridge_talking_indicate_callback talker_cb, ast_bridge_talking_indicate_destructor talker_destructor, void *pvt_data); /*! \brief Enable a built in feature on a bridge features structure * * \param features Bridge features structure * \param feature Feature to enable * \param dtmf Optionally the DTMF stream to trigger the feature, if not specified it will be the default * \param config Configuration structure unique to the built in type * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * struct ast_bridge_features features; * ast_bridge_features_init(&features); * ast_bridge_features_enable(&features, AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, NULL); * \endcode * * This enables the attended transfer DTMF option using the default DTMF string. An alternate * string may be provided using the dtmf parameter. Internally this is simply setting up a hook * to a built in feature callback function. */ int ast_bridge_features_enable(struct ast_bridge_features *features, enum ast_bridge_builtin_feature feature, const char *dtmf, void *config); /*! \brief Set a flag on a bridge features structure * * \param features Bridge features structure * \param flag Flag to enable * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * struct ast_bridge_features features; * ast_bridge_features_init(&features); * ast_bridge_features_set_flag(&features, AST_BRIDGE_FLAG_DISSOLVE); * \endcode * * This sets the AST_BRIDGE_FLAG_DISSOLVE feature to be enabled on the features structure * 'features'. */ int ast_bridge_features_set_flag(struct ast_bridge_features *features, enum ast_bridge_feature_flags flag); /*! \brief Initialize bridge features structure * * \param features Bridge featues structure * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * struct ast_bridge_features features; * ast_bridge_features_init(&features); * \endcode * * This initializes the feature structure 'features' to have nothing enabled. * * \note This MUST be called before enabling features or flags. Failure to do so * may result in a crash. */ int ast_bridge_features_init(struct ast_bridge_features *features); /*! \brief Clean up the contents of a bridge features structure * * \param features Bridge features structure * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * struct ast_bridge_features features; * ast_bridge_features_init(&features); * ast_bridge_features_cleanup(&features); * \endcode * * This cleans up the feature structure 'features'. * * \note This MUST be called after the features structure is done being used * or a memory leak may occur. */ int ast_bridge_features_cleanup(struct ast_bridge_features *features); /*! \brief Play a DTMF stream into a bridge, optionally not to a given channel * * \param bridge Bridge to play stream into * \param dtmf DTMF to play * \param chan Channel to optionally not play to * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_dtmf_stream(bridge, "0123456789", NULL); * \endcode * * This sends the DTMF digits '0123456789' to all channels in the bridge pointed to * by the bridge pointer. Optionally a channel may be excluded by passing it's channel pointer * using the chan parameter. */ int ast_bridge_dtmf_stream(struct ast_bridge *bridge, const char *dtmf, struct ast_channel *chan); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_BRIDGING_FEATURES_H */ asterisk-11.7.0/include/asterisk/presencestate.h0000644000175000007640000001134411763214744021647 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2011, Digium, Inc. * * David Vossel * * 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 Presence state management */ #ifndef _ASTERISK_PRESSTATE_H #define _ASTERISK_PRESSTATE_H enum ast_presence_state { AST_PRESENCE_NOT_SET = 0, AST_PRESENCE_UNAVAILABLE, AST_PRESENCE_AVAILABLE, AST_PRESENCE_AWAY, AST_PRESENCE_XA, AST_PRESENCE_CHAT, AST_PRESENCE_DND, /* This is not something that a user can * set his presence to. Rather, this is returned * to indicate that presence is in some invalid * state */ AST_PRESENCE_INVALID, }; /*! \brief Presence state provider call back */ typedef enum ast_presence_state (*ast_presence_state_prov_cb_type)(const char *data, char **subtype, char **message); /*! * \brief Convert presence state to text string for output * * \param state Current presence state */ const char *ast_presence_state2str(enum ast_presence_state state); /*! * \brief Convert presence state from text to integer value * * \param val The text representing the presence state. Valid values are anything * that comes after AST_PRESENCE_ in one of the defined values. * * \return The AST_PRESENCE_ integer value */ enum ast_presence_state ast_presence_state_val(const char *val); /*! * \brief Asks a presence state provider for the current presence state. * * \param presence_provider, The presence provider to retrieve the state from. * \param subtype, The output paramenter to store the subtype string in. Must be freed if returned * \param message, The output paramenter to store the message string in. Must be freed if returned * * \retval presence state value on success, * \retval -1 on failure. */ enum ast_presence_state ast_presence_state(const char *presence_provider, char **subtype, char **message); /*! * \brief Asks a presence state provider for the current presence state, bypassing the event cache * * \details Some presence state providers may perform transformations on presence data when it is * requested (such as a base64 decode). In such instances, use of the event cache is not suitable * and should be bypassed. * * \param presence_provider, The presence provider to retrieve the state from. * \param subtype, The output paramenter to store the subtype string in. Must be freed if returned * \param message, The output paramenter to store the message string in. Must be freed if returned * * \retval presence state value on success, * \retval -1 on failure. */ enum ast_presence_state ast_presence_state_nocache(const char *presence_provider, char **subtype, char **message); /*! * \brief Notify the world that a presence provider state changed. * * \param state the new presence state * \param subtype the new presence subtype * \param message the new presence message * \param fmt Presence entity whose state has changed * * The new state of the entity will be sent off to any subscribers * of the presence state. It will also be stored in the internal event * cache. * * \retval 0 Success * \retval -1 Failure */ int ast_presence_state_changed(enum ast_presence_state state, const char *subtype, const char *message, const char *fmt, ...) __attribute__((format(printf, 4, 5))); /*! * \brief Notify the world that a presence provider state changed. * * \param state the new presence state * \param subtype the new presence subtype * \param message the new presence message * \param presence_provider Presence entity whose state has changed * * The new state of the entity will be sent off to any subscribers * of the presence state. It will also be stored in the internal event * cache. * * \retval 0 Success * \retval -1 Failure */ int ast_presence_state_changed_literal(enum ast_presence_state state, const char *subtype, const char *message, const char *presence_provider); /*! * \brief Add presence state provider * * \param label to use in hint, like label:object * \param callback Callback * * \retval 0 success * \retval -1 failure */ int ast_presence_state_prov_add(const char *label, ast_presence_state_prov_cb_type callback); /*! * \brief Remove presence state provider * * \param label to use in hint, like label:object * * \retval -1 on failure * \retval 0 on success */ int ast_presence_state_prov_del(const char *label); int ast_presence_state_engine_init(void); #endif asterisk-11.7.0/include/asterisk/fskmodem_int.h0000644000175000007640000000420211041174227021442 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 FSK Modem Support * \note Includes code and algorithms from the Zapata library. */ #ifndef _ASTERISK_FSKMODEM_H #define _ASTERISK_FSKMODEM_H #define PARITY_NONE 0 #define PARITY_EVEN 1 #define PARITY_ODD 2 #define NCOLA 0x4000 /* new filter structure */ struct filter_struct { int icoefs[8]; int ip; int ixv[8]; int iyv[8]; }; typedef struct { int nbit; /*!< Number of Data Bits (5,7,8) */ int parity; /*!< Parity 0=none 1=even 2=odd */ int instop; /*!< Number of Stop Bits */ int hdlc; /*!< Modo Packet */ int xi0; int xi1; int xi2; int ispb; int icont; int bw; /*!< Band Selector*/ int f_mark_idx; /*!< Mark Frequency Index (f_M-500)/5 */ int f_space_idx; /*!< Space Frequency Index (f_S-500)/5 */ int state; int pllispb; /*! * * 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 Persistant data storage (akin to *doze registry) */ #ifndef _ASTERISK_ASTDB_H #define _ASTERISK_ASTDB_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif struct ast_db_entry { struct ast_db_entry *next; char *key; char data[0]; }; /*!\brief Get key value specified by family/key */ int ast_db_get(const char *family, const char *key, char *out, int outlen); /*!\brief Get key value specified by family/key as a heap allocated string. * * Given a \a family and \a key, sets \a out to a pointer to a heap * allocated string. In the event of an error, \a out will be set to * NULL. The string must be freed by calling ast_free(). * * \retval -1 An error occurred * \retval 0 Success */ int ast_db_get_allocated(const char *family, const char *key, char **out); /*!\brief Store value addressed by family/key */ int ast_db_put(const char *family, const char *key, const char *value); /*!\brief Delete entry in astdb */ int ast_db_del(const char *family, const char *key); /*!\brief Delete one or more entries in astdb * If both parameters are NULL, the entire database will be purged. If * only keytree is NULL, all entries within the family will be purged. * It is an error for keytree to have a value when family is NULL. * * \retval -1 An error occurred * \retval >= 0 Number of records deleted */ int ast_db_deltree(const char *family, const char *keytree); /*!\brief Get a list of values within the astdb tree * If family is specified, only those keys will be returned. If keytree * is specified, subkeys are expected to exist (separated from the key with * a slash). If subkeys do not exist and keytree is specified, the tree will * consist of either a single entry or NULL will be returned. * * Resulting tree should be freed by passing the return value to ast_db_freetree() * when usage is concluded. */ struct ast_db_entry *ast_db_gettree(const char *family, const char *keytree); /*!\brief Free structure created by ast_db_gettree() */ void ast_db_freetree(struct ast_db_entry *entry); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_ASTDB_H */ asterisk-11.7.0/include/asterisk/xmpp.h0000644000175000007640000002031612001311612017737 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Digium, Inc. * * Joshua Colp * * 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 XMPP Interface * \author Joshua Colp * \extref IKSEMEL http://iksemel.jabberstudio.org */ #ifndef _ASTERISK_XMPP_H #define _ASTERISK_XMPP_H #ifdef HAVE_OPENSSL #include #include #define TRY_SECURE 2 #define SECURE 4 #endif /* HAVE_OPENSSL */ /* file is read by blocks with this size */ #define NET_IO_BUF_SIZE 16384 /* Return value for timeout connection expiration */ #define IKS_NET_EXPIRED 12 #include #include "asterisk/utils.h" #include "asterisk/astobj2.h" #include "asterisk/linkedlists.h" #include "asterisk/stringfields.h" #include "asterisk/pbx.h" /* * As per RFC 3920 - section 3.1, the maximum length for a full Jabber ID * is 3071 bytes. * The ABNF syntax for jid : * jid = [node "@" ] domain [ "/" resource ] * Each allowable portion of a JID (node identifier, domain identifier, * and resource identifier) MUST NOT be more than 1023 bytes in length, * resulting in a maximum total size (including the '@' and '/' separators) * of 3071 bytes. */ #define XMPP_MAX_JIDLEN 3071 /*! \brief Maximum size of a resource JID */ #define XMPP_MAX_RESJIDLEN 1023 /*! \brief Maximum size of an attribute */ #define XMPP_MAX_ATTRLEN 256 /*! \brief Client connection states */ enum xmpp_state { XMPP_STATE_DISCONNECTING, /*!< Client is disconnecting */ XMPP_STATE_DISCONNECTED, /*!< Client is disconnected */ XMPP_STATE_CONNECTING, /*!< Client is connecting */ XMPP_STATE_REQUEST_TLS, /*!< Client should request TLS */ XMPP_STATE_REQUESTED_TLS, /*!< Client has requested TLS */ XMPP_STATE_AUTHENTICATE, /*!< Client needs to authenticate */ XMPP_STATE_AUTHENTICATING, /*!< Client is authenticating */ XMPP_STATE_ROSTER, /*!< Client is currently getting the roster */ XMPP_STATE_CONNECTED, /*!< Client is fully connected */ }; /*! \brief Resource capabilities */ struct ast_xmpp_capabilities { char node[200]; /*!< Node string from the capabilities stanza in presence notification */ char version[50]; /*!< Version string from the capabilities stanza in presence notification */ unsigned int jingle:1; /*!< Set if the resource supports Jingle */ unsigned int google:1; /*!< Set if the resource supports Google Talk */ }; /*! \brief XMPP Resource */ struct ast_xmpp_resource { char resource[XMPP_MAX_RESJIDLEN]; /*!< JID of the resource */ int status; /*!< Current status of the resource */ char *description; /*!< Description of the resource */ int priority; /*!< Priority, used for deciding what resource to use */ struct ast_xmpp_capabilities caps; /*!< Capabilities of the resource */ }; /*! \brief XMPP Message */ struct ast_xmpp_message { char *from; /*!< Who the message is from */ char *message; /*!< Message contents */ char id[25]; /*!< Identifier for the message */ struct timeval arrived; /*!< When the message arrived */ AST_LIST_ENTRY(ast_xmpp_message) list; /*!< Linked list information */ }; /*! \brief XMPP Buddy */ struct ast_xmpp_buddy { char id[XMPP_MAX_JIDLEN]; /*!< JID of the buddy */ struct ao2_container *resources; /*!< Resources for the buddy */ unsigned int subscribe:1; /*!< Need to subscribe to get their status */ }; /*! \brief XMPP Client Connection */ struct ast_xmpp_client { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(name); /*!< Name of the client configuration */ ); char mid[6]; /* Message ID */ iksid *jid; iksparser *parser; iksfilter *filter; ikstack *stack; #ifdef HAVE_OPENSSL SSL_CTX *ssl_context; SSL *ssl_session; const SSL_METHOD *ssl_method; unsigned int stream_flags; #endif /* HAVE_OPENSSL */ enum xmpp_state state; struct ao2_container *buddies; AST_LIST_HEAD(, ast_xmpp_message) messages; pthread_t thread; int timeout; unsigned int reconnect:1; /*!< Reconnect this client */ struct ast_event_sub *mwi_sub; /*!< If distributing event information the MWI subscription */ struct ast_event_sub *device_state_sub; /*!< If distributing event information the device state subscription */ }; /*! * \brief Find an XMPP client connection using a given name * * \param name Name of the client connection * * \retval non-NULL on success * \retval NULL on failure * * \note This will return the client connection with the reference count incremented by one. */ struct ast_xmpp_client *ast_xmpp_client_find(const char *name); /*! * \brief Disconnect an XMPP client connection * * \param client Pointer to the client * * \retval 0 on success * \retval -1 on failure */ int ast_xmpp_client_disconnect(struct ast_xmpp_client *client); /*! * \brief Release XMPP client connection reference * * \param client Pointer to the client */ void ast_xmpp_client_unref(struct ast_xmpp_client *client); /*! * \brief Lock an XMPP client connection * * \param client Pointer to the client */ void ast_xmpp_client_lock(struct ast_xmpp_client *client); /*! * \brief Unlock an XMPP client connection * * \param client Pointer to the client */ void ast_xmpp_client_unlock(struct ast_xmpp_client *client); /*! * \brief Send an XML stanza out using an established XMPP client connection * * \param client Pointer to the client * \param stanza Pointer to the Iksemel stanza * * \retval 0 on success * \retval -1 on failure */ int ast_xmpp_client_send(struct ast_xmpp_client *client, iks *stanza); /*! * \brief Send a message to a given user using an established XMPP client connection * * \param client Pointer to the client * \param user User the message should be sent to * \param message The message to send * * \retval 0 on success * \retval -1 on failure */ int ast_xmpp_client_send_message(struct ast_xmpp_client *client, const char *user, const char *message); /*! * \brief Invite a user to an XMPP multi-user chatroom * * \param client Pointer to the client * \param user JID of the user * \param room Name of the chatroom * \param message Message to send with the invitation * * \retval 0 on success * \retval -1 on failure */ int ast_xmpp_chatroom_invite(struct ast_xmpp_client *client, const char *user, const char *room, const char *message); /*! * \brief Join an XMPP multi-user chatroom * * \param client Pointer to the client * \param room Name of the chatroom * \param nickname Nickname to use * * \retval 0 on success * \retval -1 on failure */ int ast_xmpp_chatroom_join(struct ast_xmpp_client *client, const char *room, const char *nickname); /*! * \brief Send a message to an XMPP multi-user chatroom * * \param client Pointer to the client * \param nickname Nickname to use * \param Address Address of the room * \param message Message itself * * \retval 0 on success * \retval -1 on failure */ int ast_xmpp_chatroom_send(struct ast_xmpp_client *client, const char *nickname, const char *address, const char *message); /*! * \brief Leave an XMPP multi-user chatroom * * \param client Pointer to the client * \param room Name of the chatroom * \param nickname Nickname being used * * \retval 0 on success * \retval -1 on failure */ int ast_xmpp_chatroom_leave(struct ast_xmpp_client *client, const char *room, const char *nickname); /*! * \brief Helper function which increments the message identifier * * \param mid Pointer to a string containing the message identifier */ void ast_xmpp_increment_mid(char *mid); #endif asterisk-11.7.0/include/asterisk/paths.h0000644000175000007640000000232711667744541020130 0ustar sharkyjerryweb/* * Asterisk -- A telephony toolkit for Linux. * * Paths to configurable Asterisk directories * * Copyright (C) 1999-2006, Digium, Inc. * * Mark Spencer * * This program is free software, distributed under the terms of * the GNU General Public License */ /*! \file * \brief Asterisk file paths, configured in asterisk.conf */ #ifndef _ASTERISK_PATHS_H #define _ASTERISK_PATHS_H extern const char *ast_config_AST_CONFIG_DIR; extern const char *ast_config_AST_CONFIG_FILE; extern const char *ast_config_AST_MODULE_DIR; extern const char *ast_config_AST_SPOOL_DIR; extern const char *ast_config_AST_MONITOR_DIR; extern const char *ast_config_AST_VAR_DIR; extern const char *ast_config_AST_DATA_DIR; extern const char *ast_config_AST_LOG_DIR; extern const char *ast_config_AST_AGI_DIR; extern const char *ast_config_AST_DB; extern const char *ast_config_AST_KEY_DIR; extern const char *ast_config_AST_PID; extern const char *ast_config_AST_SOCKET; extern const char *ast_config_AST_RUN_DIR; extern const char *ast_config_AST_RUN_GROUP; extern const char *ast_config_AST_RUN_USER; extern const char *ast_config_AST_SYSTEM_NAME; extern const char *ast_config_AST_SBIN_DIR; #endif /* _ASTERISK_PATHS_H */ asterisk-11.7.0/include/asterisk/slinfactory.h0000644000175000007640000000711511531040421021316 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2005, Anthony Minessale II * * Anthony Minessale * * 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 A machine to gather up arbitrary frames and convert them * to raw slinear on demand. */ #ifndef _ASTERISK_SLINFACTORY_H #define _ASTERISK_SLINFACTORY_H #include "asterisk/format.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define AST_SLINFACTORY_MAX_HOLD 1280 struct ast_slinfactory { AST_LIST_HEAD_NOLOCK(, ast_frame) queue; /*!< A list of unaltered frames */ struct ast_trans_pvt *trans; /*!< Translation path that converts fed frames into signed linear */ short hold[AST_SLINFACTORY_MAX_HOLD]; /*!< Hold for audio that no longer belongs to a frame (ie: if only some samples were taken from a frame) */ short *offset; /*!< Offset into the hold where audio begins */ size_t holdlen; /*!< Number of samples currently in the hold */ unsigned int size; /*!< Number of samples currently in the factory */ struct ast_format format; /*!< Current format the translation path is converting from */ struct ast_format output_format; /*!< The output format desired */ }; /*! * \brief Initialize a slinfactory * * \param sf The slinfactory to initialize * * \return Nothing */ void ast_slinfactory_init(struct ast_slinfactory *sf); /*! * \brief Initialize a slinfactory * * \param sf The slinfactory to initialize * \param slin_out the slinear output format desired. * * \return 0 on success, non-zero on failure */ int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, const struct ast_format *slin_out); /*! * \brief Destroy the contents of a slinfactory * * \param sf The slinfactory that is no longer needed * * This function will free any memory allocated for the contents of the * slinfactory. It does not free the slinfactory itself. If the sf is * malloc'd, then it must be explicitly free'd after calling this function. * * \return Nothing */ void ast_slinfactory_destroy(struct ast_slinfactory *sf); /*! * \brief Feed audio into a slinfactory * * \param sf The slinfactory to feed into * \param f Frame containing audio to feed in * * \return Number of frames currently in factory */ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f); /*! * \brief Read samples from a slinfactory * * \param sf The slinfactory to read from * \param buf Buffer to put samples into * \param samples Number of samples wanted * * \return Number of samples read */ int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples); /*! * \brief Retrieve number of samples currently in a slinfactory * * \param sf The slinfactory to peek into * * \return Number of samples in slinfactory */ unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf); /*! * \brief Flush the contents of a slinfactory * * \param sf The slinfactory to flush * * \return Nothing */ void ast_slinfactory_flush(struct ast_slinfactory *sf); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_SLINFACTORY_H */ asterisk-11.7.0/include/asterisk/config.h0000644000175000007640000007420411777343400020250 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Configuration File Parser */ #ifndef _ASTERISK_CONFIG_H #define _ASTERISK_CONFIG_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/utils.h" #include "asterisk/inline_api.h" struct ast_config; struct ast_category; /*! Options for ast_config_load() */ enum { /*! Load the configuration, including comments */ CONFIG_FLAG_WITHCOMMENTS = (1 << 0), /*! On a reload, give us a -1 if the file hasn't changed. */ CONFIG_FLAG_FILEUNCHANGED = (1 << 1), /*! Don't attempt to cache mtime on this config file. */ CONFIG_FLAG_NOCACHE = (1 << 2), /*! Don't attempt to load from realtime (typically called from a realtime driver dependency) */ CONFIG_FLAG_NOREALTIME = (1 << 3), }; #define CONFIG_STATUS_FILEMISSING (void *)0 #define CONFIG_STATUS_FILEUNCHANGED (void *)-1 #define CONFIG_STATUS_FILEINVALID (void *)-2 /*! * \brief Types used in ast_realtime_require_field */ typedef enum { RQ_INTEGER1, RQ_UINTEGER1, RQ_INTEGER2, RQ_UINTEGER2, RQ_INTEGER3, RQ_UINTEGER3, RQ_INTEGER4, RQ_UINTEGER4, RQ_INTEGER8, RQ_UINTEGER8, RQ_CHAR, RQ_FLOAT, RQ_DATE, RQ_DATETIME, } require_type; /*! \brief Structure for variables, used for configurations and for channel variables */ struct ast_variable { /*! Variable name. Stored in stuff[] at struct end. */ const char *name; /*! Variable value. Stored in stuff[] at struct end. */ const char *value; /*! Next node in the list. */ struct ast_variable *next; /*! Filename where variable found. Stored in stuff[] at struct end. */ const char *file; int lineno; int object; /*!< 0 for variable, 1 for object */ int blanklines; /*!< Number of blanklines following entry */ struct ast_comment *precomments; struct ast_comment *sameline; struct ast_comment *trailing; /*!< the last object in the list will get assigned any trailing comments when EOF is hit */ /*! * \brief Contents of file, name, and value in that order stuffed here. * \note File must be stuffed before name because of ast_include_rename(). */ char stuff[0]; }; typedef struct ast_config *config_load_func(const char *database, const char *table, const char *configfile, struct ast_config *config, struct ast_flags flags, const char *suggested_include_file, const char *who_asked); typedef struct ast_variable *realtime_var_get(const char *database, const char *table, va_list ap); typedef struct ast_config *realtime_multi_get(const char *database, const char *table, va_list ap); typedef int realtime_update(const char *database, const char *table, const char *keyfield, const char *entity, va_list ap); typedef int realtime_update2(const char *database, const char *table, va_list ap); typedef int realtime_store(const char *database, const char *table, va_list ap); typedef int realtime_destroy(const char *database, const char *table, const char *keyfield, const char *entity, va_list ap); /*! * \brief Function pointer called to ensure database schema is properly configured for realtime use * \since 1.6.1 */ typedef int realtime_require(const char *database, const char *table, va_list ap); /*! * \brief Function pointer called to clear the database cache and free resources used for such * \since 1.6.1 */ typedef int realtime_unload(const char *database, const char *table); /*! \brief Configuration engine structure, used to define realtime drivers */ struct ast_config_engine { char *name; config_load_func *load_func; realtime_var_get *realtime_func; realtime_multi_get *realtime_multi_func; realtime_update *update_func; realtime_update2 *update2_func; realtime_store *store_func; realtime_destroy *destroy_func; realtime_require *require_func; realtime_unload *unload_func; struct ast_config_engine *next; }; /*! * \brief Load a config file * * \param filename path of file to open. If no preceding '/' character, * path is considered relative to AST_CONFIG_DIR * \param who_asked The module which is making this request. * \param flags Optional flags: * CONFIG_FLAG_WITHCOMMENTS - load the file with comments intact; * CONFIG_FLAG_FILEUNCHANGED - check the file mtime and return CONFIG_STATUS_FILEUNCHANGED if the mtime is the same; or * CONFIG_FLAG_NOCACHE - don't cache file mtime (main purpose of this option is to save memory on temporary files). * * \details * Create a config structure from a given configuration file. * * \return an ast_config data structure on success * \retval NULL on error */ struct ast_config *ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags); /*! * \brief Load a config file * * \param filename path of file to open. If no preceding '/' character, * path is considered relative to AST_CONFIG_DIR * \param flags Optional flags: * CONFIG_FLAG_WITHCOMMENTS - load the file with comments intact; * CONFIG_FLAG_FILEUNCHANGED - check the file mtime and return CONFIG_STATUS_FILEUNCHANGED if the mtime is the same; or * CONFIG_FLAG_NOCACHE - don't cache file mtime (main purpose of this option is to save memory on temporary files). * * \details * Create a config structure from a given configuration file. * * \return an ast_config data structure on success * \retval NULL on error */ #define ast_config_load(filename, flags) ast_config_load2(filename, AST_MODULE, flags) /*! * \brief Destroys a config * * \param config pointer to config data structure * * \details * Free memory associated with a given config */ void ast_config_destroy(struct ast_config *config); /*! * \brief returns the root ast_variable of a config * * \param config pointer to an ast_config data structure * \param cat name of the category for which you want the root * * \return the category specified */ struct ast_variable *ast_category_root(struct ast_config *config, char *cat); /*! * \brief Sorts categories in a config in the order of a numerical value contained within them. * * \param config The config structure you wish to sort * \param variable Which numerical value you wish to sort by * \param descending If true, we sort highest to lowest instead of lowest to highest * * \details * This function will assume a value of 0 for any non-numerical strings and NULL fields. */ void ast_config_sort_categories(struct ast_config *config, int descending, int (*comparator)(struct ast_category *p, struct ast_category *q)); /*! * \brief Goes through categories * * \param config Which config structure you wish to "browse" * \param prev A pointer to a previous category. * * \details * This function is kind of non-intuitive in it's use. * To begin, one passes NULL as the second argument. * It will return a pointer to the string of the first category in the file. * From here on after, one must then pass the previous usage's return value * as the second pointer, and it will return a pointer to the category name * afterwards. * * \retval a category on success * \retval NULL on failure/no-more-categories */ char *ast_category_browse(struct ast_config *config, const char *prev); /*! * \brief Goes through variables * * \details * Somewhat similar in intent as the ast_category_browse. * List variables of config file category * * \retval ast_variable list on success * \retval NULL on failure */ struct ast_variable *ast_variable_browse(const struct ast_config *config, const char *category); /*! * \brief given a pointer to a category, return the root variable. * * \details * This is equivalent to ast_variable_browse(), but more efficient if we * already have the struct ast_category * (e.g. from ast_category_get()) */ struct ast_variable *ast_category_first(struct ast_category *cat); /*! * \brief Gets a variable * * \param config which (opened) config to use * \param category category under which the variable lies * \param variable which variable you wish to get the data for * * \details * Goes through a given config file in the given category and searches for the given variable * * \retval The variable value on success * \retval NULL if unable to find it. */ const char *ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable); /*! * \brief Retrieve a category if it exists * * \param config which config to use * \param category_name name of the category you're looking for * * \details * This will search through the categories within a given config file for a match. * * \retval pointer to category if found * \retval NULL if not. */ struct ast_category *ast_category_get(const struct ast_config *config, const char *category_name); /*! * \brief Check for category duplicates * * \param config which config to use * \param category_name name of the category you're looking for * * \details * This will search through the categories within a given config file for a match. * * \return non-zero if found */ int ast_category_exist(const struct ast_config *config, const char *category_name); /*! * \brief Retrieve realtime configuration * * \param family which family/config to lookup * * \details * This will use builtin configuration backends to look up a particular * entity in realtime and return a variable list of its parameters. * * \note * Unlike the variables in ast_config, the resulting list of variables * MUST be freed with ast_variables_destroy() as there is no container. * * \note * The difference between these two calls is that ast_load_realtime excludes * fields whose values are NULL, while ast_load_realtime_all loads all columns. * * \note * You should use the constant SENTINEL to terminate arguments, in * order to preserve cross-platform compatibility. */ struct ast_variable *ast_load_realtime(const char *family, ...) attribute_sentinel; struct ast_variable *ast_load_realtime_all(const char *family, ...) attribute_sentinel; /*! * \brief Release any resources cached for a realtime family * \since 1.6.1 * * \param family which family/config to destroy * * \details * Various backends may cache attributes about a realtime data storage * facility; on reload, a front end resource may request to purge that cache. * * \retval 0 If any cache was purged * \retval -1 If no cache was found */ int ast_unload_realtime(const char *family); /*! * \brief Inform realtime what fields that may be stored * \since 1.6.1 * * \param family which family/config is referenced * * \details * This will inform builtin configuration backends that particular fields * may be updated during the use of that configuration section. This is * mainly to be used during startup routines, to ensure that various fields * exist in the backend. The backends may take various actions, such as * creating new fields in the data store or warning the administrator that * new fields may need to be created, in order to ensure proper function. * * The arguments are specified in groups of 3: column name, column type, * and column size. The column types are specified as integer constants, * defined by the enum require_type. Note that the size is specified as * the number of equivalent character fields that a field may take up, even * if a field is otherwise specified as an integer type. This is due to * the fact that some fields have historically been specified as character * types, even if they contained integer values. * * A family should always specify its fields to the minimum necessary * requirements to fulfill all possible values (within reason; for example, * a timeout value may reasonably be specified as an INTEGER2, with size 5. * Even though values above 32767 seconds are possible, they are unlikely * to be useful, and we should not complain about that size). * * \retval 0 Required fields met specified standards * \retval -1 One or more fields was missing or insufficient * * \note You should use the constant SENTINEL to terminate arguments, in * order to preserve cross-platform compatibility. */ int ast_realtime_require_field(const char *family, ...) attribute_sentinel; /*! * \brief Retrieve realtime configuration * * \param family which family/config to lookup * * \details * This will use builtin configuration backends to look up a particular * entity in realtime and return a variable list of its parameters. Unlike * the ast_load_realtime, this function can return more than one entry and * is thus stored inside a traditional ast_config structure rather than * just returning a linked list of variables. * * \return An ast_config with one or more results * \retval NULL Error or no results returned * * \note You should use the constant SENTINEL to terminate arguments, in * order to preserve cross-platform compatibility. */ struct ast_config *ast_load_realtime_multientry(const char *family, ...) attribute_sentinel; /*! * \brief Update realtime configuration * * \param family which family/config to be updated * \param keyfield which field to use as the key * \param lookup which value to look for in the key field to match the entry. * * \details * This function is used to update a parameter in realtime configuration space. * * \return Number of rows affected, or -1 on error. * * \note You should use the constant SENTINEL to terminate arguments, in * order to preserve cross-platform compatibility. */ int ast_update_realtime(const char *family, const char *keyfield, const char *lookup, ...) attribute_sentinel; /*! * \brief Update realtime configuration * * \param family which family/config to be updated * * \details * This function is used to update a parameter in realtime configuration space. * It includes the ability to lookup a row based upon multiple key criteria. * As a result, this function includes two sentinel values, one to terminate * lookup values and the other to terminate the listing of fields to update. * * \return Number of rows affected, or -1 on error. * * \note You should use the constant SENTINEL to terminate arguments, in * order to preserve cross-platform compatibility. */ int ast_update2_realtime(const char *family, ...) attribute_sentinel; /*! * \brief Create realtime configuration * * \param family which family/config to be created * * \details * This function is used to create a parameter in realtime configuration space. * * \return Number of rows affected, or -1 on error. * * \note * On the MySQL engine only, for reasons of backwards compatibility, the return * value is the insert ID. This value is nonportable and may be changed in a * future version to match the other engines. * * \note You should use the constant SENTINEL to terminate arguments, in * order to preserve cross-platform compatibility. */ int ast_store_realtime(const char *family, ...) attribute_sentinel; /*! * \brief Destroy realtime configuration * * \param family which family/config to be destroyed * \param keyfield which field to use as the key * \param lookup which value to look for in the key field to match the entry. * * \details * This function is used to destroy an entry in realtime configuration space. * Additional params are used as keys. * * \return Number of rows affected, or -1 on error. * * \note You should use the constant SENTINEL to terminate arguments, in * order to preserve cross-platform compatibility. */ int ast_destroy_realtime(const char *family, const char *keyfield, const char *lookup, ...) attribute_sentinel; /*! * \brief Check if realtime engine is configured for family * \param family which family/config to be checked * \return 1 if family is configured in realtime and engine exists */ int ast_check_realtime(const char *family); /*! \brief Check if there's any realtime engines loaded */ int ast_realtime_enabled(void); /*! * \brief Duplicate variable list * \param var the linked list of variables to clone * \return A duplicated list which you'll need to free with * ast_variables_destroy or NULL when out of memory. * * \note Do not depend on this to copy more than just name, value and filename * (the arguments to ast_variables_new). */ struct ast_variable *ast_variables_dup(struct ast_variable *var); /*! * \brief Free variable list * \param var the linked list of variables to free * * \details * This function frees a list of variables. */ void ast_variables_destroy(struct ast_variable *var); /*! * \brief Register config engine * \retval 1 Always */ int ast_config_engine_register(struct ast_config_engine *newconfig); /*! * \brief Deregister config engine * \retval 0 Always */ int ast_config_engine_deregister(struct ast_config_engine *del); /*! * \brief Determine if a mapping exists for a given family * * \param family which family you are looking to see if a mapping exists for * \retval 1 if it is mapped * \retval 0 if it is not */ int ast_realtime_is_mapping_defined(const char *family); /*! * \brief Exposed initialization method for core process * * \details * This method is intended for use only with the core initialization and is * not designed to be called from any user applications. */ int register_config_cli(void); /*! * \brief Exposed re-initialization method for core process * * \details * This method is intended for use only with the core re-initialization and is * not designed to be called from any user applications. */ int read_config_maps(void); /*! \brief Create a new base configuration structure */ struct ast_config *ast_config_new(void); /*! * \brief Retrieve the current category name being built. * * \details * API for backend configuration engines while building a configuration set. */ struct ast_category *ast_config_get_current_category(const struct ast_config *cfg); /*! * \brief Set the category within the configuration as being current. * * \details * API for backend configuration engines while building a configuration set. */ void ast_config_set_current_category(struct ast_config *cfg, const struct ast_category *cat); /*! * \brief Retrieve a configuration variable within the configuration set. * * \details * Retrieves the named variable \p var within category \p cat of configuration * set \p cfg. If not found, attempts to retrieve the named variable \p var * from within category \em general. * * \return Value of \p var, or NULL if not found. */ const char *ast_config_option(struct ast_config *cfg, const char *cat, const char *var); /*! \brief Create a category structure */ struct ast_category *ast_category_new(const char *name, const char *in_file, int lineno); void ast_category_append(struct ast_config *config, struct ast_category *cat); /*! * \brief Inserts new category * * \param config which config to use * \param cat newly created category to insert * \param match which category to insert above * * \details * This function is used to insert a new category above another category * matching the match parameter. */ void ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match); int ast_category_delete(struct ast_config *cfg, const char *category); /*! * \brief Removes and destroys all variables within a category * \retval 0 if the category was found and emptied * \retval -1 if the category was not found */ int ast_category_empty(struct ast_config *cfg, const char *category); void ast_category_destroy(struct ast_category *cat); struct ast_variable *ast_category_detach_variables(struct ast_category *cat); void ast_category_rename(struct ast_category *cat, const char *name); #ifdef MALLOC_DEBUG struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *function, int lineno); #define ast_variable_new(a, b, c) _ast_variable_new(a, b, c, __FILE__, __PRETTY_FUNCTION__, __LINE__) #else struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename); #endif struct ast_config_include *ast_include_new(struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size); struct ast_config_include *ast_include_find(struct ast_config *conf, const char *included_file); void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file); void ast_variable_append(struct ast_category *category, struct ast_variable *variable); void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line); int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line); /*! * \brief Update variable value within a config * * \param category Category element within the config * \param variable Name of the variable to change * \param value New value of the variable * \param match If set, previous value of the variable (if NULL or zero-length, no matching will be done) * \param object Boolean of whether to make the new variable an object * * \return 0 on success or -1 on failure. */ int ast_variable_update(struct ast_category *category, const char *variable, const char *value, const char *match, unsigned int object); int ast_config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator); int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator) __attribute__((deprecated)); struct ast_config *ast_config_internal_load(const char *configfile, struct ast_config *cfg, struct ast_flags flags, const char *suggested_incl_file, const char *who_asked); /*! * \brief * Copies the contents of one ast_config into another * * \note * This creates a config on the heap. The caller of this must * be prepared to free the memory returned. * * \param orig the config to copy * \return The new config on success, NULL on failure. */ struct ast_config *ast_config_copy(const struct ast_config *orig); /*! * \brief * Flags that affect the behaviour of config hooks. */ enum config_hook_flags { butt, }; /* * \brief Callback when configuration is updated * * \param cfg A copy of the configuration that is being changed. * This MUST be freed by the callback before returning. */ typedef int (*config_hook_cb)(struct ast_config *cfg); /*! * \brief * Register a config hook for a particular file and module * * \param name The name of the hook you are registering. * \param filename The file whose config you wish to hook into. * \param module The module that is reloading the config. This * can be useful if multiple modules may possibly * reload the same file, but you are only interested * when a specific module reloads the file * \param flags Flags that affect the way hooks work. * \param hook The callback to be called when config is loaded. * return 0 Success * return -1 Unsuccess, also known as UTTER AND COMPLETE FAILURE */ int ast_config_hook_register(const char *name, const char *filename, const char *module, enum config_hook_flags flags, config_hook_cb hook); /*! * \brief * Unregister a config hook * * \param name The name of the hook to unregister */ void ast_config_hook_unregister(const char *name); /*! * \brief Support code to parse config file arguments * * \details * The function ast_parse_arg() provides a generic interface to parse * strings (e.g. numbers, network addresses and so on) in a flexible * way, e.g. by doing proper error and bound checks, provide default * values, and so on. * The function (described later) takes a string as an argument, * a set of flags to specify the result format and checks to perform, * a pointer to the result, and optionally some additional arguments. * * \return It returns 0 on success, != 0 otherwise. */ enum ast_parse_flags { /* low 4 bits of flags are used for the operand type */ PARSE_TYPE = 0x000f, /* numeric types, with optional default value and bound checks. * Additional arguments are passed by value. */ PARSE_INT32 = 0x0001, PARSE_UINT32 = 0x0002, PARSE_DOUBLE = 0x0003, #if 0 /* not supported yet */ PARSE_INT16 = 0x0004, PARSE_UINT16 = 0x0005, #endif /* Returns a struct ast_sockaddr, with optional default value * (passed by reference) and port handling (accept, ignore, * require, forbid). The format is 'ipaddress[:port]'. IPv6 address * literals need square brackets around them if a port is specified. */ PARSE_ADDR = 0x000e, /* Returns a struct sockaddr_in, with optional default value * (passed by reference) and port handling (accept, ignore, * require, forbid). The format is 'host.name[:port]' */ PARSE_INADDR = 0x000f, /* Other data types can be added as needed */ /* If PARSE_DEFAULT is set, next argument is a default value * which is returned in case of error. The argument is passed * by value in case of numeric types, by reference in other cases. */ PARSE_DEFAULT = 0x0010, /* assign default on error */ /* Request a range check, applicable to numbers. Two additional * arguments are passed by value, specifying the low-high end of * the range (inclusive). An error is returned if the value * is outside or inside the range, respectively. */ PARSE_IN_RANGE = 0x0020, /* accept values inside a range */ PARSE_OUT_RANGE = 0x0040, /* accept values outside a range */ PARSE_RANGE_DEFAULTS = 0x0080, /* default to range min/max on range error */ /* Port handling, for ast_sockaddr. accept/ignore/require/forbid * port number after the hostname or address. */ PARSE_PORT_MASK = 0x0300, /* 0x000: accept port if present */ PARSE_PORT_IGNORE = 0x0100, /* 0x100: ignore port if present */ PARSE_PORT_REQUIRE = 0x0200, /* 0x200: require port number */ PARSE_PORT_FORBID = 0x0300, /* 0x100: forbid port number */ }; /*! * \brief The argument parsing routine. * * \param arg the string to parse. It is not modified. * \param flags combination of ast_parse_flags to specify the * return type and additional checks. * \param result pointer to the result. NULL is valid here, and can * be used to perform only the validity checks. * \param ... extra arguments are required according to flags. * * \retval 0 in case of success, != 0 otherwise. * \retval result returns the parsed value in case of success, * the default value in case of error, or it is left unchanged * in case of error and no default specified. Note that in certain * cases (e.g. sockaddr_in, with multi-field return values) some * of the fields in result may be changed even if an error occurs. * * \details * Examples of use: * ast_parse_arg("223", PARSE_INT32|PARSE_IN_RANGE, &a, -1000, 1000); * returns 0, a = 223 * ast_parse_arg("22345", PARSE_INT32|PARSE_IN_RANGE|PARSE_DEFAULT, &a, 9999, 10, 100); * returns 1, a = 9999 * ast_parse_arg("22345ssf", PARSE_UINT32|PARSE_IN_RANGE, &b, 10, 100); * returns 1, b unchanged * ast_parse_arg("12", PARSE_UINT32|PARSE_IN_RANGE|PARSE_RANGE_DEFAULTS, &a, 1, 10); * returns 1, a = 10 * ast_parse_arg("www.foo.biz:44", PARSE_INADDR, &sa); * returns 0, sa contains address and port * ast_parse_arg("www.foo.biz", PARSE_INADDR|PARSE_PORT_REQUIRE, &sa); * returns 1 because port is missing, sa contains address */ int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result, ...); /* * Parsing config file options in C is slightly annoying because we cannot use * string in a switch() statement, yet we need a similar behaviour, with many * branches and a break on a matching one. * The following somehow simplifies the job: we create a block using * the CV_START and CV_END macros, and then within the block we can run * actions such as "if (condition) { body; break; }" * Additional macros are present to run simple functions (e.g. ast_copy_string) * or to pass arguments to ast_parse_arg() * * As an example: CV_START(v->name, v->value); // start the block CV_STR("foo", x_foo); // static string CV_DSTR("bar", y_bar); // malloc'ed string CV_F("bar", ...); // call a generic function CV_END; // end the block */ /*! \brief the macro to open a block for variable parsing */ #define CV_START(__in_var, __in_val) \ do { \ const char *__var = __in_var; \ const char *__val = __in_val; /*! \brief close a variable parsing block */ #define CV_END } while (0) /*! \brief call a generic function if the name matches. */ #define CV_F(__pattern, __body) if (!strcasecmp((__var), __pattern)) { __body; break; } /*! * \brief helper macros to assign the value to a BOOL, UINT, static string and * dynamic string */ #define CV_BOOL(__x, __dst) CV_F(__x, (__dst) = ast_true(__val) ) #define CV_UINT(__x, __dst) CV_F(__x, (__dst) = strtoul(__val, NULL, 0) ) #define CV_STR(__x, __dst) CV_F(__x, ast_copy_string(__dst, __val, sizeof(__dst))) #define CV_DSTR(__x, __dst) CV_F(__x, ast_free(__dst); __dst = ast_strdup(__val)) #define CV_STRFIELD(__x, __obj, __field) CV_F(__x, ast_string_field_set(__obj, __field, __val)) /*! \brief Check if require type is an integer type */ AST_INLINE_API( int ast_rq_is_int(require_type type), { switch (type) { case RQ_INTEGER1: case RQ_UINTEGER1: case RQ_INTEGER2: case RQ_UINTEGER2: case RQ_INTEGER3: case RQ_UINTEGER3: case RQ_INTEGER4: case RQ_UINTEGER4: case RQ_INTEGER8: case RQ_UINTEGER8: return 1; default: return 0; } } ) /*! * \brief Remove standard encoding from realtime values, which ensures * that a semicolon embedded within a single value is not treated upon * retrieval as multiple values. * \param chunk Data to be decoded * \return The decoded data, in the original buffer * \since 1.8 * \warn This function modifies the original buffer */ char *ast_realtime_decode_chunk(char *chunk); /*! * \brief Encodes a chunk of data for realtime * \param dest Destination buffer * \param maxlen Length passed through to ast_str_* functions * \param chunk Source data to be encoded * \return Buffer within dest * \since 1.8 */ char *ast_realtime_encode_chunk(struct ast_str **dest, ssize_t maxlen, const char *chunk); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_CONFIG_H */ asterisk-11.7.0/include/asterisk/time.h0000644000175000007640000001170512046530216017727 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Time-related functions and macros */ #ifndef _ASTERISK_TIME_H #define _ASTERISK_TIME_H #ifdef HAVE_SYS_TIME_H #include #endif #include "asterisk/inline_api.h" /* We have to let the compiler learn what types to use for the elements of a struct timeval since on linux, it's time_t and suseconds_t, but on *BSD, they are just a long. */ extern struct timeval tv; typedef typeof(tv.tv_sec) ast_time_t; typedef typeof(tv.tv_usec) ast_suseconds_t; /*! * \brief Computes the difference (in seconds) between two \c struct \c timeval instances. * \param end the end of the time period * \param start the beginning of the time period * \return the difference in seconds */ AST_INLINE_API( int64_t ast_tvdiff_sec(struct timeval end, struct timeval start), { int64_t result = end.tv_sec - start.tv_sec; if (result > 0 && end.tv_usec < start.tv_usec) result--; else if (result < 0 && end.tv_usec > start.tv_usec) result++; return result; } ) /*! * \brief Computes the difference (in microseconds) between two \c struct \c timeval instances. * \param end the end of the time period * \param start the beginning of the time period * \return the difference in microseconds */ AST_INLINE_API( int64_t ast_tvdiff_us(struct timeval end, struct timeval start), { return (end.tv_sec - start.tv_sec) * (int64_t) 1000000 + end.tv_usec - start.tv_usec; } ) /*! * \brief Computes the difference (in milliseconds) between two \c struct \c timeval instances. * \param end end of the time period * \param start beginning of the time period * \return the difference in milliseconds */ AST_INLINE_API( int64_t ast_tvdiff_ms(struct timeval end, struct timeval start), { /* the offset by 1,000,000 below is intentional... it avoids differences in the way that division is handled for positive and negative numbers, by ensuring that the divisor is always positive */ int64_t sec_dif = (int64_t)(end.tv_sec - start.tv_sec) * 1000; int64_t usec_dif = (1000000 + end.tv_usec - start.tv_usec) / 1000 - 1000; return sec_dif + usec_dif; } ) /*! * \brief Returns true if the argument is 0,0 */ AST_INLINE_API( int ast_tvzero(const struct timeval t), { return (t.tv_sec == 0 && t.tv_usec == 0); } ) /*! * \brief Compres two \c struct \c timeval instances returning * -1, 0, 1 if the first arg is smaller, equal or greater to the second. */ AST_INLINE_API( int ast_tvcmp(struct timeval _a, struct timeval _b), { if (_a.tv_sec < _b.tv_sec) return -1; if (_a.tv_sec > _b.tv_sec) return 1; /* now seconds are equal */ if (_a.tv_usec < _b.tv_usec) return -1; if (_a.tv_usec > _b.tv_usec) return 1; return 0; } ) /*! * \brief Returns true if the two \c struct \c timeval arguments are equal. */ AST_INLINE_API( int ast_tveq(struct timeval _a, struct timeval _b), { return (_a.tv_sec == _b.tv_sec && _a.tv_usec == _b.tv_usec); } ) /*! * \brief Returns current timeval. Meant to replace calls to gettimeofday(). */ AST_INLINE_API( struct timeval ast_tvnow(void), { struct timeval t; gettimeofday(&t, NULL); return t; } ) /*! * \brief Returns the sum of two timevals a + b */ struct timeval ast_tvadd(struct timeval a, struct timeval b); /*! * \brief Returns the difference of two timevals a - b */ struct timeval ast_tvsub(struct timeval a, struct timeval b); /*! * \brief Calculate remaining milliseconds given a starting timestamp * and upper bound * * If the upper bound is negative, then this indicates that there is no * upper bound on the amount of time to wait. This will result in a * negative return. * * \param start When timing started being calculated * \param max_ms The maximum number of milliseconds to wait from start. May be negative. * \return The number of milliseconds left to wait for. May be negative. */ int ast_remaining_ms(struct timeval start, int max_ms); /*! * \brief Returns a timeval from sec, usec */ AST_INLINE_API( struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec), { struct timeval t; t.tv_sec = sec; t.tv_usec = usec; return t; } ) /*! * \brief Returns a timeval corresponding to the duration of n samples at rate r. * Useful to convert samples to timevals, or even milliseconds to timevals * in the form ast_samp2tv(milliseconds, 1000) */ AST_INLINE_API( struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate), { return ast_tv(_nsamp / _rate, (_nsamp % _rate) * (1000000 / (float) _rate)); } ) #endif /* _ASTERISK_TIME_H */ asterisk-11.7.0/include/asterisk/strings.h0000644000175000007640000007525412073346753020506 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 String manipulation functions */ #ifndef _ASTERISK_STRINGS_H #define _ASTERISK_STRINGS_H /* #define DEBUG_OPAQUE */ #include #include "asterisk/utils.h" #include "asterisk/threadstorage.h" #if defined(DEBUG_OPAQUE) #define __AST_STR_USED used2 #define __AST_STR_LEN len2 #define __AST_STR_STR str2 #define __AST_STR_TS ts2 #else #define __AST_STR_USED used #define __AST_STR_LEN len #define __AST_STR_STR str #define __AST_STR_TS ts #endif /* You may see casts in this header that may seem useless but they ensure this file is C++ clean */ #define AS_OR(a,b) (a && ast_str_strlen(a)) ? ast_str_buffer(a) : (b) #ifdef AST_DEVMODE #define ast_strlen_zero(foo) _ast_strlen_zero(foo, __FILE__, __PRETTY_FUNCTION__, __LINE__) static force_inline int _ast_strlen_zero(const char *s, const char *file, const char *function, int line) { if (!s || (*s == '\0')) { return 1; } if (!strcmp(s, "(null)")) { ast_log(__LOG_WARNING, file, line, function, "Possible programming error: \"(null)\" is not NULL!\n"); } return 0; } #else static force_inline int attribute_pure ast_strlen_zero(const char *s) { return (!s || (*s == '\0')); } #endif #ifdef SENSE_OF_HUMOR #define ast_strlen_real(a) (a) ? strlen(a) : 0 #define ast_strlen_imaginary(a) ast_random() #endif /*! \brief returns the equivalent of logic or for strings: * first one if not empty, otherwise second one. */ #define S_OR(a, b) ({typeof(&((a)[0])) __x = (a); ast_strlen_zero(__x) ? (b) : __x;}) /*! \brief returns the equivalent of logic or for strings, with an additional boolean check: * second one if not empty and first one is true, otherwise third one. * example: S_COR(usewidget, widget, "") */ #define S_COR(a, b, c) ({typeof(&((b)[0])) __x = (b); (a) && !ast_strlen_zero(__x) ? (__x) : (c);}) /*! \brief Gets a pointer to the first non-whitespace character in a string. \param str the input string \return a pointer to the first non-whitespace character */ AST_INLINE_API( char * attribute_pure ast_skip_blanks(const char *str), { while (*str && ((unsigned char) *str) < 33) str++; return (char *) str; } ) /*! \brief Trims trailing whitespace characters from a string. \param str the input string \return a pointer to the modified string */ AST_INLINE_API( char *ast_trim_blanks(char *str), { char *work = str; if (work) { work += strlen(work) - 1; /* It's tempting to only want to erase after we exit this loop, but since ast_trim_blanks *could* receive a constant string (which we presumably wouldn't have to touch), we shouldn't actually set anything unless we must, and it's easier just to set each position to \0 than to keep track of a variable for it */ while ((work >= str) && ((unsigned char) *work) < 33) *(work--) = '\0'; } return str; } ) /*! \brief Gets a pointer to first whitespace character in a string. \param str the input string \return a pointer to the first whitespace character */ AST_INLINE_API( char * attribute_pure ast_skip_nonblanks(const char *str), { while (*str && ((unsigned char) *str) > 32) str++; return (char *) str; } ) /*! \brief Strip leading/trailing whitespace from a string. \param s The string to be stripped (will be modified). \return The stripped string. This functions strips all leading and trailing whitespace characters from the input string, and returns a pointer to the resulting string. The string is modified in place. */ AST_INLINE_API( char *ast_strip(char *s), { if ((s = ast_skip_blanks(s))) { ast_trim_blanks(s); } return s; } ) /*! \brief Strip leading/trailing whitespace and quotes from a string. \param s The string to be stripped (will be modified). \param beg_quotes The list of possible beginning quote characters. \param end_quotes The list of matching ending quote characters. \return The stripped string. This functions strips all leading and trailing whitespace characters from the input string, and returns a pointer to the resulting string. The string is modified in place. It can also remove beginning and ending quote (or quote-like) characters, in matching pairs. If the first character of the string matches any character in beg_quotes, and the last character of the string is the matching character in end_quotes, then they are removed from the string. Examples: \code ast_strip_quoted(buf, "\"", "\""); ast_strip_quoted(buf, "'", "'"); ast_strip_quoted(buf, "[{(", "]})"); \endcode */ char *ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes); /*! \brief Strip backslash for "escaped" semicolons, the string to be stripped (will be modified). \return The stripped string. */ char *ast_unescape_semicolon(char *s); /*! \brief Convert some C escape sequences \verbatim (\b\f\n\r\t) \endverbatim into the equivalent characters. The string to be converted (will be modified). \return The converted string. */ char *ast_unescape_c(char *s); /*! \brief Size-limited null-terminating string copy. \param dst The destination buffer. \param src The source string \param size The size of the destination buffer \return Nothing. This is similar to \a strncpy, with two important differences: - the destination buffer will \b always be null-terminated - the destination buffer is not filled with zeros past the copied string length These differences make it slightly more efficient, and safer to use since it will not leave the destination buffer unterminated. There is no need to pass an artificially reduced buffer size to this function (unlike \a strncpy), and the buffer does not need to be initialized to zeroes prior to calling this function. */ AST_INLINE_API( void ast_copy_string(char *dst, const char *src, size_t size), { while (*src && size) { *dst++ = *src++; size--; } if (__builtin_expect(!size, 0)) dst--; *dst = '\0'; } ) /*! \brief Build a string in a buffer, designed to be called repeatedly \note This method is not recommended. New code should use ast_str_*() instead. This is a wrapper for snprintf, that properly handles the buffer pointer and buffer space available. \param buffer current position in buffer to place string into (will be updated on return) \param space remaining space in buffer (will be updated on return) \param fmt printf-style format string \retval 0 on success \retval non-zero on failure. */ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attribute__((format(printf, 3, 4))); /*! \brief Build a string in a buffer, designed to be called repeatedly This is a wrapper for snprintf, that properly handles the buffer pointer and buffer space available. \return 0 on success, non-zero on failure. \param buffer current position in buffer to place string into (will be updated on return) \param space remaining space in buffer (will be updated on return) \param fmt printf-style format string \param ap varargs list of arguments for format */ int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap) __attribute__((format(printf, 3, 0))); /*! * \brief Make sure something is true. * Determine if a string containing a boolean value is "true". * This function checks to see whether a string passed to it is an indication of an "true" value. * It checks to see if the string is "yes", "true", "y", "t", "on" or "1". * * \retval 0 if val is a NULL pointer. * \retval -1 if "true". * \retval 0 otherwise. */ int attribute_pure ast_true(const char *val); /*! * \brief Make sure something is false. * Determine if a string containing a boolean value is "false". * This function checks to see whether a string passed to it is an indication of an "false" value. * It checks to see if the string is "no", "false", "n", "f", "off" or "0". * * \retval 0 if val is a NULL pointer. * \retval -1 if "true". * \retval 0 otherwise. */ int attribute_pure ast_false(const char *val); /* * \brief Join an array of strings into a single string. * \param s the resulting string buffer * \param len the length of the result buffer, s * \param w an array of strings to join. * * This function will join all of the strings in the array 'w' into a single * string. It will also place a space in the result buffer in between each * string from 'w'. */ void ast_join(char *s, size_t len, const char * const w[]); /* \brief Parse a time (integer) string. \param src String to parse \param dst Destination \param _default Value to use if the string does not contain a valid time \param consumed The number of characters 'consumed' in the string by the parse (see 'man sscanf' for details) \retval 0 on success \retval non-zero on failure. */ int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed); /* \brief Parse a time (float) string. \param src String to parse \param dst Destination \param _default Value to use if the string does not contain a valid time \param consumed The number of characters 'consumed' in the string by the parse (see 'man sscanf' for details) \return zero on success, non-zero on failure */ int ast_get_timeval(const char *src, struct timeval *tv, struct timeval _default, int *consumed); /*! * Support for dynamic strings. * * A dynamic string is just a C string prefixed by a few control fields * that help setting/appending/extending it using a printf-like syntax. * * One should never declare a variable with this type, but only a pointer * to it, e.g. * * struct ast_str *ds; * * The pointer can be initialized with the following: * * ds = ast_str_create(init_len); * creates a malloc()'ed dynamic string; * * ds = ast_str_alloca(init_len); * creates a string on the stack (not very dynamic!). * * ds = ast_str_thread_get(ts, init_len) * creates a malloc()'ed dynamic string associated to * the thread-local storage key ts * * Finally, the string can be manipulated with the following: * * ast_str_set(&buf, max_len, fmt, ...) * ast_str_append(&buf, max_len, fmt, ...) * * and their varargs variant * * ast_str_set_va(&buf, max_len, ap) * ast_str_append_va(&buf, max_len, ap) * * \param max_len The maximum allowed capacity of the ast_str. Note that * if the value of max_len is less than the current capacity of the * ast_str (as returned by ast_str_size), then the parameter is effectively * ignored. * 0 means unlimited, -1 means "at most the available space" * * \return All the functions return <0 in case of error, or the * length of the string added to the buffer otherwise. Note that * in most cases where an error is returned, characters ARE written * to the ast_str. */ /*! \brief The descriptor of a dynamic string * XXX storage will be optimized later if needed * We use the ts field to indicate the type of storage. * Three special constants indicate malloc, ast_alloca() or static * variables, all other values indicate a * struct ast_threadstorage pointer. */ struct ast_str { size_t __AST_STR_LEN; /*!< The current maximum length of the string */ size_t __AST_STR_USED; /*!< Amount of space used */ struct ast_threadstorage *__AST_STR_TS; /*!< What kind of storage is this ? */ #define DS_MALLOC ((struct ast_threadstorage *)1) #define DS_ALLOCA ((struct ast_threadstorage *)2) #define DS_STATIC ((struct ast_threadstorage *)3) /* not supported yet */ char __AST_STR_STR[0]; /*!< The string buffer */ }; /*! * \brief Given a string regex_string in the form of "/regex/", convert it into the form of "regex" * * This function will trim one leading / and one trailing / from a given input string * ast_str regex_pattern must be preallocated before calling this function * * \return 0 on success, non-zero on failure. * \return 1 if we only stripped a leading / * \return 2 if we only stripped a trailing / * \return 3 if we did not strip any / characters * \param regex_string the string containing /regex/ * \param regex_pattern the destination ast_str which will contain "regex" after execution */ int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str **regex_pattern); /*! * \brief Create a malloc'ed dynamic length string * * \param init_len This is the initial length of the string buffer * * \return This function returns a pointer to the dynamic string length. The * result will be NULL in the case of a memory allocation error. * * \note The result of this function is dynamically allocated memory, and must * be free()'d after it is no longer needed. */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) #define ast_str_create(a) _ast_str_create(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) AST_INLINE_API( struct ast_str * attribute_malloc _ast_str_create(size_t init_len, const char *file, int lineno, const char *func), { struct ast_str *buf; buf = (struct ast_str *)__ast_calloc(1, sizeof(*buf) + init_len, file, lineno, func); if (buf == NULL) return NULL; buf->__AST_STR_LEN = init_len; buf->__AST_STR_USED = 0; buf->__AST_STR_TS = DS_MALLOC; return buf; } ) #else AST_INLINE_API( struct ast_str * attribute_malloc ast_str_create(size_t init_len), { struct ast_str *buf; buf = (struct ast_str *)ast_calloc(1, sizeof(*buf) + init_len); if (buf == NULL) return NULL; buf->__AST_STR_LEN = init_len; buf->__AST_STR_USED = 0; buf->__AST_STR_TS = DS_MALLOC; return buf; } ) #endif /*! \brief Reset the content of a dynamic string. * Useful before a series of ast_str_append. */ AST_INLINE_API( void ast_str_reset(struct ast_str *buf), { if (buf) { buf->__AST_STR_USED = 0; if (buf->__AST_STR_LEN) { buf->__AST_STR_STR[0] = '\0'; } } } ) /*! \brief Update the length of the buffer, after using ast_str merely as a buffer. * \param buf A pointer to the ast_str string. */ AST_INLINE_API( void ast_str_update(struct ast_str *buf), { buf->__AST_STR_USED = strlen(buf->__AST_STR_STR); } ) /*! \brief Trims trailing whitespace characters from an ast_str string. * \param buf A pointer to the ast_str string. */ AST_INLINE_API( void ast_str_trim_blanks(struct ast_str *buf), { if (!buf) { return; } while (buf->__AST_STR_USED && buf->__AST_STR_STR[buf->__AST_STR_USED - 1] < 33) { buf->__AST_STR_STR[--(buf->__AST_STR_USED)] = '\0'; } } ) /*!\brief Returns the current length of the string stored within buf. * \param buf A pointer to the ast_str structure. */ AST_INLINE_API( size_t attribute_pure ast_str_strlen(const struct ast_str *buf), { return buf->__AST_STR_USED; } ) /*!\brief Returns the current maximum length (without reallocation) of the current buffer. * \param buf A pointer to the ast_str structure. * \retval Current maximum length of the buffer. */ AST_INLINE_API( size_t attribute_pure ast_str_size(const struct ast_str *buf), { return buf->__AST_STR_LEN; } ) /*!\brief Returns the string buffer within the ast_str buf. * \param buf A pointer to the ast_str structure. * \retval A pointer to the enclosed string. */ AST_INLINE_API( char * attribute_pure ast_str_buffer(const struct ast_str *buf), { /* for now, cast away the const qualifier on the pointer * being returned; eventually, it should become truly const * and only be modified via accessor functions */ return (char *) buf->__AST_STR_STR; } ) /*!\brief Truncates the enclosed string to the given length. * \param buf A pointer to the ast_str structure. * \param len Maximum length of the string. If len is larger than the * current maximum length, things will explode. If it is negative * at most -len characters will be trimmed off the end. * \retval A pointer to the resulting string. */ AST_INLINE_API( char *ast_str_truncate(struct ast_str *buf, ssize_t len), { if (len < 0) { if ((typeof(buf->__AST_STR_USED)) -len >= buf->__AST_STR_USED) { buf->__AST_STR_USED = 0; } else { buf->__AST_STR_USED += len; } } else { buf->__AST_STR_USED = len; } buf->__AST_STR_STR[buf->__AST_STR_USED] = '\0'; return buf->__AST_STR_STR; } ) /* * AST_INLINE_API() is a macro that takes a block of code as an argument. * Using preprocessor #directives in the argument is not supported by all * compilers, and it is a bit of an obfuscation anyways, so avoid it. * As a workaround, define a macro that produces either its argument * or nothing, and use that instead of #ifdef/#endif within the * argument to AST_INLINE_API(). */ #if defined(DEBUG_THREADLOCALS) #define _DB1(x) x #else #define _DB1(x) #endif /*! * Make space in a new string (e.g. to read in data from a file) */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) AST_INLINE_API( int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function), { struct ast_str *old_buf = *buf; if (new_len <= (*buf)->__AST_STR_LEN) return 0; /* success */ if ((*buf)->__AST_STR_TS == DS_ALLOCA || (*buf)->__AST_STR_TS == DS_STATIC) return -1; /* cannot extend */ *buf = (struct ast_str *)__ast_realloc(*buf, new_len + sizeof(struct ast_str), file, lineno, function); if (*buf == NULL) { *buf = old_buf; return -1; } if ((*buf)->__AST_STR_TS != DS_MALLOC) { pthread_setspecific((*buf)->__AST_STR_TS->key, *buf); _DB1(__ast_threadstorage_object_replace(old_buf, *buf, new_len + sizeof(struct ast_str));) } (*buf)->__AST_STR_LEN = new_len; return 0; } ) #define ast_str_make_space(a,b) _ast_str_make_space(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else AST_INLINE_API( int ast_str_make_space(struct ast_str **buf, size_t new_len), { struct ast_str *old_buf = *buf; if (new_len <= (*buf)->__AST_STR_LEN) return 0; /* success */ if ((*buf)->__AST_STR_TS == DS_ALLOCA || (*buf)->__AST_STR_TS == DS_STATIC) return -1; /* cannot extend */ *buf = (struct ast_str *)ast_realloc(*buf, new_len + sizeof(struct ast_str)); if (*buf == NULL) { *buf = old_buf; return -1; } if ((*buf)->__AST_STR_TS != DS_MALLOC) { pthread_setspecific((*buf)->__AST_STR_TS->key, *buf); _DB1(__ast_threadstorage_object_replace(old_buf, *buf, new_len + sizeof(struct ast_str));) } (*buf)->__AST_STR_LEN = new_len; return 0; } ) #endif AST_INLINE_API( int ast_str_copy_string(struct ast_str **dst, struct ast_str *src), { /* make sure our destination is large enough */ if (src->__AST_STR_USED + 1 > (*dst)->__AST_STR_LEN) { if (ast_str_make_space(dst, src->__AST_STR_USED + 1)) { return -1; } } memcpy((*dst)->__AST_STR_STR, src->__AST_STR_STR, src->__AST_STR_USED + 1); (*dst)->__AST_STR_USED = src->__AST_STR_USED; return 0; } ) #define ast_str_alloca(init_len) \ ({ \ struct ast_str *__ast_str_buf; \ __ast_str_buf = ast_alloca(sizeof(*__ast_str_buf) + init_len); \ __ast_str_buf->__AST_STR_LEN = init_len; \ __ast_str_buf->__AST_STR_USED = 0; \ __ast_str_buf->__AST_STR_TS = DS_ALLOCA; \ __ast_str_buf->__AST_STR_STR[0] = '\0'; \ (__ast_str_buf); \ }) /*! * \brief Retrieve a thread locally stored dynamic string * * \param ts This is a pointer to the thread storage structure declared by using * the AST_THREADSTORAGE macro. If declared with * AST_THREADSTORAGE(my_buf, my_buf_init), then this argument would be * (&my_buf). * \param init_len This is the initial length of the thread's dynamic string. The * current length may be bigger if previous operations in this thread have * caused it to increase. * * \return This function will return the thread locally stored dynamic string * associated with the thread storage management variable passed as the * first argument. * The result will be NULL in the case of a memory allocation error. * * Example usage: * \code * AST_THREADSTORAGE(my_str, my_str_init); * #define MY_STR_INIT_SIZE 128 * ... * void my_func(const char *fmt, ...) * { * struct ast_str *buf; * * if (!(buf = ast_str_thread_get(&my_str, MY_STR_INIT_SIZE))) * return; * ... * } * \endcode */ #if !defined(DEBUG_THREADLOCALS) AST_INLINE_API( struct ast_str *ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len), { struct ast_str *buf; buf = (struct ast_str *)ast_threadstorage_get(ts, sizeof(*buf) + init_len); if (buf == NULL) return NULL; if (!buf->__AST_STR_LEN) { buf->__AST_STR_LEN = init_len; buf->__AST_STR_USED = 0; buf->__AST_STR_TS = ts; } return buf; } ) #else /* defined(DEBUG_THREADLOCALS) */ AST_INLINE_API( struct ast_str *__ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len, const char *file, const char *function, unsigned int line), { struct ast_str *buf; buf = (struct ast_str *)__ast_threadstorage_get(ts, sizeof(*buf) + init_len, file, function, line); if (buf == NULL) return NULL; if (!buf->__AST_STR_LEN) { buf->__AST_STR_LEN = init_len; buf->__AST_STR_USED = 0; buf->__AST_STR_TS = ts; } return buf; } ) #define ast_str_thread_get(ts, init_len) __ast_str_thread_get(ts, init_len, __FILE__, __PRETTY_FUNCTION__, __LINE__) #endif /* defined(DEBUG_THREADLOCALS) */ /*! * \brief Error codes from __ast_str_helper() * The undelying processing to manipulate dynamic string is done * by __ast_str_helper(), which can return a success or a * permanent failure (e.g. no memory). */ enum { /*! An error has occurred and the contents of the dynamic string * are undefined */ AST_DYNSTR_BUILD_FAILED = -1, /*! The buffer size for the dynamic string had to be increased, and * __ast_str_helper() needs to be called again after * a va_end() and va_start(). This return value is legacy and will * no longer be used. */ AST_DYNSTR_BUILD_RETRY = -2 }; /*! * \brief Core functionality of ast_str_(set|append)_va * * The arguments to this function are the same as those described for * ast_str_set_va except for an addition argument, append. * If append is non-zero, this will append to the current string instead of * writing over it. * * AST_DYNSTR_BUILD_RETRY is a legacy define. It should probably never * again be used. * * A return of AST_DYNSTR_BUILD_FAILED indicates a memory allocation error. * * A return value greater than or equal to zero indicates the number of * characters that have been written, not including the terminating '\0'. * In the append case, this only includes the number of characters appended. * * \note This function should never need to be called directly. It should * through calling one of the other functions or macros defined in this * file. */ #if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) int __attribute__((format(printf, 4, 0))) __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len, int append, const char *fmt, va_list ap, const char *file, int lineno, const char *func); #define __ast_str_helper(a,b,c,d,e) __ast_debug_str_helper(a,b,c,d,e,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, ssize_t max_len, int append, const char *fmt, va_list ap); #endif char *__ast_str_helper2(struct ast_str **buf, ssize_t max_len, const char *src, size_t maxsrc, int append, int escapecommas); /*! * \brief Set a dynamic string from a va_list * * \param buf This is the address of a pointer to a struct ast_str. * If it is retrieved using ast_str_thread_get, the struct ast_threadstorage pointer will need to * be updated in the case that the buffer has to be reallocated to * accommodate a longer string than what it currently has space for. * \param max_len This is the maximum length to allow the string buffer to grow * to. If this is set to 0, then there is no maximum length. * \param fmt This is the format string (printf style) * \param ap This is the va_list * * \return The return value of this function is the same as that of the printf * family of functions. * * Example usage (the first part is only for thread-local storage) * \code * AST_THREADSTORAGE(my_str, my_str_init); * #define MY_STR_INIT_SIZE 128 * ... * void my_func(const char *fmt, ...) * { * struct ast_str *buf; * va_list ap; * * if (!(buf = ast_str_thread_get(&my_str, MY_STR_INIT_SIZE))) * return; * ... * va_start(fmt, ap); * ast_str_set_va(&buf, 0, fmt, ap); * va_end(ap); * * printf("This is the string we just built: %s\n", buf->str); * ... * } * \endcode * * \note Care should be taken when using this function. The function can * result in reallocating the ast_str. If a pointer to the ast_str is passed * by value to a function that calls ast_str_set_va(), then the original ast_str * pointer may be invalidated due to a reallocation. * */ AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap), { return __ast_str_helper(buf, max_len, 0, fmt, ap); } ) /*! * \brief Append to a dynamic string using a va_list * * Same as ast_str_set_va(), but append to the current content. * * \note Care should be taken when using this function. The function can * result in reallocating the ast_str. If a pointer to the ast_str is passed * by value to a function that calls ast_str_append_va(), then the original ast_str * pointer may be invalidated due to a reallocation. * */ AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_append_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap), { return __ast_str_helper(buf, max_len, 1, fmt, ap); } ) /*!\brief Set a dynamic string to a non-NULL terminated substring. */ AST_INLINE_API(char *ast_str_set_substr(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc), { return __ast_str_helper2(buf, maxlen, src, maxsrc, 0, 0); } ) /*!\brief Append a non-NULL terminated substring to the end of a dynamic string. */ AST_INLINE_API(char *ast_str_append_substr(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc), { return __ast_str_helper2(buf, maxlen, src, maxsrc, 1, 0); } ) /*!\brief Set a dynamic string to a non-NULL terminated substring, with escaping of commas. */ AST_INLINE_API(char *ast_str_set_escapecommas(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc), { return __ast_str_helper2(buf, maxlen, src, maxsrc, 0, 1); } ) /*!\brief Append a non-NULL terminated substring to the end of a dynamic string, with escaping of commas. */ AST_INLINE_API(char *ast_str_append_escapecommas(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc), { return __ast_str_helper2(buf, maxlen, src, maxsrc, 1, 1); } ) /*! * \brief Set a dynamic string using variable arguments * * \note Care should be taken when using this function. The function can * result in reallocating the ast_str. If a pointer to the ast_str is passed * by value to a function that calls ast_str_set(), then the original ast_str * pointer may be invalidated due to a reallocation. * * \param buf This is the address of a pointer to a struct ast_str which should * have been retrieved using ast_str_thread_get. It will need to * be updated in the case that the buffer has to be reallocated to * accomodate a longer string than what it currently has space for. * \param max_len This is the maximum length to allow the string buffer to grow * to. If this is set to 0, then there is no maximum length. * If set to -1, we are bound to the current maximum length. * \param fmt This is the format string (printf style) * * \return The return value of this function is the same as that of the printf * family of functions. * * All the rest is the same as ast_str_set_va() */ AST_INLINE_API( int __attribute__((format(printf, 3, 4))) ast_str_set( struct ast_str **buf, ssize_t max_len, const char *fmt, ...), { int res; va_list ap; va_start(ap, fmt); res = ast_str_set_va(buf, max_len, fmt, ap); va_end(ap); return res; } ) /*! * \brief Append to a thread local dynamic string * * \note Care should be taken when using this function. The function can * result in reallocating the ast_str. If a pointer to the ast_str is passed * by value to a function that calls ast_str_append(), then the original ast_str * pointer may be invalidated due to a reallocation. * * The arguments, return values, and usage of this function are the same as * ast_str_set(), but the new data is appended to the current value. */ AST_INLINE_API( int __attribute__((format(printf, 3, 4))) ast_str_append( struct ast_str **buf, ssize_t max_len, const char *fmt, ...), { int res; va_list ap; va_start(ap, fmt); res = ast_str_append_va(buf, max_len, fmt, ap); va_end(ap); return res; } ) /*! * \brief Check if a string is only digits * * \retval 1 The string contains only digits * \retval 0 The string contains non-digit characters */ AST_INLINE_API( int ast_check_digits(const char *arg), { while (*arg) { if (*arg < '0' || *arg > '9') { return 0; } arg++; } return 1; } ) /*! * \brief Convert the tech portion of a device string to upper case * * \retval dev_str Returns the char* passed in for convenience */ AST_INLINE_API( char *ast_tech_to_upper(char *dev_str), { char *pos; if (!dev_str || !strchr(dev_str, '/')) { return dev_str; } for (pos = dev_str; *pos && *pos != '/'; pos++) { *pos = toupper(*pos); } return dev_str; } ) /*! * \brief Compute a hash value on a string * * This famous hash algorithm was written by Dan Bernstein and is * commonly used. * * http://www.cse.yorku.ca/~oz/hash.html */ static force_inline int attribute_pure ast_str_hash(const char *str) { int hash = 5381; while (*str) hash = hash * 33 ^ *str++; return abs(hash); } /*! * \brief Compute a hash value on a string * * \param[in] str The string to add to the hash * \param[in] hash The hash value to add to * * \details * This version of the function is for when you need to compute a * string hash of more than one string. * * This famous hash algorithm was written by Dan Bernstein and is * commonly used. * * \sa http://www.cse.yorku.ca/~oz/hash.html */ static force_inline int ast_str_hash_add(const char *str, int hash) { while (*str) hash = hash * 33 ^ *str++; return abs(hash); } /*! * \brief Compute a hash value on a case-insensitive string * * Uses the same hash algorithm as ast_str_hash, but converts * all characters to lowercase prior to computing a hash. This * allows for easy case-insensitive lookups in a hash table. */ static force_inline int attribute_pure ast_str_case_hash(const char *str) { int hash = 5381; while (*str) { hash = hash * 33 ^ tolower(*str++); } return abs(hash); } #endif /* _ASTERISK_STRINGS_H */ asterisk-11.7.0/include/asterisk/format_pref.h0000644000175000007640000001065511674712624021313 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * Mark Spencer * * 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 Format Preference API */ #ifndef _AST_FORMATPREF_H_ #define _AST_FORMATPREF_H_ #include "asterisk/format.h" #include "asterisk/format_cap.h" #define AST_CODEC_PREF_SIZE 64 struct ast_codec_pref { /*! This array represents the each format in the pref list */ struct ast_format formats[AST_CODEC_PREF_SIZE]; /*! This array represents the format id's index in the global format list. */ char order[AST_CODEC_PREF_SIZE]; /*! This array represents the format's framing size if present. */ int framing[AST_CODEC_PREF_SIZE]; }; /*! \page AudioCodecPref Audio Codec Preferences In order to negotiate audio codecs in the order they are configured in \.conf for a device, we set up codec preference lists in addition to the codec capabilities setting. The capabilities setting is a bitmask of audio and video codecs with no internal order. This will reflect the offer given to the other side, where the prefered codecs will be added to the top of the list in the order indicated by the "allow" lines in the device configuration. Video codecs are not included in the preference lists since they can't be transcoded and we just have to pick whatever is supported */ /*! *\brief Initialize an audio codec preference to "no preference". * \arg \ref AudioCodecPref */ void ast_codec_pref_init(struct ast_codec_pref *pref); /*! * \brief Codec located at a particular place in the preference index. * \param preference structure to get the codec out of * \param index to retrieve from * \param retult ast_format structure to store the index value in * \return pointer to input ast_format on success, NULL on failure */ struct ast_format *ast_codec_pref_index(struct ast_codec_pref *pref, int index, struct ast_format *result); /*! \brief Remove audio a codec from a preference list */ void ast_codec_pref_remove(struct ast_codec_pref *pref, struct ast_format *format); /*! \brief Append a audio codec to a preference list, removing it first if it was already there */ int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format); /*! \brief Prepend an audio codec to a preference list, removing it first if it was already there */ void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_format *format, int only_if_existing); /*! \brief Select the best audio format according to preference list from supplied options. * Best audio format is returned in the result format. * * \note If "find_best" is non-zero then if nothing is found, the "Best" format of * the format list is selected and returned in the result structure, otherwise * NULL is returned * * \retval ptr to result struture. * \retval NULL, best codec was not found */ struct ast_format *ast_codec_choose(struct ast_codec_pref *pref, struct ast_format_cap *cap, int find_best, struct ast_format *result); /*! \brief Set packet size for codec */ int ast_codec_pref_setsize(struct ast_codec_pref *pref, struct ast_format *format, int framems); /*! \brief Get packet size for codec */ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, struct ast_format *format); /*! \brief Dump audio codec preference list into a string */ int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size); /*! \brief Shift an audio codec preference list up or down 65 bytes so that it becomes an ASCII string * \note Due to a misunderstanding in how codec preferences are stored, this * list starts at 'B', not 'A'. For backwards compatibility reasons, this * cannot change. * \param pref A codec preference list structure * \param buf A string denoting codec preference, appropriate for use in line transmission * \param size Size of \a buf * \param right Boolean: if 0, convert from \a buf to \a pref; if 1, convert from \a pref to \a buf. */ void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, int right); #endif /* _AST_FORMATPREF_H */ asterisk-11.7.0/include/asterisk/channel.h0000644000175000007640000044676212102335475020423 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 General Asterisk PBX channel definitions. * \par See also: * \arg \ref Def_Channel * \arg \ref channel_drivers */ /*! \page Def_Channel Asterisk Channels \par What is a Channel? A phone call through Asterisk consists of an incoming connection and an outbound connection. Each call comes in through a channel driver that supports one technology, like SIP, DAHDI, IAX2 etc. \par Each channel driver, technology, has it's own private channel or dialog structure, that is technology-dependent. Each private structure is "owned" by a generic Asterisk channel structure, defined in channel.h and handled by channel.c . \par Call scenario This happens when an incoming call arrives to Asterisk -# Call arrives on a channel driver interface -# Channel driver creates a PBX channel and starts a pbx thread on the channel -# The dial plan is executed -# At this point at least two things can happen: -# The call is answered by Asterisk and Asterisk plays a media stream or reads media -# The dial plan forces Asterisk to create an outbound call somewhere with the dial (see \ref app_dial.c) application . \par Bridging channels If Asterisk dials out this happens: -# Dial creates an outbound PBX channel and asks one of the channel drivers to create a call -# When the call is answered, Asterisk bridges the media streams so the caller on the first channel can speak with the callee on the second, outbound channel -# In some cases where we have the same technology on both channels and compatible codecs, a native bridge is used. In a native bridge, the channel driver handles forwarding of incoming audio to the outbound stream internally, without sending audio frames through the PBX. -# In SIP, theres an "external native bridge" where Asterisk redirects the endpoint, so audio flows directly between the caller's phone and the callee's phone. Signalling stays in Asterisk in order to be able to provide a proper CDR record for the call. \par Masquerading channels In some cases, a channel can masquerade itself into another channel. This happens frequently in call transfers, where a new channel takes over a channel that is already involved in a call. The new channel sneaks in and takes over the bridge and the old channel, now a zombie, is hung up. \par Reference \arg channel.c - generic functions \arg channel.h - declarations of functions, flags and structures \arg translate.h - Transcoding support functions \arg \ref channel_drivers - Implemented channel drivers \arg \ref Def_Frame Asterisk Multimedia Frames \arg \ref Def_Bridge */ /*! \page Def_Bridge Asterisk Channel Bridges In Asterisk, there's several media bridges. The Core bridge handles two channels (a "phone call") and bridge them together. The conference bridge (meetme) handles several channels simultaneously with the support of an external timer (DAHDI timer). This is used not only by the Conference application (meetme) but also by the page application and the SLA system introduced in 1.4. The conference bridge does not handle video. When two channels of the same type connect, the channel driver or the media subsystem used by the channel driver (i.e. RTP) can create a native bridge without sending media through the core. Native bridging can be disabled by a number of reasons, like DTMF being needed by the core or codecs being incompatible so a transcoding module is needed. References: \li \see ast_channel_early_bridge() \li \see ast_channel_bridge() \li \see app_meetme.c \li \ref AstRTPbridge \li \see ast_rtp_bridge() \li \ref Def_Channel */ /*! \page AstFileDesc File descriptors Asterisk File descriptors are connected to each channel (see \ref Def_Channel) in the \ref ast_channel structure. */ #ifndef _ASTERISK_CHANNEL_H #define _ASTERISK_CHANNEL_H #include "asterisk/abstract_jb.h" #include "asterisk/astobj2.h" #include "asterisk/poll-compat.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define AST_MAX_EXTENSION 80 /*!< Max length of an extension */ #define AST_MAX_CONTEXT 80 /*!< Max length of a context */ #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */ #define MAX_LANGUAGE 40 /*!< Max length of the language setting */ #define MAX_MUSICCLASS 80 /*!< Max length of the music class setting */ #include "asterisk/frame.h" #include "asterisk/chanvars.h" #include "asterisk/config.h" #include "asterisk/lock.h" #include "asterisk/cdr.h" #include "asterisk/utils.h" #include "asterisk/linkedlists.h" #include "asterisk/stringfields.h" #include "asterisk/datastore.h" #include "asterisk/data.h" #include "asterisk/channelstate.h" #include "asterisk/ccss.h" #include "asterisk/framehook.h" #define DATASTORE_INHERIT_FOREVER INT_MAX #define AST_MAX_FDS 11 /* * We have AST_MAX_FDS file descriptors in a channel. * Some of them have a fixed use: */ #define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe */ #define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd */ #define AST_AGENT_FD (AST_MAX_FDS-3) /*!< used by agents for pass through */ #define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< used by generator */ #define AST_JITTERBUFFER_FD (AST_MAX_FDS-5) /*!< used by generator */ enum ast_bridge_result { AST_BRIDGE_COMPLETE = 0, AST_BRIDGE_FAILED = -1, AST_BRIDGE_FAILED_NOWARN = -2, AST_BRIDGE_RETRY = -3, }; typedef unsigned long long ast_group_t; /*! \todo Add an explanation of an Asterisk generator */ struct ast_generator { void *(*alloc)(struct ast_channel *chan, void *params); /*! Channel is locked during this function callback. */ void (*release)(struct ast_channel *chan, void *data); /*! This function gets called with the channel unlocked, but is called in * the context of the channel thread so we know the channel is not going * to disappear. This callback is responsible for locking the channel as * necessary. */ int (*generate)(struct ast_channel *chan, void *data, int len, int samples); /*! This gets called when DTMF_END frames are read from the channel */ void (*digit)(struct ast_channel *chan, char digit); /*! This gets called when the write format on a channel is changed while * generating. The channel is locked during this callback. */ void (*write_format_change)(struct ast_channel *chan, void *data); }; /*! Party name character set enumeration values (values from Q.SIG) */ enum AST_PARTY_CHAR_SET { AST_PARTY_CHAR_SET_UNKNOWN = 0, AST_PARTY_CHAR_SET_ISO8859_1 = 1, AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */ AST_PARTY_CHAR_SET_ISO8859_2 = 3, AST_PARTY_CHAR_SET_ISO8859_3 = 4, AST_PARTY_CHAR_SET_ISO8859_4 = 5, AST_PARTY_CHAR_SET_ISO8859_5 = 6, AST_PARTY_CHAR_SET_ISO8859_7 = 7, AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8, AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9, }; /*! * \since 1.8 * \brief Information needed to specify a name in a call. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. */ struct ast_party_name { /*! \brief Subscriber name (Malloced) */ char *str; /*! * \brief Character set the name is using. * \see enum AST_PARTY_CHAR_SET * \note * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use. * \todo Start using the party name character set value. Not currently used. */ int char_set; /*! * \brief Q.931 encoded presentation-indicator encoded field * \note Must tolerate the Q.931 screening-indicator field values being present. */ int presentation; /*! \brief TRUE if the name information is valid/present */ unsigned char valid; }; /*! * \since 1.8 * \brief Information needed to specify a number in a call. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. */ struct ast_party_number { /*! \brief Subscriber phone number (Malloced) */ char *str; /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */ int plan; /*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */ int presentation; /*! \brief TRUE if the number information is valid/present */ unsigned char valid; }; /*! * \since 1.8 * \brief Information needed to specify a subaddress in a call. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. */ struct ast_party_subaddress { /*! * \brief Malloced subaddress string. * \note If the subaddress type is user specified then the subaddress is * a string of ASCII hex because the actual subaddress is likely BCD encoded. */ char *str; /*! * \brief Q.931 subaddress type. * \details * nsap(0), * user_specified(2) */ int type; /*! * \brief TRUE if odd number of address signals * \note The odd/even indicator is used when the type of subaddress is * user_specified and the coding is BCD. */ unsigned char odd_even_indicator; /*! \brief TRUE if the subaddress information is valid/present */ unsigned char valid; }; /*! * \since 1.8 * \brief Information needed to identify an endpoint in a call. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. */ struct ast_party_id { /*! \brief Subscriber name */ struct ast_party_name name; /*! \brief Subscriber phone number */ struct ast_party_number number; /*! \brief Subscriber subaddress. */ struct ast_party_subaddress subaddress; /*! * \brief User-set "tag" * \details * A user-settable field used to help associate some extrinsic information * about the channel or user of the channel to the party ID. This information * is normally not transmitted over the wire and so is only useful within an * Asterisk environment. */ char *tag; }; /*! * \since 1.8 * \brief Indicate what information in ast_party_id should be set. */ struct ast_set_party_id { /*! TRUE if the ast_party_name information should be set. */ unsigned char name; /*! TRUE if the ast_party_number information should be set. */ unsigned char number; /*! TRUE if the ast_party_subaddress information should be set. */ unsigned char subaddress; }; /*! * \since 1.8 * \brief Dialed/Called Party information. * \note Dialed Number Identifier (DNID) * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. */ struct ast_party_dialed { /*! * \brief Dialed/Called number * \note Done this way in case we ever really need to use ast_party_number. * We currently do not need all of the ast_party_number fields. */ struct { /*! \brief Subscriber phone number (Malloced) */ char *str; /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */ int plan; } number; /*! \brief Dialed/Called subaddress */ struct ast_party_subaddress subaddress; /*! * \brief Transit Network Select * \note Currently this value is just passed around the system. * You can read it and set it but it is never used for anything. */ int transit_network_select; }; /*! * \since 1.8 * \brief Caller Party information. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. * * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names. * In some cases, we also have an alternative (RPID) E.164 number that can * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to * PSTN gateway). * * \todo Implement settings for transliteration between UTF8 Caller ID names in * to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into * Osten Asklund or Oesten Aasklund depending upon language and person... * We need automatic routines for incoming calls and static settings for * our own accounts. */ struct ast_party_caller { /*! \brief Caller party ID */ struct ast_party_id id; /*! * \brief Automatic Number Identification (ANI) * \note The name subcomponent is only likely to be used by SIP. * \note The subaddress subcomponent is not likely to be used. */ struct ast_party_id ani; /*! \brief Private caller party ID */ struct ast_party_id priv; /*! \brief Automatic Number Identification 2 (Info Digits) */ int ani2; }; /*! * \since 1.8 * \brief Indicate what information in ast_party_caller should be set. */ struct ast_set_party_caller { /*! What caller id information to set. */ struct ast_set_party_id id; /*! What ANI id information to set. */ struct ast_set_party_id ani; /*! What private caller id information to set. */ struct ast_set_party_id priv; }; /*! * \since 1.8 * \brief Connected Line/Party information. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. */ struct ast_party_connected_line { /*! \brief Connected party ID */ struct ast_party_id id; /*! * \brief Automatic Number Identification (ANI) * \note Not really part of connected line data but needed to * save the corresponding caller id value. */ struct ast_party_id ani; /*! \brief Private connected party ID */ struct ast_party_id priv; /*! * \brief Automatic Number Identification 2 (Info Digits) * \note Not really part of connected line data but needed to * save the corresponding caller id value. */ int ani2; /*! * \brief Information about the source of an update. * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values * for Normal-Answer and Call-transfer. */ int source; }; /*! * \since 1.8 * \brief Indicate what information in ast_party_connected_line should be set. */ struct ast_set_party_connected_line { /*! What connected line id information to set. */ struct ast_set_party_id id; /*! What ANI id information to set. */ struct ast_set_party_id ani; /*! What private connected line id information to set. */ struct ast_set_party_id priv; }; /*! * \since 1.8 * \brief Redirecting Line information. * RDNIS (Redirecting Directory Number Information Service) * Where a call diversion or transfer was invoked. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * \note NULL and "" must be considered equivalent. */ struct ast_party_redirecting { /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */ struct ast_party_id orig; /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */ struct ast_party_id from; /*! \brief Call is redirecting to a new party (Sent to the caller) */ struct ast_party_id to; /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) - private representation */ struct ast_party_id priv_orig; /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) - private representation */ struct ast_party_id priv_from; /*! \brief Call is redirecting to a new party (Sent to the caller) - private representation */ struct ast_party_id priv_to; /*! \brief Number of times the call was redirected */ int count; /*! \brief enum AST_REDIRECTING_REASON value for redirection */ int reason; /*! \brief enum AST_REDIRECTING_REASON value for redirection by original party */ int orig_reason; }; /*! * \since 1.8 * \brief Indicate what information in ast_party_redirecting should be set. */ struct ast_set_party_redirecting { /*! What redirecting-orig id information to set. */ struct ast_set_party_id orig; /*! What redirecting-from id information to set. */ struct ast_set_party_id from; /*! What redirecting-to id information to set. */ struct ast_set_party_id to; /*! What private redirecting-orig id information to set. */ struct ast_set_party_id priv_orig; /*! What private redirecting-from id information to set. */ struct ast_set_party_id priv_from; /*! What private redirecting-to id information to set. */ struct ast_set_party_id priv_to; }; /*! * \brief Typedef for a custom read function * \note data should be treated as const char *. */ typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len); /*! * \brief Typedef for a custom read2 function * \note data should be treated as const char *. */ typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len); /*! * \brief Typedef for a custom write function * \note data should be treated as const char *. */ typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value); /*! \brief Structure to handle passing func_channel_write info to channels via setoption */ typedef struct { /*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */ #define AST_CHAN_WRITE_INFO_T_VERSION 1 uint32_t version; ast_acf_write_fn_t write_fn; struct ast_channel *chan; const char *function; char *data; const char *value; } ast_chan_write_info_t; /*! * \brief * Structure to describe a channel "technology", ie a channel driver * See for examples: * \arg chan_iax2.c - The Inter-Asterisk exchange protocol * \arg chan_sip.c - The SIP channel driver * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS) * * \details * If you develop your own channel driver, this is where you * tell the PBX at registration of your driver what properties * this driver supports and where different callbacks are * implemented. */ struct ast_channel_tech { const char * const type; const char * const description; struct ast_format_cap *capabilities; /*!< format capabilities this channel can handle */ int properties; /*!< Technology Properties */ /*! * \brief Requester - to set up call data structures (pvt's) * * \param type type of channel to request * \param cap Format capabilities for requested channel * \param requestor channel asking for data * \param addr destination of the call * \param cause Cause of failure * * \details * Request a channel of a given type, with addr as optional information used * by the low level module * * \retval NULL failure * \retval non-NULL channel on success */ struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, int *cause); int (* const devicestate)(const char *device_number); /*!< Devicestate call back */ /*! * \brief Start sending a literal DTMF digit * * \note The channel is not locked when this function gets called. */ int (* const send_digit_begin)(struct ast_channel *chan, char digit); /*! * \brief Stop sending a literal DTMF digit * * \note The channel is not locked when this function gets called. */ int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration); /*! * \brief Make a call * \note The channel is locked when called. * \param chan which channel to make the call on * \param addr destination of the call * \param timeout time to wait on for connect (Doesn't seem to be used.) * \retval 0 on success * \retval -1 on failure */ int (* const call)(struct ast_channel *chan, const char *addr, int timeout); /*! \brief Hangup (and possibly destroy) the channel */ int (* const hangup)(struct ast_channel *chan); /*! \brief Answer the channel */ int (* const answer)(struct ast_channel *chan); /*! \brief Read a frame, in standard format (see frame.h) */ struct ast_frame * (* const read)(struct ast_channel *chan); /*! \brief Write a frame, in standard format (see frame.h) */ int (* const write)(struct ast_channel *chan, struct ast_frame *frame); /*! \brief Display or transmit text */ int (* const send_text)(struct ast_channel *chan, const char *text); /*! \brief Display or send an image */ int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame); /*! \brief Send HTML data */ int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len); /*! \brief Handle an exception, reading a frame */ struct ast_frame * (* const exception)(struct ast_channel *chan); /*! \brief Bridge two channels of the same type together */ enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms); /*! \brief Bridge two channels of the same type together (early) */ enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1); /*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */ int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen); /*! \brief Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links */ int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan); /*! \brief Set a given option. Called with chan locked */ int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen); /*! \brief Query a given option. Called with chan locked */ int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen); /*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */ int (* const transfer)(struct ast_channel *chan, const char *newdest); /*! \brief Write a frame, in standard format */ int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame); /*! \brief Write a text frame, in standard format */ int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame); /*! \brief Find bridged channel */ struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge); /*! * \brief Provide additional read items for CHANNEL() dialplan function * \note data should be treated as a const char *. */ int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len); /*! * \brief Provide additional write items for CHANNEL() dialplan function * \note data should be treated as a const char *. */ int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value); /*! \brief Retrieve base channel (agent and local) */ struct ast_channel* (* get_base_channel)(struct ast_channel *chan); /*! \brief Set base channel (agent and local) */ int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base); /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */ const char * (* get_pvt_uniqueid)(struct ast_channel *chan); /*! \brief Call a function with cc parameters as a function parameter * * \details * This is a highly specialized callback that is not likely to be needed in many * channel drivers. When dealing with a busy channel, for instance, most channel * drivers will successfully return a channel to the requester. Once called, the channel * can then queue a busy frame when it receives an appropriate message from the far end. * In such a case, the channel driver has the opportunity to also queue a CC frame. * The parameters for the CC channel can be retrieved from the channel structure. * * For other channel drivers, notably those that deal with "dumb" phones, the channel * driver will not return a channel when one is requested. In such a scenario, there is never * an opportunity for the channel driver to queue a CC frame since the channel is never * called. Furthermore, it is not possible to retrieve the CC configuration parameters * for the desired channel because no channel is ever allocated or returned to the * requester. In such a case, call completion may still be a viable option. What we do is * pass the same string that the requester used originally to request the channel to the * channel driver. The channel driver can then find any potential channels/devices that * match the input and return call the designated callback with the device's call completion * parameters as a parameter. */ int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback); /*! * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed. * \since 11.0 * * \param chan Channel to execute Gosub in a tech specific way. * \param sub_args Gosub application parameter string. * * \note The chan is locked before calling. * * \retval 0 on success. * \retval -1 on error. */ int (*pre_call)(struct ast_channel *chan, const char *sub_args); }; /*! Kill the channel channel driver technology descriptor. */ extern const struct ast_channel_tech ast_kill_tech; struct ast_epoll_data; /*! * The high bit of the frame count is used as a debug marker, so * increments of the counters must be done with care. * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout. */ #define DEBUGCHAN_FLAG 0x80000000 /* XXX not ideal to evaluate x twice... */ #define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) ) /*! * The current value of the debug flags is stored in the two * variables global_fin and global_fout (declared in main/channel.c) */ extern unsigned long global_fin, global_fout; enum ast_channel_adsicpe { AST_ADSI_UNKNOWN, AST_ADSI_AVAILABLE, AST_ADSI_UNAVAILABLE, AST_ADSI_OFFHOOKONLY, }; /*! * \brief Possible T38 states on channels */ enum ast_t38_state { T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */ T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */ T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */ T38_STATE_REJECTED, /*!< Remote side has rejected our offer */ T38_STATE_NEGOTIATED, /*!< T38 established */ }; /*! Hangup handler instance node. */ struct ast_hangup_handler { /*! Next hangup handler node. */ AST_LIST_ENTRY(ast_hangup_handler) node; /*! Hangup handler arg string passed to the Gosub application */ char args[0]; }; AST_LIST_HEAD_NOLOCK(ast_hangup_handler_list, ast_hangup_handler); AST_LIST_HEAD_NOLOCK(ast_datastore_list, ast_datastore); AST_LIST_HEAD_NOLOCK(ast_autochan_list, ast_autochan); AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame); typedef int(*ast_timing_func_t)(const void *data); /*! * \page AstChannel ast_channel locking and reference tracking * * \par Creating Channels * A channel is allocated using the ast_channel_alloc() function. When created, it is * automatically inserted into the main channels hash table that keeps track of all * active channels in the system. The hash key is based on the channel name. Because * of this, if you want to change the name, you _must_ use ast_change_name(), not change * the name field directly. When ast_channel_alloc() returns a channel pointer, you now * hold a reference to that channel. In most cases this reference is given to ast_pbx_run(). * * \par Channel Locking * There is a lock associated with every ast_channel. It is allocated internally via astobj2. * To lock or unlock a channel, you must use the ast_channel_lock() wrappers. * * Previously, before ast_channel was converted to astobj2, the channel lock was used in some * additional ways that are no longer necessary. Before, the only way to ensure that a channel * did not disappear out from under you if you were working with a channel outside of the channel * thread that owns it, was to hold the channel lock. Now, that is no longer necessary. * You simply must hold a reference to the channel to ensure it does not go away. * * The channel must be locked if you need to ensure that data that you reading from the channel * does not change while you access it. Further, you must hold the channel lock if you are * making a non-atomic change to channel data. * * \par Channel References * There are multiple ways to get a reference to a channel. The first is that you hold a reference * to a channel after creating it. The other ways involve using the channel search or the channel * traversal APIs. These functions are the ast_channel_get_*() functions or ast_channel_iterator_*() * functions. Once a reference is retrieved by one of these methods, you know that the channel will * not go away. So, the channel should only get locked as needed for data access or modification. * But, make sure that the reference gets released when you are done with it! * * There are different things you can do when you are done with a reference to a channel. The first * is to simply release the reference using ast_channel_unref(). The other option is to call * ast_channel_release(). This function is generally used where ast_channel_free() was used in * the past. The release function releases a reference as well as ensures that the channel is no * longer in the global channels container. That way, the channel will get destroyed as soon as any * other pending references get released. * * \par Exceptions to the rules * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel * get stored, but the reference count does not reflect it. The reason is mostly historical. * The only places where this happens should be places where because of how the code works, we * _know_ that the pointer to the channel will get removed before the channel goes away. The main * example of this is in channel drivers. Channel drivers generally store a pointer to their owner * ast_channel in their technology specific pvt struct. In this case, the channel drivers _know_ * that this pointer to the channel will be removed in time, because the channel's hangup callback * gets called before the channel goes away. */ struct ast_channel; /*! \brief ast_channel_tech Properties */ enum { /*! * \brief Channels have this property if they can accept input with jitter; * i.e. most VoIP channels */ AST_CHAN_TP_WANTSJITTER = (1 << 0), /*! * \brief Channels have this property if they can create jitter; * i.e. most VoIP channels */ AST_CHAN_TP_CREATESJITTER = (1 << 1), }; /*! \brief ast_channel flags */ enum { /*! Queue incoming DTMF, to be released when this flag is turned off */ AST_FLAG_DEFER_DTMF = (1 << 1), /*! write should be interrupt generator */ AST_FLAG_WRITE_INT = (1 << 2), /*! a thread is blocking on this channel */ AST_FLAG_BLOCKING = (1 << 3), /*! This is a zombie channel */ AST_FLAG_ZOMBIE = (1 << 4), /*! There is an exception pending */ AST_FLAG_EXCEPTION = (1 << 5), /*! Listening to moh XXX anthm promises me this will disappear XXX */ AST_FLAG_MOH = (1 << 6), /*! This channel is spying on another channel */ AST_FLAG_SPYING = (1 << 7), /*! This channel is in a native bridge */ AST_FLAG_NBRIDGE = (1 << 8), /*! the channel is in an auto-incrementing dialplan processor, * so when ->priority is set, it will get incremented before * finding the next priority to run */ AST_FLAG_IN_AUTOLOOP = (1 << 9), /*! This is an outgoing call */ AST_FLAG_OUTGOING = (1 << 10), /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */ AST_FLAG_IN_DTMF = (1 << 12), /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is * currently being emulated */ AST_FLAG_EMULATE_DTMF = (1 << 13), /*! This is set to tell the channel not to generate DTMF begin frames, and * to instead only generate END frames. */ AST_FLAG_END_DTMF_ONLY = (1 << 14), /* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE Flag to show channels that this call is hangup due to the fact that the call was indeed answered, but in another channel */ /* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */ /*! This flag indicates that on a masquerade, an active stream should not * be carried over */ AST_FLAG_MASQ_NOSTREAM = (1 << 16), /*! This flag indicates that the hangup exten was run when the bridge terminated, * a message aimed at preventing a subsequent hangup exten being run at the pbx_run * level */ AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17), /*! This flag indicates that the hangup exten should NOT be run when the * bridge terminates, this will allow the hangup in the pbx loop to be run instead. * */ AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18), /*! Disable certain workarounds. This reintroduces certain bugs, but allows * some non-traditional dialplans (like AGI) to continue to function. */ AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20), /*! * Disable device state event caching. This allows channel * drivers to selectively prevent device state events from being * cached by certain channels such as anonymous calls which have * no persistent represenatation that can be tracked. */ AST_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21), /*! * This flag indicates that a dual channel redirect is in * progress. The bridge needs to wait until the flag is cleared * to continue. */ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT = (1 << 22), }; /*! \brief ast_bridge_config flags */ enum { AST_FEATURE_PLAY_WARNING = (1 << 0), AST_FEATURE_REDIRECT = (1 << 1), AST_FEATURE_DISCONNECT = (1 << 2), AST_FEATURE_ATXFER = (1 << 3), AST_FEATURE_AUTOMON = (1 << 4), AST_FEATURE_PARKCALL = (1 << 5), AST_FEATURE_AUTOMIXMON = (1 << 6), AST_FEATURE_NO_H_EXTEN = (1 << 7), AST_FEATURE_WARNING_ACTIVE = (1 << 8), }; /*! \brief bridge configuration */ struct ast_bridge_config { struct ast_flags features_caller; struct ast_flags features_callee; struct timeval start_time; struct timeval nexteventts; struct timeval feature_start_time; long feature_timer; long timelimit; long play_warning; long warning_freq; const char *warning_sound; const char *end_sound; const char *start_sound; unsigned int flags; void (* end_bridge_callback)(void *); /*!< A callback that is called after a bridge attempt */ void *end_bridge_callback_data; /*!< Data passed to the callback */ /*! If the end_bridge_callback_data refers to a channel which no longer is going to * exist when the end_bridge_callback is called, then it needs to be fixed up properly */ void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator); }; struct chanmon; struct outgoing_helper { const char *context; const char *exten; int priority; int connect_on_early_media; /* If set, treat session progress as answer */ const char *cid_num; const char *cid_name; const char *account; struct ast_variable *vars; struct ast_channel *parent_channel; }; enum { /*! * Soft hangup requested by device or other internal reason. * Actual hangup needed. */ AST_SOFTHANGUP_DEV = (1 << 0), /*! * Used to break the normal frame flow so an async goto can be * done instead of actually hanging up. */ AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), /*! * Soft hangup requested by system shutdown. Actual hangup * needed. */ AST_SOFTHANGUP_SHUTDOWN = (1 << 2), /*! * Used to break the normal frame flow after a timeout so an * implicit async goto can be done to the 'T' exten if it exists * instead of actually hanging up. If the exten does not exist * then actually hangup. */ AST_SOFTHANGUP_TIMEOUT = (1 << 3), /*! * Soft hangup requested by application/channel-driver being * unloaded. Actual hangup needed. */ AST_SOFTHANGUP_APPUNLOAD = (1 << 4), /*! * Soft hangup requested by non-associated party. Actual hangup * needed. */ AST_SOFTHANGUP_EXPLICIT = (1 << 5), /*! * Used to break a bridge so the channel can be spied upon * instead of actually hanging up. */ AST_SOFTHANGUP_UNBRIDGE = (1 << 6), /*! * \brief All softhangup flags. * * This can be used as an argument to ast_channel_clear_softhangup() * to clear all softhangup flags from a channel. */ AST_SOFTHANGUP_ALL = (0xFFFFFFFF) }; /*! \brief Channel reload reasons for manager events at load or reload of configuration */ enum channelreloadreason { CHANNEL_MODULE_LOAD, CHANNEL_MODULE_RELOAD, CHANNEL_CLI_RELOAD, CHANNEL_MANAGER_RELOAD, CHANNEL_ACL_RELOAD, }; /*! * \note None of the datastore API calls lock the ast_channel they are using. * So, the channel should be locked before calling the functions that * take a channel argument. */ /*! * \brief Create a channel data store object * \deprecated You should use the ast_datastore_alloc() generic function instead. * \version 1.6.1 deprecated */ struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid) __attribute__((deprecated)); /*! * \brief Free a channel data store object * \deprecated You should use the ast_datastore_free() generic function instead. * \version 1.6.1 deprecated */ int ast_channel_datastore_free(struct ast_datastore *datastore) __attribute__((deprecated)); /*! \brief Inherit datastores from a parent to a child. */ int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to); /*! * \brief Add a datastore to a channel * * \note The channel should be locked before calling this function. * * \retval 0 success * \retval non-zero failure */ int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore); /*! * \brief Remove a datastore from a channel * * \note The channel should be locked before calling this function. * * \retval 0 success * \retval non-zero failure */ int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore); /*! * \brief Find a datastore on a channel * * \note The channel should be locked before calling this function. * * \note The datastore returned from this function must not be used if the * reference to the channel is released. * * \retval pointer to the datastore if found * \retval NULL if not found */ struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid); /*! * \brief Create a channel structure * \since 1.8 * * \retval NULL failure * \retval non-NULL successfully allocated channel * * \note Absolutely _NO_ channel locks should be held before calling this function. * \note By default, new channels are set to the "s" extension * and "default" context. */ struct ast_channel * attribute_malloc __attribute__((format(printf, 13, 14))) __ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt, ...); /*! * \brief Create a channel structure * * \retval NULL failure * \retval non-NULL successfully allocated channel * * \note Absolutely _NO_ channel locks should be held before calling this function. * \note By default, new channels are set to the "s" extension * and "default" context. */ #define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, ...) \ __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, \ __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) #if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC) /*! * \brief Create a fake channel structure * * \retval NULL failure * \retval non-NULL successfully allocated channel * * \note This function should ONLY be used to create a fake channel * that can then be populated with data for use in variable * substitution when a real channel does not exist. * * \note The created dummy channel should be destroyed by * ast_channel_unref(). Using ast_channel_release() needlessly * grabs the channel container lock and can cause a deadlock as * a result. Also grabbing the channel container lock reduces * system performance. */ #define ast_dummy_channel_alloc() __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__) struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function); #else /*! * \brief Create a fake channel structure * * \retval NULL failure * \retval non-NULL successfully allocated channel * * \note This function should ONLY be used to create a fake channel * that can then be populated with data for use in variable * substitution when a real channel does not exist. * * \note The created dummy channel should be destroyed by * ast_channel_unref(). Using ast_channel_release() needlessly * grabs the channel container lock and can cause a deadlock as * a result. Also grabbing the channel container lock reduces * system performance. */ struct ast_channel *ast_dummy_channel_alloc(void); #endif /*! * \brief Queue one or more frames to a channel's frame queue * * \param chan the channel to queue the frame(s) on * \param f the frame(s) to queue. Note that the frame(s) will be duplicated * by this function. It is the responsibility of the caller to handle * freeing the memory associated with the frame(s) being passed if * necessary. * * \retval 0 success * \retval non-zero failure */ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f); /*! * \brief Queue one or more frames to the head of a channel's frame queue * * \param chan the channel to queue the frame(s) on * \param f the frame(s) to queue. Note that the frame(s) will be duplicated * by this function. It is the responsibility of the caller to handle * freeing the memory associated with the frame(s) being passed if * necessary. * * \retval 0 success * \retval non-zero failure */ int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f); /*! * \brief Queue a hangup frame * * \note The channel does not need to be locked before calling this function. */ int ast_queue_hangup(struct ast_channel *chan); /*! * \brief Queue a hangup frame with hangupcause set * * \note The channel does not need to be locked before calling this function. * \param[in] chan channel to queue frame onto * \param[in] cause the hangup cause * \return 0 on success, -1 on error * \since 1.6.1 */ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause); /*! * \brief Queue a control frame with payload * * \param chan channel to queue frame onto * \param control type of control frame * * \note The channel does not need to be locked before calling this function. * * \retval zero on success * \retval non-zero on failure */ int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control); /*! * \brief Queue a control frame with payload * * \param chan channel to queue frame onto * \param control type of control frame * \param data pointer to payload data to be included in frame * \param datalen number of bytes of payload data * * \retval 0 success * \retval non-zero failure * * \details * The supplied payload data is copied into the frame, so the caller's copy * is not modified nor freed, and the resulting frame will retain a copy of * the data even if the caller frees their local copy. * * \note This method should be treated as a 'network transport'; in other * words, your frames may be transferred across an IAX2 channel to another * system, which may be a different endianness than yours. Because of this, * you should ensure that either your frames will never be expected to work * across systems, or that you always put your payload data into 'network byte * order' before calling this function. * * \note The channel does not need to be locked before calling this function. */ int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen); /*! * \brief Change channel name * * \pre Absolutely all channels _MUST_ be unlocked before calling this function. * * \param chan the channel to change the name of * \param newname the name to change to * * \return nothing * * \note this function must _NEVER_ be used when any channels are locked * regardless if it is the channel who's name is being changed or not because * it invalidates our channel container locking order... lock container first, * then the individual channels, never the other way around. */ void ast_change_name(struct ast_channel *chan, const char *newname); /*! * \brief Unlink and release reference to a channel * * This function will unlink the channel from the global channels container * if it is still there and also release the current reference to the channel. * * \return NULL, convenient for clearing invalid pointers * \note Absolutely _NO_ channel locks should be held before calling this function. * * \since 1.8 */ struct ast_channel *ast_channel_release(struct ast_channel *chan); /*! * \brief Requests a channel * * \param type type of channel to request * \param request_cap Format capabilities for requested channel * \param requestor channel asking for data * \param addr destination of the call * \param cause Cause of failure * * \details * Request a channel of a given type, with addr as optional information used * by the low level module * * \retval NULL failure * \retval non-NULL channel on success */ struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_channel *requestor, const char *addr, int *cause); /*! * \brief Request a channel of a given type, with data as optional information used * by the low level module and attempt to place a call on it * * \param type type of channel to request * \param format capabilities for requested channel * \param requestor channel asking for data * \param addr destination of the call * \param timeout maximum amount of time to wait for an answer * \param reason why unsuccessful (if unsuccessful) * \param cid_num Caller-ID Number * \param cid_name Caller-ID Name (ascii) * * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state * to know if the call was answered or not. */ struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, int timeout, int *reason, const char *cid_num, const char *cid_name); /*! * \brief Request a channel of a given type, with data as optional information used * by the low level module and attempt to place a call on it * \param type type of channel to request * \param format capabilities for requested channel * \param requestor channel requesting data * \param addr destination of the call * \param timeout maximum amount of time to wait for an answer * \param reason why unsuccessful (if unsuccessful) * \param cid_num Caller-ID Number * \param cid_name Caller-ID Name (ascii) * \param oh Outgoing helper * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state * to know if the call was answered or not. */ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh); /*! * \brief Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated. * \param caller in channel that requested orig * \param orig channel being replaced by the call forward channel * \param timeout maximum amount of time to wait for setup of new forward channel * \param format capabilities for requested channel * \param oh outgoing helper used with original channel * \param outstate reason why unsuccessful (if uncuccessful) * \return Returns the forwarded call's ast_channel on success or NULL on failure */ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate); /*! * \brief Register a channel technology (a new channel driver) * Called by a channel module to register the kind of channels it supports. * \param tech Structure defining channel technology or "type" * \return Returns 0 on success, -1 on failure. */ int ast_channel_register(const struct ast_channel_tech *tech); /*! * \brief Unregister a channel technology * \param tech Structure defining channel technology or "type" that was previously registered * \return No return value. */ void ast_channel_unregister(const struct ast_channel_tech *tech); /*! * \brief Get a channel technology structure by name * \param name name of technology to find * \return a pointer to the structure, or NULL if no matching technology found */ const struct ast_channel_tech *ast_get_channel_tech(const char *name); #ifdef CHANNEL_TRACE /*! * \brief Update the context backtrace if tracing is enabled * \return Returns 0 on success, -1 on failure */ int ast_channel_trace_update(struct ast_channel *chan); /*! * \brief Enable context tracing in the channel * \return Returns 0 on success, -1 on failure */ int ast_channel_trace_enable(struct ast_channel *chan); /*! * \brief Disable context tracing in the channel. * \note Does not remove current trace entries * \return Returns 0 on success, -1 on failure */ int ast_channel_trace_disable(struct ast_channel *chan); /*! * \brief Whether or not context tracing is enabled * \return Returns -1 when the trace is enabled. 0 if not. */ int ast_channel_trace_is_enabled(struct ast_channel *chan); /*! * \brief Put the channel backtrace in a string * \return Returns the amount of lines in the backtrace. -1 on error. */ int ast_channel_trace_serialize(struct ast_channel *chan, struct ast_str **out); #endif /*! * \brief Hang up a channel * \note Absolutely _NO_ channel locks should be held before calling this function. * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function * performs all stream stopping, etc, on the channel that needs to end. * chan is no longer valid after this call. * \param chan channel to hang up * \return Returns 0 on success, -1 on failure. */ int ast_hangup(struct ast_channel *chan); /*! * \brief Softly hangup up a channel * * \param chan channel to be soft-hung-up * \param reason an AST_SOFTHANGUP_* reason code * * \details * Call the protocol layer, but don't destroy the channel structure * (use this if you are trying to * safely hangup a channel managed by another thread. * * \note The channel passed to this function does not need to be locked. * * \return Returns 0 regardless */ int ast_softhangup(struct ast_channel *chan, int reason); /*! * \brief Softly hangup up a channel (no channel lock) * \param chan channel to be soft-hung-up * \param reason an AST_SOFTHANGUP_* reason code */ int ast_softhangup_nolock(struct ast_channel *chan, int reason); /*! * \brief Clear a set of softhangup flags from a channel * * Never clear a softhangup flag from a channel directly. Instead, * use this function. This ensures that all aspects of the softhangup * process are aborted. * * \param chan the channel to clear the flag on * \param flag the flag or flags to clear * * \return Nothing. */ void ast_channel_clear_softhangup(struct ast_channel *chan, int flag); /*! * \brief Set the source of the hangup in this channel and it's bridge * * \param chan channel to set the field on * \param source a string describing the source of the hangup for this channel * \param force * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \since 1.8 * * Hangupsource is generally the channel name that caused the bridge to be * hung up, but it can also be other things such as "dialplan/agi" * This can then be logged in the CDR or CEL */ void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force); /*! \brief Check to see if a channel is needing hang up * \param chan channel on which to check for hang up * This function determines if the channel is being requested to be hung up. * \return Returns 0 if not, or 1 if hang up is requested (including time-out). */ int ast_check_hangup(struct ast_channel *chan); int ast_check_hangup_locked(struct ast_channel *chan); /*! * \brief Lock the given channel, then request softhangup on the channel with the given causecode * \param chan channel on which to hang up * \param causecode cause code to use (Zero if don't use cause code) * \return Nothing */ void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode); /*! * \brief Compare a offset with the settings of when to hang a channel up * \param chan channel on which to check for hang up * \param offset offset in seconds from current time * \return 1, 0, or -1 * \details * This function compares a offset from current time with the absolute time * out on a channel (when to hang up). If the absolute time out on a channel * is earlier than current time plus the offset, it returns 1, if the two * time values are equal, it return 0, otherwise, it return -1. * \sa ast_channel_cmpwhentohangup_tv() * \version 1.6.1 deprecated function (only had seconds precision) */ int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated)); /*! * \brief Compare a offset with the settings of when to hang a channel up * \param chan channel on which to check for hangup * \param offset offset in seconds and microseconds from current time * \return 1, 0, or -1 * This function compares a offset from current time with the absolute time * out on a channel (when to hang up). If the absolute time out on a channel * is earlier than current time plus the offset, it returns 1, if the two * time values are equal, it return 0, otherwise, it return -1. * \since 1.6.1 */ int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset); /*! * \brief Set when to hang a channel up * * \param chan channel on which to check for hang up * \param offset offset in seconds relative to the current time of when to hang up * * \details * This function sets the absolute time out on a channel (when to hang up). * * \note This function does not require that the channel is locked before * calling it. * * \return Nothing * \sa ast_channel_setwhentohangup_tv() * \version 1.6.1 deprecated function (only had seconds precision) */ void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated)); /*! * \brief Set when to hang a channel up * * \param chan channel on which to check for hang up * \param offset offset in seconds and useconds relative to the current time of when to hang up * * This function sets the absolute time out on a channel (when to hang up). * * \note This function does not require that the channel is locked before * calling it. * * \return Nothing * \since 1.6.1 */ void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset); /*! * \brief Answer a channel * * \param chan channel to answer * * \details * This function answers a channel and handles all necessary call * setup functions. * * \note The channel passed does not need to be locked, but is locked * by the function when needed. * * \note This function will wait up to 500 milliseconds for media to * arrive on the channel before returning to the caller, so that the * caller can properly assume the channel is 'ready' for media flow. * * \retval 0 on success * \retval non-zero on failure */ int ast_answer(struct ast_channel *chan); /*! * \brief Answer a channel * * \param chan channel to answer * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered' * * This function answers a channel and handles all necessary call * setup functions. * * \note The channel passed does not need to be locked, but is locked * by the function when needed. * * \note Unlike ast_answer(), this function will not wait for media * flow to begin. The caller should be careful before sending media * to the channel before incoming media arrives, as the outgoing * media may be lost. * * \retval 0 on success * \retval non-zero on failure */ int ast_raw_answer(struct ast_channel *chan, int cdr_answer); /*! * \brief Answer a channel, with a selectable delay before returning * * \param chan channel to answer * \param delay maximum amount of time to wait for incoming media * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered' * * This function answers a channel and handles all necessary call * setup functions. * * \note The channel passed does not need to be locked, but is locked * by the function when needed. * * \note This function will wait up to 'delay' milliseconds for media to * arrive on the channel before returning to the caller, so that the * caller can properly assume the channel is 'ready' for media flow. If * 'delay' is less than 500, the function will wait up to 500 milliseconds. * * \retval 0 on success * \retval non-zero on failure */ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer); /*! * \brief Execute a Gosub call on the channel before a call is placed. * \since 11.0 * * \details * This is called between ast_request() and ast_call() to * execute a predial routine on the newly created channel. * * \param chan Channel to execute Gosub. * \param sub_args Gosub application parameter string. * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \retval 0 on success. * \retval -1 on error. */ int ast_pre_call(struct ast_channel *chan, const char *sub_args); /*! * \brief Make a call * \note Absolutely _NO_ channel locks should be held before calling this function. * \param chan which channel to make the call on * \param addr destination of the call * \param timeout time to wait on for connect (Doesn't seem to be used.) * \details * Place a call, take no longer than timeout ms. * \retval 0 on success * \retval -1 on failure */ int ast_call(struct ast_channel *chan, const char *addr, int timeout); /*! * \brief Indicates condition of channel * \note Absolutely _NO_ channel locks should be held before calling this function. * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel * \param chan channel to change the indication * \param condition which condition to indicate on the channel * \return Returns 0 on success, -1 on failure */ int ast_indicate(struct ast_channel *chan, int condition); /*! * \brief Indicates condition of channel, with payload * \note Absolutely _NO_ channel locks should be held before calling this function. * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class * \param chan channel to change the indication * \param condition which condition to indicate on the channel * \param data pointer to payload data * \param datalen size of payload data * \return Returns 0 on success, -1 on failure */ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen); /* Misc stuff ------------------------------------------------ */ /*! * \brief Wait for input on a channel * \param chan channel to wait on * \param ms length of time to wait on the channel * \details * Wait for input on a channel for a given # of milliseconds (<0 for indefinite). * \retval < 0 on failure * \retval 0 if nothing ever arrived * \retval the # of ms remaining otherwise */ int ast_waitfor(struct ast_channel *chan, int ms); /*! * \brief Should we keep this frame for later? * * There are functions such as ast_safe_sleep which will * service a channel to ensure that it does not have a * large backlog of queued frames. When this happens, * we want to hold on to specific frame types and just drop * others. This function will tell if the frame we just * read should be held onto. * * \param frame The frame we just read * \retval 1 frame should be kept * \retval 0 frame should be dropped */ int ast_is_deferrable_frame(const struct ast_frame *frame); /*! * \brief Wait for a specified amount of time, looking for hangups * \param chan channel to wait for * \param ms length of time in milliseconds to sleep. This should never be less than zero. * \details * Waits for a specified amount of time, servicing the channel as required. * \return returns -1 on hangup, otherwise 0. */ int ast_safe_sleep(struct ast_channel *chan, int ms); /*! * \brief Wait for a specified amount of time, looking for hangups and a condition argument * \param chan channel to wait for * \param ms length of time in milliseconds to sleep. * \param cond a function pointer for testing continue condition * \param data argument to be passed to the condition test function * \return returns -1 on hangup, otherwise 0. * \details * Waits for a specified amount of time, servicing the channel as required. If cond * returns 0, this function returns. */ int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data ); /*! * \brief Waits for activity on a group of channels * \param chan an array of pointers to channels * \param n number of channels that are to be waited upon * \param fds an array of fds to wait upon * \param nfds the number of fds to wait upon * \param exception exception flag * \param outfd fd that had activity on it * \param ms how long the wait was * \details * Big momma function here. Wait for activity on any of the n channels, or any of the nfds * file descriptors. * \return Returns the channel with activity, or NULL on error or if an FD * came first. If the FD came first, it will be returned in outfd, otherwise, outfd * will be -1 */ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms); /*! * \brief Waits for input on a group of channels * Wait for input on an array of channels for a given # of milliseconds. * \return Return channel with activity, or NULL if none has activity. * \param chan an array of pointers to channels * \param n number of channels that are to be waited upon * \param ms time "ms" is modified in-place, if applicable */ struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms); /*! * \brief Waits for input on an fd * \note This version works on fd's only. Be careful with it. */ int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception); /*! * \brief Reads a frame * \param chan channel to read a frame from * \return Returns a frame, or NULL on error. If it returns NULL, you * best just stop reading frames and assume the channel has been * disconnected. */ struct ast_frame *ast_read(struct ast_channel *chan); /*! * \brief Reads a frame, returning AST_FRAME_NULL frame if audio. * \param chan channel to read a frame from * \return Returns a frame, or NULL on error. If it returns NULL, you * best just stop reading frames and assume the channel has been * disconnected. * \note Audio is replaced with AST_FRAME_NULL to avoid * transcode when the resulting audio is not necessary. */ struct ast_frame *ast_read_noaudio(struct ast_channel *chan); /*! * \brief Write a frame to a channel * This function writes the given frame to the indicated channel. * \param chan destination channel of the frame * \param frame frame that will be written * \return It returns 0 on success, -1 on failure. */ int ast_write(struct ast_channel *chan, struct ast_frame *frame); /*! * \brief Write video frame to a channel * This function writes the given frame to the indicated channel. * \param chan destination channel of the frame * \param frame frame that will be written * \return It returns 1 on success, 0 if not implemented, and -1 on failure. */ int ast_write_video(struct ast_channel *chan, struct ast_frame *frame); /*! * \brief Write text frame to a channel * This function writes the given frame to the indicated channel. * \param chan destination channel of the frame * \param frame frame that will be written * \return It returns 1 on success, 0 if not implemented, and -1 on failure. */ int ast_write_text(struct ast_channel *chan, struct ast_frame *frame); /*! \brief Send empty audio to prime a channel driver */ int ast_prod(struct ast_channel *chan); /*! * \brief Sets read format on channel chan from capabilities * Set read format for channel to whichever component of "format" is best. * \param chan channel to change * \param formats new formats to pick from for reading * \return Returns 0 on success, -1 on failure */ int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats); /*! * \brief Sets read format on channel chan * \param chan channel to change * \param formats, format to set for reading * \return Returns 0 on success, -1 on failure */ int ast_set_read_format(struct ast_channel *chan, struct ast_format *format); /*! * \brief Sets read format on channel chan by id * \param chan channel to change * \param format id to set for reading, only used for formats without attributes * \return Returns 0 on success, -1 on failure */ int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id); /*! * \brief Sets write format on channel chan * Set write format for channel to whichever component of "format" is best. * \param chan channel to change * \param formats new formats to pick from for writing * \return Returns 0 on success, -1 on failure */ int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats); /*! * \brief Sets write format on channel chan * \param chan channel to change * \param formats, format to set for writing * \return Returns 0 on success, -1 on failure */ int ast_set_write_format(struct ast_channel *chan, struct ast_format *format); /*! * \brief Sets write format on channel chan * \param chan channel to change * \param format id to set for writing, only used for formats without attributes * \return Returns 0 on success, -1 on failure */ int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id); /*! * \brief Sends text to a channel * * \param chan channel to act upon * \param text string of text to send on the channel * * \details * Write text to a display on a channel * * \note The channel does not need to be locked before calling this function. * * \retval 0 on success * \retval -1 on failure */ int ast_sendtext(struct ast_channel *chan, const char *text); /*! * \brief Receives a text character from a channel * \param chan channel to act upon * \param timeout timeout in milliseconds (0 for infinite wait) * \details * Read a char of text from a channel * \return 0 on success, -1 on failure */ int ast_recvchar(struct ast_channel *chan, int timeout); /*! * \brief Send a DTMF digit to a channel. * \param chan channel to act upon * \param digit the DTMF digit to send, encoded in ASCII * \param duration the duration of the digit ending in ms * \return 0 on success, -1 on failure */ int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration); /*! * \brief Send a DTMF digit to a channel. * \param chan channel to act upon * \param digit the DTMF digit to send, encoded in ASCII * \return 0 on success, -1 on failure */ int ast_senddigit_begin(struct ast_channel *chan, char digit); /*! * \brief Send a DTMF digit to a channel. * \param chan channel to act upon * \param digit the DTMF digit to send, encoded in ASCII * \param duration the duration of the digit ending in ms * \return Returns 0 on success, -1 on failure */ int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration); /*! * \brief Receives a text string from a channel * Read a string of text from a channel * \param chan channel to act upon * \param timeout timeout in milliseconds (0 for infinite wait) * \return the received text, or NULL to signify failure. */ char *ast_recvtext(struct ast_channel *chan, int timeout); /*! * \brief Waits for a digit * \param c channel to wait for a digit on * \param ms how many milliseconds to wait (<0 for indefinite). * \return Returns <0 on error, 0 on no entry, and the digit on success. */ int ast_waitfordigit(struct ast_channel *c, int ms); /*! * \brief Wait for a digit * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading. * \param c channel to wait for a digit on * \param ms how many milliseconds to wait (<0 for indefinite). * \param audiofd audio file descriptor to write to if audio frames are received * \param ctrlfd control file descriptor to monitor for reading * \return Returns 1 if ctrlfd becomes available */ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd); /*! * \brief Reads multiple digits * \param c channel to read from * \param s string to read in to. Must be at least the size of your length * \param len how many digits to read (maximum) * \param timeout how long to timeout between digits * \param rtimeout timeout to wait on the first digit * \param enders digits to end the string * \details * Read in a digit string "s", max length "len", maximum timeout between * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout * for the first digit. * \return Returns 0 on normal return, or 1 on a timeout. In the case of * a timeout, any digits that were read before the timeout will still be available in s. * RETURNS 2 in full version when ctrlfd is available, NOT 1 */ int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders); int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd); /*! \brief Report DTMF on channel 0 */ #define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0) /*! \brief Report DTMF on channel 1 */ #define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1) /*! \brief Return all voice frames on channel 0 */ #define AST_BRIDGE_REC_CHANNEL_0 (1 << 2) /*! \brief Return all voice frames on channel 1 */ #define AST_BRIDGE_REC_CHANNEL_1 (1 << 3) /*! \brief Ignore all signal frames except NULL */ #define AST_BRIDGE_IGNORE_SIGS (1 << 4) /*! * \brief Makes two channel formats compatible * \param c0 first channel to make compatible * \param c1 other channel to make compatible * \details * Set two channels to compatible formats -- call before ast_channel_bridge in general. * \return Returns 0 on success and -1 if it could not be done */ int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1); /*! * \brief Bridge two channels together (early) * \param c0 first channel to bridge * \param c1 second channel to bridge * \details * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet. * \return Returns 0 on success and -1 if it could not be done */ int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1); /*! * \brief Bridge two channels together * \param c0 first channel to bridge * \param c1 second channel to bridge * \param config config for the channels * \param fo destination frame(?) * \param rc destination channel(?) * \details * Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in * *rf (remember, it could be NULL) and which channel (0 or 1) in rc */ /* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */ int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc); /*! * \brief Weird function made for call transfers * * \param original channel to make a copy of * \param clone copy of the original channel * * \details * This is a very strange and freaky function used primarily for transfer. Suppose that * "original" and "clone" are two channels in random situations. This function takes * the guts out of "clone" and puts them into the "original" channel, then alerts the * channel driver of the change, asking it to fixup any private information (like the * p->owner pointer) that is affected by the change. The physical layer of the original * channel is hung up. * * \note Neither channel passed here should be locked before * calling this function. This function performs deadlock * avoidance involving these two channels. */ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone); /*! * \brief Setup a masquerade to transfer a call. * \since 1.8 * * \param target_chan Target of the call transfer. (Masquerade original channel) * \param target_id New connected line information for the target channel. * \param target_held TRUE if the target call is on hold. * \param transferee_chan Transferee of the call transfer. (Masquerade clone channel) * \param transferee_id New connected line information for the transferee channel. * \param transferee_held TRUE if the transferee call is on hold. * * \details * Party A - Transferee * Party B - Transferer * Party C - Target of transfer * * Party B transfers A to C. * * Party A is connected to bridged channel B1. * Party B is connected to channels C1 and C2. * Party C is connected to bridged channel B2. * * Party B -- C1 == B1 -- Party A * __/ * / * Party B -- C2 == B2 -- Party C * * Bridged channel B1 is masqueraded into channel C2. Where B1 * is the masquerade clone channel and C2 is the masquerade * original channel. * * \see ast_channel_masquerade() * * \note Has the same locking requirements as ast_channel_masquerade(). * * \retval 0 on success. * \retval -1 on error. */ int ast_channel_transfer_masquerade( struct ast_channel *target_chan, const struct ast_party_connected_line *target_id, int target_held, struct ast_channel *transferee_chan, const struct ast_party_connected_line *transferee_id, int transferee_held); /*! * \brief Gives the string form of a given cause code. * * \param state cause to get the description of * \return the text form of the binary cause code given */ const char *ast_cause2str(int state) attribute_pure; /*! * \brief Convert the string form of a cause code to a number * * \param name string form of the cause * \return the cause code */ int ast_str2cause(const char *name) attribute_pure; /*! * \brief Gives the string form of a given channel state * * \param ast_channel_state state to get the name of * \return the text form of the binary state given */ const char *ast_state2str(enum ast_channel_state); /*! * \brief Gives the string form of a given transfer capability * * \param transfercapability transfer capability to get the name of * \return the text form of the binary transfer capability */ char *ast_transfercapability2str(int transfercapability) attribute_const; /* * Options: Some low-level drivers may implement "options" allowing fine tuning of the * low level channel. See frame.h for options. Note that many channel drivers may support * none or a subset of those features, and you should not count on this if you want your * asterisk application to be portable. They're mainly useful for tweaking performance */ /*! * \brief Sets an option on a channel * * \param channel channel to set options on * \param option option to change * \param data data specific to option * \param datalen length of the data * \param block blocking or not * \details * Set an option on a channel (see frame.h), optionally blocking awaiting the reply * \return 0 on success and -1 on failure */ int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block); /*! * \brief Pick the best codec * * \param capabilities to pick best codec out of * \param result stucture to store the best codec in. * \retval on success, pointer to result structure * \retval on failure, NULL */ struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result); /*! * \brief Checks the value of an option * * Query the value of an option * Works similarly to setoption except only reads the options. */ int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block); /*! * \brief Checks for HTML support on a channel * \return 0 if channel does not support HTML or non-zero if it does */ int ast_channel_supports_html(struct ast_channel *channel); /*! * \brief Sends HTML on given channel * Send HTML or URL on link. * \return 0 on success or -1 on failure */ int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen); /*! * \brief Sends a URL on a given link * Send URL on link. * \return 0 on success or -1 on failure */ int ast_channel_sendurl(struct ast_channel *channel, const char *url); /*! * \brief Defers DTMF so that you only read things like hangups and audio. * \return non-zero if channel was already DTMF-deferred or * 0 if channel is just now being DTMF-deferred */ int ast_channel_defer_dtmf(struct ast_channel *chan); /*! Undo defer. ast_read will return any DTMF characters that were queued */ void ast_channel_undefer_dtmf(struct ast_channel *chan); /*! Initiate system shutdown -- prevents new channels from being allocated. * \param hangup If "hangup" is non-zero, all existing channels will receive soft * hangups */ void ast_begin_shutdown(int hangup); /*! Cancels an existing shutdown and returns to normal operation */ void ast_cancel_shutdown(void); /*! \return number of channels available for lookup */ int ast_active_channels(void); /*! \return the number of channels not yet destroyed */ int ast_undestroyed_channels(void); /*! \return non-zero if Asterisk is being shut down */ int ast_shutting_down(void); /*! Activate a given generator */ int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params); /*! Deactivate an active generator */ void ast_deactivate_generator(struct ast_channel *chan); /*! * \brief Set caller ID number, name and ANI and generate AMI event. * * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead. * \note The channel does not need to be locked before calling this function. */ void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani); /*! * \brief Set the caller id information in the Asterisk channel * \since 1.8 * * \param chan Asterisk channel to set caller id information * \param caller Caller id information * \param update What caller information to update. NULL if all. * * \return Nothing * * \note The channel does not need to be locked before calling this function. */ void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update); /*! * \brief Set the caller id information in the Asterisk channel and generate an AMI event * if the caller id name or number changed. * \since 1.8 * * \param chan Asterisk channel to set caller id information * \param caller Caller id information * \param update What caller information to update. NULL if all. * * \return Nothing * * \note The channel does not need to be locked before calling this function. */ void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update); /*! Set the file descriptor on the channel */ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd); /*! Add a channel to an optimized waitfor */ void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1); /*! Delete a channel from an optimized waitfor */ void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1); /*! Start a tone going */ int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol); /*! Stop a tone from playing */ void ast_tonepair_stop(struct ast_channel *chan); /*! Play a tone pair for a given amount of time */ int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol); /*! * \brief Automatically service a channel for us... * * \retval 0 success * \retval -1 failure, or the channel is already being autoserviced */ int ast_autoservice_start(struct ast_channel *chan); /*! * \brief Stop servicing a channel for us... * * \note if chan is locked prior to calling ast_autoservice_stop, it * is likely that there will be a deadlock between the thread that calls * ast_autoservice_stop and the autoservice thread. It is important * that chan is not locked prior to this call * * \param chan * \retval 0 success * \retval -1 error, or the channel has been hungup */ int ast_autoservice_stop(struct ast_channel *chan); /*! * \brief Put chan into autoservice while hanging up peer. * \since 11.0 * * \param chan Chan to put into autoservice. * \param peer Chan to run hangup handlers and hangup. * * \return Nothing */ void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer); /*! * \brief Ignore certain frame types * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames * while a channel is in autoservice and queue them up when taken out of * autoservice. When this is not desireable, this API may be used to * cause the channel to ignore those frametypes after the channel is put * into autoservice, but before autoservice is stopped. * \retval 0 success * \retval -1 channel is not in autoservice */ int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype); /*! * \brief Enable or disable timer ticks for a channel * * \param c channel * \param rate number of timer ticks per second * \param func callback function * \param data * * \details * If timers are supported, force a scheduled expiration on the * timer fd, at which point we call the callback function / data * * \note Call this function with a rate of 0 to turn off the timer ticks * * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods */ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data); /*! * \brief Transfer a channel (if supported). * \retval -1 on error * \retval 0 if not supported * \retval 1 if supported and requested * \param chan current channel * \param dest destination extension for transfer */ int ast_transfer(struct ast_channel *chan, char *dest); /*! * \brief Start masquerading a channel * \note absolutely _NO_ channel locks should be held before calling this function. * \details * XXX This is a seriously whacked out operation. We're essentially putting the guts of * the clone channel into the original channel. Start by killing off the original * channel's backend. I'm not sure we're going to keep this function, because * while the features are nice, the cost is very high in terms of pure nastiness. XXX * \param chan Channel to masquerade */ int ast_do_masquerade(struct ast_channel *chan); /*! * \brief Find bridged channel * * \note This function does _not_ return a reference to the bridged channel. * The reason for this is mostly historical. It _should_ return a reference, * but it will take a lot of work to make the code base account for that. * So, for now, the old rules still apply for how to handle this function. * If this function is being used from the channel thread that owns the channel, * then a reference is already held, and channel locking is not required to * guarantee that the channel will stay around. If this function is used * outside of the associated channel thread, the channel parameter 'chan' * MUST be locked before calling this function. Also, 'chan' must remain locked * for the entire time that the result of this function is being used. * * \param chan Current channel * * \return A pointer to the bridged channel */ struct ast_channel *ast_bridged_channel(struct ast_channel *chan); /*! * \brief Inherits channel variable from parent to child channel * \param parent Parent channel * \param child Child channel * * \details * Scans all channel variables in the parent channel, looking for those * that should be copied into the child channel. * Variables whose names begin with a single '_' are copied into the * child channel with the prefix removed. * Variables whose names begin with '__' are copied into the child * channel with their names unchanged. */ void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child); /*! * \brief adds a list of channel variables to a channel * \param chan the channel * \param vars a linked list of variables * * \details * Variable names can be for a regular channel variable or a dialplan function * that has the ability to be written to. */ void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars); /*! * \brief An opaque 'object' structure use by silence generators on channels. */ struct ast_silence_generator; /*! * \brief Starts a silence generator on the given channel. * \param chan The channel to generate silence on * \return An ast_silence_generator pointer, or NULL if an error occurs * * \details * This function will cause SLINEAR silence to be generated on the supplied * channel until it is disabled; if the channel cannot be put into SLINEAR * mode then the function will fail. * * \note * The pointer returned by this function must be preserved and passed to * ast_channel_stop_silence_generator when you wish to stop the silence * generation. */ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan); /*! * \brief Stops a previously-started silence generator on the given channel. * \param chan The channel to operate on * \param state The ast_silence_generator pointer return by a previous call to * ast_channel_start_silence_generator. * \return nothing * * \details * This function will stop the operating silence generator and return the channel * to its previous write format. */ void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state); /*! * \brief Check if the channel can run in internal timing mode. * \param chan The channel to check * \return boolean * * \details * This function will return 1 if internal timing is enabled and the timing * device is available. */ int ast_internal_timing_enabled(struct ast_channel *chan); /* Misc. functions below */ /*! * \brief if fd is a valid descriptor, set *pfd with the descriptor * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the * return value to the index into the array) */ static inline int ast_add_fd(struct pollfd *pfd, int fd) { pfd->fd = fd; pfd->events = POLLIN | POLLPRI; return fd >= 0; } /*! \brief Helper function for migrating select to poll */ static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start) { int x; int dummy = 0; if (fd < 0) return 0; if (!start) start = &dummy; for (x = *start; x < maximum; x++) if (pfds[x].fd == fd) { if (x == *start) (*start)++; return pfds[x].revents; } return 0; } /*! \brief Retrieves the current T38 state of a channel */ static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan) { enum ast_t38_state state = T38_STATE_UNAVAILABLE; int datalen = sizeof(state); ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0); return state; } #define CHECK_BLOCKING(c) do { \ if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\ ast_debug(1, "Thread %p is blocking '%s', already blocked by thread %p in procedure %s\n", \ (void *) pthread_self(), ast_channel_name(c), (void *) ast_channel_blocker(c), ast_channel_blockproc(c)); \ } else { \ ast_channel_blocker_set((c), pthread_self()); \ ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \ ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \ } } while (0) ast_group_t ast_get_group(const char *s); /*! \brief Print call and pickup groups into buffer */ char *ast_print_group(char *buf, int buflen, ast_group_t group); /*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */ struct ast_namedgroups; /*! \brief Create an ast_namedgroups set with group names from comma separated string */ struct ast_namedgroups *ast_get_namedgroups(const char *s); struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups); struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups); /*! \brief Return TRUE if group a and b contain at least one common groupname */ int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b); /*! \brief Print named call groups and named pickup groups */ char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups); /*! * \brief Convert enum channelreloadreason to text string for manager event * \param reason The reason for reload (manager, cli, start etc) */ const char *channelreloadreason2txt(enum channelreloadreason reason); /*! \brief return an ast_variable list of channeltypes */ struct ast_variable *ast_channeltype_list(void); /*! * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument * \param reason The integer argument, usually taken from AST_CONTROL_ macros * \return char pointer explaining the code */ const char *ast_channel_reason2str(int reason); /*! \brief channel group info */ struct ast_group_info { struct ast_channel *chan; char *category; char *group; AST_LIST_ENTRY(ast_group_info) group_list; }; #define ast_channel_lock(chan) ao2_lock(chan) #define ast_channel_unlock(chan) ao2_unlock(chan) #define ast_channel_trylock(chan) ao2_trylock(chan) /*! * \brief Lock two channels. */ #define ast_channel_lock_both(chan1, chan2) do { \ ast_channel_lock(chan1); \ while (ast_channel_trylock(chan2)) { \ ast_channel_unlock(chan1); \ sched_yield(); \ ast_channel_lock(chan1); \ } \ } while (0) /*! * \brief Increase channel reference count * * \param c the channel * * \retval c always * * \since 1.8 */ #define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); }) /*! * \brief Decrease channel reference count * * \param c the channel * * \retval NULL always * * \since 1.8 */ #define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); }) /*! Channel Iterating @{ */ /*! * \brief A channel iterator * * This is an opaque type. */ struct ast_channel_iterator; /*! * \brief Destroy a channel iterator * * \param i the itereator to destroy * * \details * This function is used to destroy a channel iterator that was retrieved by * using one of the channel_iterator_xxx_new() functions. * * \return NULL, for convenience to clear out the pointer to the iterator that * was just destroyed. * * \since 1.8 */ struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i); /*! * \brief Create a new channel iterator based on extension * * \param exten The extension that channels must be in * \param context The context that channels must be in * * \details * After creating an iterator using this function, the ast_channel_iterator_next() * function can be used to iterate through all channels that are currently * in the specified context and extension. * * \note You must call ast_channel_iterator_destroy() when done. * * \retval NULL on failure * \retval a new channel iterator based on the specified parameters * * \since 1.8 */ struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context); /*! * \brief Create a new channel iterator based on name * * \param name channel name or channel uniqueid to match * \param name_len number of characters in the channel name to match on. This * would be used to match based on name prefix. If matching on the full * channel name is desired, then this parameter should be 0. * * \details * After creating an iterator using this function, the ast_channel_iterator_next() * function can be used to iterate through all channels that exist that have * the specified name or name prefix. * * \note You must call ast_channel_iterator_destroy() when done. * * \retval NULL on failure * \retval a new channel iterator based on the specified parameters * * \since 1.8 */ struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len); /*! * \brief Create a new channel iterator * * \details * After creating an iterator using this function, the ast_channel_iterator_next() * function can be used to iterate through all channels that exist. * * \note You must call ast_channel_iterator_destroy() when done. * * \retval NULL on failure * \retval a new channel iterator * * \since 1.8 */ struct ast_channel_iterator *ast_channel_iterator_all_new(void); /*! * \brief Get the next channel for a channel iterator * * \param i the channel iterator that was created using one of the * channel_iterator_xxx_new() functions. * * \details * This function should be used to iterate through all channels that match a * specified set of parameters that were provided when the iterator was created. * * \retval the next channel that matches the parameters used when the iterator * was created. * \retval NULL, if no more channels match the iterator parameters. * * \since 1.8 */ struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i); /*! @} End channel iterator definitions. */ /*! * \brief Call a function with every active channel * * \details * This function executes a callback one time for each active channel on the * system. The channel is provided as an argument to the function. * * \note Absolutely _NO_ channel locks should be held before calling this function. * \since 1.8 */ struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags); /*! @{ Channel search functions */ /*! * \brief Find a channel by name * * \param name the name or uniqueid of the channel to search for * * \details * Find a channel that has the same name as the provided argument. * * \retval a channel with the name specified by the argument * \retval NULL if no channel was found * * \since 1.8 */ struct ast_channel *ast_channel_get_by_name(const char *name); /*! * \brief Find a channel by a name prefix * * \param name The channel name or uniqueid prefix to search for * \param name_len Only search for up to this many characters from the name * * \details * Find a channel that has the same name prefix as specified by the arguments. * * \retval a channel with the name prefix specified by the arguments * \retval NULL if no channel was found * * \since 1.8 */ struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len); /*! * \brief Find a channel by extension and context * * \param exten the extension to search for * \param context the context to search for * * \details * Return a channel that is currently at the specified extension and context. * * \retval a channel that is at the specified extension and context * \retval NULL if no channel was found * * \since 1.8 */ struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context); /*! @} End channel search functions. */ /*! \brief propagate the linked id between chan and peer */ void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer); /*! * \brief Initialize the given name structure. * \since 1.8 * * \param init Name structure to initialize. * * \return Nothing */ void ast_party_name_init(struct ast_party_name *init); /*! * \brief Copy the source party name information to the destination party name. * \since 1.8 * * \param dest Destination party name * \param src Source party name * * \return Nothing */ void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src); /*! * \brief Initialize the given party name structure using the given guide * for a set update operation. * \since 1.8 * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Party name structure to initialize. * \param guide Source party name to use as a guide in initializing. * * \return Nothing */ void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide); /*! * \brief Set the source party name information into the destination party name. * \since 1.8 * * \param dest The name one wishes to update * \param src The new name values to update the dest * * \return Nothing */ void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src); /*! * \brief Destroy the party name contents * \since 1.8 * * \param doomed The party name to destroy. * * \return Nothing */ void ast_party_name_free(struct ast_party_name *doomed); /*! * \brief Initialize the given number structure. * \since 1.8 * * \param init Number structure to initialize. * * \return Nothing */ void ast_party_number_init(struct ast_party_number *init); /*! * \brief Copy the source party number information to the destination party number. * \since 1.8 * * \param dest Destination party number * \param src Source party number * * \return Nothing */ void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src); /*! * \brief Initialize the given party number structure using the given guide * for a set update operation. * \since 1.8 * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Party number structure to initialize. * \param guide Source party number to use as a guide in initializing. * * \return Nothing */ void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide); /*! * \brief Set the source party number information into the destination party number. * \since 1.8 * * \param dest The number one wishes to update * \param src The new number values to update the dest * * \return Nothing */ void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src); /*! * \brief Destroy the party number contents * \since 1.8 * * \param doomed The party number to destroy. * * \return Nothing */ void ast_party_number_free(struct ast_party_number *doomed); /*! * \since 1.8 * \brief Initialize the given subaddress structure. * * \param init Subaddress structure to initialize. * * \return Nothing */ void ast_party_subaddress_init(struct ast_party_subaddress *init); /*! * \since 1.8 * \brief Copy the source party subaddress information to the destination party subaddress. * * \param dest Destination party subaddress * \param src Source party subaddress * * \return Nothing */ void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src); /*! * \since 1.8 * \brief Initialize the given party subaddress structure using the given guide * for a set update operation. * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Party subaddress structure to initialize. * \param guide Source party subaddress to use as a guide in initializing. * * \return Nothing */ void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide); /*! * \since 1.8 * \brief Set the source party subaddress information into the destination party subaddress. * * \param dest The subaddress one wishes to update * \param src The new subaddress values to update the dest * * \return Nothing */ void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src); /*! * \since 1.8 * \brief Destroy the party subaddress contents * * \param doomed The party subaddress to destroy. * * \return Nothing */ void ast_party_subaddress_free(struct ast_party_subaddress *doomed); /*! * \brief Set the update marker to update all information of a corresponding party id. * \since 11.0 * * \param update_id The update marker for a corresponding party id. * * \return Nothing */ void ast_set_party_id_all(struct ast_set_party_id *update_id); /*! * \brief Initialize the given party id structure. * \since 1.8 * * \param init Party id structure to initialize. * * \return Nothing */ void ast_party_id_init(struct ast_party_id *init); /*! * \brief Copy the source party id information to the destination party id. * \since 1.8 * * \param dest Destination party id * \param src Source party id * * \return Nothing */ void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src); /*! * \brief Initialize the given party id structure using the given guide * for a set update operation. * \since 1.8 * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Party id structure to initialize. * \param guide Source party id to use as a guide in initializing. * * \return Nothing */ void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide); /*! * \brief Set the source party id information into the destination party id. * \since 1.8 * * \param dest The id one wishes to update * \param src The new id values to update the dest * \param update What id information to update. NULL if all. * * \return Nothing */ void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update); /*! * \brief Destroy the party id contents * \since 1.8 * * \param doomed The party id to destroy. * * \return Nothing */ void ast_party_id_free(struct ast_party_id *doomed); /*! * \brief Determine the overall presentation value for the given party. * \since 1.8 * * \param id Party to determine the overall presentation value. * * \return Overall presentation value for the given party. */ int ast_party_id_presentation(const struct ast_party_id *id); /*! * \brief Invalidate all components of the given party id. * \since 11.0 * * \param id The party id to invalidate. * * \return Nothing */ void ast_party_id_invalidate(struct ast_party_id *id); /*! * \brief Destroy and initialize the given party id structure. * \since 11.0 * * \param id The party id to reset. * * \return Nothing */ void ast_party_id_reset(struct ast_party_id *id); /*! * \brief Merge a given party id into another given party id. * \since 11.0 * * \details * This function will generate an effective party id. * * Each party id component of the party id 'base' is overwritten * by components of the party id 'overlay' if the overlay * component is marked as valid. However the component 'tag' of * the base party id remains untouched. * * \param base The party id which is merged. * \param overlay The party id which is used to merge into. * * \return The merged party id as a struct, not as a pointer. * \note The merged party id returned is a shallow copy and must not be freed. */ struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay); /*! * \brief Copy a merge of a given party id into another given party id to a given destination party id. * \since 11.0 * * \details * Each party id component of the party id 'base' is overwritten by components * of the party id 'overlay' if the 'overlay' component is marked as valid. * However the component 'tag' of the 'base' party id remains untouched. * The result is copied into the given party id 'dest'. * * \note The resulting merged party id is a real copy and has to be freed. * * \param dest The resulting merged party id. * \param base The party id which is merged. * \param overlay The party id which is used to merge into. * * \return Nothing */ void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay); /*! * \brief Initialize the given dialed structure. * \since 1.8 * * \param init Dialed structure to initialize. * * \return Nothing */ void ast_party_dialed_init(struct ast_party_dialed *init); /*! * \brief Copy the source dialed party information to the destination dialed party. * \since 1.8 * * \param dest Destination dialed party * \param src Source dialed party * * \return Nothing */ void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src); /*! * \brief Initialize the given dialed structure using the given * guide for a set update operation. * \since 1.8 * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Caller structure to initialize. * \param guide Source dialed to use as a guide in initializing. * * \return Nothing */ void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide); /*! * \brief Set the dialed information based on another dialed source * \since 1.8 * * This is similar to ast_party_dialed_copy, except that NULL values for * strings in the src parameter indicate not to update the corresponding dest values. * * \param dest The dialed one wishes to update * \param src The new dialed values to update the dest * * \return Nada */ void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src); /*! * \brief Destroy the dialed party contents * \since 1.8 * * \param doomed The dialed party to destroy. * * \return Nothing */ void ast_party_dialed_free(struct ast_party_dialed *doomed); /*! * \since 1.8 * \brief Initialize the given caller structure. * * \param init Caller structure to initialize. * * \return Nothing */ void ast_party_caller_init(struct ast_party_caller *init); /*! * \since 1.8 * \brief Copy the source caller information to the destination caller. * * \param dest Destination caller * \param src Source caller * * \return Nothing */ void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src); /*! * \brief Initialize the given caller structure using the given * guide for a set update operation. * \since 1.8 * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Caller structure to initialize. * \param guide Source caller to use as a guide in initializing. * * \return Nothing */ void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide); /*! * \brief Set the caller information based on another caller source * \since 1.8 * * This is similar to ast_party_caller_copy, except that NULL values for * strings in the src parameter indicate not to update the corresponding dest values. * * \param dest The caller one wishes to update * \param src The new caller values to update the dest * \param update What caller information to update. NULL if all. * * \return Nada */ void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update); /*! * \brief Destroy the caller party contents * \since 1.8 * * \param doomed The caller party to destroy. * * \return Nothing */ void ast_party_caller_free(struct ast_party_caller *doomed); /*! * \since 1.8 * \brief Initialize the given connected line structure. * * \param init Connected line structure to initialize. * * \return Nothing */ void ast_party_connected_line_init(struct ast_party_connected_line *init); /*! * \since 1.8 * \brief Copy the source connected line information to the destination connected line. * * \param dest Destination connected line * \param src Source connected line * * \return Nothing */ void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src); /*! * \since 1.8 * \brief Initialize the given connected line structure using the given * guide for a set update operation. * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Connected line structure to initialize. * \param guide Source connected line to use as a guide in initializing. * * \return Nothing */ void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide); /*! * \since 1.8 * \brief Set the connected line information based on another connected line source * * This is similar to ast_party_connected_line_copy, except that NULL values for * strings in the src parameter indicate not to update the corresponding dest values. * * \param dest The connected line one wishes to update * \param src The new connected line values to update the dest * \param update What connected line information to update. NULL if all. * * \return Nothing */ void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update); /*! * \since 1.8 * \brief Collect the caller party information into a connected line structure. * * \param connected Collected caller information for the connected line * \param caller Caller information. * * \return Nothing * * \warning This is a shallow copy. * \warning DO NOT call ast_party_connected_line_free() on the filled in * connected line structure! */ void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller); /*! * \since 1.8 * \brief Destroy the connected line information contents * * \param doomed The connected line information to destroy. * * \return Nothing */ void ast_party_connected_line_free(struct ast_party_connected_line *doomed); /*! * \brief Initialize the given redirecting structure. * \since 1.8 * * \param init Redirecting structure to initialize. * * \return Nothing */ void ast_party_redirecting_init(struct ast_party_redirecting *init); /*! * \since 1.8 * \brief Copy the source redirecting information to the destination redirecting. * * \param dest Destination redirecting * \param src Source redirecting * * \return Nothing */ void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src); /*! * \since 1.8 * \brief Initialize the given redirecting id structure using the given guide * for a set update operation. * * \details * The initialization is needed to allow a set operation to know if a * value needs to be updated. Simple integers need the guide's original * value in case the set operation is not trying to set a new value. * String values are simply set to NULL pointers if they are not going * to be updated. * * \param init Redirecting id structure to initialize. * \param guide Source redirecting id to use as a guide in initializing. * * \return Nothing */ void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide); /*! * \brief Set the redirecting information based on another redirecting source * \since 1.8 * * This is similar to ast_party_redirecting_copy, except that NULL values for * strings in the src parameter indicate not to update the corresponding dest values. * * \param dest The redirecting one wishes to update * \param src The new redirecting values to update the dest * \param update What redirecting information to update. NULL if all. * * \return Nothing */ void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update); /*! * \since 1.8 * \brief Destroy the redirecting information contents * * \param doomed The redirecting information to destroy. * * \return Nothing */ void ast_party_redirecting_free(struct ast_party_redirecting *doomed); /*! * \since 1.8 * \brief Copy the caller information to the connected line information. * * \param dest Destination connected line information * \param src Source caller information * * \return Nothing * * \note Assumes locks are already acquired */ void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src); /*! * \since 1.8 * \brief Copy the connected line information to the caller information. * * \param dest Destination caller information * \param src Source connected line information * * \return Nothing * * \note Assumes locks are already acquired */ void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src); /*! * \since 1.8 * \brief Set the connected line information in the Asterisk channel * * \param chan Asterisk channel to set connected line information * \param connected Connected line information * \param update What connected line information to update. NULL if all. * * \return Nothing * * \note The channel does not need to be locked before calling this function. */ void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update); /*! * \since 1.8 * \brief Build the connected line information data frame. * * \param data Buffer to fill with the frame data * \param datalen Size of the buffer to fill * \param connected Connected line information * \param update What connected line information to build. NULL if all. * * \retval -1 if error * \retval Amount of data buffer used */ int ast_connected_line_build_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update); /*! * \since 1.8 * \brief Parse connected line indication frame data * * \param data Buffer with the frame data to parse * \param datalen Size of the buffer * \param connected Extracted connected line information * * \retval 0 on success. * \retval -1 on error. * * \note The filled in connected line structure needs to be initialized by * ast_party_connected_line_set_init() before calling. If defaults are not * required use ast_party_connected_line_init(). * \note The filled in connected line structure needs to be destroyed by * ast_party_connected_line_free() when it is no longer needed. */ int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected); /*! * \since 1.8 * \brief Indicate that the connected line information has changed * * \param chan Asterisk channel to indicate connected line information * \param connected Connected line information * \param update What connected line information to update. NULL if all. * * \return Nothing */ void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update); /*! * \since 1.8 * \brief Queue a connected line update frame on a channel * * \param chan Asterisk channel to indicate connected line information * \param connected Connected line information * \param update What connected line information to update. NULL if all. * * \return Nothing */ void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update); /*! * \since 1.8 * \brief Set the redirecting id information in the Asterisk channel * * \param chan Asterisk channel to set redirecting id information * \param redirecting Redirecting id information * \param update What redirecting information to update. NULL if all. * * \return Nothing * * \note The channel does not need to be locked before calling this function. */ void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); /*! * \since 1.8 * \brief Build the redirecting id data frame. * * \param data Buffer to fill with the frame data * \param datalen Size of the buffer to fill * \param redirecting Redirecting id information * \param update What redirecting information to build. NULL if all. * * \retval -1 if error * \retval Amount of data buffer used */ int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); /*! * \since 1.8 * \brief Parse redirecting indication frame data * * \param data Buffer with the frame data to parse * \param datalen Size of the buffer * \param redirecting Extracted redirecting id information * * \retval 0 on success. * \retval -1 on error. * * \note The filled in id structure needs to be initialized by * ast_party_redirecting_set_init() before calling. * \note The filled in id structure needs to be destroyed by * ast_party_redirecting_free() when it is no longer needed. */ int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting); /*! * \since 1.8 * \brief Indicate that the redirecting id has changed * * \param chan Asterisk channel to indicate redirecting id information * \param redirecting Redirecting id information * \param update What redirecting information to update. NULL if all. * * \return Nothing */ void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); /*! * \since 1.8 * \brief Queue a redirecting update frame on a channel * * \param chan Asterisk channel to indicate redirecting id information * \param redirecting Redirecting id information * \param update What redirecting information to update. NULL if all. * * \return Nothing */ void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); /*! * \since 1.8 * \brief Run a connected line interception macro and update a channel's connected line * information * \deprecated You should use the ast_channel_connected_line_sub() function instead. * * Whenever we want to update a channel's connected line information, we may need to run * a macro so that an administrator can manipulate the information before sending it * out. This function both runs the macro and sends the update to the channel. * * \param autoservice_chan Channel to place into autoservice while the macro is running. * It is perfectly safe for this to be NULL * \param macro_chan The channel to run the macro on. Also the channel from which we * determine which macro we need to run. * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type * AST_CONTROL_CONNECTED_LINE * \param is_caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO with arguments from * CONNECTED_LINE_CALLER_SEND_MACRO_ARGS, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO * with arguments from CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an * ast_party_connected_line pointer. * \retval 0 Success * \retval -1 Either the macro does not exist, or there was an error while attempting to * run the macro * * \todo Have multiple return codes based on the MACRO_RESULT * \todo Make constants so that caller and frame can be more expressive than just '1' and * '0' */ int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int frame); /*! * \since 11 * \brief Run a connected line interception subroutine and update a channel's connected line * information * * Whenever we want to update a channel's connected line information, we may need to run * a subroutine so that an administrator can manipulate the information before sending it * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and * sends the update to the channel. * * \param autoservice_chan Channel to place into autoservice while the sub is running. * It is perfectly safe for this to be NULL * \param sub_chan The channel to run the subroutine on. Also the channel from which we * determine which subroutine we need to run. * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type * AST_CONTROL_CONNECTED_LINE * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an * ast_party_connected_line pointer. * \retval 0 Success * \retval -1 Either the subroutine does not exist, or there was an error while attempting to * run the subroutine */ int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame); /*! * \brief Insert into an astdata tree, the channel structure. * \param[in] tree The ast data tree. * \param[in] chan The channel structure to add to tree. * \param[in] add_bridged Add the bridged channel to the structure. * \retval <0 on error. * \retval 0 on success. */ int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged); /*! * \brief Compare to channel structures using the data api. * \param[in] tree The search tree generated by the data api. * \param[in] chan The channel to compare. * \param[in] structure_name The name of the node of the channel structure. * \retval 0 The structure matches. * \retval 1 The structure doesn't matches. */ int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan, const char *structure_name); /*! * \since 1.8 * \brief Run a redirecting interception macro and update a channel's redirecting information * \deprecated You should use the ast_channel_redirecting_sub() function instead. * * \details * Whenever we want to update a channel's redirecting information, we may need to run * a macro so that an administrator can manipulate the information before sending it * out. This function both runs the macro and sends the update to the channel. * * \param autoservice_chan Channel to place into autoservice while the macro is running. * It is perfectly safe for this to be NULL * \param macro_chan The channel to run the macro on. Also the channel from which we * determine which macro we need to run. * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type * AST_CONTROL_REDIRECTING * \param is_caller If true, then run REDIRECTING_CALLER_SEND_MACRO with arguments from * REDIRECTING_CALLER_SEND_MACRO_ARGS, otherwise run REDIRECTING_CALLEE_SEND_MACRO with * arguments from REDIRECTING_CALLEE_SEND_MACRO_ARGS * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an * ast_party_redirecting pointer. * * \retval 0 Success * \retval -1 Either the macro does not exist, or there was an error while attempting to * run the macro * * \todo Have multiple return codes based on the MACRO_RESULT * \todo Make constants so that caller and frame can be more expressive than just '1' and * '0' */ int ast_channel_redirecting_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame); /*! * \since 11 * \brief Run a redirecting interception subroutine and update a channel's redirecting information * * \details * Whenever we want to update a channel's redirecting information, we may need to run * a subroutine so that an administrator can manipulate the information before sending it * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and * sends the update to the channel. * * \param autoservice_chan Channel to place into autoservice while the subroutine is running. * It is perfectly safe for this to be NULL * \param sub_chan The channel to run the subroutine on. Also the channel from which we * determine which subroutine we need to run. * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type * AST_CONTROL_REDIRECTING * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an * ast_party_redirecting pointer. * * \retval 0 Success * \retval -1 Either the subroutine does not exist, or there was an error while attempting to * run the subroutine */ int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame); #include "asterisk/ccss.h" /*! * \since 1.8 * \brief Set up datastore with CCSS parameters for a channel * * \note * If base_params is NULL, the channel will get the default * values for all CCSS parameters. * * \details * This function makes use of datastore operations on the channel, so * it is important to lock the channel before calling this function. * * \param chan The channel to create the datastore on * \param base_params CCSS parameters we wish to copy into the channel * \retval 0 Success * \retval -1 Failure */ int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params); /*! * \since 1.8 * \brief Get the CCSS parameters from a channel * * \details * This function makes use of datastore operations on the channel, so * it is important to lock the channel before calling this function. * * \param chan Channel to retrieve parameters from * \retval NULL Failure * \retval non-NULL The parameters desired */ struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan); /*! * \since 1.8 * \brief Get a device name given its channel structure * * \details * A common practice in Asterisk is to determine the device being talked * to by dissecting the channel name. For certain channel types, this is not * accurate. For instance, an ISDN channel is named based on what B channel is * used, not the device being communicated with. * * This function interfaces with a channel tech's queryoption callback to * retrieve the name of the device being communicated with. If the channel does not * implement this specific option, then the traditional method of using the channel * name is used instead. * * \param chan The channel to retrieve the information from * \param[out] device_name The buffer to place the device's name into * \param name_buffer_length The allocated space for the device_name * \return 0 always */ int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length); /*! * \since 1.8 * \brief Find the appropriate CC agent type to use given a channel * * \details * During call completion, we will need to create a call completion agent structure. To * figure out the type of agent to construct, we need to ask the channel driver for the * appropriate type. * * Prior to adding this function, the call completion core attempted to figure this * out for itself by stripping the technology off the channel's name. However, in the * case of chan_dahdi, there are multiple agent types registered, and so simply searching * for an agent type called "DAHDI" is not possible. In a case where multiple agent types * are defined, the channel driver must have a queryoption callback defined in its * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE * * If a channel driver does not have a queryoption callback or if the queryoption callback * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology * portion of the channel name is used instead. This is perfectly suitable for channel drivers * whose channel technologies are a one-to-one match with the agent types defined within. * * Note that this function is only called when the agent policy on a given channel is set * to "native." Generic agents' type can be determined automatically by the core. * * \param chan The channel for which we wish to retrieve the agent type * \param[out] agent_type The type of agent the channel driver wants us to use * \param size The size of the buffer to write to */ int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size); #if defined(__cplusplus) || defined(c_plusplus) } #endif /*! * \brief Remove a channel from the global channels container * * \param chan channel to remove * * In a case where it is desired that a channel not be available in any lookups * in the global channels conatiner, use this function. */ void ast_channel_unlink(struct ast_channel *chan); /*! * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash * on the given channel * * \param chan channel on which to set the cause information * \param cause_code ast_control_pvt_cause_code structure containing cause information * \param datalen total length of the structure since it may vary */ void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen); /* ACCESSOR FUNTIONS */ /*! \brief Set the channel name */ void ast_channel_name_set(struct ast_channel *chan, const char *name); #define DECLARE_STRINGFIELD_SETTERS_FOR(field) \ void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \ void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \ void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3))) DECLARE_STRINGFIELD_SETTERS_FOR(name); DECLARE_STRINGFIELD_SETTERS_FOR(language); DECLARE_STRINGFIELD_SETTERS_FOR(musicclass); DECLARE_STRINGFIELD_SETTERS_FOR(accountcode); DECLARE_STRINGFIELD_SETTERS_FOR(peeraccount); DECLARE_STRINGFIELD_SETTERS_FOR(userfield); DECLARE_STRINGFIELD_SETTERS_FOR(call_forward); DECLARE_STRINGFIELD_SETTERS_FOR(uniqueid); DECLARE_STRINGFIELD_SETTERS_FOR(linkedid); DECLARE_STRINGFIELD_SETTERS_FOR(parkinglot); DECLARE_STRINGFIELD_SETTERS_FOR(hangupsource); DECLARE_STRINGFIELD_SETTERS_FOR(dialcontext); const char *ast_channel_name(const struct ast_channel *chan); const char *ast_channel_language(const struct ast_channel *chan); const char *ast_channel_musicclass(const struct ast_channel *chan); const char *ast_channel_accountcode(const struct ast_channel *chan); const char *ast_channel_peeraccount(const struct ast_channel *chan); const char *ast_channel_userfield(const struct ast_channel *chan); const char *ast_channel_call_forward(const struct ast_channel *chan); const char *ast_channel_uniqueid(const struct ast_channel *chan); const char *ast_channel_linkedid(const struct ast_channel *chan); const char *ast_channel_parkinglot(const struct ast_channel *chan); const char *ast_channel_hangupsource(const struct ast_channel *chan); const char *ast_channel_dialcontext(const struct ast_channel *chan); const char *ast_channel_appl(const struct ast_channel *chan); void ast_channel_appl_set(struct ast_channel *chan, const char *value); const char *ast_channel_blockproc(const struct ast_channel *chan); void ast_channel_blockproc_set(struct ast_channel *chan, const char *value); const char *ast_channel_data(const struct ast_channel *chan); void ast_channel_data_set(struct ast_channel *chan, const char *value); const char *ast_channel_context(const struct ast_channel *chan); void ast_channel_context_set(struct ast_channel *chan, const char *value); const char *ast_channel_exten(const struct ast_channel *chan); void ast_channel_exten_set(struct ast_channel *chan, const char *value); const char *ast_channel_macrocontext(const struct ast_channel *chan); void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value); const char *ast_channel_macroexten(const struct ast_channel *chan); void ast_channel_macroexten_set(struct ast_channel *chan, const char *value); char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan); void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value); char ast_channel_sending_dtmf_digit(const struct ast_channel *chan); void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value); struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan); void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value); int ast_channel_amaflags(const struct ast_channel *chan); void ast_channel_amaflags_set(struct ast_channel *chan, int value); int ast_channel_epfd(const struct ast_channel *chan); void ast_channel_epfd_set(struct ast_channel *chan, int value); int ast_channel_fdno(const struct ast_channel *chan); void ast_channel_fdno_set(struct ast_channel *chan, int value); int ast_channel_hangupcause(const struct ast_channel *chan); void ast_channel_hangupcause_set(struct ast_channel *chan, int value); int ast_channel_macropriority(const struct ast_channel *chan); void ast_channel_macropriority_set(struct ast_channel *chan, int value); int ast_channel_priority(const struct ast_channel *chan); void ast_channel_priority_set(struct ast_channel *chan, int value); int ast_channel_rings(const struct ast_channel *chan); void ast_channel_rings_set(struct ast_channel *chan, int value); int ast_channel_streamid(const struct ast_channel *chan); void ast_channel_streamid_set(struct ast_channel *chan, int value); int ast_channel_timingfd(const struct ast_channel *chan); void ast_channel_timingfd_set(struct ast_channel *chan, int value); int ast_channel_visible_indication(const struct ast_channel *chan); void ast_channel_visible_indication_set(struct ast_channel *chan, int value); int ast_channel_vstreamid(const struct ast_channel *chan); void ast_channel_vstreamid_set(struct ast_channel *chan, int value); unsigned short ast_channel_transfercapability(const struct ast_channel *chan); void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value); unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan); void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value); unsigned int ast_channel_fin(const struct ast_channel *chan); void ast_channel_fin_set(struct ast_channel *chan, unsigned int value); unsigned int ast_channel_fout(const struct ast_channel *chan); void ast_channel_fout_set(struct ast_channel *chan, unsigned int value); unsigned long ast_channel_insmpl(const struct ast_channel *chan); void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value); unsigned long ast_channel_outsmpl(const struct ast_channel *chan); void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value); void *ast_channel_generatordata(const struct ast_channel *chan); void ast_channel_generatordata_set(struct ast_channel *chan, void *value); void *ast_channel_music_state(const struct ast_channel *chan); void ast_channel_music_state_set(struct ast_channel *chan, void *value); void *ast_channel_tech_pvt(const struct ast_channel *chan); void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value); void *ast_channel_timingdata(const struct ast_channel *chan); void ast_channel_timingdata_set(struct ast_channel *chan, void *value); struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan); void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value); struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan); void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value); struct ast_channel *ast_channel__bridge(const struct ast_channel *chan); void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value); struct ast_channel *ast_channel_masq(const struct ast_channel *chan); void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value); struct ast_channel *ast_channel_masqr(const struct ast_channel *chan); void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value); struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan); void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value); struct ast_filestream *ast_channel_stream(const struct ast_channel *chan); void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value); struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan); void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value); struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan); void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value); struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan); void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value); struct ast_generator *ast_channel_generator(const struct ast_channel *chan); void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value); struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan); void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value); struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan); void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value); struct ast_timer *ast_channel_timer(const struct ast_channel *chan); void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value); struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan); void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value); struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan); void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value); struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan); void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value); const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan); void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value); enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan); void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value); enum ast_channel_state ast_channel_state(const struct ast_channel *chan); struct ast_callid *ast_channel_callid(const struct ast_channel *chan); void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *value); /* XXX Internal use only, make sure to move later */ void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state); void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value); void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value); void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value); void ast_channel_callid_cleanup(struct ast_channel *chan); int ast_channel_softhangup_internal_flag(struct ast_channel *chan); /* Format getters */ struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan); struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan); struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan); struct ast_format *ast_channel_readformat(struct ast_channel *chan); struct ast_format *ast_channel_writeformat(struct ast_channel *chan); /* Other struct getters */ struct ast_frame *ast_channel_dtmff(struct ast_channel *chan); struct ast_jb *ast_channel_jb(struct ast_channel *chan); struct ast_party_caller *ast_channel_caller(struct ast_channel *chan); struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan); struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan); struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan); struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan); struct ast_party_id ast_channel_redirecting_effective_orig(struct ast_channel *chan); struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan); struct ast_party_id ast_channel_redirecting_effective_to(struct ast_channel *chan); struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan); struct timeval *ast_channel_whentohangup(struct ast_channel *chan); struct varshead *ast_channel_varshead(struct ast_channel *chan); void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value); void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value); void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value); void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value); void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value); void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value); void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value); void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value); void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value); struct timeval ast_channel_creationtime(struct ast_channel *chan); void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value); /* List getters */ struct ast_hangup_handler_list *ast_channel_hangup_handlers(struct ast_channel *chan); struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan); struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan); struct ast_readq_list *ast_channel_readq(struct ast_channel *chan); /* Typedef accessors */ ast_group_t ast_channel_callgroup(const struct ast_channel *chan); void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value); ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan); void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value); struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan); void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value); struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan); void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value); /* Alertpipe accessors--the "internal" functions for channel.c use only */ typedef enum { AST_ALERT_READ_SUCCESS = 0, AST_ALERT_NOT_READABLE, AST_ALERT_READ_FAIL, AST_ALERT_READ_FATAL, } ast_alert_status_t; int ast_channel_alert_write(struct ast_channel *chan); int ast_channel_alert_writable(struct ast_channel *chan); ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan); int ast_channel_internal_alert_readable(struct ast_channel *chan); void ast_channel_internal_alertpipe_clear(struct ast_channel *chan); void ast_channel_internal_alertpipe_close(struct ast_channel *chan); int ast_channel_internal_alert_readfd(struct ast_channel *chan); int ast_channel_internal_alertpipe_init(struct ast_channel *chan); /*! \brief Swap the interal alertpipe between two channels * \note Handle all of the necessary locking before calling this */ void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2); /* file descriptor array accessors */ void ast_channel_internal_fd_clear(struct ast_channel *chan, int which); void ast_channel_internal_fd_clear_all(struct ast_channel *chan); void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value); int ast_channel_fd(const struct ast_channel *chan, int which); int ast_channel_fd_isset(const struct ast_channel *chan, int which); /* epoll data internal accessors */ #ifdef HAVE_EPOLL struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which); void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value); #endif pthread_t ast_channel_blocker(const struct ast_channel *chan); void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value); ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan); void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value); struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan); void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value); struct ast_channel *ast_channel_internal_bridged_channel(const struct ast_channel *chan); void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value); /*! * \since 11 * \brief Retreive a comma-separated list of channels for which dialed cause information is available * * \details * This function makes use of datastore operations on the channel, so * it is important to lock the channel before calling this function. * * \param chan The channel from which to retreive information * \retval NULL on allocation failure * \retval Pointer to an ast_str object containing the desired information which must be freed */ struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan); /*! * \since 11 * \brief Retreive a ref-counted cause code information structure * * \details * This function makes use of datastore operations on the channel, so * it is important to lock the channel before calling this function. * This function increases the ref count of the returned object, so the * calling function must decrease the reference count when it is finished * with the object. * * \param chan The channel from which to retreive information * \param chan_name The name of the channel about which to retreive information * \retval NULL on search failure * \retval Pointer to a ref-counted ast_control_pvt_cause_code object containing the desired information */ struct ast_control_pvt_cause_code *ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name); /*! * \since 11 * \brief Add cause code information to the channel * * \details * This function makes use of datastore operations on the channel, so * it is important to lock the channel before calling this function. * The passed in data is copied and so is still owned by the caller. * * \param chan The channel on which to add information * \param cause_code The cause information to be added to the channel * \param datalen The total length of the structure since its length is variable * \retval 0 on success * \retval -1 on error */ int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen); /*! * \since 11 * \brief Clear all cause information from the channel * * \details * This function makes use of datastore operations on the channel, so * it is important to lock the channel before calling this function. * * \param chan The channel from which to clear information */ void ast_channel_dialed_causes_clear(const struct ast_channel *chan); struct ast_flags *ast_channel_flags(struct ast_channel *chan); #endif /* _ASTERISK_CHANNEL_H */ asterisk-11.7.0/include/asterisk/silk.h0000644000175000007640000000265211531040421017724 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2011, Digium, Inc. * * David Vossel * * 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 SILK Format Attributes * * \author David Vossel */ #ifndef _AST_FORMAT_SILK_H_ #define _AST_FORMAT_SILK_H_ /*! SILK format attribute key value pairs, all are accessible through ast_format_get_value()*/ enum silk_attr_keys { SILK_ATTR_KEY_SAMP_RATE, /*!< value is silk_attr_vals enum */ SILK_ATTR_KEY_DTX, /*!< value is an int, 1 dtx is enabled, 0 dtx not enabled. */ SILK_ATTR_KEY_FEC, /*!< value is an int, 1 encode with FEC, 0 do not use FEC. */ SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE, /*!< value is an int (0-100), Represents estimated packetloss in uplink direction.*/ SILK_ATTR_KEY_MAX_BITRATE, /*!< value is an int */ }; enum silk_attr_vals { SILK_ATTR_VAL_SAMP_8KHZ = (1 << 0), SILK_ATTR_VAL_SAMP_12KHZ = (1 << 1), SILK_ATTR_VAL_SAMP_16KHZ = (1 << 2), SILK_ATTR_VAL_SAMP_24KHZ = (1 << 3), }; #endif /* _AST_FORMAT_SILK_H */ asterisk-11.7.0/include/asterisk/compiler.h0000644000175000007640000000352711441512317020606 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Compiler-specific macros and other items */ #ifndef _ASTERISK_COMPILER_H #define _ASTERISK_COMPILER_H #ifdef HAVE_ATTRIBUTE_always_inline #define force_inline __attribute__((always_inline)) inline #else #define force_inline inline #endif #ifdef HAVE_ATTRIBUTE_pure #define attribute_pure __attribute__((pure)) #else #define attribute_pure #endif #ifdef HAVE_ATTRIBUTE_const #define attribute_const __attribute__((const)) #else #define attribute_const #endif #ifdef HAVE_ATTRIBUTE_deprecated #define attribute_deprecated __attribute__((deprecated)) #else #define attribute_deprecated #endif #ifdef HAVE_ATTRIBUTE_unused #define attribute_unused __attribute__((unused)) #else #define attribute_unused #endif #ifdef HAVE_ATTRIBUTE_malloc #define attribute_malloc __attribute__((malloc)) #else #define attribute_malloc #endif #ifdef HAVE_ATTRIBUTE_sentinel #define attribute_sentinel __attribute__((sentinel)) #else #define attribute_sentinel #endif #ifdef HAVE_ATTRIBUTE_warn_unused_result #define attribute_warn_unused_result __attribute__((warn_unused_result)) #else #define attribute_warn_unused_result #endif /* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */ #define SENTINEL ((char *)NULL) #endif /* _ASTERISK_COMPILER_H */ asterisk-11.7.0/include/asterisk/udptl.h0000644000175000007640000001112511503707512020117 0ustar sharkyjerryweb/* * Asterisk -- A telephony toolkit for Linux. * * UDPTL support for T.38 * * Copyright (C) 2005, Steve Underwood, partly based on RTP code which is * Copyright (C) 1999-2004, Digium, Inc. * * Steve Underwood * * This program is free software, distributed under the terms of * the GNU General Public License * * A license has been granted to Digium (via disclaimer) for the use of * this code. */ /*! \file * \brief UDPTL support for T.38 * \author Steve Underwood * \ref udptl.c * \todo add doxygen documentation to this file! */ #ifndef _ASTERISK_UDPTL_H #define _ASTERISK_UDPTL_H #include "asterisk/network.h" #include "asterisk/frame.h" #include "asterisk/io.h" #include "asterisk/sched.h" #include "asterisk/channel.h" #include "asterisk/netsock2.h" enum ast_t38_ec_modes { UDPTL_ERROR_CORRECTION_NONE, UDPTL_ERROR_CORRECTION_FEC, UDPTL_ERROR_CORRECTION_REDUNDANCY }; #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif struct ast_udptl_protocol { /*! \brief Get UDPTL struct, or NULL if unwilling to transfer */ struct ast_udptl *(*get_udptl_info)(struct ast_channel *chan); /*! \brief Set UDPTL peer */ int (* const set_udptl_peer)(struct ast_channel *chan, struct ast_udptl *peer); const char * const type; AST_RWLIST_ENTRY(ast_udptl_protocol) list; }; struct ast_udptl; typedef int (*ast_udptl_callback)(struct ast_udptl *udptl, struct ast_frame *f, void *data); struct ast_udptl *ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, struct io_context *io, int callbackmode, struct ast_sockaddr *in); /*! * \brief Associates a character string 'tag' with a UDPTL session. * \param udptl The UDPTL session. * \param format printf-style format string used to construct the tag * * This function formats a tag for the specified UDPTL * session, so that any log messages generated by the UDPTL stack * related to that session will include the tag and the reader of * the messages will be able to identify which endpoint caused them * to be generated. * * \retval none */ void __attribute__((format(printf, 2, 3))) ast_udptl_set_tag(struct ast_udptl *udptl, const char *format, ...); void ast_udptl_set_peer(struct ast_udptl *udptl, const struct ast_sockaddr *them); void ast_udptl_get_peer(const struct ast_udptl *udptl, struct ast_sockaddr *them); void ast_udptl_get_us(const struct ast_udptl *udptl, struct ast_sockaddr *us); void ast_udptl_destroy(struct ast_udptl *udptl); void ast_udptl_reset(struct ast_udptl *udptl); void ast_udptl_set_callback(struct ast_udptl *udptl, ast_udptl_callback callback); void ast_udptl_set_data(struct ast_udptl *udptl, void *data); int ast_udptl_write(struct ast_udptl *udptl, struct ast_frame *f); struct ast_frame *ast_udptl_read(struct ast_udptl *udptl); int ast_udptl_fd(const struct ast_udptl *udptl); int ast_udptl_setqos(struct ast_udptl *udptl, unsigned int tos, unsigned int cos); void ast_udptl_set_m_type(struct ast_udptl *udptl, unsigned int pt); void ast_udptl_set_udptlmap_type(struct ast_udptl *udptl, unsigned int pt, char *mimeType, char *mimeSubtype); enum ast_t38_ec_modes ast_udptl_get_error_correction_scheme(const struct ast_udptl *udptl); void ast_udptl_set_error_correction_scheme(struct ast_udptl *udptl, enum ast_t38_ec_modes ec); void ast_udptl_set_local_max_ifp(struct ast_udptl *udptl, unsigned int max_ifp); /*! * \brief retrieves local_max_datagram. * * \retval positive value representing max datagram size. * \retval 0 if no value is present */ unsigned int ast_udptl_get_local_max_datagram(struct ast_udptl *udptl); /*! * \brief sets far max datagram size. If max_datagram is = 0, the far max datagram * size is set to a default value. */ void ast_udptl_set_far_max_datagram(struct ast_udptl *udptl, unsigned int max_datagram); unsigned int ast_udptl_get_far_max_datagram(const struct ast_udptl *udptl); /*! * \brief retrieves far max ifp * * \retval positive value representing max ifp size * \retval 0 if no value is present */ unsigned int ast_udptl_get_far_max_ifp(struct ast_udptl *udptl); void ast_udptl_setnat(struct ast_udptl *udptl, int nat); int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); int ast_udptl_proto_register(struct ast_udptl_protocol *proto); void ast_udptl_proto_unregister(struct ast_udptl_protocol *proto); void ast_udptl_stop(struct ast_udptl *udptl); void ast_udptl_init(void); /*! * \version 1.6.1 return changed to int */ int ast_udptl_reload(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif asterisk-11.7.0/include/asterisk/astobj.h0000644000175000007640000006250311035666264020267 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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. */ /* * Object Model for Asterisk */ #ifndef _ASTERISK_ASTOBJ_H #define _ASTERISK_ASTOBJ_H #include "asterisk/lock.h" /*! \file * \brief A set of macros implementing objects and containers. * Macros are used for maximum performance, to support multiple inheritance, * and to be easily integrated into existing structures without additional * malloc calls, etc. * * These macros expect to operate on two different object types, ASTOBJs and * ASTOBJ_CONTAINERs. These are not actual types, as any struct can be * converted into an ASTOBJ compatible object or container using the supplied * macros. * * Sample Usage: * \code * struct sample_object { * ASTOBJ_COMPONENTS(struct sample_object); * }; * * struct sample_container { * ASTOBJ_CONTAINER_COMPONENTS(struct sample_object); * } super_container; * * void sample_object_destroy(struct sample_object *obj) * { * free(obj); * } * * int init_stuff() * { * struct sample_object *obj1; * struct sample_object *found_obj; * * obj1 = malloc(sizeof(struct sample_object)); * * ASTOBJ_CONTAINER_INIT(&super_container); * * ASTOBJ_INIT(obj1); * ASTOBJ_WRLOCK(obj1); * ast_copy_string(obj1->name, "obj1", sizeof(obj1->name)); * ASTOBJ_UNLOCK(obj1); * * ASTOBJ_CONTAINER_LINK(&super_container, obj1); * * found_obj = ASTOBJ_CONTAINER_FIND(&super_container, "obj1"); * * if(found_obj) { * printf("Found object: %s", found_obj->name); * ASTOBJ_UNREF(found_obj,sample_object_destroy); * } * * ASTOBJ_CONTAINER_DESTROYALL(&super_container,sample_object_destroy); * ASTOBJ_CONTAINER_DESTROY(&super_container); * * return 0; * } * \endcode */ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define ASTOBJ_DEFAULT_NAMELEN 80 #define ASTOBJ_DEFAULT_BUCKETS 256 #define ASTOBJ_DEFAULT_HASH ast_strhash #define ASTOBJ_FLAG_MARKED (1 << 0) /* Object has been marked for future operation */ /* C++ is simply a syntactic crutch for those who cannot think for themselves in an object oriented way. */ /*! \brief Lock an ASTOBJ for reading. */ #define ASTOBJ_RDLOCK(object) ast_mutex_lock(&(object)->_lock) /*! \brief Lock an ASTOBJ for writing. */ #define ASTOBJ_WRLOCK(object) ast_mutex_lock(&(object)->_lock) #define ASTOBJ_TRYWRLOCK(object) ast_mutex_trylock(&(object)->_lock) /*! \brief Unlock a locked object. */ #define ASTOBJ_UNLOCK(object) ast_mutex_unlock(&(object)->_lock) #ifdef ASTOBJ_CONTAINER_HASHMODEL #define __ASTOBJ_HASH(type,hashes) \ type *next[hashes] #else #define __ASTOBJ_HASH(type,hashes) \ type *next[1] #endif /*! \brief Add ASTOBJ components to a struct (without locking support). * * \param type The datatype of the object. * \param namelen The length to make the name char array. * \param hashes The number of containers the object can be present in. * * This macro adds components to a struct to make it an ASTOBJ. This macro * differs from ASTOBJ_COMPONENTS_FULL in that it does not create a mutex for * locking. * * Sample Usage: * \code * struct sample_struct { * ASTOBJ_COMPONENTS_NOLOCK_FULL(struct sample_struct,1,1); * }; * \endcode */ #define ASTOBJ_COMPONENTS_NOLOCK_FULL(type,namelen,hashes) \ char name[namelen]; \ unsigned int refcount; \ unsigned int objflags; \ __ASTOBJ_HASH(type,hashes) /*! \brief Add ASTOBJ components to a struct (without locking support). * * \param type The datatype of the object. * * This macro works like #ASTOBJ_COMPONENTS_NOLOCK_FULL() except it only accepts a * type and uses default values for namelen and hashes. * * Sample Usage: * \code * struct sample_struct_componets { * ASTOBJ_COMPONENTS_NOLOCK(struct sample_struct); * }; * \endcode */ #define ASTOBJ_COMPONENTS_NOLOCK(type) \ ASTOBJ_COMPONENTS_NOLOCK_FULL(type,ASTOBJ_DEFAULT_NAMELEN,1) /*! \brief Add ASTOBJ components to a struct (with locking support). * * \param type The datatype of the object. * * This macro works like #ASTOBJ_COMPONENTS_NOLOCK() except it includes locking * support. * * Sample Usage: * \code * struct sample_struct { * ASTOBJ_COMPONENTS(struct sample_struct); * }; * \endcode */ #define ASTOBJ_COMPONENTS(type) \ ASTOBJ_COMPONENTS_NOLOCK(type); \ ast_mutex_t _lock; /*! \brief Add ASTOBJ components to a struct (with locking support). * * \param type The datatype of the object. * \param namelen The length to make the name char array. * \param hashes The number of containers the object can be present in. * * This macro adds components to a struct to make it an ASTOBJ and includes * support for locking. * * Sample Usage: * \code * struct sample_struct { * ASTOBJ_COMPONENTS_FULL(struct sample_struct,1,1); * }; * \endcode */ #define ASTOBJ_COMPONENTS_FULL(type,namelen,hashes) \ ASTOBJ_COMPONENTS_NOLOCK_FULL(type,namelen,hashes); \ ast_mutex_t _lock; /*! \brief Increment an object reference count. * \param object A pointer to the object to operate on. * \return The object. */ #define ASTOBJ_REF(object) \ ({ \ ASTOBJ_WRLOCK(object); \ (object)->refcount++; \ ASTOBJ_UNLOCK(object); \ (object); \ }) /*! \brief Decrement the reference count on an object. * * \param object A pointer the object to operate on. * \param destructor The destructor to call if the object is no longer referenced. It will be passed the pointer as an argument. * * This macro unreferences an object and calls the specfied destructor if the * object is no longer referenced. The destructor should free the object if it * was dynamically allocated. */ #define ASTOBJ_UNREF(object,destructor) \ do { \ int newcount = 0; \ ASTOBJ_WRLOCK(object); \ if (__builtin_expect((object)->refcount > 0, 1)) \ newcount = --((object)->refcount); \ else \ ast_log(AST_LOG_WARNING, "Unreferencing unreferenced (object)!\n"); \ ASTOBJ_UNLOCK(object); \ if (newcount == 0) { \ ast_mutex_destroy(&(object)->_lock); \ destructor((object)); \ } \ (object) = NULL; \ } while(0) /*! \brief Mark an ASTOBJ by adding the #ASTOBJ_FLAG_MARKED flag to its objflags mask. * \param object A pointer to the object to operate on. * * This macro "marks" an object. Marked objects can later be unlinked from a container using * #ASTOBJ_CONTAINER_PRUNE_MARKED(). * */ #define ASTOBJ_MARK(object) \ do { \ ASTOBJ_WRLOCK(object); \ (object)->objflags |= ASTOBJ_FLAG_MARKED; \ ASTOBJ_UNLOCK(object); \ } while(0) /*! \brief Unmark an ASTOBJ by subtracting the #ASTOBJ_FLAG_MARKED flag from its objflags mask. * \param object A pointer to the object to operate on. */ #define ASTOBJ_UNMARK(object) \ do { \ ASTOBJ_WRLOCK(object); \ (object)->objflags &= ~ASTOBJ_FLAG_MARKED; \ ASTOBJ_UNLOCK(object); \ } while(0) /*! \brief Initialize an object. * \param object A pointer to the object to operate on. * * \note This should only be used on objects that support locking (objects * created with #ASTOBJ_COMPONENTS() or #ASTOBJ_COMPONENTS_FULL()) */ #define ASTOBJ_INIT(object) \ do { \ ast_mutex_init(&(object)->_lock); \ object->name[0] = '\0'; \ object->refcount = 1; \ } while(0) /* Containers for objects -- current implementation is linked lists, but should be able to be converted to hashes relatively easily */ /*! \brief Lock an ASTOBJ_CONTAINER for reading. */ #define ASTOBJ_CONTAINER_RDLOCK(container) ast_mutex_lock(&(container)->_lock) /*! \brief Lock an ASTOBJ_CONTAINER for writing. */ #define ASTOBJ_CONTAINER_WRLOCK(container) ast_mutex_lock(&(container)->_lock) /*! \brief Unlock an ASTOBJ_CONTAINER. */ #define ASTOBJ_CONTAINER_UNLOCK(container) ast_mutex_unlock(&(container)->_lock) #ifdef ASTOBJ_CONTAINER_HASHMODEL #error "Hash model for object containers not yet implemented!" #else /* Linked lists */ /*! \brief Create a container for ASTOBJs (without locking support). * * \param type The type of objects the container will hold. * \param hashes Currently unused. * \param buckets Currently unused. * * This macro is used to create a container for ASTOBJs without locking * support. * * Sample Usage: * \code * struct sample_struct_nolock_container { * ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(struct sample_struct,1,1); * }; * \endcode */ #define ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(type,hashes,buckets) \ type *head /*! \brief Initialize a container. * * \param container A pointer to the container to initialize. * \param hashes Currently unused. * \param buckets Currently unused. * * This macro initializes a container. It should only be used on containers * that support locking. * * Sample Usage: * \code * struct sample_struct_container { * ASTOBJ_CONTAINER_COMPONENTS_FULL(struct sample_struct,1,1); * } container; * * int func() * { * ASTOBJ_CONTAINER_INIT_FULL(&container,1,1); * } * \endcode */ #define ASTOBJ_CONTAINER_INIT_FULL(container,hashes,buckets) \ do { \ ast_mutex_init(&(container)->_lock); \ } while(0) /*! \brief Destroy a container. * * \param container A pointer to the container to destroy. * \param hashes Currently unused. * \param buckets Currently unused. * * This macro frees up resources used by a container. It does not operate on * the objects in the container. To unlink the objects from the container use * #ASTOBJ_CONTAINER_DESTROYALL(). * * \note This macro should only be used on containers with locking support. */ #define ASTOBJ_CONTAINER_DESTROY_FULL(container,hashes,buckets) \ do { \ ast_mutex_destroy(&(container)->_lock); \ } while(0) /*! \brief Iterate through the objects in a container. * * \param container A pointer to the container to traverse. * \param continue A condition to allow the traversal to continue. * \param eval A statement to evaluate in the iteration loop. * * This is macro is a little complicated, but it may help to think of it as a * loop. Basically it iterates through the specfied containter as long as the * condition is met. Two variables, iterator and next, are provided for use in * your \p eval statement. See the sample code for an example. * * Sample Usage: * \code * ASTOBJ_CONTAINER_TRAVERSE(&sample_container,1, { * ASTOBJ_RDLOCK(iterator); * printf("Currently iterating over '%s'\n", iterator->name); * ASTOBJ_UNLOCK(iterator); * } ); * \endcode * * \code * ASTOBJ_CONTAINER_TRAVERSE(&sample_container,1, sample_func(iterator)); * \endcode */ #define ASTOBJ_CONTAINER_TRAVERSE(container,continue,eval) \ do { \ typeof((container)->head) iterator; \ typeof((container)->head) next; \ ASTOBJ_CONTAINER_RDLOCK(container); \ next = (container)->head; \ while((continue) && (iterator = next)) { \ next = iterator->next[0]; \ eval; \ } \ ASTOBJ_CONTAINER_UNLOCK(container); \ } while(0) /*! \brief Find an object in a container. * * \param container A pointer to the container to search. * \param namestr The name to search for. * * Use this function to find an object with the specfied name in a container. * * \note When the returned object is no longer in use, #ASTOBJ_UNREF() should * be used to free the additional reference created by this macro. * * \return A new reference to the object located or NULL if nothing is found. */ #define ASTOBJ_CONTAINER_FIND(container,namestr) \ ({ \ typeof((container)->head) found = NULL; \ ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \ if (!(strcasecmp(iterator->name, (namestr)))) \ found = ASTOBJ_REF(iterator); \ } while (0)); \ found; \ }) /*! \brief Find an object in a container. * * \param container A pointer to the container to search. * \param data The data to search for. * \param field The field/member of the container's objects to search. * \param hashfunc The hash function to use, currently not implemented. * \param hashoffset The hash offset to use, currently not implemented. * \param comparefunc The function used to compare the field and data values. * * This macro iterates through a container passing the specified field and data * elements to the specified comparefunc. The function should return 0 when a match is found. * * \note When the returned object is no longer in use, #ASTOBJ_UNREF() should * be used to free the additional reference created by this macro. * * \return A pointer to the object located or NULL if nothing is found. */ #define ASTOBJ_CONTAINER_FIND_FULL(container,data,field,hashfunc,hashoffset,comparefunc) \ ({ \ typeof((container)->head) found = NULL; \ ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \ ASTOBJ_RDLOCK(iterator); \ if (!(comparefunc(iterator->field, (data)))) { \ found = ASTOBJ_REF(iterator); \ } \ ASTOBJ_UNLOCK(iterator); \ } while (0)); \ found; \ }) /*! \brief Empty a container. * * \param container A pointer to the container to operate on. * \param destructor A destructor function to call on each object. * * This macro loops through a container removing all the items from it using * #ASTOBJ_UNREF(). This does not destroy the container itself, use * #ASTOBJ_CONTAINER_DESTROY() for that. * * \note If any object in the container is only referenced by the container, * the destructor will be called for that object once it has been removed. */ #define ASTOBJ_CONTAINER_DESTROYALL(container,destructor) \ do { \ typeof((container)->head) iterator; \ ASTOBJ_CONTAINER_WRLOCK(container); \ while((iterator = (container)->head)) { \ (container)->head = (iterator)->next[0]; \ ASTOBJ_UNREF(iterator,destructor); \ } \ ASTOBJ_CONTAINER_UNLOCK(container); \ } while(0) /*! \brief Remove an object from a container. * * \param container A pointer to the container to operate on. * \param obj A pointer to the object to remove. * * This macro iterates through a container and removes the specfied object if * it exists in the container. * * \note This macro does not destroy any objects, it simply unlinks * them from the list. No destructors are called. * * \return The container's reference to the removed object or NULL if no * matching object was found. */ #define ASTOBJ_CONTAINER_UNLINK(container,obj) \ ({ \ typeof((container)->head) found = NULL; \ typeof((container)->head) prev = NULL; \ ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \ if (iterator == obj) { \ found = iterator; \ found->next[0] = NULL; \ ASTOBJ_CONTAINER_WRLOCK(container); \ if (prev) \ prev->next[0] = next; \ else \ (container)->head = next; \ ASTOBJ_CONTAINER_UNLOCK(container); \ } \ prev = iterator; \ } while (0)); \ found; \ }) /*! \brief Find and remove an object from a container. * * \param container A pointer to the container to operate on. * \param namestr The name of the object to remove. * * This macro iterates through a container and removes the first object with * the specfied name from the container. * * \note This macro does not destroy any objects, it simply unlinks * them. No destructors are called. * * \return The container's reference to the removed object or NULL if no * matching object was found. */ #define ASTOBJ_CONTAINER_FIND_UNLINK(container,namestr) \ ({ \ typeof((container)->head) found = NULL; \ typeof((container)->head) prev = NULL; \ ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \ if (!(strcasecmp(iterator->name, (namestr)))) { \ found = iterator; \ found->next[0] = NULL; \ ASTOBJ_CONTAINER_WRLOCK(container); \ if (prev) \ prev->next[0] = next; \ else \ (container)->head = next; \ ASTOBJ_CONTAINER_UNLOCK(container); \ } \ prev = iterator; \ } while (0)); \ found; \ }) /*! \brief Find and remove an object in a container. * * \param container A pointer to the container to search. * \param data The data to search for. * \param field The field/member of the container's objects to search. * \param hashfunc The hash function to use, currently not implemented. * \param hashoffset The hash offset to use, currently not implemented. * \param comparefunc The function used to compare the field and data values. * * This macro iterates through a container passing the specified field and data * elements to the specified comparefunc. The function should return 0 when a match is found. * If a match is found it is removed from the list. * * \note This macro does not destroy any objects, it simply unlinks * them. No destructors are called. * * \return The container's reference to the removed object or NULL if no match * was found. */ #define ASTOBJ_CONTAINER_FIND_UNLINK_FULL(container,data,field,hashfunc,hashoffset,comparefunc) \ ({ \ typeof((container)->head) found = NULL; \ typeof((container)->head) prev = NULL; \ ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \ ASTOBJ_RDLOCK(iterator); \ if (!(comparefunc(iterator->field, (data)))) { \ found = iterator; \ found->next[0] = NULL; \ ASTOBJ_CONTAINER_WRLOCK(container); \ if (prev) \ prev->next[0] = next; \ else \ (container)->head = next; \ ASTOBJ_CONTAINER_UNLOCK(container); \ } \ ASTOBJ_UNLOCK(iterator); \ prev = iterator; \ } while (0)); \ found; \ }) /*! \brief Add an object to the end of a container. * * \param container A pointer to the container to operate on. * \param newobj A pointer to the object to be added. * * This macro adds an object to the end of a container. */ #define ASTOBJ_CONTAINER_LINK_END(container,newobj) \ do { \ typeof((container)->head) iterator; \ typeof((container)->head) next; \ typeof((container)->head) prev; \ ASTOBJ_CONTAINER_RDLOCK(container); \ prev = NULL; \ next = (container)->head; \ while((iterator = next)) { \ next = iterator->next[0]; \ prev = iterator; \ } \ if(prev) { \ ASTOBJ_CONTAINER_WRLOCK((container)); \ prev->next[0] = ASTOBJ_REF(newobj); \ (newobj)->next[0] = NULL; \ ASTOBJ_CONTAINER_UNLOCK((container)); \ } else { \ ASTOBJ_CONTAINER_LINK_START((container),(newobj)); \ } \ ASTOBJ_CONTAINER_UNLOCK((container)); \ } while(0) /*! \brief Add an object to the front of a container. * * \param container A pointer to the container to operate on. * \param newobj A pointer to the object to be added. * * This macro adds an object to the start of a container. */ #define ASTOBJ_CONTAINER_LINK_START(container,newobj) \ do { \ ASTOBJ_CONTAINER_WRLOCK(container); \ (newobj)->next[0] = (container)->head; \ (container)->head = ASTOBJ_REF(newobj); \ ASTOBJ_CONTAINER_UNLOCK(container); \ } while(0) /*! \brief Remove an object from the front of a container. * * \param container A pointer to the container to operate on. * * This macro removes the first object in a container. * * \note This macro does not destroy any objects, it simply unlinks * them from the list. No destructors are called. * * \return The container's reference to the removed object or NULL if no * matching object was found. */ #define ASTOBJ_CONTAINER_UNLINK_START(container) \ ({ \ typeof((container)->head) found = NULL; \ ASTOBJ_CONTAINER_WRLOCK(container); \ if((container)->head) { \ found = (container)->head; \ (container)->head = (container)->head->next[0]; \ found->next[0] = NULL; \ } \ ASTOBJ_CONTAINER_UNLOCK(container); \ found; \ }) /*! \brief Prune marked objects from a container. * * \param container A pointer to the container to prune. * \param destructor A destructor function to call on each marked object. * * This macro iterates through the specfied container and prunes any marked * objects executing the specfied destructor if necessary. */ #define ASTOBJ_CONTAINER_PRUNE_MARKED(container,destructor) \ do { \ typeof((container)->head) prev = NULL; \ ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { \ ASTOBJ_RDLOCK(iterator); \ if (iterator->objflags & ASTOBJ_FLAG_MARKED) { \ ASTOBJ_CONTAINER_WRLOCK(container); \ if (prev) \ prev->next[0] = next; \ else \ (container)->head = next; \ ASTOBJ_CONTAINER_UNLOCK(container); \ ASTOBJ_UNLOCK(iterator); \ ASTOBJ_UNREF(iterator,destructor); \ continue; \ } \ ASTOBJ_UNLOCK(iterator); \ prev = iterator; \ } while (0)); \ } while(0) /*! \brief Add an object to a container. * * \param container A pointer to the container to operate on. * \param newobj A pointer to the object to be added. * \param data Currently unused. * \param field Currently unused. * \param hashfunc Currently unused. * \param hashoffset Currently unused. * \param comparefunc Currently unused. * * Currently this function adds an object to the head of the list. One day it * will support adding objects atthe position specified using the various * options this macro offers. */ #define ASTOBJ_CONTAINER_LINK_FULL(container,newobj,data,field,hashfunc,hashoffset,comparefunc) \ do { \ ASTOBJ_CONTAINER_WRLOCK(container); \ (newobj)->next[0] = (container)->head; \ (container)->head = ASTOBJ_REF(newobj); \ ASTOBJ_CONTAINER_UNLOCK(container); \ } while(0) #endif /* List model */ /* Common to hash and linked list models */ /*! \brief Create a container for ASTOBJs (without locking support). * * \param type The type of objects the container will hold. * * This macro is used to create a container for ASTOBJs without locking * support. * * Sample Usage: * \code * struct sample_struct_nolock_container { * ASTOBJ_CONTAINER_COMPONENTS_NOLOCK(struct sample_struct); * }; * \endcode */ #define ASTOBJ_CONTAINER_COMPONENTS_NOLOCK(type) \ ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(type,1,ASTOBJ_DEFAULT_BUCKETS) /*! \brief Create a container for ASTOBJs (with locking support). * * \param type The type of objects the container will hold. * * This macro is used to create a container for ASTOBJs with locking support. * * Sample Usage: * \code * struct sample_struct_container { * ASTOBJ_CONTAINER_COMPONENTS(struct sample_struct); * }; * \endcode */ #define ASTOBJ_CONTAINER_COMPONENTS(type) \ ast_mutex_t _lock; \ ASTOBJ_CONTAINER_COMPONENTS_NOLOCK(type) /*! \brief Initialize a container. * * \param container A pointer to the container to initialize. * * This macro initializes a container. It should only be used on containers * that support locking. * * Sample Usage: * \code * struct sample_struct_container { * ASTOBJ_CONTAINER_COMPONENTS(struct sample_struct); * } container; * * int func() * { * ASTOBJ_CONTAINER_INIT(&container); * } * \endcode */ #define ASTOBJ_CONTAINER_INIT(container) \ ASTOBJ_CONTAINER_INIT_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) /*! \brief Destroy a container. * * \param container A pointer to the container to destory. * * This macro frees up resources used by a container. It does not operate on * the objects in the container. To unlink the objects from the container use * #ASTOBJ_CONTAINER_DESTROYALL(). * * \note This macro should only be used on containers with locking support. */ #define ASTOBJ_CONTAINER_DESTROY(container) \ ASTOBJ_CONTAINER_DESTROY_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) /*! \brief Add an object to a container. * * \param container A pointer to the container to operate on. * \param newobj A pointer to the object to be added. * * Currently this macro adds an object to the head of a container. One day it * should add an object in alphabetical order. */ #define ASTOBJ_CONTAINER_LINK(container,newobj) \ ASTOBJ_CONTAINER_LINK_FULL(container,newobj,(newobj)->name,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp) /*! \brief Mark all the objects in a container. * \param container A pointer to the container to operate on. */ #define ASTOBJ_CONTAINER_MARKALL(container) \ ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_MARK(iterator)) /*! \brief Unmark all the objects in a container. * \param container A pointer to the container to operate on. */ #define ASTOBJ_CONTAINER_UNMARKALL(container) \ ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_UNMARK(iterator)) /*! \brief Dump information about an object into a string. * * \param s A pointer to the string buffer to use. * \param slen The length of s. * \param obj A pointer to the object to dump. * * This macro dumps a text representation of the name, objectflags, and * refcount fields of an object to the specfied string buffer. */ #define ASTOBJ_DUMP(s,slen,obj) \ snprintf((s),(slen),"name: %s\nobjflags: %d\nrefcount: %d\n\n", (obj)->name, (obj)->objflags, (obj)->refcount); /*! \brief Dump information about all the objects in a container to a file descriptor. * * \param fd The file descriptor to write to. * \param s A string buffer, same as #ASTOBJ_DUMP(). * \param slen The length of s, same as #ASTOBJ_DUMP(). * \param container A pointer to the container to dump. * * This macro dumps a text representation of the name, objectflags, and * refcount fields of all the objects in a container to the specified file * descriptor. */ #define ASTOBJ_CONTAINER_DUMP(fd,s,slen,container) \ ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, "%s", s); } while(0)) #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_ASTOBJ_H */ asterisk-11.7.0/include/asterisk/translate.h0000644000175000007640000003261611531040421020762 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Support for translation of data formats. * \ref translate.c */ #ifndef _ASTERISK_TRANSLATE_H #define _ASTERISK_TRANSLATE_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #if 1 /* need lots of stuff... */ #include "asterisk/frame.h" #include "asterisk/plc.h" #include "asterisk/linkedlists.h" #endif struct ast_trans_pvt; /* declared below */ /*! * \brief Translator Cost Table definition. * * \note The defined values in this table must be used to set * the translator's table_cost value. * * \note The cost value of the first two values must always add * up to be greater than the largest value defined in this table. * This is done to guarantee a direct translation will always * have precedence over a multi step translation. * * \details This table is built in a way that allows translation * paths to be built that guarantee the best possible balance * between performance and quality. With this table direct * translation paths between two formats will always take precedence * over multi step paths, lossless intermediate steps will always * be chosen over lossy intermediate steps, and preservation of * sample rate across the translation will always have precedence * over a path that involves any re-sampling. */ enum ast_trans_cost_table { /* Lossless Source Translation Costs */ /*! [lossless -> lossless] original sampling */ AST_TRANS_COST_LL_LL_ORIGSAMP = 400000, /*! [lossless -> lossy] original sampling */ AST_TRANS_COST_LL_LY_ORIGSAMP = 600000, /*! [lossless -> lossless] up sample */ AST_TRANS_COST_LL_LL_UPSAMP = 800000, /*! [lossless -> lossy] up sample */ AST_TRANS_COST_LL_LY_UPSAMP = 825000, /*! [lossless -> lossless] down sample */ AST_TRANS_COST_LL_LL_DOWNSAMP = 850000, /*! [lossless -> lossy] down sample */ AST_TRANS_COST_LL_LY_DOWNSAMP = 875000, /*! [lossless -> unknown] unknown. * This value is for a lossless source translation * with an unknown destination and or sample rate conversion. */ AST_TRANS_COST_LL_UNKNOWN = 885000, /* Lossy Source Translation Costs */ /*! [lossy -> lossless] original sampling */ AST_TRANS_COST_LY_LL_ORIGSAMP = 900000, /*! [lossy -> lossy] original sampling */ AST_TRANS_COST_LY_LY_ORIGSAMP = 915000, /*! [lossy -> lossless] up sample */ AST_TRANS_COST_LY_LL_UPSAMP = 930000, /*! [lossy -> lossy] up sample */ AST_TRANS_COST_LY_LY_UPSAMP = 945000, /*! [lossy -> lossless] down sample */ AST_TRANS_COST_LY_LL_DOWNSAMP = 960000, /*! [lossy -> lossy] down sample */ AST_TRANS_COST_LY_LY_DOWNSAMP = 975000, /*! [lossy -> unknown] unknown. * This value is for a lossy source translation * with an unknown destination and or sample rate conversion. */ AST_TRANS_COST_LY_UNKNOWN = 985000, }; /*! \brief * Descriptor of a translator. * * Name, callbacks, and various options * related to run-time operation (size of buffers, auxiliary * descriptors, etc). * * A codec registers itself by filling the relevant fields * of a structure and passing it as an argument to * ast_register_translator(). The structure should not be * modified after a successful registration, and its address * must be used as an argument to ast_unregister_translator(). * * As a minimum, a translator should supply name, srcfmt and dstfmt, * the required buf_size (in bytes) and buffer_samples (in samples), * and a few callbacks (framein, frameout, sample). * The outbuf is automatically prepended by AST_FRIENDLY_OFFSET * spare bytes so generic routines can place data in there. * * Note, the translator is not supposed to do any memory allocation * or deallocation, nor any locking, because all of this is done in * the generic code. * * Translators using generic plc (packet loss concealment) should * supply a non-zero plc_samples indicating the size (in samples) * of artificially generated frames and incoming data. * Generic plc is only available for dstfmt = SLINEAR */ struct ast_translator { char name[80]; /*!< Name of translator */ struct ast_format src_format; /*!< Source format */ struct ast_format dst_format; /*!< Destination format */ int table_cost; /*!< Cost value associated with this translator based * on translation cost table. */ int comp_cost; /*!< Cost value associated with this translator based * on computation time. This cost value is computed based * on the time required to translate sample data. */ int (*newpvt)(struct ast_trans_pvt *); /*!< initialize private data * associated with the translator */ int (*framein)(struct ast_trans_pvt *pvt, struct ast_frame *in); /*!< Input frame callback. Store * (and possibly convert) input frame. */ struct ast_frame * (*frameout)(struct ast_trans_pvt *pvt); /*!< Output frame callback. Generate a frame * with outbuf content. */ void (*destroy)(struct ast_trans_pvt *pvt); /*!< cleanup private data, if needed * (often unnecessary). */ struct ast_frame * (*sample)(void); /*!< Generate an example frame */ /*!\brief size of outbuf, in samples. Leave it 0 if you want the framein * callback deal with the frame. Set it appropriately if you * want the code to checks if the incoming frame fits the * outbuf (this is e.g. required for plc). */ int buffer_samples; /*< size of outbuf, in samples */ /*! \brief size of outbuf, in bytes. Mandatory. The wrapper code will also * allocate an AST_FRIENDLY_OFFSET space before. */ int buf_size; int desc_size; /*!< size of private descriptor in pvt->pvt, if any */ int native_plc; /*!< true if the translator can do native plc */ struct ast_module *module; /*!< opaque reference to the parent module */ int active; /*!< Whether this translator should be used or not */ int src_fmt_index; /*!< index of the source format in the matrix table */ int dst_fmt_index; /*!< index of the destination format in the matrix table */ AST_LIST_ENTRY(ast_translator) list; /*!< link field */ }; /*! \brief * Default structure for translators, with the basic fields and buffers, * all allocated as part of the same chunk of memory. The buffer is * preceded by \ref AST_FRIENDLY_OFFSET bytes in front of the user portion. * 'buf' points right after this space. * * *_framein() routines operate in two ways: * 1. some convert on the fly and place the data directly in outbuf; * in this case 'samples' and 'datalen' contain the number of samples * and number of bytes available in the buffer. * In this case we can use a generic *_frameout() routine that simply * takes whatever is there and places it into the output frame. * 2. others simply store the (unconverted) samples into a working * buffer, and leave the conversion task to *_frameout(). * In this case, the intermediate buffer must be in the private * descriptor, 'datalen' is left to 0, while 'samples' is still * updated with the number of samples received. */ struct ast_trans_pvt { struct ast_translator *t; struct ast_frame f; /*!< used in frameout */ /*! If a translation path using a format with attributes requires the output * to be a specific set of attributes, this variable will be set describing those * attributes to the translator. Otherwise, the translator must choose a set * of format attributes for the destination that preserves the quality of the * audio in the best way possible. */ struct ast_format explicit_dst; int samples; /*!< samples available in outbuf */ /*! \brief actual space used in outbuf */ int datalen; void *pvt; /*!< more private data, if any */ union { char *c; /*!< the useful portion of the buffer */ unsigned char *uc; /*!< the useful portion of the buffer */ int16_t *i16; uint8_t *ui8; } outbuf; plc_state_t *plc; /*!< optional plc pointer */ struct ast_trans_pvt *next; /*!< next in translator chain */ struct timeval nextin; struct timeval nextout; }; /*! \brief generic frameout function */ struct ast_frame *ast_trans_frameout(struct ast_trans_pvt *pvt, int datalen, int samples); struct ast_trans_pvt; /*! * \brief Register a translator * This registers a codec translator with asterisk * \param t populated ast_translator structure * \param module handle to the module that owns this translator * \return 0 on success, -1 on failure */ int __ast_register_translator(struct ast_translator *t, struct ast_module *module); /*! \brief See \ref __ast_register_translator() */ #define ast_register_translator(t) __ast_register_translator(t, ast_module_info->self) /*! * \brief Unregister a translator * Unregisters the given tranlator * \param t translator to unregister * \return 0 on success, -1 on failure */ int ast_unregister_translator(struct ast_translator *t); /*! * \brief Activate a previously deactivated translator * \param t translator to activate * \return nothing * * Enables the specified translator for use. */ void ast_translator_activate(struct ast_translator *t); /*! * \brief Deactivate a translator * \param t translator to deactivate * \return nothing * * Disables the specified translator from being used. */ void ast_translator_deactivate(struct ast_translator *t); /*! * \brief Chooses the best translation path * * Given a list of sources, and a designed destination format, which should * I choose? * * \param destination capabilities * \param source capabilities * \param destination format chosen out of destination capabilities * \param source format chosen out of source capabilities * \return Returns 0 on success, -1 if no path could be found. * * \note dst_cap and src_cap are not mondified. */ int ast_translator_best_choice(struct ast_format_cap *dst_cap, struct ast_format_cap *src_cap, struct ast_format *dst_fmt_out, struct ast_format *src_fmt_out); /*! * \brief Builds a translator path * Build a path (possibly NULL) from source to dest * \param dest destination format * \param source source format * \return ast_trans_pvt on success, NULL on failure * */ struct ast_trans_pvt *ast_translator_build_path(struct ast_format *dest, struct ast_format *source); /*! * \brief Frees a translator path * Frees the given translator path structure * \param tr translator path to get rid of */ void ast_translator_free_path(struct ast_trans_pvt *tr); /*! * \brief translates one or more frames * Apply an input frame into the translator and receive zero or one output frames. Consume * determines whether the original frame should be freed * \param tr translator structure to use for translation * \param f frame to translate * \param consume Whether or not to free the original frame * \return an ast_frame of the new translation format on success, NULL on failure */ struct ast_frame *ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume); /*! * \brief Returns the number of steps required to convert from 'src' to 'dest'. * \param dest destination format * \param src source format * \return the number of translation steps required, or -1 if no path is available */ unsigned int ast_translate_path_steps(struct ast_format *dest, struct ast_format *src); /*! * \brief Find available formats * \param dest possible destination formats * \param src source formats * \param result capabilities structure to store available formats in * * \return the destination formats that are available in the source or translatable * * The result will include all formats from 'dest' that are either present * in 'src' or translatable from a format present in 'src'. * * \note Only a single audio format and a single video format can be * present in 'src', or the function will produce unexpected results. */ void ast_translate_available_formats(struct ast_format_cap *dest, struct ast_format_cap *src, struct ast_format_cap *result); /*! * \brief Puts a string representation of the translation path into outbuf * \param translator structure containing the translation path * \param ast_str output buffer * \retval on success pointer to beginning of outbuf. on failure "". */ const char *ast_translate_path_to_str(struct ast_trans_pvt *t, struct ast_str **str); /*! * \brief Initialize the translation matrix and index to format conversion table. * \retval 0 on success * \retval -1 on failure */ int ast_translate_init(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_TRANSLATE_H */ asterisk-11.7.0/include/asterisk/endian.h0000644000175000007640000000322711073442005020224 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Asterisk architecture endianess compatibility definitions */ #ifndef _ASTERISK_ENDIAN_H #define _ASTERISK_ENDIAN_H /* * Autodetect system endianess */ #ifndef __BYTE_ORDER #ifdef __linux__ #include #elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) #if defined(__OpenBSD__) #include "asterisk/compat.h" #endif #include #define __BYTE_ORDER BYTE_ORDER #define __LITTLE_ENDIAN LITTLE_ENDIAN #define __BIG_ENDIAN BIG_ENDIAN #else #ifndef __LITTLE_ENDIAN #define __LITTLE_ENDIAN 1234 #endif #ifndef __BIG_ENDIAN #define __BIG_ENDIAN 4321 #endif #ifdef __LITTLE_ENDIAN__ #define __BYTE_ORDER __LITTLE_ENDIAN #endif /* __LITTLE_ENDIAN */ #if defined(i386) || defined(__i386__) #define __BYTE_ORDER __LITTLE_ENDIAN #endif /* defined i386 */ #if defined(sun) && defined(unix) && defined(sparc) #define __BYTE_ORDER __BIG_ENDIAN #endif /* sun unix sparc */ #endif /* linux */ #endif /* __BYTE_ORDER */ #ifndef __BYTE_ORDER #error Need to know endianess #endif /* __BYTE_ORDER */ #endif /* _ASTERISK_ENDIAN_H */ asterisk-11.7.0/include/asterisk/timing.h0000644000175000007640000001502512046043452020260 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008 - 2009, Digium, Inc. * * Kevin P. Fleming * Russell Bryant * * 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 timing.h \brief Timing source management \author Kevin P. Fleming \author Russell Bryant Portions of Asterisk require a timing source, a periodic trigger for media handling activities. The functions in this file allow a loadable module to provide a timing source for Asterisk and its modules, so that those modules can request a 'timing handle' when they require one. These handles are file descriptors, which can be used with select() or poll(). The timing source used by Asterisk must provide the following features: 1) Periodic triggers, with a configurable interval (specified as number of triggers per second). 2) Multiple outstanding triggers, each of which must be 'acked' to clear it. Triggers must also be 'ackable' in quantity. 3) Continuous trigger mode, which when enabled causes every call to poll() on the timer handle to immediately return. 4) Multiple 'event types', so that the code using the timer can know whether the wakeup it received was due to a periodic trigger or a continuous trigger. */ #ifndef _ASTERISK_TIMING_H #define _ASTERISK_TIMING_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif enum ast_timer_event { AST_TIMING_EVENT_EXPIRED = 1, AST_TIMING_EVENT_CONTINUOUS = 2, }; /*! * \brief Timing module interface * * The public API calls for the timing API directly map to this interface. * So, the behavior of these calls should match the documentation of the * public API calls. */ struct ast_timing_interface { const char *name; /*! This handles the case where multiple timing modules are loaded. * The highest priority timing interface available will be used. */ unsigned int priority; int (*timer_open)(void); void (*timer_close)(int handle); int (*timer_set_rate)(int handle, unsigned int rate); int (*timer_ack)(int handle, unsigned int quantity); int (*timer_enable_continuous)(int handle); int (*timer_disable_continuous)(int handle); enum ast_timer_event (*timer_get_event)(int handle); unsigned int (*timer_get_max_rate)(int handle); }; /*! * \brief Register a set of timing functions. * * \param i An instance of the \c ast_timing_interfaces structure with pointers * to the functions provided by the timing implementation. * * \retval NULL failure * \retval non-Null handle to be passed to ast_unregister_timing_interface() on success * \since 1.6.1 */ #define ast_register_timing_interface(i) _ast_register_timing_interface(i, ast_module_info->self) void *_ast_register_timing_interface(struct ast_timing_interface *funcs, struct ast_module *mod); /*! * \brief Unregister a previously registered timing interface. * * \param handle The handle returned from a prior successful call to * ast_register_timing_interface(). * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_unregister_timing_interface(void *handle); struct ast_timer; /*! * \brief Open a timer * * \retval NULL on error, with errno set * \retval non-NULL timer handle on success * \since 1.6.1 */ struct ast_timer *ast_timer_open(void); /*! * \brief Close an opened timing handle * * \param handle timer handle returned from timer_open() * * \return nothing * \since 1.6.1 */ void ast_timer_close(struct ast_timer *handle); /*! * \brief Get a poll()-able file descriptor for a timer * * \param handle timer handle returned from timer_open() * * \return file descriptor which can be used with poll() to wait for events * \since 1.6.1 */ int ast_timer_fd(const struct ast_timer *handle); /*! * \brief Set the timing tick rate * * \param handle timer handle returned from timer_open() * \param rate ticks per second, 0 turns the ticks off if needed * * Use this function if you want the timer to show input at a certain * rate. The other alternative use of a timer is the continuous * mode. * * \retval -1 error, with errno set * \retval 0 success * \since 1.6.1 */ int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate); /*! * \brief Acknowledge a timer event * * \param handle timer handle returned from timer_open() * \param quantity number of timer events to acknowledge * * \note This function should only be called if timer_get_event() * returned AST_TIMING_EVENT_EXPIRED. * * \retval -1 failure, with errno set * \retval 0 success * \since 10.5.2 */ int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity); /*! * \brief Enable continuous mode * * \param handle timer handle returned from timer_open() * * Continuous mode causes poll() on the timer's fd to immediately return * always until continuous mode is disabled. * * \retval -1 failure, with errno set * \retval 0 success * \since 1.6.1 */ int ast_timer_enable_continuous(const struct ast_timer *handle); /*! * \brief Disable continuous mode * * \param handle timer handle returned from timer_close() * * \retval -1 failure, with errno set * \retval 0 success * \since 1.6.1 */ int ast_timer_disable_continuous(const struct ast_timer *handle); /*! * \brief Retrieve timing event * * \param handle timer handle returned by timer_open() * * After poll() indicates that there is input on the timer's fd, this will * be called to find out what triggered it. * * \return which event triggered the timer * \since 1.6.1 */ enum ast_timer_event ast_timer_get_event(const struct ast_timer *handle); /*! * \brief Get maximum rate supported for a timer * * \param handle timer handle returned by timer_open() * * \return maximum rate supported by timer * \since 1.6.1 */ unsigned int ast_timer_get_max_rate(const struct ast_timer *handle); /*! * \brief Get name of timer in use * * \param handle timer handle returned by timer_open() * * \return name of timer * \since 1.6.2 */ const char *ast_timer_get_name(const struct ast_timer *handle); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_TIMING_H */ asterisk-11.7.0/include/asterisk/logger.h0000644000175000007640000003331012205704266020251 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 logger.h \brief Support for logging to various files, console and syslog Configuration in file logger.conf */ #ifndef _ASTERISK_LOGGER_H #define _ASTERISK_LOGGER_H #include "asterisk/options.h" /* need option_debug */ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define EVENTLOG "event_log" #define QUEUELOG "queue_log" #define DEBUG_M(a) { \ a; \ } #define VERBOSE_PREFIX_1 " " #define VERBOSE_PREFIX_2 " == " #define VERBOSE_PREFIX_3 " -- " #define VERBOSE_PREFIX_4 " > " #define AST_CALLID_BUFFER_LENGTH 13 /*! \brief Used for sending a log message This is the standard logger function. Probably the only way you will invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments. \param level Type of log event \param file Will be provided by the AST_LOG_* macro \param line Will be provided by the AST_LOG_* macro \param function Will be provided by the AST_LOG_* macro \param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-) */ void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf, 5, 6))); /* XXX needs documentation */ struct ast_callid; /*! \brief Used for sending a log message with a known call_id This is a modified logger function which is functionally identical to the above logger function, it just include a call_id argument as well. If NULL is specified here, no attempt will be made to join the log message with a call_id. \param level Type of log event \param file Will be provided by the AST_LOG_* macro \param line Will be provided by the AST_LOG_* macro \param function Will be provided by the AST_LOG_* macro \param callid This is the ast_callid that is associated with the log message. May be NULL. \param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-) */ void ast_log_callid(int level, const char *file, int line, const char *function, struct ast_callid *callid, const char *fmt, ...) __attribute__((format(printf, 6, 7))); void ast_backtrace(void); /*! \brief Reload logger without rotating log files */ int logger_reload(void); void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...); /*! Send a verbose message (based on verbose level) * \brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set. * ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing"); * This will print the message to the console if the verbose level is set to a level >= 3 * Note the absence of a comma after the VERBOSE_PREFIX_3. This is important. * VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined. * \version 11 added level parameter */ void __attribute__((format(printf, 5, 6))) __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...); /*! Send a verbose message (based on verbose level) with deliberately specified callid * \brief just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used * for the log without needing to bind it to a thread. NULL is a valid argument for this function and will * allow you to specify that a log will never display a call id even when there is a call id bound to the * thread. */ void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, ...); #define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, __VA_ARGS__) #define ast_verbose_callid(callid, ...) __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, callid, __VA_ARGS__) void __attribute__((format(printf, 6, 0))) __ast_verbose_ap(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, va_list ap); void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...); int ast_register_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result; int ast_unregister_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result; void ast_console_puts(const char *string); /*! * \brief log the string to the console, and all attached * console clients * \version 1.6.1 added level parameter */ void ast_console_puts_mutable(const char *string, int level); void ast_console_toggle_mute(int fd, int silent); /*! * \brief enables or disables logging of a specified level to the console * fd specifies the index of the console receiving the level change * level specifies the index of the logging level being toggled * state indicates whether logging will be on or off (0 for off, 1 for on) */ void ast_console_toggle_loglevel(int fd, int level, int state); /* Note: The AST_LOG_* macros below are the same as * the LOG_* macros and are intended to eventually replace * the LOG_* macros to avoid name collisions with the syslog(3) * log levels. However, please do NOT remove * the LOG_* macros from the source since these may be still * needed for third-party modules */ #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__ #ifdef LOG_DEBUG #undef LOG_DEBUG #endif #define __LOG_DEBUG 0 #define LOG_DEBUG __LOG_DEBUG, _A_ #ifdef AST_LOG_DEBUG #undef AST_LOG_DEBUG #endif #define AST_LOG_DEBUG __LOG_DEBUG, _A_ #ifdef LOG_NOTICE #undef LOG_NOTICE #endif #define __LOG_NOTICE 2 #define LOG_NOTICE __LOG_NOTICE, _A_ #ifdef AST_LOG_NOTICE #undef AST_LOG_NOTICE #endif #define AST_LOG_NOTICE __LOG_NOTICE, _A_ #ifdef LOG_WARNING #undef LOG_WARNING #endif #define __LOG_WARNING 3 #define LOG_WARNING __LOG_WARNING, _A_ #ifdef AST_LOG_WARNING #undef AST_LOG_WARNING #endif #define AST_LOG_WARNING __LOG_WARNING, _A_ #ifdef LOG_ERROR #undef LOG_ERROR #endif #define __LOG_ERROR 4 #define LOG_ERROR __LOG_ERROR, _A_ #ifdef AST_LOG_ERROR #undef AST_LOG_ERROR #endif #define AST_LOG_ERROR __LOG_ERROR, _A_ #ifdef LOG_VERBOSE #undef LOG_VERBOSE #endif #define __LOG_VERBOSE 5 #define LOG_VERBOSE __LOG_VERBOSE, _A_ #ifdef AST_LOG_VERBOSE #undef AST_LOG_VERBOSE #endif #define AST_LOG_VERBOSE __LOG_VERBOSE, _A_ #ifdef LOG_DTMF #undef LOG_DTMF #endif #define __LOG_DTMF 6 #define LOG_DTMF __LOG_DTMF, _A_ #ifdef AST_LOG_DTMF #undef AST_LOG_DTMF #endif #define AST_LOG_DTMF __LOG_DTMF, _A_ #define NUMLOGLEVELS 32 /*! * \brief Get the debug level for a module * \param module the name of module * \return the debug level */ unsigned int ast_debug_get_by_module(const char *module); /*! * \brief Get the verbose level for a module * \param module the name of module * \return the verbose level */ unsigned int ast_verbose_get_by_module(const char *module); /*! * \brief Register a new logger level * \param name The name of the level to be registered * \retval -1 if an error occurs * \retval non-zero level to be used with ast_log for sending messages to this level * \since 1.8 */ int ast_logger_register_level(const char *name); /*! * \brief Unregister a previously registered logger level * \param name The name of the level to be unregistered * \return nothing * \since 1.8 */ void ast_logger_unregister_level(const char *name); /*! * \brief factory function to create a new uniquely identifying callid. * * \retval ast_callid struct pointer containing the call id * * \note The newly created callid will be referenced upon creation and this function should be * paired with a call to ast_callid_unref() */ struct ast_callid *ast_create_callid(void); /*! * \brief extracts the callerid from the thread * * \retval ast_callid reference to call_id related to the thread * \retval NULL if no call_id is present in the thread * * This reference must be unreffed before it loses scope to prevent memory leaks. */ struct ast_callid *ast_read_threadstorage_callid(void); /*! * \brief Increase callid reference count * * \param c the ast_callid * * \retval c always */ #define ast_callid_ref(c) ({ ao2_ref(c, +1); (c); }) /*! * \brief Decrease callid reference count * * \param c the ast_callid * * \retval NULL always */ #define ast_callid_unref(c) ({ ao2_ref(c, -1); (NULL); }) /*! * \brief Sets what is stored in the thread storage to the given * callid if it does not match what is already there. * * \retval 0 - success * \retval non-zero - failure */ int ast_callid_threadassoc_change(struct ast_callid *callid); /*! * \brief Adds a known callid to thread storage of the calling thread * * \retval 0 - success * \retval non-zero - failure */ int ast_callid_threadassoc_add(struct ast_callid *callid); /*! * \brief Removes callid from thread storage of the calling thread * * \retval 0 - success * \retval non-zero - failure */ int ast_callid_threadassoc_remove(void); /*! * \brief Checks thread storage for a callid and stores a reference if it exists. * If not, then a new one will be created, bound to the thread, and a reference * to it will be stored. * * \param callid pointer to struct pointer used to store the referenced callid * \retval 0 - callid was found * \retval 1 - callid was created * \retval -1 - the function failed somehow (presumably memory problems) */ int ast_callid_threadstorage_auto(struct ast_callid **callid); /*! * \brief Use in conjunction with ast_callid_threadstorage_auto. Cleans up the * references and if the callid was created by threadstorage_auto, unbinds * the callid from the threadstorage * \param callid The callid set by ast_callid_threadstorage_auto * \param callid_created The integer returned through ast_callid_threadstorage_auto */ void ast_callid_threadstorage_auto_clean(struct ast_callid *callid, int callid_created); /*! * \brief copy a string representation of the callid into a target string * * \param buffer destination of callid string (should be able to store 13 characters or more) * \param buffer_size maximum writable length of the string (Less than 13 will result in truncation) * \param callid Callid for which string is being requested */ void ast_callid_strnprint(char *buffer, size_t buffer_size, struct ast_callid *callid); /*! * \brief Send a log message to a dynamically registered log level * \param level The log level to send the message to * * Like ast_log, the log message may include printf-style formats, and * the data for these must be provided as additional parameters after * the log message. * * \return nothing * \since 1.8 */ #define ast_log_dynamic_level(level, ...) ast_log(level, __FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__) /*! * \brief Log a DEBUG message * \param level The minimum value of option_debug for this message * to get logged */ #define ast_debug(level, ...) do { \ if (option_debug >= (level) || (ast_opt_dbg_module && ast_debug_get_by_module(AST_MODULE) >= (level)) ) \ ast_log(AST_LOG_DEBUG, __VA_ARGS__); \ } while (0) #define ast_verb(level, ...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, __VA_ARGS__) #define ast_verb_callid(level, callid, ...) __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, callid, __VA_ARGS__) #ifndef _LOGGER_BACKTRACE_H #define _LOGGER_BACKTRACE_H #ifdef HAVE_BKTR #define AST_MAX_BT_FRAMES 32 /* \brief * * A structure to hold backtrace information. This structure provides an easy means to * store backtrace information or pass backtraces to other functions. */ struct ast_bt { /*! The addresses of the stack frames. This is filled in by calling the glibc backtrace() function */ void *addresses[AST_MAX_BT_FRAMES]; /*! The number of stack frames in the backtrace */ int num_frames; /*! Tells if the ast_bt structure was dynamically allocated */ unsigned int alloced:1; }; /* \brief * Allocates memory for an ast_bt and stores addresses and symbols. * * \return Returns NULL on failure, or the allocated ast_bt on success * \since 1.6.1 */ struct ast_bt *ast_bt_create(void); /* \brief * Fill an allocated ast_bt with addresses * * \retval 0 Success * \retval -1 Failure * \since 1.6.1 */ int ast_bt_get_addresses(struct ast_bt *bt); /* \brief * * Free dynamically allocated portions of an ast_bt * * \retval NULL. * \since 1.6.1 */ void *ast_bt_destroy(struct ast_bt *bt); /* \brief Retrieve symbols for a set of backtrace addresses * * \param addresses A list of addresses, such as the ->addresses structure element of struct ast_bt. * \param num_frames Number of addresses in the addresses list * \retval NULL Unable to allocate memory * \return List of strings. Free the entire list with a single ast_std_free call. * \since 1.6.2.16 */ char **ast_bt_get_symbols(void **addresses, size_t num_frames); #endif /* HAVE_BKTR */ #endif /* _LOGGER_BACKTRACE_H */ #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_LOGGER_H */ asterisk-11.7.0/include/asterisk/pbx.h0000644000175000007640000014744512253651331017577 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Core PBX routines and definitions. */ #ifndef _ASTERISK_PBX_H #define _ASTERISK_PBX_H #include "asterisk/channel.h" #include "asterisk/sched.h" #include "asterisk/devicestate.h" #include "asterisk/presencestate.h" #include "asterisk/chanvars.h" #include "asterisk/hashtab.h" #include "asterisk/stringfields.h" #include "asterisk/xmldoc.h" #include "asterisk/format.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define AST_MAX_APP 32 /*!< Max length of an application */ #define AST_PBX_GOTO_FAILED -3 #define AST_PBX_KEEP 0 #define AST_PBX_REPLACE 1 /*! \brief Special return values from applications to the PBX * @{ */ #define AST_PBX_HANGUP -1 /*!< Jump to the 'h' exten */ #define AST_PBX_OK 0 /*!< No errors */ #define AST_PBX_ERROR 1 /*!< Jump to the 'e' exten */ #define AST_PBX_INCOMPLETE 12 /*!< Return to PBX matching, allowing more digits for the extension */ /*! @} */ #define PRIORITY_HINT -1 /*!< Special Priority for a hint */ /*! * \brief Extension states * \note States can be combined * \ref AstExtState */ enum ast_extension_states { AST_EXTENSION_REMOVED = -2, /*!< Extension removed */ AST_EXTENSION_DEACTIVATED = -1, /*!< Extension hint removed */ AST_EXTENSION_NOT_INUSE = 0, /*!< No device INUSE or BUSY */ AST_EXTENSION_INUSE = 1 << 0, /*!< One or more devices INUSE */ AST_EXTENSION_BUSY = 1 << 1, /*!< All devices BUSY */ AST_EXTENSION_UNAVAILABLE = 1 << 2, /*!< All devices UNAVAILABLE/UNREGISTERED */ AST_EXTENSION_RINGING = 1 << 3, /*!< All devices RINGING */ AST_EXTENSION_ONHOLD = 1 << 4, /*!< All devices ONHOLD */ }; /*! * \brief extension matchcid types * \note matchcid in ast_exten retains 0/1, this adds 3rd state for functions to specify all * \see ast_context_remove_extension_callerid */ enum ast_ext_matchcid_types { AST_EXT_MATCHCID_OFF = 0, /*!< Match only extensions with matchcid=0 */ AST_EXT_MATCHCID_ON = 1, /*!< Match only extensions with matchcid=1 AND cidmatch matches */ AST_EXT_MATCHCID_ANY = 2, /*!< Match both - used only in functions manipulating ast_exten's */ }; struct ast_context; struct ast_exten; struct ast_include; struct ast_ignorepat; struct ast_sw; enum ast_state_cb_update_reason { /*! The extension state update is a result of a device state changing on the extension. */ AST_HINT_UPDATE_DEVICE = 1, /*! The extension state update is a result of presence state changing on the extension. */ AST_HINT_UPDATE_PRESENCE = 2, }; struct ast_device_state_info { enum ast_device_state device_state; struct ast_channel *causing_channel; char device_name[1]; }; struct ast_state_cb_info { enum ast_state_cb_update_reason reason; enum ast_extension_states exten_state; struct ao2_container *device_state_info; /* holds ast_device_state_info, must be referenced by callback if stored */ enum ast_presence_state presence_state; const char *presence_subtype; const char *presence_message; }; /*! \brief Typedef for devicestate and hint callbacks */ typedef int (*ast_state_cb_type)(char *context, char *id, struct ast_state_cb_info *info, void *data); /*! \brief Typedef for devicestate and hint callback removal indication callback */ typedef void (*ast_state_cb_destroy_type)(int id, void *data); /*! \brief Data structure associated with a custom dialplan function */ struct ast_custom_function { const char *name; /*!< Name */ AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(synopsis); /*!< Synopsis text for 'show functions' */ AST_STRING_FIELD(desc); /*!< Description (help text) for 'show functions <name>' */ AST_STRING_FIELD(syntax); /*!< Syntax text for 'core show functions' */ AST_STRING_FIELD(arguments); /*!< Arguments description */ AST_STRING_FIELD(seealso); /*!< See also */ ); enum ast_doc_src docsrc; /*!< Where the documentation come from */ /*! Read function, if read is supported */ ast_acf_read_fn_t read; /*!< Read function, if read is supported */ /*! Read function, if read is supported. Note: only one of read or read2 * needs to be implemented. In new code, read2 should be implemented as * the way forward, but they should return identical results, within the * constraints of buffer size, if both are implemented. That is, if the * read function is handed a 16-byte buffer, and the result is 17 bytes * long, then the first 15 bytes (remember NULL terminator) should be * the same for both the read and the read2 methods. */ ast_acf_read2_fn_t read2; /*! If no read2 function is provided, what maximum size? */ size_t read_max; /*! Write function, if write is supported */ ast_acf_write_fn_t write; /*!< Write function, if write is supported */ struct ast_module *mod; /*!< Module this custom function belongs to */ AST_RWLIST_ENTRY(ast_custom_function) acflist; }; /*! \brief All switch functions have the same interface, so define a type for them */ typedef int (ast_switch_f)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data); /*!< Data structure associated with an Asterisk switch */ struct ast_switch { AST_LIST_ENTRY(ast_switch) list; const char *name; /*!< Name of the switch */ const char *description; /*!< Description of the switch */ ast_switch_f *exists; ast_switch_f *canmatch; ast_switch_f *exec; ast_switch_f *matchmore; }; struct ast_timing { int hastime; /*!< If time construct exists */ unsigned int monthmask; /*!< Mask for month */ unsigned int daymask; /*!< Mask for date */ unsigned int dowmask; /*!< Mask for day of week (sun-sat) */ unsigned int minmask[48]; /*!< Mask for minute */ char *timezone; /*!< NULL, or zoneinfo style timezone */ }; /*! * \brief Construct a timing bitmap, for use in time-based conditionals. * \param i Pointer to an ast_timing structure. * \param info Standard string containing a timerange, weekday range, monthday range, and month range, as well as an optional timezone. * \retval Returns 1 on success or 0 on failure. */ int ast_build_timing(struct ast_timing *i, const char *info); /*! * \brief Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified. * \param i Pointer to an ast_timing structure. * \retval Returns 1, if the time matches or 0, if the current time falls outside of the specified range. */ int ast_check_timing(const struct ast_timing *i); /*! * \brief Evaluate a pre-constructed bitmap as to whether a particular time falls within the range specified. * \param i Pointer to an ast_timing structure. * \param tv Specified time * \retval Returns 1, if the time matches or 0, if the time falls outside of the specified range. */ int ast_check_timing2(const struct ast_timing *i, const struct timeval tv); /*! * \brief Deallocates memory structures associated with a timing bitmap. * \param i Pointer to an ast_timing structure. * \retval 0 success * \retval non-zero failure (number suitable to pass to \see strerror) */ int ast_destroy_timing(struct ast_timing *i); struct ast_pbx { int dtimeoutms; /*!< Timeout between digits (milliseconds) */ int rtimeoutms; /*!< Timeout for response (milliseconds) */ }; /*! * \brief Register an alternative dialplan switch * * \param sw switch to register * * This function registers a populated ast_switch structure with the * asterisk switching architecture. * * \retval 0 success * \retval non-zero failure */ int ast_register_switch(struct ast_switch *sw); /*! * \brief Unregister an alternative switch * * \param sw switch to unregister * * Unregisters a switch from asterisk. * * \return nothing */ void ast_unregister_switch(struct ast_switch *sw); /*! * \brief Look up an application * * \param app name of the app * * This function searches for the ast_app structure within * the apps that are registered for the one with the name * you passed in. * * \return the ast_app structure that matches on success, or NULL on failure */ struct ast_app *pbx_findapp(const char *app); /*! * \brief Execute an application * * \param c channel to execute on * \param app which app to execute * \param data the data passed into the app * * This application executes an application on a given channel. It * saves the stack and executes the given application passing in * the given data. * * \retval 0 success * \retval -1 failure */ int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data); /*! * \brief Register a new context or find an existing one * * \param extcontexts pointer to the ast_context structure pointer * \param exttable pointer to the hashtable that contains all the elements in extcontexts * \param name name of the new context * \param registrar registrar of the context * * This function allows you to play in two environments: the global contexts (active dialplan) * or an external context set of your choosing. To act on the external set, make sure extcontexts * and exttable are set; for the globals, make sure both extcontexts and exttable are NULL. * * This will first search for a context with your name. If it exists already, it will not * create a new one. If it does not exist, it will create a new one with the given name * and registrar. * * \return NULL on failure, and an ast_context structure on success */ struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar); /*! * \brief Merge the temporary contexts into a global contexts list and delete from the * global list the ones that are being added * * \param extcontexts pointer to the ast_context structure * \param exttable pointer to the ast_hashtab structure that contains all the elements in extcontexts * \param registrar of the context; if it's set the routine will delete all contexts * that belong to that registrar; if NULL only the contexts that are specified * in extcontexts */ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar); /*! * \brief Destroy a context (matches the specified context (or ANY context if NULL) * * \param con context to destroy * \param registrar who registered it * * You can optionally leave out either parameter. It will find it * based on either the ast_context or the registrar name. * * \return nothing */ void ast_context_destroy(struct ast_context *con, const char *registrar); /*! * \brief Find a context * * \param name name of the context to find * * Will search for the context with the given name. * * \return the ast_context on success, NULL on failure. */ struct ast_context *ast_context_find(const char *name); /*! * \brief The result codes when starting the PBX on a channel with ast_pbx_start. * \note AST_PBX_CALL_LIMIT refers to the maxcalls call limit in asterisk.conf * \see ast_pbx_start */ enum ast_pbx_result { AST_PBX_SUCCESS = 0, AST_PBX_FAILED = -1, AST_PBX_CALL_LIMIT = -2, }; /*! * \brief Create a new thread and start the PBX * * \param c channel to start the pbx on * * \see ast_pbx_run for a synchronous function to run the PBX in the * current thread, as opposed to starting a new one. * * \retval Zero on success * \retval non-zero on failure */ enum ast_pbx_result ast_pbx_start(struct ast_channel *c); /*! * \brief Execute the PBX in the current thread * * \param c channel to run the pbx on * * This executes the PBX on a given channel. It allocates a new * PBX structure for the channel, and provides all PBX functionality. * See ast_pbx_start for an asynchronous function to run the PBX in a * new thread as opposed to the current one. * * \retval Zero on success * \retval non-zero on failure */ enum ast_pbx_result ast_pbx_run(struct ast_channel *c); /*! * \brief Options for ast_pbx_run() */ struct ast_pbx_args { union { /*! Pad this out so that we have plenty of room to add options * but still maintain ABI compatibility over time. */ uint64_t __padding; struct { /*! Do not hangup the channel when the PBX is complete. */ unsigned int no_hangup_chan:1; }; }; }; /*! * \brief Execute the PBX in the current thread * * \param c channel to run the pbx on * \param args options for the pbx * * This executes the PBX on a given channel. It allocates a new * PBX structure for the channel, and provides all PBX functionality. * See ast_pbx_start for an asynchronous function to run the PBX in a * new thread as opposed to the current one. * * \retval Zero on success * \retval non-zero on failure */ enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args); /*! * \brief Run the h exten from the given context. * \since 11.0 * * \param chan Channel to run the h exten on. * \param context Context the h exten is in. * * \return Nothing */ void ast_pbx_h_exten_run(struct ast_channel *chan, const char *context); /*! * \brief Run all hangup handlers on the channel. * \since 11.0 * * \param chan Channel to run the hangup handlers on. * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \retval Zero if no hangup handlers run. * \retval non-zero if hangup handlers were run. */ int ast_pbx_hangup_handler_run(struct ast_channel *chan); /*! * \brief Init the hangup handler container on a channel. * \since 11.0 * * \param chan Channel to init the hangup handler container on. * * \return Nothing */ void ast_pbx_hangup_handler_init(struct ast_channel *chan); /*! * \brief Destroy the hangup handler container on a channel. * \since 11.0 * * \param chan Channel to destroy the hangup handler container on. * * \return Nothing */ void ast_pbx_hangup_handler_destroy(struct ast_channel *chan); /*! * \brief Pop the top of the channel hangup handler stack. * \since 11.0 * * \param chan Channel to push the hangup handler onto. * * \retval TRUE if a handler was popped off of the stack. */ int ast_pbx_hangup_handler_pop(struct ast_channel *chan); /*! * \brief Push the given hangup handler onto the channel hangup handler stack. * \since 11.0 * * \param chan Channel to push the hangup handler onto. * \param handler Gosub application parameter string. * * \return Nothing */ void ast_pbx_hangup_handler_push(struct ast_channel *chan, const char *handler); /*! * \brief Add and extension to an extension context. * * \param context context to add the extension to * \param replace * \param extension extension to add * \param priority priority level of extension addition * \param label extension label * \param callerid pattern to match CallerID, or NULL to match any CallerID * \param application application to run on the extension with that priority level * \param data data to pass to the application * \param datad * \param registrar who registered the extension * * \retval 0 success * \retval -1 failure */ int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void (*datad)(void *), const char *registrar); /*! * \brief Add an extension to an extension context, this time with an ast_context *. * * \note For details about the arguments, check ast_add_extension() */ int ast_add_extension2(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void (*datad)(void *), const char *registrar); /*! * \brief Map devstate to an extension state. * * \param[in] devstate device state * * \return the extension state mapping. */ enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate); /*! * \brief Uses hint and devicestate callback to get the state of an extension * * \param c this is not important * \param context which context to look in * \param exten which extension to get state * * \return extension state as defined in the ast_extension_states enum */ int ast_extension_state(struct ast_channel *c, const char *context, const char *exten); /*! * \brief Uses hint and devicestate callback to get the extended state of an extension * \since 11 * * \param c this is not important * \param context which context to look in * \param exten which extension to get state * \param[out] device_state_info ptr to an ao2_container with extended state info, must be unref'd after use. * * \return extension state as defined in the ast_extension_states enum */ int ast_extension_state_extended(struct ast_channel *c, const char *context, const char *exten, struct ao2_container **device_state_info); /*! * \brief Uses hint and presence state callback to get the presence state of an extension * * \param c this is not important * \param context which context to look in * \param exten which extension to get state * \param[out] subtype Further information regarding the presence returned * \param[out] message Custom message further describing current presence * * \note The subtype and message are dynamically allocated and must be freed by * the caller of this function. * * \return returns the presence state value. */ int ast_hint_presence_state(struct ast_channel *c, const char *context, const char *exten, char **subtype, char **message); /*! * \brief Return string representation of the state of an extension * * \param extension_state is the numerical state delivered by ast_extension_state * * \return the state of an extension as string */ const char *ast_extension_state2str(int extension_state); /*! * \brief Registers a state change callback with destructor. * \since 1.8.9 * \since 10.1.0 * * \param context which context to look in * \param exten which extension to get state * \param change_cb callback to call if state changed * \param destroy_cb callback to call when registration destroyed. * \param data to pass to callback * * \note The change_cb is called if the state of an extension is changed. * * \note The destroy_cb is called when the registration is * deleted so the registerer can release any associated * resources. * * \retval -1 on failure * \retval ID on success */ int ast_extension_state_add_destroy(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data); /*! * \brief Registers an extended state change callback with destructor. * \since 11 * * \param context which context to look in * \param exten which extension to get state * \param change_cb callback to call if state changed * \param destroy_cb callback to call when registration destroyed. * \param data to pass to callback * * \note The change_cb is called if the state of an extension is changed. * The extended state is passed to the callback in the device_state_info * member of ast_state_cb_info. * * \note The destroy_cb is called when the registration is * deleted so the registerer can release any associated * resources. * * \retval -1 on failure * \retval ID on success */ int ast_extension_state_add_destroy_extended(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data); /*! * \brief Registers a state change callback * * \param context which context to look in * \param exten which extension to get state * \param change_cb callback to call if state changed * \param data to pass to callback * * \note The change_cb is called if the state of an extension is changed. * * \retval -1 on failure * \retval ID on success */ int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data); /*! * \brief Registers an extended state change callback * \since 11 * * \param context which context to look in * \param exten which extension to get state * \param change_cb callback to call if state changed * \param data to pass to callback * * \note The change_cb is called if the state of an extension is changed. * The extended state is passed to the callback in the device_state_info * member of ast_state_cb_info. * * \retval -1 on failure * \retval ID on success */ int ast_extension_state_add_extended(const char *context, const char *exten, ast_state_cb_type change_cb, void *data); /*! * \brief Deletes a registered state change callback by ID * * \param id of the registered state callback to delete * \param change_cb callback to call if state changed (Used if id == 0 (global)) * * \retval 0 success * \retval -1 failure */ int ast_extension_state_del(int id, ast_state_cb_type change_cb); /*! * \brief If an extension hint exists, return non-zero * * \param hint buffer for hint * \param hintsize size of hint buffer, in bytes * \param name buffer for name portion of hint * \param namesize size of name buffer * \param c Channel from which to return the hint. This is only important when the hint or name contains an expression to be expanded. * \param context which context to look in * \param exten which extension to search for * * \return If an extension within the given context with the priority PRIORITY_HINT * is found, a non zero value will be returned. * Otherwise, 0 is returned. */ int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten); /*! * \brief If an extension hint exists, return non-zero * * \param hint buffer for hint * \param hintsize Maximum size of hint buffer (<0 to prevent growth, >0 to limit growth to that number of bytes, or 0 for unlimited growth) * \param name buffer for name portion of hint * \param namesize Maximum size of name buffer (<0 to prevent growth, >0 to limit growth to that number of bytes, or 0 for unlimited growth) * \param c Channel from which to return the hint. This is only important when the hint or name contains an expression to be expanded. * \param context which context to look in * \param exten which extension to search for * * \return If an extension within the given context with the priority PRIORITY_HINT * is found, a non zero value will be returned. * Otherwise, 0 is returned. */ int ast_str_get_hint(struct ast_str **hint, ssize_t hintsize, struct ast_str **name, ssize_t namesize, struct ast_channel *c, const char *context, const char *exten); /*! * \brief Determine whether an extension exists * * \param c this is not important * \param context which context to look in * \param exten which extension to search for * \param priority priority of the action within the extension * \param callerid callerid to search for * * \note It is possible for autoservice to be started and stopped on c during this * function call, it is important that c is not locked prior to calling this. Otherwise * a deadlock may occur * * \return If an extension within the given context(or callerid) with the given priority * is found a non zero value will be returned. Otherwise, 0 is returned. */ int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid); /*! * \brief Find the priority of an extension that has the specified label * * \param c this is not important * \param context which context to look in * \param exten which extension to search for * \param label label of the action within the extension to match to priority * \param callerid callerid to search for * * \note It is possible for autoservice to be started and stopped on c during this * function call, it is important that c is not locked prior to calling this. Otherwise * a deadlock may occur * * \retval the priority which matches the given label in the extension * \retval -1 if not found. */ int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid); /*! * \brief Find the priority of an extension that has the specified label * * \note It is possible for autoservice to be started and stopped on c during this * function call, it is important that c is not locked prior to calling this. Otherwise * a deadlock may occur * * \note This function is the same as ast_findlabel_extension, except that it accepts * a pointer to an ast_context structure to specify the context instead of the * name of the context. Otherwise, the functions behave the same. */ int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid); /*! * \brief Looks for a valid matching extension * * \param c not really important * \param context context to serach within * \param exten extension to check * \param priority priority of extension path * \param callerid callerid of extension being searched for * * \note It is possible for autoservice to be started and stopped on c during this * function call, it is important that c is not locked prior to calling this. Otherwise * a deadlock may occur * * \return If "exten" *could be* a valid extension in this context with or without * some more digits, return non-zero. Basically, when this returns 0, no matter * what you add to exten, it's not going to be a valid extension anymore */ int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid); /*! * \brief Looks to see if adding anything to this extension might match something. (exists ^ canmatch) * * \param c not really important XXX * \param context context to serach within * \param exten extension to check * \param priority priority of extension path * \param callerid callerid of extension being searched for * * \note It is possible for autoservice to be started and stopped on c during this * function call, it is important that c is not locked prior to calling this. Otherwise * a deadlock may occur * * \return If "exten" *could match* a valid extension in this context with * some more digits, return non-zero. Does NOT return non-zero if this is * an exact-match only. Basically, when this returns 0, no matter * what you add to exten, it's not going to be a valid extension anymore */ int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid); /*! * \brief Determine if a given extension matches a given pattern (in NXX format) * * \param pattern pattern to match * \param extension extension to check against the pattern. * * Checks whether or not the given extension matches the given pattern. * * \retval 1 on match * \retval 0 on failure */ int ast_extension_match(const char *pattern, const char *extension); int ast_extension_close(const char *pattern, const char *data, int needmore); /*! * \brief Determine if one extension should match before another * * \param a extension to compare with b * \param b extension to compare with a * * Checks whether or extension a should match before extension b * * \retval 0 if the two extensions have equal matching priority * \retval 1 on a > b * \retval -1 on a < b */ int ast_extension_cmp(const char *a, const char *b); /*! * \brief Launch a new extension (i.e. new stack) * * \param c not important * \param context which context to generate the extension within * \param exten new extension to add * \param priority priority of new extension * \param callerid callerid of extension * \param found * \param combined_find_spawn * * This adds a new extension to the asterisk extension list. * * \note It is possible for autoservice to be started and stopped on c during this * function call, it is important that c is not locked prior to calling this. Otherwise * a deadlock may occur * * \retval 0 on success * \retval -1 on failure. */ int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn); /*! * \brief Add a context include * * \param context context to add include to * \param include new include to add * \param registrar who's registering it * * Adds an include taking a char * string as the context parameter * * \retval 0 on success * \retval -1 on error */ int ast_context_add_include(const char *context, const char *include, const char *registrar); /*! * \brief Add a context include * * \param con context to add the include to * \param include include to add * \param registrar who registered the context * * Adds an include taking a struct ast_context as the first parameter * * \retval 0 on success * \retval -1 on failure */ int ast_context_add_include2(struct ast_context *con, const char *include, const char *registrar); /*! * \brief Remove a context include * * \note See ast_context_add_include for information on arguments * * \retval 0 on success * \retval -1 on failure */ int ast_context_remove_include(const char *context, const char *include, const char *registrar); /*! * \brief Removes an include by an ast_context structure * * \note See ast_context_add_include2 for information on arguments * * \retval 0 on success * \retval -1 on success */ int ast_context_remove_include2(struct ast_context *con, const char *include, const char *registrar); /*! * \brief Verifies includes in an ast_contect structure * * \param con context in which to verify the includes * * \retval 0 if no problems found * \retval -1 if there were any missing context */ int ast_context_verify_includes(struct ast_context *con); /*! * \brief Add a switch * * \param context context to which to add the switch * \param sw switch to add * \param data data to pass to switch * \param eval whether to evaluate variables when running switch * \param registrar whoever registered the switch * * This function registers a switch with the asterisk switch architecture * * \retval 0 on success * \retval -1 on failure */ int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar); /*! * \brief Adds a switch (first param is a ast_context) * * \note See ast_context_add_switch() for argument information, with the exception of * the first argument. In this case, it's a pointer to an ast_context structure * as opposed to the name. */ int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar); /*! * \brief Remove a switch * * Removes a switch with the given parameters * * \retval 0 on success * \retval -1 on failure */ int ast_context_remove_switch(const char *context, const char *sw, const char *data, const char *registrar); int ast_context_remove_switch2(struct ast_context *con, const char *sw, const char *data, const char *registrar); /*! * \brief Simply remove extension from context * * \param context context to remove extension from * \param extension which extension to remove * \param priority priority of extension to remove (0 to remove all) * \param registrar registrar of the extension * * This function removes an extension from a given context. * * \retval 0 on success * \retval -1 on failure * * @{ */ int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar); int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar, int already_locked); int ast_context_remove_extension_callerid(const char *context, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar); int ast_context_remove_extension_callerid2(struct ast_context *con, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar, int already_locked); /*! @} */ /*! * \brief Add an ignorepat * * \param context which context to add the ignorpattern to * \param ignorepat ignorepattern to set up for the extension * \param registrar registrar of the ignore pattern * * Adds an ignore pattern to a particular context. * * \retval 0 on success * \retval -1 on failure */ int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar); int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar); /* * \brief Remove an ignorepat * * \param context context from which to remove the pattern * \param ignorepat the pattern to remove * \param registrar the registrar of the ignore pattern * * This removes the given ignorepattern * * \retval 0 on success * \retval -1 on failure */ int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar); int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar); /*! * \brief Checks to see if a number should be ignored * * \param context context to search within * \param pattern to check whether it should be ignored or not * * Check if a number should be ignored with respect to dialtone cancellation. * * \retval 0 if the pattern should not be ignored * \retval non-zero if the pattern should be ignored */ int ast_ignore_pattern(const char *context, const char *pattern); /* Locking functions for outer modules, especially for completion functions */ /*! * \brief Write locks the context list * * \retval 0 on success * \retval -1 on error */ int ast_wrlock_contexts(void); /*! * \brief Read locks the context list * * \retval 0 on success * \retval -1 on error */ int ast_rdlock_contexts(void); /*! * \brief Unlocks contexts * * \retval 0 on success * \retval -1 on failure */ int ast_unlock_contexts(void); /*! * \brief Write locks a given context * * \param con context to lock * * \retval 0 on success * \retval -1 on failure */ int ast_wrlock_context(struct ast_context *con); /*! * \brief Read locks a given context * * \param con context to lock * * \retval 0 on success * \retval -1 on failure */ int ast_rdlock_context(struct ast_context *con); /*! * \retval Unlocks the given context * * \param con context to unlock * * \retval 0 on success * \retval -1 on failure */ int ast_unlock_context(struct ast_context *con); /*! * \brief locks the macrolock in the given given context * * \param macrocontext name of the macro-context to lock * * Locks the given macro-context to ensure only one thread (call) can execute it at a time * * \retval 0 on success * \retval -1 on failure */ int ast_context_lockmacro(const char *macrocontext); /*! * \brief Unlocks the macrolock in the given context * * \param macrocontext name of the macro-context to unlock * * Unlocks the given macro-context so that another thread (call) can execute it * * \retval 0 on success * \retval -1 on failure */ int ast_context_unlockmacro(const char *macrocontext); /*! * \brief Set the channel to next execute the specified dialplan location. * \see ast_async_parseable_goto, ast_async_goto_if_exists * * \note Do _NOT_ hold any channel locks when calling this function. */ int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority); /*! * \brief Set the channel to next execute the specified dialplan location. */ int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority); /*! Synchronously or asynchronously make an outbound call and send it to a particular extension */ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media); /*! Synchronously or asynchronously make an outbound call and send it to a particular application with given extension */ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel); /*! * \brief Evaluate a condition * * \retval 0 if the condition is NULL or of zero length * \retval int If the string is an integer, the integer representation of * the integer is returned * \retval 1 Any other non-empty string */ int pbx_checkcondition(const char *condition); /*! @name * Functions for returning values from structures */ /*! @{ */ const char *ast_get_context_name(struct ast_context *con); const char *ast_get_extension_name(struct ast_exten *exten); struct ast_context *ast_get_extension_context(struct ast_exten *exten); const char *ast_get_include_name(struct ast_include *include); const char *ast_get_ignorepat_name(struct ast_ignorepat *ip); const char *ast_get_switch_name(struct ast_sw *sw); const char *ast_get_switch_data(struct ast_sw *sw); int ast_get_switch_eval(struct ast_sw *sw); /*! @} */ /*! @name Other Extension stuff */ /*! @{ */ int ast_get_extension_priority(struct ast_exten *exten); int ast_get_extension_matchcid(struct ast_exten *e); const char *ast_get_extension_cidmatch(struct ast_exten *e); const char *ast_get_extension_app(struct ast_exten *e); const char *ast_get_extension_label(struct ast_exten *e); void *ast_get_extension_app_data(struct ast_exten *e); /*! @} */ /*! @name Registrar info functions ... */ /*! @{ */ const char *ast_get_context_registrar(struct ast_context *c); const char *ast_get_extension_registrar(struct ast_exten *e); const char *ast_get_include_registrar(struct ast_include *i); const char *ast_get_ignorepat_registrar(struct ast_ignorepat *ip); const char *ast_get_switch_registrar(struct ast_sw *sw); /*! @} */ /*! @name Walking functions ... */ /*! @{ */ struct ast_context *ast_walk_contexts(struct ast_context *con); struct ast_exten *ast_walk_context_extensions(struct ast_context *con, struct ast_exten *priority); struct ast_exten *ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority); struct ast_include *ast_walk_context_includes(struct ast_context *con, struct ast_include *inc); struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip); struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw); /*! @} */ /*! * \brief Create a human-readable string, specifying all variables and their corresponding values. * \param chan Channel from which to read variables * \param buf Dynamic string in which to place the result (should be allocated with ast_str_create). * \see ast_str_create * \note Will lock the channel. */ int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf); /*! * \brief Return a pointer to the value of the corresponding channel variable. * \note Will lock the channel. * * \note This function will return a pointer to the buffer inside the channel * variable. This value should only be accessed with the channel locked. If * the value needs to be kept around, it should be done by using the following * thread-safe code: * \code * const char *var; * * ast_channel_lock(chan); * if ((var = pbx_builtin_getvar_helper(chan, "MYVAR"))) { * var = ast_strdupa(var); * } * ast_channel_unlock(chan); * \endcode */ const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name); /*! * \brief Add a variable to the channel variable stack, without removing any previously set value. * \note Will lock the channel. */ void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value); /*! * \brief Add a variable to the channel variable stack, removing the most recently set value for the same name. * \note Will lock the channel. May also be used to set a channel dialplan function to a particular value. * \see ast_func_write * \return -1 if the dialplan function fails to be set * \version 1.8 changed the function to return an error code */ int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value); /*! * \brief Retrieve the value of a builtin variable or variable from the channel variable stack. * \note Will lock the channel. */ void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp); void pbx_builtin_clear_globals(void); /*! * \brief Parse and set a single channel variable, where the name and value are separated with an '=' character. * \note Will lock the channel. */ int pbx_builtin_setvar(struct ast_channel *chan, const char *data); /*! * \brief Parse and set multiple channel variables, where the pairs are separated by the ',' character, and name and value are separated with an '=' character. * \note Will lock the channel. */ int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *data); int pbx_builtin_raise_exception(struct ast_channel *chan, const char *data); /*! @name Substitution routines, using static string buffers * @{ */ void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count); void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count); void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int cp2_size, size_t *used); /*! @} */ /*! @} */ /*! @name Substitution routines, using dynamic string buffers */ /*! * \param buf Result will be placed in this buffer. * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes. * \param chan Channel variables from which to extract values, and channel to pass to any dialplan functions. * \param headp If no channel is specified, a channel list from which to extract variable values * \param var Variable name to retrieve. */ const char *ast_str_retrieve_variable(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, struct varshead *headp, const char *var); /*! * \param buf Result will be placed in this buffer. * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes. * \param chan Channel variables from which to extract values, and channel to pass to any dialplan functions. * \param templ Variable template to expand. */ void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ); /*! * \param buf Result will be placed in this buffer. * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes. * \param headp If no channel is specified, a channel list from which to extract variable values * \param templ Variable template to expand. */ void ast_str_substitute_variables_varshead(struct ast_str **buf, ssize_t maxlen, struct varshead *headp, const char *templ); /*! * \param buf Result will be placed in this buffer. * \param maxlen -1 if the buffer should not grow, 0 if the buffer may grow to any size, and >0 if the buffer should grow only to that number of bytes. * \param c Channel variables from which to extract values, and channel to pass to any dialplan functions. * \param headp If no channel is specified, a channel list from which to extract variable values * \param templ Variable template to expand. * \param used Number of bytes read from the template. */ void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used); /*! @} */ int ast_extension_patmatch(const char *pattern, const char *data); /*! Set "autofallthrough" flag, if newval is <0, does not actually set. If set to 1, sets to auto fall through. If newval set to 0, sets to no auto fall through (reads extension instead). Returns previous value. */ int pbx_set_autofallthrough(int newval); /*! Set "extenpatternmatchnew" flag, if newval is <0, does not actually set. If set to 1, sets to use the new Trie-based pattern matcher. If newval set to 0, sets to use the old linear-search algorithm. Returns previous value. */ int pbx_set_extenpatternmatchnew(int newval); /*! Set "overrideswitch" field. If set and of nonzero length, all contexts * will be tried directly through the named switch prior to any other * matching within that context. * \since 1.6.1 */ void pbx_set_overrideswitch(const char *newval); /*! * \note This function will handle locking the channel as needed. */ int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority); /*! * \note This function will handle locking the channel as needed. */ int ast_parseable_goto(struct ast_channel *chan, const char *goto_string); /*! * \note This function will handle locking the channel as needed. */ int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string); /*! * \note This function will handle locking the channel as needed. */ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority); /*! * \note This function will handle locking the channel as needed. */ int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority); struct ast_custom_function* ast_custom_function_find(const char *name); /*! * \brief Unregister a custom function */ int ast_custom_function_unregister(struct ast_custom_function *acf); /*! * \brief Description of the ways in which a function may escalate privileges. */ enum ast_custom_function_escalation { AST_CFE_NONE, AST_CFE_READ, AST_CFE_WRITE, AST_CFE_BOTH, }; /*! * \brief Register a custom function */ #define ast_custom_function_register(acf) __ast_custom_function_register(acf, ast_module_info->self) /*! * \brief Register a custom function which requires escalated privileges. * * Examples would be SHELL() (for which a read needs permission to execute * arbitrary code) or FILE() (for which write needs permission to change files * on the filesystem). */ #define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, ast_module_info->self) /*! * \brief Register a custom function */ int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod); /*! * \brief Register a custom function which requires escalated privileges. * * Examples would be SHELL() (for which a read needs permission to execute * arbitrary code) or FILE() (for which write needs permission to change files * on the filesystem). */ int __ast_custom_function_register_escalating(struct ast_custom_function *acf, enum ast_custom_function_escalation escalation, struct ast_module *mod); /*! * \brief Retrieve the number of active calls */ int ast_active_calls(void); /*! * \brief Retrieve the total number of calls processed through the PBX since last restart */ int ast_processed_calls(void); /*! * \brief executes a read operation on a function * * \param chan Channel to execute on * \param function Data containing the function call string (will be modified) * \param workspace A pointer to safe memory to use for a return value * \param len the number of bytes in workspace * * This application executes a function in read mode on a given channel. * * \retval 0 success * \retval non-zero failure */ int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len); /*! * \brief executes a read operation on a function * * \param chan Channel to execute on * \param function Data containing the function call string (will be modified) * \param str A dynamic string buffer into which to place the result. * \param maxlen <0 if the dynamic buffer should not grow; >0 if the dynamic buffer should be limited to that number of bytes; 0 if the dynamic buffer has no upper limit * * This application executes a function in read mode on a given channel. * * \retval 0 success * \retval non-zero failure */ int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen); /*! * \brief executes a write operation on a function * * \param chan Channel to execute on * \param function Data containing the function call string (will be modified) * \param value A value parameter to pass for writing * * This application executes a function in write mode on a given channel. * * \retval 0 success * \retval non-zero failure */ int ast_func_write(struct ast_channel *chan, const char *function, const char *value); /*! * \details * When looking up extensions, we can have different requests * identified by the 'action' argument, as follows. * * \note that the coding is such that the low 4 bits are the * third argument to extension_match_core. */ enum ext_match_t { E_MATCHMORE = 0x00, /* extension can match but only with more 'digits' */ E_CANMATCH = 0x01, /* extension can match with or without more 'digits' */ E_MATCH = 0x02, /* extension is an exact match */ E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */ E_SPAWN = 0x12, /* want to spawn an extension. Requires exact match */ E_FINDLABEL = 0x22 /* returns the priority for a given label. Requires exact match */ }; #define STATUS_NO_CONTEXT 1 #define STATUS_NO_EXTENSION 2 #define STATUS_NO_PRIORITY 3 #define STATUS_NO_LABEL 4 #define STATUS_SUCCESS 5 #define AST_PBX_MAX_STACK 128 /* request and result for pbx_find_extension */ struct pbx_find_info { #if 0 const char *context; const char *exten; int priority; #endif char *incstack[AST_PBX_MAX_STACK]; /* filled during the search */ int stacklen; /* modified during the search */ int status; /* set on return */ struct ast_switch *swo; /* set on return */ const char *data; /* set on return */ const char *foundcontext; /* set on return */ }; struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action); /*! \brief hashtable functions for contexts */ /*! @{ */ int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b); unsigned int ast_hashtab_hash_contexts(const void *obj); /*! @} */ /*! * \brief Command completion for the list of installed applications. * * This can be called from a CLI command completion function that wants to * complete from the list of available applications. */ char *ast_complete_applications(const char *line, const char *word, int state); /*! * \brief Enable/disable the execution of 'dangerous' functions from external * protocols (AMI, etc.). * * These dialplan functions (such as \c SHELL) provide an opportunity for * privilege escalation. They are okay to invoke from the dialplan, but external * protocols with permission controls should not normally invoke them. * * This function can globally enable/disable the execution of dangerous * functions from external protocols. * * \param new_live_dangerously If true, enable the execution of escalating * functions from external protocols. */ void pbx_live_dangerously(int new_live_dangerously); /*! * \brief Inhibit (in the current thread) the execution of dialplan functions * which cause privilege escalations. If pbx_live_dangerously() has been * called, this function has no effect. * * \return 0 if successfuly marked current thread. * \return Non-zero if marking current thread failed. */ int ast_thread_inhibit_escalations(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_PBX_H */ asterisk-11.7.0/include/asterisk/config_options.h0000644000175000007640000007075112002113204022001 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Digium, Inc. * * Mark Spencer * * 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 Configuration option-handling * \author Terry Wilson */ #ifndef _ASTERISK_CONFIG_OPTIONS_H #define _ASTERISK_CONFIG_OPTIONS_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include #include "asterisk/config.h" #include "asterisk/astobj2.h" struct aco_option; struct aco_info_internal; struct aco_type_internal; enum aco_type_t { ACO_GLOBAL, ACO_ITEM, }; /*! \brief Whether a category regex is a blackist or a whitelist */ enum aco_category_op { ACO_BLACKLIST = 0, ACO_WHITELIST, }; /*! \brief What kind of matching should be done on an option name */ enum aco_matchtype { ACO_EXACT = 1, ACO_REGEX, }; /*! Callback functions for option parsing via aco_process_config() */ /*! \brief Allocate a configurable ao2 object * \param category The config category the object is being generated for * \retval NULL error * \retval non-NULL a new configurable ao2 object */ typedef void *(*aco_type_item_alloc)(const char *category); /*! \brief Find a item given a category and container of items * \param container The container to search for the item * \param category The category associated with the item * \retval non-NULL item from the container * \retval NULL item does not exist in container */ typedef void *(*aco_type_item_find)(struct ao2_container *newcontainer, const char *category); /*! \brief Callback function that is called after a config object is initialized with defaults * * \note This callback is called during config processing after a new config is allocated and * and defaults applied but before values from the config are read. This callback could be used * to merge in settings inherited from the global settings if necessary, despite that being a * bad thing to do! * * \param newitem The newly allocated config object with defaults populated * \retval 0 succes, continue processing * \retval non-zero failure, stop processing */ typedef int (*aco_type_item_pre_process)(void *newitem); /*! \brief Callback function that is called after config processing, but before linking * * \note This callback is called after config processing, but before linking the object * in the config container. This callback can be used to verify that all settings make * sense together, that required options have been set, etc. * * \param newitem The newly configured object * \retval 0 success, continue processing * \retval non-zero failure, stop processing */ typedef int (*aco_type_prelink)(void *newitem); /*! \brief A function for determining whether the value for the matchfield in an aco_type is sufficient for a match * \param text The value of the option * \retval -1 The value is sufficient for a match * \retval 0 The value is not sufficient for a match */ typedef int (*aco_matchvalue_func)(const char *text); /*! \struct aco_type * \brief Type information about a category-level configurable object */ struct aco_type { /* common stuff */ enum aco_type_t type; /*!< Whether this is a global or item type */ const char *category; /*!< A regular expression for matching categories to be allowed or denied */ const char *matchfield; /*!< An option name to match for this type (i.e. a 'type'-like column) */ const char *matchvalue; /*!< The value of the option to require for matching (i.e. 'peer' for type= in sip.conf) */ aco_matchvalue_func matchfunc; /*!< A function for determing whether the option value matches (i.e. hassip= requires ast_true()) */ enum aco_category_op category_match; /*!< Whether the following category regex is a whitelist or blacklist */ size_t item_offset; /*!< The offset in the config snapshot for the global config or item config container */ /* non-global callbacks */ aco_type_item_alloc item_alloc; /*!< An allocation function for item associated with this type */ aco_type_item_find item_find; /*!< A callback function to find an existing item in a particular container */ aco_type_item_pre_process item_pre_process; /*!< An optional callback function that is called after defaults are applied, but before config processing */ aco_type_prelink item_prelink; /*!< An optional callback function that is called after config processing, but before applying changes */ struct aco_type_internal *internal; }; /*! \brief A callback function to run just prior to applying config changes * \retval 0 Success * \retval non-zero Failure. Changes not applied */ typedef int (*aco_pre_apply_config)(void); /*! \brief A callback function called only if config changes have been applied * * \note If a config file has not been edited prior to performing a reload, this * callback will not be called. */ typedef void (*aco_post_apply_config)(void); /*! \brief A callback function for allocating an object to hold all config objects * \retval NULL error * \retval non-NULL a config object container */ typedef void *(*aco_snapshot_alloc)(void); /*! \brief The representation of a single configuration file to be processed */ struct aco_file { const char *filename; /*!< \brief The filename to be processed */ const char *alias; /*!< \brief An alias filename to be tried if 'filename' cannot be found */ const char **preload; /*!< \brief A null-terminated oredered array of categories to be loaded first */ struct aco_type *types[]; /*!< The list of types for this config. Required. Use a sentinel! */ }; struct aco_info { const char *module; /*!< The name of the module whose config is being processed */ aco_pre_apply_config pre_apply_config; /*!< A callback called after processing, but before changes are applied */ aco_post_apply_config post_apply_config;/*!< A callback called after changes are applied */ aco_snapshot_alloc snapshot_alloc; /*!< Allocate an object to hold all global configs and item containers */ struct ao2_global_obj *global_obj; /*!< The global object array that holds the user-defined config object */ struct aco_info_internal *internal; struct aco_file *files[]; /*!< An array of aco_files to process */ }; /*! \brief A helper macro to ensure that aco_info types always have a sentinel */ #define ACO_TYPES(...) { __VA_ARGS__, NULL, } #define ACO_FILES(...) { __VA_ARGS__, NULL, } /*! \brief Get pending config changes * \note This will most likely be called from the pre_apply_config callback function * \param info An initialized aco_info * \retval NULL error * \retval non-NULL A pointer to the user-defined config object with un-applied changes */ void *aco_pending_config(struct aco_info *info); /*! \def CONFIG_INFO_STANDARD * \brief Declare an aco_info struct with default module and preload values * \param name The name of the struct * \param fn The filename of the config * \param arr The global object array for holding the user-defined config object * \param alloc The allocater for the user-defined config object * * Example: * \code * static AO2_GLOBAL_OBJ_STATIC(globals, 1); * CONFIG_INFO_STANDARD(cfg_info, globals, skel_config_alloc, * .pre_apply_config = skel_pre_apply_config, * .files = { &app_skel_conf, NULL }, * ); * ... * if (aco_info_init(&cfg_info)) { * return AST_MODULE_LOAD_DECLINE; * } * ... * aco_info_destroy(&cfg_info); * \endcode */ #define CONFIG_INFO_STANDARD(name, arr, alloc, ...) \ static struct aco_info name = { \ .module = AST_MODULE, \ .global_obj = &arr, \ .snapshot_alloc = alloc, \ __VA_ARGS__ \ }; /*! \brief Initialize an aco_info structure * \note aco_info_destroy must be called if this succeeds * \param info The address of an aco_info struct to initialize * \retval 0 Success * \retval non-zero Failure */ int aco_info_init(struct aco_info *info); /*! \brief Destroy an initialized aco_info struct * \param info The address of the aco_info struct to destroy */ void aco_info_destroy(struct aco_info *info); /*! \brief The option types * * \note aco_option_register takes an option type which is used * to look up the handler for that type. Each non-custom type requires * field names for specific types in the struct being configured. Each * option below is commented with the field types, additional arguments * and example usage with aco_option_register */ enum aco_option_type { /*! \brief Type for default option handler for ACLs * \note aco_option_register flags: * non-zero : "permit" * 0 : "deny" * aco_option_register varargs: * FLDSET macro with the field of type struct ast_ha *. * * Example: * {code} * struct test_item { * struct ast_ha *ha; * }; * aco_option_register(&cfg_info, "permit", ACO_EXACT, my_types, NULL, OPT_ACL_T, 1, FLDSET(struct test_item, ha)); * aco_option_register(&cfg_info, "deny", ACO_EXACT, my_types, NULL, OPT_ACL_T, 0, FLDSET(struct test_item, ha)); * {code} */ OPT_ACL_T, /*! \brief Type for default option handler for bools (ast_true/ast_false) * \note aco_option_register flags: * non-zero : process via ast_true * 0 : process via ast_false * aco_option_register varargs: * FLDSET macro with the field of type int. It is important to note that the field * cannot be a bitfield. If bitfields are required, they must be set via a custom handler. * * Example: * {code} * struct test_item { * int enabled; * }; aco_option_register(&cfg_info, "enabled", ACO_EXACT, my_types, "no", OPT_BOOL_T, 1, FLDSET(struct test_item, enabled)); * {endcode} */ OPT_BOOL_T, /*! \brief Type for default option handler for bools (ast_true/ast_false) that are stored in a flag * \note aco_option_register flags: * non-zero : process via ast_true * 0 : process via ast_false * aco_option_register varargs: * FLDSET macro with the field of type of unsigned int. * The flag to set * * Example: * {code} * #define MY_TYPE_ISQUIET 1 << 4 * struct test_item { * unsigned int flags; * }; aco_option_register(&cfg_info, "quiet", ACO_EXACT, my_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct test_item, flags), MY_TYPE_ISQUIET); * {endcode} */ OPT_BOOLFLAG_T, /*! \brief Type for default option handler for character arrays * \note aco_option_register varargs: * CHARFLDSET macro with a field of type char[] * * Example: * {code} * struct test_item { * char description[128]; * }; * aco_option_register(&cfg_info, "description", ACO_EXACT, my_types, "none", OPT_CHAR_ARRAY_T, CHARFLDSET(struct test_item, description)); * {endcode} */ OPT_CHAR_ARRAY_T, /*! \brief Type for default option handler for codec preferences/capabilities * \note aco_option_register flags: * non-zero : This is an "allow" style option * 0 : This is a "disallow" style option * aco_option_register varargs: * FLDSET macro with fields representing a struct ast_codec_pref and a struct ast_format_cap * * * Example: * {code} * struct test_item { * struct ast_codec_pref pref; * struct ast_format cap *cap; * }; * aco_option_register(&cfg_info, "allow", ACO_EXACT, my_types, "ulaw,alaw", OPT_CODEC_T, 1, FLDSET(struct test_item, pref, cap)); * aco_option_register(&cfg_info, "disallow", ACO_EXACT, my_types, "all", OPT_CODEC_T, 0, FLDSET(struct test_item, pref, cap)); * {endcode} */ OPT_CODEC_T, /*! \brief Type for a custom (user-defined) option handler */ OPT_CUSTOM_T, /*! \brief Type for default option handler for doubles * * \note aco_option_register flags: * See flags available for use with the PARSE_DOUBLE type for the ast_parse_arg function * aco_option_register varargs: * FLDSET macro with the field of type double * * Example: * struct test_item { * double dub; * }; * {code} * aco_option_register(&cfg_info, "doubleopt", ACO_EXACT, my_types, "3", OPT_DOUBLE_T, FLDSET(struct test_item, dub)); * {endcode} */ OPT_DOUBLE_T, /*! \brief Type for default option handler for signed integers * * \note aco_option_register flags: * See flags available for use with the PARSE_INT32 type for the ast_parse_arg function * aco_option_register varargs: * FLDSET macro with the field of type int32_t * The remaining varargs for should be arguments compatible with the varargs for the * ast_parse_arg function with the PARSE_INT32 type and the flags passed in the * aco_option_register flags parameter. * * \note In most situations, it is preferable to not pass the PARSE_DEFAULT flag. If a config * contains an invalid value, it is better to let the config loading fail with warnings so that * the problem is fixed by the administrator. * * Example: * struct test_item { * int32_t intopt; * }; * {code} * aco_option_register(&cfg_info, "intopt", ACO_EXACT, my_types, "3", OPT_INT_T, PARSE_IN_RANGE, FLDSET(struct test_item, intopt), -10, 10); * {endcode} */ OPT_INT_T, /*! \brief Type for a default handler that should do nothing * * \note This might be useful for a "type" field that is valid, but doesn't * actually need to do anything */ OPT_NOOP_T, /*! \brief Type for default handler for ast_sockaddrs * * \note aco_option_register flags: * See flags available for use with the PARSE_ADDR type for the ast_parse_arg function * aco_option_register varargs: * FLDSET macro with the field being of type struct ast_sockaddr. * * Example: * {code} * struct test_item { * struct ast_sockaddr addr; * }; * aco_option_register(&cfg_info, "sockaddropt", ACO_EXACT, my_types, "0.0.0.0:1234", OPT_SOCKADDR_T, 0, FLDSET(struct test_item, addr)); * {endcode} */ OPT_SOCKADDR_T, /*! \brief Type for default option handler for stringfields * \note aco_option_register flags: * none * aco_option_register varargs: * STRFLDSET macro with the field being the field created by AST_STRING_FIELD * * Example: * {code} * struct test_item { * AST_DECLARE_STRING_FIELDS( * AST_STRING_FIELD(thing); * ); * }; * aco_option_register(&cfg_info, "thing", ACO_EXACT, my_types, NULL, OPT_STRINGFIELD_T, 0, STRFLDSET(struct test_item, thing)); * {endcode} */ OPT_STRINGFIELD_T, /*! \brief Type for default option handler for unsigned integers * * \note aco_option_register flags: * See flags available for use with the PARSE_UINT32 type for the ast_parse_arg function * aco_option_register varargs: * FLDSET macro with the field of type uint32_t * The remaining varargs for should be arguments compatible with the varargs for the * ast_parse_arg function with the PARSE_UINT32 type and the flags passed in the * aco_option_register flags parameter. * * \note In most situations, it is preferable to not pass the PARSE_DEFAULT flag. If a config * contains an invalid value, it is better to let the config loading fail with warnings so that * the problem is fixed by the administrator. * * Example: * struct test_item { * int32_t intopt; * }; * {code} * aco_option_register(&cfg_info, "uintopt", ACO_EXACT, my_types, "3", OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct test_item, uintopt), 1, 10); * {endcode} */ OPT_UINT_T, }; /*! \brief A callback function for handling a particular option * \param opt The option being configured * \param var The config variable to use to configure \a obj * \param obj The object to be configured * * \retval 0 Parsing and recording the config value succeeded * \retval non-zero Failure. Parsing should stop and no reload applied */ typedef int (*aco_option_handler)(const struct aco_option *opt, struct ast_variable *var, void *obj); /*! \brief Allocate a container to hold config options */ struct ao2_container *aco_option_container_alloc(void); /*! \brief Return values for the aco_process functions */ enum aco_process_status { ACO_PROCESS_OK, /*!< \brief The config was processed and applied */ ACO_PROCESS_UNCHANGED, /*!< \brief The config had not been edited and no changes applied */ ACO_PROCESS_ERROR, /*!< \brief Their was an error and no changes were applied */ }; /*! \brief Process a config info via the options registered with an aco_info * * \param info The config_options_info to be used for handling the config * \param reload Whether or not this is a reload * * \retval ACO_PROCESS_OK Success * \retval ACO_PROCESS_ERROR Failure * \retval ACO_PROCESS_UNCHANGED No change due to unedited config file */ enum aco_process_status aco_process_config(struct aco_info *info, int reload); /*! \brief Process config info from an ast_config via options registered with an aco_info * * \param info The aco_info to be used for handling the config * \param file The file attached to aco_info that the config represents * \param cfg A pointer to a loaded ast_config to parse * \param reload Whether or not this is a reload * * \retval ACO_PROCESS_OK Success * \retval ACO_PROCESS_ERROR Failure */ enum aco_process_status aco_process_ast_config(struct aco_info *info, struct aco_file *file, struct ast_config *cfg); /*! \brief Parse a single ast_variable and apply it to an object * \note This function can be used to build up an object by repeatedly passing in * the config variable name and values that would be found in a config file. This can * be useful if the object is to be populated by a dialplan function, for example. * * \param type The aco_type associated with the object * \param cat The category to use * \param var A variable to apply to the object * \param obj A pointer to the object to be configured * * \retval 0 Success * \retval -1 Failure */ int aco_process_var(struct aco_type *type, const char *cat, struct ast_variable *var, void *obj); /*! \brief Parse each option defined in a config category * \param type The aco_type with the options for parsing * \param cfg The ast_config being parsed * \param cat The config category being parsed * \param obj The user-defined config object that will store the parsed config items * * \retval 0 Success * \retval -1 Failure */ int aco_process_category_options(struct aco_type *type, struct ast_config *cfg, const char *cat, void *obj); /*! \brief Set all default options of \a obj * \param info The aco_type with the options * \param category The configuration category from which \a obj is being configured * \param obj The object being configured * * \retval 0 Success * \retval -1 Failure */ int aco_set_defaults(struct aco_type *type, const char *category, void *obj); /*! \brief register a config option * * \note this should probably only be called by one of the aco_option_register* macros * * \param info The aco_info holding this module's config information * \param name The name of the option * \param types An array of valid option types for matching categories to the correct struct type * \param default_val The default value of the option in the same format as defined in a config file * \param type The option type (only for default handlers) * \param handler The handler function for the option (only for non-default types) * \param flags \a type specific flags, stored in the option and available to the handler * \param argc The number for variadic arguments * \param ... field offsets to store for default handlers * * \retval 0 success * \retval -1 failure */ int __aco_option_register(struct aco_info *info, const char *name, enum aco_matchtype match_type, struct aco_type **types, const char *default_val, enum aco_option_type type, aco_option_handler handler, unsigned int flags, size_t argc, ...); /*! \brief Register a config option * \param info A pointer to the aco_info struct * \param name The name of the option * \param types An array of valid option types for matching categories to the correct struct type * \param default_val The default value of the option in the same format as defined in a config file * \param opt_type The option type for default option type handling * \param flags \a type specific flags, stored in the option and available to the handler * * \retval 0 Success * \retval -1 Failure */ #define aco_option_register(info, name, matchtype, types, default_val, opt_type, flags, ...) \ __aco_option_register(info, name, matchtype, types, default_val, opt_type, NULL, flags, VA_NARGS(__VA_ARGS__), __VA_ARGS__); /*! \brief Register a config option * \param info A pointer to the aco_info struct * \param name The name of the option * \param types An array of valid option types for matching categories to the correct struct type * \param default_val The default value of the option in the same format as defined in a config file * \param handler The handler callback for the option * \param flags \a type specific flags, stored in the option and available to the handler * * \retval 0 Success * \retval -1 Failure */ #define aco_option_register_custom(info, name, matchtype, types, default_val, handler, flags) \ __aco_option_register(info, name, matchtype, types, default_val, OPT_CUSTOM_T, handler, flags, 0); /*! \brief Register a deprecated (and aliased) config option * \param info A pointer to the aco_info struct * \param name The name of the deprecated option * \param types An array of valid option types for matching categories to the correct struct type * \param aliased_to The name of the option that this deprecated option matches to * * \retval 0 Success * \retval -1 Failure */ int aco_option_register_deprecated(struct aco_info *info, const char *name, struct aco_type **types, const char *aliased_to); /*! \note Everything below this point is to handle converting varargs * containing field names, to varargs containing a count of args, followed * by the offset of each of the field names in the struct type that is * passed in. It is currently limited to 8 arguments, but 8 variadic * arguments, like 640K, should be good enough for anyone. If not, it is * easy to add more. * */ /*! \def ARGMAP(func, func_arg, x, ...) * \brief Map \a func(\a func_arg, field) across all fields including \a x * \param func The function (almost certainly offsetof) to map across the fields * \param func_arg The first argument (almost certainly a type (e.g. "struct mystruct") * \param x The first field * \param varargs The rest of the fields * * Example usage: * \code * struct foo { * int a; * char *b; * foo *c; * }; * ARGMAP(offsetof, struct foo, a, c) * \endcode * produces the string: * \code * 2, offsetof(struct foo, a), offsetof(struct foo, b) * \encode * which can be passed as the varargs to some other function * * The macro isn't limited to offsetof, but that is the only purpose for * which it has been tested. * * As an example of how the processing works: * * ARGMAP(offsetof, struct foo, a, b, c) -> * ARGMAP_(3, offsetof, struct foo, a, b, c) -> * ARGMAP_3(offsetof, struct foo, 3, a, b, c) -> * ARGMAP_2(offsetof, struct foo, ARGIFY(3, offsetof(struct foo, a)), b, c) -> * ARGMAP_1(offsetof, struct foo, ARGIFY(3, offsetof(struct foo, a), offsetof(struct foo, b)), c) -> * ARGIFY(3, offsetof(struct foo, a), offsetof(struct foo, b), offsetof(struct foo, c)) -> * 3, offsetof(struct foo, a), offsetof(struct foo, b), offsetof(struct foo, c) */ #define ARGMAP(func, func_arg, x, ...) ARGMAP_(VA_NARGS(x, ##__VA_ARGS__), func, func_arg, x, __VA_ARGS__) /*! \note This is sneaky. On the very first argument, we set "in" to N, the number of arguments, so * that the accumulation both works properly for the first argument (since "in" can't be empty) and * we get the number of arguments in our varargs as a bonus */ #define ARGMAP_(N, func, func_arg, x, ...) PASTE(ARGMAP_, N)(func, func_arg, N, x, __VA_ARGS__) /*! \def PASTE(arg1, arg2) * \brief Paste two arguments together, even if they are macros themselves * \note Uses two levels to handle the case where arg1 and arg2 are macros themselves */ #define PASTE(arg1, arg2) PASTE1(arg1, arg2) #define PASTE1(arg1, arg2) arg1##arg2 /*! \brief Take a comma-separated list and allow it to be passed as a single argument to another macro */ #define ARGIFY(...) __VA_ARGS__ /*! \brief The individual field handlers for ARGMAP * \param func The function (most likely offsetof) * \param func_arg The first argument to func (most likely a type e.g. "struct my_struct") * \param in The accumulated function-mapped field names so far * \param x The next field name * \param varargs The rest of the field names */ #define ARGMAP_1(func, func_arg, in, x, ...) ARGIFY(in, func(func_arg, x)) #define ARGMAP_2(func, func_arg, in, x, ...)\ ARGMAP_1(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) #define ARGMAP_3(func, func_arg, in, x, ...)\ ARGMAP_2(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) #define ARGMAP_4(func, func_arg, in, x, ...)\ ARGMAP_3(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) #define ARGMAP_5(func, func_arg, in, x, ...)\ ARGMAP_4(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) #define ARGMAP_6(func, func_arg, in, x, ...)\ ARGMAP_5(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) #define ARGMAP_7(func, func_arg, in, x, ...)\ ARGMAP_6(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) #define ARGMAP_8(func, func_arg, in, x, ...)\ ARGMAP_7(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) /*! \def VA_NARGS(...) * \brief Results in the number of arguments passed to it * \note Currently only up to 8, but expanding is easy. This macro basically counts * commas + 1. To visualize: * * VA_NARGS(one, two, three) -> v * VA_NARGS1(one, two, three, 8, 7, 6, 5, 4, 3, 2, 1, 0) -> * VA_NARGS1( _1, _2, _3, _4, _5, _6, _7, _8, N, ... ) N -> 3 * * Note that VA_NARGS *does not* work when there are no arguments passed. Pasting an empty * __VA_ARGS__ with a comma like ", ##__VA_ARGS__" will delete the leading comma, but it * does not work when __VA_ARGS__ is the first argument. Instead, 1 is returned instead of 0: * * VA_NARGS() -> v * VA_NARGS1( , 8, 7, 6, 5, 4, 3, 2, 1, 0) -> * VA_NARGS1(_1, _2, _3, _4, _5, _6, _7, _8, N) -> 1 */ #define VA_NARGS(...) VA_NARGS1(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0) #define VA_NARGS1(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N /*! \def FLDSET(type, ...) * \brief Convert a struct and list of fields to an argument list of field offsets * \param type The type with the fields (e.g. "struct my_struct") * \param varags The fields in the struct whose offsets are needed as arguments * * For example: * \code * struct foo {int a, char b[128], char *c}; * FLDSET(struct foo, a, c) * \endcode * * produces * \code * offsetof(struct foo, a), offsetof(struct foo, c) * \endcode */ #define FLDSET(type, ...) FLDSET1(type, ##__VA_ARGS__) #define FLDSET1(type, ...) POPPED(ARGMAP(offsetof, type, ##__VA_ARGS__)) /*! \def STRFLDSET(type, ...) * \brief Convert a struct and a list of stringfield fields to an argument list of field offsets * \note Stringfields require the passing of the field manager pool, and field manager to the * default stringfield option handler, so registering options that point to stringfields requires * this macro to be called instead of the FLDSET macro. * \param type The type with the fields (e.g. "struct my_struct") * \param varargs The fields in the struct whose offsets are needed as arguments */ #define STRFLDSET(type, ...) FLDSET(type, __VA_ARGS__, __field_mgr_pool, __field_mgr) /*! \def CHARFLDSET(type, field) * \brief A helper macro to pass the appropriate arguments to aco_option_register for OPT_CHAR_ARRAY_T * \note This will pass the offset of the field and its length as arguments * \param type The type with the char array field (e.g. "struct my_struct") * \param field The name of char array field */ #define CHARFLDSET(type, field) ARGIFY(offsetof(type, field), sizeof(((type *)0)->field)) /*! \def POPPED(...) * \brief A list of arguments without the first argument * \note Used internally to remove the leading "number of arguments" argument from ARGMAP for * FLDSET. This is because a call to FLDSET may be followed by additional arguments in * aco_register_option, so the true number of arguments will possibly be different than what * ARGMAP returns. * \params varags A list of arguments * * POPPED(a, b, c) -> b, c */ #define POPPED(...) POPPED1(__VA_ARGS__) #define POPPED1(x, ...) __VA_ARGS__ #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_CONFIG_OPTIONS_H */ asterisk-11.7.0/include/asterisk/ccss.h0000644000175000007640000016007111722732113017725 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Digium, Inc. * * Mark Michelson * * 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 Call Completion Supplementary Services API * \author Mark Michelson */ #ifndef _ASTERISK_CCSS_H #define _ASTERISK_CCSS_H #include "asterisk.h" #include "asterisk/linkedlists.h" #include "asterisk/devicestate.h" enum ast_cc_service_type { /* No Service available/requested */ AST_CC_NONE, /* Call Completion Busy Subscriber */ AST_CC_CCBS, /* Call Completion No Response */ AST_CC_CCNR, /* Call Completion Not Logged In (currently SIP only) */ AST_CC_CCNL, }; /*! * \since 1.8 * \brief The various possibilities for cc_agent_policy values */ enum ast_cc_agent_policies { /*! Never offer CCSS to the caller */ AST_CC_AGENT_NEVER, /*! Offer CCSS using native signaling */ AST_CC_AGENT_NATIVE, /*! Use generic agent for caller */ AST_CC_AGENT_GENERIC, }; /*! * \brief agent flags that can alter core behavior */ enum ast_cc_agent_flags { /* Some agent types allow for a caller to * request CC without reaching the CC_CALLER_OFFERED * state. In other words, the caller can request * CC while he is still on the phone from the failed * call. The generic agent is an agent which allows * for this behavior. */ AST_CC_AGENT_SKIP_OFFER = (1 << 0), }; /*! * \since 1.8 * \brief The various possibilities for cc_monitor_policy values */ enum ast_cc_monitor_policies { /*! Never accept CCSS offers from callee */ AST_CC_MONITOR_NEVER, /* CCSS only available if callee offers it through signaling */ AST_CC_MONITOR_NATIVE, /*! Always use CCSS generic monitor for callee * Note that if callee offers CCSS natively, we still * will use a generic CCSS monitor if this is set */ AST_CC_MONITOR_GENERIC, /*! Accept native CCSS offers, but if no offer is present, * use a generic CCSS monitor */ AST_CC_MONITOR_ALWAYS, }; /* Forward declaration. Struct is in main/ccss.c */ struct ast_cc_config_params; /*! * \since 1.8 * \brief Queue an AST_CONTROL_CC frame * * \note * Since this function calls ast_queue_frame, the channel will be * locked during the course of this function. * * \param chan The channel onto which to queue the frame * \param monitor_type The type of monitor to use when CC is requested * \param dialstring The dial string used to call the device * \param service The type of CC service the device is willing to offer * \param private_data If a native monitor is being used, and some channel-driver-specific private * data has been allocated, then this parameter should contain a pointer to that data. If using a generic * monitor, this parameter should remain NULL. Note that if this function should fail at some point, * it is the responsibility of the caller to free the private data upon return. * \retval 0 Success * \retval -1 Error */ int ast_queue_cc_frame(struct ast_channel *chan, const char * const monitor_type, const char * const dialstring, enum ast_cc_service_type service, void *private_data); /*! * \brief Allocate and initialize an ast_cc_config_params structure * * \note * Reasonable default values are chosen for the parameters upon allocation. * * \retval NULL Unable to allocate the structure * \retval non-NULL A pointer to the newly allocated and initialized structure */ struct ast_cc_config_params *__ast_cc_config_params_init(const char *file, int line, const char *function); /*! * \brief Allocate and initialize an ast_cc_config_params structure * * \note * Reasonable default values are chosen for the parameters upon allocation. * * \retval NULL Unable to allocate the structure * \retval non-NULL A pointer to the newly allocated and initialized structure */ #define ast_cc_config_params_init() __ast_cc_config_params_init(__FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Free memory from CCSS configuration params * * \note * Just a call to ast_free for now... * * \param params Pointer to structure whose memory we need to free * \retval void */ void ast_cc_config_params_destroy(struct ast_cc_config_params *params); /*! * \brief set a CCSS configuration parameter, given its name * * \note * Useful when parsing config files when used in conjunction * with ast_ccss_is_cc_config_param. * * \param params The parameter structure to set the value on * \param name The name of the cc parameter * \param value The value of the parameter * \retval 0 Success * \retval -1 Failure */ int ast_cc_set_param(struct ast_cc_config_params *params, const char * const name, const char * value); /*! * \brief get a CCSS configuration parameter, given its name * * \note * Useful when reading input as a string, like from dialplan or * manager. * * \param params The CCSS configuration from which to get the value * \param name The name of the CCSS parameter we want * \param buf A preallocated buffer to hold the value * \param buf_len The size of buf * \retval 0 Success * \retval -1 Failure */ int ast_cc_get_param(struct ast_cc_config_params *params, const char * const name, char *buf, size_t buf_len); /*! * \since 1.8 * \brief Is this a CCSS configuration parameter? * \param name Name of configuration option being parsed. * \retval 1 Yes, this is a CCSS configuration parameter. * \retval 0 No, this is not a CCSS configuration parameter. */ int ast_cc_is_config_param(const char * const name); /*! * \since 1.8 * \brief Set the specified CC config params to default values. * * \details * This is just like ast_cc_copy_config_params() and could be used in place * of it if you need to set the config params to defaults instead. * You are simply "copying" defaults into the destination. * * \param params CC config params to set to default values. * * \return Nothing */ void ast_cc_default_config_params(struct ast_cc_config_params *params); /*! * \since 1.8 * \brief copy CCSS configuration parameters from one structure to another * * \details * For now, this is a simple memcpy, but this function is necessary since * the size of an ast_cc_config_params structure is unknown outside of * main/ccss.c. Also, this allows for easier expansion of the function in * case it becomes more complex than just a memcpy. * * \param src The structure from which data is copied * \param dest The structure to which data is copied * * \return Nothing */ void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src); /*! * \since 1.8 * \brief Get the cc_agent_policy * \param config The configuration to retrieve the policy from * \return The current cc_agent_policy for this configuration */ enum ast_cc_agent_policies ast_get_cc_agent_policy(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the cc_agent_policy * \param config The configuration to set the cc_agent_policy on * \param value The new cc_agent_policy we want to change to * \retval 0 Success * \retval -1 Failure (likely due to bad input) */ int ast_set_cc_agent_policy(struct ast_cc_config_params *config, enum ast_cc_agent_policies value); /*! * \since 1.8 * \brief Get the cc_monitor_policy * \param config The configuration to retrieve the cc_monitor_policy from * \return The cc_monitor_policy retrieved from the configuration */ enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the cc_monitor_policy * \param config The configuration to set the cc_monitor_policy on * \param value The new cc_monitor_policy we want to change to * \retval 0 Success * \retval -1 Failure (likely due to bad input) */ int ast_set_cc_monitor_policy(struct ast_cc_config_params *config, enum ast_cc_monitor_policies value); /*! * \since 1.8 * \brief Get the cc_offer_timer * \param config The configuration to retrieve the cc_offer_timer from * \return The cc_offer_timer from this configuration */ unsigned int ast_get_cc_offer_timer(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the cc_offer_timer * \param config The configuration to set the cc_offer_timer on * \param value The new cc_offer_timer we want to change to * \retval void */ void ast_set_cc_offer_timer(struct ast_cc_config_params *config, unsigned int value); /*! * \since 1.8 * \brief Get the ccnr_available_timer * \param config The configuration to retrieve the ccnr_available_timer from * \return The ccnr_available_timer from this configuration */ unsigned int ast_get_ccnr_available_timer(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the ccnr_available_timer * \param config The configuration to set the ccnr_available_timer on * \param value The new ccnr_available_timer we want to change to * \retval void */ void ast_set_ccnr_available_timer(struct ast_cc_config_params *config, unsigned int value); /*! * \since 1.8 * \brief Get the cc_recall_timer * \param config The configuration to retrieve the cc_recall_timer from * \return The cc_recall_timer from this configuration */ unsigned int ast_get_cc_recall_timer(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the cc_recall_timer * \param config The configuration to set the cc_recall_timer on * \param value The new cc_recall_timer we want to change to * \retval void */ void ast_set_cc_recall_timer(struct ast_cc_config_params *config, unsigned int value); /*! * \since 1.8 * \brief Get the ccbs_available_timer * \param config The configuration to retrieve the ccbs_available_timer from * \return The ccbs_available_timer from this configuration */ unsigned int ast_get_ccbs_available_timer(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the ccbs_available_timer * \param config The configuration to set the ccbs_available_timer on * \param value The new ccbs_available_timer we want to change to * \retval void */ void ast_set_ccbs_available_timer(struct ast_cc_config_params *config, unsigned int value); /*! * \since 1.8 * \brief Get the cc_agent_dialstring * \param config The configuration to retrieve the cc_agent_dialstring from * \return The cc_agent_dialstring from this configuration */ const char *ast_get_cc_agent_dialstring(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the cc_agent_dialstring * \param config The configuration to set the cc_agent_dialstring on * \param value The new cc_agent_dialstring we want to change to * \retval void */ void ast_set_cc_agent_dialstring(struct ast_cc_config_params *config, const char *const value); /*! * \since 1.8 * \brief Get the cc_max_agents * \param config The configuration to retrieve the cc_max_agents from * \return The cc_max_agents from this configuration */ unsigned int ast_get_cc_max_agents(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the cc_max_agents * \param config The configuration to set the cc_max_agents on * \param value The new cc_max_agents we want to change to * \retval void */ void ast_set_cc_max_agents(struct ast_cc_config_params *config, unsigned int value); /*! * \since 1.8 * \brief Get the cc_max_monitors * \param config The configuration to retrieve the cc_max_monitors from * \return The cc_max_monitors from this configuration */ unsigned int ast_get_cc_max_monitors(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the cc_max_monitors * \param config The configuration to set the cc_max_monitors on * \param value The new cc_max_monitors we want to change to * \retval void */ void ast_set_cc_max_monitors(struct ast_cc_config_params *config, unsigned int value); /*! * \since 1.8 * \brief Get the name of the callback_macro * \param config The configuration to retrieve the callback_macro from * \return The callback_macro name */ const char *ast_get_cc_callback_macro(struct ast_cc_config_params *config); /*! * \since 1.8 * \brief Set the callback_macro name * \param config The configuration to set the callback_macro on * \param value The new callback macro we want to change to * \retval void */ void ast_set_cc_callback_macro(struct ast_cc_config_params *config, const char * const value); /*! * \since 11 * \brief Get the name of the callback subroutine * \param config The configuration to retrieve the callback_sub from * \return The callback_sub name */ const char *ast_get_cc_callback_sub(struct ast_cc_config_params *config); /*! * \since 11 * \brief Set the callback subroutine name * \param config The configuration to set the callback_sub on * \param value The new callback subroutine we want to change to * \retval void */ void ast_set_cc_callback_sub(struct ast_cc_config_params *config, const char * const value); /* END CONFIGURATION FUNCTIONS */ /* BEGIN AGENT/MONITOR REGISTRATION API */ struct ast_cc_monitor_callbacks; /*! * \since 1.8 * \brief Register a set of monitor callbacks with the core * * \details * This is made so that at monitor creation time, the proper callbacks * may be installed and the proper .init callback may be called for the * monitor to establish private data. * * \param callbacks The callbacks used by the monitor implementation * \retval 0 Successfully registered * \retval -1 Failure to register */ int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks); /*! * \since 1.8 * \brief Unregister a set of monitor callbacks with the core * * \details * If a module which makes use of a CC monitor is unloaded, then it may * unregister its monitor callbacks with the core. * * \param callbacks The callbacks used by the monitor implementation * \retval 0 Successfully unregistered * \retval -1 Failure to unregister */ void ast_cc_monitor_unregister(const struct ast_cc_monitor_callbacks *callbacks); struct ast_cc_agent_callbacks; /*! * \since 1.8 * \brief Register a set of agent callbacks with the core * * \details * This is made so that at agent creation time, the proper callbacks * may be installed and the proper .init callback may be called for the * monitor to establish private data. * * \param callbacks The callbacks used by the agent implementation * \retval 0 Successfully registered * \retval -1 Failure to register */ int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks); /*! * \since 1.8 * \brief Unregister a set of agent callbacks with the core * * \details * If a module which makes use of a CC agent is unloaded, then it may * unregister its agent callbacks with the core. * * \param callbacks The callbacks used by the agent implementation * \retval 0 Successfully unregistered * \retval -1 Failure to unregister */ void ast_cc_agent_unregister(const struct ast_cc_agent_callbacks *callbacks); /* END AGENT/MONITOR REGISTRATION API */ /* BEGIN SECTION ON MONITORS AND MONITOR CALLBACKS */ /*! * It is recommended that monitors use a pointer to * an ast_cc_monitor_callbacks::type when creating * an AST_CONTROL_CC frame. Since the generic monitor * callbacks are opaque and channel drivers will wish * to use that, this string is made globally available * for all to use */ #define AST_CC_GENERIC_MONITOR_TYPE "generic" /*! * Used to determine which type * of monitor an ast_cc_device_monitor * is. */ enum ast_cc_monitor_class { AST_CC_DEVICE_MONITOR, AST_CC_EXTENSION_MONITOR, }; /*! * \internal * \brief An item in a CC interface tree. * * These are the individual items in an interface tree. * The key difference between this structure and the ast_cc_interface * is that this structure contains data which is intrinsic to the item's * placement in the tree, such as who its parent is. */ struct ast_cc_monitor { /*! * Information regarding the interface. */ struct ast_cc_interface *interface; /*! * Every interface has an id that uniquely identifies it. It is * formed by incrementing a counter. */ unsigned int id; /*! * The ID of this monitor's parent. If this monitor is at the * top of the tree, then his parent will be 0. */ unsigned int parent_id; /*! * The instance of the CC core to which this monitor belongs */ int core_id; /*! * The type of call completion service offered by a device. */ enum ast_cc_service_type service_offered; /*! * \brief Name that should be used to recall specified interface * * \details * When issuing a CC recall, some technologies will require * that a name other than the device name is dialed. For instance, * with SIP, a specific URI will be used which chan_sip will be able * to recognize as being a CC recall. Similarly, ISDN will need a specific * dial string to know that the call is a recall. */ char *dialstring; /*! * The ID of the available timer used by the current monitor */ int available_timer_id; /*! * Monitor callbacks */ const struct ast_cc_monitor_callbacks *callbacks; /*! * \brief Data that is private to a monitor technology * * Most channel drivers that implement CC monitors will have to * allocate data that the CC core does not care about but which * is vital to the operation of the monitor. This data is stored * in this pointer so that the channel driver may use it as * needed */ void *private_data; AST_LIST_ENTRY(ast_cc_monitor) next; }; /*! * \brief Callbacks defined by CC monitors * * \note * Every callback is called with the list of monitors locked. There * are several public API calls that also will try to lock this lock. * These public functions have a note in their doxygen stating so. * As such, pay attention to the lock order you establish in these callbacks * to ensure that you do not violate the lock order when calling * the functions in this file with lock order notices. */ struct ast_cc_monitor_callbacks { /*! * \brief Type of monitor the callbacks belong to. * * \note * Examples include "generic" and "SIP" */ const char *type; /*! * \brief Request CCSS. * * \param monitor CC core monitor control. * \param available_timer_id The scheduler ID for the available timer. * Will never be NULL for a device monitor. * * \details * Perform whatever steps are necessary in order to request CC. * In addition, the monitor implementation is responsible for * starting the available timer in this callback. * * \retval 0 on success * \retval -1 on failure. */ int (*request_cc)(struct ast_cc_monitor *monitor, int *available_timer_id); /*! * \brief Suspend monitoring. * * \param monitor CC core monitor control. * * \details * Implementers must perform the necessary steps to suspend * monitoring. * * \retval 0 on success * \retval -1 on failure. */ int (*suspend)(struct ast_cc_monitor *monitor); /*! * \brief Status response to an ast_cc_monitor_status_request(). * * \param monitor CC core monitor control. * \param devstate Current status of a Party A device. * * \details * Alert a monitor as to the status of the agent for which * the monitor had previously requested a status request. * * \note Zero or more responses may come as a result. * * \retval 0 on success * \retval -1 on failure. */ int (*status_response)(struct ast_cc_monitor *monitor, enum ast_device_state devstate); /*! * \brief Unsuspend monitoring. * * \param monitor CC core monitor control. * * \details * Perform the necessary steps to unsuspend monitoring. * * \retval 0 on success * \retval -1 on failure. */ int (*unsuspend)(struct ast_cc_monitor *monitor); /*! * \brief Cancel the running available timer. * * \param monitor CC core monitor control. * \param sched_id Available timer scheduler id to cancel. * Will never be NULL for a device monitor. * * \details * In most cases, this function will likely consist of just a * call to AST_SCHED_DEL. It might have been possible to do this * within the core, but unfortunately the mixture of sched_thread * and sched usage in Asterisk prevents such usage. * * \retval 0 on success * \retval -1 on failure. */ int (*cancel_available_timer)(struct ast_cc_monitor *monitor, int *sched_id); /*! * \brief Destroy private data on the monitor. * * \param private_data The private data pointer from the monitor. * * \details * Implementers of this callback are responsible for destroying * all heap-allocated data in the monitor's private_data pointer, including * the private_data itself. */ void (*destructor)(void *private_data); }; /*! * \since 1.8 * \brief Scheduler callback for available timer expiration * * \note * When arming the available timer from within a device monitor, you MUST * use this function as the callback for the scheduler. * * \param data A reference to the CC monitor on which the timer was running. */ int ast_cc_available_timer_expire(const void *data); /* END SECTION ON MONITORS AND MONITOR CALLBACKS */ /* BEGIN API FOR IN-CALL CC HANDLING */ /*! * \since 1.8 * * \brief Mark the channel to ignore further CC activity. * * \details * When a CC-capable application, such as Dial, has finished * with all CC processing for a channel and knows that any further * CC processing should be ignored, this function should be called. * * \param chan The channel for which further CC processing should be ignored. * \retval void */ void ast_ignore_cc(struct ast_channel *chan); /*! * \since 1.8 * * \brief Properly react to a CC control frame. * * \details * When a CC-capable application, such as Dial, receives a frame * of type AST_CONTROL_CC, then it may call this function in order * to have the device which sent the frame added to the tree of interfaces * which is kept on the inbound channel. * * \param inbound The inbound channel * \param outbound The outbound channel (The one from which the CC frame was read) * \param frame_data The ast_frame's data.ptr field. * \retval void */ void ast_handle_cc_control_frame(struct ast_channel *inbound, struct ast_channel *outbound, void *frame_data); /*! * \since 1.8 * * \brief Start the CC process on a call. * * \details * Whenever a CC-capable application, such as Dial, wishes to * engage in CC activity, it initiates the process by calling this * function. If the CC core should discover that a previous application * has called ast_ignore_cc on this channel or a "parent" channel, then * the value of the ignore_cc integer passed in will be set nonzero. * * The ignore_cc parameter is a convenience parameter. It can save an * application the trouble of trying to call CC APIs when it knows that * it should just ignore further attempts at CC actions. * * \param chan The inbound channel calling the CC-capable application. * \param[out] ignore_cc Will be set non-zero if no further CC actions need to be taken * \retval 0 Success * \retval -1 Failure */ int ast_cc_call_init(struct ast_channel *chan, int *ignore_cc); /*! * \since 1.8 * * \brief Add a child dialstring to an extension monitor * * Whenever we request a channel, the parent extension monitor needs * to store the dialstring of the device requested. The reason is so * that we can call the device back during the recall even if we are * not monitoring the device. * * \param incoming The caller's channel * \param dialstring The dialstring used when requesting the outbound channel * \param device_name The device name associated with the requested outbound channel * \retval void */ void ast_cc_extension_monitor_add_dialstring(struct ast_channel *incoming, const char * const dialstring, const char * const device_name); /*! * \since 1.8 * \brief Check if the incoming CC request is within the bounds * set by the cc_max_requests configuration option * * \details * It is recommended that an entity which receives an incoming * CC request calls this function before calling * ast_cc_agent_accept_request. This way, immediate feedback can be * given to the caller about why his request was rejected. * * If this is not called and a state change to CC_CALLER_REQUESTED * is made, then the core will still not allow for the request * to succeed. However, if done this way, it may not be obvious * to the requestor why the request failed. * * \retval 0 Not within the limits. Fail. * \retval non-zero Within the limits. Success. */ int ast_cc_request_is_within_limits(void); /*! * \since 1.8 * \brief Get the core id for the current call * * \details * The main use of this function is for channel drivers * who queue an AST_CONTROL_CC frame. A channel driver may * call this function in order to get the core_id for what * may become a CC request. This way, when monitor functions * are called which use a core_id as a means of identification, * the channel driver will have saved this information. * * The channel given to this function may be an inbound or outbound * channel. Both will have the necessary info on it. * * \param chan The channel from which to get the core_id. * \retval core_id on success * \retval -1 Failure */ int ast_cc_get_current_core_id(struct ast_channel *chan); /* END API FOR IN-CALL CC HANDLING */ /*! * \brief Structure with information about an outbound interface * * \details * This structure is first created when an outbound interface indicates that * it is capable of accepting a CC request. It is stored in a "tree" on a datastore on * the caller's channel. Once an agent structure is created, the agent gains * a reference to the tree of interfaces. If CC is requested, then the * interface tree on the agent is converted into a tree of monitors. Each * monitor will contain a pointer to an individual ast_cc_interface. Finally, * the tree of interfaces is also present on a second datastore during a * CC recall so that the CC_INTERFACES channel variable may be properly * populated. */ struct ast_cc_interface { /* What class of monitor is being offered here */ enum ast_cc_monitor_class monitor_class; /*! * \brief The type of monitor that should be used for this interface * * \details * This will be something like "extension" "generic" or "SIP". * This should point to a static const char *, so there is * no reason to make a new copy. */ const char *monitor_type; /*! * The configuration parameters used for this interface */ struct ast_cc_config_params *config_params; /* The name of the interface/extension. local channels will * have 'exten@context' for a name. Other channel types will * have 'tech/device' for a name. */ char device_name[1]; }; /* BEGIN STRUCTURES FOR AGENTS */ struct ast_cc_agent { /*! * Which instance of the core state machine does this * agent pertain to? */ unsigned int core_id; /*! * Callback functions needed for specific agent * implementations */ const struct ast_cc_agent_callbacks *callbacks; /*! * Configuration parameters that affect this * agent's operation. */ struct ast_cc_config_params *cc_params; /*! * \brief Flags for agent operation * * \details * There are some attributes of certain agent types * that can alter the behavior of certain CC functions. * For a list of these flags, see the ast_cc_agent_flags * enum */ unsigned int flags; /*! Data specific to agent implementation */ void *private_data; /*! The name of the device which this agent * represents/communicates with */ char device_name[1]; }; enum ast_cc_agent_response_reason { /*! CC request accepted */ AST_CC_AGENT_RESPONSE_SUCCESS, /*! CC request not allowed at this time. Invalid state transition. */ AST_CC_AGENT_RESPONSE_FAILURE_INVALID, /*! Too many CC requests in the system. */ AST_CC_AGENT_RESPONSE_FAILURE_TOO_MANY, }; struct ast_cc_agent_callbacks { /*! * \brief Type of agent the callbacks belong to. * * \note * Examples are "SIP" "ISDN" and "generic" */ const char *type; /*! * \brief CC agent initialization. * * \param agent CC core agent control. * \param chan Original channel the agent will attempt to recall. * * \details * This callback is called when the CC core * is initialized. Agents should allocate * any private data necessary for the * call and assign it to the private_data * on the agent. Additionally, if any ast_cc_agent_flags * are pertinent to the specific agent type, they should * be set in this function as well. * * \retval 0 on success. * \retval -1 on error. */ int (*init)(struct ast_cc_agent *agent, struct ast_channel *chan); /*! * \brief Start the offer timer. * * \param agent CC core agent control. * * \details * This is called by the core when the caller hangs up after * a call for which CC may be requested. The agent should * begin the timer as configured. * * The primary reason why this functionality is left to * the specific agent implementations is due to the differing * use of schedulers throughout the code. Some channel drivers * may already have a scheduler context they wish to use, and * amongst those, some may use the ast_sched API while others * may use the ast_sched_thread API, which are incompatible. * * \retval 0 on success. * \retval -1 on error. */ int (*start_offer_timer)(struct ast_cc_agent *agent); /*! * \brief Stop the offer timer. * * \param agent CC core agent control. * * \details * This callback is called by the CC core when the caller * has requested CC. * * \retval 0 on success. * \retval -1 on error. */ int (*stop_offer_timer)(struct ast_cc_agent *agent); /*! * \brief Respond to a CC request. * * \param agent CC core agent control. * \param reason CC request response status. * * \details * When the core receives knowledge that a called * party has accepted a CC request, it will call * this callback. The core may also call this * if there is some error when attempting to process * the incoming CC request. * * The duty of this is to issue a propper response to a * CC request from the caller by acknowledging receipt * of that request or rejecting it. */ void (*respond)(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason); /*! * \brief Request the status of the agent's device. * * \param agent CC core agent control. * * \details * Asynchronous request for the status of any caller * which may be a valid caller for the CC transaction. * Status responses should be made using the * ast_cc_status_response function. * * \retval 0 on success. * \retval -1 on error. */ int (*status_request)(struct ast_cc_agent *agent); /*! * \brief Request for an agent's phone to stop ringing. * * \param agent CC core agent control. * * \details * The usefulness of this is quite limited. The only specific * known case for this is if Asterisk requests CC over an ISDN * PTMP link as the TE side. If other phones are in the same * recall group as the Asterisk server, and one of those phones * picks up the recall notice, then Asterisk will receive a * "stop ringing" notification from the NT side of the PTMP * link. This indication needs to be passed to the phone * on the other side of the Asterisk server which originally * placed the call so that it will stop ringing. Since the * phone may be of any type, it is necessary to have a callback * that the core can know about. * * \retval 0 on success. * \retval -1 on error. */ int (*stop_ringing)(struct ast_cc_agent *agent); /*! * \brief Let the caller know that the callee has become free * but that the caller cannot attempt to call back because * he is either busy or there is congestion on his line. * * \param agent CC core agent control. * * \details * This is something that really only affects a scenario where * a phone places a call over ISDN PTMP to Asterisk, who then * connects over PTMP again to the ISDN network. For most agent * types, there is no need to implement this callback at all * because they don't really need to actually do anything in * this situation. If you're having trouble understanding what * the purpose of this callback is, then you can be safe simply * not implementing it. * * \retval 0 on success. * \retval -1 on error. */ int (*party_b_free)(struct ast_cc_agent *agent); /*! * \brief Begin monitoring a busy device. * * \param agent CC core agent control. * * \details * The core will call this callback if the callee becomes * available but the caller has reported that he is busy. * The agent should begin monitoring the caller's device. * When the caller becomes available again, the agent should * call ast_cc_agent_caller_available. * * \retval 0 on success. * \retval -1 on error. */ int (*start_monitoring)(struct ast_cc_agent *agent); /*! * \brief Alert the caller that it is time to try recalling. * * \param agent CC core agent control. * * \details * The core will call this function when it receives notice * that a monitored party has become available. * * The agent's job is to send a message to the caller to * notify it of such a change. If the agent is able to * discern that the caller is currently unavailable, then * the agent should react by calling the ast_cc_caller_unavailable * function. * * \retval 0 on success. * \retval -1 on error. */ int (*callee_available)(struct ast_cc_agent *agent); /*! * \brief Destroy private data on the agent. * * \param agent CC core agent control. * * \details * The core will call this function upon completion * or failure of CC. * * \note * The agent private_data pointer may be NULL if the agent * constructor failed. */ void (*destructor)(struct ast_cc_agent *agent); }; /*! * \brief Call a callback on all agents of a specific type * * \details * Since the container of CC core instances is private, and so * are the items which the container contains, we have to provide * an ao2_callback-like method so that a specific agent may be * found or so that an operation can be made on all agents of * a particular type. The first three arguments should be familiar * to anyone who has used ao2_callback. The final argument is the * type of agent you wish to have the callback called on. * * \note Since agents are refcounted, and this function returns * a reference to the agent, it is imperative that you decrement * the refcount of the agent once you have finished using it. * * \param flags astobj2 search flags * \param function an ao2 callback function to call * \param arg the argument to the callback function * \param type The type of agents to call the callback on */ struct ast_cc_agent *ast_cc_agent_callback(int flags, ao2_callback_fn *function, void *arg, const char * const type); /* END STRUCTURES FOR AGENTS */ /* BEGIN STATE CHANGE API */ /*! * \since 1.8 * \brief Offer CC to a caller * * \details * This function is called from ast_hangup if the caller is * eligible to be offered call completion service. * * \param caller_chan The calling channel * \retval -1 Error * \retval 0 Success */ int ast_cc_offer(struct ast_channel *caller_chan); /*! * \since 1.8 * \brief Accept inbound CC request * * \details * When a caller requests CC, this function should be called to let * the core know that the request has been accepted. * * \param core_id core_id of the CC transaction * \param debug optional string to print for debugging purposes * \retval 0 Success * \retval -1 Failure */ int __attribute__((format(printf, 2, 3))) ast_cc_agent_accept_request(int core_id, const char * const debug, ...); /*! * \since 1.8 * \brief Indicate that an outbound entity has accepted our CC request * * \details * When we receive confirmation that an outbound device has accepted the * CC request we sent it, this function must be called. * * \param core_id core_id of the CC transaction * \param debug optional string to print for debugging purposes * \retval 0 Success * \retval -1 Failure */ int __attribute__((format(printf, 2, 3))) ast_cc_monitor_request_acked(int core_id, const char * const debug, ...); /*! * \since 1.8 * \brief Indicate that the caller is busy * * \details * When the callee makes it known that he is available, the core * will let the caller's channel driver know that it may attempt * to let the caller know to attempt a recall. If the channel * driver can detect, though, that the caller is busy, then * the channel driver should call this function to let the CC * core know. * * \param core_id core_id of the CC transaction * \param debug optional string to print for debugging purposes * \retval 0 Success * \retval -1 Failure */ int __attribute__((format(printf, 2, 3))) ast_cc_agent_caller_busy(int core_id, const char * const debug, ...); /*! * \since 1.8 * \brief Indicate that a previously unavailable caller has become available * * \details * If a monitor is suspended due to a caller becoming unavailable, then this * function should be called to indicate that the caller has become available. * * \param core_id core_id of the CC transaction * \param debug optional string to print for debugging purposes * \retval 0 Success * \retval -1 Failure */ int __attribute__((format(printf, 2, 3))) ast_cc_agent_caller_available(int core_id, const char * const debug, ...); /*! * \since 1.8 * \brief Tell the CC core that a caller is currently recalling * * \details * The main purpose of this is so that the core can alert the monitor * to stop its available timer since the caller has begun its recall * phase. * * \param core_id core_id of the CC transaction * \param debug optional string to print for debugging purposes * \retval 0 Success * \retval -1 Failure */ int __attribute__((format(printf, 2, 3))) ast_cc_agent_recalling(int core_id, const char * const debug, ...); /*! * \since 1.8 * \brief Indicate recall has been acknowledged * * \details * When we receive confirmation that an endpoint has responded to our * CC recall, we call this function. * * \param chan The inbound channel making the CC recall * \param debug optional string to print for debugging purposes * \retval 0 Success * \retval -1 Failure */ int __attribute__((format(printf, 2, 3))) ast_cc_completed(struct ast_channel *chan, const char * const debug, ...); /*! * \since 1.8 * \brief Indicate failure has occurred * * \details * If at any point a failure occurs, this is the function to call * so that the core can initiate cleanup procedures. * * \param core_id core_id of the CC transaction * \param debug optional string to print for debugging purposes * \retval 0 Success * \retval -1 Failure */ int __attribute__((format(printf, 2, 3))) ast_cc_failed(int core_id, const char * const debug, ...); /*! * \since 1.8 * \brief Indicate that a failure has occurred on a specific monitor * * \details * If a monitor should detect that a failure has occurred when communicating * with its endpoint, then ast_cc_monitor_failed should be called. The big * difference between ast_cc_monitor_failed and ast_cc_failed is that ast_cc_failed * indicates a global failure for a CC transaction, where as ast_cc_monitor_failed * is localized to a particular monitor. When ast_cc_failed is called, the entire * CC transaction is torn down. When ast_cc_monitor_failed is called, only the * monitor on which the failure occurred is pruned from the tree of monitors. * * If there are no more devices left to monitor when this function is called, * then the core will fail the CC transaction globally. * * \param core_id The core ID for the CC transaction * \param monitor_name The name of the monitor on which the failure occurred * \param debug A debug message to print to the CC log * \return void */ int __attribute__((format(printf, 3, 4))) ast_cc_monitor_failed(int core_id, const char * const monitor_name, const char * const debug, ...); /* END STATE CHANGE API */ /*! * The following are all functions which are required due to the unique * case where Asterisk is acting as the NT side of an ISDN PTMP * connection to the caller and as the TE side of an ISDN PTMP connection * to the callee. In such a case, there are several times where the * PTMP monitor needs information from the agent in order to formulate * the appropriate messages to send. */ /*! * \brief Request the status of a caller or callers. * * \details * When an ISDN PTMP monitor senses that the callee has become * available, it needs to know the current status of the caller * in order to determine the appropriate response to send to * the caller. In order to do this, the monitor calls this function. * Responses will arrive asynchronously. * * \note Zero or more responses may come as a result. * * \param core_id The core ID of the CC transaction * * \retval 0 Successfully requested status * \retval -1 Failed to request status */ int ast_cc_monitor_status_request(int core_id); /*! * \brief Response with a caller's current status * * \details * When an ISDN PTMP monitor requests the caller's status, the * agent must respond to the request using this function. For * simplicity it is recommended that the devstate parameter * be one of AST_DEVICE_INUSE or AST_DEVICE_NOT_INUSE. * * \param core_id The core ID of the CC transaction * \param devstate The current state of the caller to which the agent pertains * \retval 0 Successfully responded with our status * \retval -1 Failed to respond with our status */ int ast_cc_agent_status_response(int core_id, enum ast_device_state devstate); /*! * \brief Alert a caller to stop ringing * * \details * When an ISDN PTMP monitor becomes available, it is assumed * that the agent will then cause the caller's phone to ring. In * some cases, this is literally what happens. In other cases, it may * be that the caller gets a visible indication on his phone that he * may attempt to recall the callee. If multiple callers are recalled * (since it may be possible to have a group of callers configured as * a single party A), and one of those callers picks up his phone, then * the ISDN PTMP monitor will alert the other callers to stop ringing. * The agent's stop_ringing callback will be called, and it is up to the * agent's driver to send an appropriate message to make his caller * stop ringing. * * \param core_id The core ID of the CC transaction * \retval 0 Successfully requested for the phone to stop ringing * \retval -1 Could not request for the phone to stop ringing */ int ast_cc_monitor_stop_ringing(int core_id); /*! * \brief Alert a caller that though the callee has become free, the caller * himself is not and may not call back. * * \details * When an ISDN PTMP monitor senses that his monitored party has become * available, he will request the status of the called party. If he determines * that the caller is currently not available, then he will call this function * so that an appropriate message is sent to the caller. * * Yes, you just read that correctly. The callee asks the caller what his * current status is, and if the caller is currently unavailable, the monitor * must send him a message anyway. WTF? * * This function results in the agent's party_b_free callback being called. * It is most likely that you will not need to actually implement the * party_b_free callback in an agent because it is not likely that you will * need to or even want to send a caller a message indicating the callee's * status if the caller himself is not also free. * * \param core_id The core ID of the CC transaction * \retval 0 Successfully alerted the core that party B is free * \retval -1 Could not alert the core that party B is free */ int ast_cc_monitor_party_b_free(int core_id); /* BEGIN API FOR USE WITH/BY MONITORS */ /*! * \since 1.8 * \brief Return the number of outstanding CC requests to a specific device * * \note * This function will lock the list of monitors stored on every instance of * the CC core. Callers of this function should be aware of this and avoid * any potential lock ordering problems. * * \param name The name of the monitored device * \param type The type of the monitored device (e.g. "generic") * \return The number of CC requests for the monitor */ int ast_cc_monitor_count(const char * const name, const char * const type); /*! * \since 1.8 * \brief Alert the core that a device being monitored has become available. * * \note * The code in the core will take care of making sure that the information gets passed * up the ladder correctly. * * \param core_id The core ID of the corresponding CC transaction * \param debug * \retval 0 Request successfully queued * \retval -1 Request could not be queued */ int __attribute__((format(printf, 2, 3))) ast_cc_monitor_callee_available(const int core_id, const char * const debug, ...); /* END API FOR USE WITH/BY MONITORS */ /* BEGIN API TO BE USED ON CC RECALL */ /*! * \since 1.8 * \brief Set up a CC recall datastore on a channel * * \details * Implementers of protocol-specific CC agents will need to call this * function in order for the channel to have the necessary interfaces * to recall. * * This function must be called by the implementer once it has been detected * that an inbound call is a cc_recall. After allocating the channel, call this * function, followed by ast_cc_set_cc_interfaces_chanvar. While it would be nice to * be able to have the core do this automatically, it just cannot be done given * the current architecture. */ int ast_setup_cc_recall_datastore(struct ast_channel *chan, const int core_id); /*! * \since 1.8 * \brief Decide if a call to a particular channel is a CC recall * * \details * When a CC recall happens, it is important on the called side to * know that the call is a CC recall and not a normal call. This function * will determine first if the call in question is a CC recall. Then it * will determine based on the chan parameter if the channel is being * called is being recalled. * * As a quick example, let's say a call is placed to SIP/1000 and SIP/1000 * is currently on the phone. The caller requests CCBS. SIP/1000 finishes * his call, and so the caller attempts to recall. Now, the dialplan * administrator has set up this second call so that not only is SIP/1000 * called, but also SIP/2000 is called. If SIP/1000's channel were passed * to this function, the return value would be non-zero, but if SIP/2000's * channel were passed into this function, then the return would be 0 since * SIP/2000 was not one of the original devices dialed. * * \note * This function may be called on a calling channel as well to * determine if it is part of a CC recall. * * \note * This function will lock the channel as well as the list of monitors * on the channel datastore, though the locks are not held at the same time. Be * sure that you have no potential lock order issues here. * * \param chan The channel to check * \param[out] core_id If this is a valid CC recall, the core_id of the failed call * will be placed in this output parameter * \param monitor_type Clarify which type of monitor type we are looking for if this * is happening on a called channel. For incoming channels, this parameter is not used. * \retval 0 Either this is not a recall or it is but this channel is not part of the recall * \retval non-zero This is a recall and the channel in question is directly involved. */ int ast_cc_is_recall(struct ast_channel *chan, int *core_id, const char * const monitor_type); /*! * \since 1.8 * \brief Get the associated monitor given the device name and core_id * * \details * The function ast_cc_is_recall is helpful for determining if a call to * a specific channel is a recall. However, once you have determined that * this is a recall, you will most likely need access to the private data * within the associated monitor. This function is what one uses to get * that monitor. * * \note * This function locks the list of monitors that correspond to the core_id * passed in. Be sure that you have no potential lock order issues when * calling this function. * * \param core_id The core ID to which this recall corresponds. This likely will * have been obtained using the ast_cc_is_recall function * \param device_name Which device to find the monitor for. * * \retval NULL Appropriate monitor does not exist * \retval non-NULL The monitor to use for this recall */ struct ast_cc_monitor *ast_cc_get_monitor_by_recall_core_id(const int core_id, const char * const device_name); /*! * \since 1.8 * \brief Set the first level CC_INTERFACES channel variable for a channel. * * \note * Implementers of protocol-specific CC agents should call this function after * calling ast_setup_cc_recall_datastore. * * \note * This function will lock the channel as well as the list of monitors stored * on the channel's CC recall datastore, though neither are held at the same * time. Callers of this function should be aware of potential lock ordering * problems that may arise. * * \details * The CC_INTERFACES channel variable will have the interfaces that should be * called back for a specific PBX instance. * * \param chan The channel to set the CC_INTERFACES variable on */ int ast_cc_agent_set_interfaces_chanvar(struct ast_channel *chan); /*! * \since 1.8 * \brief Set the CC_INTERFACES channel variable for a channel using an * extension@context as a starting point * * \details * The CC_INTERFACES channel variable will have the interfaces that should be * called back for a specific PBX instance. This version of the function is used * mainly by chan_local, wherein we need to set CC_INTERFACES based on an extension * and context that appear in the middle of the tree of dialed interfaces * * \note * This function will lock the channel as well as the list of monitors stored * on the channel's CC recall datastore, though neither are held at the same * time. Callers of this function should be aware of potential lock ordering * problems that may arise. * * \param chan The channel to set the CC_INTERFACES variable on * \param extension The name of the extension for which we're setting the variable. * This should be in the form of "exten@context" */ int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char * const extension); /*! * \since 1.8 * \brief Make CCBS available in the case that ast_call fails * * In some situations, notably if a call-limit is reached in SIP, ast_call will fail * due to Asterisk's knowing that the desired device is currently busy. In such a situation, * CCBS should be made available to the caller. * * One caveat is that this may only be used if generic monitoring is being used. The reason * is that since Asterisk determined that the device was busy without actually placing a call to it, * the far end will have no idea what call we are requesting call completion for if we were to send * a call completion request. */ void ast_cc_call_failed(struct ast_channel *incoming, struct ast_channel *outgoing, const char * const dialstring); /*! * \since 1.8 * \brief Callback made from ast_cc_callback for certain channel types * * \param inbound Incoming asterisk channel. * \param cc_params The CC configuration parameters for the outbound target * \param monitor_type The type of monitor to use when CC is requested * \param device_name The name of the outbound target device. * \param dialstring The dial string used when calling this specific interface * \param private_data If a native monitor is being used, and some channel-driver-specific private * data has been allocated, then this parameter should contain a pointer to that data. If using a generic * monitor, this parameter should remain NULL. Note that if this function should fail at some point, * it is the responsibility of the caller to free the private data upon return. * * \details * For channel types that fail ast_request when the device is busy, we call into the * channel driver with ast_cc_callback. This is the callback that is called in that * case for each device found which could have been returned by ast_request. * * This function creates a CC control frame payload, simulating the act of reading * it from the nonexistent outgoing channel's frame queue. We then handle this * simulated frame just as we would a normal CC frame which had actually been queued * by the channel driver. */ void ast_cc_busy_interface(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char *monitor_type, const char * const device_name, const char * const dialstring, void *private_data); /*! * \since 1.8 * \brief Create a CC Control frame * * \details * chan_dahdi is weird. It doesn't seem to actually queue frames when it needs to tell * an application something. Instead it wakes up, tells the application that it has data * ready, and then based on set flags, creates the proper frame type. For chan_dahdi, we * provide this function. It provides us the data we need, and we'll make its frame for it. * * \param chan A channel involved in the call. What we want is on a datastore on both incoming * and outgoing so either may be provided * \param cc_params The CC configuration parameters for the outbound target * \param monitor_type The type of monitor to use when CC is requested * \param device_name The name of the outbound target device. * \param dialstring The dial string used when calling this specific interface * \param service What kind of CC service is being offered. (CCBS/CCNR/etc...) * \param private_data If a native monitor is being used, and some channel-driver-specific private * data has been allocated, then this parameter should contain a pointer to that data. If using a generic * monitor, this parameter should remain NULL. Note that if this function should fail at some point, * it is the responsibility of the caller to free the private data upon return. * \param[out] frame The frame we will be returning to the caller. It is vital that ast_frame_free be * called on this frame since the payload will be allocated on the heap. * \retval -1 Failure. At some point there was a failure. Do not attempt to use the frame in this case. * \retval 0 Success */ int ast_cc_build_frame(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char * const device_name, const char * const dialstring, enum ast_cc_service_type service, void *private_data, struct ast_frame *frame); /*! * \brief Callback made from ast_cc_callback for certain channel types * \since 1.8 * * \param chan A channel involved in the call. What we want is on a datastore on both incoming and outgoing so either may be provided * \param cc_params The CC configuration parameters for the outbound target * \param monitor_type The type of monitor to use when CC is requested * \param device_name The name of the outbound target device. * \param dialstring The dial string used when calling this specific interface * \param private_data If a native monitor is being used, and some channel-driver-specific private * data has been allocated, then this parameter should contain a pointer to that data. If using a generic * monitor, this parameter should remain NULL. Note that if this function should fail at some point, * it is the responsibility of the caller to free the private data upon return. * * \details * For channel types that fail ast_request when the device is busy, we call into the * channel driver with ast_cc_callback. This is the callback that is called in that * case for each device found which could have been returned by ast_request. * * \return Nothing */ typedef void (*ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char * const device_name, const char * const dialstring, void *private_data); /*! * \since 1.8 * \brief Run a callback for potential matching destinations. * * \note * See the explanation in ast_channel_tech::cc_callback for more * details. * * \param inbound * \param tech Channel technology to use * \param dest Channel/group/peer or whatever the specific technology uses * \param callback Function to call when a target is reached * \retval Always 0, I guess. */ int ast_cc_callback(struct ast_channel *inbound, const char * const tech, const char * const dest, ast_cc_callback_fn callback); /*! * \since 1.8 * \brief Initialize CCSS * * Performs startup routines necessary for CC operation. * * \retval 0 Success * \retval nonzero Failure */ int ast_cc_init(void); #endif /* _ASTERISK_CCSS_H */ asterisk-11.7.0/include/asterisk/autochan.h0000644000175000007640000000725311174343352020602 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Digium, Inc. * * Mark Michelson * * 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 "smart" channels that update automatically if a channel is masqueraded * * \author Mark Michelson */ #include "asterisk.h" #include "asterisk/linkedlists.h" #ifndef _ASTERISK_AUTOCHAN_H #define _ASTERISK_AUTOCHAN_H struct ast_autochan { struct ast_channel *chan; AST_LIST_ENTRY(ast_autochan) list; }; /*! * \par Just what the $!@# is an autochan? * * An ast_autochan is a structure which contains an ast_channel. The pointer * inside an autochan has the ability to update itself if the channel it points * to is masqueraded into a different channel. * * This has a great benefit for any application or service which creates a thread * outside of the channel's main operating thread which keeps a pointer to said * channel. when a masquerade occurs on the channel, the autochan's chan pointer * will automatically update to point to the new channel. * * Some rules for autochans * * 1. If you are going to use an autochan, then be sure to always refer to the * channel using the chan pointer inside the autochan if possible, since this is * the pointer that will be updated during a masquerade. * * 2. If you are going to save off a pointer to the autochan's chan, then be sure * to save off the pointer using ast_channel_ref and to unref the channel when you * are finished with the pointer. If you do not do this and a masquerade occurs on * the channel, then it is possible that your saved pointer will become invalid. */ /*! * \brief set up a new ast_autochan structure * * \details * Allocates and initializes an ast_autochan, sets the * autochan's chan pointer to point to the chan parameter, and * adds the autochan to the global list of autochans. The newly- * created autochan is returned to the caller. This function will * cause the refcount of chan to increase by 1. * * \param chan The channel our new autochan will point to * * \note autochans must be freed using ast_autochan_destroy * * \retval NULL Failure * \retval non-NULL success */ struct ast_autochan *ast_autochan_setup(struct ast_channel *chan); /*! * \brief destroy an ast_autochan structure * * \details * Removes the passed-in autochan from the list of autochans and * unrefs the channel that is pointed to. Also frees the autochan * struct itself. This function will unref the channel reference * which was made in ast_autochan_setup * * \param autochan The autochan that you wish to destroy * * \retval void */ void ast_autochan_destroy(struct ast_autochan *autochan); /*! * \brief Switch what channel autochans point to * * \details * Traverses the list of autochans. All autochans which point to * old_chan will be updated to point to new_chan instead. Currently * this is only called from ast_do_masquerade in channel.c. * * \pre Both channels must be locked before calling this function. * * \param old_chan The channel that autochans may currently point to * \param new_chan The channel that we want to point those autochans to now * * \retval void */ void ast_autochan_new_channel(struct ast_channel *old_chan, struct ast_channel *new_chan); #endif /* _ASTERISK_AUTOCHAN_H */ asterisk-11.7.0/include/asterisk/jabber.h0000644000175000007640000001363511663225161020226 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Digium, Inc. * * Matt O'Gorman * * 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 AJI - The Asterisk Jabber Interface * \arg \ref AJI_intro * \ref res_jabber.c * \author Matt O'Gorman * \extref IKSEMEL http://iksemel.jabberstudio.org * * \page AJI_intro AJI - The Asterisk Jabber Interface * * The Asterisk Jabber Interface, AJI, publishes an API for * modules to use jabber communication. res_jabber.c implements * a Jabber client and a component that can connect as a service * to Jabber servers. * * \section External dependencies * AJI use the IKSEMEL library found at http://iksemel.jabberstudio.org/ * * \section Files * - res_jabber.c * - jabber.h * - chan_gtalk.c * */ #ifndef _ASTERISK_JABBER_H #define _ASTERISK_JABBER_H #ifdef HAVE_OPENSSL #include #include #define TRY_SECURE 2 #define SECURE 4 #endif /* HAVE_OPENSSL */ /* file is read by blocks with this size */ #define NET_IO_BUF_SIZE 4096 /* Return value for timeout connection expiration */ #define IKS_NET_EXPIRED 12 #include #include "asterisk/astobj.h" #include "asterisk/linkedlists.h" /* * As per RFC 3920 - section 3.1, the maximum length for a full Jabber ID * is 3071 bytes. * The ABNF syntax for jid : * jid = [node "@" ] domain [ "/" resource ] * Each allowable portion of a JID (node identifier, domain identifier, * and resource identifier) MUST NOT be more than 1023 bytes in length, * resulting in a maximum total size (including the '@' and '/' separators) * of 3071 bytes. */ #define AJI_MAX_JIDLEN 3071 #define AJI_MAX_RESJIDLEN 1023 #define AJI_MAX_ATTRLEN 256 #define MUC_NS "http://jabber.org/protocol/muc" enum aji_state { AJI_DISCONNECTING, AJI_DISCONNECTED, AJI_CONNECTING, AJI_CONNECTED }; enum { AJI_AUTOPRUNE = (1 << 0), AJI_AUTOREGISTER = (1 << 1), AJI_AUTOACCEPT = (1 << 2), }; enum { AJI_XEP0248 = (1 << 0), AJI_PUBSUB = (1 << 1), AJI_PUBSUB_AUTOCREATE = (1 << 2), }; enum aji_btype { AJI_USER = 0, AJI_TRANS = 1, AJI_UTRANS = 2, }; struct aji_version { char version[50]; int jingle; struct aji_capabilities *parent; struct aji_version *next; }; struct aji_capabilities { char node[200]; struct aji_version *versions; struct aji_capabilities *next; }; struct aji_resource { int status; char resource[AJI_MAX_RESJIDLEN]; char *description; struct aji_version *cap; int priority; struct aji_resource *next; }; struct aji_message { char *from; char *message; char id[25]; struct timeval arrived; AST_LIST_ENTRY(aji_message) list; }; struct aji_buddy { ASTOBJ_COMPONENTS_FULL(struct aji_buddy, AJI_MAX_JIDLEN, 1); char channel[160]; struct aji_resource *resources; enum aji_btype btype; struct ast_flags flags; }; struct aji_buddy_container { ASTOBJ_CONTAINER_COMPONENTS(struct aji_buddy); }; struct aji_transport_container { ASTOBJ_CONTAINER_COMPONENTS(struct aji_transport); }; struct aji_client { ASTOBJ_COMPONENTS(struct aji_client); char password[160]; char user[AJI_MAX_JIDLEN]; char serverhost[AJI_MAX_RESJIDLEN]; char pubsub_node[AJI_MAX_RESJIDLEN]; char statusmessage[256]; char name_space[256]; char sid[10]; /* Session ID */ char mid[6]; /* Message ID */ char context[AST_MAX_CONTEXT]; iksid *jid; iksparser *p; iksfilter *f; ikstack *stack; #ifdef HAVE_OPENSSL SSL_CTX *ssl_context; SSL *ssl_session; const SSL_METHOD *ssl_method; unsigned int stream_flags; #endif /* HAVE_OPENSSL */ enum aji_state state; int port; int debug; int usetls; int forcessl; int usesasl; int keepalive; int allowguest; int timeout; int message_timeout; int authorized; int distribute_events; int send_to_dialplan; struct ast_flags flags; int component; /* 0 client, 1 component */ struct aji_buddy_container buddies; AST_LIST_HEAD(messages,aji_message) messages; void *jingle; pthread_t thread; int priority; enum ikshowtype status; }; struct aji_client_container{ ASTOBJ_CONTAINER_COMPONENTS(struct aji_client); }; /* !Send XML stanza over the established XMPP connection */ int ast_aji_send(struct aji_client *client, iks *x); /*! Send jabber chat message from connected client to jabber URI */ int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message); /*! Send jabber chat message from connected client to a groupchat using * a given nickname */ int ast_aji_send_groupchat(struct aji_client *client, const char *nick, const char *address, const char *message); /*! Disconnect jabber client */ int ast_aji_disconnect(struct aji_client *client); int ast_aji_check_roster(void); void ast_aji_increment_mid(char *mid); /*! Open Chat session */ int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic); /*! Invite to opened Chat session */ int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message); /*! Join/leave existing Chat session */ int ast_aji_join_chat(struct aji_client *client, char *room, char *nick); int ast_aji_leave_chat(struct aji_client *client, char *room, char *nick); /*! Get a client via its name. Increases refcount of client by 1 */ struct aji_client *ast_aji_get_client(const char *name); struct aji_client_container *ast_aji_get_clients(void); /*! Destructor function for buddies to be used with ASTOBJ_UNREF */ void ast_aji_buddy_destroy(struct aji_buddy *obj); /*! Destructor function for clients to be used with ASTOBJ_UNREF after calls to ast_aji_get_client */ void ast_aji_client_destroy(struct aji_client *obj); #endif asterisk-11.7.0/include/asterisk/version.h0000644000175000007640000000012411710072260020444 0ustar sharkyjerryweb#error "Do not include 'asterisk/version.h'; use 'asterisk/ast_version.h' instead." asterisk-11.7.0/include/asterisk/localtime.h0000644000175000007640000001116011451172650020740 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Digium, Inc. * * Mark Spencer * Tilghman Lesher * * 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 Custom localtime functions for multiple timezones */ #ifndef _ASTERISK_LOCALTIME_H #define _ASTERISK_LOCALTIME_H #ifdef HAVE_LOCALE_T_IN_LOCALE_H #include #elif defined(HAVE_LOCALE_T_IN_XLOCALE_H) #include #else typedef void * locale_t; #endif struct ast_tm { int tm_sec; /*!< Seconds. [0-60] (1 leap second) */ int tm_min; /*!< Minutes. [0-59] */ int tm_hour; /*!< Hours. [0-23] */ int tm_mday; /*!< Day. [1-31] */ int tm_mon; /*!< Month. [0-11] */ int tm_year; /*!< Year - 1900. */ int tm_wday; /*!< Day of week. [0-6] */ int tm_yday; /*!< Days in year.[0-365] */ int tm_isdst; /*!< DST. [-1/0/1]*/ long int tm_gmtoff; /*!< Seconds east of UTC. */ char *tm_zone; /*!< Timezone abbreviation. */ /* NOTE: do NOT reorder this final item. The order needs to remain compatible with struct tm */ int tm_usec; /*!< microseconds */ }; /*!\brief Timezone-independent version of localtime_r(3). * \param timep Current time, including microseconds * \param p_tm Pointer to memory where the broken-out time will be stored * \param zone Text string of a standard system zoneinfo file. If NULL, the system localtime will be used. * \retval p_tm is returned for convenience */ struct ast_tm *ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone); void ast_get_dst_info(const time_t * const timep, int *dst_enabled, time_t *dst_start, time_t *dst_end, int *gmt_off, const char * const zone); /*!\brief Timezone-independent version of mktime(3). * \param tmp Current broken-out time, including microseconds * \param zone Text string of a standard system zoneinfo file. If NULL, the system localtime will be used. * \retval A structure containing both seconds and fractional thereof since January 1st, 1970 UTC */ struct timeval ast_mktime(struct ast_tm * const tmp, const char *zone); /*!\brief Set the thread-local representation of the current locale. */ const char *ast_setlocale(const char *locale); /*!\brief Special version of strftime(3) that handles fractions of a second. * Takes the same arguments as strftime(3), with the addition of %q, which * specifies microseconds. * \param buf Address in memory where the resulting string will be stored. * \param len Size of the chunk of memory buf. * \param format A string specifying the format of time to be placed into buf. * \param tm Pointer to the broken out time to be used for the format. * \param locale Text string specifying the locale to be used for language strings. * \retval An integer value specifying the number of bytes placed into buf or -1 on error. */ int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm); int ast_strftime_locale(char *buf, size_t len, const char *format, const struct ast_tm *tm, const char *locale); /*!\brief Special version of strptime(3) which places the answer in the common * structure ast_tm. Also, unlike strptime(3), ast_strptime() initializes its * memory prior to use. * \param s A string specifying some portion of a date and time. * \param format The format in which the string, s, is expected. * \param tm The broken-out time structure into which the parsed data is expected. * \param locale Text string specifying the locale to be used for language strings. * \retval A pointer to the first character within s not used to parse the date and time. */ char *ast_strptime(const char *s, const char *format, struct ast_tm *tm); char *ast_strptime_locale(const char *s, const char *format, struct ast_tm *tm, const char *locale); /*!\brief Wakeup localtime monitor thread * For use in testing. Normally, the failsafe monitor thread waits 60 seconds * between checks to verify whether a timezone file has changed. This routine * forces the monitor thread to wakeup immediately and check the timezone files. */ struct ast_test; void ast_localtime_wakeup_monitor(struct ast_test *info); #endif /* _ASTERISK_LOCALTIME_H */ asterisk-11.7.0/include/asterisk/netsock.h0000644000175000007640000000406511722727734020455 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * Kevin P. Fleming * * 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 Network socket handling */ #ifndef _ASTERISK_NETSOCK_H #define _ASTERISK_NETSOCK_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/network.h" #include "asterisk/io.h" #include "asterisk/netsock2.h" struct ast_netsock; struct ast_netsock_list; struct ast_netsock_list *ast_netsock_list_alloc(void); int ast_netsock_init(struct ast_netsock_list *list); struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, int cos, ast_io_cb callback, void *data); struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc, struct ast_sockaddr *bindaddr, int tos, int cos, ast_io_cb callback, void *data); int ast_netsock_release(struct ast_netsock_list *list); struct ast_netsock *ast_netsock_find(struct ast_netsock_list *list, struct ast_sockaddr *addr); /*! * \deprecated Use ast_seq_qos in netsock2.h which properly handles IPv4 and IPv6 * sockets, instead. */ int ast_netsock_set_qos(int sockfd, int tos, int cos, const char *desc); int ast_netsock_sockfd(const struct ast_netsock *ns); const struct ast_sockaddr *ast_netsock_boundaddr(const struct ast_netsock *ns); void *ast_netsock_data(const struct ast_netsock *ns); void ast_netsock_unref(struct ast_netsock *ns); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_NETSOCK_H */ asterisk-11.7.0/include/asterisk/framehook.h0000644000175000007640000003047711445756505020770 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * David Vossel * * 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 FrameHook Architecture */ /*! \page AstFrameHookAPI Asterisk FrameHook API \section FrameHookFunctionality How FrameHooks Work FrameHooks work by intercepting all frames being written and read off a channel and allowing those frames to be viewed and manipulated within a call back function. Frame interception occurs before any processing is done on the frame, which means this hook can be used to transparently manipulate a frame before it is read from the channel or written to the tech_pvt. This API can be thought of as a layer between the channel API and the Asterisk core when going in the READ direction, and as a layer between the Channel API and the tech_pvt when going in the WRITE direction. \section FrameHookAPIUsage How to Use an FrameHook Attaching and detaching an FrameHook to a channel is very simple. There are only two functions involved, ast_framehook_attach() which will return an id representing the new FrameHook on the channel, and ast_framehook_detach() which signals the FrameHook for detachment and destruction. Below is detailed information each of these functions and their usage. \code struct ast_framehook_interface interface = { .version = AST_FRAMEHOOK_INTERFACE_VERSION, .event_cb = hook_event_cb, .destroy_cb = hook_destroy_cb, .data = data, // where the data ptr points to any custom data used later by the hook cb. }; int id = ast_framehook_attach(channel, &interface); \endcode The ast_framehook_attach() function creates and attaches a new FrameHook onto a channel. Once attached to the channel, the FrameHook will call the event_callback function each time a frame is written or read on the channel. A custom data pointer can be provided to this function to store on the FrameHook as well. This pointer can be used to keep up with any statefull information associated with the FrameHook and is provided during the event_callback function. The destroy_callback function is optional. This function exists so any custom data stored on the FrameHook can be destroyed before the Framehook if destroyed. \code ast_framehook_detach(channel, id); \endcode The ast_framehook_detach() function signals the FrameHook represented by an id to be detached and destroyed on a channel. Since it is possible this function may be called during the FrameHook's event callback, it is impossible to synchronously detach the FrameHook from the channel during this function call. It is guaranteed that the next event proceeding the ast_framehook_detach() will be of type AST_FRAMEHOOK_EVENT_DETACH, and that after that event occurs no other event will ever be issued for that FrameHook. Once the FrameHook is destroyed, the destroy callback function will be called if it was provided. Note that if this function is never called, the FrameHook will be detached on channel destruction. \section FrameHookAPICodeExample FrameHook Example Code The example code below attaches an FrameHook on a channel, and then detachs it when the first ast_frame is read or written to the event callback function. The Framehook's id is stored on the FrameHook's data pointer so it can be detached within the callback. \code static void destroy_cb(void *data) { ast_free(data); } static struct ast_frame *event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data) { int *id = data; if (!frame) { return frame; } if (event == AST_FRAMEHOOK_EVENT_WRITE) { ast_log(LOG_NOTICE, "YAY we received a frame in the write direction, Type: %d\n", frame->frametype) ast_framehook_detach(chan, id); // the channel is guaranteed to be locked during this function call. } else if (event == AST_FRAMEHOOK_EVENT_READ) { ast_log(LOG_NOTICE, "YAY we received a frame in the read direction: Type: %d\n", frame->frametype); ast_framehook_detach(chan, id); // the channel is guaranteed to be locked during this function call. } return frame; { int some_function() { struct ast_framehook_interface interface = { .version = AST_FRAMEHOOK_INTERFACE_VERSION, .event_cb = hook_event_cb, .destroy_cb = hook_destroy_cb, }; int *id = ast_calloc(1, sizeof(int)); if (!id) { return -1; } interface.data = id; // This data will be returned to us in the callbacks. ast_channel_lock(chan); *id = ast_framehook_attach(chan, &interface); ast_channel_unlock(chan); if (*id < 0) { // framehook attach failed, free data ast_free(id); return -1; } return 0; } \endcode */ #ifndef _AST_FRAMEHOOK_H_ #define _AST_FRAMEHOOK_H_ #include "asterisk/linkedlists.h" #include "asterisk/frame.h" struct ast_framehook; struct ast_framehook_list; /*! * \brief These are the types of events that the framehook's event callback can receive * \since 1.8 */ enum ast_framehook_event { AST_FRAMEHOOK_EVENT_READ, /*!< frame is intercepted in the read direction on the channel. */ AST_FRAMEHOOK_EVENT_WRITE, /*!< frame is intercepted on the write direction on the channel. */ AST_FRAMEHOOK_EVENT_ATTACHED, /*!< framehook is attached and running on the channel, the first message sent to event_cb. */ AST_FRAMEHOOK_EVENT_DETACHED /*!< framehook is detached from the channel, last message sent to event_cb. */ }; /*! * \brief This callback is called every time an event occurs on the framehook. * \since 1.8 * * \details Two events are guaranteed to occur once the ast_framehook_attach() * function is called. These events are AST_FRAMEHOOK_EVENT_ATTACHED, which occurs * immediately after the framehook is attached to a channel, and * AST_FRAMEHOOK_EVENT_DETACHED, which occurs right after the framehook is * detached. * * It is completely valid for the frame variable to be set to NULL. Always do a NULL * check on the frame before attempted to access it. When the frame variable is present, * it is safe to view and manipulate that frame in any way possible. It is even safe * to return a completely different frame, but when that occurs this function is in * charge of freeing the previous frame. * * The ast_channel will always be locked during this callback. Never attempt to unlock the * channel for any reason. * * \param channel, The ast_channel this framehook is attached to * \param frame, The ast_frame being intercepted for viewing and manipulation * \param event, The type of event which is occurring * \param data, The data pointer provided at framehook initilization. * * \retval the resulting frame. */ typedef struct ast_frame *(*ast_framehook_event_callback)( struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data); /*! * \brief This callback is called immediately before the framehook is destroyed. * \since 1.8 * \note This function should be used to clean up any pointers pointing to the * framehook structure as the framehook will be freed immediately afterwards. * * \param data, The data pointer provided at framehook initialization. This * is a good place to clean up any state data allocated for the framehook stored in this * pointer. */ typedef void (*ast_framehook_destroy_callback)(void *data); #define AST_FRAMEHOOK_INTERFACE_VERSION 1 /*! This interface is required for attaching a framehook to a channel. */ struct ast_framehook_interface { /*! framehook interface version number */ uint16_t version; /*! event_cb represents the function that will be called everytime an event occurs on the framehook. */ ast_framehook_event_callback event_cb; /*! destroy_cb is optional. This function is called immediately before the framehook * is destroyed to allow for stored_data cleanup. */ ast_framehook_destroy_callback destroy_cb; /*! This pointer can represent any custom data to be stored on the !framehook. This * data pointer will be provided during each event callback which allows the framehook * to store any stateful data associated with the application using the hook. */ void *data; }; /*! * \brief Attach an framehook onto a channel for frame interception. * \since 1.8 * * \param ast_channel, The channel to attach the hook on to. * \param framehook interface, The framehook's callback functions and stored data. * * \pre XXX The Channel must be locked during this function all. * * \note The data pointer is never touched by the framehook API except to * provide it during the event and destruction callbacks. It is entirely up to the * application using this API to manage the memory associated with the data pointer. * * \retval On success, positive id representing this hook on the channel * \retval On failure, -1 */ int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i); /*! * \brief Detach an framehook from a channel. * \since 1.8 * * \pre XXX The Channel must be locked during this function all. * If this function is never called after attaching an framehook, * the framehook will be detached and destroyed during channel * destruction. * * \param The channel the framehook is attached to * \param The framehook's id * * \retval 0 success * \retval -1 framehook did not exist on the channel. This means the * framehook either never existed on the channel, or was already detached. */ int ast_framehook_detach(struct ast_channel *chan, int framehook_id); /*! * \brief This is used by the channel API to detach and destroy all * framehooks on a channel during channel destruction. * \since 1.8 * * \pre XXX The Channel must be locked during this function all. * * \param channel containing the framehook list to destroy. * \retval 0 success * \retval -1 failure */ int ast_framehook_list_destroy(struct ast_channel *chan); /*! * \brief This is used by the channel API push a frame read event to a channel's framehook list. * \since 1.8 * * \details After this function completes, the resulting frame that is returned could be anything, * even NULL. There is nothing to keep up with after this function. If the frame is modified, the * framehook callback is in charge of any memory management associated with that modification. * * \pre XXX The Channel must be locked during this function all. * * \param framehook list to push event to. * \param frame being pushed to the framehook list. * * \return The resulting frame after being viewed and modified by the framehook callbacks. */ struct ast_frame *ast_framehook_list_read_event(struct ast_framehook_list *framehooks, struct ast_frame *frame); /*! * \brief This is used by the channel API push a frame write event to a channel's framehook list. * \since 1.8 * * \details After this function completes, the resulting frame that is returned could be anything, * even NULL. There is nothing to keep up with after this function. If the frame is modified, the * framehook callback is in charge of any memory management associated with that modification. * * \pre XXX The Channel must be locked during this function all. * * \param framehook list to push event to. * \param frame being pushed to the framehook list. * * \return The resulting frame after being viewed and modified by the framehook callbacks. */ struct ast_frame *ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame); /*! * \brief Determine if an framehook list is empty or not * \since 1.8 * \pre XXX The Channel must be locked during this function all. * * \param the framehook list * \retval 0, not empty * \retval 1, is empty */ int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks); #endif /* _AST_FRAMEHOOK_H */ asterisk-11.7.0/include/asterisk/unaligned.h0000644000175000007640000000717411432562134020746 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * Mark Spencer * * 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 Handle unaligned data access */ #ifndef _ASTERISK_UNALIGNED_H #define _ASTERISK_UNALIGNED_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #ifdef __GNUC__ /* If we just tell GCC what's going on, we can trust it to behave optimally */ static inline uint64_t get_unaligned_uint64(const void *p) { const struct { uint64_t d; } __attribute__((packed)) *pp = p; return pp->d; } static inline unsigned int get_unaligned_uint32(const void *p) { const struct { unsigned int d; } __attribute__((packed)) *pp = p; return pp->d; } static inline unsigned short get_unaligned_uint16(const void *p) { const struct { unsigned short d; } __attribute__((packed)) *pp = p; return pp->d; } static inline void put_unaligned_uint64(void *p, uint64_t datum) { struct { uint64_t d; } __attribute__((packed,may_alias)) *pp = p; pp->d = datum; } static inline void put_unaligned_uint32(void *p, unsigned int datum) { struct { unsigned int d; } __attribute__((packed)) *pp = p; pp->d = datum; } static inline void put_unaligned_uint16(void *p, unsigned short datum) { struct { unsigned short d; } __attribute__((packed)) *pp = p; pp->d = datum; } #elif defined(SOLARIS) && defined(__sparc__) static inline uint64_t get_unaligned_uint64(const void *p) { const unsigned char *cp = p; return (((uint64_t) cp[0]) << 56) | (((uint64_t) cp[1]) << 48) | (((uint64_t) cp[2]) << 40) | (((uint64_t) cp[3]) << 32) | (((uint64_t) cp[4]) << 24) | (((uint64_t) cp[5]) << 16) | (((uint64_t) cp[6]) << 8) | (((uint64_t) cp[7]) << 0); } static inline unsigned int get_unaligned_uint32(const void *p) { const unsigned char *cp = p; return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; } static inline unsigned short get_unaligned_uint16(const void *p) { const unsigned char *cp = p; return (cp[0] << 8) | cp[1] ; } static inline void put_unaligned_uint64(void *p, uint64_t datum) { unsigned char *cp = p; cp[0] = (datum >> 56) & 0xff; cp[1] = (datum >> 48) & 0xff; cp[2] = (datum >> 40) & 0xff; cp[3] = (datum >> 32) & 0xff; cp[4] = (datum >> 24) & 0xff; cp[5] = (datum >> 16) & 0xff; cp[6] = (datum >> 8) & 0xff; cp[7] = (datum >> 0) & 0xff; } static inline void put_unaligned_uint32(void *p, unsigned int datum) { unsigned char *cp = p; cp[0] = datum >> 24; cp[1] = datum >> 16; cp[2] = datum >> 8; cp[3] = datum; } static inline void put_unaligned_uint16(void *p, unsigned int datum) { unsigned char *cp = p; cp[0] = datum >> 8; cp[1] = datum; } #else /* Not GCC, not Solaris/SPARC. Assume we can handle direct load/store. */ #define get_unaligned_uint64(p) (*((uint64_t *)(p))) #define get_unaligned_uint32(p) (*((unsigned int *)(p))) #define get_unaligned_uint16(p) (*((unsigned short *)(p))) #define put_unaligned_uint64(p,d) do { uint64_t *__P = (p); *__P = d; } while(0) #define put_unaligned_uint32(p,d) do { unsigned int *__P = (p); *__P = d; } while(0) #define put_unaligned_uint16(p,d) do { unsigned short *__P = (p); *__P = d; } while(0) #endif #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_UNALIGNED_H */ asterisk-11.7.0/include/asterisk/slin.h0000644000175000007640000000671411522553062017744 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * Russell Bryant * * 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. */ /* Source: beep.sln16 * Converted to beep.sln via file convert, then converted to hex: * od -An -tx2 beep.sln | awk '{for (i=1; i and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the Advanced Linux Sound Architecture library. */ #undef HAVE_ALSA /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_NAMESER_H /* Define to 1 if you have the `asin' function. */ #undef HAVE_ASIN /* Define to 1 if you have the `asinl' function. */ #undef HAVE_ASINL /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF /* Define to 1 if you have the `atan' function. */ #undef HAVE_ATAN /* Define to 1 if you have the `atan2' function. */ #undef HAVE_ATAN2 /* Define to 1 if you have the `atan2l' function. */ #undef HAVE_ATAN2L /* Define to 1 if you have the `atanl' function. */ #undef HAVE_ATANL /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT /* Define to 1 if your GCC C compiler supports the 'always_inline' attribute. */ #undef HAVE_ATTRIBUTE_always_inline /* Define to 1 if your GCC C compiler supports the 'const' attribute. */ #undef HAVE_ATTRIBUTE_const /* Define to 1 if your GCC C compiler supports the 'deprecated' attribute. */ #undef HAVE_ATTRIBUTE_deprecated /* Define to 1 if your GCC C compiler supports the 'malloc' attribute. */ #undef HAVE_ATTRIBUTE_malloc /* Define to 1 if your GCC C compiler supports the 'pure' attribute. */ #undef HAVE_ATTRIBUTE_pure /* Define to 1 if your GCC C compiler supports the 'sentinel' attribute. */ #undef HAVE_ATTRIBUTE_sentinel /* Define to 1 if your GCC C compiler supports the 'unused' attribute. */ #undef HAVE_ATTRIBUTE_unused /* Define to 1 if your GCC C compiler supports the 'warn_unused_result' attribute. */ #undef HAVE_ATTRIBUTE_warn_unused_result /* Define to 1 if your GCC C compiler supports the 'weak' attribute. */ #undef HAVE_ATTRIBUTE_weak /* Define to 1 if your GCC C compiler supports the 'weak_import' attribute. */ #undef HAVE_ATTRIBUTE_weak_import /* Define to 1 if your GCC C compiler supports the 'weakref' attribute. */ #undef HAVE_ATTRIBUTE_weakref /* Define to 1 if you have the Debug symbol decoding library. */ #undef HAVE_BFD /* Define to 1 if you have the Stack Backtrace library. */ #undef HAVE_BKTR /* Define to 1 if you have the Bluetooth library. */ #undef HAVE_BLUETOOTH /* Define to 1 if byteswap.h macros are available. */ #undef HAVE_BYTESWAP_H /* Define to 1 if you have the POSIX 1.e capabilities library. */ #undef HAVE_CAP /* Define to 1 if you have the `ceil' function. */ #undef HAVE_CEIL /* Define to 1 if you have the `ceill' function. */ #undef HAVE_CEILL /* Define to 1 if your system has a working `chown' function. */ #undef HAVE_CHOWN /* Define to 1 if you have the `closefrom' function. */ #undef HAVE_CLOSEFROM /* Define to 1 if you have the Corosync library. */ #undef HAVE_COROSYNC /* Define to 1 if COROSYNC has the A callback only in corosync 1.x feature. */ #undef HAVE_COROSYNC_CFG_STATE_TRACK /* Define to 1 if you have the `cos' function. */ #undef HAVE_COS /* Define to 1 if you have the `cosl' function. */ #undef HAVE_COSL /* Define to 1 if you have the OpenSSL Cryptography library. */ #undef HAVE_CRYPTO /* Define to 1 if you have a functional curl library. */ #undef HAVE_CURL /* Define to 1 if you have the curses library. */ #undef HAVE_CURSES /* Define if your system has the DAHDI headers. */ #undef HAVE_DAHDI /* Define if your system has the DAHDI_ECHOCANCEL_FAX_MODE headers. */ #undef HAVE_DAHDI_ECHOCANCEL_FAX_MODE /* Define if your system has the DAHDI_HALF_FULL headers. */ #undef HAVE_DAHDI_HALF_FULL /* Define if your system has the DAHDI_LINEREVERSE_VMWI headers. */ #undef HAVE_DAHDI_LINEREVERSE_VMWI /* Define DAHDI headers version */ #undef HAVE_DAHDI_VERSION /* Define to 1 if your system has /dev/urandom. */ #undef HAVE_DEV_URANDOM /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if your system has the dladdr() GNU extension */ #undef HAVE_DLADDR /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the `dup2' function. */ #undef HAVE_DUP2 /* Define to 1 if you have the `eaccess' function. */ #undef HAVE_EACCESS /* Define to 1 if you have the `endpwent' function. */ #undef HAVE_ENDPWENT /* Define to 1 if you have the `euidaccess' function. */ #undef HAVE_EUIDACCESS /* Define to 1 if you have the `exp' function. */ #undef HAVE_EXP /* Define to 1 if you have the `exp10' function. */ #undef HAVE_EXP10 /* Define to 1 if you have the `exp10l' function. */ #undef HAVE_EXP10L /* Define to 1 if you have the `exp2' function. */ #undef HAVE_EXP2 /* Define to 1 if you have the `exp2l' function. */ #undef HAVE_EXP2L /* Define to 1 if you have the `expl' function. */ #undef HAVE_EXPL /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the Ffmpeg and avcodec library. */ #undef HAVE_FFMPEG /* Define to 1 if you have the `ffsll' function. */ #undef HAVE_FFSLL /* Define to 1 if you have the `floor' function. */ #undef HAVE_FLOOR /* Define to 1 if you have the `floorl' function. */ #undef HAVE_FLOORL /* Define to 1 if you have the `fmod' function. */ #undef HAVE_FMOD /* Define to 1 if you have the `fmodl' function. */ #undef HAVE_FMODL /* Define to 1 if you have the `fopencookie' function. */ #undef HAVE_FOPENCOOKIE /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the FreeTDS library. */ #undef HAVE_FREETDS /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO /* Define to 1 if you have the `ftruncate' function. */ #undef HAVE_FTRUNCATE /* Define to 1 if you have the `funopen' function. */ #undef HAVE_FUNOPEN /* Define to 1 if your GCC C compiler provides atomic operations. */ #undef HAVE_GCC_ATOMICS /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD /* Define to 1 if you have the `gethostbyname' function. */ #undef HAVE_GETHOSTBYNAME /* Define to 1 if your system has gethostbyname_r with 5 arguments. */ #undef HAVE_GETHOSTBYNAME_R_5 /* Define to 1 if your system has gethostbyname_r with 6 arguments. */ #undef HAVE_GETHOSTBYNAME_R_6 /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define if your system has the GETIFADDRS headers. */ #undef HAVE_GETIFADDRS /* Define to 1 if you have the `getloadavg' function. */ #undef HAVE_GETLOADAVG /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE /* Define to 1 if you have the `getpeereid' function. */ #undef HAVE_GETPEEREID /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the `glob' function. */ #undef HAVE_GLOB /* Define if your system has the GLOB_BRACE headers. */ #undef HAVE_GLOB_BRACE /* Define if your system has the GLOB_NOMAGIC headers. */ #undef HAVE_GLOB_NOMAGIC /* Define if your system has the GMIME libraries. */ #undef HAVE_GMIME /* Define to indicate the GSM library */ #undef HAVE_GSM /* Define to indicate that gsm.h is in gsm/gsm.h */ #undef HAVE_GSM_GSM_HEADER /* Define to indicate that gsm.h has no prefix for its location */ #undef HAVE_GSM_HEADER /* Define if your system has the GTK2 libraries. */ #undef HAVE_GTK2 /* Define to 1 if you have the Hoard Memory Allocator library. */ #undef HAVE_HOARD /* Define to 1 if you have the `htonll' function. */ #undef HAVE_HTONLL /* Define to 1 if you have the iCal library. */ #undef HAVE_ICAL /* Define to 1 if you have the Iconv library. */ #undef HAVE_ICONV /* Define to 1 if you have the Iksemel Jabber library. */ #undef HAVE_IKSEMEL /* Define if your system has the ILBC libraries. */ #undef HAVE_ILBC /* Define if your system has the UW IMAP Toolkit c-client library. */ #undef HAVE_IMAP_TK /* Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater. */ #undef HAVE_IMAP_TK2006 /* Define to 1 if you have the `inet_aton' function. */ #undef HAVE_INET_ATON /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA /* Define to 1 if you have the inotify support library. */ #undef HAVE_INOTIFY /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the iODBC library. */ #undef HAVE_IODBC /* Define to 1 if you have the `ioperm' function. */ #undef HAVE_IOPERM /* Define if your system has the IP_MTU_DISCOVER headers. */ #undef HAVE_IP_MTU_DISCOVER /* Define to 1 if you have the `isascii' function. */ #undef HAVE_ISASCII /* Define to 1 if you have the ISDN4Linux library. */ #undef HAVE_ISDNNET /* Define to 1 if you have the Jack Audio Connection Kit library. */ #undef HAVE_JACK /* Define to 1 if you have the `kevent64' function. */ #undef HAVE_KEVENT64 /* Define to 1 if you have the kqueue support library. */ #undef HAVE_KQUEUE /* Define to 1 if you have the OpenLDAP library. */ #undef HAVE_LDAP /* Define if your system has the LIBEDIT libraries. */ #undef HAVE_LIBEDIT /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM /* Define if your system has the LIBXML2 libraries. */ #undef HAVE_LIBXML2 /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if your system has linux/compiler.h. */ #undef HAVE_LINUX_COMPILER_H /* Define to 1 if limits.h includes a LLONG_MAX definition. */ #undef HAVE_LLONG_MAX /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if your system defines the locale_t type in locale.h */ #undef HAVE_LOCALE_T_IN_LOCALE_H /* Define to 1 if your system defines the locale_t type in xlocale.h */ #undef HAVE_LOCALE_T_IN_XLOCALE_H /* Define to 1 if you have the `log' function. */ #undef HAVE_LOG /* Define to 1 if you have the `log10' function. */ #undef HAVE_LOG10 /* Define to 1 if you have the `log10l' function. */ #undef HAVE_LOG10L /* Define to 1 if you have the `log2' function. */ #undef HAVE_LOG2 /* Define to 1 if you have the `log2l' function. */ #undef HAVE_LOG2L /* Define to 1 if you have the `logl' function. */ #undef HAVE_LOGL /* Define to 1 if the type `long double' works and has more range or precision than `double'. */ #undef HAVE_LONG_DOUBLE_WIDER /* Define to 1 if you have the libtool library. */ #undef HAVE_LTDL /* Define to 1 if you have the Lua library. */ #undef HAVE_LUA /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the `memchr' function. */ #undef HAVE_MEMCHR /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the mISDN user library. */ #undef HAVE_MISDN /* Define if your system has the MISDN_FAC_ERROR headers. */ #undef HAVE_MISDN_FAC_ERROR /* Define if your system has the MISDN_FAC_RESULT headers. */ #undef HAVE_MISDN_FAC_RESULT /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the `mkdtemp' function. */ #undef HAVE_MKDTEMP /* Define to 1 if you have a working `mmap' system call. */ #undef HAVE_MMAP /* Define if your system has the MSG_NOSIGNAL headers. */ #undef HAVE_MSG_NOSIGNAL /* Define to 1 if you have the `munmap' function. */ #undef HAVE_MUNMAP /* Define if your system has the MYSQLCLIENT libraries. */ #undef HAVE_MYSQLCLIENT /* Define to 1 if you have the Network Broadcast Sound library. */ #undef HAVE_NBS /* Define to 1 if you have the ncurses library. */ #undef HAVE_NCURSES /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define if your system has the NEON libraries. */ #undef HAVE_NEON /* Define if your system has the NEON29 libraries. */ #undef HAVE_NEON29 /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define if your system has the NETSNMP libraries. */ #undef HAVE_NETSNMP /* Define to 1 if you have the `newlocale' function. */ #undef HAVE_NEWLOCALE /* Define to 1 if you have the newt library. */ #undef HAVE_NEWT /* Define to 1 if you have the `ntohll' function. */ #undef HAVE_NTOHLL /* Define to 1 if your C library can safely print NULL to string formats. */ #undef HAVE_NULLSAFE_PRINTF /* Define to 1 if your ODBC library has wide (Unicode) types. */ #undef HAVE_ODBC_WCHAR /* Define to 1 if you have the OGG library. */ #undef HAVE_OGG /* Define if your system has the OpenH323 libraries. */ #undef HAVE_OPENH323 /* Define to 1 if you have the MFR2 library. */ #undef HAVE_OPENR2 /* Define to 1 if you have the OpenSSL Secure Sockets Layer library. */ #undef HAVE_OPENSSL /* Define to 1 if CRYPTO has the OpenSSL SRTP Extension Support feature. */ #undef HAVE_OPENSSL_SRTP /* Define this to indicate the ${OSPTK_DESCRIP} library */ #undef HAVE_OSPTK /* Define to 1 if you have the Open Sound System library. */ #undef HAVE_OSS /* Define to 1 if OSX atomic operations are supported. */ #undef HAVE_OSX_ATOMICS /* Define to 1 if your system defines the file flag O_EVTONLY in fcntl.h */ #undef HAVE_O_EVTONLY /* Define to 1 if your system defines the file flag O_SYMLINK in fcntl.h */ #undef HAVE_O_SYMLINK /* Define to indicate the PostgreSQL library */ #undef HAVE_PGSQL /* Define to indicate presence of the pg_encoding_to_char API. */ #undef HAVE_PGSQL_pg_encoding_to_char /* Define to 1 if your system defines IP_PKTINFO. */ #undef HAVE_PKTINFO /* Define to 1 if you have the popt library. */ #undef HAVE_POPT /* Define to 1 if you have the PortAudio library. */ #undef HAVE_PORTAUDIO /* Define to 1 if you have the `pow' function. */ #undef HAVE_POW /* Define to 1 if you have the `powl' function. */ #undef HAVE_POWL /* Define to 1 if you have the `ppoll' function. */ #undef HAVE_PPOLL /* Define to 1 if you have the ISDN PRI library. */ #undef HAVE_PRI /* Define to 1 if PRI has the ISDN PRI advice of charge supplementary service events feature. */ #undef HAVE_PRI_AOC_EVENTS /* Define to 1 if PRI has the ISDN PRI call hold feature. */ #undef HAVE_PRI_CALL_HOLD /* Define to 1 if PRI has the ISDN PRI call rerouting and call deflection feature. */ #undef HAVE_PRI_CALL_REROUTING /* Define to 1 if PRI has the ISDN PRI call waiting supplementary service feature. */ #undef HAVE_PRI_CALL_WAITING /* Define to 1 if PRI has the ISDN PRI call completion supplementary service feature. */ #undef HAVE_PRI_CCSS /* Define to 1 if PRI has the ISDN PRI Date/time ie send policy feature. */ #undef HAVE_PRI_DATETIME_SEND /* Define to 1 if PRI has the ISDN PRI user display text IE contents during call feature. */ #undef HAVE_PRI_DISPLAY_TEXT /* Define to 1 if PRI has the ISDN PRI hangup fix feature. */ #undef HAVE_PRI_HANGUP_FIX /* Define to 1 if PRI has the ISDN PRI set_inbanddisconnect feature. */ #undef HAVE_PRI_INBANDDISCONNECT /* Define to 1 if PRI has the ISDN Layer 2 persistence option feature. */ #undef HAVE_PRI_L2_PERSISTENCE /* Define to 1 if PRI has the ISDN PRI Malicious Call ID feature. */ #undef HAVE_PRI_MCID /* Define to 1 if PRI has the ISDN PRI Message Waiting Indication feature. */ #undef HAVE_PRI_MWI /* Define to 1 if PRI has the ISDN PRI Message Waiting Indication (Fixed) feature. */ #undef HAVE_PRI_MWI_V2 /* Define to 1 if PRI has the ISDN progress with cause feature. */ #undef HAVE_PRI_PROG_W_CAUSE /* Define to 1 if PRI has the ISDN reverse charge feature. */ #undef HAVE_PRI_REVERSE_CHARGE /* Define to 1 if PRI has the ISDN service messages feature. */ #undef HAVE_PRI_SERVICE_MESSAGES /* Define to 1 if PRI has the ISDN PRI keypad facility in SETUP feature. */ #undef HAVE_PRI_SETUP_KEYPAD /* Define to 1 if PRI has the ISDN PRI subaddressing feature. */ #undef HAVE_PRI_SUBADDR /* Define to 1 if PRI has the ISDN PRI call transfer supplementary service feature. */ #undef HAVE_PRI_TRANSFER /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Define to 1 if your system defines PTHREAD_MUTEX_RECURSIVE_NP in pthread.h */ #undef HAVE_PTHREAD_MUTEX_RECURSIVE_NP /* Define if your system has the PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP headers. */ #undef HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP /* Define if your system has the PTHREAD_RWLOCK_INITIALIZER headers. */ #undef HAVE_PTHREAD_RWLOCK_INITIALIZER /* Define to 1 if your system defines PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h */ #undef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP /* Define if your system has pthread_rwlock_timedwrlock() */ #undef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK /* Define to 1 if the system has the type `ptrdiff_t'. */ #undef HAVE_PTRDIFF_T /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV /* Define if your system has the PWLib libraries. */ #undef HAVE_PWLIB /* Define to 1 if you have the Radius Client library. */ #undef HAVE_RADIUS /* Define to 1 if you have the `regcomp' function. */ #undef HAVE_REGCOMP /* Define to 1 if you have the `remainder' function. */ #undef HAVE_REMAINDER /* Define to 1 if you have the `remainderl' function. */ #undef HAVE_REMAINDERL /* Define to 1 if you have the LIBRESAMPLE library. */ #undef HAVE_RESAMPLE /* Define to 1 if your system has the close resolver function. */ #undef HAVE_RES_CLOSE /* Define to 1 if your system has the ndestroy resolver function. */ #undef HAVE_RES_NDESTROY /* Define to 1 if your system has the re-entrant resolver functions. */ #undef HAVE_RES_NINIT /* Define to 1 if you have the `re_comp' function. */ #undef HAVE_RE_COMP /* Define to 1 if you have the `rint' function. */ #undef HAVE_RINT /* Define to 1 if you have the `rintl' function. */ #undef HAVE_RINTL /* Define to 1 if you have the `round' function. */ #undef HAVE_ROUND /* Define to 1 if you have the `roundf' function. */ #undef HAVE_ROUNDF /* Define to 1 if you have the `roundl' function. */ #undef HAVE_ROUNDL /* Define to 1 if your system has /sbin/launchd. */ #undef HAVE_SBIN_LAUNCHD /* Define if your system has the SDL libraries. */ #undef HAVE_SDL /* Define to 1 if you have the Sdl Image library. */ #undef HAVE_SDL_IMAGE /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV /* Define to 1 if you have the `sin' function. */ #undef HAVE_SIN /* Define to 1 if you have the `sinl' function. */ #undef HAVE_SINL /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if your system has soxmix application. */ #undef HAVE_SOXMIX /* Define if your system has the SO_NOSIGPIPE headers. */ #undef HAVE_SO_NOSIGPIPE /* Define if your system has the SPANDSP headers. */ #undef HAVE_SPANDSP /* Define to 1 if you have the Speex library. */ #undef HAVE_SPEEX /* Define to 1 if you have the SpeexDSP library. */ #undef HAVE_SPEEXDSP /* Define to 1 if you have the speex_preprocess_ctl library. */ #undef HAVE_SPEEX_PREPROCESS /* Define to 1 if you have the SQLite library. */ #undef HAVE_SQLITE /* Define to 1 if you have the SQLite library. */ #undef HAVE_SQLITE3 /* Define to 1 if you have the `sqrtl' function. */ #undef HAVE_SQRTL /* Define to 1 if you have the Secure RTP library. */ #undef HAVE_SRTP /* Define to 1 if SRTP has the SRTP Library Shutdown Function feature. */ #undef HAVE_SRTP_SHUTDOWN /* Define to 1 if you have the ISDN SS7 library. */ #undef HAVE_SS7 /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strcasestr' function. */ #undef HAVE_STRCASESTR /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strcoll' function and it is properly defined. */ #undef HAVE_STRCOLL /* Define to 1 if you have the `strcspn' function. */ #undef HAVE_STRCSPN /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the `strftime' function. */ #undef HAVE_STRFTIME /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strlcat' function. */ #undef HAVE_STRLCAT /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY /* Define to 1 if you have the `strncasecmp' function. */ #undef HAVE_STRNCASECMP /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP /* Define to 1 if you have the `strnlen' function. */ #undef HAVE_STRNLEN /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strsep' function. */ #undef HAVE_STRSEP /* Define to 1 if you have the `strspn' function. */ #undef HAVE_STRSPN /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the `strtod' function. */ #undef HAVE_STRTOD /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the `strtold' function. */ #undef HAVE_STRTOLD /* Define to 1 if you have the `strtoq' function. */ #undef HAVE_STRTOQ /* Define to 1 if `ifr_ifru.ifru_hwaddr' is a member of `struct ifreq'. */ #undef HAVE_STRUCT_IFREQ_IFR_IFRU_IFRU_HWADDR /* Define to 1 if `uid' is a member of `struct sockpeercred'. */ #undef HAVE_STRUCT_SOCKPEERCRED_UID /* Define to 1 if `st_blksize' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BLKSIZE /* Define to 1 if `cr_uid' is a member of `struct ucred'. */ #undef HAVE_STRUCT_UCRED_CR_UID /* Define to 1 if `uid' is a member of `struct ucred'. */ #undef HAVE_STRUCT_UCRED_UID /* Define to 1 if you have the mISDN Supplemental Services library. */ #undef HAVE_SUPPSERV /* Define to 1 if you have the `swapctl' function. */ #undef HAVE_SWAPCTL /* Define to 1 if you have the `sysctl' function. */ #undef HAVE_SYSCTL /* Define to 1 if your system has sysinfo support */ #undef HAVE_SYSINFO /* Define if your system has the SYSLOG_FACILITY_LOG_AUTH headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_AUTH /* Define if your system has the SYSLOG_FACILITY_LOG_AUTHPRIV headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_AUTHPRIV /* Define if your system has the SYSLOG_FACILITY_LOG_CRON headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_CRON /* Define if your system has the SYSLOG_FACILITY_LOG_DAEMON headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_DAEMON /* Define if your system has the SYSLOG_FACILITY_LOG_FTP headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_FTP /* Define if your system has the SYSLOG_FACILITY_LOG_KERN headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_KERN /* Define if your system has the SYSLOG_FACILITY_LOG_LPR headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_LPR /* Define if your system has the SYSLOG_FACILITY_LOG_MAIL headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_MAIL /* Define if your system has the SYSLOG_FACILITY_LOG_NEWS headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_NEWS /* Define if your system has the SYSLOG_FACILITY_LOG_SYSLOG headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_SYSLOG /* Define if your system has the SYSLOG_FACILITY_LOG_UUCP headers. */ #undef HAVE_SYSLOG_FACILITY_LOG_UUCP /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if your sys/endian.h header file provides the bswap16 macro. */ #undef HAVE_SYS_ENDIAN_BSWAP16 /* Define to 1 if your sys/endian.h header file provides the __swap16 macro. */ #undef HAVE_SYS_ENDIAN_SWAP16 /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EVENT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_FILE_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IO_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if your system has working sys/poll.h */ #undef HAVE_SYS_POLL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_THR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the `tan' function. */ #undef HAVE_TAN /* Define to 1 if you have the `tanl' function. */ #undef HAVE_TANL /* Define to 1 if you have the Termcap library. */ #undef HAVE_TERMCAP /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define if your system has the TIMERFD headers. */ #undef HAVE_TIMERFD /* Define to 1 if your system defines timersub. */ #undef HAVE_TIMERSUB /* Define to 1 if you have the Term Info library. */ #undef HAVE_TINFO /* Define to 1 if you have the tonezone library. */ #undef HAVE_TONEZONE /* Define to 1 if you have the `trunc' function. */ #undef HAVE_TRUNC /* Define to 1 if you have the `truncl' function. */ #undef HAVE_TRUNCL /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the unixODBC library. */ #undef HAVE_UNIXODBC /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV /* Define to 1 if you have the `utime' function. */ #undef HAVE_UTIME /* Define to 1 if you have the header file. */ #undef HAVE_UTIME_H /* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */ #undef HAVE_UTIME_NULL /* Define to 1 if you have the UUID library. */ #undef HAVE_UUID /* Define to 1 if your system can support larger than default select bitmasks. */ #undef HAVE_VARIABLE_FDSET /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if your system has linux/videodev.h. */ #undef HAVE_VIDEODEV_H /* Define to 1 if you have the Vorbis library. */ #undef HAVE_VORBIS /* Define if your system has OV_CALLBACKS_NOCLOSE declared. */ #undef HAVE_VORBIS_OPEN_CALLBACKS /* Define if your system has the VoiceTronix API libraries. */ #undef HAVE_VPB /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to 1 if you have the X11 library. */ #undef HAVE_X11 /* Define to the version of the X11 library. */ #undef HAVE_X11_VERSION /* Define to 1 if you have the header file. */ #undef HAVE_XLOCALE_H /* Define to 1 if you have the zlib compression library. */ #undef HAVE_ZLIB /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Defined if libcurl supports AsynchDNS */ #undef LIBCURL_FEATURE_ASYNCHDNS /* Defined if libcurl supports IDN */ #undef LIBCURL_FEATURE_IDN /* Defined if libcurl supports IPv6 */ #undef LIBCURL_FEATURE_IPV6 /* Defined if libcurl supports KRB4 */ #undef LIBCURL_FEATURE_KRB4 /* Defined if libcurl supports libz */ #undef LIBCURL_FEATURE_LIBZ /* Defined if libcurl supports NTLM */ #undef LIBCURL_FEATURE_NTLM /* Defined if libcurl supports SSL */ #undef LIBCURL_FEATURE_SSL /* Defined if libcurl supports SSPI */ #undef LIBCURL_FEATURE_SSPI /* Defined if libcurl supports DICT */ #undef LIBCURL_PROTOCOL_DICT /* Defined if libcurl supports FILE */ #undef LIBCURL_PROTOCOL_FILE /* Defined if libcurl supports FTP */ #undef LIBCURL_PROTOCOL_FTP /* Defined if libcurl supports FTPS */ #undef LIBCURL_PROTOCOL_FTPS /* Defined if libcurl supports HTTP */ #undef LIBCURL_PROTOCOL_HTTP /* Defined if libcurl supports HTTPS */ #undef LIBCURL_PROTOCOL_HTTPS /* Defined if libcurl supports LDAP */ #undef LIBCURL_PROTOCOL_LDAP /* Defined if libcurl supports TELNET */ #undef LIBCURL_PROTOCOL_TELNET /* Defined if libcurl supports TFTP */ #undef LIBCURL_PROTOCOL_TFTP /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* Build chan_misdn for mISDN 1.2 or later. */ #undef MISDN_1_2 /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* Define if your system needs braces around PTHREAD_ONCE_INIT */ #undef PTHREAD_ONCE_INIT_NEEDS_BRACES /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to the type of arg 1 for `select'. */ #undef SELECT_TYPE_ARG1 /* Define to the type of args 2, 3 and 4 for `select'. */ #undef SELECT_TYPE_ARG234 /* Define to the type of arg 5 for `select'. */ #undef SELECT_TYPE_ARG5 /* The size of `char *', as computed by sizeof. */ #undef SIZEOF_CHAR_P /* The size of `fd_set.fds_bits', as computed by sizeof. */ #undef SIZEOF_FD_SET_FDS_BITS /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Define to a type of the same size as fd_set.fds_bits[[0]] */ #undef TYPEOF_FD_SET_FDS_BITS /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Define to 1 if running on Darwin. */ #undef _DARWIN_UNLIMITED_SELECT /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 #endif /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ #undef _LARGEFILE_SOURCE /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define curl_free() as free() if our version of curl lacks curl_free. */ #undef curl_free /* Define to `int' if doesn't define. */ #undef gid_t /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to `int' if does not define. */ #undef mode_t /* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if doesn't define. */ #undef uid_t /* Define as `fork' if `vfork' does not work. */ #undef vfork /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile #endif asterisk-11.7.0/include/asterisk/ael_structs.h0000644000175000007640000000633311046713743021331 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2007, Digium, Inc. * * Mark Spencer * * 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 Structures for AEL - the Asterisk extension language * * \ref pbx_ael.c * \todo document this file (ael.h) */ #ifndef _ASTERISK_AEL_STRUCTS_H #define _ASTERISK_AEL_STRUCTS_H /* * We include asterisk/paths.h here because it is a convenient place * that doesn't require us to rebuild ael files from .fl/.y */ #include "asterisk/paths.h" #include "pval.h" #if !defined(SOLARIS) && !defined(__CYGWIN__) /* #include */ #else #define quad_t int64_t #endif #if defined(LONG_LONG_MIN) && !defined(QUAD_MIN) #define QUAD_MIN LONG_LONG_MIN #endif #if defined(LONG_LONG_MAX) && !defined(QUAD_MAX) #define QUAD_MAX LONG_LONG_MAX #endif # if ! defined(QUAD_MIN) # define QUAD_MIN (-0x7fffffffffffffffLL-1) # endif # if ! defined(QUAD_MAX) # define QUAD_MAX (0x7fffffffffffffffLL) # endif #if 0 #endif void ael2_semantic_check(pval *item, int *errs, int *warns, int *notes); pval *npval(pvaltype type, int first_line, int last_line, int first_column, int last_column); pval *linku1(pval *head, pval *tail); void ael2_print(char *fname, pval *tree); struct pval *ael2_parse(char *fname, int *errs); /* in ael.flex */ void destroy_pval(pval *item); extern char *prev_word; /* in ael.flex */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; #endif /* for passing info into and out of yyparse */ struct parse_io { struct pval *pval; /* yyparse will set this to point to the parse tree */ yyscan_t scanner; /* yylex needs a scanner. Set it up, and pass it in */ int syntax_error_count; /* the count of syntax errors encountered */ }; /* for CODE GENERATION */ typedef enum { AEL_APPCALL, AEL_CONTROL1, AEL_FOR_CONTROL, AEL_IF_CONTROL, AEL_IFTIME_CONTROL, AEL_RAND_CONTROL, AEL_LABEL, AEL_RETURN } ael_priority_type; struct ael_priority { int priority_num; ael_priority_type type; char *app; char *appargs; struct pval *origin; struct ael_extension *exten; struct ael_priority *goto_true; struct ael_priority *goto_false; struct ael_priority *next; }; struct ael_extension { char *name; char *cidmatch; char *hints; int regexten; int is_switch; int has_switch; /* set if a switch exists in the extension */ int checked_switch; /* set if we checked for a switch in the extension -- so we don't have to do it again */ struct ast_context *context; struct ael_priority *plist; struct ael_priority *plist_last; struct ael_extension *next_exten; struct ael_priority *loop_break; /*!< set by latest loop for breaks */ struct ael_priority *loop_continue; /*!< set by lastest loop for continuing */ struct ael_priority *return_target; int return_needed; }; #endif /* _ASTERISK_AEL_STRUCTS_H */ asterisk-11.7.0/include/asterisk/dnsmgr.h0000644000175000007640000001274011711627273020273 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Kevin P. Fleming * * 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 Background DNS update manager */ #ifndef _ASTERISK_DNSMGR_H #define _ASTERISK_DNSMGR_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/netsock2.h" #include "asterisk/srv.h" /*! * \brief A DNS manager entry * * This is an opaque type. */ struct ast_dnsmgr_entry; typedef void (*dns_update_func)(struct ast_sockaddr *old_addr, struct ast_sockaddr *new_addr, void *data); /*! * \brief Allocate a new DNS manager entry * * \param name the hostname * \param result where the DNS manager should store the IP address as it refreshes it. * \param service * * \details * This function allocates a new DNS manager entry object, and fills it with the * provided hostname and IP address. This function does not force an initial lookup * of the IP address. So, generally, this should be used when the initial address * is already known. * * \return a DNS manager entry * \version 1.6.1 result changed from struct in_addr to struct sockaddr_in to store port number * \version 1.8.0 result changed from struct ast_sockaddr_in to ast_sockaddr for IPv6 support */ struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service); /*! * \brief Allocate a new DNS manager entry * * \param name the hostname * \param result where the DNS manager should store the IP address as it refreshes it. * \param service * \param family Address family to filter DNS addresses. * * \details * This function allocates a new DNS manager entry object, and fills it with the * provided hostname and IP address. This function does not force an initial lookup * of the IP address. So, generally, this should be used when the initial address * is already known. * * \return a DNS manager entry */ struct ast_dnsmgr_entry *ast_dnsmgr_get_family(const char *name, struct ast_sockaddr *result, const char *service, unsigned int family); /*! * \brief Free a DNS manager entry * * \param entry the DNS manager entry to free * * \return nothing */ void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry); /*! * \brief Allocate and initialize a DNS manager entry * * \param name the hostname * \param result where to store the IP address as the DNS manager refreshes it. * The address family is used as an input parameter to filter the returned addresses. * If it is 0, both IPv4 and IPv6 addresses can be returned. * \param dnsmgr Where to store the allocate DNS manager entry * \param service * * \note * This function allocates a new DNS manager entry object, and fills it with * the provided hostname and IP address. This function _does_ force an initial * lookup, so it may block for some period of time. * * \retval 0 success * \retval non-zero failure * \version 1.6.1 result changed from struct in_addr to struct aockaddr_in to store port number */ int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service); /*! * \brief Allocate and initialize a DNS manager entry, with update callback * * \param name the hostname * \param result The addr which is intended to be updated in the update callback when DNS manager calls it on refresh. * The address family is used as an input parameter to filter the returned addresses. * If it is 0, both IPv4 and IPv6 addresses can be returned. * \param dnsmgr Where to store the allocate DNS manager entry * \param service * \param func The update callback function * The update callback will be called when DNS manager detects that an IP address has been changed. * Instead of updating the addr itself, DNS manager will call this callback function with the old * and new addresses. It is the responsibility of the callback to perform any updates * \param data A pointer to data that will be passed through to the callback function * * \note * This function allocates a new DNS manager entry object, and fills it with * the provided hostname and IP address. This function _does_ force an initial * lookup, so it may block for some period of time. * * \retval 0 success * \retval non-zero failure */ int ast_dnsmgr_lookup_cb(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service, dns_update_func func, void *data); /*! * \brief Force a refresh of a dnsmgr entry * * \retval non-zero if the result is different than the previous result * \retval zero if the result is the same as the previous result */ int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry); /*! * \brief Check is see if a dnsmgr entry has changed * * \retval non-zero if the dnsmgr entry has changed since the last call to * this function * \retval zero if the dnsmgr entry has not changed since the last call to * this function */ int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry); #if defined(__cplusplus) || defined(c_plusplus) } #endif /* c_plusplus */ #endif /* ASTERISK_DNSMGR_H */ asterisk-11.7.0/include/asterisk/pktccops.h0000644000175000007640000000346111273656477020642 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Attila Domjan * * Attila Domjan * * 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 PacketCable COPS * * \author Attila Domjan */ #ifndef _ASTERISK_PKTCCOPS_H #define _ASTERISK_PKTCCOPS_H #include "asterisk/optional_api.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif enum { GATE_SET, GATE_INFO, GATE_SET_HAVE_GATEID, GATE_DEL }; enum { GATE_ALLOC_FAILED, GATE_ALLOC_PROGRESS, GATE_ALLOCATED, GATE_CLOSED, GATE_CLOSED_ERR, GATE_OPEN, GATE_DELETED, GATE_TIMEOUT }; struct cops_gate { AST_LIST_ENTRY(cops_gate) list; uint32_t gateid; uint16_t trid; time_t in_transaction; uint32_t mta; int state; time_t allocated; time_t checked; time_t deltimer; struct cops_cmts *cmts; int (* got_dq_gi) (struct cops_gate *gate); int (* gate_remove) (struct cops_gate *gate); int (* gate_open) (struct cops_gate *gate); void *tech_pvt; }; AST_OPTIONAL_API(struct cops_gate *, ast_pktccops_gate_alloc, (int cmd, struct cops_gate *gate, uint32_t mta, uint32_t actcount, float bitrate, uint32_t psize, uint32_t ssip, uint16_t ssport, int (* const got_dq_gi) (struct cops_gate *gate), int (* const gate_remove) (struct cops_gate *gate)), { return NULL; }); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_PKTCCOPS_H */ asterisk-11.7.0/include/asterisk/bridging.h0000644000175000007640000005073012062441320020552 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007 - 2009, Digium, Inc. * * Joshua Colp * * 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 Channel Bridging API * \author Joshua Colp * \ref AstBridging */ /*! * \page AstBridging Channel Bridging API * * The purpose of this API is to provide an easy and flexible way to bridge * channels of different technologies with different features. * * Bridging technologies provide the mechanism that do the actual handling * of frames between channels. They provide capability information, codec information, * and preference value to assist the bridging core in choosing a bridging technology when * creating a bridge. Different bridges may use different bridging technologies based on needs * but once chosen they all operate under the same premise; they receive frames and send frames. * * Bridges are a combination of bridging technology, channels, and features. A * developer creates a new bridge based on what they are currently expecting to do * with it or what they will do with it in the future. The bridging core determines what * available bridging technology will best fit the requirements and creates a new bridge. * Once created, channels can be added to the bridge in a blocking or non-blocking fashion. * * Features are such things as channel muting or DTMF based features such as attended transfer, * blind transfer, and hangup. Feature information must be set at the most granular level, on * the channel. While you can use features on a global scope the presence of a feature structure * on the channel will override the global scope. An example would be having the bridge muted * at global scope and attended transfer enabled on a channel. Since the channel itself is not muted * it would be able to speak. * * Feature hooks allow a developer to tell the bridging core that when a DTMF string * is received from a channel a callback should be called in their application. For * example, a conference bridge application may want to provide an IVR to control various * settings on the conference bridge. This can be accomplished by attaching a feature hook * that calls an IVR function when a DTMF string is entered. * */ #ifndef _ASTERISK_BRIDGING_H #define _ASTERISK_BRIDGING_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/bridging_features.h" #include "asterisk/dsp.h" /*! \brief Capabilities for a bridge technology */ enum ast_bridge_capability { /*! Bridge is only capable of mixing 2 channels */ AST_BRIDGE_CAPABILITY_1TO1MIX = (1 << 1), /*! Bridge is capable of mixing 2 or more channels */ AST_BRIDGE_CAPABILITY_MULTIMIX = (1 << 2), /*! Bridge should natively bridge two channels if possible */ AST_BRIDGE_CAPABILITY_NATIVE = (1 << 3), /*! Bridge should run using the multithreaded model */ AST_BRIDGE_CAPABILITY_MULTITHREADED = (1 << 4), /*! Bridge should run a central bridge thread */ AST_BRIDGE_CAPABILITY_THREAD = (1 << 5), /*! Bridge technology can do video mixing (or something along those lines) */ AST_BRIDGE_CAPABILITY_VIDEO = (1 << 6), /*! Bridge technology can optimize things based on who is talking */ AST_BRIDGE_CAPABILITY_OPTIMIZE = (1 << 7), }; /*! \brief State information about a bridged channel */ enum ast_bridge_channel_state { /*! Waiting for a signal */ AST_BRIDGE_CHANNEL_STATE_WAIT = 0, /*! Bridged channel has ended itself (it has hung up) */ AST_BRIDGE_CHANNEL_STATE_END, /*! Bridged channel should be hung up */ AST_BRIDGE_CHANNEL_STATE_HANGUP, /*! Bridged channel should be removed from the bridge without being hung up */ AST_BRIDGE_CHANNEL_STATE_DEPART, /*! Bridged channel is executing a feature hook */ AST_BRIDGE_CHANNEL_STATE_FEATURE, /*! Bridged channel is sending a DTMF stream out */ AST_BRIDGE_CHANNEL_STATE_DTMF, /*! Bridged channel began talking */ AST_BRIDGE_CHANNEL_STATE_START_TALKING, /*! Bridged channel has stopped talking */ AST_BRIDGE_CHANNEL_STATE_STOP_TALKING, }; /*! \brief Return values for bridge technology write function */ enum ast_bridge_write_result { /*! Bridge technology wrote out frame fine */ AST_BRIDGE_WRITE_SUCCESS = 0, /*! Bridge technology attempted to write out the frame but failed */ AST_BRIDGE_WRITE_FAILED, /*! Bridge technology does not support writing out a frame of this type */ AST_BRIDGE_WRITE_UNSUPPORTED, }; struct ast_bridge_technology; struct ast_bridge; /*! * \brief Structure specific to bridge technologies capable of * performing talking optimizations. */ struct ast_bridge_tech_optimizations { /*! The amount of time in ms that talking must be detected before * the dsp determines that talking has occurred */ unsigned int talking_threshold; /*! The amount of time in ms that silence must be detected before * the dsp determines that talking has stopped */ unsigned int silence_threshold; /*! Whether or not the bridging technology should drop audio * detected as silence from the mix. */ unsigned int drop_silence:1; }; /*! * \brief Structure that contains information regarding a channel in a bridge */ struct ast_bridge_channel { /*! Lock to protect this data structure */ ast_mutex_t lock; /*! Condition, used if we want to wake up a thread waiting on the bridged channel */ ast_cond_t cond; /*! Current bridged channel state */ enum ast_bridge_channel_state state; /*! Asterisk channel participating in the bridge */ struct ast_channel *chan; /*! Asterisk channel we are swapping with (if swapping) */ struct ast_channel *swap; /*! Bridge this channel is participating in */ struct ast_bridge *bridge; /*! Private information unique to the bridge technology */ void *bridge_pvt; /*! Thread handling the bridged channel */ pthread_t thread; /*! Additional file descriptors to look at */ int fds[4]; /*! Bit to indicate whether the channel is suspended from the bridge or not */ unsigned int suspended:1; /*! Bit to indicate if a imparted channel is allowed to get hungup after leaving the bridge by the bridging core. */ unsigned int allow_impart_hangup:1; /*! Features structure for features that are specific to this channel */ struct ast_bridge_features *features; /*! Technology optimization parameters used by bridging technologies capable of * optimizing based upon talk detection. */ struct ast_bridge_tech_optimizations tech_args; /*! Queue of DTMF digits used for DTMF streaming */ char dtmf_stream_q[8]; /*! Call ID associated with bridge channel */ struct ast_callid *callid; /*! Linked list information */ AST_LIST_ENTRY(ast_bridge_channel) entry; }; enum ast_bridge_video_mode_type { /*! Video is not allowed in the bridge */ AST_BRIDGE_VIDEO_MODE_NONE = 0, /*! A single user is picked as the only distributed of video across the bridge */ AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, /*! A single user's video feed is distributed to all bridge channels, but * that feed is automatically picked based on who is talking the most. */ AST_BRIDGE_VIDEO_MODE_TALKER_SRC, }; /*! This is used for both SINGLE_SRC mode to set what channel * should be the current single video feed */ struct ast_bridge_video_single_src_data { /*! Only accept video coming from this channel */ struct ast_channel *chan_vsrc; }; /*! This is used for both SINGLE_SRC_TALKER mode to set what channel * should be the current single video feed */ struct ast_bridge_video_talker_src_data { /*! Only accept video coming from this channel */ struct ast_channel *chan_vsrc; int average_talking_energy; /*! Current talker see's this person */ struct ast_channel *chan_old_vsrc; }; struct ast_bridge_video_mode { enum ast_bridge_video_mode_type mode; /* Add data for all the video modes here. */ union { struct ast_bridge_video_single_src_data single_src_data; struct ast_bridge_video_talker_src_data talker_src_data; } mode_data; }; /*! * \brief Structure that contains information about a bridge */ struct ast_bridge { /*! Number of channels participating in the bridge */ int num; /*! The video mode this bridge is using */ struct ast_bridge_video_mode video_mode; /*! The internal sample rate this bridge is mixed at when multiple channels are being mixed. * If this value is 0, the bridge technology may auto adjust the internal mixing rate. */ unsigned int internal_sample_rate; /*! The mixing interval indicates how quickly the bridges internal mixing should occur * for bridge technologies that mix audio. When set to 0, the bridge tech must choose a * default interval for itself. */ unsigned int internal_mixing_interval; /*! Bit to indicate that the bridge thread is waiting on channels in the bridge array */ unsigned int waiting:1; /*! Bit to indicate the bridge thread should stop */ unsigned int stop:1; /*! Bit to indicate the bridge thread should refresh itself */ unsigned int refresh:1; /*! Bridge flags to tweak behavior */ struct ast_flags feature_flags; /*! Bridge technology that is handling the bridge */ struct ast_bridge_technology *technology; /*! Private information unique to the bridge technology */ void *bridge_pvt; /*! Thread running the bridge */ pthread_t thread; /*! Enabled features information */ struct ast_bridge_features features; /*! Array of channels that the bridge thread is currently handling */ struct ast_channel **array; /*! Number of channels in the above array */ size_t array_num; /*! Number of channels the array can handle */ size_t array_size; /*! Call ID associated with the bridge */ struct ast_callid *callid; /*! Linked list of channels participating in the bridge */ AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) channels; }; /*! \brief Create a new bridge * * \param capabilities The capabilities that we require to be used on the bridge * \param flags Flags that will alter the behavior of the bridge * * \retval a pointer to a new bridge on success * \retval NULL on failure * * Example usage: * * \code * struct ast_bridge *bridge; * bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE); * \endcode * * This creates a simple two party bridge that will be destroyed once one of * the channels hangs up. */ struct ast_bridge *ast_bridge_new(uint32_t capabilities, int flags); /*! * \brief Lock the bridge. * * \param bridge Bridge to lock * * \return Nothing */ #define ast_bridge_lock(bridge) _ast_bridge_lock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge) static inline void _ast_bridge_lock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var) { __ao2_lock(bridge, AO2_LOCK_REQ_MUTEX, file, function, line, var); } /*! * \brief Unlock the bridge. * * \param bridge Bridge to unlock * * \return Nothing */ #define ast_bridge_unlock(bridge) _ast_bridge_unlock(bridge, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge) static inline void _ast_bridge_unlock(struct ast_bridge *bridge, const char *file, const char *function, int line, const char *var) { __ao2_unlock(bridge, file, function, line, var); } /*! \brief See if it is possible to create a bridge * * \param capabilities The capabilities that the bridge will use * * \retval 1 if possible * \retval 0 if not possible * * Example usage: * * \code * int possible = ast_bridge_check(AST_BRIDGE_CAPABILITY_1TO1MIX); * \endcode * * This sees if it is possible to create a bridge capable of bridging two channels * together. */ int ast_bridge_check(uint32_t capabilities); /*! \brief Destroy a bridge * * \param bridge Bridge to destroy * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_destroy(bridge); * \endcode * * This destroys a bridge that was previously created using ast_bridge_new. */ int ast_bridge_destroy(struct ast_bridge *bridge); /*! \brief Join (blocking) a channel to a bridge * * \param bridge Bridge to join * \param chan Channel to join * \param swap Channel to swap out if swapping * \param features Bridge features structure * \param (Optional) Bridging tech optimization parameters for this channel. * * \retval state that channel exited the bridge with * * Example usage: * * \code * ast_bridge_join(bridge, chan, NULL, NULL); * \endcode * * This adds a channel pointed to by the chan pointer to the bridge pointed to by * the bridge pointer. This function will not return until the channel has been * removed from the bridge, swapped out for another channel, or has hung up. * * If this channel will be replacing another channel the other channel can be specified * in the swap parameter. The other channel will be thrown out of the bridge in an * atomic fashion. * * If channel specific features are enabled a pointer to the features structure * can be specified in the features parameter. */ enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, struct ast_bridge_tech_optimizations *tech_args); /*! \brief Impart (non-blocking) a channel on a bridge * * \param bridge Bridge to impart on * \param chan Channel to impart * \param swap Channel to swap out if swapping * \param features Bridge features structure * \param allow_hangup Indicates if the bridge thread should manage hanging up of the channel or not. * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_impart(bridge, chan, NULL, NULL, 0); * \endcode * * This adds a channel pointed to by the chan pointer to the bridge pointed to by * the bridge pointer. This function will return immediately and will not wait * until the channel is no longer part of the bridge. * * If this channel will be replacing another channel the other channel can be specified * in the swap parameter. The other channel will be thrown out of the bridge in an * atomic fashion. * * If channel specific features are enabled a pointer to the features structure * can be specified in the features parameter. */ int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, int allow_hangup); /*! \brief Depart a channel from a bridge * * \param bridge Bridge to depart from * \param chan Channel to depart * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_depart(bridge, chan); * \endcode * * This removes the channel pointed to by the chan pointer from the bridge * pointed to by the bridge pointer and gives control to the calling thread. * This does not hang up the channel. * * \note This API call can only be used on channels that were added to the bridge * using the ast_bridge_impart API call. */ int ast_bridge_depart(struct ast_bridge *bridge, struct ast_channel *chan); /*! \brief Remove a channel from a bridge * * \param bridge Bridge that the channel is to be removed from * \param chan Channel to remove * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_remove(bridge, chan); * \endcode * * This removes the channel pointed to by the chan pointer from the bridge * pointed to by the bridge pointer and requests that it be hung up. Control * over the channel will NOT be given to the calling thread. * * \note This API call can be used on channels that were added to the bridge * using both ast_bridge_join and ast_bridge_impart. */ int ast_bridge_remove(struct ast_bridge *bridge, struct ast_channel *chan); /*! \brief Merge two bridges together * * \param bridge0 First bridge * \param bridge1 Second bridge * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_merge(bridge0, bridge1); * \endcode * * This merges the bridge pointed to by bridge1 with the bridge pointed to by bridge0. * In reality all of the channels in bridge1 are simply moved to bridge0. * * \note The second bridge specified is not destroyed when this operation is * completed. */ int ast_bridge_merge(struct ast_bridge *bridge0, struct ast_bridge *bridge1); /*! \brief Suspend a channel temporarily from a bridge * * \param bridge Bridge to suspend the channel from * \param chan Channel to suspend * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_suspend(bridge, chan); * \endcode * * This suspends the channel pointed to by chan from the bridge pointed to by bridge temporarily. * Control of the channel is given to the calling thread. This differs from ast_bridge_depart as * the channel will not be removed from the bridge. * * \note This API call can be used on channels that were added to the bridge * using both ast_bridge_join and ast_bridge_impart. */ int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan); /*! \brief Unsuspend a channel from a bridge * * \param bridge Bridge to unsuspend the channel from * \param chan Channel to unsuspend * * \retval 0 on success * \retval -1 on failure * * Example usage: * * \code * ast_bridge_unsuspend(bridge, chan); * \endcode * * This unsuspends the channel pointed to by chan from the bridge pointed to by bridge. * The bridge will go back to handling the channel once this function returns. * * \note You must not mess with the channel once this function returns. * Doing so may result in bad things happening. */ int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan); /*! \brief Change the state of a bridged channel * * \param bridge_channel Channel to change the state on * \param new_state The new state to place the channel into * * Example usage: * * \code * ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT); * \endcode * * This places the channel pointed to by bridge_channel into the state * AST_BRIDGE_CHANNEL_STATE_WAIT. * * \note This API call is only meant to be used in feature hook callbacks to * make sure the channel either hangs up or returns to the bridge. */ void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state); /*! \brief Adjust the internal mixing sample rate of a bridge used during * multimix mode. * * \param bridge_channel Channel to change the sample rate on. * \param sample rate, the sample rate to change to. If a * value of 0 is passed here, the bridge will be free to pick * what ever sample rate it chooses. * */ void ast_bridge_set_internal_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate); /*! \brief Adjust the internal mixing interval of a bridge used during * multimix mode. * * \param bridge_channel Channel to change the sample rate on. * \param mixing_interval, the sample rate to change to. If 0 is set * the bridge tech is free to choose any mixing interval it uses by default. */ void ast_bridge_set_mixing_interval(struct ast_bridge *bridge, unsigned int mixing_interval); /*! * \brief Set a bridge to feed a single video source to all participants. */ void ast_bridge_set_single_src_video_mode(struct ast_bridge *bridge, struct ast_channel *video_src_chan); /*! * \brief Set the bridge to pick the strongest talker supporting * video as the single source video feed */ void ast_bridge_set_talker_src_video_mode(struct ast_bridge *bridge); /*! * \brief Update information about talker energy for talker src video mode. */ void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyfame); /*! * \brief Returns the number of video sources currently active in the bridge */ int ast_bridge_number_video_src(struct ast_bridge *bridge); /*! * \brief Determine if a channel is a video src for the bridge * * \retval 0 Not a current video source of the bridge. * \retval None 0, is a video source of the bridge, The number * returned represents the priority this video stream has * on the bridge where 1 is the highest priority. */ int ast_bridge_is_video_src(struct ast_bridge *bridge, struct ast_channel *chan); /*! * \brief remove a channel as a source of video for the bridge. */ void ast_bridge_remove_video_src(struct ast_bridge *bridge, struct ast_channel *chan); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_BRIDGING_H */ asterisk-11.7.0/include/asterisk/image.h0000644000175000007640000000557211522553062020062 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 General Asterisk channel definitions for image handling */ #ifndef _ASTERISK_IMAGE_H #define _ASTERISK_IMAGE_H /*! \brief structure associated with registering an image format */ struct ast_imager { char *name; /*!< Name */ char *desc; /*!< Description */ char *exts; /*!< Extension(s) (separated by '|' ) */ struct ast_format format; /*!< Image format */ struct ast_frame *(*read_image)(int fd, int len); /*!< Read an image from a file descriptor */ int (*identify)(int fd); /*!< Identify if this is that type of file */ int (*write_image)(int fd, struct ast_frame *frame); /*!< Returns length written */ AST_LIST_ENTRY(ast_imager) list; /*!< For linked list */ }; /*! * \brief Check for image support on a channel * \param chan channel to check * Checks the channel to see if it supports the transmission of images * \return non-zero if image transmission is supported */ int ast_supports_images(struct ast_channel *chan); /*! * \brief Sends an image * \param chan channel to send image on * \param filename filename of image to send (minus extension) * Sends an image on the given channel. * \retval 0 on success * \retval -1 on error */ int ast_send_image(struct ast_channel *chan, const char *filename); /*! * \brief Make an image * \param filename filename of image to prepare * \param preflang preferred language to get the image...? * \param format the format of the file, NULL for any image format * Make an image from a filename ??? No estoy positivo * \retval an ast_frame on success * \retval NULL on failure */ struct ast_frame *ast_read_image(const char *filename, const char *preflang, struct ast_format *format); /*! * \brief Register image format * \param imgdrv Populated ast_imager structure with info to register * Registers an image format * \return 0 regardless */ int ast_image_register(struct ast_imager *imgdrv); /*! * \brief Unregister an image format * \param imgdrv pointer to the ast_imager structure you wish to unregister * Unregisters the image format passed in. * Returns nothing */ void ast_image_unregister(struct ast_imager *imgdrv); /*! * \brief Initialize image stuff * Initializes all the various image stuff. Basically just registers the cli stuff * \return 0 all the time */ int ast_image_init(void); #endif /* _ASTERISK_IMAGE_H */ asterisk-11.7.0/include/asterisk/data.h0000644000175000007640000007003211522553062017702 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Eliel C. Sardanons (LU1ALY) * * 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 Data retrieval API. * \author Brett Bryant * \author Eliel C. Sardanons (LU1ALY) * \arg \ref AstDataRetrieval */ #ifndef ASTERISK_DATA_H #define ASTERISK_DATA_H #include "asterisk/frame.h" /*! * \page AstDataRetrieval The Asterisk DATA retrieval API. * * This module implements an abstraction for retrieving asterisk data and * export it. * * \section USAGE * * \subsection Provider * * \b Register * * To register a callback use: * * \code * static const struct ast_data_handler callback_handler = { * .get = callback_handler_get_function, * }; * * ast_data_register("/node/path", &callback_handler); * \endcode * * If you instead want to register multiple nodes at once use: * \code * static const struct ast_data_handler handler_struct1 = { * .get = handler_callback_read, * }; * ... other handlers ... * * static const struct ast_data_entry list_providers[] = { * AST_DATA_ENTRY("/path1/node1", &handler_struct1), * AST_DATA_ENTRY("/path2/node2", &handler_struct2), * AST_DATA_ENTRY("/path3/node3", &handler_struct3), * }; * * ... * * ast_data_register_multiple(list_providers, ARRAY_LEN(list_providers)); * \endcode * * \b Unregister * * To unregister a callback function already registered you can just call: * * \code * ast_data_unregister(NULL); * \endcode * And every node registered by the current module (file) will be unregistered. * If you want to unregister a specific node use: * * \code * ast_data_unregister("/node/path"); * \endcode * * \b Implementation * * A simple callback function implementation: * * \code * #include * * struct test_structure { * int a; * double b; * }; * * DATA_EXPORT_TEST_STRUCTURE(MEMBER) \ * MEMBER(test_structure, a, AST_DATA_INTEGER) \ * MEMBER(test_structure, b, AST_DATA_DOUBLE) * * AST_DATA_STRUCTURE(test_structure, DATA_EXPORT_TEST_STRUCTURE) * * static int my_callback_function(struct ast_data_search *search, * struct ast_data *root_node) * { * struct ast_data *internal_node; * struct test_structure ts = { * .a = 10, * .b = 20 * }; * * internal_node = ast_data_add_node(root_node, "test_node"); * if (!internal_node) { * return -1; * } * * ast_data_add_structure(test_structure, internal_node, ts); * * if (!ast_data_search_match(search, internal_node)) { * ast_data_remove_node(root_node, internal_node); * } * * return 0; * } * * \endcode * * \subsection Get * * \b Getting \b the \b tree * * To get the tree you need to create a query, a query is based on three parameters * a \b path to the provider, a \b search condition and a \b filter condition. * \code * struct ast_data *result; * struct ast_data_query query = { * .path = "/asterisk/application/app_queue/queues", * .search = "/queues/queue/name=queue1", * .filter = "/queues/queue/name|wrapuptime|members/member/interface" * }; * * result = ast_data_get(&query); * \endcode * * After using it you need to release the allocated memory of the returned tree: * \code * ast_data_free(result); * \endcode * * \b Iterate * * To retrieve nodes from the tree, it is possible to iterate through the returned * nodes of the tree using: * \code * struct ast_data_iterator *i; * struct ast_data *internal_node; * * i = ast_data_iterator_init(result_tree, "path/node_name"); * while ((internal_node = ast_data_iterator_next(i))) { * ... do something with node ... * } * ast_data_iterator_end(i); * \endcode * node_name is the name of the nodes to retrieve and path is the path to the internal * nodes to retrieve (if needed). * * \b Retrieving * * After getting the node you where searching for, you will need to retrieve its value, * to do that you may use one of the ast_data_retrieve_##type functions: * \code * int a = ast_data_retrieve_int(tree, "path/to/the/node"); * double b = ast_data_retrieve_dbl(tree, "path/to/the/node"); * unsigned int c = ast_data_retrieve_bool(tree, "path/to/the/node"); * char *d = ast_data_retrieve_string(tree, "path/to/the/node"); * struct sockaddr_in e = ast_data_retrieve_ipaddr(tree, "path/to/the/node"); * unsigned int f = ast_data_retrieve_uint(tree, "path/to/the/node"); * void *g = ast_data_retrieve_ptr(tree, "path/to/the/node"); * \endcode * */ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief The data type of the data node. */ enum ast_data_type { AST_DATA_CONTAINER, AST_DATA_INTEGER, AST_DATA_UNSIGNED_INTEGER, AST_DATA_DOUBLE, AST_DATA_BOOLEAN, AST_DATA_STRING, AST_DATA_CHARACTER, AST_DATA_PASSWORD, AST_DATA_IPADDR, AST_DATA_TIMESTAMP, AST_DATA_SECONDS, AST_DATA_MILLISECONDS, AST_DATA_POINTER }; /*! \brief The Data API structures version. */ #define AST_DATA_HANDLER_VERSION 1 #define AST_DATA_QUERY_VERSION 1 /*! \brief opaque definition of an ast_data handler, a tree node. */ struct ast_data; /*! \brief opaque definition of an ast_data_iterator handler. */ struct ast_data_iterator; /*! \brief opaque definition of an ast_data_search structure. */ struct ast_data_search; /*! \brief structure retrieved from a node, with the nodes content. */ struct ast_data_retrieve { /*! \brief The type of the node retrieved. */ enum ast_data_type type; union { char AST_DATA_CHARACTER; char *AST_DATA_STRING; char *AST_DATA_PASSWORD; int AST_DATA_INTEGER; unsigned int AST_DATA_TIMESTAMP; unsigned int AST_DATA_SECONDS; unsigned int AST_DATA_MILLISECONDS; double AST_DATA_DOUBLE; unsigned int AST_DATA_UNSIGNED_INTEGER; unsigned int AST_DATA_BOOLEAN; void *AST_DATA_POINTER; struct in_addr AST_DATA_IPADDR; void *AST_DATA_CONTAINER; } value; }; /*! * \brief The get callback definition. */ typedef int (*ast_data_get_cb)(const struct ast_data_search *search, struct ast_data *root); /*! \brief The structure of the node handler. */ struct ast_data_handler { /*! \brief Structure version. */ uint32_t version; /*! \brief Data get callback implementation. */ ast_data_get_cb get; }; /*! \brief This entries are for multiple registers. */ struct ast_data_entry { /*! \brief Path of the node to register. */ const char *path; /*! \brief Data handler structure. */ const struct ast_data_handler *handler; }; #define AST_DATA_ENTRY(__path, __handler) { .path = __path, .handler = __handler } /*! \brief A query to the data API is specified in this structure. */ struct ast_data_query { /*! \brief Data query version. */ uint32_t version; /*! \brief Path to the node to retrieve. */ char *path; /*! \brief Filter string, return the internal nodes specified here. * Setting it to NULL will return every internal node. */ char *filter; /*! \brief Search condition. */ char *search; }; /*! \brief Map the members of a structure. */ struct ast_data_mapping_structure { /*! \brief structure member name. */ const char *name; /*! \brief structure member type. */ enum ast_data_type type; /*! \brief member getter. */ union { char (*AST_DATA_CHARACTER)(void *ptr); char *(*AST_DATA_STRING)(void *ptr); char *(*AST_DATA_PASSWORD)(void *ptr); int (*AST_DATA_INTEGER)(void *ptr); int (*AST_DATA_TIMESTAMP)(void *ptr); int (*AST_DATA_SECONDS)(void *ptr); int (*AST_DATA_MILLISECONDS)(void *ptr); double (*AST_DATA_DOUBLE)(void *ptr); unsigned int (*AST_DATA_UNSIGNED_INTEGER)(void *ptr); unsigned int (*AST_DATA_BOOLEAN)(void *ptr); void *(*AST_DATA_POINTER)(void *ptr); struct in_addr (*AST_DATA_IPADDR)(void *ptr); void *(*AST_DATA_CONTAINER)(void *ptr); } get; }; /* Generate the structure and the functions to access the members of a structure. */ #define AST_DATA_STRUCTURE(__struct, __name) \ __name(__AST_DATA_MAPPING_FUNCTION); \ static const struct ast_data_mapping_structure __data_mapping_structure_##__struct[] = { \ __name(__AST_DATA_MAPPING_STRUCTURE) \ } /* Generate the structure to access the members and setup the pointer of the getter. */ #define __AST_DATA_MAPPING_STRUCTURE(__structure, __member, __type) \ { .name = #__member, .get.__type = data_mapping_structure_get_##__structure##__member, \ .type = __type }, /* based on the data type, specifify the type of return value for the getter function. */ #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_PASSWORD(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_PASSWORD, char *) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_STRING(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_STRING, char *) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_CHARACTER(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_CHARACTER, char) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_INTEGER(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_TIMESTAMP(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_SECONDS(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_MILLISECONDS(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_UNSIGNED_INTEGER(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_UNSIGNED_INTEGER, unsigned int) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_BOOLEAN(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_BOOLEAN, unsigned int) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_POINTER(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_POINTER, void *) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_IPADDR(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_IPADDR, struct in_addr) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_DOUBLE(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_DBL, double) #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_CONTAINER(__structure, __member) \ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_CONTAINER, void *) #define __AST_DATA_MAPPING_FUNCTION(__structure, __member, __type) \ __AST_DATA_MAPPING_FUNCTION_##__type(__structure, __member) /* Create the function to retrieve a member of the structure. */ #define __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, __type, __real_type) \ static __real_type data_mapping_structure_get_##__structure##__member(void *ptr) { \ struct __structure *struct_##__member = (struct __structure *) ptr; \ return (__real_type) struct_##__member->__member; \ } /*! * \brief Register a data provider. * \param[in] path The path of the node to register. * \param[in] handler The structure defining this node handler. * \param[in] registrar Who is registering this node. * \param[in] mod The module registering this handler. * \see ast_data_unregister * \retval <0 on error. * \retval 0 on success. * \see __ast_data_unregister, __ast_data_register_multiple */ int __ast_data_register(const char *path, const struct ast_data_handler *handler, const char *registrar, struct ast_module *mod); #define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, ast_module_info->self) #define ast_data_register_core(path, handler) __ast_data_register(path, handler, __FILE__, NULL) /*! * \brief Register multiple data providers at once. * \param[in] data_entries An array of data_entries structures. * \param[in] entries The number of entries in the data_entries array. * \param[in] registrar Who is registering this nodes. * \param[in] mod The module registering this handlers. * \retval <0 on error (none of the nodes are being registered on error). * \retval 0 on success. * \see __ast_data_register, __ast_data_unregister */ int __ast_data_register_multiple(const struct ast_data_entry *data_entries, size_t entries, const char *registrar, struct ast_module *mod); #define ast_data_register_multiple(data_entries, entries) \ __ast_data_register_multiple(data_entries, entries, __FILE__, ast_module_info->self) #define ast_data_register_multiple_core(data_entries, entries) \ __ast_data_register_multiple(data_entries, entries, __FILE__, NULL) /*! * \brief Unregister a data provider. * \param[in] path Which node to unregister, if path is NULL unregister every node * registered by the passed 'registrar'. * \param[in] registrar Who is trying to unregister this node, only the owner (the * one who registered the node) will be able to unregister it. * \see ast_data_register * \retval <0 on error. * \retval 0 on success. * \see __ast_data_register, __ast_data_register_multiple */ int __ast_data_unregister(const char *path, const char *registrar); #define ast_data_unregister(path) __ast_data_unregister(path, __FILE__) /*! * \brief Check the current generated node to know if it matches the search * condition. * \param[in] search The search condition. * \param[in] data The AstData node generated. * \return 1 If the "data" node matches the search condition. * \return 0 If the "data" node does not matches the search condition. * \see ast_data_remove_node */ int ast_data_search_match(const struct ast_data_search *search, struct ast_data *data); /*! * \brief Based on a search tree, evaluate every member of a structure against it. * \param[in] search The search tree. * \param[in] mapping The structure mapping. * \param[in] mapping_len The lenght of the structure mapping. * \param[in] structure The structure pointer. * \param[in] structure_name The name of the structure to compare. * \retval 0 If the structure matches. * \retval 1 If the structure doesn't match. */ int __ast_data_search_cmp_structure(const struct ast_data_search *search, const struct ast_data_mapping_structure *mapping, size_t mapping_len, void *structure, const char *structure_name); #define ast_data_search_cmp_structure(search, structure_name, structure, structure_name_cmp) \ __ast_data_search_cmp_structure(search, __data_mapping_structure_##structure_name, \ ARRAY_LEN(__data_mapping_structure_##structure_name), structure, structure_name_cmp) /*! * \brief Retrieve a subtree from the asterisk data API. * \param[in] query The query structure specifying what nodes to retrieve. * \retval NULL on error. * \retval non-NULL The dynamically allocated requested sub-tree (it needs to be * released using ast_data_free. * \see ast_data_free, ast_data_get_xml */ struct ast_data *ast_data_get(const struct ast_data_query *query); #ifdef HAVE_LIBXML2 /*! * \brief Retrieve a subtree from the asterisk data API in XML format.. * \param[in] query The query structure specifying what nodes to retrieve. * \retval NULL on error. * \retval non-NULL The dynamically allocated requested sub-tree (it needs to be * released using ast_data_free. * \see ast_data_free, ast_data_get */ struct ast_xml_doc *ast_data_get_xml(const struct ast_data_query *query); #endif /*! * \brief Release the allocated memory of a tree. * \param[in] root The sub-tree pointer returned by a call to ast_data_get. * \see ast_data_get */ void ast_data_free(struct ast_data *root); /*! * \brief Get a node type. * \param[in] res A pointer to the ast_data result set. * \param[in] path A path to the node to get the type. * \return The type of the requested node type. */ enum ast_data_type ast_data_retrieve_type(struct ast_data *res, const char *path); /*! * \brief Get the node name. * \param[in] node The node pointer. * \returns The node name. */ char *ast_data_retrieve_name(struct ast_data *node); /*! * \brief Add a container child. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_node(struct ast_data *root, const char *childname); /*! * \brief Add an integer node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] value The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_int(struct ast_data *root, const char *childname, int value); /*! * \brief Add a char node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] value The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_char(struct ast_data *root, const char *childname, char value); /*! * \brief Add an unsigned integer node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] value The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_uint(struct ast_data *root, const char *childname, unsigned int value); /*! * \brief Add a floating point node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] dbl The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_dbl(struct ast_data *root, const char *childname, double dbl); /*! * \brief Add a ipv4 address type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] addr The ipv4 address value. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_ipaddr(struct ast_data *root, const char *childname, struct in_addr addr); /*! * \brief Add a ptr node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] ptr The pointer value to add. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_ptr(struct ast_data *root, const char *childname, void *ptr); /*! * \brief Add a password node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] string The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_password(struct ast_data *root, const char *childname, const char *string); /*! * \brief Add a timestamp node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] timestamp The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_timestamp(struct ast_data *root, const char *childname, unsigned int timestamp); /*! * \brief Add a seconds node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] seconds The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_seconds(struct ast_data *root, const char *childname, unsigned int seconds); /*! * \brief Add a milliseconds node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] milliseconds The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_milliseconds(struct ast_data *root, const char *childname, unsigned int milliseconds); /*! * \brief Add a string node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] string The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_str(struct ast_data *root, const char *childname, const char *string); /*! * \brief Add a boolean node type. * \param[in] root The root of the ast_data to insert into. * \param[in] childname The name of the child element to be added. * \param[in] boolean The value for the new node. * \retval NULL on error (memory exhaustion only). * \retval non-NULL a newly allocated node. */ struct ast_data *ast_data_add_bool(struct ast_data *root, const char *childname, unsigned int boolean); /*! * \brief Add a complete structure to a node. * \param[in] root Where to add the structure. * \param[in] mapping The structure mapping array. * \param[in] mapping_len The lenght of the mapping array. * \param[in] structure The structure pointer. * \retval 0 on success. * \retval 1 on error. */ int __ast_data_add_structure(struct ast_data *root, const struct ast_data_mapping_structure *mapping, size_t mapping_len, void *structure); #define ast_data_add_structure(structure_name, root, structure) \ __ast_data_add_structure(root, __data_mapping_structure_##structure_name, \ ARRAY_LEN(__data_mapping_structure_##structure_name), structure) /*! * \brief Remove a node that was added using ast_data_add_ * \param[in] root The root node of the node to be removed. * \param[in] child The node pointer to remove. */ void ast_data_remove_node(struct ast_data *root, struct ast_data *child); /*! * \brief Initialize an iterator. * \param[in] tree The returned tree by a call to ast_data_get. * \param[in] elements Which elements to iterate through. * \retval NULL on error. * \retval non-NULL A dinamically allocated iterator structure. */ struct ast_data_iterator *ast_data_iterator_init(struct ast_data *tree, const char *elements); /*! * \brief Release (stop using) an iterator. * \param[in] iterator The iterator created by ast_data_iterator_start. * \see ast_data_iterator_start */ void ast_data_iterator_end(struct ast_data_iterator *iterator); /*! * \brief Get the next node of the tree. * \param[in] iterator The iterator structure returned by ast_data_iterator_start. * \retval NULL when no more nodes to return. * \retval non-NULL A node of the ast_data tree. * \see ast_data_iterator_start, ast_data_iterator_stop */ struct ast_data *ast_data_iterator_next(struct ast_data_iterator *iterator); /*! * \brief Retrieve a value from a node in the tree. * \param[in] tree The structure returned by a call to ast_data_get. * \param[in] path The path to the node. * \param[out] content The node content. * \retval 0 on success. * \retval <0 on error. */ int ast_data_retrieve(struct ast_data *tree, const char *path, struct ast_data_retrieve *content); /*! * \brief Retrieve the integer value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline int ast_data_retrieve_int(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_INTEGER; } /*! * \brief Retrieve the character value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline char ast_data_retrieve_char(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_CHARACTER; } /*! * \brief Retrieve the boolean value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline unsigned int ast_data_retrieve_bool(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_BOOLEAN; } /*! * \brief Retrieve the unsigned integer value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline unsigned int ast_data_retrieve_uint(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_UNSIGNED_INTEGER; } /*! * \brief Retrieve the password value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline const char *ast_data_retrieve_password(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_PASSWORD; } /*! * \brief Retrieve the string value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline const char *ast_data_retrieve_string(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_STRING; } /*! * \brief Retrieve the ptr value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline void *ast_data_retrieve_ptr(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_POINTER; } /*! * \brief Retrieve the double value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline double ast_data_retrieve_dbl(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_DOUBLE; } /*! * \brief Retrieve the ipv4 address value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ static inline struct in_addr ast_data_retrieve_ipaddr(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; ast_data_retrieve(tree, path, &ret); return ret.value.AST_DATA_IPADDR; } /*! * \brief Add the codec in the root node based on the format parameter. * \param[in] root The astdata root node where to add the codec node. * \param[in] node_name The name of the node where we are going to add the codec. * \param[in] format The codec allowed. * \return < 0 on error. * \return 0 on success. */ int ast_data_add_codec(struct ast_data *root, const char *node_name, struct ast_format *format); /*! * \brief Add the list of codecs in the root node based on the capability parameter. * \param[in] root The astdata root node where to add the codecs node. * \param[in] node_name The name of the node where we are going to add the list of * codecs. * \param[in] capability The codecs allowed. * \return < 0 on error. * \return 0 on success. */ int ast_data_add_codecs(struct ast_data *root, const char *node_name, struct ast_format_cap *capability); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* ASTERISK_DATA_H */ asterisk-11.7.0/include/asterisk/select.h0000644000175000007640000000644312133015136020247 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * Tilghman Lesher * * 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 Bitfield expansions for ast_select */ #ifndef __AST_SELECT_H #define __AST_SELECT_H #include #include #include #include "asterisk/compat.h" #ifdef __cplusplus extern "C" { #endif extern unsigned int ast_FD_SETSIZE; #if !defined(HAVE_VARIABLE_FDSET) && defined(CONFIGURE_RAN_AS_ROOT) #define ast_fdset fd_set #else #define ast_FDMAX 32768 typedef struct { TYPEOF_FD_SET_FDS_BITS fds_bits[ast_FDMAX / 8 / SIZEOF_FD_SET_FDS_BITS]; /* 32768 bits */ } ast_fdset; #define _bitsize(a) (sizeof(a) * 8) #undef FD_ZERO #define FD_ZERO(a) \ do { \ TYPEOF_FD_SET_FDS_BITS *bytes = (TYPEOF_FD_SET_FDS_BITS *) a; \ int i; \ for (i = 0; i < ast_FDMAX / _bitsize(TYPEOF_FD_SET_FDS_BITS); i++) { \ bytes[i] = 0; \ } \ } while (0) #undef FD_SET #define FD_SET(fd, fds) \ do { \ TYPEOF_FD_SET_FDS_BITS *bytes = (TYPEOF_FD_SET_FDS_BITS *) fds; \ /* 32bit: FD / 32 + ((FD + 1) % 32 ? 1 : 0) < 1024 */ \ /* 64bit: FD / 64 + ((FD + 1) % 64 ? 1 : 0) < 512 */ \ if (fd / _bitsize(*bytes) + ((fd + 1) % _bitsize(*bytes) ? 1 : 0) < sizeof(*(fds)) / SIZEOF_FD_SET_FDS_BITS) { \ bytes[fd / _bitsize(*bytes)] |= ((TYPEOF_FD_SET_FDS_BITS) 1) << (fd % _bitsize(*bytes)); \ } else { \ fprintf(stderr, "FD %d exceeds the maximum size of ast_fdset!\n", fd); \ } \ } while (0) #endif /* HAVE_VARIABLE_FDSET */ /*! \brief Waits for activity on a group of channels * \param nfds the maximum number of file descriptors in the sets * \param rfds file descriptors to check for read availability * \param wfds file descriptors to check for write availability * \param efds file descriptors to check for exceptions (OOB data) * \param tvp timeout while waiting for events * This is the same as a standard select(), except it guarantees the * behaviour where the passed struct timeval is updated with how much * time was not slept while waiting for the specified events */ static inline int ast_select(int nfds, ast_fdset *rfds, ast_fdset *wfds, ast_fdset *efds, struct timeval *tvp) { #ifdef __linux__ return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp); #else int save_errno = 0; if (tvp) { struct timeval tv, tvstart, tvend, tvlen; int res; tv = *tvp; gettimeofday(&tvstart, NULL); res = select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, tvp); save_errno = errno; gettimeofday(&tvend, NULL); timersub(&tvend, &tvstart, &tvlen); timersub(&tv, &tvlen, tvp); if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) { tvp->tv_sec = 0; tvp->tv_usec = 0; } errno = save_errno; return res; } else return select(nfds, (fd_set *) rfds, (fd_set *) wfds, (fd_set *) efds, NULL); #endif } #ifdef __cplusplus } #endif #endif /* __AST_SELECT_H */ asterisk-11.7.0/include/asterisk/security_events.h0000644000175000007640000000600111313741645022223 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Digium, Inc. * * Russell Bryant * * 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 Security Event Reporting API * * \author Russell Bryant */ #ifndef __AST_SECURITY_EVENTS_H__ #define __AST_SECURITY_EVENTS_H__ #include "asterisk/event.h" /* Data structure definitions */ #include "asterisk/security_events_defs.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! * \brief Report a security event * * \param[in] sec security event data. Callers of this function should never * declare an instance of ast_security_event_common directly. The * argument should be an instance of a specific security event * descriptor which has ast_security_event_common at the very * beginning. * * \retval 0 success * \retval non-zero failure */ int ast_security_event_report(const struct ast_security_event_common *sec); struct ast_security_event_ie_type { enum ast_event_ie_type ie_type; /*! \brief For internal usage */ size_t offset; }; /*! * \brief Get the list of required IEs for a given security event sub-type * * \param[in] event_type security event sub-type * * \retval NULL invalid event_type * \retval non-NULL An array terminated with the value AST_EVENT_IE_END * * \since 1.8 */ const struct ast_security_event_ie_type *ast_security_event_get_required_ies( const enum ast_security_event_type event_type); /*! * \brief Get the list of optional IEs for a given security event sub-type * * \param[in] event_type security event sub-type * * \retval NULL invalid event_type * \retval non-NULL An array terminated with the value AST_EVENT_IE_END * * \since 1.8 */ const struct ast_security_event_ie_type *ast_security_event_get_optional_ies( const enum ast_security_event_type event_type); /*! * \brief Get the name of a security event sub-type * * \param[in] event_type security event sub-type * * \retval NULL if event_type is invalid * \retval non-NULL the name of the security event type * * \since 1.8 */ const char *ast_security_event_get_name(const enum ast_security_event_type event_type); /*! * \brief Get the name of a security event severity * * \param[in] severity security event severity * * \retval NULL if severity is invalid * \retval non-NULL the name of the security event severity * * \since 1.8 */ const char *ast_security_event_severity_get_name( const enum ast_security_event_severity severity); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* __AST_SECURITY_EVENTS_H__ */ asterisk-11.7.0/include/asterisk/frame_defs.h0000644000175000007640000000000011522553062021050 0ustar sharkyjerrywebasterisk-11.7.0/include/asterisk/transcap.h0000644000175000007640000000256610727606446020626 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Matthew Fredrickson * * 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 General Asterisk channel transcoding definitions. */ #ifndef _ASTERISK_TRANSCAP_H #define _ASTERISK_TRANSCAP_H /* These definitions are taken directly out of libpri.h and used here. * DO NOT change them as it will cause unexpected behavior in channels * that utilize these fields. */ /*! \name AstTranscode General Asterisk channel transcoding definitions. */ /*@{ */ #define AST_TRANS_CAP_SPEECH 0x0 #define AST_TRANS_CAP_DIGITAL 0x08 #define AST_TRANS_CAP_RESTRICTED_DIGITAL 0x09 #define AST_TRANS_CAP_3_1K_AUDIO 0x10 #define AST_TRANS_CAP_7K_AUDIO 0x11 /* Depriciated ITU Q.931 (05/1998)*/ #define AST_TRANS_CAP_DIGITAL_W_TONES 0x11 #define AST_TRANS_CAP_VIDEO 0x18 /*@} */ #define IS_DIGITAL(cap)\ (cap) & AST_TRANS_CAP_DIGITAL ? 1 : 0 #endif /* _ASTERISK_TRANSCAP_H */ asterisk-11.7.0/include/asterisk/chanvars.h0000644000175000007640000000257511075217516020611 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Channel Variables */ #ifndef _ASTERISK_CHANVARS_H #define _ASTERISK_CHANVARS_H #include "asterisk/linkedlists.h" struct ast_var_t { AST_LIST_ENTRY(ast_var_t) entries; char *value; char name[0]; }; AST_LIST_HEAD_NOLOCK(varshead, ast_var_t); #ifdef MALLOC_DEBUG struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function); #define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else struct ast_var_t *ast_var_assign(const char *name, const char *value); #endif void ast_var_delete(struct ast_var_t *var); const char *ast_var_name(const struct ast_var_t *var); const char *ast_var_full_name(const struct ast_var_t *var); const char *ast_var_value(const struct ast_var_t *var); #endif /* _ASTERISK_CHANVARS_H */ asterisk-11.7.0/include/asterisk/callerid.h0000644000175000007640000004261611763214744020567 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 CallerID (and other GR30) management and generation * Includes code and algorithms from the Zapata library. * * \ref CID * */ /*! * \page CID Caller ID names and numbers * * Caller ID names are currently 8 bit characters, propably * ISO8859-1, depending on what your channel drivers handle. * * IAX2 and SIP caller ID names are UTF8 * On ISDN Caller ID names are 7 bit, Almost ASCII * (See http://www.zytrax.com/tech/ia5.html ) * * \note Asterisk does not currently support SIP utf8 caller ID names or caller ID's. * * \par See also * \arg \ref callerid.c * \arg \ref callerid.h * \arg \ref Def_CallerPres */ #ifndef _ASTERISK_CALLERID_H #define _ASTERISK_CALLERID_H #include "asterisk/format.h" #define MAX_CALLERID_SIZE 32000 #define CID_PRIVATE_NAME (1 << 0) #define CID_PRIVATE_NUMBER (1 << 1) #define CID_UNKNOWN_NAME (1 << 2) #define CID_UNKNOWN_NUMBER (1 << 3) #define CID_MSGWAITING (1 << 4) #define CID_NOMSGWAITING (1 << 5) #define CID_SIG_BELL 1 #define CID_SIG_V23 2 #define CID_SIG_DTMF 3 #define CID_SIG_V23_JP 4 #define CID_SIG_SMDI 5 #define CID_START_RING 1 #define CID_START_POLARITY 2 #define CID_START_POLARITY_IN 3 #define CID_START_DTMF_NOALERT 4 /* defines dealing with message waiting indication generation */ /*! MWI SDMF format */ #define CID_MWI_TYPE_SDMF 0x00 /*! MWI MDMF format -- generate only MWI field */ #define CID_MWI_TYPE_MDMF 0x01 /*! MWI MDMF format -- generate name, callerid, date and MWI fields */ #define CID_MWI_TYPE_MDMF_FULL 0x02 #define AST_LIN2X(a) ((codec->id == AST_FORMAT_ALAW) ? (AST_LIN2A(a)) : (AST_LIN2MU(a))) #define AST_XLAW(a) ((codec->id == AST_FORMAT_ALAW) ? (AST_ALAW(a)) : (AST_MULAW(a))) struct callerid_state; typedef struct callerid_state CIDSTATE; /*! \brief CallerID Initialization * \par * Initializes the callerid system. Mostly stuff for inverse FFT */ void callerid_init(void); /*! \brief Generates a CallerID FSK stream in ulaw format suitable for transmission. * \param buf Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own. * "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun. * \param number Use NULL for no number or "P" for "private" * \param name name to be used * \param flags passed flags * \param callwaiting callwaiting flag * \param codec -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW * \details * This function creates a stream of callerid (a callerid spill) data in ulaw format. * \return It returns the size * (in bytes) of the data (if it returns a size of 0, there is probably an error) */ int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec); /*! \brief Create a callerID state machine * \param cid_signalling Type of signalling in use * * \details * This function returns a malloc'd instance of the callerid_state data structure. * \return Returns a pointer to a malloc'd callerid_state structure, or NULL on error. */ struct callerid_state *callerid_new(int cid_signalling); /*! \brief Read samples into the state machine. * \param cid Which state machine to act upon * \param ubuf containing your samples * \param samples number of samples contained within the buffer. * \param codec which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW) * * \details * Send received audio to the Caller*ID demodulator. * \retval -1 on error * \retval 0 for "needs more samples" * \retval 1 if the CallerID spill reception is complete. */ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec); /*! \brief Read samples into the state machine. * \param cid Which state machine to act upon * \param ubuf containing your samples * \param samples number of samples contained within the buffer. * \param codec which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW) * * \details * Send received audio to the Caller*ID demodulator (for japanese style lines). * \retval -1 on error * \retval 0 for "needs more samples" * \retval 1 if the CallerID spill reception is complete. */ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec); /*! \brief Extract info out of callerID state machine. Flags are listed above * \param cid Callerid state machine to act upon * \param number Pass the address of a pointer-to-char (will contain the phone number) * \param name Pass the address of a pointer-to-char (will contain the name) * \param flags Pass the address of an int variable(will contain the various callerid flags) * * \details * This function extracts a callerid string out of a callerid_state state machine. * If no number is found, *number will be set to NULL. Likewise for the name. * Flags can contain any of the following: * * \return Returns nothing. */ void callerid_get(struct callerid_state *cid, char **number, char **name, int *flags); /*! * \brief Get and parse DTMF-based callerid * \param cidstring The actual transmitted string. * \param number The cid number is returned here. * \param flags The cid flags are returned here. */ void callerid_get_dtmf(char *cidstring, char *number, int *flags); /*! \brief This function frees callerid_state cid. * \param cid This is the callerid_state state machine to free */ void callerid_free(struct callerid_state *cid); /*! \brief Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format) * \param buf buffer for output samples. See callerid_generate() for details regarding buffer. * \param name Caller-ID Name * \param number Caller-ID Number * \param codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW) * * \details * Acts like callerid_generate except uses an asterisk format callerid string. */ int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec); /*! * \brief Generate message waiting indicator * \param buf * \param active The message indicator state * -- either 0 no messages in mailbox or 1 messages in mailbox * \param type Format of message (any of CID_MWI_TYPE_*) * \param codec * \param name * \param number * \param flags * \see callerid_generate() for more info as it uses the same encoding * \version 1.6.1 changed mdmf parameter to type, added name, number and flags for caller id message generation */ int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct ast_format *codec, const char *name, const char *number, int flags); /*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm) * \see ast_callerid_generate() for other details */ int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec); /*! \brief Destructively parse inbuf into name and location (or number) * \details * Parses callerid stream from inbuf and changes into useable form, outputed in name and location. * \param instr buffer of callerid stream (in audio form) to be parsed. Warning, data in buffer is changed. * \param name address of a pointer-to-char for the name value of the stream. * \param location address of a pointer-to-char for the phone number value of the stream. * \note XXX 'name' is not parsed consistently e.g. we have * input location name * " foo bar " <123> 123 ' foo bar ' (with spaces around) * " foo bar " NULL 'foo bar' (without spaces around) * The parsing of leading and trailing space/quotes should be more consistent. * \return Returns 0 on success, -1 on failure. */ int ast_callerid_parse(char *instr, char **name, char **location); /*! * \brief Generate a CAS (CPE Alert Signal) tone for 'n' samples * \param outbuf Allocated buffer for data. Must be at least 2400 bytes unless no SAS is desired * \param sas Non-zero if CAS should be preceeded by SAS * \param len How many samples to generate. * \param codec Which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW) * \return Returns -1 on error (if len is less than 2400), 0 on success. */ int ast_gen_cas(unsigned char *outbuf, int sas, int len, struct ast_format *codec); /*! * \brief Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s... * \param n The number to be stripped/shrunk * \return Returns nothing important */ void ast_shrink_phone_number(char *n); /*! * \brief Check if a string consists only of digits and + \# * \param n number to be checked. * \return Returns 0 if n is a number, 1 if it's not. */ int ast_isphonenumber(const char *n); /*! * \brief Check if a string consists only of digits and and + \# ( ) - . * (meaning it can be cleaned with ast_shrink_phone_number) * \param exten The extension (or URI) to be checked. * \retval 1 if string is valid AST shrinkable phone number * \retval 0 if not */ int ast_is_shrinkable_phonenumber(const char *exten); int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen); char *ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown); /* * Caller*ID and other GR-30 compatible generation * routines (used by ADSI for example) */ extern float cid_dr[4]; extern float cid_di[4]; extern float clidsb; static inline float callerid_getcarrier(float *cr, float *ci, int bit) { /* Move along. There's nothing to see here... */ float t; t = *cr * cid_dr[bit] - *ci * cid_di[bit]; *ci = *cr * cid_di[bit] + *ci * cid_dr[bit]; *cr = t; t = 2.0 - (*cr * *cr + *ci * *ci); *cr *= t; *ci *= t; return *cr; } #define PUT_BYTE(a) do { \ *(buf++) = (a); \ bytes++; \ } while(0) #define PUT_AUDIO_SAMPLE(y) do { \ int __sample_idx = (short)(rint(8192.0 * (y))); \ *(buf++) = AST_LIN2X(__sample_idx); \ bytes++; \ } while(0) #define PUT_CLID_MARKMS do { \ int __clid_x; \ for (__clid_x=0;__clid_x<8;__clid_x++) \ PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, 1)); \ } while(0) #define PUT_CLID_BAUD(bit) do { \ while(scont < clidsb) { \ PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, bit)); \ scont += 1.0; \ } \ scont -= clidsb; \ } while(0) #define PUT_CLID(byte) do { \ int z; \ unsigned char b = (byte); \ PUT_CLID_BAUD(0); /* Start bit */ \ for (z=0;z<8;z++) { \ PUT_CLID_BAUD(b & 1); \ b >>= 1; \ } \ PUT_CLID_BAUD(1); /* Stop bit */ \ } while(0) /* Various defines and bits for handling PRI- and SS7-type restriction */ #define AST_PRES_NUMBER_TYPE 0x03 #define AST_PRES_USER_NUMBER_UNSCREENED 0x00 #define AST_PRES_USER_NUMBER_PASSED_SCREEN 0x01 #define AST_PRES_USER_NUMBER_FAILED_SCREEN 0x02 #define AST_PRES_NETWORK_NUMBER 0x03 #define AST_PRES_RESTRICTION 0x60 #define AST_PRES_ALLOWED 0x00 #define AST_PRES_RESTRICTED 0x20 #define AST_PRES_UNAVAILABLE 0x40 #define AST_PRES_RESERVED 0x60 #define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED \ (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_UNSCREENED) #define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN \ (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_PASSED_SCREEN) #define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN \ (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_FAILED_SCREEN) #define AST_PRES_ALLOWED_NETWORK_NUMBER \ (AST_PRES_ALLOWED | AST_PRES_NETWORK_NUMBER) #define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED \ (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED) #define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN \ (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_PASSED_SCREEN) #define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN \ (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_FAILED_SCREEN) #define AST_PRES_PROHIB_NETWORK_NUMBER \ (AST_PRES_RESTRICTED | AST_PRES_NETWORK_NUMBER) #define AST_PRES_NUMBER_NOT_AVAILABLE \ (AST_PRES_UNAVAILABLE | AST_PRES_NETWORK_NUMBER) int ast_parse_caller_presentation(const char *data); const char *ast_describe_caller_presentation(int data); const char *ast_named_caller_presentation(int data); /*! * \page Def_CallerPres Caller ID Presentation * * Caller ID presentation values are used to set properties to a * caller ID in PSTN networks, and as RPID value in SIP transactions. * * The following values are available to use: * \arg \b Defined value, text string in config file, explanation * * \arg \b AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened", Presentation Allowed, Not Screened, * \arg \b AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen", Presentation Allowed, Passed Screen, * \arg \b AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen", Presentation Allowed, Failed Screen, * \arg \b AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed", Presentation Allowed, Network Number, * \arg \b AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, "prohib_not_screened", Presentation Prohibited, Not Screened, * \arg \b AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen", Presentation Prohibited, Passed Screen, * \arg \b AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen", Presentation Prohibited, Failed Screen, * \arg \b AST_PRES_PROHIB_NETWORK_NUMBER, "prohib", Presentation Prohibited, Network Number, * * \par References * \arg \ref callerid.h Definitions * \arg \ref callerid.c Functions * \arg \ref CID Caller ID names and numbers */ /*! * \brief redirecting reason codes. * * This list attempts to encompass redirecting reasons * as defined by several channel technologies. */ enum AST_REDIRECTING_REASON { AST_REDIRECTING_REASON_UNKNOWN, AST_REDIRECTING_REASON_USER_BUSY, AST_REDIRECTING_REASON_NO_ANSWER, AST_REDIRECTING_REASON_UNAVAILABLE, AST_REDIRECTING_REASON_UNCONDITIONAL, AST_REDIRECTING_REASON_TIME_OF_DAY, AST_REDIRECTING_REASON_DO_NOT_DISTURB, AST_REDIRECTING_REASON_DEFLECTION, AST_REDIRECTING_REASON_FOLLOW_ME, AST_REDIRECTING_REASON_OUT_OF_ORDER, AST_REDIRECTING_REASON_AWAY, AST_REDIRECTING_REASON_CALL_FWD_DTE, /* This is something defined in Q.931, and no I don't know what it means */ AST_REDIRECTING_REASON_SEND_TO_VM, }; /*! * \since 1.8 * \brief Convert redirecting reason text code to value (used in config file parsing) * * \param data text string from config file * * \retval Q931_REDIRECTING_REASON from callerid.h * \retval -1 if not in table */ int ast_redirecting_reason_parse(const char *data); /*! * \since 1.8 * \brief Convert redirecting reason value to explanatory string * * \param data Q931_REDIRECTING_REASON from callerid.h * * \return string for human presentation */ const char *ast_redirecting_reason_describe(int data); /*! * \since 1.8 * \brief Convert redirecting reason value to text code * * \param data Q931_REDIRECTING_REASON from callerid.h * * \return string for config file */ const char *ast_redirecting_reason_name(int data); /*! * \brief Connected line update source code */ enum AST_CONNECTED_LINE_UPDATE_SOURCE { /*! Update for unknown reason (May be interpreted to mean from answer) */ AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, /*! Update from normal call answering */ AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, /*! Update from call diversion (Deprecated, use REDIRECTING updates instead.) */ AST_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION, /*! Update from call transfer(active) (Party has already answered) */ AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER, /*! Update from call transfer(alerting) (Party has not answered yet) */ AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING }; /*! * \since 1.8 * \brief Convert connected line update source text code to value (used in config file parsing) * * \param data text string from config file * * \retval AST_CONNECTED_LINE_UPDATE_SOURCE from callerid.h * \retval -1 if not in table */ int ast_connected_line_source_parse(const char *data); /*! * \since 1.8 * \brief Convert connected line update source value to explanatory string * * \param data AST_CONNECTED_LINE_UPDATE_SOURCE from callerid.h * * \return string for human presentation */ const char *ast_connected_line_source_describe(int data); /*! * \since 1.8 * \brief Convert connected line update source value to text code * * \param data AST_CONNECTED_LINE_UPDATE_SOURCE from callerid.h * * \return string for config file */ const char *ast_connected_line_source_name(int data); /*! * \since 1.8 * \brief Convert ast_party_name.char_set text code to value (used in config file parsing) * * \param data text string from config file * * \retval AST_PARTY_CHAR_SET from channel.h * \retval -1 if not in table */ int ast_party_name_charset_parse(const char *data); /*! * \since 1.8 * \brief Convert ast_party_name.char_set value to explanatory string * * \param data AST_PARTY_CHAR_SET from channel.h * * \return string for human presentation */ const char *ast_party_name_charset_describe(int data); /*! * \since 1.8 * \brief Convert ast_party_name.char_set value to text code * * \param data AST_PARTY_CHAR_SET from channel.h * * \return string for config file */ const char *ast_party_name_charset_str(int data); #endif /* _ASTERISK_CALLERID_H */ asterisk-11.7.0/include/asterisk/monitor.h0000644000175000007640000000431411215470673020465 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Channel monitoring */ #ifndef _ASTERISK_MONITOR_H #define _ASTERISK_MONITOR_H #include "asterisk/channel.h" #include "asterisk/optional_api.h" enum AST_MONITORING_STATE { AST_MONITOR_RUNNING, AST_MONITOR_PAUSED }; /* Streams recording control */ #define X_REC_IN 1 #define X_REC_OUT 2 #define X_JOIN 4 /*! Responsible for channel monitoring data */ struct ast_channel_monitor { struct ast_filestream *read_stream; struct ast_filestream *write_stream; char read_filename[FILENAME_MAX]; char write_filename[FILENAME_MAX]; char filename_base[FILENAME_MAX]; int filename_changed; char *format; int joinfiles; enum AST_MONITORING_STATE state; int (*stop)(struct ast_channel *chan, int need_lock); }; /* Start monitoring a channel */ AST_OPTIONAL_API(int, ast_monitor_start, (struct ast_channel *chan, const char *format_spec, const char *fname_base, int need_lock, int stream_action), { return -1; }); /* Stop monitoring a channel */ AST_OPTIONAL_API(int, ast_monitor_stop, (struct ast_channel *chan, int need_lock), { return -1; }); /* Change monitoring filename of a channel */ AST_OPTIONAL_API(int, ast_monitor_change_fname, (struct ast_channel *chan, const char *fname_base, int need_lock), { return -1; }); AST_OPTIONAL_API(void, ast_monitor_setjoinfiles, (struct ast_channel *chan, int turnon), { return; }); /* Pause monitoring of a channel */ AST_OPTIONAL_API(int, ast_monitor_pause, (struct ast_channel *chan), { return -1; }); /* Unpause monitoring of a channel */ AST_OPTIONAL_API(int, ast_monitor_unpause, (struct ast_channel *chan), { return -1; }); #endif /* _ASTERISK_MONITOR_H */ asterisk-11.7.0/include/asterisk/format.h0000644000175000007640000004220212000065703020247 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * David Vossel * * 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 Format API * * \author David Vossel */ #ifndef _AST_FORMAT_H_ #define _AST_FORMAT_H_ #include "asterisk/astobj2.h" #include "asterisk/silk.h" #include "asterisk/celt.h" #define AST_FORMAT_ATTR_SIZE 64 #define AST_FORMAT_INC 100000 /*! This is the value that ends a var list of format attribute * key value pairs. */ #define AST_FORMAT_ATTR_END -1 /* \brief Format Categories*/ enum ast_format_type { AST_FORMAT_TYPE_AUDIO = 1 * AST_FORMAT_INC, AST_FORMAT_TYPE_VIDEO = 2 * AST_FORMAT_INC, AST_FORMAT_TYPE_IMAGE = 3 * AST_FORMAT_INC, AST_FORMAT_TYPE_TEXT = 4 * AST_FORMAT_INC, }; enum ast_format_id { /*! G.723.1 compression */ AST_FORMAT_G723_1 = 1 + AST_FORMAT_TYPE_AUDIO, /*! GSM compression */ AST_FORMAT_GSM = 2 + AST_FORMAT_TYPE_AUDIO, /*! Raw mu-law data (G.711) */ AST_FORMAT_ULAW = 3 + AST_FORMAT_TYPE_AUDIO, /*! Raw A-law data (G.711) */ AST_FORMAT_ALAW = 4 + AST_FORMAT_TYPE_AUDIO, /*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */ AST_FORMAT_G726_AAL2 = 5 + AST_FORMAT_TYPE_AUDIO, /*! ADPCM (IMA) */ AST_FORMAT_ADPCM = 6 + AST_FORMAT_TYPE_AUDIO, /*! LPC10, 180 samples/frame */ AST_FORMAT_LPC10 = 7 + AST_FORMAT_TYPE_AUDIO, /*! G.729A audio */ AST_FORMAT_G729A = 8 + AST_FORMAT_TYPE_AUDIO, /*! SpeeX Free Compression */ AST_FORMAT_SPEEX = 9 + AST_FORMAT_TYPE_AUDIO, /*! iLBC Free Compression */ AST_FORMAT_ILBC = 10 + AST_FORMAT_TYPE_AUDIO, /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */ AST_FORMAT_G726 = 11 + AST_FORMAT_TYPE_AUDIO, /*! G.722 */ AST_FORMAT_G722 = 12 + AST_FORMAT_TYPE_AUDIO, /*! G.722.1 (also known as Siren7, 32kbps assumed) */ AST_FORMAT_SIREN7 = 13 + AST_FORMAT_TYPE_AUDIO, /*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */ AST_FORMAT_SIREN14 = 14 + AST_FORMAT_TYPE_AUDIO, /*! G.719 (64 kbps assumed) */ AST_FORMAT_G719 = 15 + AST_FORMAT_TYPE_AUDIO, /*! SpeeX Wideband (16kHz) Free Compression */ AST_FORMAT_SPEEX16 = 16 + AST_FORMAT_TYPE_AUDIO, /*! Raw mu-law data (G.711) */ AST_FORMAT_TESTLAW = 17 + AST_FORMAT_TYPE_AUDIO, /*! SILK format */ AST_FORMAT_SILK = 18 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (8000 Hz) PCM */ AST_FORMAT_SLINEAR = 19 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (12000 Hz) PCM */ AST_FORMAT_SLINEAR12 = 20 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (16000 Hz) PCM */ AST_FORMAT_SLINEAR16 = 21 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (24000 Hz) PCM */ AST_FORMAT_SLINEAR24 = 22 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (32000 Hz) PCM */ AST_FORMAT_SLINEAR32 = 23 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (44100 Hz) PCM just because we can. */ AST_FORMAT_SLINEAR44 = 24 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (48000 Hz) PCM */ AST_FORMAT_SLINEAR48 = 25 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (96000 Hz) PCM */ AST_FORMAT_SLINEAR96 = 26 + AST_FORMAT_TYPE_AUDIO, /*! Raw 16-bit Signed Linear (192000 Hz) PCM. maybe we're taking this too far. */ AST_FORMAT_SLINEAR192 = 27 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_SPEEX32 = 28 + AST_FORMAT_TYPE_AUDIO, AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, /*! H.261 Video */ AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, /*! H.263 Video */ AST_FORMAT_H263 = 2 + AST_FORMAT_TYPE_VIDEO, /*! H.263+ Video */ AST_FORMAT_H263_PLUS = 3 + AST_FORMAT_TYPE_VIDEO, /*! H.264 Video */ AST_FORMAT_H264 = 4 + AST_FORMAT_TYPE_VIDEO, /*! MPEG4 Video */ AST_FORMAT_MP4_VIDEO = 5 + AST_FORMAT_TYPE_VIDEO, /*! JPEG Images */ AST_FORMAT_JPEG = 1 + AST_FORMAT_TYPE_IMAGE, /*! PNG Images */ AST_FORMAT_PNG = 2 + AST_FORMAT_TYPE_IMAGE, /*! T.140 RED Text format RFC 4103 */ AST_FORMAT_T140RED = 1 + AST_FORMAT_TYPE_TEXT, /*! T.140 Text format - ITU T.140, RFC 4103 */ AST_FORMAT_T140 = 2 + AST_FORMAT_TYPE_TEXT, }; /*! Determine what type of media a ast_format_id is. */ #define AST_FORMAT_GET_TYPE(id) (((int) (id / AST_FORMAT_INC)) * AST_FORMAT_INC) /*! \brief This structure contains the buffer used for format attributes */ struct ast_format_attr { /*! The buffer formats can use to represent attributes */ uint32_t format_attr[AST_FORMAT_ATTR_SIZE]; /*! If a format's payload needs to pass through that a new marker is required * for RTP, this variable will be set. */ uint8_t rtp_marker_bit; }; /*! \brief Represents a media format within Asterisk. */ struct ast_format { /*! The unique id representing this format from all the other formats. */ enum ast_format_id id; /*! Attribute structure used to associate attributes with a format. */ struct ast_format_attr fattr; }; enum ast_format_cmp_res { /*! structure 1 is identical to structure 2. */ AST_FORMAT_CMP_EQUAL = 0, /*! structure 1 contains elements not in structure 2. */ AST_FORMAT_CMP_NOT_EQUAL, /*! structure 1 is a proper subset of the elements in structure 2.*/ AST_FORMAT_CMP_SUBSET, }; /*! \brief Definition of supported media formats (codecs) */ struct ast_format_list { struct ast_format format; /*!< The unique format. */ char name[64]; /*!< short name */ unsigned int samplespersecond; /*!< Number of samples per second (8000/16000) */ char desc[128]; /*!< Description */ int fr_len; /*!< Single frame length in bytes */ int min_ms; /*!< Min value */ int max_ms; /*!< Max value */ int inc_ms; /*!< Increment */ int def_ms; /*!< Default value */ unsigned int flags; /*!< Smoother flags */ int cur_ms; /*!< Current value */ int custom_entry; }; /*! \brief A format must register an attribute interface if it requires the use of the format attributes void pointer */ struct ast_format_attr_interface { /*! format type */ enum ast_format_id id; /*! \brief Determine if format_attr 1 is a subset of format_attr 2. * * \retval ast_format_cmp_res representing the result of comparing fattr1 and fattr2. */ enum ast_format_cmp_res (* const format_attr_cmp)(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2); /*! \brief Get joint attributes of same format type if they exist. * * \retval 0 if joint attributes exist * \retval -1 if no joint attributes are present */ int (* const format_attr_get_joint)(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2, struct ast_format_attr *result); /*! \brief Set format capabilities from a list of key value pairs ending with AST_FORMAT_ATTR_END. * \note This function does not need to call va_end of the va_list. */ void (* const format_attr_set)(struct ast_format_attr *format_attr, va_list ap); /*! * \brief Find out if format capabilities in va_list are in format. * \note This function does not need to call va_end of the va_list. * * \note This function is optional. In many cases the format_attr_cmp * function can be used to derive these results. If it is possible * that some format attributes have no bearing on the equality of two formats, this * function must exist. * * \retval 0 if all attributes exist * \retval -1 if any of the attributes not present */ int (* const format_attr_isset)(const struct ast_format_attr *format_attr, va_list ap); /* * \brief Return a value for a specific format key. Return that value in the void pointer. * * \note It is not expected that all key value pairs can be returned, but those that can should * be documented as such. * * \note This function is optional if key value pairs are not allowed to be accessed. This * will result in -1 always being returned. * * \retval 0 Success, value was found and copied into void pointer. * \retval -1 failure, Value was either not found, or not allowed to be accessed. */ int (* const format_attr_get_val)(const struct ast_format_attr *format_attr, int key, void *val); /* * \brief Parse SDP attribute information, interpret it, and store it in ast_format_attr structure. * * \retval 0 Success, values were valid * \retval -1 Failure, some values were not acceptable */ int (* const format_attr_sdp_parse)(struct ast_format_attr *format_attr, const char *attributes); /*! * \brief Generate SDP attribute information from an ast_format_attr structure. * * \note This callback should generate a full fmtp line using the provided payload number. */ void (* const format_attr_sdp_generate)(const struct ast_format_attr *format_attr, unsigned int payload, struct ast_str **str); }; /*! * \brief This function is used to have a media format aware module parse and interpret * SDP attribute information. Once interpreted this information is stored on the format * itself using Asterisk format attributes. * * \param format to set * \param attributes string containing the fmtp line from the SDP * * \retval 0 success, attribute values were valid * \retval -1 failure, values were not acceptable */ int ast_format_sdp_parse(struct ast_format *format, const char *attributes); /*! * \brief This function is used to produce an fmtp SDP line for an Asterisk format. The * attributes present on the Asterisk format are translated into the SDP equivalent. * * \param format to generate an fmtp line for * \param payload numerical payload for the fmtp line * \param str structure that the fmtp line will be appended to */ void ast_format_sdp_generate(const struct ast_format *format, unsigned int payload, struct ast_str **str); /*! * \brief This function is used to set an ast_format object to represent a media format * with optional format attributes represented by format specific key value pairs. * * \param format to set * \param id, format id to set on format * \param set_attributes, are there attributes to set on this format. 0 == false, 1 == True. * \param var list of attribute key value pairs, must end with AST_FORMAT_ATTR_END; * * \details Example usage. * ast_format_set(format, AST_FORMAT_ULAW, 0); // no capability attributes are needed for ULAW * * ast_format_set(format, AST_FORMAT_SILK, 1, // SILK has capability attributes. * AST_FORMAT_SILK_ATTR_RATE, 24000, * AST_FORMAT_SILK_ATTR_RATE, 16000, * AST_FORMAT_SILK_ATTR_RATE, 12000, * AST_FORMAT_SILK_ATTR_RATE, 8000, * AST_FORMAT_ATTR_END); * * \note This function will initialize the ast_format structure. * * \return Pointer to ast_format object, same pointer that is passed in * by the first argument. */ struct ast_format *ast_format_set(struct ast_format *format, enum ast_format_id id, int set_attributes, ... ); /*! * \brief After ast_format_set has been used on a function, this function can be used to * set additional format attributes to the structure. * * \param format to set * \param var list of attribute key value pairs, must end with AST_FORMAT_ATTR_END; * * \details Example usage. * ast_format_set(format, AST_FORMAT_SILK, 0); * ast_format_append(format, // SILK has capability attributes. * AST_FORMAT_SILK_ATTR_RATE, 24000, * AST_FORMAT_SILK_ATTR_RATE, 16000, * AST_FORMAT_SILK_ATTR_RATE, 12000, * AST_FORMAT_SILK_ATTR_RATE, 8000, * AST_FORMAT_ATTR_END); * * \return Pointer to ast_format object, same pointer that is passed in * by the first argument. */ struct ast_format *ast_format_append(struct ast_format *format, ... ); /*! * \brief Clears the format stucture. */ void ast_format_clear(struct ast_format *format); /*! * \brief This function is used to set an ast_format object to represent a media format * with optional capability attributes represented by format specific key value pairs. * * \details Example usage. Is this SILK format capable of 8khz * is_8khz = ast_format_isset(format, AST_FORMAT_SILK_CAP_RATE, 8000); * * \return 0, The format key value pairs are within the capabilities defined in this structure. * \return -1, The format key value pairs are _NOT_ within the capabilities of this structure. */ int ast_format_isset(const struct ast_format *format, ... ); /*! * \brief Get a value from a format containing attributes. * \note The key represents the format attribute to be retrieved, and the void pointer * is to the structure that value will be stored in. It must be known what structure a * key represents. * * \retval 0, success * \retval -1, failure */ int ast_format_get_value(const struct ast_format *format, int key, void *value); /*! * \brief Compare ast_formats structures * * \retval ast_format_cmp_res representing the result of comparing format1 and format2. */ enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2); /*! * \brief Find joint format attributes of two ast_format * structures containing the same uid and return the intersection in the * result structure. * * retval 0, joint attribute capabilities exist. * retval -1, no joint attribute capabilities exist. */ int ast_format_joint(const struct ast_format *format1, const struct ast_format *format2, struct ast_format *result); /*! * \brief copy format src into format dst. */ void ast_format_copy(struct ast_format *dst, const struct ast_format *src); /*! * \brief Set the rtp mark value on the format to indicate to the interface * writing this format's payload that a new RTP marker is necessary. */ void ast_format_set_video_mark(struct ast_format *format); /*! * \brief Determine of the marker bit is set or not on this format. * * \retval 1, true * \retval 0, false */ int ast_format_get_video_mark(const struct ast_format *format); /*! * \brief ast_format to old bitfield format represenatation * * \note This is only to be used for IAX2 compatibility * * \retval iax2 representation of ast_format * \retval 0, if no representation existis for iax2 */ uint64_t ast_format_to_old_bitfield(const struct ast_format *format); /*! * \brief ast_format_id to old bitfield format represenatation * */ uint64_t ast_format_id_to_old_bitfield(enum ast_format_id id); /*! * \brief convert old bitfield format to ast_format represenatation * \note This is only to be used for IAX2 compatibility * * \retval on success, pointer to the dst format in the input parameters * \retval on failure, NULL */ struct ast_format *ast_format_from_old_bitfield(struct ast_format *dst, uint64_t src); /*! * \brief convert old bitfield format to ast_format_id value */ enum ast_format_id ast_format_id_from_old_bitfield(uint64_t src); /*! * \brief Retrieve the global format list in a read only array. * \note ast_format_list_destroy must be called on every format * list retrieved from this function. */ const struct ast_format_list *ast_format_list_get(size_t *size); /*! * \brief Destroy an ast_format_list gotten from ast_format_list_get() */ const struct ast_format_list *ast_format_list_destroy(const struct ast_format_list *list); /*! \brief Get the name of a format * \param format id of format * \return A static string containing the name of the format or "unknown" if unknown. */ const char* ast_getformatname(const struct ast_format *format); /*! \brief Returns a string containing all formats pertaining to an format id. * \param buf a buffer for the output string * \param size size of buf (bytes) * \param format id. * \return The return value is buf. */ char* ast_getformatname_multiple_byid(char *buf, size_t size, enum ast_format_id id); /*! * \brief Gets a format from a name. * \param name string of format * \param format structure to return the format in. * \return This returns the format pointer given to it on success and NULL on failure */ struct ast_format *ast_getformatbyname(const char *name, struct ast_format *format); /*! * \brief Get a name from a format * \param format to get name of * \return This returns a static string identifying the format on success, 0 on error. */ const char *ast_codec2str(struct ast_format *format); /*! * \brief Get the sample rate for a given format. */ int ast_format_rate(const struct ast_format *format); /*! * \brief register ast_format_attr_interface with core. * * \retval 0 success * \retval -1 failure */ int ast_format_attr_reg_interface(const struct ast_format_attr_interface *interface); /*! * \brief unregister format_attr interface with core. * * \retval 0 success * \retval -1 failure */ int ast_format_attr_unreg_interface(const struct ast_format_attr_interface *interface); /*! * \brief Determine if a format is 16bit signed linear of any sample rate. */ int ast_format_is_slinear(const struct ast_format *format); /*! * \brief Get the best slinear format id for a given sample rate */ enum ast_format_id ast_format_slin_by_rate(unsigned int rate); #endif /* _AST_FORMAT_H */ asterisk-11.7.0/include/asterisk/module.h0000644000175000007640000004242311676430263020270 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2008, Digium, Inc. * * Mark Spencer * Kevin P. Fleming * Luigi Rizzo * * 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 Asterisk module definitions. * * This file contains the definitons for functions Asterisk modules should * provide and some other module related functions. */ #ifndef _ASTERISK_MODULE_H #define _ASTERISK_MODULE_H #include "asterisk/utils.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief The text the key() function should return. */ #define ASTERISK_GPL_KEY \ "This paragraph is copyright (c) 2006 by Digium, Inc. \ In order for your module to load, it must return this \ key via a function called \"key\". Any code which \ includes this paragraph must be licensed under the GNU \ General Public License version 2 or later (at your \ option). In addition to Digium's general reservations \ of rights, Digium expressly reserves the right to \ allow other parties to license this paragraph under \ different terms. Any use of Digium, Inc. trademarks or \ logos (including \"Asterisk\" or \"Digium\") without \ express written permission of Digium, Inc. is prohibited.\n" #define AST_MODULE_CONFIG "modules.conf" /*!< \brief Module configuration file */ enum ast_module_unload_mode { AST_FORCE_SOFT = 0, /*!< Softly unload a module, only if not in use */ AST_FORCE_FIRM = 1, /*!< Firmly unload a module, even if in use */ AST_FORCE_HARD = 2, /*!< as FIRM, plus dlclose() on the module. Not recommended as it may cause crashes */ }; enum ast_module_load_result { AST_MODULE_LOAD_SUCCESS = 0, /*!< Module loaded and configured */ AST_MODULE_LOAD_DECLINE = 1, /*!< Module is not configured */ AST_MODULE_LOAD_SKIP = 2, /*!< Module was skipped for some reason */ AST_MODULE_LOAD_PRIORITY = 3, /*!< Module is not loaded yet, but is added to prioity heap */ AST_MODULE_LOAD_FAILURE = -1, /*!< Module could not be loaded properly */ }; /*! * \brief Load a module. * \param resource_name The name of the module to load. * * This function is run by the PBX to load the modules. It performs * all loading and initialization tasks. Basically, to load a module, just * give it the name of the module and it will do the rest. * * \return See possible enum values for ast_module_load_result. */ enum ast_module_load_result ast_load_resource(const char *resource_name); /*! * \brief Unload a module. * \param resource_name The name of the module to unload. * \param ast_module_unload_mode The force flag. This should be set using one of the AST_FORCE flags. * * This function unloads a module. It will only unload modules that are not in * use (usecount not zero), unless #AST_FORCE_FIRM or #AST_FORCE_HARD is * specified. Setting #AST_FORCE_FIRM or #AST_FORCE_HARD will unload the * module regardless of consequences (NOT RECOMMENDED). * * \retval 0 on success. * \retval -1 on error. */ int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode); /*! * \brief Notify when usecount has been changed. * * This function calulates use counts and notifies anyone trying to keep track * of them. It should be called whenever your module's usecount changes. * * \note The ast_module_user_* functions take care of calling this function for you. */ void ast_update_use_count(void); /*! * \brief Ask for a list of modules, descriptions, and use counts. * \param modentry A callback to an updater function. * \param like * * For each of the modules loaded, modentry will be executed with the resource, * description, and usecount values of each particular module. * * \return the number of modules loaded */ int ast_update_module_list(int (*modentry)(const char *module, const char *description, int usecnt, const char *like), const char *like); /*! * \brief Check if module with the name given is loaded * \param name Module name, like "chan_sip.so" * \retval 1 if true * \retval 0 if false */ int ast_module_check(const char *name); /*! * \brief Add a procedure to be run when modules have been updated. * \param updater The function to run when modules have been updated. * * This function adds the given function to a linked list of functions to be * run when the modules are updated. * * \retval 0 on success * \retval -1 on failure. */ int ast_loader_register(int (*updater)(void)); /*! * \brief Remove a procedure to be run when modules are updated. * \param updater The updater function to unregister. * * This removes the given function from the updater list. * * \retval 0 on success * \retval -1 on failure. */ int ast_loader_unregister(int (*updater)(void)); /*! * \brief Run the unload() callback for all loaded modules * * This function should be called when Asterisk is shutting down gracefully. */ void ast_module_shutdown(void); /*! * \brief Match modules names for the Asterisk cli. * \param line Unused by this function, but this should be the line we are * matching. * \param word The partial name to match. * \param pos The position the word we are completing is in. * \param state The possible match to return. * \param rpos The position we should be matching. This should be the same as * pos. * \param needsreload This should be 1 if we need to reload this module and 0 * otherwise. This function will only return modules that are reloadble * if this is 1. * * \retval A possible completion of the partial match. * \retval NULL if no matches were found. */ char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload); /* Opaque type for module handles generated by the loader */ struct ast_module; /*! * \brief Get the name of a module. * \param mod A pointer to the module. * \return the name of the module * \retval NULL if mod or mod->info is NULL */ const char *ast_module_name(const struct ast_module *mod); /* User count routines keep track of which channels are using a given module resource. They can help make removing modules safer, particularly if they're in use at the time they have been requested to be removed */ struct ast_module_user; struct ast_module_user_list; /*! \page ModMngmnt The Asterisk Module management interface * * All modules must implement the module API (load, unload...) */ enum ast_module_flags { AST_MODFLAG_DEFAULT = 0, AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0), AST_MODFLAG_LOAD_ORDER = (1 << 1), }; enum ast_module_load_priority { AST_MODPRI_REALTIME_DEPEND = 10, /*!< Dependency for a realtime driver */ AST_MODPRI_REALTIME_DEPEND2 = 20, /*!< Second level dependency for a realtime driver (func_curl needs res_curl, but is needed by res_config_curl) */ AST_MODPRI_REALTIME_DRIVER = 30, /*!< A realtime driver, which provides configuration services for other modules */ AST_MODPRI_TIMING = 40, /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */ AST_MODPRI_CHANNEL_DEPEND = 50, /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */ AST_MODPRI_CHANNEL_DRIVER = 60, /*!< Channel drivers (provide devicestate) */ AST_MODPRI_APP_DEPEND = 70, /*!< Dependency for an application */ AST_MODPRI_DEVSTATE_PROVIDER = 80, /*!< Applications and other modules that _provide_ devicestate (e.g. meetme) */ AST_MODPRI_DEVSTATE_PLUGIN = 90, /*!< Plugin for a module that provides devstate (e.g. res_calendar_*) */ AST_MODPRI_CDR_DRIVER = 100, /*!< CDR or CEL backend */ AST_MODPRI_DEFAULT = 128, /*!< Modules not otherwise defined (such as most apps) will load here */ AST_MODPRI_DEVSTATE_CONSUMER = 150, /*!< Certain modules, which consume devstate, need to load after all others (e.g. app_queue) */ }; struct ast_module_info { /*! * The 'self' pointer for a module; it will be set by the loader before * it calls the module's load_module() entrypoint, and used by various * other macros that need to identify the module. */ struct ast_module *self; enum ast_module_load_result (*load)(void); /*!< register stuff etc. Optional. */ int (*reload)(void); /*!< config etc. Optional. */ int (*unload)(void); /*!< unload. called with the module locked */ int (*backup_globals)(void); /*!< for embedded modules, backup global data */ void (*restore_globals)(void); /*!< for embedded modules, restore global data */ const char *name; /*!< name of the module for loader reference and CLI commands */ const char *description; /*!< user friendly description of the module. */ /*! * This holds the ASTERISK_GPL_KEY, signifiying that you agree to the terms of * the Asterisk license as stated in the ASTERISK_GPL_KEY. Your module will not * load if it does not return the EXACT key string. */ const char *key; unsigned int flags; /*! The value of AST_BUILDOPT_SUM when this module was compiled */ const char buildopt_sum[33]; /*! This value represents the order in which a module's load() function is initialized. * The lower this value, the higher the priority. The value is only checked if the * AST_MODFLAG_LOAD_ORDER flag is set. If the AST_MODFLAG_LOAD_ORDER flag is not set, * this value will never be read and the module will be given the lowest possible priority * on load. */ unsigned char load_pri; /*! Modules which should be loaded first, in comma-separated string format. * These are only required for loading, when the optional_api header file * detects that the compiler does not support the optional API featureset. */ const char *nonoptreq; }; void ast_module_register(const struct ast_module_info *); void ast_module_unregister(const struct ast_module_info *); struct ast_module_user *__ast_module_user_add(struct ast_module *, struct ast_channel *); void __ast_module_user_remove(struct ast_module *, struct ast_module_user *); void __ast_module_user_hangup_all(struct ast_module *); #define ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan) #define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user) #define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self) struct ast_module *ast_module_ref(struct ast_module *); void ast_module_unref(struct ast_module *); #if defined(__cplusplus) || defined(c_plusplus) #define AST_MODULE_INFO(keystr, flags_to_set, desc, load_func, unload_func, reload_func, load_pri) \ static struct ast_module_info __mod_info = { \ NULL, \ load_func, \ reload_func, \ unload_func, \ NULL, \ NULL, \ AST_MODULE, \ desc, \ keystr, \ flags_to_set, \ AST_BUILDOPT_SUM, \ load_pri, \ }; \ static void __attribute__((constructor)) __reg_module(void) \ { \ ast_module_register(&__mod_info); \ } \ static void __attribute__((destructor)) __unreg_module(void) \ { \ ast_module_unregister(&__mod_info); \ } \ static const __attribute__((unused)) struct ast_module_info *ast_module_info = &__mod_info #define AST_MODULE_INFO_STANDARD(keystr, desc) \ AST_MODULE_INFO(keystr, AST_MODFLAG_LOAD_ORDER, desc, \ load_module, \ unload_module, \ NULL, \ AST_MODPRI_DEFAULT \ ) #else /* plain C */ /* forward declare this pointer in modules, so that macro/function calls that need it can get it, since it will actually be declared and populated at the end of the module's source file... */ static const __attribute__((unused)) struct ast_module_info *ast_module_info; #if !defined(EMBEDDED_MODULE) #define __MODULE_INFO_SECTION #define __MODULE_INFO_GLOBALS #else /* * For embedded modules we need additional information to backup and * restore the global variables in the module itself, so we can unload * reload the module. * EMBEDDED_MODULE is defined as the module name, so the calls to make_var() * below will actually define different symbols for each module. */ #define __MODULE_INFO_SECTION __attribute__((section(".embed_module"))) #define __MODULE_INFO_GLOBALS .backup_globals = __backup_globals, .restore_globals = __restore_globals, #define make_var_sub(mod, type) __ ## mod ## _ ## type #define make_var(mod, type) make_var_sub(mod, type) extern void make_var(EMBEDDED_MODULE, bss_start); extern void make_var(EMBEDDED_MODULE, bss_end); extern void make_var(EMBEDDED_MODULE, data_start); extern void make_var(EMBEDDED_MODULE, data_end); static void * __attribute__((section(".embed_module"))) __global_backup; static int __backup_globals(void) { size_t data_size = & make_var(EMBEDDED_MODULE, data_end) - & make_var(EMBEDDED_MODULE, data_start); if (__global_backup) return 0; if (!data_size) return 0; if (!(__global_backup = ast_malloc(data_size))) return -1; memcpy(__global_backup, & make_var(EMBEDDED_MODULE, data_start), data_size); return 0; } static void __restore_globals(void) { size_t data_size = & make_var(EMBEDDED_MODULE, data_end) - & make_var(EMBEDDED_MODULE, data_start); size_t bss_size = & make_var(EMBEDDED_MODULE, bss_end) - & make_var(EMBEDDED_MODULE, bss_start); if (bss_size) memset(& make_var(EMBEDDED_MODULE, bss_start), 0, bss_size); if (!data_size || !__global_backup) return; memcpy(& make_var(EMBEDDED_MODULE, data_start), __global_backup, data_size); } #undef make_var #undef make_var_sub #endif /* EMBEDDED_MODULE */ #define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) \ static struct ast_module_info \ __MODULE_INFO_SECTION \ __mod_info = { \ __MODULE_INFO_GLOBALS \ .name = AST_MODULE, \ .flags = flags_to_set, \ .description = desc, \ .key = keystr, \ .buildopt_sum = AST_BUILDOPT_SUM, \ fields \ }; \ static void __attribute__((constructor)) __reg_module(void) \ { \ ast_module_register(&__mod_info); \ } \ static void __attribute__((destructor)) __unreg_module(void) \ { \ ast_module_unregister(&__mod_info); \ } \ static const struct ast_module_info *ast_module_info = &__mod_info #define AST_MODULE_INFO_STANDARD(keystr, desc) \ AST_MODULE_INFO(keystr, AST_MODFLAG_LOAD_ORDER, desc, \ .load = load_module, \ .unload = unload_module, \ .load_pri = AST_MODPRI_DEFAULT, \ ) #endif /* plain C */ /*! * \brief Register an application. * * \param app Short name of the application * \param execute a function callback to execute the application. It should return * non-zero if the channel needs to be hung up. * \param synopsis a short description (one line synopsis) of the application * \param description long description with all of the details about the use of * the application * * This registers an application with Asterisk's internal application list. * \note The individual applications themselves are responsible for registering and unregistering * and unregistering their own CLI commands. * * \retval 0 success * \retval -1 failure. */ #define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, ast_module_info->self) /*! * \brief Register an application using XML documentation. * * \param app Short name of the application * \param execute a function callback to execute the application. It should return * non-zero if the channel needs to be hung up. * * This registers an application with Asterisk's internal application list. * \note The individual applications themselves are responsible for registering and unregistering * and unregistering their own CLI commands. * * \retval 0 success * \retval -1 failure. */ #define ast_register_application_xml(app, execute) ast_register_application(app, execute, NULL, NULL) /*! * \brief Register an application. * * \param app Short name of the application * \param execute a function callback to execute the application. It should return * non-zero if the channel needs to be hung up. * \param synopsis a short description (one line synopsis) of the application * \param description long description with all of the details about the use of * the application * \param mod module this application belongs to * * This registers an application with Asterisk's internal application list. * \note The individual applications themselves are responsible for registering and unregistering * and unregistering their own CLI commands. * * \retval 0 success * \retval -1 failure. */ int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod); /*! * \brief Unregister an application * * \param app name of the application (does not have to be the same string as the one that was registered) * * This unregisters an application from Asterisk's internal application list. * * \retval 0 success * \retval -1 failure */ int ast_unregister_application(const char *app); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_MODULE_H */ asterisk-11.7.0/include/asterisk/ulaw.h0000644000175000007640000000452410727606446017757 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 u-Law to Signed linear conversion */ #ifndef _ASTERISK_ULAW_H #define _ASTERISK_ULAW_H /*! * To init the ulaw to slinear conversion stuff, this needs to be run. */ void ast_ulaw_init(void); #define AST_ULAW_BIT_LOSS 3 #define AST_ULAW_STEP (1 << AST_ULAW_BIT_LOSS) #define AST_ULAW_TAB_SIZE (32768 / AST_ULAW_STEP + 1) #define AST_ULAW_SIGN_BIT 0x80 /*! \brief converts signed linear to mulaw */ #ifndef G711_NEW_ALGORITHM extern unsigned char __ast_lin2mu[16384]; #else extern unsigned char __ast_lin2mu[AST_ULAW_TAB_SIZE]; #endif /*! help */ extern short __ast_mulaw[256]; #ifndef G711_NEW_ALGORITHM #define AST_LIN2MU(a) (__ast_lin2mu[((unsigned short)(a)) >> 2]) #else #define AST_LIN2MU_LOOKUP(mag) \ __ast_lin2mu[((mag) + AST_ULAW_STEP / 2) >> AST_ULAW_BIT_LOSS] /*! \brief convert signed linear sample to sign-magnitude pair for u-Law */ static inline void ast_ulaw_get_sign_mag(short sample, unsigned *sign, unsigned *mag) { /* It may look illogical to retrive the sign this way in both cases, * but this helps gcc eliminate the branch below and produces * faster code */ *sign = ((unsigned short)sample >> 8) & AST_ULAW_SIGN_BIT; #if defined(G711_REDUCED_BRANCHING) { unsigned dual_mag = (-sample << 16) | (unsigned short)sample; *mag = (dual_mag >> (*sign >> 3)) & 0xffffU; } #else if (sample < 0) *mag = -sample; else *mag = sample; #endif /* G711_REDUCED_BRANCHING */ } static inline unsigned char AST_LIN2MU(short sample) { unsigned mag, sign; ast_ulaw_get_sign_mag(sample, &sign, &mag); return ~(sign | AST_LIN2MU_LOOKUP(mag)); } #endif #define AST_MULAW(a) (__ast_mulaw[(a)]) #endif /* _ASTERISK_ULAW_H */ asterisk-11.7.0/include/asterisk/io.h0000644000175000007640000001002511160056147017374 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 I/O Management (derived from Cheops-NG) */ #ifndef _ASTERISK_IO_H #define _ASTERISK_IO_H #include "asterisk/poll-compat.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! Input ready */ #define AST_IO_IN POLLIN /*! Output ready */ #define AST_IO_OUT POLLOUT /*! Priority input ready */ #define AST_IO_PRI POLLPRI /* Implicitly polled for */ /*! Error condition (errno or getsockopt) */ #define AST_IO_ERR POLLERR /*! Hangup */ #define AST_IO_HUP POLLHUP /*! Invalid fd */ #define AST_IO_NVAL POLLNVAL /*! \brief * An Asterisk IO callback takes its id, a file descriptor, list of events, and * callback data as arguments and returns 0 if it should not be * run again, or non-zero if it should be run again. */ struct io_context; /*! * \brief Creates a context * Create a context for I/O operations * Basically mallocs an IO structure and sets up some default values. * \return an allocated io_context structure */ struct io_context *io_context_create(void); /*! * \brief Destroys a context * \param ioc structure to destroy * Destroy a context for I/O operations * Frees all memory associated with the given io_context structure along with the structure itself */ void io_context_destroy(struct io_context *ioc); typedef int (*ast_io_cb)(int *id, int fd, short events, void *cbdata); #define AST_IO_CB(a) ((ast_io_cb)(a)) /*! * \brief Adds an IO context * \param ioc which context to use * \param fd which fd to monitor * \param callback callback function to run * \param events event mask of events to wait for * \param data data to pass to the callback * Watch for any of revents activites on fd, calling callback with data as * callback data. * \retval a pointer to ID of the IO event * \retval NULL on failure */ int *ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data); /*! * \brief Changes an IO handler * \param ioc which context to use * \param id * \param fd the fd you wish it to contain now * \param callback new callback function * \param events event mask to wait for * \param data data to pass to the callback function * Change an I/O handler, updating fd if > -1, callback if non-null, * and revents if >-1, and data if non-null. * \retval a pointer to the ID of the IO event * \retval NULL on failure */ int *ast_io_change(struct io_context *ioc, int *id, int fd, ast_io_cb callback, short events, void *data); /*! * \brief Removes an IO context * \param ioc which io_context to remove it from * \param id which ID to remove * Remove an I/O id from consideration * \retval 0 on success * \retval -1 on failure */ int ast_io_remove(struct io_context *ioc, int *id); /*! * \brief Waits for IO * \param ioc which context to act upon * \param howlong how many milliseconds to wait * Wait for I/O to happen, returning after * howlong milliseconds, and after processing * any necessary I/O. * \return he number of I/O events which took place. */ int ast_io_wait(struct io_context *ioc, int howlong); /*! * \brief Dumps the IO array. * Debugging: Dump everything in the I/O array */ void ast_io_dump(struct io_context *ioc); /*! Set fd into non-echoing mode (if fd is a tty) */ int ast_hide_password(int fd); /*! * \brief Restores TTY mode. * Call with result from previous ast_hide_password */ int ast_restore_tty(int fd, int oldstatus); int ast_get_termcols(int fd); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_IO_H */ asterisk-11.7.0/include/asterisk/tdd.h0000644000175000007640000000530010714136042017535 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 TTY/TDD Generation support * \note Includes code and algorithms from the Zapata library. */ #ifndef _ASTERISK_TDD_H #define _ASTERISK_TDD_H #define TDD_BYTES_PER_CHAR 2700 struct tdd_state; typedef struct tdd_state TDDSTATE; /*! CallerID Initialization * Initializes the TDD system. Mostly stuff for inverse FFT */ void tdd_init(void); /*! Generates a CallerID FSK stream in ulaw format suitable for transmission. * \param tdd tdd structure * \param buf Buffer to use. This needs to be large enough to accomodate all the generated samples. * \param string This is the string to send. * This function creates a stream of TDD data in ulaw format. It returns the size * (in bytes) of the data (if it returns a size of 0, there is probably an error) */ int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *string); /*! Create a TDD state machine * This function returns a malloc'd instance of the tdd_state data structure. * Returns a pointer to a malloc'd tdd_state structure, or NULL on error. */ struct tdd_state *tdd_new(void); /*! Read samples into the state machine, and return character (if any). * \param tdd Which state machine to act upon * \param ubuf containing your samples * \param samples number of samples contained within the buffer. * * Send received audio to the TDD demodulator. * Returns -1 on error, 0 for "needs more samples", * and > 0 (the character) if reception of a character is complete. */ int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples); /*! Free a TDD state machine * \param tdd This is the tdd_state state machine to free * This function frees tdd_state tdd. */ void tdd_free(struct tdd_state *tdd); /*! Generate Echo Canceller disable tone (2100HZ) * \param outbuf This is the buffer to receive the tone data * \param len This is the length (in samples) of the tone data to generate * Returns 0 if no error, and -1 if error. */ int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len); /*! Generate hold tone * \param outbuf This is the buffer to receive the tone data */ int tdd_gen_holdtone(unsigned char* outbuf); #endif /* _ASTERISK_TDD_H */ asterisk-11.7.0/include/asterisk/format_cap.h0000644000175000007640000002451711531040421021101 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * David Vossel * * 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 Format Capability API * * \author David Vossel */ #ifndef _AST_FORMATCAP_H_ #define _AST_FORMATCAP_H_ /*! Capabilities are represented by an opaque structure statically defined in format_capability.c */ struct ast_format_cap; /*! * \brief Allocate a new ast_format_cap structure. * * \note Allocation of this object assumes locking * is already occuring and that the point of contention * is above this capabilities structure. For example, * a tech_pvt object referencing a capabilities structure * can use this function as long as it always holds the * tech_pvt lock while accessing its capabilities. * * \retval ast_format_cap object on success. * \retval NULL on failure. */ struct ast_format_cap *ast_format_cap_alloc_nolock(void); /*! * \brief Allocate a new ast_format_cap structure with locking * * \note If no other form of locking is taking place, use this function. * This function makes most sense for globally accessible capabilities structures * that have no other means of locking. * * \retval ast_format_cap object on success. * \retval NULL on failure. */ struct ast_format_cap *ast_format_cap_alloc(void); /*! * \brief Destroy an ast_format_cap structure. * * \return NULL */ void *ast_format_cap_destroy(struct ast_format_cap *cap); /*! * \brief Add format capability to capabilities structure. * * \note A copy of the input format is made and that copy is * what is placed in the ast_format_cap structure. The actual * input format ptr is not stored. */ void ast_format_cap_add(struct ast_format_cap *cap, const struct ast_format *format); /*! * \brief Add all formats Asterisk knows about for a specific type to * the capabilities structure. Formats with attributes are set, but their * attributes are initilized to 0's. An attribute structure of 0's should * indicate to the format attribute interface that the format has full * capabilities. * * \note A copy of the input format is made and that copy is * what is placed in the ast_format_cap structure. The actual * input format ptr is not stored. */ void ast_format_cap_add_all_by_type(struct ast_format_cap *cap, enum ast_format_type type); /*! * \brief Add all known formats to the capabilities structure using default format attribute. */ void ast_format_cap_add_all(struct ast_format_cap *cap); /*! * \brief Append the formats in src to dst */ void ast_format_cap_append(struct ast_format_cap *dst, const struct ast_format_cap *src); /*! * \brief Copy all items in src to dst. * \note any items in dst will be removed before copying */ void ast_format_cap_copy(struct ast_format_cap *dst, const struct ast_format_cap *src); /*! * \brief create a deep copy of an ast_format_cap structure * * \retval cap on success * \retval NULL on failure */ struct ast_format_cap *ast_format_cap_dup(const struct ast_format_cap *src); /*! * \brief determine if a capabilities structure is empty or not * * \retval 1, true is empty * \retval 0, false, not empty */ int ast_format_cap_is_empty(const struct ast_format_cap *cap); /*! * \brief Remove format capability from capability structure. * * \Note format must match Exactly to format in ast_format_cap object in order * to be removed. * * \retval 0, remove was successful * \retval -1, remove failed. Could not find format to remove */ int ast_format_cap_remove(struct ast_format_cap *cap, struct ast_format *format); /*! * \brief Remove all format capabilities from capability * structure for a specific format id. * * \Note This will remove _ALL_ formats matching the format id from the * capabilities structure. * * \retval 0, remove was successful * \retval -1, remove failed. Could not find formats to remove */ int ast_format_cap_remove_byid(struct ast_format_cap *cap, enum ast_format_id id); /*! * \brief Remove all formats matching a specific format type. */ void ast_format_cap_remove_bytype(struct ast_format_cap *cap, enum ast_format_type type); /*! * \brief Remove all format capabilities from capability structure */ void ast_format_cap_remove_all(struct ast_format_cap *cap); /*! * \brief Remove all previous formats and set a single new format. */ void ast_format_cap_set(struct ast_format_cap *cap, struct ast_format *format); /*! * \brief Find if input ast_format is within the capabilities of the ast_format_cap object * then return the compatible format from the capabilities structure in the result. * * \retval 1 format is compatible with formats held in ast_format_cap object. * \retval 0 format is not compatible with any formats in ast_format_cap object. */ int ast_format_cap_get_compatible_format(const struct ast_format_cap *cap, const struct ast_format *format, struct ast_format *result); /*! * \brief Find if ast_format is within the capabilities of the ast_format_cap object. * * retval 1 format is compatible with formats held in ast_format_cap object. * retval 0 format is not compatible with any formats in ast_format_cap object. */ int ast_format_cap_iscompatible(const struct ast_format_cap *cap, const struct ast_format *format); /*! * \brief Finds the best quality audio format for a given format id and returns it in result. * * \retval 1 format found and set to result structure. * \retval 0 no format found, result structure is cleared. */ int ast_format_cap_best_byid(const struct ast_format_cap *cap, enum ast_format_id, struct ast_format *result); /*! * \brief is cap1 identical to cap2 * * retval 1 true, identical * retval 0 false, not identical */ int ast_format_cap_identical(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2); /*! * \brief Get joint capability structure. * * \note returns an ast_format_cap object containing the joint capabilities on success. This new * capabilities structure is allocated with _NO_ locking enabled. If a joint structure requires * locking, allocate it and use the ast_format_cap_joint_copy function to fill it with the joint * capabilities. * * \retval !NULL success, joint capabilties structure with _NO_ locking enabled. * \retval NULL failure */ struct ast_format_cap *ast_format_cap_joint(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2); /*! * \brief Get joint capability structure, copy into result capabilities structure * * \retval 1, joint capabilities exist * \retval 0, joint capabilities do not exist */ int ast_format_cap_joint_copy(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result); /*! * \brief Get joint capability structure, append into result capabilities structure * * \retval 1, joint capabilities exist * \retval 0, joint capabilities do not exist */ int ast_format_cap_joint_append(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result); /*! * \brief Find out if capability structures have any joint capabilities without * returning those capabilities. * * \retval 1 true, has joint capabilities * \retval 0 false, failure */ int ast_format_cap_has_joint(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2); /*! * \brief Get all capabilities for a specific media type * * \retval !NULL success, new capabilities structure with _NO_ locking enabled on the new structure. * \retval NULL failure */ struct ast_format_cap *ast_format_cap_get_type(const struct ast_format_cap *cap, enum ast_format_type ftype); /*! * \brief Find out if the capabilities structure has any formats * of a specific type. * * \retval 1 true * \retval 0 false, no formats of specific type. */ int ast_format_cap_has_type(const struct ast_format_cap *cap, enum ast_format_type type); /*! \brief Start iterating formats */ void ast_format_cap_iter_start(struct ast_format_cap *cap); /*! * \brief Next format in interation * * \details * Here is how to use the ast_format_cap iterator. * * 1. call ast_format_cap_iter_start * 2. call ast_format_cap_iter_next in a loop until it returns -1 * 3. call ast_format_cap_iter_end to terminate the iterator. * * example: * * ast_format_cap_iter_start(cap); * while (!ast_format_cap_iter_next(cap, &format)) { * * } * ast_format_cap_iter_end(Cap); * * \Note Unless the container was alloced using no_lock, the container * will be locked during the entire iteration until ast_format_cap_iter_end * is called. XXX Remember this, and do not attempt to lock any containers * within this iteration that will violate locking order. * * \retval 0 on success, new format is copied into input format struct * \retval -1, no more formats are present. */ int ast_format_cap_iter_next(struct ast_format_cap *cap, struct ast_format *format); /*! * \brief Ends ast_format_cap iteration. * \note this must be call after every ast_format_cap_iter_start */ void ast_format_cap_iter_end(struct ast_format_cap *cap); /*! * \brief ast_format_cap to old bitfield format represenatation * * \note This is only to be used for IAX2 compatibility * * \retval old bitfield representation of ast_format_cap * \retval 0, if no old bitfield capabilities are present in ast_format_cap */ uint64_t ast_format_cap_to_old_bitfield(const struct ast_format_cap *cap); /*! * \brief convert old bitfield format to ast_format_cap represenatation * \note This is only to be used for IAX2 compatibility */ void ast_format_cap_from_old_bitfield(struct ast_format_cap *dst, uint64_t src); /*! \brief Get the names of a set of formats * \param buf a buffer for the output string * \param size size of buf (bytes) * \param format the format (combined IDs of codecs) * Prints a list of readable codec names corresponding to "format". * ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)" * \return The return value is buf. */ char* ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap); #endif /* _AST_FORMATCAP_H */ asterisk-11.7.0/include/asterisk/celt.h0000644000175000007640000000211711605432672017724 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2011, Digium, Inc. * * David Vossel * * 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 CELT Format Attributes * * \author David Vossel */ #ifndef _AST_FORMAT_CELT_H_ #define _AST_FORMAT_CELT_H_ #define AST_CELT_DEFAULT_FRAME_SIZE 480 /*! CELT format attribute key value pairs, all are accessible through ast_format_get_value()*/ enum celt_attr_keys { CELT_ATTR_KEY_SAMP_RATE, /*!< value is an unsigned integer representing sample rate */ CELT_ATTR_KEY_MAX_BITRATE, /*!< value is an int */ CELT_ATTR_KEY_FRAME_SIZE, /*!< value is an int */ }; #endif /* _AST_FORMAT_CELT_H */ asterisk-11.7.0/include/asterisk/lock.h0000644000175000007640000006263512213424530017726 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Digium, Inc. * * Mark Spencer * * 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 Asterisk locking-related definitions: * - ast_mutext_t, ast_rwlock_t and related functions; * - atomic arithmetic instructions; * - wrappers for channel locking. * * - See \ref LockDef */ /*! \page LockDef Asterisk thread locking models * * This file provides different implementation of the functions, * depending on the platform, the use of DEBUG_THREADS, and the way * module-level mutexes are initialized. * * - \b static: the mutex is assigned the value AST_MUTEX_INIT_VALUE * this is done at compile time, and is the way used on Linux. * This method is not applicable to all platforms e.g. when the * initialization needs that some code is run. * * - \b through constructors: for each mutex, a constructor function is * defined, which then runs when the program (or the module) * starts. The problem with this approach is that there is a * lot of code duplication (a new block of code is created for * each mutex). Also, it does not prevent a user from declaring * a global mutex without going through the wrapper macros, * so sane programming practices are still required. */ #ifndef _ASTERISK_LOCK_H #define _ASTERISK_LOCK_H #include #include #include #ifdef HAVE_BKTR #include #endif #ifndef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK #include "asterisk/time.h" #endif #include "asterisk/logger.h" #include "asterisk/compiler.h" #define AST_PTHREADT_NULL (pthread_t) -1 #define AST_PTHREADT_STOP (pthread_t) -2 #if (defined(SOLARIS) || defined(BSD)) #define AST_MUTEX_INIT_W_CONSTRUCTORS #endif /* SOLARIS || BSD */ /* Asterisk REQUIRES recursive (not error checking) mutexes and will not run without them. */ #if defined(HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) && defined(HAVE_PTHREAD_MUTEX_RECURSIVE_NP) #define PTHREAD_MUTEX_INIT_VALUE PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP #else #define PTHREAD_MUTEX_INIT_VALUE PTHREAD_MUTEX_INITIALIZER #define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE #endif /* PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */ #ifdef HAVE_PTHREAD_RWLOCK_INITIALIZER #define __AST_RWLOCK_INIT_VALUE PTHREAD_RWLOCK_INITIALIZER #else /* HAVE_PTHREAD_RWLOCK_INITIALIZER */ #define __AST_RWLOCK_INIT_VALUE {0} #endif /* HAVE_PTHREAD_RWLOCK_INITIALIZER */ #ifdef HAVE_BKTR #define AST_LOCK_TRACK_INIT_VALUE { { NULL }, { 0 }, 0, { NULL }, { 0 }, {{{ 0 }}}, PTHREAD_MUTEX_INIT_VALUE } #else #define AST_LOCK_TRACK_INIT_VALUE { { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE } #endif #define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, NULL, 1 } #define AST_MUTEX_INIT_VALUE_NOTRACKING { PTHREAD_MUTEX_INIT_VALUE, NULL, 0 } #define AST_RWLOCK_INIT_VALUE { __AST_RWLOCK_INIT_VALUE, NULL, 1 } #define AST_RWLOCK_INIT_VALUE_NOTRACKING { __AST_RWLOCK_INIT_VALUE, NULL, 0 } #define AST_MAX_REENTRANCY 10 struct ast_channel; struct ast_lock_track { const char *file[AST_MAX_REENTRANCY]; int lineno[AST_MAX_REENTRANCY]; int reentrancy; const char *func[AST_MAX_REENTRANCY]; pthread_t thread[AST_MAX_REENTRANCY]; #ifdef HAVE_BKTR struct ast_bt backtrace[AST_MAX_REENTRANCY]; #endif pthread_mutex_t reentr_mutex; }; /*! \brief Structure for mutex and tracking information. * * We have tracking information in this structure regardless of DEBUG_THREADS being enabled. * The information will just be ignored in the core if a module does not request it.. */ struct ast_mutex_info { pthread_mutex_t mutex; /*! Track which thread holds this mutex */ struct ast_lock_track *track; unsigned int tracking:1; }; /*! \brief Structure for rwlock and tracking information. * * We have tracking information in this structure regardless of DEBUG_THREADS being enabled. * The information will just be ignored in the core if a module does not request it.. */ struct ast_rwlock_info { pthread_rwlock_t lock; /*! Track which thread holds this lock */ struct ast_lock_track *track; unsigned int tracking:1; }; typedef struct ast_mutex_info ast_mutex_t; typedef struct ast_rwlock_info ast_rwlock_t; typedef pthread_cond_t ast_cond_t; int __ast_pthread_mutex_init(int tracking, const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t); int __ast_pthread_mutex_destroy(const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t); int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func, const char* mutex_name, ast_mutex_t *t); int __ast_pthread_mutex_trylock(const char *filename, int lineno, const char *func, const char* mutex_name, ast_mutex_t *t); int __ast_pthread_mutex_unlock(const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t); #define ast_mutex_init(pmutex) __ast_pthread_mutex_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex) #define ast_mutex_init_notracking(pmutex) __ast_pthread_mutex_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex) #define ast_mutex_destroy(a) __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) #define ast_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) #define ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) #define ast_mutex_trylock(a) __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) int __ast_cond_init(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond, pthread_condattr_t *cond_attr); int __ast_cond_signal(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond); int __ast_cond_broadcast(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond); int __ast_cond_destroy(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond); int __ast_cond_wait(const char *filename, int lineno, const char *func, const char *cond_name, const char *mutex_name, ast_cond_t *cond, ast_mutex_t *t); int __ast_cond_timedwait(const char *filename, int lineno, const char *func, const char *cond_name, const char *mutex_name, ast_cond_t *cond, ast_mutex_t *t, const struct timespec *abstime); #define ast_cond_init(cond, attr) __ast_cond_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond, attr) #define ast_cond_destroy(cond) __ast_cond_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) #define ast_cond_signal(cond) __ast_cond_signal(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) #define ast_cond_broadcast(cond) __ast_cond_broadcast(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) #define ast_cond_wait(cond, mutex) __ast_cond_wait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex) #define ast_cond_timedwait(cond, mutex, time) __ast_cond_timedwait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex, time) int __ast_rwlock_init(int tracking, const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *t); int __ast_rwlock_destroy(const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *t); int __ast_rwlock_unlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name); int __ast_rwlock_rdlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name); int __ast_rwlock_wrlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name); int __ast_rwlock_timedrdlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name, const struct timespec *abs_timeout); int __ast_rwlock_timedwrlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name, const struct timespec *abs_timeout); int __ast_rwlock_tryrdlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name); int __ast_rwlock_trywrlock(const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name); /*! * \brief wrapper for rwlock with tracking enabled * \return 0 on success, non zero for error * \since 1.6.1 */ #define ast_rwlock_init(rwlock) __ast_rwlock_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) /*! * \brief wrapper for ast_rwlock_init with tracking disabled * \return 0 on success, non zero for error * \since 1.6.1 */ #define ast_rwlock_init_notracking(rwlock) __ast_rwlock_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) #define ast_rwlock_destroy(rwlock) __ast_rwlock_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) #define ast_rwlock_unlock(a) __ast_rwlock_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) #define ast_rwlock_rdlock(a) __ast_rwlock_rdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) #define ast_rwlock_wrlock(a) __ast_rwlock_wrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) #define ast_rwlock_tryrdlock(a) __ast_rwlock_tryrdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) #define ast_rwlock_trywrlock(a) __ast_rwlock_trywrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) #define ast_rwlock_timedrdlock(a, b) __ast_rwlock_timedrdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a, b) #define ast_rwlock_timedwrlock(a, b) __ast_rwlock_timedwrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a, b) #define ROFFSET ((lt->reentrancy > 0) ? (lt->reentrancy-1) : 0) #ifdef DEBUG_THREADS #define __ast_mutex_logger(...) do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0) #ifdef THREAD_CRASH #define DO_THREAD_CRASH do { *((int *)(0)) = 1; } while(0) #else #define DO_THREAD_CRASH do { } while (0) #endif #include enum ast_lock_type { AST_MUTEX, AST_RDLOCK, AST_WRLOCK, }; /*! * \brief Store lock info for the current thread * * This function gets called in ast_mutex_lock() and ast_mutex_trylock() so * that information about this lock can be stored in this thread's * lock info struct. The lock is marked as pending as the thread is waiting * on the lock. ast_mark_lock_acquired() will mark it as held by this thread. */ #if !defined(LOW_MEMORY) #ifdef HAVE_BKTR void ast_store_lock_info(enum ast_lock_type type, const char *filename, int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt); #else void ast_store_lock_info(enum ast_lock_type type, const char *filename, int line_num, const char *func, const char *lock_name, void *lock_addr); #endif /* HAVE_BKTR */ #else #ifdef HAVE_BKTR #define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS,BUD) #else #define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS) #endif /* HAVE_BKTR */ #endif /* !defined(LOW_MEMORY) */ /*! * \brief Mark the last lock as acquired */ #if !defined(LOW_MEMORY) void ast_mark_lock_acquired(void *lock_addr); #else #define ast_mark_lock_acquired(ignore) #endif /*! * \brief Mark the last lock as failed (trylock) */ #if !defined(LOW_MEMORY) void ast_mark_lock_failed(void *lock_addr); #else #define ast_mark_lock_failed(ignore) #endif /*! * \brief remove lock info for the current thread * * this gets called by ast_mutex_unlock so that information on the lock can * be removed from the current thread's lock info struct. */ #if !defined(LOW_MEMORY) #ifdef HAVE_BKTR void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt); #else void ast_remove_lock_info(void *lock_addr); #endif /* HAVE_BKTR */ void ast_suspend_lock_info(void *lock_addr); void ast_restore_lock_info(void *lock_addr); #else #ifdef HAVE_BKTR #define ast_remove_lock_info(ignore,me) #else #define ast_remove_lock_info(ignore) #endif /* HAVE_BKTR */ #define ast_suspend_lock_info(ignore); #define ast_restore_lock_info(ignore); #endif /* !defined(LOW_MEMORY) */ /*! * \brief log info for the current lock with ast_log(). * * this function would be mostly for debug. If you come across a lock * that is unexpectedly but momentarily locked, and you wonder who * are fighting with for the lock, this routine could be called, IF * you have the thread debugging stuff turned on. * \param this_lock_addr lock address to return lock information * \since 1.6.1 */ void log_show_lock(void *this_lock_addr); /*! * \brief retrieve lock info for the specified mutex * * this gets called during deadlock avoidance, so that the information may * be preserved as to what location originally acquired the lock. */ #if !defined(LOW_MEMORY) int ast_find_lock_info(void *lock_addr, char *filename, size_t filename_size, int *lineno, char *func, size_t func_size, char *mutex_name, size_t mutex_name_size); #else #define ast_find_lock_info(a,b,c,d,e,f,g,h) -1 #endif /*! * \brief Unlock a lock briefly * * used during deadlock avoidance, to preserve the original location where * a lock was originally acquired. */ #define CHANNEL_DEADLOCK_AVOIDANCE(chan) \ do { \ char __filename[80], __func[80], __mutex_name[80]; \ int __lineno; \ int __res = ast_find_lock_info(ao2_object_get_lockaddr(chan), __filename, sizeof(__filename), &__lineno, __func, sizeof(__func), __mutex_name, sizeof(__mutex_name)); \ int __res2 = ast_channel_unlock(chan); \ usleep(1); \ if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \ if (__res2) { \ ast_log(LOG_WARNING, "Could not unlock channel '%s': %s and no lock info found! I will NOT try to relock.\n", #chan, strerror(__res2)); \ } else { \ ast_channel_lock(chan); \ } \ } else { \ if (__res2) { \ ast_log(LOG_WARNING, "Could not unlock channel '%s': %s. {{{Originally locked at %s line %d: (%s) '%s'}}} I will NOT try to relock.\n", #chan, strerror(__res2), __filename, __lineno, __func, __mutex_name); \ } else { \ __ao2_lock(chan, AO2_LOCK_REQ_MUTEX, __filename, __func, __lineno, __mutex_name); \ } \ } \ } while (0) #define DEADLOCK_AVOIDANCE(lock) \ do { \ char __filename[80], __func[80], __mutex_name[80]; \ int __lineno; \ int __res = ast_find_lock_info(lock, __filename, sizeof(__filename), &__lineno, __func, sizeof(__func), __mutex_name, sizeof(__mutex_name)); \ int __res2 = ast_mutex_unlock(lock); \ usleep(1); \ if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \ if (__res2 == 0) { \ ast_mutex_lock(lock); \ } else { \ ast_log(LOG_WARNING, "Could not unlock mutex '%s': %s and no lock info found! I will NOT try to relock.\n", #lock, strerror(__res2)); \ } \ } else { \ if (__res2 == 0) { \ __ast_pthread_mutex_lock(__filename, __lineno, __func, __mutex_name, lock); \ } else { \ ast_log(LOG_WARNING, "Could not unlock mutex '%s': %s. {{{Originally locked at %s line %d: (%s) '%s'}}} I will NOT try to relock.\n", #lock, strerror(__res2), __filename, __lineno, __func, __mutex_name); \ } \ } \ } while (0) /*! * \brief Deadlock avoidance unlock * * In certain deadlock avoidance scenarios, there is more than one lock to be * unlocked and relocked. Therefore, this pair of macros is provided for that * purpose. Note that every DLA_UNLOCK _MUST_ be paired with a matching * DLA_LOCK. The intent of this pair of macros is to be used around another * set of deadlock avoidance code, mainly CHANNEL_DEADLOCK_AVOIDANCE, as the * locking order specifies that we may safely lock a channel, followed by its * pvt, with no worries about a deadlock. In any other scenario, this macro * may not be safe to use. */ #define DLA_UNLOCK(lock) \ do { \ char __filename[80], __func[80], __mutex_name[80]; \ int __lineno; \ int __res = ast_find_lock_info(lock, __filename, sizeof(__filename), &__lineno, __func, sizeof(__func), __mutex_name, sizeof(__mutex_name)); \ int __res2 = ast_mutex_unlock(lock); /*! * \brief Deadlock avoidance lock * * In certain deadlock avoidance scenarios, there is more than one lock to be * unlocked and relocked. Therefore, this pair of macros is provided for that * purpose. Note that every DLA_UNLOCK _MUST_ be paired with a matching * DLA_LOCK. The intent of this pair of macros is to be used around another * set of deadlock avoidance code, mainly CHANNEL_DEADLOCK_AVOIDANCE, as the * locking order specifies that we may safely lock a channel, followed by its * pvt, with no worries about a deadlock. In any other scenario, this macro * may not be safe to use. */ #define DLA_LOCK(lock) \ if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \ if (__res2) { \ ast_log(LOG_WARNING, "Could not unlock mutex '%s': %s and no lock info found! I will NOT try to relock.\n", #lock, strerror(__res2)); \ } else { \ ast_mutex_lock(lock); \ } \ } else { \ if (__res2) { \ ast_log(LOG_WARNING, "Could not unlock mutex '%s': %s. {{{Originally locked at %s line %d: (%s) '%s'}}} I will NOT try to relock.\n", #lock, strerror(__res2), __filename, __lineno, __func, __mutex_name); \ } else { \ __ast_pthread_mutex_lock(__filename, __lineno, __func, __mutex_name, lock); \ } \ } \ } while (0) static inline void ast_reentrancy_lock(struct ast_lock_track *lt) { int res; if ((res = pthread_mutex_lock(<->reentr_mutex))) { fprintf(stderr, "ast_reentrancy_lock failed: '%s' (%d)\n", strerror(res), res); #if defined(DO_CRASH) || defined(THREAD_CRASH) abort(); #endif } } static inline void ast_reentrancy_unlock(struct ast_lock_track *lt) { int res; if ((res = pthread_mutex_unlock(<->reentr_mutex))) { fprintf(stderr, "ast_reentrancy_unlock failed: '%s' (%d)\n", strerror(res), res); #if defined(DO_CRASH) || defined(THREAD_CRASH) abort(); #endif } } static inline void ast_reentrancy_init(struct ast_lock_track **plt) { int i; pthread_mutexattr_t reentr_attr; struct ast_lock_track *lt = *plt; if (!lt) { lt = *plt = (struct ast_lock_track *) calloc(1, sizeof(*lt)); } for (i = 0; i < AST_MAX_REENTRANCY; i++) { lt->file[i] = NULL; lt->lineno[i] = 0; lt->func[i] = NULL; lt->thread[i] = 0; #ifdef HAVE_BKTR memset(<->backtrace[i], 0, sizeof(lt->backtrace[i])); #endif } lt->reentrancy = 0; pthread_mutexattr_init(&reentr_attr); pthread_mutexattr_settype(&reentr_attr, AST_MUTEX_KIND); pthread_mutex_init(<->reentr_mutex, &reentr_attr); pthread_mutexattr_destroy(&reentr_attr); } static inline void delete_reentrancy_cs(struct ast_lock_track **plt) { struct ast_lock_track *lt; if (*plt) { lt = *plt; pthread_mutex_destroy(<->reentr_mutex); free(lt); *plt = NULL; } } #else /* !DEBUG_THREADS */ #define CHANNEL_DEADLOCK_AVOIDANCE(chan) \ ast_channel_unlock(chan); \ usleep(1); \ ast_channel_lock(chan); #define DEADLOCK_AVOIDANCE(lock) \ do { \ int __res; \ if (!(__res = ast_mutex_unlock(lock))) { \ usleep(1); \ ast_mutex_lock(lock); \ } else { \ ast_log(LOG_WARNING, "Failed to unlock mutex '%s' (%s). I will NOT try to relock. {{{ THIS IS A BUG. }}}\n", #lock, strerror(__res)); \ } \ } while (0) #define DLA_UNLOCK(lock) ast_mutex_unlock(lock) #define DLA_LOCK(lock) ast_mutex_lock(lock) #endif /* !DEBUG_THREADS */ #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) /* * If AST_MUTEX_INIT_W_CONSTRUCTORS is defined, use file scope constructors * and destructors to create/destroy global mutexes. */ #define __AST_MUTEX_DEFINE(scope, mutex, init_val, track) \ scope ast_mutex_t mutex = init_val; \ static void __attribute__((constructor)) init_##mutex(void) \ { \ if (track) \ ast_mutex_init(&mutex); \ else \ ast_mutex_init_notracking(&mutex); \ } \ \ static void __attribute__((destructor)) fini_##mutex(void) \ { \ ast_mutex_destroy(&mutex); \ } #else /* !AST_MUTEX_INIT_W_CONSTRUCTORS */ /* By default, use static initialization of mutexes. */ #define __AST_MUTEX_DEFINE(scope, mutex, init_val, track) scope ast_mutex_t mutex = init_val #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ #define AST_MUTEX_DEFINE_STATIC(mutex) __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE, 1) #define AST_MUTEX_DEFINE_STATIC_NOTRACKING(mutex) __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE_NOTRACKING, 0) /* Statically declared read/write locks */ #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS #define __AST_RWLOCK_DEFINE(scope, rwlock, init_val, track) \ scope ast_rwlock_t rwlock = init_val; \ static void __attribute__((constructor)) init_##rwlock(void) \ { \ if (track) \ ast_rwlock_init(&rwlock); \ else \ ast_rwlock_init_notracking(&rwlock); \ } \ static void __attribute__((destructor)) fini_##rwlock(void) \ { \ ast_rwlock_destroy(&rwlock); \ } #else #define __AST_RWLOCK_DEFINE(scope, rwlock, init_val, track) scope ast_rwlock_t rwlock = init_val #endif #define AST_RWLOCK_DEFINE_STATIC(rwlock) __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE, 1) #define AST_RWLOCK_DEFINE_STATIC_NOTRACKING(rwlock) __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE_NOTRACKING, 0) #ifndef __CYGWIN__ /* temporary disabled for cygwin */ #define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t #define pthread_cond_t use_ast_cond_t_instead_of_pthread_cond_t #endif #define pthread_mutex_lock use_ast_mutex_lock_instead_of_pthread_mutex_lock #define pthread_mutex_unlock use_ast_mutex_unlock_instead_of_pthread_mutex_unlock #define pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock #define pthread_mutex_init use_ast_mutex_init_instead_of_pthread_mutex_init #define pthread_mutex_destroy use_ast_mutex_destroy_instead_of_pthread_mutex_destroy #define pthread_cond_init use_ast_cond_init_instead_of_pthread_cond_init #define pthread_cond_destroy use_ast_cond_destroy_instead_of_pthread_cond_destroy #define pthread_cond_signal use_ast_cond_signal_instead_of_pthread_cond_signal #define pthread_cond_broadcast use_ast_cond_broadcast_instead_of_pthread_cond_broadcast #define pthread_cond_wait use_ast_cond_wait_instead_of_pthread_cond_wait #define pthread_cond_timedwait use_ast_cond_timedwait_instead_of_pthread_cond_timedwait #define AST_MUTEX_INITIALIZER __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__ #define gethostbyname __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__ #ifndef __linux__ #define pthread_create __use_ast_pthread_create_instead__ #endif /* * Support for atomic instructions. * For platforms that have it, use the native cpu instruction to * implement them. For other platforms, resort to a 'slow' version * (defined in utils.c) that protects the atomic instruction with * a single lock. * The slow versions is always available, for testing purposes, * as ast_atomic_fetchadd_int_slow() */ int ast_atomic_fetchadd_int_slow(volatile int *p, int v); #include "asterisk/inline_api.h" #if defined(HAVE_OSX_ATOMICS) #include "libkern/OSAtomic.h" #endif /*! \brief Atomically add v to *p and return * the previous value of *p. * This can be used to handle reference counts, and the return value * can be used to generate unique identifiers. */ #if defined(HAVE_GCC_ATOMICS) AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v), { return __sync_fetch_and_add(p, v); }) #elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 4) AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v), { return OSAtomicAdd32(v, (int32_t *) p) - v; }) #elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 8) AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v), { return OSAtomicAdd64(v, (int64_t *) p) - v; #elif defined (__i386__) || defined(__x86_64__) #ifdef sun AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v), { __asm __volatile ( " lock; xaddl %0, %1 ; " : "+r" (v), /* 0 (result) */ "=m" (*p) /* 1 */ : "m" (*p)); /* 2 */ return (v); }) #else /* ifndef sun */ AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v), { __asm __volatile ( " lock xaddl %0, %1 ; " : "+r" (v), /* 0 (result) */ "=m" (*p) /* 1 */ : "m" (*p)); /* 2 */ return (v); }) #endif #else /* low performance version in utils.c */ AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v), { return ast_atomic_fetchadd_int_slow(p, v); }) #endif /*! \brief decrement *p by 1 and return true if the variable has reached 0. * Useful e.g. to check if a refcount has reached 0. */ #if defined(HAVE_GCC_ATOMICS) AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p), { return __sync_sub_and_fetch(p, 1) == 0; }) #elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 4) AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p), { return OSAtomicAdd32( -1, (int32_t *) p) == 0; }) #elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 8) AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p), { return OSAtomicAdd64( -1, (int64_t *) p) == 0; #else AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p), { int a = ast_atomic_fetchadd_int(p, -1); return a == 1; /* true if the value is 0 now (so it was 1 previously) */ }) #endif #endif /* _ASTERISK_LOCK_H */ asterisk-11.7.0/include/asterisk/sched.h0000644000175000007640000002633511720555237020074 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Digium, Inc. * * Mark Spencer * Russell Bryant * * 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 Scheduler Routines (derived from cheops) */ #ifndef _ASTERISK_SCHED_H #define _ASTERISK_SCHED_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! * \brief Remove a scheduler entry * * This is a loop construct to ensure that * the scheduled task get deleted. The idea is that * if we loop attempting to remove the scheduled task, * then whatever callback had been running will complete * and reinsert the task into the scheduler. * * Since macro expansion essentially works like pass-by-name * parameter passing, this macro will still work correctly even * if the id of the task to delete changes. This holds as long as * the name of the id which could change is passed to the macro * and not a copy of the value of the id. */ #define AST_SCHED_DEL(sched, id) \ ({ \ int _count = 0; \ int _sched_res = -1; \ while (id > -1 && (_sched_res = ast_sched_del(sched, id)) && ++_count < 10) \ usleep(1); \ if (_count == 10) { \ ast_debug(3, "Unable to cancel schedule ID %d.\n", id); \ } \ id = -1; \ (_sched_res); \ }) #define AST_SCHED_DEL_ACCESSOR(sched, obj, getter, setter) \ ({ \ int _count = 0; \ int _sched_res = -1; \ while (getter(obj) > -1 && (_sched_res = ast_sched_del(sched, getter(obj))) && ++_count < 10) \ usleep(1); \ if (_count == 10) { \ ast_debug(3, "Unable to cancel schedule ID %d.\n", getter(obj)); \ } \ setter(obj, -1); \ (_sched_res); \ }) /*! * \brief schedule task to get deleted and call unref function * \sa AST_SCHED_DEL * \since 1.6.1 */ #define AST_SCHED_DEL_UNREF(sched, id, refcall) \ do { \ int _count = 0; \ while (id > -1 && ast_sched_del(sched, id) && ++_count < 10) { \ usleep(1); \ } \ if (_count == 10) \ ast_log(LOG_WARNING, "Unable to cancel schedule ID %d. This is probably a bug (%s: %s, line %d).\n", id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ if (id > -1) \ refcall; \ id = -1; \ } while (0); /*! * \brief schedule task to get deleted releasing the lock between attempts * \since 1.6.1 */ #define AST_SCHED_DEL_SPINLOCK(sched, id, lock) \ ({ \ int _count = 0; \ int _sched_res = -1; \ while (id > -1 && (_sched_res = ast_sched_del(sched, id)) && ++_count < 10) { \ ast_mutex_unlock(lock); \ usleep(1); \ ast_mutex_lock(lock); \ } \ if (_count == 10) { \ ast_debug(3, "Unable to cancel schedule ID %d.\n", id); \ } \ id = -1; \ (_sched_res); \ }) #define AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, variable) \ do { \ int _count = 0; \ while (id > -1 && ast_sched_del(sched, id) && ++_count < 10) { \ usleep(1); \ } \ if (_count == 10) \ ast_log(LOG_WARNING, "Unable to cancel schedule ID %d. This is probably a bug (%s: %s, line %d).\n", id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ id = ast_sched_add_variable(sched, when, callback, data, variable); \ } while (0); #define AST_SCHED_REPLACE(id, sched, when, callback, data) \ AST_SCHED_REPLACE_VARIABLE(id, sched, when, callback, data, 0) /*! * \note Not currently used in the source? * \since 1.6.1 */ #define AST_SCHED_REPLACE_VARIABLE_UNREF(id, sched, when, callback, data, variable, unrefcall, addfailcall, refcall) \ do { \ int _count = 0, _res=1; \ void *_data = (void *)ast_sched_find_data(sched, id); \ while (id > -1 && (_res = ast_sched_del(sched, id) && _count++ < 10)) { \ usleep(1); \ } \ if (!_res && _data) \ unrefcall; /* should ref _data! */ \ if (_count == 10) \ ast_log(LOG_WARNING, "Unable to cancel schedule ID %d. This is probably a bug (%s: %s, line %d).\n", id, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ refcall; \ id = ast_sched_add_variable(sched, when, callback, data, variable); \ if (id == -1) \ addfailcall; \ } while (0); #define AST_SCHED_REPLACE_UNREF(id, sched, when, callback, data, unrefcall, addfailcall, refcall) \ AST_SCHED_REPLACE_VARIABLE_UNREF(id, sched, when, callback, data, 0, unrefcall, addfailcall, refcall) /*! * \brief Create a scheduler context * * \return Returns a malloc'd sched_context structure, NULL on failure */ struct ast_sched_context *ast_sched_context_create(void); /*! * \brief destroys a schedule context * * \param c Context to free */ void ast_sched_context_destroy(struct ast_sched_context *c); /*! * \brief scheduler callback * * A scheduler callback takes a pointer with callback data and * * \retval 0 if the callback should not be rescheduled * \retval non-zero if the callback should be scheduled agai */ typedef int (*ast_sched_cb)(const void *data); #define AST_SCHED_CB(a) ((ast_sched_cb)(a)) struct ast_cb_names { int numassocs; char *list[10]; ast_sched_cb cblist[10]; }; /*! * \brief Show statics on what it is in the schedule queue * \param con Schedule context to check * \param buf dynamic string to store report * \param cbnames to check against * \since 1.6.1 */ void ast_sched_report(struct ast_sched_context *con, struct ast_str **buf, struct ast_cb_names *cbnames); /*! * \brief Adds a scheduled event * * Schedule an event to take place at some point in the future. callback * will be called with data as the argument, when milliseconds into the * future (approximately) * * If callback returns 0, no further events will be re-scheduled * * \param con Scheduler context to add * \param when how many milliseconds to wait for event to occur * \param callback function to call when the amount of time expires * \param data data to pass to the callback * * \return Returns a schedule item ID on success, -1 on failure */ int ast_sched_add(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result; /*! * \brief replace a scheduler entry * \deprecated You should use the AST_SCHED_REPLACE() macro instead. * * This deletes the scheduler entry for old_id if it exists, and then * calls ast_sched_add to create a new entry. A negative old_id will * be ignored. * * \retval -1 failure * \retval otherwise, returns scheduled item ID */ int ast_sched_replace(int old_id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result; /*! * \brief Adds a scheduled event with rescheduling support * * \param con Scheduler context to add * \param when how many milliseconds to wait for event to occur * \param callback function to call when the amount of time expires * \param data data to pass to the callback * \param variable If true, the result value of callback function will be * used for rescheduling * * Schedule an event to take place at some point in the future. Callback * will be called with data as the argument, when milliseconds into the * future (approximately) * * If callback returns 0, no further events will be re-scheduled * * \return Returns a schedule item ID on success, -1 on failure */ int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result; /*! * \brief replace a scheduler entry * \deprecated You should use the AST_SCHED_REPLACE_VARIABLE() macro instead. * * This deletes the scheduler entry for old_id if it exists, and then * calls ast_sched_add to create a new entry. A negative old_id will * be ignored. * * \retval -1 failure * \retval otherwise, returns scheduled item ID */ int ast_sched_replace_variable(int old_id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result; /*! * \brief Find a sched structure and return the data field associated with it. * * \param con scheduling context in which to search fro the matching id * \param id ID of the scheduled item to find * \return the data field from the matching sched struct if found; else return NULL if not found. * * \since 1.6.1 */ const void *ast_sched_find_data(struct ast_sched_context *con, int id); /*! * \brief Deletes a scheduled event * * Remove this event from being run. A procedure should not remove its own * event, but return 0 instead. In most cases, you should not call this * routine directly, but use the AST_SCHED_DEL() macro instead (especially if * you don't intend to do something different when it returns failure). * * \param con scheduling context to delete item from * \param id ID of the scheduled item to delete * * \return Returns 0 on success, -1 on failure */ #ifndef AST_DEVMODE int ast_sched_del(struct ast_sched_context *con, int id) attribute_warn_unused_result; #else int _ast_sched_del(struct ast_sched_context *con, int id, const char *file, int line, const char *function) attribute_warn_unused_result; #define ast_sched_del(a, b) _ast_sched_del(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) #endif /*! * \brief Determines number of seconds until the next outstanding event to take place * * Determine the number of seconds until the next outstanding event * should take place, and return the number of milliseconds until * it needs to be run. This value is perfect for passing to the poll * call. * * \param con context to act upon * * \return Returns "-1" if there is nothing there are no scheduled events * (and thus the poll should not timeout) */ int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result; /*! * \brief Runs the queue * * Run the queue, executing all callbacks which need to be performed * at this time. * * \param con Scheduling context to run * \param con context to act upon * * \return Returns the number of events processed. */ int ast_sched_runq(struct ast_sched_context *con); /*! * \brief Dumps the scheduler contents * * Debugging: Dump the contents of the scheduler to stderr * * \param con Context to dump */ void ast_sched_dump(struct ast_sched_context *con); /*! * \brief Returns the number of seconds before an event takes place * * \param con Context to use * \param id Id to dump */ long ast_sched_when(struct ast_sched_context *con,int id); /*! * \brief Convenience macro for objects and reference (add) * */ #define ast_sched_add_object(obj,con,when,callback) ast_sched_add((con),(when),(callback), ASTOBJ_REF((obj))) /*! * \brief Convenience macro for objects and reference (del) * */ #define ast_sched_del_object(obj,destructor,con,id) do { \ if ((id) > -1) { \ ast_sched_del((con),(id)); \ (id) = -1; \ ASTOBJ_UNREF((obj),(destructor)); \ } \ } while(0) /*! * \brief Start a thread for processing scheduler entries * * \param con the scheduler context this thread will manage * * \retval 0 success * \retval non-zero failure */ int ast_sched_start_thread(struct ast_sched_context *con); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_SCHED_H */ asterisk-11.7.0/include/asterisk/frame.h0000644000175000007640000005667412205154371020102 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Asterisk internal frame definitions. * \arg For an explanation of frames, see \ref Def_Frame * \arg Frames are send of Asterisk channels, see \ref Def_Channel */ #ifndef _ASTERISK_FRAME_H #define _ASTERISK_FRAME_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include #include "asterisk/format_pref.h" #include "asterisk/format.h" #include "asterisk/endian.h" #include "asterisk/linkedlists.h" /*! * \page Def_Frame AST Multimedia and signalling frames * \section Def_AstFrame What is an ast_frame ? * A frame of data read used to communicate between * between channels and applications. * Frames are divided into frame types and subclasses. * * \par Frame types * \arg \b VOICE: Voice data, subclass is codec (AST_FORMAT_*) * \arg \b VIDEO: Video data, subclass is codec (AST_FORMAT_*) * \arg \b DTMF: A DTMF digit, subclass is the digit * \arg \b IMAGE: Image transport, mostly used in IAX * \arg \b TEXT: Text messages and character by character (real time text) * \arg \b HTML: URL's and web pages * \arg \b MODEM: Modulated data encodings, such as T.38 and V.150 * \arg \b IAX: Private frame type for the IAX protocol * \arg \b CNG: Comfort noice frames * \arg \b CONTROL:A control frame, subclass defined as AST_CONTROL_ * \arg \b NULL: Empty, useless frame * * \par Files * \arg frame.h Definitions * \arg frame.c Function library * \arg \ref Def_Channel Asterisk channels * \section Def_ControlFrame Control Frames * Control frames send signalling information between channels * and devices. They are prefixed with AST_CONTROL_, like AST_CONTROL_FRAME_HANGUP * \arg \b HANGUP The other end has hungup * \arg \b RING Local ring * \arg \b RINGING The other end is ringing * \arg \b ANSWER The other end has answered * \arg \b BUSY Remote end is busy * \arg \b TAKEOFFHOOK Make it go off hook (what's "it" ? ) * \arg \b OFFHOOK Line is off hook * \arg \b CONGESTION Congestion (circuit is busy, not available) * \arg \b FLASH Other end sends flash hook * \arg \b WINK Other end sends wink * \arg \b OPTION Send low-level option * \arg \b RADIO_KEY Key radio (see app_rpt.c) * \arg \b RADIO_UNKEY Un-key radio (see app_rpt.c) * \arg \b PROGRESS Other end indicates call progress * \arg \b PROCEEDING Indicates proceeding * \arg \b HOLD Call is placed on hold * \arg \b UNHOLD Call is back from hold * \arg \b VIDUPDATE Video update requested * \arg \b SRCUPDATE The source of media has changed (RTP marker bit must change) * \arg \b SRCCHANGE Media source has changed (RTP marker bit and SSRC must change) * \arg \b CONNECTED_LINE Connected line has changed * \arg \b REDIRECTING Call redirecting information has changed. */ /*! * \brief Frame types * * \note It is important that the values of each frame type are never changed, * because it will break backwards compatability with older versions. * This is because these constants are transmitted directly over IAX2. */ enum ast_frame_type { /*! DTMF end event, subclass is the digit */ AST_FRAME_DTMF_END = 1, /*! Voice data, subclass is AST_FORMAT_* */ AST_FRAME_VOICE, /*! Video frame, maybe?? :) */ AST_FRAME_VIDEO, /*! A control frame, subclass is AST_CONTROL_* */ AST_FRAME_CONTROL, /*! An empty, useless frame */ AST_FRAME_NULL, /*! Inter Asterisk Exchange private frame type */ AST_FRAME_IAX, /*! Text messages */ AST_FRAME_TEXT, /*! Image Frames */ AST_FRAME_IMAGE, /*! HTML Frame */ AST_FRAME_HTML, /*! Comfort Noise frame (subclass is level of CNG in -dBov), body may include zero or more 8-bit quantization coefficients */ AST_FRAME_CNG, /*! Modem-over-IP data streams */ AST_FRAME_MODEM, /*! DTMF begin event, subclass is the digit */ AST_FRAME_DTMF_BEGIN, }; #define AST_FRAME_DTMF AST_FRAME_DTMF_END enum { /*! This frame contains valid timing information */ AST_FRFLAG_HAS_TIMING_INFO = (1 << 0), }; union ast_frame_subclass { int integer; struct ast_format format; }; /*! \brief Data structure associated with a single frame of data */ struct ast_frame { /*! Kind of frame */ enum ast_frame_type frametype; /*! Subclass, frame dependent */ union ast_frame_subclass subclass; /*! Length of data */ int datalen; /*! Number of samples in this frame */ int samples; /*! Was the data malloc'd? i.e. should we free it when we discard the frame? */ int mallocd; /*! The number of bytes allocated for a malloc'd frame header */ size_t mallocd_hdr_len; /*! How many bytes exist _before_ "data" that can be used if needed */ int offset; /*! Optional source of frame for debugging */ const char *src; /*! Pointer to actual data */ union { void *ptr; uint32_t uint32; char pad[8]; } data; /*! Global delivery time */ struct timeval delivery; /*! For placing in a linked list */ AST_LIST_ENTRY(ast_frame) frame_list; /*! Misc. frame flags */ unsigned int flags; /*! Timestamp in milliseconds */ long ts; /*! Length in milliseconds */ long len; /*! Sequence number */ int seqno; }; /*! * Set the various field of a frame to point to a buffer. * Typically you set the base address of the buffer, the offset as * AST_FRIENDLY_OFFSET, and the datalen as the amount of bytes queued. * The remaining things (to be done manually) is set the number of * samples, which cannot be derived from the datalen unless you know * the number of bits per sample. */ #define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen) \ { \ (fr)->data.ptr = (char *)_base + (_ofs); \ (fr)->offset = (_ofs); \ (fr)->datalen = (_datalen); \ } /*! Queueing a null frame is fairly common, so we declare a global null frame object for this purpose instead of having to declare one on the stack */ extern struct ast_frame ast_null_frame; /*! \brief Offset into a frame's data buffer. * * By providing some "empty" space prior to the actual data of an ast_frame, * this gives any consumer of the frame ample space to prepend other necessary * information without having to create a new buffer. * * As an example, RTP can use the data from an ast_frame and simply prepend the * RTP header information into the space provided by AST_FRIENDLY_OFFSET instead * of having to create a new buffer with the necessary space allocated. */ #define AST_FRIENDLY_OFFSET 64 #define AST_MIN_OFFSET 32 /*! Make sure we keep at least this much handy */ /*! Need the header be free'd? */ #define AST_MALLOCD_HDR (1 << 0) /*! Need the data be free'd? */ #define AST_MALLOCD_DATA (1 << 1) /*! Need the source be free'd? (haha!) */ #define AST_MALLOCD_SRC (1 << 2) /* MODEM subclasses */ /*! T.38 Fax-over-IP */ #define AST_MODEM_T38 1 /*! V.150 Modem-over-IP */ #define AST_MODEM_V150 2 /* HTML subclasses */ /*! Sending a URL */ #define AST_HTML_URL 1 /*! Data frame */ #define AST_HTML_DATA 2 /*! Beginning frame */ #define AST_HTML_BEGIN 4 /*! End frame */ #define AST_HTML_END 8 /*! Load is complete */ #define AST_HTML_LDCOMPLETE 16 /*! Peer is unable to support HTML */ #define AST_HTML_NOSUPPORT 17 /*! Send URL, and track */ #define AST_HTML_LINKURL 18 /*! No more HTML linkage */ #define AST_HTML_UNLINK 19 /*! Reject link request */ #define AST_HTML_LINKREJECT 20 enum ast_control_frame_type { AST_CONTROL_HANGUP = 1, /*!< Other end has hungup */ AST_CONTROL_RING = 2, /*!< Local ring */ AST_CONTROL_RINGING = 3, /*!< Remote end is ringing */ AST_CONTROL_ANSWER = 4, /*!< Remote end has answered */ AST_CONTROL_BUSY = 5, /*!< Remote end is busy */ AST_CONTROL_TAKEOFFHOOK = 6, /*!< Make it go off hook */ AST_CONTROL_OFFHOOK = 7, /*!< Line is off hook */ AST_CONTROL_CONGESTION = 8, /*!< Congestion (circuits busy) */ AST_CONTROL_FLASH = 9, /*!< Flash hook */ AST_CONTROL_WINK = 10, /*!< Wink */ AST_CONTROL_OPTION = 11, /*!< Set a low-level option */ AST_CONTROL_RADIO_KEY = 12, /*!< Key Radio */ AST_CONTROL_RADIO_UNKEY = 13, /*!< Un-Key Radio */ AST_CONTROL_PROGRESS = 14, /*!< Indicate PROGRESS */ AST_CONTROL_PROCEEDING = 15, /*!< Indicate CALL PROCEEDING */ AST_CONTROL_HOLD = 16, /*!< Indicate call is placed on hold */ AST_CONTROL_UNHOLD = 17, /*!< Indicate call is left from hold */ AST_CONTROL_VIDUPDATE = 18, /*!< Indicate video frame update */ _XXX_AST_CONTROL_T38 = 19, /*!< T38 state change request/notification \deprecated This is no longer supported. Use AST_CONTROL_T38_PARAMETERS instead. */ AST_CONTROL_SRCUPDATE = 20, /*!< Indicate source of media has changed */ AST_CONTROL_TRANSFER = 21, /*!< Indicate status of a transfer request */ AST_CONTROL_CONNECTED_LINE = 22,/*!< Indicate connected line has changed */ AST_CONTROL_REDIRECTING = 23, /*!< Indicate redirecting id has changed */ AST_CONTROL_T38_PARAMETERS = 24,/*!< T38 state change request/notification with parameters */ AST_CONTROL_CC = 25, /*!< Indication that Call completion service is possible */ AST_CONTROL_SRCCHANGE = 26, /*!< Media source has changed and requires a new RTP SSRC */ AST_CONTROL_READ_ACTION = 27, /*!< Tell ast_read to take a specific action */ AST_CONTROL_AOC = 28, /*!< Advice of Charge with encoded generic AOC payload */ AST_CONTROL_END_OF_Q = 29, /*!< Indicate that this position was the end of the channel queue for a softhangup. */ AST_CONTROL_INCOMPLETE = 30, /*!< Indication that the extension dialed is incomplete */ AST_CONTROL_MCID = 31, /*!< Indicate that the caller is being malicious. */ AST_CONTROL_UPDATE_RTP_PEER = 32, /*!< Interrupt the bridge and have it update the peer */ AST_CONTROL_PVT_CAUSE_CODE = 33, /*!< Contains an update to the protocol-specific cause-code stored for branching dials */ }; enum ast_frame_read_action { AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, }; struct ast_control_read_action_payload { /* An indicator to ast_read of what action to * take with the frame; */ enum ast_frame_read_action action; /* The size of the frame's payload */ size_t payload_size; /* A payload for the frame. */ unsigned char payload[0]; }; enum ast_control_t38 { AST_T38_REQUEST_NEGOTIATE = 1, /*!< Request T38 on a channel (voice to fax) */ AST_T38_REQUEST_TERMINATE, /*!< Terminate T38 on a channel (fax to voice) */ AST_T38_NEGOTIATED, /*!< T38 negotiated (fax mode) */ AST_T38_TERMINATED, /*!< T38 terminated (back to voice) */ AST_T38_REFUSED, /*!< T38 refused for some reason (usually rejected by remote end) */ AST_T38_REQUEST_PARMS, /*!< request far end T.38 parameters for a channel in 'negotiating' state */ }; enum ast_control_t38_rate { AST_T38_RATE_2400 = 1, AST_T38_RATE_4800, AST_T38_RATE_7200, AST_T38_RATE_9600, AST_T38_RATE_12000, /* Set to 0 so it's taken as default when unspecified. * See ITU-T T.38 Implementors' Guide (11 May 2012), * Table H.2: if the T38MaxBitRate attribute is omitted * it should use a default of 14400. */ AST_T38_RATE_14400 = 0, }; enum ast_control_t38_rate_management { AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF = 0, AST_T38_RATE_MANAGEMENT_LOCAL_TCF, }; struct ast_control_t38_parameters { enum ast_control_t38 request_response; /*!< Request or response of the T38 control frame */ unsigned int version; /*!< Supported T.38 version */ unsigned int max_ifp; /*!< Maximum IFP size supported */ enum ast_control_t38_rate rate; /*!< Maximum fax rate supported */ enum ast_control_t38_rate_management rate_management; /*!< Rate management setting */ unsigned int fill_bit_removal:1; /*!< Set if fill bit removal can be used */ unsigned int transcoding_mmr:1; /*!< Set if MMR transcoding can be used */ unsigned int transcoding_jbig:1; /*!< Set if JBIG transcoding can be used */ }; enum ast_control_transfer { AST_TRANSFER_SUCCESS = 0, /*!< Transfer request on the channel worked */ AST_TRANSFER_FAILED, /*!< Transfer request on the channel failed */ }; struct ast_control_pvt_cause_code { char chan_name[AST_CHANNEL_NAME]; /*!< Name of the channel that originated the cause information */ unsigned int emulate_sip_cause:1; /*!< Indicates whether this should be used to emulate SIP_CAUSE support */ int ast_cause; /*!< Asterisk cause code associated with this message */ char code[1]; /*!< Tech-specific cause code information, beginning with the name of the tech */ }; #define AST_SMOOTHER_FLAG_G729 (1 << 0) #define AST_SMOOTHER_FLAG_BE (1 << 1) /* Option identifiers and flags */ #define AST_OPTION_FLAG_REQUEST 0 #define AST_OPTION_FLAG_ACCEPT 1 #define AST_OPTION_FLAG_REJECT 2 #define AST_OPTION_FLAG_QUERY 4 #define AST_OPTION_FLAG_ANSWER 5 #define AST_OPTION_FLAG_WTF 6 /*! Verify touchtones by muting audio transmission * (and reception) and verify the tone is still present * Option data is a single signed char value 0 or 1 */ #define AST_OPTION_TONE_VERIFY 1 /*! Put a compatible channel into TDD (TTY for the hearing-impared) mode * Option data is a single signed char value 0 or 1 */ #define AST_OPTION_TDD 2 /*! Relax the parameters for DTMF reception (mainly for radio use) * Option data is a single signed char value 0 or 1 */ #define AST_OPTION_RELAXDTMF 3 /*! Set (or clear) Audio (Not-Clear) Mode * Option data is a single signed char value 0 or 1 */ #define AST_OPTION_AUDIO_MODE 4 /*! Set channel transmit gain * Option data is a single signed char representing number of decibels (dB) * to set gain to (on top of any gain specified in channel driver) */ #define AST_OPTION_TXGAIN 5 /*! Set channel receive gain * Option data is a single signed char representing number of decibels (dB) * to set gain to (on top of any gain specified in channel driver) */ #define AST_OPTION_RXGAIN 6 /* set channel into "Operator Services" mode * Option data is a struct oprmode * * \note This option should never be sent over the network */ #define AST_OPTION_OPRMODE 7 /*! Explicitly enable or disable echo cancelation for the given channel * Option data is a single signed char value 0 or 1 * * \note This option appears to be unused in the code. It is handled, but never * set or queried. */ #define AST_OPTION_ECHOCAN 8 /*! \brief Handle channel write data * If a channel needs to process the data from a func_channel write operation * after func_channel_write executes, it can define the setoption callback * and process this option. A pointer to an ast_chan_write_info_t will be passed. * * \note This option should never be passed over the network. */ #define AST_OPTION_CHANNEL_WRITE 9 /* ! * Read-only. Allows query current status of T38 on the channel. * data: ast_t38state */ #define AST_OPTION_T38_STATE 10 /*! Request that the channel driver deliver frames in a specific format * Option data is a format_t */ #define AST_OPTION_FORMAT_READ 11 /*! Request that the channel driver be prepared to accept frames in a specific format * Option data is a format_t */ #define AST_OPTION_FORMAT_WRITE 12 /*! Request that the channel driver make two channels of the same tech type compatible if possible * Option data is an ast_channel * * \note This option should never be passed over the network */ #define AST_OPTION_MAKE_COMPATIBLE 13 /*! Get or set the digit detection state of the channel * Option data is a single signed char value 0 or 1 */ #define AST_OPTION_DIGIT_DETECT 14 /*! Get or set the fax tone detection state of the channel * Option data is a single signed char value 0 or 1 */ #define AST_OPTION_FAX_DETECT 15 /*! Get the device name from the channel (Read only) * Option data is a character buffer of suitable length */ #define AST_OPTION_DEVICE_NAME 16 /*! Get the CC agent type from the channel (Read only) * Option data is a character buffer of suitable length */ #define AST_OPTION_CC_AGENT_TYPE 17 /*! Get or set the security options on a channel * Option data is an integer value of 0 or 1 */ #define AST_OPTION_SECURE_SIGNALING 18 #define AST_OPTION_SECURE_MEDIA 19 struct oprmode { struct ast_channel *peer; int mode; } ; struct ast_option_header { /* Always keep in network byte order */ #if __BYTE_ORDER == __BIG_ENDIAN uint16_t flag:3; uint16_t option:13; #else #if __BYTE_ORDER == __LITTLE_ENDIAN uint16_t option:13; uint16_t flag:3; #else #error Byte order not defined #endif #endif uint8_t data[0]; }; /*! \brief Requests a frame to be allocated * * \param source * Request a frame be allocated. source is an optional source of the frame, * len is the requested length, or "0" if the caller will supply the buffer */ #if 0 /* Unimplemented */ struct ast_frame *ast_fralloc(char *source, int len); #endif /*! * \brief Frees a frame or list of frames * * \param fr Frame to free, or head of list to free * \param cache Whether to consider this frame for frame caching */ void ast_frame_free(struct ast_frame *fr, int cache); #define ast_frfree(fr) ast_frame_free(fr, 1) /*! \brief Makes a frame independent of any static storage * \param fr frame to act upon * Take a frame, and if it's not been malloc'd, make a malloc'd copy * and if the data hasn't been malloced then make the * data malloc'd. If you need to store frames, say for queueing, then * you should call this function. * \return Returns a frame on success, NULL on error * \note This function may modify the frame passed to it, so you must * not assume the frame will be intact after the isolated frame has * been produced. In other words, calling this function on a frame * should be the last operation you do with that frame before freeing * it (or exiting the block, if the frame is on the stack.) */ struct ast_frame *ast_frisolate(struct ast_frame *fr); /*! \brief Copies a frame * \param fr frame to copy * Duplicates a frame -- should only rarely be used, typically frisolate is good enough * \return Returns a frame on success, NULL on error */ struct ast_frame *ast_frdup(const struct ast_frame *fr); void ast_swapcopy_samples(void *dst, const void *src, int samples); /* Helpers for byteswapping native samples to/from little-endian and big-endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN #define ast_frame_byteswap_le(fr) do { ; } while(0) #define ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0) #else #define ast_frame_byteswap_le(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0) #define ast_frame_byteswap_be(fr) do { ; } while(0) #endif /*! \brief Parse an "allow" or "deny" line in a channel or device configuration and update the capabilities and pref if provided. Video codecs are not added to codec preference lists, since we can not transcode \return Returns number of errors encountered during parsing */ int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap *cap, const char *list, int allowing); /*! \name AST_Smoother */ /*@{ */ /*! \page ast_smooth The AST Frame Smoother The ast_smoother interface was designed specifically to take frames of variant sizes and produce frames of a single expected size, precisely what you want to do. The basic interface is: - Initialize with ast_smoother_new() - Queue input frames with ast_smoother_feed() - Get output frames with ast_smoother_read() - when you're done, free the structure with ast_smoother_free() - Also see ast_smoother_test_flag(), ast_smoother_set_flags(), ast_smoother_get_flags(), ast_smoother_reset() */ struct ast_smoother; struct ast_smoother *ast_smoother_new(int bytes); void ast_smoother_set_flags(struct ast_smoother *smoother, int flags); int ast_smoother_get_flags(struct ast_smoother *smoother); int ast_smoother_test_flag(struct ast_smoother *s, int flag); void ast_smoother_free(struct ast_smoother *s); void ast_smoother_reset(struct ast_smoother *s, int bytes); /*! * \brief Reconfigure an existing smoother to output a different number of bytes per frame * \param s the smoother to reconfigure * \param bytes the desired number of bytes per output frame * \return nothing * */ void ast_smoother_reconfigure(struct ast_smoother *s, int bytes); int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap); struct ast_frame *ast_smoother_read(struct ast_smoother *s); #define ast_smoother_feed(s,f) __ast_smoother_feed(s, f, 0) #if __BYTE_ORDER == __LITTLE_ENDIAN #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 1) #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 0) #else #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 0) #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 1) #endif /*@} Doxygen marker */ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix); /*! \brief Returns the number of samples contained in the frame */ int ast_codec_get_samples(struct ast_frame *f); /*! \brief Returns the number of bytes for the number of samples of the given format */ int ast_codec_get_len(struct ast_format *format, int samples); /*! \brief Appends a frame to the end of a list of frames, truncating the maximum length of the list */ struct ast_frame *ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe); /*! \brief Gets duration in ms of interpolation frame for a format */ static inline int ast_codec_interp_len(struct ast_format *format) { return (format->id == AST_FORMAT_ILBC) ? 30 : 20; } /*! \brief Adjusts the volume of the audio samples contained in a frame. \param f The frame containing the samples (must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR) \param adjustment The number of dB to adjust up or down. \return 0 for success, non-zero for an error */ int ast_frame_adjust_volume(struct ast_frame *f, int adjustment); /*! \brief Sums two frames of audio samples. \param f1 The first frame (which will contain the result) \param f2 The second frame \return 0 for success, non-zero for an error The frames must be AST_FRAME_VOICE and must contain AST_FORMAT_SLINEAR samples, and must contain the same number of samples. */ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2); /*! * \brief Clear all audio samples from an ast_frame. The frame must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR */ int ast_frame_clear(struct ast_frame *frame); /*! * \brief Copy the discription of a frame's subclass into the provided string * * \param f The frame to get the information from * \param subclass Buffer to fill with subclass information * \param slen Length of subclass buffer * \param moreinfo Buffer to fill with additional information * \param mlen Length of moreinfo buffer * \since 11 */ void ast_frame_subclass2str(struct ast_frame *f, char *subclass, size_t slen, char *moreinfo, size_t mlen); /*! * \brief Copy the discription of a frame type into the provided string * * \param frame_type The frame type to be described * \param ftype Buffer to fill with frame type description * \param len Length of subclass buffer * \since 11 */ void ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_FRAME_H */ asterisk-11.7.0/include/asterisk/alaw.h0000644000175000007640000000442010727515771017726 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 A-Law to Signed linear conversion */ #ifndef _ASTERISK_ALAW_H #define _ASTERISK_ALAW_H /*! \brief * To init the alaw to slinear conversion stuff, this needs to be run. */ void ast_alaw_init(void); #define AST_ALAW_BIT_LOSS 4 #define AST_ALAW_STEP (1 << AST_ALAW_BIT_LOSS) #define AST_ALAW_TAB_SIZE (32768 / AST_ALAW_STEP + 1) #define AST_ALAW_SIGN_BIT 0x80 #define AST_ALAW_AMI_MASK 0x55 /*! \brief converts signed linear to alaw */ #ifndef G711_NEW_ALGORITHM extern unsigned char __ast_lin2a[8192]; #else extern unsigned char __ast_lin2a[AST_ALAW_TAB_SIZE]; #endif /*! help */ extern short __ast_alaw[256]; #ifndef G711_NEW_ALGORITHM #define AST_LIN2A(a) (__ast_lin2a[((unsigned short)(a)) >> 3]) #else #define AST_LIN2A_LOOKUP(mag) \ __ast_lin2a[(mag) >> AST_ALAW_BIT_LOSS] /*! \brief Convert signed linear sample to sign-magnitude pair for a-Law */ static inline void ast_alaw_get_sign_mag(short sample, unsigned *sign, unsigned *mag) { /* It may look illogical to retrive the sign this way in both cases, * but this helps gcc eliminate the branch below and produces * faster code */ *sign = ((unsigned short)sample >> 8) & AST_ALAW_SIGN_BIT; #if defined(G711_REDUCED_BRANCHING) { unsigned dual_mag = (-sample << 16) | (unsigned short)sample; *mag = (dual_mag >> (*sign >> 3)) & 0xffffU; } #else if (sample < 0) *mag = -sample; else *mag = sample; #endif /* G711_REDUCED_BRANCHING */ *sign ^= AST_ALAW_SIGN_BIT; } static inline unsigned char AST_LIN2A(short sample) { unsigned mag, sign; ast_alaw_get_sign_mag(sample, &sign, &mag); return (sign | AST_LIN2A_LOOKUP(mag)) ^ AST_ALAW_AMI_MASK; } #endif #define AST_ALAW(a) (__ast_alaw[(int)(a)]) #endif /* _ASTERISK_ALAW_H */ asterisk-11.7.0/include/asterisk/ast_version.h0000644000175000007640000000203010761070106021313 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008, Digium, Inc. * * Russell Bryant * * 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 Asterisk version information * \author Russell Bryant */ #ifndef __AST_VERSION_H #define __AST_VERSION_H /*! * \brief Retrieve the Asterisk version string. */ const char *ast_get_version(void); /*! * \brief Retrieve the numeric Asterisk version * * Format ABBCC * AABB - Major version (1.4 would be 104) * CC - Minor version * * 1.4.17 would be 10417. */ const char *ast_get_version_num(void); #endif /* __AST_VERSION_H */ asterisk-11.7.0/include/asterisk/linkedlists.h0000644000175000007640000007564612055176264021345 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * Kevin P. Fleming * * 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. */ #ifndef ASTERISK_LINKEDLISTS_H #define ASTERISK_LINKEDLISTS_H #include "asterisk/lock.h" /*! * \file linkedlists.h * \brief A set of macros to manage forward-linked lists. */ /*! * \brief Locks a list. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure */ #define AST_LIST_LOCK(head) \ ast_mutex_lock(&(head)->lock) /*! * \brief Write locks a list. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive write lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure */ #define AST_RWLIST_WRLOCK(head) \ ast_rwlock_wrlock(&(head)->lock) /*! * \brief Write locks a list, with timeout. * \param head This is a pointer to the list head structure * \param ts Pointer to a timespec structure * * This macro attempts to place an exclusive write lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * * \since 1.6.1 */ #define AST_RWLIST_TIMEDWRLOCK(head, ts) ast_rwlock_timedwrlock(&(head)->lock, ts) /*! * \brief Read locks a list. * \param head This is a pointer to the list head structure * * This macro attempts to place a read lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure */ #define AST_RWLIST_RDLOCK(head) \ ast_rwlock_rdlock(&(head)->lock) /*! * \brief Read locks a list, with timeout. * \param head This is a pointer to the list head structure * \param ts Pointer to a timespec structure * * This macro attempts to place a read lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure * * \since 1.6.1 */ #define AST_RWLIST_TIMEDRDLOCK(head, ts) \ ast_rwlock_timedrdlock(&(head)->lock, ts) /*! * \brief Locks a list, without blocking if the list is locked. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure */ #define AST_LIST_TRYLOCK(head) \ ast_mutex_trylock(&(head)->lock) /*! * \brief Write locks a list, without blocking if the list is locked. * \param head This is a pointer to the list head structure * * This macro attempts to place an exclusive write lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure */ #define AST_RWLIST_TRYWRLOCK(head) \ ast_rwlock_trywrlock(&(head)->lock) /*! * \brief Read locks a list, without blocking if the list is locked. * \param head This is a pointer to the list head structure * * This macro attempts to place a read lock in the * list head structure pointed to by head. * \retval 0 on success * \retval non-zero on failure */ #define AST_RWLIST_TRYRDLOCK(head) \ ast_rwlock_tryrdlock(&(head)->lock) /*! * \brief Attempts to unlock a list. * \param head This is a pointer to the list head structure * * This macro attempts to remove an exclusive lock from the * list head structure pointed to by head. If the list * was not locked by this thread, this macro has no effect. */ #define AST_LIST_UNLOCK(head) \ ast_mutex_unlock(&(head)->lock) /*! * \brief Attempts to unlock a read/write based list. * \param head This is a pointer to the list head structure * * This macro attempts to remove a read or write lock from the * list head structure pointed to by head. If the list * was not locked by this thread, this macro has no effect. */ #define AST_RWLIST_UNLOCK(head) \ ast_rwlock_unlock(&(head)->lock) /*! * \brief Defines a structure to be used to hold a list of specified type. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type. It does not actually * declare (allocate) a structure; to do that, either follow this * macro with the desired name of the instance you wish to declare, * or use the specified \a name to declare instances elsewhere. * * Example usage: * \code * static AST_LIST_HEAD(entry_list, entry) entries; * \endcode * * This would define \c struct \c entry_list, and declare an instance of it named * \a entries, all intended to hold a list of type \c struct \c entry. */ #define AST_LIST_HEAD(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ } /*! * \brief Defines a structure to be used to hold a read/write list of specified type. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type. It does not actually * declare (allocate) a structure; to do that, either follow this * macro with the desired name of the instance you wish to declare, * or use the specified \a name to declare instances elsewhere. * * Example usage: * \code * static AST_RWLIST_HEAD(entry_list, entry) entries; * \endcode * * This would define \c struct \c entry_list, and declare an instance of it named * \a entries, all intended to hold a list of type \c struct \c entry. */ #define AST_RWLIST_HEAD(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_rwlock_t lock; \ } /*! * \brief Defines a structure to be used to hold a list of specified type (with no lock). * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type. It does not actually * declare (allocate) a structure; to do that, either follow this * macro with the desired name of the instance you wish to declare, * or use the specified \a name to declare instances elsewhere. * * Example usage: * \code * static AST_LIST_HEAD_NOLOCK(entry_list, entry) entries; * \endcode * * This would define \c struct \c entry_list, and declare an instance of it named * \a entries, all intended to hold a list of type \c struct \c entry. */ #define AST_LIST_HEAD_NOLOCK(name, type) \ struct name { \ struct type *first; \ struct type *last; \ } /*! * \brief Defines initial values for a declaration of AST_LIST_HEAD */ #define AST_LIST_HEAD_INIT_VALUE { \ .first = NULL, \ .last = NULL, \ .lock = AST_MUTEX_INIT_VALUE, \ } /*! * \brief Defines initial values for a declaration of AST_RWLIST_HEAD */ #define AST_RWLIST_HEAD_INIT_VALUE { \ .first = NULL, \ .last = NULL, \ .lock = AST_RWLOCK_INIT_VALUE, \ } /*! * \brief Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK */ #define AST_LIST_HEAD_NOLOCK_INIT_VALUE { \ .first = NULL, \ .last = NULL, \ } /*! * \brief Defines a structure to be used to hold a list of specified type, statically initialized. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type, and allocates an instance * of it, initialized to be empty. * * Example usage: * \code * static AST_LIST_HEAD_STATIC(entry_list, entry); * \endcode * * This would define \c struct \c entry_list, intended to hold a list of * type \c struct \c entry. */ #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) #define AST_LIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ } name; \ static void __attribute__((constructor)) __init_##name(void) \ { \ AST_LIST_HEAD_INIT(&name); \ } \ static void __attribute__((destructor)) __fini_##name(void) \ { \ AST_LIST_HEAD_DESTROY(&name); \ } \ struct __dummy_##name #else #define AST_LIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_mutex_t lock; \ } name = AST_LIST_HEAD_INIT_VALUE #endif /*! * \brief Defines a structure to be used to hold a read/write list of specified type, statically initialized. * \param name This will be the name of the defined structure. * \param type This is the type of each list entry. * * This macro creates a structure definition that can be used * to hold a list of the entries of type \a type, and allocates an instance * of it, initialized to be empty. * * Example usage: * \code * static AST_RWLIST_HEAD_STATIC(entry_list, entry); * \endcode * * This would define \c struct \c entry_list, intended to hold a list of * type \c struct \c entry. */ #ifndef HAVE_PTHREAD_RWLOCK_INITIALIZER #define AST_RWLIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_rwlock_t lock; \ } name; \ static void __attribute__((constructor)) __init_##name(void) \ { \ AST_RWLIST_HEAD_INIT(&name); \ } \ static void __attribute__((destructor)) __fini_##name(void) \ { \ AST_RWLIST_HEAD_DESTROY(&name); \ } \ struct __dummy_##name #else #define AST_RWLIST_HEAD_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ ast_rwlock_t lock; \ } name = AST_RWLIST_HEAD_INIT_VALUE #endif /*! * \brief Defines a structure to be used to hold a list of specified type, statically initialized. * * This is the same as AST_LIST_HEAD_STATIC, except without the lock included. */ #define AST_LIST_HEAD_NOLOCK_STATIC(name, type) \ struct name { \ struct type *first; \ struct type *last; \ } name = AST_LIST_HEAD_NOLOCK_INIT_VALUE /*! * \brief Initializes a list head structure with a specified first entry. * \param head This is a pointer to the list head structure * \param entry pointer to the list entry that will become the head of the list * * This macro initializes a list head structure by setting the head * entry to the supplied value and recreating the embedded lock. */ #define AST_LIST_HEAD_SET(head, entry) do { \ (head)->first = (entry); \ (head)->last = (entry); \ ast_mutex_init(&(head)->lock); \ } while (0) /*! * \brief Initializes an rwlist head structure with a specified first entry. * \param head This is a pointer to the list head structure * \param entry pointer to the list entry that will become the head of the list * * This macro initializes a list head structure by setting the head * entry to the supplied value and recreating the embedded lock. */ #define AST_RWLIST_HEAD_SET(head, entry) do { \ (head)->first = (entry); \ (head)->last = (entry); \ ast_rwlock_init(&(head)->lock); \ } while (0) /*! * \brief Initializes a list head structure with a specified first entry. * \param head This is a pointer to the list head structure * \param entry pointer to the list entry that will become the head of the list * * This macro initializes a list head structure by setting the head * entry to the supplied value. */ #define AST_LIST_HEAD_SET_NOLOCK(head, entry) do { \ (head)->first = (entry); \ (head)->last = (entry); \ } while (0) /*! * \brief Declare a forward link structure inside a list entry. * \param type This is the type of each list entry. * * This macro declares a structure to be used to link list entries together. * It must be used inside the definition of the structure named in * \a type, as follows: * * \code * struct list_entry { ... AST_LIST_ENTRY(list_entry) list; * } * \endcode * * The field name \a list here is arbitrary, and can be anything you wish. */ #define AST_LIST_ENTRY(type) \ struct { \ struct type *next; \ } #define AST_RWLIST_ENTRY AST_LIST_ENTRY /*! * \brief Returns the first entry contained in a list. * \param head This is a pointer to the list head structure */ #define AST_LIST_FIRST(head) ((head)->first) #define AST_RWLIST_FIRST AST_LIST_FIRST /*! * \brief Returns the last entry contained in a list. * \param head This is a pointer to the list head structure */ #define AST_LIST_LAST(head) ((head)->last) #define AST_RWLIST_LAST AST_LIST_LAST /*! * \brief Returns the next entry in the list after the given entry. * \param elm This is a pointer to the current entry. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. */ #define AST_LIST_NEXT(elm, field) ((elm)->field.next) #define AST_RWLIST_NEXT AST_LIST_NEXT /*! * \brief Checks whether the specified list contains any entries. * \param head This is a pointer to the list head structure * * \return zero if the list has entries * \return non-zero if not. */ #define AST_LIST_EMPTY(head) (AST_LIST_FIRST(head) == NULL) #define AST_RWLIST_EMPTY AST_LIST_EMPTY /*! * \brief Loops over (traverses) the entries in a list. * \param head This is a pointer to the list head structure * \param var This is the name of the variable that will hold a pointer to the * current list entry on each iteration. It must be declared before calling * this macro. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * * This macro is use to loop over (traverse) the entries in a list. It uses a * \a for loop, and supplies the enclosed code with a pointer to each list * entry as it loops. It is typically used as follows: * \code * static AST_LIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { ... AST_LIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_LIST_TRAVERSE(&entries, current, list) { (do something with current here) * } * \endcode * \warning If you modify the forward-link pointer contained in the \a current entry while * inside the loop, the behavior will be unpredictable. At a minimum, the following * macros will modify the forward-link pointer, and should not be used inside * AST_LIST_TRAVERSE() against the entry pointed to by the \a current pointer without * careful consideration of their consequences: * \li AST_LIST_NEXT() (when used as an lvalue) * \li AST_LIST_INSERT_AFTER() * \li AST_LIST_INSERT_HEAD() * \li AST_LIST_INSERT_TAIL() * \li AST_LIST_INSERT_SORTALPHA() */ #define AST_LIST_TRAVERSE(head,var,field) \ for((var) = (head)->first; (var); (var) = (var)->field.next) #define AST_RWLIST_TRAVERSE AST_LIST_TRAVERSE /*! * \brief Loops safely over (traverses) the entries in a list. * \param head This is a pointer to the list head structure * \param var This is the name of the variable that will hold a pointer to the * current list entry on each iteration. It must be declared before calling * this macro. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * * This macro is used to safely loop over (traverse) the entries in a list. It * uses a \a for loop, and supplies the enclosed code with a pointer to each list * entry as it loops. It is typically used as follows: * * \code * static AST_LIST_HEAD(entry_list, list_entry) entries; * ... * struct list_entry { ... AST_LIST_ENTRY(list_entry) list; * } * ... * struct list_entry *current; * ... * AST_LIST_TRAVERSE_SAFE_BEGIN(&entries, current, list) { (do something with current here) * } * AST_LIST_TRAVERSE_SAFE_END; * \endcode * * It differs from AST_LIST_TRAVERSE() in that the code inside the loop can modify * (or even free, after calling AST_LIST_REMOVE_CURRENT()) the entry pointed to by * the \a current pointer without affecting the loop traversal. */ #define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field) { \ typeof((head)) __list_head = head; \ typeof(__list_head->first) __list_next; \ typeof(__list_head->first) __list_prev = NULL; \ typeof(__list_head->first) __list_current; \ for ((var) = __list_head->first, \ __list_current = (var), \ __list_next = (var) ? (var)->field.next : NULL; \ (var); \ __list_prev = __list_current, \ (var) = __list_next, \ __list_current = (var), \ __list_next = (var) ? (var)->field.next : NULL, \ (void) __list_prev /* To quiet compiler? */ \ ) #define AST_RWLIST_TRAVERSE_SAFE_BEGIN AST_LIST_TRAVERSE_SAFE_BEGIN /*! * \brief Removes the \a current entry from a list during a traversal. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * * \note This macro can \b only be used inside an AST_LIST_TRAVERSE_SAFE_BEGIN() * block; it is used to unlink the current entry from the list without affecting * the list traversal (and without having to re-traverse the list to modify the * previous entry, if any). */ #define AST_LIST_REMOVE_CURRENT(field) do { \ __list_current->field.next = NULL; \ __list_current = __list_prev; \ if (__list_prev) { \ __list_prev->field.next = __list_next; \ } else { \ __list_head->first = __list_next; \ } \ if (!__list_next) { \ __list_head->last = __list_prev; \ } \ } while (0) #define AST_RWLIST_REMOVE_CURRENT AST_LIST_REMOVE_CURRENT /*! * \brief Move the current list entry to another list. * * \note This is a silly macro. It should be done explicitly * otherwise the field parameter must be the same for the two * lists. * * AST_LIST_REMOVE_CURRENT(field); * AST_LIST_INSERT_TAIL(newhead, var, other_field); */ #define AST_LIST_MOVE_CURRENT(newhead, field) do { \ typeof ((newhead)->first) __extracted = __list_current; \ AST_LIST_REMOVE_CURRENT(field); \ AST_LIST_INSERT_TAIL((newhead), __extracted, field); \ } while (0) #define AST_RWLIST_MOVE_CURRENT AST_LIST_MOVE_CURRENT /*! * \brief Inserts a list entry before the current entry during a traversal. * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * * \note This macro can \b only be used inside an AST_LIST_TRAVERSE_SAFE_BEGIN() * block. */ #define AST_LIST_INSERT_BEFORE_CURRENT(elm, field) do { \ if (__list_prev) { \ (elm)->field.next = __list_prev->field.next; \ __list_prev->field.next = elm; \ } else { \ (elm)->field.next = __list_head->first; \ __list_head->first = (elm); \ } \ __list_prev = (elm); \ } while (0) #define AST_RWLIST_INSERT_BEFORE_CURRENT AST_LIST_INSERT_BEFORE_CURRENT /*! * \brief Closes a safe loop traversal block. */ #define AST_LIST_TRAVERSE_SAFE_END } #define AST_RWLIST_TRAVERSE_SAFE_END AST_LIST_TRAVERSE_SAFE_END /*! * \brief Initializes a list head structure. * \param head This is a pointer to the list head structure * * This macro initializes a list head structure by setting the head * entry to \a NULL (empty list) and recreating the embedded lock. */ #define AST_LIST_HEAD_INIT(head) { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_mutex_init(&(head)->lock); \ } /*! * \brief Initializes an rwlist head structure. * \param head This is a pointer to the list head structure * * This macro initializes a list head structure by setting the head * entry to \a NULL (empty list) and recreating the embedded lock. */ #define AST_RWLIST_HEAD_INIT(head) { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_rwlock_init(&(head)->lock); \ } /*! * \brief Destroys a list head structure. * \param head This is a pointer to the list head structure * * This macro destroys a list head structure by setting the head * entry to \a NULL (empty list) and destroying the embedded lock. * It does not free the structure from memory. */ #define AST_LIST_HEAD_DESTROY(head) { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_mutex_destroy(&(head)->lock); \ } /*! * \brief Destroys an rwlist head structure. * \param head This is a pointer to the list head structure * * This macro destroys a list head structure by setting the head * entry to \a NULL (empty list) and destroying the embedded lock. * It does not free the structure from memory. */ #define AST_RWLIST_HEAD_DESTROY(head) { \ (head)->first = NULL; \ (head)->last = NULL; \ ast_rwlock_destroy(&(head)->lock); \ } /*! * \brief Initializes a list head structure. * \param head This is a pointer to the list head structure * * This macro initializes a list head structure by setting the head * entry to \a NULL (empty list). There is no embedded lock handling * with this macro. */ #define AST_LIST_HEAD_INIT_NOLOCK(head) { \ (head)->first = NULL; \ (head)->last = NULL; \ } /*! * \brief Inserts a list entry after a given entry. * \param head This is a pointer to the list head structure * \param listelm This is a pointer to the entry after which the new entry should * be inserted. * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. */ #define AST_LIST_INSERT_AFTER(head, listelm, elm, field) do { \ (elm)->field.next = (listelm)->field.next; \ (listelm)->field.next = (elm); \ if ((head)->last == (listelm)) \ (head)->last = (elm); \ } while (0) #define AST_RWLIST_INSERT_AFTER AST_LIST_INSERT_AFTER /*! * \brief Inserts a list entry at the head of a list. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the entry to be inserted. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. */ #define AST_LIST_INSERT_HEAD(head, elm, field) do { \ (elm)->field.next = (head)->first; \ (head)->first = (elm); \ if (!(head)->last) \ (head)->last = (elm); \ } while (0) #define AST_RWLIST_INSERT_HEAD AST_LIST_INSERT_HEAD /*! * \brief Appends a list entry to the tail of a list. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the entry to be appended. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * * Note: The link field in the appended entry is \b not modified, so if it is * actually the head of a list itself, the entire list will be appended * temporarily (until the next AST_LIST_INSERT_TAIL is performed). */ #define AST_LIST_INSERT_TAIL(head, elm, field) do { \ if (!(head)->first) { \ (head)->first = (elm); \ (head)->last = (elm); \ } else { \ (head)->last->field.next = (elm); \ (head)->last = (elm); \ } \ } while (0) #define AST_RWLIST_INSERT_TAIL AST_LIST_INSERT_TAIL /*! * \brief Inserts a list entry into a alphabetically sorted list * \param head Pointer to the list head structure * \param elm Pointer to the entry to be inserted * \param field Name of the list entry field (declared using AST_LIST_ENTRY()) * \param sortfield Name of the field on which the list is sorted * \since 1.6.1 */ #define AST_LIST_INSERT_SORTALPHA(head, elm, field, sortfield) do { \ if (!(head)->first) { \ (head)->first = (elm); \ (head)->last = (elm); \ } else { \ typeof((head)->first) __cur = (head)->first, __prev = NULL; \ while (__cur && strcmp(__cur->sortfield, elm->sortfield) < 0) { \ __prev = __cur; \ __cur = __cur->field.next; \ } \ if (!__prev) { \ AST_LIST_INSERT_HEAD(head, elm, field); \ } else if (!__cur) { \ AST_LIST_INSERT_TAIL(head, elm, field); \ } else { \ AST_LIST_INSERT_AFTER(head, __prev, elm, field); \ } \ } \ } while (0) #define AST_RWLIST_INSERT_SORTALPHA AST_LIST_INSERT_SORTALPHA /*! * \brief Appends a whole list to the tail of a list. * \param head This is a pointer to the list head structure * \param list This is a pointer to the list to be appended. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * * Note: The source list (the \a list parameter) will be empty after * calling this macro (the list entries are \b moved to the target list). */ #define AST_LIST_APPEND_LIST(head, list, field) do { \ if (!(list)->first) { \ break; \ } \ if (!(head)->first) { \ (head)->first = (list)->first; \ (head)->last = (list)->last; \ } else { \ (head)->last->field.next = (list)->first; \ (head)->last = (list)->last; \ } \ (list)->first = NULL; \ (list)->last = NULL; \ } while (0) #define AST_RWLIST_APPEND_LIST AST_LIST_APPEND_LIST /*! \brief Inserts a whole list after a specific entry in a list \param head This is a pointer to the list head structure \param list This is a pointer to the list to be inserted. \param elm This is a pointer to the entry after which the new list should be inserted. \param field This is the name of the field (declared using AST_LIST_ENTRY()) used to link entries of the lists together. Note: The source list (the \a list parameter) will be empty after calling this macro (the list entries are \b moved to the target list). */ #define AST_LIST_INSERT_LIST_AFTER(head, list, elm, field) do { \ (list)->last->field.next = (elm)->field.next; \ (elm)->field.next = (list)->first; \ if ((head)->last == elm) { \ (head)->last = (list)->last; \ } \ (list)->first = NULL; \ (list)->last = NULL; \ } while(0) #define AST_RWLIST_INSERT_LIST_AFTER AST_LIST_INSERT_LIST_AFTER /*! * \brief Removes and returns the head entry from a list. * \param head This is a pointer to the list head structure * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * * Removes the head entry from the list, and returns a pointer to it. * This macro is safe to call on an empty list. */ #define AST_LIST_REMOVE_HEAD(head, field) ({ \ typeof((head)->first) __cur = (head)->first; \ if (__cur) { \ (head)->first = __cur->field.next; \ __cur->field.next = NULL; \ if ((head)->last == __cur) \ (head)->last = NULL; \ } \ __cur; \ }) #define AST_RWLIST_REMOVE_HEAD AST_LIST_REMOVE_HEAD /*! * \brief Removes a specific entry from a list. * \param head This is a pointer to the list head structure * \param elm This is a pointer to the entry to be removed. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. * \retval elm if elm was in the list. * \retval NULL if elm was not in the list or elm was NULL. * \warning The removed entry is \b not freed. */ #define AST_LIST_REMOVE(head, elm, field) \ ({ \ __typeof(elm) __elm = (elm); \ if (__elm) { \ if ((head)->first == __elm) { \ (head)->first = __elm->field.next; \ __elm->field.next = NULL; \ if ((head)->last == __elm) { \ (head)->last = NULL; \ } \ } else { \ typeof(elm) __prev = (head)->first; \ while (__prev && __prev->field.next != __elm) { \ __prev = __prev->field.next; \ } \ if (__prev) { \ __prev->field.next = __elm->field.next; \ __elm->field.next = NULL; \ if ((head)->last == __elm) { \ (head)->last = __prev; \ } \ } else { \ __elm = NULL; \ } \ } \ } \ __elm; \ }) #define AST_RWLIST_REMOVE AST_LIST_REMOVE #endif /* _ASTERISK_LINKEDLISTS_H */ asterisk-11.7.0/include/asterisk/event.h0000644000175000007640000006255511633603737020135 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007 - 2008, Digium, Inc. * * Russell Bryant * * 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 * \author Russell Bryant * \ref AstGenericEvents */ /*! * \page AstGenericEvents Generic event system * * The purpose of this API is to provide a generic way to share events between * Asterisk modules. Code can generate events, and other code can subscribe to * them. * * Events have an associated event type, as well as information elements. The * information elements are the meta data that go along with each event. For * example, in the case of message waiting indication, the event type is MWI, * and each MWI event contains at least three information elements: the * mailbox, the number of new messages, and the number of old messages. * * Subscriptions to events consist of an event type and information elements, * as well. Subscriptions can be to all events, or a certain subset of events. * If an event type is provided, only events of that type will be sent to this * subscriber. Furthermore, if information elements are supplied with the * subscription, only events that contain the specified information elements * with specified values will be sent to the subscriber. For example, when a * SIP phone subscribes to MWI for mailbox 1234, then chan_sip can subscribe * to internal Asterisk MWI events with the MAILBOX information element with * a value of "1234". * * Another key feature of this event system is the ability to cache events. * It is useful for some types of events to be able to remember the last known * value. These are usually events that indicate some kind of state change. * In the example of MWI, app_voicemail can instruct the event core to cache * these events based on the mailbox. So, the last known MWI state of each * mailbox will be cached, and other modules can retrieve this information * on demand without having to poll the mailbox directly. */ #ifndef AST_EVENT_H #define AST_EVENT_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/event_defs.h" /*! * \brief Subscriber event callback type * * \param event the event being passed to the subscriber * \param userdata the data provider in the call to ast_event_subscribe() * * \return The event callbacks do not return anything. */ typedef void (*ast_event_cb_t)(const struct ast_event *event, void *userdata); /*! * \brief Subscribe to events * * \param event_type The type of events to subscribe to * \param cb The function to be called with events * \param description Description of the subscription. * \param userdata data to be passed to the event callback * * The rest of the arguments to this function specify additional parameters for * the subscription to filter which events are passed to this subscriber. The * arguments must be in sets of: * \code * , [enum ast_event_ie_pltype, [payload] ] * \endcode * and must end with AST_EVENT_IE_END. * * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed * by a valid IE payload type. If the payload type specified is * AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. * Otherwise, a payload must also be specified. * * \return This returns a reference to the subscription for use with * un-subscribing later. If there is a failure in creating the * subscription, NULL will be returned. * * Example usage: * * \code * peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, peer, * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox, * AST_EVENT_IE_END); * \endcode * * This creates a subscription to AST_EVENT_MWI events that contain an * information element, AST_EVENT_IE_MAILBOX, with the same string value * contained in peer->mailbox. Also, the event callback will be passed a * pointer to the peer. * * \note A NULL description will cause this function to crash, so watch out! */ struct ast_event_sub *ast_event_subscribe(enum ast_event_type event_type, ast_event_cb_t cb, const char *description, void *userdata, ...); /*! * \brief Allocate a subscription, but do not activate it * * \param type the event type to subscribe to * \param cb the function to call when an event matches this subscription * \param userdata data to pass to the provided callback * * This function should be used when you want to dynamically build a * subscription. * * \return the allocated subscription, or NULL on failure * \since 1.6.1 */ struct ast_event_sub *ast_event_subscribe_new(enum ast_event_type type, ast_event_cb_t cb, void *userdata); /*! * \brief Destroy an allocated subscription * * \param sub the subscription to destroy * * This function should be used when a subscription is allocated with * ast_event_subscribe_new(), but for some reason, you want to destroy it * instead of activating it. This could be because of an error when * reading in the configuration for the dynamically built subscription. * \since 1.6.1 */ void ast_event_sub_destroy(struct ast_event_sub *sub); /*! * \brief Append a uint parameter to a subscription * * \param sub the dynamic subscription allocated with ast_event_subscribe_new() * \param ie_type the information element type for the parameter * \param uint the value that must be present in the event to match this subscription * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_event_sub_append_ie_uint(struct ast_event_sub *sub, enum ast_event_ie_type ie_type, uint32_t uint); /*! * \brief Append a bitflags parameter to a subscription * * \param sub the dynamic subscription allocated with ast_event_subscribe_new() * \param ie_type the information element type for the parameter * \param flags the flags that must be present in the event to match this subscription * * \retval 0 success * \retval non-zero failure * \since 1.8 */ int ast_event_sub_append_ie_bitflags(struct ast_event_sub *sub, enum ast_event_ie_type ie_type, uint32_t flags); /*! * \brief Append a string parameter to a subscription * * \param sub the dynamic subscription allocated with ast_event_subscribe_new() * \param ie_type the information element type for the parameter * \param str the string that must be present in the event to match this subscription * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_event_sub_append_ie_str(struct ast_event_sub *sub, enum ast_event_ie_type ie_type, const char *str); /*! * \brief Append a raw parameter to a subscription * * \param sub the dynamic subscription allocated with ast_event_subscribe_new() * \param ie_type the information element type for the parameter * \param data the data that must be present in the event to match this subscription * \param raw_datalen length of data * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_event_sub_append_ie_raw(struct ast_event_sub *sub, enum ast_event_ie_type ie_type, void *data, size_t raw_datalen); /*! * \brief Append an 'exists' parameter to a subscription * * \param sub the dynamic subscription allocated with ast_event_subscribe_new() * \param ie_type the information element type that must be present in the event * for it to match this subscription. * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_event_sub_append_ie_exists(struct ast_event_sub *sub, enum ast_event_ie_type ie_type); /*! * \brief Activate a dynamically built subscription * * \param sub the subscription to activate that was allocated using * ast_event_subscribe_new() * * Once a dynamically built subscription has had all of the parameters added * to it, it should be activated using this function. * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_event_sub_activate(struct ast_event_sub *sub); /*! * \brief Un-subscribe from events * * \param event_sub This is the reference to the subscription returned by * ast_event_subscribe. * * This function will remove a subscription and free the associated data * structures. * * \return NULL for convenience. * \version 1.6.1 return changed to NULL */ struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *event_sub); /*! * \brief Get description for a subscription * * \param sub subscription * * \return string description of the subscription */ const char *ast_event_subscriber_get_description(struct ast_event_sub *sub); /*! * \brief Check if subscribers exist * * \param event_type This is the type of event that the caller would like to * check for subscribers to. * * The rest of the arguments to this function specify additional parameters for * checking for subscriptions to subsets of an event type. The arguments must * in sets of: * \code * , [enum ast_event_ie_pltype, [payload] ] * \endcode * and must end with AST_EVENT_IE_END. * * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed * by a valid IE payload type. If the payload type specified is * AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. * Otherwise, a payload must also be specified. * * \return This returns one of the values defined in the ast_event_subscriber_res * enum which will indicate if subscribers exist that match the given * criteria. * * Example usage: * * \code * if (ast_event_check_subscriber(AST_EVENT_MWI, * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, * AST_EVENT_IE_END) == AST_EVENT_SUB_NONE) { * return; * } * \endcode * * This example will check if there are any subscribers to MWI events for the * mailbox defined in the "mailbox" variable. */ enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type event_type, ...); /*! * \brief Report current subscriptions to a subscription subscriber * * \arg sub the subscription subscriber * * \return nothing * * This reports all of the current subscribers to a subscriber of * subscribers to a specific event type. (Try saying that a few times fast). * * The idea here is that it is sometimes very useful for a module to know when * someone subscribes to events. However, when they first subscribe, this * provides that module the ability to request the event core report to them * all of the subscriptions to that event type that already exist. */ void ast_event_report_subs(const struct ast_event_sub *sub); /*! * \brief Dump the event cache for the subscriber * \since 1.6.1 */ void ast_event_dump_cache(const struct ast_event_sub *event_sub); /*! * \brief Create a new event * * \param event_type The type of event to create * * The rest of the arguments to this function specify information elements to * add to the event. They are specified in the form: * \code * , [enum ast_event_ie_pltype, [payload] ] * \endcode * and must end with AST_EVENT_IE_END. * * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed * by a valid IE payload type. The payload type, EXISTS, should not be used here * because it makes no sense to do so. So, a payload must also be specified * after the IE payload type. * * \note The EID IE will be appended automatically when this function is used * with at least one IE specified. * * \return This returns the event that has been created. If there is an error * creating the event, NULL will be returned. * * Example usage: * * \code * if (!(event = ast_event_new(AST_EVENT_MWI, * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, * AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, new, * AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old, * AST_EVENT_IE_END))) { * return; * } * \endcode * * This creates a MWI event with 3 information elements, a mailbox which is * a string, and the number of new and old messages, specified as integers. */ struct ast_event *ast_event_new(enum ast_event_type event_type, ...); /*! * \brief Destroy an event * * \param event the event to destroy * * \return Nothing * * \note Events that have been queued should *not* be destroyed by the code that * created the event. It will be automatically destroyed after being * dispatched to the appropriate subscribers. */ void ast_event_destroy(struct ast_event *event); /*! * \brief Queue an event * * \param event the event to be queued * * \retval zero success * \retval non-zero failure. Note that the caller of this function is * responsible for destroying the event in the case of a failure. * * This function queues an event to be dispatched to all of the appropriate * subscribers. This function will not block while the event is being * dispatched because the event is queued up for a dispatching thread * to handle. */ int ast_event_queue(struct ast_event *event); /*! * \brief Queue and cache an event * * \param event the event to be queued and cached * * \details * The purpose of caching events is so that the core can retain the last known * information for events that represent some sort of state. That way, when * code needs to find out the current state, it can query the cache. * * The event API already knows which events can be cached and how to cache them. * * \retval 0 success * \retval non-zero failure. */ int ast_event_queue_and_cache(struct ast_event *event); /*! * \brief Retrieve an event from the cache * * \param ast_event_type The type of event to retrieve from the cache * * The rest of the arguments to this function specify information elements to * match for retrieving events from the cache. They are specified in the form: * \code * , [enum ast_event_ie_pltype, [payload] ] * \endcode * and must end with AST_EVENT_IE_END. * * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed * by a valid IE payload type. If the payload type specified is * AST_EVENT_IE_PLTYPE_EXISTS, then the 3rd argument should not be provided. * Otherwise, a payload must also be specified. * * \return A reference to an event retrieved from the cache. If no event was * found that matches the specified criteria, then NULL will be returned. * * \note If more than one event in the cache matches the specified criteria, only * one will be returned, and it is undefined which one it will be. * * \note The caller of this function *must* call ast_event_destroy() on the * returned event after it is done using it. * * Example Usage: * * \code * event = ast_event_get_cached(AST_EVENT_MWI, * AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, * AST_EVENT_IE_END); * \endcode * * This example will check for an MWI event in the cache that matches the * specified mailbox. This would be the way to find out the last known state * of a mailbox without having to poll the mailbox directly. */ struct ast_event *ast_event_get_cached(enum ast_event_type, ...); /*! * \brief Append an information element that has a string payload * * \param event the event that the IE will be appended to * \param ie_type the type of IE to append * \param str The string for the payload of the IE * * \retval 0 success * \retval -1 failure * * The pointer to the event will get updated with the new location for the event * that now contains the appended information element. If the re-allocation of * the memory for this event fails, it will be set to NULL. */ int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_type, const char *str); /*! * \brief Append an information element that has an integer payload * * \param event the event that the IE will be appended to * \param ie_type the type of IE to append * \param data The integer for the payload of the IE * * \retval 0 success * \retval -1 failure * * The pointer to the event will get updated with the new location for the event * that now contains the appended information element. If the re-allocation of * the memory for this event fails, it will be set to NULL. */ int ast_event_append_ie_uint(struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t data); /*! * \brief Append an information element that has a bitflags payload * * \param event the event that the IE will be appended to * \param ie_type the type of IE to append * \param bitflags the flags that are the payload of the IE * * \retval 0 success * \retval -1 failure * \since 1.8 * * The pointer to the event will get updated with the new location for the event * that now contains the appended information element. If the re-allocation of * the memory for this event fails, it will be set to NULL. */ int ast_event_append_ie_bitflags(struct ast_event **event, enum ast_event_ie_type ie_type, uint32_t bitflags); /*! * \brief Append an information element that has a raw payload * * \param event the event that the IE will be appended to * \param ie_type the type of IE to append * \param data A pointer to the raw data for the payload of the IE * \param data_len The amount of data to copy into the payload * * \retval 0 success * \retval -1 failure * * The pointer to the event will get updated with the new location for the event * that now contains the appended information element. If the re-allocation of * the memory for this event fails, it will be set to NULL. */ int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type, const void *data, size_t data_len); /*! * \brief Append the global EID IE * * \param event the event to append IE to * * \note For ast_event_new() that includes IEs, this is done automatically * for you. * * \retval 0 success * \retval -1 failure */ int ast_event_append_eid(struct ast_event **event); /*! * \brief Get the value of an information element that has an integer payload * * \param event The event to get the IE from * \param ie_type the type of information element to retrieve * * \return This returns the payload of the information element with the given type. * However, an IE with a payload of 0, and the case where no IE is found * yield the same return value. */ uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type); /*! * \brief Get the value of an information element that has a bitflags payload * * \param event The event to get the IE from * \param ie_type the type of information element to retrieve * * \return This returns the payload of the information element with the given type. * However, an IE with a payload of 0, and the case where no IE is found * yield the same return value. */ uint32_t ast_event_get_ie_bitflags(const struct ast_event *event, enum ast_event_ie_type ie_type); /*! * \brief Get the value of an information element that has a string payload * * \param event The event to get the IE from * \param ie_type the type of information element to retrieve * * \return This returns the payload of the information element with the given type. * If the information element isn't found, NULL will be returned. */ const char *ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type); /*! * \brief Get the hash for the string payload of an IE * * \param event The event to get the IE from * \param ie_type the type of information element to retrieve the hash for * * \return This function returns the hash value as calculated by ast_str_hash() * for the string payload. This is stored in the event to avoid * unnecessary string comparisons. */ uint32_t ast_event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type); /*! * \brief Get the value of an information element that has a raw payload * * \param event The event to get the IE from * \param ie_type the type of information element to retrieve * * \return This returns the payload of the information element with the given type. * If the information element isn't found, NULL will be returned. */ const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type); /*! * \brief Get the length of the raw payload for a particular IE * * \param event The event to get the IE payload length from * \param ie_type the type of information element to get the length of * * \return If an IE of type ie_type is found, its payload length is returned. * Otherwise, 0 is returned. */ uint16_t ast_event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type); /*! * \brief Get the string representation of an information element type * * \param ie_type the information element type to get the string representation of * * \return the string representation of the information element type * \since 1.6.1 */ const char *ast_event_get_ie_type_name(enum ast_event_ie_type ie_type); /*! * \brief Get the payload type for a given information element type * * \param ie_type the information element type to get the payload type of * * \return the payload type for the provided IE type * \since 1.6.1 */ enum ast_event_ie_pltype ast_event_get_ie_pltype(enum ast_event_ie_type ie_type); /*! * \brief Get the type for an event * * \param event the event to get the type for * * \return the event type as represented by one of the values in the * ast_event_type enum */ enum ast_event_type ast_event_get_type(const struct ast_event *event); /*! * \brief Get the string representation of the type of the given event * * \arg event the event to get the type of * * \return the string representation of the event type of the provided event * \since 1.6.1 */ const char *ast_event_get_type_name(const struct ast_event *event); /*! * \brief Convert a string into an event type * * \param str the string to convert * \param event_type an output parameter for the event type * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_event_str_to_event_type(const char *str, enum ast_event_type *event_type); /*! * \brief Convert a string to an IE type * * \param str the string to convert * \param ie_type an output parameter for the IE type * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ int ast_event_str_to_ie_type(const char *str, enum ast_event_ie_type *ie_type); /*! * \brief Get the size of an event * * \param event the event to get the size of * * \return the number of bytes contained in the event * \since 1.6.1 */ size_t ast_event_get_size(const struct ast_event *event); /*! * \brief Initialize an event iterator instance * * \param iterator The iterator instance to initialize * \param event The event that will be iterated through * * \retval 0 Success, there are IEs available to iterate * \retval -1 Failure, there are no IEs in the event to iterate */ int ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event); /*! * \brief Move iterator instance to next IE * * \param iterator The iterator instance * * \retval 0 on success * \retval -1 if end is reached */ int ast_event_iterator_next(struct ast_event_iterator *iterator); /*! * \brief Get the type of the current IE in the iterator instance * * \param iterator The iterator instance * * \return the ie type as represented by one of the value sin the * ast_event_ie_type enum */ enum ast_event_ie_type ast_event_iterator_get_ie_type(struct ast_event_iterator *iterator); /*! * \brief Get the value of the current IE in the iterator as an integer payload * * \param iterator The iterator instance * * \return This returns the payload of the information element as a uint. */ uint32_t ast_event_iterator_get_ie_uint(struct ast_event_iterator *iterator); /*! * \brief Get the value of the current IE in the iterator as a bitflags payload * * \param iterator The iterator instance * * \return This returns the payload of the information element as bitflags. */ uint32_t ast_event_iterator_get_ie_bitflags(struct ast_event_iterator *iterator); /*! * \brief Get the value of the current IE in the iterator as a string payload * * \param iterator The iterator instance * * \return This returns the payload of the information element as a string. */ const char *ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator); /*! * \brief Get the value of the current IE in the iterator instance that has a raw payload * * \param iterator The iterator instance * * \return This returns the payload of the information element as type raw. */ void *ast_event_iterator_get_ie_raw(struct ast_event_iterator *iterator); /*! * \brief Get the length of the raw payload for the current IE for an iterator * * \param iterator The IE iterator * * \return The payload length of the current IE */ uint16_t ast_event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator); /*! * \brief Get the minimum length of an ast_event. * * \return minimum amount of memory that will be consumed by any ast_event. */ size_t ast_event_minimum_length(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* AST_EVENT_H */ asterisk-11.7.0/include/asterisk/dundi.h0000644000175000007640000002240411114301223020057 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Distributed Universal Number Discovery (DUNDi) * See also \arg \ref AstDUNDi */ #ifndef _ASTERISK_DUNDI_H #define _ASTERISK_DUNDI_H #include "asterisk/channel.h" #include "asterisk/utils.h" #define DUNDI_PORT 4520 typedef struct ast_eid dundi_eid; struct dundi_hdr { unsigned short strans; /*!< Source transaction */ unsigned short dtrans; /*!< Destination transaction */ unsigned char iseqno; /*!< Next expected incoming sequence number */ unsigned char oseqno; /*!< Outgoing sequence number */ unsigned char cmdresp; /*!< Command / Response */ unsigned char cmdflags; /*!< Command / Response specific flags*/ unsigned char ies[0]; } __attribute__((__packed__)); struct dundi_ie_hdr { unsigned char ie; unsigned char len; unsigned char iedata[0]; } __attribute__((__packed__)); #define DUNDI_FLAG_RETRANS (1 << 16) /*!< Applies to dtrans */ #define DUNDI_FLAG_RESERVED (1 << 16) /*!< Applies to strans */ enum { /*! No answer yet */ DUNDI_PROTO_NONE = 0, /*! IAX, version 2 */ DUNDI_PROTO_IAX = 1, /*! SIP - Session Initiation Protocol, RFC 3261 */ DUNDI_PROTO_SIP = 2, /*! ITU H.323 */ DUNDI_PROTO_H323 = 3, }; enum { /*! Isn't and can't be a valid number */ DUNDI_FLAG_NONEXISTENT = (0), /*! Is a valid number */ DUNDI_FLAG_EXISTS = (1 << 0), /*! Might be valid if you add more digits */ DUNDI_FLAG_MATCHMORE = (1 << 1), /*! Might be a match */ DUNDI_FLAG_CANMATCH = (1 << 2), /*! Keep dialtone */ DUNDI_FLAG_IGNOREPAT = (1 << 3), /*! Destination known to be residential */ DUNDI_FLAG_RESIDENTIAL = (1 << 4), /*! Destination known to be commercial */ DUNDI_FLAG_COMMERCIAL = (1 << 5), /*! Destination known to be cellular/mobile */ DUNDI_FLAG_MOBILE = (1 << 6), /*! No unsolicited calls of any kind through this route */ DUNDI_FLAG_NOUNSOLICITED = (1 << 7), /*! No commercial unsolicited calls through this route */ DUNDI_FLAG_NOCOMUNSOLICIT = (1 << 8), }; enum { DUNDI_HINT_NONE = (0), /*! TTL Expired */ DUNDI_HINT_TTL_EXPIRED = (1 << 0), /*! Don't ask for anything beginning with data */ DUNDI_HINT_DONT_ASK = (1 << 1), /*! Answer not affected by entity list */ DUNDI_HINT_UNAFFECTED = (1 << 2), }; struct dundi_encblock { /*!< AES-128 encrypted block */ unsigned char iv[16]; /*!< Initialization vector of random data */ unsigned char encdata[0]; /*!< Encrypted / compressed data */ } __attribute__((__packed__)); struct dundi_answer { dundi_eid eid; /*!< Original source of answer */ unsigned char protocol; /*!< Protocol (DUNDI_PROTO_*) */ unsigned short flags; /*!< Flags relating to answer */ unsigned short weight; /*!< Weight of answers */ unsigned char data[0]; /*!< Protocol specific URI */ } __attribute__((__packed__)); struct dundi_hint { unsigned short flags; /*!< Flags relating to answer */ unsigned char data[0]; /*!< For data for hint */ } __attribute__((__packed__)); enum { /*! Success */ DUNDI_CAUSE_SUCCESS = 0, /*! General unspecified failure */ DUNDI_CAUSE_GENERAL = 1, /*! Requested entity is dynamic */ DUNDI_CAUSE_DYNAMIC = 2, /*! No or improper authorization */ DUNDI_CAUSE_NOAUTH = 3, /*! Duplicate request */ DUNDI_CAUSE_DUPLICATE = 4, /*! Expired TTL */ DUNDI_CAUSE_TTL_EXPIRED = 5, /*! Need new session key to decode */ DUNDI_CAUSE_NEEDKEY = 6, /*! Badly encrypted data */ DUNDI_CAUSE_BADENCRYPT = 7, }; struct dundi_cause { unsigned char causecode; /*!< Numerical cause (DUNDI_CAUSE_*) */ char desc[0]; /*!< Textual description */ } __attribute__((__packed__)); struct dundi_peer_status { unsigned int flags; unsigned short netlag; unsigned short querylag; dundi_eid peereid; } __attribute__((__packed__)); enum { DUNDI_PEER_PRIMARY = (1 << 0), DUNDI_PEER_SECONDARY = (1 << 1), DUNDI_PEER_UNAVAILABLE = (1 << 2), DUNDI_PEER_REGISTERED = (1 << 3), DUNDI_PEER_MOD_OUTBOUND = (1 << 4), DUNDI_PEER_MOD_INBOUND = (1 << 5), DUNDI_PEER_PCMOD_OUTBOUND = (1 << 6), DUNDI_PEER_PCMOD_INBOUND = (1 << 7), }; #define DUNDI_COMMAND_FINAL (0x80) /*!< Or'd with other flags */ #define DUNDI_COMMAND_ACK (0 | 0x40) /*!< Ack a message */ #define DUNDI_COMMAND_DPDISCOVER 1 /*!< Request discovery */ #define DUNDI_COMMAND_DPRESPONSE (2 | 0x40) /*!< Respond to a discovery request */ #define DUNDI_COMMAND_EIDQUERY 3 /*!< Request information for a peer */ #define DUNDI_COMMAND_EIDRESPONSE (4 | 0x40) /*!< Response to a peer query */ #define DUNDI_COMMAND_PRECACHERQ 5 /*!< Pre-cache Request */ #define DUNDI_COMMAND_PRECACHERP (6 | 0x40) /*!< Pre-cache Response */ #define DUNDI_COMMAND_INVALID (7 | 0x40) /*!< Invalid dialog state (does not require ack) */ #define DUNDI_COMMAND_UNKNOWN (8 | 0x40) /*!< Unknown command */ #define DUNDI_COMMAND_NULL 9 /*!< No-op */ #define DUNDI_COMMAND_REGREQ (10) /*!< Register Request */ #define DUNDI_COMMAND_REGRESPONSE (11 | 0x40) /*!< Register Response */ #define DUNDI_COMMAND_CANCEL (12) /*!< Cancel transaction entirely */ #define DUNDI_COMMAND_ENCRYPT (13) /*!< Send an encrypted message */ #define DUNDI_COMMAND_ENCREJ (14 | 0x40) /*!< Reject an encrypted message */ #define DUNDI_COMMAND_STATUS 15 /*!< Status command */ /* * Remember that some information elements may occur * more than one time within a message */ #define DUNDI_IE_EID 1 /*!< Entity identifier (dundi_eid) */ #define DUNDI_IE_CALLED_CONTEXT 2 /*!< DUNDi Context (string) */ #define DUNDI_IE_CALLED_NUMBER 3 /*!< Number of equivalent (string) */ #define DUNDI_IE_EID_DIRECT 4 /*!< Entity identifier (dundi_eid), direct connect */ #define DUNDI_IE_ANSWER 5 /*!< An answer (struct dundi_answer) */ #define DUNDI_IE_TTL 6 /*!< Max TTL for this request / Remaining TTL for the response (short)*/ #define DUNDI_IE_VERSION 10 /*!< DUNDi version (should be 1) (short) */ #define DUNDI_IE_EXPIRATION 11 /*!< Recommended expiration (short) */ #define DUNDI_IE_UNKNOWN 12 /*!< Unknown command (byte) */ #define DUNDI_IE_CAUSE 14 /*!< Success or cause of failure */ #define DUNDI_IE_REQEID 15 /*!< EID being requested for EIDQUERY*/ #define DUNDI_IE_ENCDATA 16 /*!< AES-128 encrypted data */ #define DUNDI_IE_SHAREDKEY 17 /*!< RSA encrypted AES-128 key */ #define DUNDI_IE_SIGNATURE 18 /*!< RSA Signature of encrypted shared key */ #define DUNDI_IE_KEYCRC32 19 /*!< CRC32 of encrypted key (int) */ #define DUNDI_IE_HINT 20 /*!< Answer hints */ #define DUNDI_IE_DEPARTMENT 21 /*!< Department, for EIDQUERY (string) */ #define DUNDI_IE_ORGANIZATION 22 /*!< Organization, for EIDQUERY (string) */ #define DUNDI_IE_LOCALITY 23 /*!< City/Locality, for EIDQUERY (string) */ #define DUNDI_IE_STATE_PROV 24 /*!< State/Province, for EIDQUERY (string) */ #define DUNDI_IE_COUNTRY 25 /*!< Country, for EIDQUERY (string) */ #define DUNDI_IE_EMAIL 26 /*!< E-mail addy, for EIDQUERY (string) */ #define DUNDI_IE_PHONE 27 /*!< Contact Phone, for EIDQUERY (string) */ #define DUNDI_IE_IPADDR 28 /*!< IP Address, for EIDQUERY (string) */ #define DUNDI_IE_CACHEBYPASS 29 /*!< Bypass cache (empty) */ #define DUNDI_IE_PEERSTATUS 30 /*!< Peer/peer status (struct dundi_peer_status) */ #define DUNDI_FLUFF_TIME 2000 /*!< Amount of time for answer */ #define DUNDI_TTL_TIME 200 /*!< Incremental average time */ #define DUNDI_DEFAULT_RETRANS 5 #define DUNDI_DEFAULT_RETRANS_TIMER 1000 #define DUNDI_DEFAULT_TTL 120 /*!< In seconds/hops like TTL */ #define DUNDI_DEFAULT_VERSION 1 #define DUNDI_DEFAULT_CACHE_TIME 3600 /*!< In seconds */ #define DUNDI_DEFAULT_KEY_EXPIRE 3600 /*!< Life of shared key In seconds */ #define DUNDI_DEF_EMPTY_CACHE_TIME 60 /*!< In seconds, cache of empty answer */ #define DUNDI_WINDOW 1 /*!< Max 1 message in window */ #define DEFAULT_MAXMS 2000 struct dundi_result { unsigned int flags; int weight; int expiration; int techint; dundi_eid eid; char eid_str[20]; char tech[10]; char dest[256]; }; struct dundi_entity_info { char country[80]; char stateprov[80]; char locality[80]; char org[80]; char orgunit[80]; char email[80]; char phone[80]; char ipaddr[80]; }; /*! * \brief Lookup the given number in the given dundi context. * Lookup number in a given dundi context (if unspecified use e164), the given callerid (if specified) * and return up to maxret results in the array specified. * \retval the number of results found. * \retval -1 on a hangup of the channel. */ int dundi_lookup(struct dundi_result *result, int maxret, struct ast_channel *chan, const char *dcontext, const char *number, int nocache); /*! \brief Retrieve information on a specific EID */ int dundi_query_eid(struct dundi_entity_info *dei, const char *dcontext, dundi_eid eid); /*! \brief Pre-cache to push upstream peers */ int dundi_precache(const char *dcontext, const char *number); #endif /* _ASTERISK_DUNDI_H */ asterisk-11.7.0/include/asterisk/devicestate.h0000644000175000007640000002147612071073763021306 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Device state management * * To subscribe to device state changes, use the generic ast_event_subscribe * method. For an example, see apps/app_queue.c. * * \todo Currently, when the state of a device changes, the device state provider * calls one of the functions defined here to queue an object to say that the * state of a device has changed. However, this does not include the new state. * Another thread processes these device state change objects and calls the * device state provider's callback to figure out what the new state is. It * would make a lot more sense for the new state to be included in the original * function call that says the state of a device has changed. However, it * will take a lot of work to change this. * * \arg See \ref AstExtState */ #ifndef _ASTERISK_DEVICESTATE_H #define _ASTERISK_DEVICESTATE_H #include "asterisk/channelstate.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief Device States * \note The order of these states may not change because they are included * in Asterisk events which may be transmitted across the network to * other servers. */ enum ast_device_state { AST_DEVICE_UNKNOWN, /*!< Device is valid but channel didn't know state */ AST_DEVICE_NOT_INUSE, /*!< Device is not used */ AST_DEVICE_INUSE, /*!< Device is in use */ AST_DEVICE_BUSY, /*!< Device is busy */ AST_DEVICE_INVALID, /*!< Device is invalid */ AST_DEVICE_UNAVAILABLE, /*!< Device is unavailable */ AST_DEVICE_RINGING, /*!< Device is ringing */ AST_DEVICE_RINGINUSE, /*!< Device is ringing *and* in use */ AST_DEVICE_ONHOLD, /*!< Device is on hold */ AST_DEVICE_TOTAL, /*/ Total num of device states, used for testing */ }; /*! \brief Device State Cachability * \note This is used to define the cachability of a device state when set. */ enum ast_devstate_cache { AST_DEVSTATE_NOT_CACHABLE, /*!< This device state is not cachable */ AST_DEVSTATE_CACHABLE, /*!< This device state is cachable */ }; /*! \brief Devicestate provider call back */ typedef enum ast_device_state (*ast_devstate_prov_cb_type)(const char *data); /*! * \brief Convert channel state to devicestate * * \param chanstate Current channel state * \since 1.6.1 */ enum ast_device_state ast_state_chan2dev(enum ast_channel_state chanstate); /*! * \brief Convert device state to text string for output * * \param devstate Current device state */ const char *devstate2str(enum ast_device_state devstate) attribute_pure __attribute__((deprecated)); const char *ast_devstate2str(enum ast_device_state devstate) attribute_pure; /*! * \brief Convert device state to text string that is easier to parse * * \param devstate Current device state */ const char *ast_devstate_str(enum ast_device_state devstate) attribute_pure; /*! * \brief Convert device state from text to integer value * * \param val The text representing the device state. Valid values are anything * that comes after AST_DEVICE_ in one of the defined values. * * \return The AST_DEVICE_ integer value */ enum ast_device_state ast_devstate_val(const char *val); /*! * \brief Search the Channels by Name * * \param device like a dial string * * Search the Device in active channels by compare the channel name against * the device name. Compared are only the first chars to the first '-' char. * * \retval AST_DEVICE_UNKNOWN if no channel found * \retval AST_DEVICE_INUSE if a channel is found */ enum ast_device_state ast_parse_device_state(const char *device); /*! * \brief Asks a channel for device state * * \param device like a dial string * * Asks a channel for device state, data is normally a number from a dial string * used by the low level module * Tries the channel device state callback if not supported search in the * active channels list for the device. * * \retval an AST_DEVICE_??? state * \retval -1 on failure */ enum ast_device_state ast_device_state(const char *device); /*! * \brief Tells Asterisk the State for Device is changed * * \param state the new state of the device * \param cachable whether this device state is cachable * \param fmt device name like a dial string with format parameters * * The new state of the device will be sent off to any subscribers * of device states. It will also be stored in the internal event * cache. * * \retval 0 on success * \retval -1 on failure */ int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt, ...) __attribute__((format(printf, 3, 4))); /*! * \brief Tells Asterisk the State for Device is changed * * \param state the new state of the device * \param cachable whether this device state is cachable * \param device device name like a dial string with format parameters * * The new state of the device will be sent off to any subscribers * of device states. It will also be stored in the internal event * cache. * * \retval 0 on success * \retval -1 on failure */ int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device); /*! * \brief Tells Asterisk the State for Device is changed. * (Accept change notification, add it to change queue.) * * \param fmt device name like a dial string with format parameters * * Asterisk polls the new extension states and calls the registered * callbacks for the changed extensions * * \retval 0 on success * \retval -1 on failure * * \note This is deprecated in favor of ast_devstate_changed() * \version 1.6.1 deprecated */ int ast_device_state_changed(const char *fmt, ...) __attribute__((deprecated,format(printf, 1, 2))); /*! * \brief Tells Asterisk the State for Device is changed * * \param device device name like a dial string * * Asterisk polls the new extension states and calls the registered * callbacks for the changed extensions * * \retval 0 on success * \retval -1 on failure * * \note This is deprecated in favor of ast_devstate_changed_literal() * \version 1.6.1 deprecated */ int ast_device_state_changed_literal(const char *device) __attribute__((deprecated)); /*! * \brief Add device state provider * * \param label to use in hint, like label:object * \param callback Callback * * \retval 0 success * \retval -1 failure */ int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback); /*! * \brief Remove device state provider * * \param label to use in hint, like label:object * * \retval -1 on failure * \retval 0 on success */ int ast_devstate_prov_del(const char *label); /*! * \brief An object to hold state when calculating aggregate device state */ struct ast_devstate_aggregate; /*! * \brief Initialize aggregate device state * * \param[in] agg the state object * * \return nothing * \since 1.6.1 */ void ast_devstate_aggregate_init(struct ast_devstate_aggregate *agg); /*! * \brief Add a device state to the aggregate device state * * \param[in] agg the state object * \param[in] state the state to add * * \return nothing * \since 1.6.1 */ void ast_devstate_aggregate_add(struct ast_devstate_aggregate *agg, enum ast_device_state state); /*! * \brief Get the aggregate device state result * * \param[in] agg the state object * * \return the aggregate device state after adding some number of device states. * \since 1.6.1 */ enum ast_device_state ast_devstate_aggregate_result(struct ast_devstate_aggregate *agg); /*! * \brief You shouldn't care about the contents of this struct * * This struct is only here so that it can be easily declared on the stack. */ struct ast_devstate_aggregate { unsigned int ringing:1; unsigned int inuse:1; enum ast_device_state state; }; /*! * \brief Enable distributed device state processing. * * \details * By default, Asterisk assumes that device state change events will only be * originating from one instance. If a module gets loaded and configured such * that multiple instances of Asterisk will be sharing device state, this * function should be called to enable distributed device state processing. * It is off by default to save on unnecessary processing. * * \retval 0 success * \retval -1 failure */ int ast_enable_distributed_devstate(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_DEVICESTATE_H */ asterisk-11.7.0/include/asterisk/res_srtp.h0000644000175000007640000000510611721724153020634 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010 FIXME * * 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 SRTP resource */ #ifndef _ASTERISK_RES_SRTP_H #define _ASTERISK_RES_SRTP_H struct ast_srtp; struct ast_srtp_policy; struct ast_rtp_instance; struct ast_srtp_cb { int (*no_ctx)(struct ast_rtp_instance *rtp, unsigned long ssrc, void *data); }; struct ast_srtp_res { /*! Create a new SRTP session for an RTP instance with a default policy */ int (*create)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy); /* Replace an existing SRTP session with a new session, along with a new default policy */ int (*replace)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy); /*! Destroy an SRTP session, along with all associated policies */ void (*destroy)(struct ast_srtp *srtp); /* Add a new stream to an existing SRTP session. Note that the policy cannot be for a wildcard SSRC */ int (*add_stream)(struct ast_srtp *srtp, struct ast_srtp_policy *policy); /* Change the source on an existing SRTP session. */ int (*change_source)(struct ast_srtp *srtp, unsigned int from_ssrc, unsigned int to_ssrc); /* Set a callback function */ void (*set_cb)(struct ast_srtp *srtp, const struct ast_srtp_cb *cb, void *data); /* Unprotect SRTP data */ int (*unprotect)(struct ast_srtp *srtp, void *buf, int *size, int rtcp); /* Protect RTP data */ int (*protect)(struct ast_srtp *srtp, void **buf, int *size, int rtcp); /* Obtain a random cryptographic key */ int (*get_random)(unsigned char *key, size_t len); }; /* Crypto suites */ enum ast_srtp_suite { AST_AES_CM_128_HMAC_SHA1_80 = 1, AST_AES_CM_128_HMAC_SHA1_32 = 2, AST_F8_128_HMAC_SHA1_80 = 3 }; struct ast_srtp_policy_res { struct ast_srtp_policy *(*alloc)(void); void (*destroy)(struct ast_srtp_policy *policy); int (*set_suite)(struct ast_srtp_policy *policy, enum ast_srtp_suite suite); int (*set_master_key)(struct ast_srtp_policy *policy, const unsigned char *key, size_t key_len, const unsigned char *salt, size_t salt_len); void (*set_ssrc)(struct ast_srtp_policy *policy, unsigned long ssrc, int inbound); }; #endif /* _ASTERISK_RES_SRTP_H */ asterisk-11.7.0/include/asterisk/calendar.h0000644000175000007640000001712011721256243020543 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008 - 2009, Digium, Inc. * * Terry Wilson * * 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. */ #ifndef _ASTERISK_CALENDAR_H #define _ASTERISK_CALENDAR_H #include "asterisk.h" #include "asterisk/stringfields.h" #include "asterisk/config.h" #include "asterisk/linkedlists.h" #include "asterisk/lock.h" #include "asterisk/dial.h" #include "asterisk/module.h" /*! \file calendar.h * \brief A general API for managing calendar events with Asterisk * * \author Terry Wilson * * \note This API implements an abstraction for handling different calendaring * technologies in Asterisk. The services provided by the API are a dialplan * function to query whether or not a calendar is busy at the present time, a * adialplan function to query specific information about events in a time range, * a devicestate provider, and notification of calendar events through execution * of dialplan apps or dialplan logic at a specific context and extension. The * information available through the CALENDAR_EVENT() dialplan function are: * * SUMMARY, DESCRIPTION, ORGANIZER, LOCATION * CALENDAR, UID, START, END, and BUSYSTATE * * BUSYSTATE can have the values 0 (free), 1 (tentatively busy), or 2 (busy) * * Usage * All calendaring configuration data is located in calendar.conf and is only read * directly by the Calendaring API. Each calendar technology resource must register * a load_calendar callback which will be passed an ast_calendar_load_data structure. * The load_calendar callback function should then set the values it needs from this * cfg, load the calendar data, and then loop updating the calendar data and events * baesd on the refresh interval in the ast_calendar object. Each call to * the load_calendar callback will be will run in its own thread. * * Updating events involves creating an astobj2 container of new events and passing * it to the API through ast_calendar_merge_events. * * Calendar technology resource modules must also register an unref_calendar callback * which will only be called when the resource module calls ast_calendar_unregister() * to unregister that module's calendar type (usually done in module_unload()) */ struct ast_calendar; struct ast_calendar_event; /*! \brief Individual calendaring technology data */ struct ast_calendar_tech { const char *type; const char *description; const char *module; struct ast_module_user *user; int (* is_busy)(struct ast_calendar *calendar); /*!< Override default busy determination */ void *(* load_calendar)(void *data); /*!< Create private structure, add calendar events, etc. */ void *(* unref_calendar)(void *obj); /*!< Function to be called to free the private structure */ int (* write_event)(struct ast_calendar_event *event); /*!< Function for writing an event to the calendar */ AST_LIST_ENTRY(ast_calendar_tech) list; }; enum ast_calendar_busy_state { AST_CALENDAR_BS_FREE = 0, AST_CALENDAR_BS_BUSY_TENTATIVE, AST_CALENDAR_BS_BUSY, }; struct ast_calendar_attendee { char *data; AST_LIST_ENTRY(ast_calendar_attendee) next; }; /* \brief Calendar events */ struct ast_calendar_event { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(summary); AST_STRING_FIELD(description); AST_STRING_FIELD(organizer); AST_STRING_FIELD(location); AST_STRING_FIELD(uid); AST_STRING_FIELD(categories); ); int priority; /*!< Priority of event */ struct ast_calendar *owner; /*!< The calendar that owns this event */ time_t start; /*!< Start of event (UTC) */ time_t end; /*!< End of event (UTC) */ time_t alarm; /*!< Time for event notification */ enum ast_calendar_busy_state busy_state; /*!< The busy status of the event */ int notify_sched; /*!< The sched for event notification */ int bs_start_sched; /*!< The sched for changing the device state at the start of an event */ int bs_end_sched; /*!< The sched for changing the device state at the end of an event */ struct ast_dial *dial; struct ast_channel *notify_chan; AST_LIST_HEAD_NOLOCK(attendees, ast_calendar_attendee) attendees; }; /*! \brief Asterisk calendar structure */ struct ast_calendar { const struct ast_calendar_tech *tech; void *tech_pvt; AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(name); /*!< Name from config file [name] */ AST_STRING_FIELD(notify_channel); /*!< Channel to use for notification */ AST_STRING_FIELD(notify_context); /*!< Optional context to execute from for notification */ AST_STRING_FIELD(notify_extension); /*!< Optional extension to execute from for notification */ AST_STRING_FIELD(notify_app); /*!< Optional dialplan app to execute for notification */ AST_STRING_FIELD(notify_appdata); /*!< Optional arguments for dialplan app */ ); struct ast_variable *vars; /*!< Channel variables to pass to notification channel */ int autoreminder; /*!< If set, override any calendar_tech specific notification times and use this time (in mins) */ int notify_waittime; /*!< Maxiumum time to allow for a notification attempt */ int refresh; /*!< When to refresh the calendar events */ int timeframe; /*!< Span (in mins) of calendar data to pull with each request */ pthread_t thread; /*!< The thread that the calendar is loaded/updated in */ ast_cond_t unload; int unloading:1; int pending_deletion:1; struct ao2_container *events; /*!< The events that are known at this time */ }; /*! \brief Register a new calendar technology * * \param tech calendar technology to register * * \retval 0 success * \retval -1 failure */ int ast_calendar_register(struct ast_calendar_tech *tech); /*! \brief Unregister a new calendar technology * * \param tech calendar technology to unregister * * \retval 0 success * \retval -1 failure */ void ast_calendar_unregister(struct ast_calendar_tech *tech); /*! \brief Allocate an astobj2 ast_calendar_event object * * \param cal calendar to allocate an event for * * \return a new, initialized calendar event */ struct ast_calendar_event *ast_calendar_event_alloc(struct ast_calendar *cal); /*! \brief Allocate an astobj2 container for ast_calendar_event objects * * \return a new event container */ struct ao2_container *ast_calendar_event_container_alloc(void); /*! \brief Add an event to the list of events for a calendar * * \param cal calendar containing the events to be merged * \param new_events an oa2 container of events to be merged into cal->events */ void ast_calendar_merge_events(struct ast_calendar *cal, struct ao2_container *new_events); /*! \brief Unreference an ast_calendar_event * * \param event event to unref * * \return NULL */ struct ast_calendar_event *ast_calendar_unref_event(struct ast_calendar_event *event); /*! \brief Remove all events from calendar * * \param cal calendar whose events need to be cleared */ void ast_calendar_clear_events(struct ast_calendar *cal); /*! \brief Grab and lock pointer to the calendar config (read only) * * \note ast_calendar_config_release must be called when finished with the pointer * * \return the parsed calendar config */ const struct ast_config *ast_calendar_config_acquire(void); /*! \brief Release the calendar config */ void ast_calendar_config_release(void); #endif /* _ASTERISK_CALENDAR_H */ asterisk-11.7.0/include/asterisk/astobj2.h0000644000175000007640000016627312144504275020355 0ustar sharkyjerryweb/* * astobj2 - replacement containers for asterisk data structures. * * Copyright (C) 2006 Marta Carbone, Luigi Rizzo - Univ. di Pisa, Italy * * 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. */ #ifndef _ASTERISK_ASTOBJ2_H #define _ASTERISK_ASTOBJ2_H #include "asterisk/compat.h" #include "asterisk/lock.h" /*! \file * \ref AstObj2 * * \page AstObj2 Object Model implementing objects and containers. This module implements an abstraction for objects (with locks and reference counts), and containers for these user-defined objects, also supporting locking, reference counting and callbacks. The internal implementation of objects and containers is opaque to the user, so we can use different data structures as needs arise. \section AstObj2_UsageObjects USAGE - OBJECTS An ao2 object is a block of memory that the user code can access, and for which the system keeps track (with a bit of help from the programmer) of the number of references around. When an object has no more references (refcount == 0), it is destroyed, by first invoking whatever 'destructor' function the programmer specifies (it can be NULL if none is necessary), and then freeing the memory. This way objects can be shared without worrying who is in charge of freeing them. As an additional feature, ao2 objects are associated to individual locks. Creating an object requires the size of the object and a pointer to the destructor function: struct foo *o; o = ao2_alloc(sizeof(struct foo), my_destructor_fn); The value returned points to the user-visible portion of the objects (user-data), but is also used as an identifier for all object-related operations such as refcount and lock manipulations. On return from ao2_alloc(): - the object has a refcount = 1; - the memory for the object is allocated dynamically and zeroed; - we cannot realloc() the object itself; - we cannot call free(o) to dispose of the object. Rather, we tell the system that we do not need the reference anymore: ao2_ref(o, -1) causing the destructor to be called (and then memory freed) when the refcount goes to 0. - ao2_ref(o, +1) can be used to modify the refcount on the object in case we want to pass it around. - ao2_lock(obj), ao2_unlock(obj), ao2_trylock(obj) can be used to manipulate the lock associated with the object. \section AstObj2_UsageContainers USAGE - CONTAINERS An ao2 container is an abstract data structure where we can store ao2 objects, search them (hopefully in an efficient way), and iterate or apply a callback function to them. A container is just an ao2 object itself. A container must first be allocated, specifying the initial parameters. At the moment, this is done as follows: Sample Usage: \code struct ao2_container *c; c = ao2_container_alloc(MAX_BUCKETS, my_hash_fn, my_cmp_fn); \endcode where - MAX_BUCKETS is the number of buckets in the hash table, - my_hash_fn() is the (user-supplied) function that returns a hash key for the object (further reduced modulo MAX_BUCKETS by the container's code); - my_cmp_fn() is the default comparison function used when doing searches on the container, A container knows little or nothing about the objects it stores, other than the fact that they have been created by ao2_alloc(). All knowledge of the (user-defined) internals of the objects is left to the (user-supplied) functions passed as arguments to ao2_container_alloc(). If we want to insert an object in a container, we should initialize its fields -- especially, those used by my_hash_fn() -- to compute the bucket to use. Once done, we can link an object to a container with ao2_link(c, o); The function returns NULL in case of errors (and the object is not inserted in the container). Other values mean success (we are not supposed to use the value as a pointer to anything). Linking an object to a container increases its refcount by 1 automatically. \note While an object o is in a container, we expect that my_hash_fn(o) will always return the same value. The function does not lock the object to be computed, so modifications of those fields that affect the computation of the hash should be done by extracting the object from the container, and re-inserting it after the change (this is not terribly expensive). \note A container with a single buckets is effectively a linked list. However there is no ordering among elements. - \ref AstObj2_Containers - \ref astobj2.h All documentation for functions and data structures */ /* \note DEBUGGING REF COUNTS BIBLE: An interface to help debug refcounting is provided in this package. It is dependent on the REF_DEBUG macro being defined in a source file, before the #include of astobj2.h, and in using variants of the normal ao2_xxx functions that are named ao2_t_xxx instead, with an extra argument, a string, that will be printed out into /tmp/refs when the refcount for an object is changed. these ao2_t_xxx variants are provided: ao2_t_alloc(arg1, arg2, arg3) ao2_t_ref(arg1,arg2,arg3) ao2_t_container_alloc(arg1,arg2,arg3,arg4) ao2_t_link(arg1, arg2, arg3) ao2_t_unlink(arg1, arg2, arg3) ao2_t_callback(arg1,arg2,arg3,arg4,arg5) ao2_t_find(arg1,arg2,arg3,arg4) ao2_t_iterator_next(arg1, arg2) If you study each argument list, you will see that these functions all have one extra argument than their ao2_xxx counterpart. The last argument in each case is supposed to be a string pointer, a "tag", that should contain enough of an explanation, that you can pair operations that increment the ref count, with operations that are meant to decrement the refcount. Each of these calls will generate at least one line of output in /tmp/refs. These lines look like this: ... 0x8756f00 =1 chan_sip.c:22240:load_module (allocate users) 0x86e3408 =1 chan_sip.c:22241:load_module (allocate peers) 0x86dd380 =1 chan_sip.c:22242:load_module (allocate peers_by_ip) 0x822d020 =1 chan_sip.c:22243:load_module (allocate dialogs) 0x8930fd8 =1 chan_sip.c:20025:build_peer (allocate a peer struct) 0x8930fd8 +1 chan_sip.c:21467:reload_config (link peer into peer table) [@1] 0x8930fd8 -1 chan_sip.c:2370:unref_peer (unref_peer: from reload_config) [@2] 0x89318b0 =1 chan_sip.c:20025:build_peer (allocate a peer struct) 0x89318b0 +1 chan_sip.c:21467:reload_config (link peer into peer table) [@1] 0x89318b0 -1 chan_sip.c:2370:unref_peer (unref_peer: from reload_config) [@2] 0x8930218 =1 chan_sip.c:20025:build_peer (allocate a peer struct) 0x8930218 +1 chan_sip.c:21539:reload_config (link peer into peers table) [@1] 0x868c040 -1 chan_sip.c:2424:dialog_unlink_all (unset the relatedpeer->call field in tandem with relatedpeer field itself) [@2] 0x868c040 -1 chan_sip.c:2443:dialog_unlink_all (Let's unbump the count in the unlink so the poor pvt can disappear if it is time) [@1] 0x868c040 **call destructor** chan_sip.c:2443:dialog_unlink_all (Let's unbump the count in the unlink so the poor pvt can disappear if it is time) 0x8cc07e8 -1 chan_sip.c:2370:unref_peer (unsetting a dialog relatedpeer field in sip_destroy) [@3] 0x8cc07e8 +1 chan_sip.c:3876:find_peer (ao2_find in peers table) [@2] 0x8cc07e8 -1 chan_sip.c:2370:unref_peer (unref_peer, from sip_devicestate, release ref from find_peer) [@3] ... The first column is the object address. The second column reflects how the operation affected the ref count for that object. Creation sets the ref count to 1 (=1). increment or decrement and amount are specified (-1/+1). The remainder of the line specifies where in the file the call was made, and the function name, and the tag supplied in the function call. The **call destructor** is specified when the destroy routine is run for an object. It does not affect the ref count, but is important in debugging, because it is possible to have the astobj2 system run it multiple times on the same object, commonly fatal to asterisk. Sometimes you have some helper functions to do object ref/unref operations. Using these normally hides the place where these functions were called. To get the location where these functions were called to appear in /tmp/refs, you can do this sort of thing: #ifdef REF_DEBUG #define dialog_ref(arg1,arg2) dialog_ref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define dialog_unref(arg1,arg2) dialog_unref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__) static struct sip_pvt *dialog_ref_debug(struct sip_pvt *p, const char *tag, const char *file, int line, const char *func) { if (p) { ao2_ref_debug(p, 1, tag, file, line, func); } else { ast_log(LOG_ERROR, "Attempt to Ref a null pointer\n"); } return p; } static struct sip_pvt *dialog_unref_debug(struct sip_pvt *p, const char *tag, const char *file, int line, const char *func) { if (p) { ao2_ref_debug(p, -1, tag, file, line, func); } return NULL; } #else static struct sip_pvt *dialog_ref(struct sip_pvt *p, const char *tag) { if (p) { ao2_ref(p, 1); } else { ast_log(LOG_ERROR, "Attempt to Ref a null pointer\n"); } return p; } static struct sip_pvt *dialog_unref(struct sip_pvt *p, const char *tag) { if (p) { ao2_ref(p, -1); } return NULL; } #endif In the above code, note that the "normal" helper funcs call ao2_ref() as normal, and the "helper" functions call ao2_ref_debug directly with the file, function, and line number info provided. You might find this well worth the effort to help track these function calls in the code. To find out why objects are not destroyed (a common bug), you can edit the source file to use the ao2_t_* variants, add the #define REF_DEBUG 1 before the #include "asterisk/astobj2.h" line, and add a descriptive tag to each call. Recompile, and run Asterisk, exit asterisk with "stop gracefully", which should result in every object being destroyed. Then, you can "sort -k 1 /tmp/refs > x1" to get a sorted list of all the objects, or you can use "util/refcounter" to scan the file for you and output any problems it finds. The above may seem astronomically more work than it is worth to debug reference counts, which may be true in "simple" situations, but for more complex situations, it is easily worth 100 times this effort to help find problems. To debug, pair all calls so that each call that increments the refcount is paired with a corresponding call that decrements the count for the same reason. Hopefully, you will be left with one or more unpaired calls. This is where you start your search! For instance, here is an example of this for a dialog object in chan_sip, that was not getting destroyed, after I moved the lines around to pair operations: 0x83787a0 =1 chan_sip.c:5733:sip_alloc (allocate a dialog(pvt) struct) 0x83787a0 -1 chan_sip.c:19173:sip_poke_peer (unref dialog at end of sip_poke_peer, obtained from sip_alloc, just before it goes out of scope) [@4] 0x83787a0 +1 chan_sip.c:5854:sip_alloc (link pvt into dialogs table) [@1] 0x83787a0 -1 chan_sip.c:19150:sip_poke_peer (About to change the callid -- remove the old name) [@3] 0x83787a0 +1 chan_sip.c:19152:sip_poke_peer (Linking in under new name) [@2] 0x83787a0 -1 chan_sip.c:2399:dialog_unlink_all (unlinking dialog via ao2_unlink) [@5] 0x83787a0 +1 chan_sip.c:19130:sip_poke_peer (copy sip alloc from p to peer->call) [@2] 0x83787a0 +1 chan_sip.c:2996:__sip_reliable_xmit (__sip_reliable_xmit: setting pkt->owner) [@3] 0x83787a0 -1 chan_sip.c:2425:dialog_unlink_all (remove all current packets in this dialog, and the pointer to the dialog too as part of __sip_destroy) [@4] 0x83787a0 +1 chan_sip.c:22356:unload_module (iterate thru dialogs) [@4] 0x83787a0 -1 chan_sip.c:22359:unload_module (toss dialog ptr from iterator_next) [@5] 0x83787a0 +1 chan_sip.c:22373:unload_module (iterate thru dialogs) [@3] 0x83787a0 -1 chan_sip.c:22375:unload_module (throw away iterator result) [@2] 0x83787a0 +1 chan_sip.c:2397:dialog_unlink_all (Let's bump the count in the unlink so it doesn't accidentally become dead before we are done) [@4] 0x83787a0 -1 chan_sip.c:2436:dialog_unlink_all (Let's unbump the count in the unlink so the poor pvt can disappear if it is time) [@3] As you can see, only one unbalanced operation is in the list, a ref count increment when the peer->call was set, but no corresponding decrement was made... Hopefully this helps you narrow your search and find those bugs. THE ART OF REFERENCE COUNTING (by Steve Murphy) SOME TIPS for complicated code, and ref counting: 1. Theoretically, passing a refcounted object pointer into a function call is an act of copying the reference, and could be refcounted. But, upon examination, this sort of refcounting will explode the amount of code you have to enter, and for no tangible benefit, beyond creating more possible failure points/bugs. It will even complicate your code and make debugging harder, slow down your program doing useless increments and decrements of the ref counts. 2. It is better to track places where a ref counted pointer is copied into a structure or stored. Make sure to decrement the refcount of any previous pointer that might have been there, if setting this field might erase a previous pointer. ao2_find and iterate_next internally increment the ref count when they return a pointer, so you need to decrement the count before the pointer goes out of scope. 3. Any time you decrement a ref count, it may be possible that the object will be destroyed (freed) immediately by that call. If you are destroying a series of fields in a refcounted object, and any of the unref calls might possibly result in immediate destruction, you can first increment the count to prevent such behavior, then after the last test, decrement the pointer to allow the object to be destroyed, if the refcount would be zero. Example: dialog_ref(dialog, "Let's bump the count in the unlink so it doesn't accidentally become dead before we are done"); ao2_t_unlink(dialogs, dialog, "unlinking dialog via ao2_unlink"); *//* Unlink us from the owner (channel) if we have one *//* if (dialog->owner) { if (lockowner) { ast_channel_lock(dialog->owner); } ast_debug(1, "Detaching from channel %s\n", dialog->owner->name); dialog->owner->tech_pvt = dialog_unref(dialog->owner->tech_pvt, "resetting channel dialog ptr in unlink_all"); if (lockowner) { ast_channel_unlock(dialog->owner); } } if (dialog->registry) { if (dialog->registry->call == dialog) { dialog->registry->call = dialog_unref(dialog->registry->call, "nulling out the registry's call dialog field in unlink_all"); } dialog->registry = registry_unref(dialog->registry, "delete dialog->registry"); } ... dialog_unref(dialog, "Let's unbump the count in the unlink so the poor pvt can disappear if it is time"); In the above code, the ao2_t_unlink could end up destroying the dialog object; if this happens, then the subsequent usages of the dialog pointer could result in a core dump. So, we 'bump' the count upwards before beginning, and then decrementing the count when we are finished. This is analogous to 'locking' or 'protecting' operations for a short while. 4. One of the most insidious problems I've run into when converting code to do ref counted automatic destruction, is in the destruction routines. Where a "destroy" routine had previously been called to get rid of an object in non-refcounted code, the new regime demands that you tear that "destroy" routine into two pieces, one that will tear down the links and 'unref' them, and the other to actually free and reset fields. A destroy routine that does any reference deletion for its own object, will never be called. Another insidious problem occurs in mutually referenced structures. As an example, a dialog contains a pointer to a peer, and a peer contains a pointer to a dialog. Watch out that the destruction of one doesn't depend on the destruction of the other, as in this case a dependency loop will result in neither being destroyed! Given the above, you should be ready to do a good job! murf */ /*! \brief * Typedef for an object destructor. This is called just before freeing * the memory for the object. It is passed a pointer to the user-defined * data of the object. */ typedef void (*ao2_destructor_fn)(void *); /*! \brief Options available when allocating an ao2 object. */ enum ao2_alloc_opts { /*! The ao2 object has a recursive mutex lock associated with it. */ AO2_ALLOC_OPT_LOCK_MUTEX = (0 << 0), /*! The ao2 object has a non-recursive read/write lock associated with it. */ AO2_ALLOC_OPT_LOCK_RWLOCK = (1 << 0), /*! The ao2 object has no lock associated with it. */ AO2_ALLOC_OPT_LOCK_NOLOCK = (2 << 0), /*! The ao2 object locking option field mask. */ AO2_ALLOC_OPT_LOCK_MASK = (3 << 0), }; /*! * \brief Allocate and initialize an object. * * \param data_size The sizeof() of the user-defined structure. * \param destructor_fn The destructor function (can be NULL) * \param options The ao2 object options (See enum ao2_alloc_opts) * \param debug_msg An ao2 object debug tracing message. * \return A pointer to user-data. * * \details * Allocates a struct astobj2 with sufficient space for the * user-defined structure. * \note * - storage is zeroed; XXX maybe we want a flag to enable/disable this. * - the refcount of the object just created is 1 * - the returned pointer cannot be free()'d or realloc()'ed; * rather, we just call ao2_ref(o, -1); * * @{ */ #if defined(REF_DEBUG) #define ao2_t_alloc_options(data_size, destructor_fn, options, debug_msg) \ __ao2_alloc_debug((data_size), (destructor_fn), (options), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #define ao2_alloc_options(data_size, destructor_fn, options) \ __ao2_alloc_debug((data_size), (destructor_fn), (options), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #define ao2_t_alloc(data_size, destructor_fn, debug_msg) \ __ao2_alloc_debug((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #define ao2_alloc(data_size, destructor_fn) \ __ao2_alloc_debug((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #elif defined(__AST_DEBUG_MALLOC) #define ao2_t_alloc_options(data_size, destructor_fn, options, debug_msg) \ __ao2_alloc_debug((data_size), (destructor_fn), (options), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #define ao2_alloc_options(data_size, destructor_fn, options) \ __ao2_alloc_debug((data_size), (destructor_fn), (options), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #define ao2_t_alloc(data_size, destructor_fn, debug_msg) \ __ao2_alloc_debug((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #define ao2_alloc(data_size, destructor_fn) \ __ao2_alloc_debug((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #else #define ao2_t_alloc_options(data_size, destructor_fn, options, debug_msg) \ __ao2_alloc((data_size), (destructor_fn), (options)) #define ao2_alloc_options(data_size, destructor_fn, options) \ __ao2_alloc((data_size), (destructor_fn), (options)) #define ao2_t_alloc(data_size, destructor_fn, debug_msg) \ __ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX) #define ao2_alloc(data_size, destructor_fn) \ __ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX) #endif void *__ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, const char *tag, const char *file, int line, const char *func, int ref_debug); void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options); /*! @} */ /*! \brief * Reference/unreference an object and return the old refcount. * * \param o A pointer to the object * \param delta Value to add to the reference counter. * \param tag used for debugging * \return The value of the reference counter before the operation. * * Increase/decrease the reference counter according * the value of delta. * * If the refcount goes to zero, the object is destroyed. * * \note The object must not be locked by the caller of this function, as * it is invalid to try to unlock it after releasing the reference. * * \note if we know the pointer to an object, it is because we * have a reference count to it, so the only case when the object * can go away is when we release our reference, and it is * the last one in existence. * * @{ */ #ifdef REF_DEBUG #define ao2_t_ref(o,delta,tag) __ao2_ref_debug((o), (delta), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_ref(o,delta) __ao2_ref_debug((o), (delta), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_t_ref(o,delta,tag) __ao2_ref((o), (delta)) #define ao2_ref(o,delta) __ao2_ref((o), (delta)) #endif int __ao2_ref_debug(void *o, int delta, const char *tag, const char *file, int line, const char *func); int __ao2_ref(void *o, int delta); /*! @} */ /*! \brief Which lock to request. */ enum ao2_lock_req { /*! Request the mutex lock be acquired. */ AO2_LOCK_REQ_MUTEX, /*! Request the read lock be acquired. */ AO2_LOCK_REQ_RDLOCK, /*! Request the write lock be acquired. */ AO2_LOCK_REQ_WRLOCK, }; /*! \brief * Lock an object. * * \param a A pointer to the object we want to lock. * \return 0 on success, other values on error. */ int __ao2_lock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var); #define ao2_lock(a) __ao2_lock(a, AO2_LOCK_REQ_MUTEX, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) #define ao2_rdlock(a) __ao2_lock(a, AO2_LOCK_REQ_RDLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) #define ao2_wrlock(a) __ao2_lock(a, AO2_LOCK_REQ_WRLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) /*! \brief * Unlock an object. * * \param a A pointer to the object we want unlock. * \return 0 on success, other values on error. */ int __ao2_unlock(void *a, const char *file, const char *func, int line, const char *var); #define ao2_unlock(a) __ao2_unlock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) /*! \brief * Try locking-- (don't block if fail) * * \param a A pointer to the object we want to lock. * \return 0 on success, other values on error. */ int __ao2_trylock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var); #define ao2_trylock(a) __ao2_trylock(a, AO2_LOCK_REQ_MUTEX, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) #define ao2_tryrdlock(a) __ao2_trylock(a, AO2_LOCK_REQ_RDLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) #define ao2_trywrlock(a) __ao2_trylock(a, AO2_LOCK_REQ_WRLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) /*! * \brief Return the mutex lock address of an object * * \param[in] obj A pointer to the object we want. * \return the address of the mutex lock, else NULL. * * This function comes in handy mainly for debugging locking * situations, where the locking trace code reports the * lock address, this allows you to correlate against * object address, to match objects to reported locks. * * \since 1.6.1 */ void *ao2_object_get_lockaddr(void *obj); /*! Global ao2 object holder structure. */ struct ao2_global_obj { /*! Access lock to the held ao2 object. */ ast_rwlock_t lock; /*! Global ao2 object. */ void *obj; }; /*! * \brief Define a global object holder to be used to hold an ao2 object, statically initialized. * \since 11.0 * * \param name This will be the name of the object holder. * * \details * This macro creates a global object holder that can be used to * hold an ao2 object accessible using the API. The structure is * allocated and initialized to be empty. * * Example usage: * \code * static AO2_GLOBAL_OBJ_STATIC(global_cfg); * \endcode * * This defines global_cfg, intended to hold an ao2 object * accessible using an API. */ #ifndef HAVE_PTHREAD_RWLOCK_INITIALIZER #define AO2_GLOBAL_OBJ_STATIC(name) \ struct ao2_global_obj name; \ static void __attribute__((constructor)) __init_##name(void) \ { \ ast_rwlock_init(&name.lock); \ name.obj = NULL; \ } \ static void __attribute__((destructor)) __fini_##name(void) \ { \ if (name.obj) { \ ao2_ref(name.obj, -1); \ name.obj = NULL; \ } \ ast_rwlock_destroy(&name.lock); \ } \ struct __dummy_##name #else #define AO2_GLOBAL_OBJ_STATIC(name) \ struct ao2_global_obj name = { \ .lock = AST_RWLOCK_INIT_VALUE, \ } #endif /*! * \brief Release the ao2 object held in the global holder. * \since 11.0 * * \param holder Global ao2 object holder. * \param tag used for debugging * * \return Nothing */ #ifdef REF_DEBUG #define ao2_t_global_obj_release(holder, tag) \ __ao2_global_obj_release(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_release(holder) \ __ao2_global_obj_release(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #else #define ao2_t_global_obj_release(holder, tag) \ __ao2_global_obj_release(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_release(holder) \ __ao2_global_obj_release(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #endif void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name); /*! * \brief Replace an ao2 object in the global holder. * \since 11.0 * * \param holder Global ao2 object holder. * \param obj Object to put into the holder. Can be NULL. * \param tag used for debugging * * \note This function automatically increases the reference * count to account for the reference that the global holder now * holds to the object. * * \retval Reference to previous global ao2 object stored. * \retval NULL if no object available. */ #ifdef REF_DEBUG #define ao2_t_global_obj_replace(holder, obj, tag) \ __ao2_global_obj_replace(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_replace(holder, obj) \ __ao2_global_obj_replace(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #else #define ao2_t_global_obj_replace(holder, obj, tag) \ __ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_replace(holder, obj) \ __ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #endif void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name); /*! * \brief Replace an ao2 object in the global holder, throwing away any old object. * \since 11.0 * * \param holder Global ao2 object holder. * \param obj Object to put into the holder. Can be NULL. * \param tag used for debugging * * \note This function automatically increases the reference * count to account for the reference that the global holder now * holds to the object. It also decreases the reference count * of any object being replaced. * * \retval 0 The global object was previously empty * \retval 1 The global object was not previously empty */ #ifdef REF_DEBUG #define ao2_t_global_obj_replace_unref(holder, obj, tag) \ __ao2_global_obj_replace_unref(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_replace_unref(holder, obj) \ __ao2_global_obj_replace_unref(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #else #define ao2_t_global_obj_replace_unref(holder, obj, tag) \ __ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_replace_unref(holder, obj) \ __ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #endif int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name); /*! * \brief Get a reference to the object stored in the global holder. * \since 11.0 * * \param holder Global ao2 object holder. * \param tag used for debugging * * \retval Reference to current ao2 object stored in the holder. * \retval NULL if no object available. */ #ifdef REF_DEBUG #define ao2_t_global_obj_ref(holder, tag) \ __ao2_global_obj_ref(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_ref(holder) \ __ao2_global_obj_ref(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #else #define ao2_t_global_obj_ref(holder, tag) \ __ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #define ao2_global_obj_ref(holder) \ __ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) #endif void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name); /*! \page AstObj2_Containers AstObj2 Containers Containers are data structures meant to store several objects, and perform various operations on them. Internally, objects are stored in lists, hash tables or other data structures depending on the needs. \note NOTA BENE: at the moment the only container we support is the hash table and its degenerate form, the list. Operations on container include: - c = \b ao2_container_alloc(size, hash_fn, cmp_fn) allocate a container with desired size and default compare and hash function -The compare function returns an int, which can be 0 for not found, CMP_STOP to stop end a traversal, or CMP_MATCH if they are equal -The hash function returns an int. The hash function takes two argument, the object pointer and a flags field, - \b ao2_find(c, arg, flags) returns zero or more elements matching a given criteria (specified as arg). 'c' is the container pointer. Flags can be: OBJ_UNLINK - to remove the object, once found, from the container. OBJ_NODATA - don't return the object if found (no ref count change) OBJ_MULTIPLE - don't stop at first match OBJ_POINTER - if set, 'arg' is an object pointer, and a hash table search will be done. If not, a traversal is done. OBJ_KEY - if set, 'arg', is a hashable item that is not an object. Similar to OBJ_POINTER and mutually exclusive. - \b ao2_callback(c, flags, fn, arg) apply fn(obj, arg) to all objects in the container. Similar to find. fn() can tell when to stop, and do anything with the object including unlinking it. - c is the container; - flags can be OBJ_UNLINK - to remove the object, once found, from the container. OBJ_NODATA - don't return the object if found (no ref count change) OBJ_MULTIPLE - don't stop at first match OBJ_POINTER - if set, 'arg' is an object pointer, and a hash table search will be done. If not, a traversal is done through all the hash table 'buckets'.. OBJ_KEY - if set, 'arg', is a hashable item that is not an object. Similar to OBJ_POINTER and mutually exclusive. - fn is a func that returns int, and takes 3 args: (void *obj, void *arg, int flags); obj is an object arg is the same as arg passed into ao2_callback flags is the same as flags passed into ao2_callback fn returns: 0: no match, keep going CMP_STOP: stop search, no match CMP_MATCH: This object is matched. Note that the entire operation is run with the container locked, so nobody else can change its content while we work on it. However, we pay this with the fact that doing anything blocking in the callback keeps the container blocked. The mechanism is very flexible because the callback function fn() can do basically anything e.g. counting, deleting records, etc. possibly using arg to store the results. - \b iterate on a container this is done with the following sequence \code struct ao2_container *c = ... // our container struct ao2_iterator i; void *o; i = ao2_iterator_init(c, flags); while ((o = ao2_iterator_next(&i))) { ... do something on o ... ao2_ref(o, -1); } ao2_iterator_destroy(&i); \endcode The difference with the callback is that the control on how to iterate is left to us. - \b ao2_ref(c, -1) dropping a reference to a container destroys it, very simple! Containers are ao2 objects themselves, and this is why their implementation is simple too. Before declaring containers, we need to declare the types of the arguments passed to the constructor - in turn, this requires to define callback and hash functions and their arguments. - \ref AstObj2 - \ref astobj2.h */ /*! \brief * Type of a generic callback function * \param obj pointer to the (user-defined part) of an object. * \param arg callback argument from ao2_callback() * \param flags flags from ao2_callback() * * The return values are a combination of enum _cb_results. * Callback functions are used to search or manipulate objects in a container. */ typedef int (ao2_callback_fn)(void *obj, void *arg, int flags); /*! \brief * Type of a generic callback function * \param obj pointer to the (user-defined part) of an object. * \param arg callback argument from ao2_callback() * \param data arbitrary data from ao2_callback() * \param flags flags from ao2_callback() * * The return values are a combination of enum _cb_results. * Callback functions are used to search or manipulate objects in a container. */ typedef int (ao2_callback_data_fn)(void *obj, void *arg, void *data, int flags); /*! \brief A common ao2_callback is one that matches by address. */ int ao2_match_by_addr(void *obj, void *arg, int flags); /*! \brief * A callback function will return a combination of CMP_MATCH and CMP_STOP. * The latter will terminate the search in a container. */ enum _cb_results { CMP_MATCH = 0x1, /*!< the object matches the request */ CMP_STOP = 0x2, /*!< stop the search now */ }; /*! \brief * Flags passed to ao2_callback() and ao2_hash_fn() to modify its behaviour. */ enum search_flags { /*! * Unlink the object for which the callback function returned * CMP_MATCH. */ OBJ_UNLINK = (1 << 0), /*! * On match, don't return the object hence do not increase its * refcount. */ OBJ_NODATA = (1 << 1), /*! * Don't stop at the first match in ao2_callback() unless the * result of of the callback function has the CMP_STOP bit set. */ OBJ_MULTIPLE = (1 << 2), /*! * The given obj is an object of the same type as the one being * searched for, so use the object's hash function for optimized * searching. * * The matching function is unaffected (i.e. The cb_fn argument * to ao2_callback). */ OBJ_POINTER = (1 << 3), /*! * \brief Continue if a match is not found in the hashed out bucket * * This flag is to be used in combination with OBJ_POINTER. This tells * the ao2_callback() core to keep searching through the rest of the * buckets if a match is not found in the starting bucket defined by * the hash value on the argument. */ OBJ_CONTINUE = (1 << 4), /*! * \brief Assume that the ao2_container is already locked. * * \note For ao2_containers that have mutexes, no locking will * be done. * * \note For ao2_containers that have RWLOCKs, the lock will be * promoted to write mode as needed. The lock will be returned * to the original locked state. * * \note Only use this flag if the ao2_container is manually * locked already. */ OBJ_NOLOCK = (1 << 5), /*! * \brief The data is hashable, but is not an object. * * \details * This can be used when you want to be able to pass custom data * to the container's stored ao2_hash_fn and ao2_find * ao2_callback_fn functions that is not a full object, but * perhaps just a string. * * \note OBJ_KEY and OBJ_POINTER are mutually exclusive options. */ OBJ_KEY = (1 << 6), }; /*! * Type of a generic function to generate a hash value from an object. * flags is ignored at the moment. Eventually, it will include the * value of OBJ_POINTER passed to ao2_callback(). */ typedef int (ao2_hash_fn)(const void *obj, int flags); /*! \name Object Containers * Here start declarations of containers. */ /*@{ */ struct ao2_container; /*! * \brief Allocate and initialize a hash container with the desired number of buckets. * * \details * We allocate space for a struct astobj_container, struct container * and the buckets[] array. * * \param options Container ao2 object options (See enum ao2_alloc_opts) * \param n_buckets Number of buckets for hash * \param hash_fn Pointer to a function computing a hash value. (NULL if everyting goes in first bucket.) * \param cmp_fn Pointer to a compare function used by ao2_find. (NULL to match everything) * \param tag used for debugging. * * \return A pointer to a struct container. * * \note Destructor is set implicitly. */ #if defined(REF_DEBUG) #define ao2_t_container_alloc_options(options, n_buckets, hash_fn, cmp_fn, tag) \ __ao2_container_alloc_debug((options), (n_buckets), (hash_fn), (cmp_fn), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #define ao2_container_alloc_options(options, n_buckets, hash_fn, cmp_fn) \ __ao2_container_alloc_debug((options), (n_buckets), (hash_fn), (cmp_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #define ao2_t_container_alloc(n_buckets, hash_fn, cmp_fn, tag) \ __ao2_container_alloc_debug(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #define ao2_container_alloc(n_buckets, hash_fn, cmp_fn) \ __ao2_container_alloc_debug(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #elif defined(__AST_DEBUG_MALLOC) #define ao2_t_container_alloc_options(options, n_buckets, hash_fn, cmp_fn, tag) \ __ao2_container_alloc_debug((options), (n_buckets), (hash_fn), (cmp_fn), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #define ao2_container_alloc_options(options, n_buckets, hash_fn, cmp_fn) \ __ao2_container_alloc_debug((options), (n_buckets), (hash_fn), (cmp_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #define ao2_t_container_alloc(n_buckets, hash_fn, cmp_fn, tag) \ __ao2_container_alloc_debug(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #define ao2_container_alloc(n_buckets, hash_fn, cmp_fn) \ __ao2_container_alloc_debug(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #else #define ao2_t_container_alloc_options(options, n_buckets, hash_fn, cmp_fn, tag) \ __ao2_container_alloc((options), (n_buckets), (hash_fn), (cmp_fn)) #define ao2_container_alloc_options(options, n_buckets, hash_fn, cmp_fn) \ __ao2_container_alloc((options), (n_buckets), (hash_fn), (cmp_fn)) #define ao2_t_container_alloc(n_buckets, hash_fn, cmp_fn, tag) \ __ao2_container_alloc(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn)) #define ao2_container_alloc(n_buckets, hash_fn, cmp_fn) \ __ao2_container_alloc(AO2_ALLOC_OPT_LOCK_MUTEX, (n_buckets), (hash_fn), (cmp_fn)) #endif struct ao2_container *__ao2_container_alloc(unsigned int options, unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn); struct ao2_container *__ao2_container_alloc_debug(unsigned int options, unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn, const char *tag, const char *file, int line, const char *func, int ref_debug); /*! \brief * Returns the number of elements in a container. */ int ao2_container_count(struct ao2_container *c); /*! * \brief Copy all object references in the src container into the dest container. * \since 11.0 * * \param dest Container to copy src object references into. * \param src Container to copy all object references from. * \param flags OBJ_NOLOCK if a lock is already held on both containers. * Otherwise, the src container is locked first. * * \pre The dest container must be empty. If the duplication fails, the * dest container will be returned empty. * * \note This can potentially be expensive because a malloc is * needed for every object in the src container. * * \retval 0 on success. * \retval -1 on error. */ int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags); /*! * \brief Create a clone/copy of the given container. * \since 11.0 * * \param orig Container to copy all object references from. * \param flags OBJ_NOLOCK if a lock is already held on the container. * * \note This can potentially be expensive because a malloc is * needed for every object in the orig container. * * \retval Clone container on success. * \retval NULL on error. */ struct ao2_container *__ao2_container_clone(struct ao2_container *orig, enum search_flags flags); struct ao2_container *__ao2_container_clone_debug(struct ao2_container *orig, enum search_flags flags, const char *tag, const char *file, int line, const char *func, int ref_debug); #if defined(REF_DEBUG) #define ao2_t_container_clone(orig, flags, tag) __ao2_container_clone_debug(orig, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #define ao2_container_clone(orig, flags) __ao2_container_clone_debug(orig, flags, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1) #elif defined(__AST_DEBUG_MALLOC) #define ao2_t_container_clone(orig, flags, tag) __ao2_container_clone_debug(orig, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #define ao2_container_clone(orig, flags) __ao2_container_clone_debug(orig, flags, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0) #else #define ao2_t_container_clone(orig, flags, tag) __ao2_container_clone(orig, flags) #define ao2_container_clone(orig, flags) __ao2_container_clone(orig, flags) #endif /*@} */ /*! \name Object Management * Here we have functions to manage objects. * * We can use the functions below on any kind of * object defined by the user. */ /*@{ */ /*! * \brief Add an object to a container. * * \param container The container to operate on. * \param obj The object to be added. * \param flags search_flags to control linking the object. (OBJ_NOLOCK) * \param tag used for debugging. * * \retval NULL on errors. * \retval !NULL on success. * * This function inserts an object in a container according its key. * * \note Remember to set the key before calling this function. * * \note This function automatically increases the reference count to account * for the reference that the container now holds to the object. */ #ifdef REF_DEBUG #define ao2_t_link(container, obj, tag) __ao2_link_debug((container), (obj), 0, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_link(container, obj) __ao2_link_debug((container), (obj), 0, "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_t_link_flags(container, obj, flags, tag) __ao2_link_debug((container), (obj), (flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_link_flags(container, obj, flags) __ao2_link_debug((container), (obj), (flags), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_t_link(container, obj, tag) __ao2_link((container), (obj), 0) #define ao2_link(container, obj) __ao2_link((container), (obj), 0) #define ao2_t_link_flags(container, obj, flags, tag) __ao2_link((container), (obj), (flags)) #define ao2_link_flags(container, obj, flags) __ao2_link((container), (obj), (flags)) #endif void *__ao2_link_debug(struct ao2_container *c, void *obj_new, int flags, const char *tag, const char *file, int line, const char *func); void *__ao2_link(struct ao2_container *c, void *obj_new, int flags); /*! * \brief Remove an object from a container * * \param container The container to operate on. * \param obj The object to unlink. * \param flags search_flags to control unlinking the object. (OBJ_NOLOCK) * \param tag used for debugging. * * \retval NULL, always * * \note The object requested to be unlinked must be valid. However, if it turns * out that it is not in the container, this function is still safe to * be called. * * \note If the object gets unlinked from the container, the container's * reference to the object will be automatically released. (The * refcount will be decremented). */ #ifdef REF_DEBUG #define ao2_t_unlink(container, obj, tag) __ao2_unlink_debug((container), (obj), 0, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_unlink(container, obj) __ao2_unlink_debug((container), (obj), 0, "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_t_unlink_flags(container, obj, flags, tag) __ao2_unlink_debug((container), (obj), (flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_unlink_flags(container, obj, flags) __ao2_unlink_debug((container), (obj), (flags), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_t_unlink(container, obj, tag) __ao2_unlink((container), (obj), 0) #define ao2_unlink(container, obj) __ao2_unlink((container), (obj), 0) #define ao2_t_unlink_flags(container, obj, flags, tag) __ao2_unlink((container), (obj), (flags)) #define ao2_unlink_flags(container, obj, flags) __ao2_unlink((container), (obj), (flags)) #endif void *__ao2_unlink_debug(struct ao2_container *c, void *obj, int flags, const char *tag, const char *file, int line, const char *func); void *__ao2_unlink(struct ao2_container *c, void *obj, int flags); /*@} */ /*! \brief * ao2_callback() is a generic function that applies cb_fn() to all objects * in a container, as described below. * * \param c A pointer to the container to operate on. * \param flags A set of flags specifying the operation to perform, * partially used by the container code, but also passed to * the callback. * - If OBJ_NODATA is set, ao2_callback will return NULL. No refcounts * of any of the traversed objects will be incremented. * On the converse, if it is NOT set (the default), the ref count * of the first matching object will be incremented and returned. If * OBJ_MULTIPLE is set, the ref count of all matching objects will * be incremented in an iterator for a temporary container and returned. * - If OBJ_POINTER is set, the traversed items will be restricted * to the objects in the bucket that the object key hashes to. * \param cb_fn A function pointer, that will be called on all * objects, to see if they match. This function returns CMP_MATCH * if the object is matches the criteria; CMP_STOP if the traversal * should immediately stop, or both (via bitwise ORing), if you find a * match and want to end the traversal, and 0 if the object is not a match, * but the traversal should continue. This is the function that is applied * to each object traversed. Its arguments are: * (void *obj, void *arg, int flags), where: * obj is an object * arg is the same as arg passed into ao2_callback * flags is the same as flags passed into ao2_callback (flags are * also used by ao2_callback). * \param arg passed to the callback. * \param tag used for debugging. * * \retval NULL on failure or no matching object found. * * \retval object found if OBJ_MULTIPLE is not set in the flags * parameter. * * \retval ao2_iterator pointer if OBJ_MULTIPLE is set in the * flags parameter. The iterator must be destroyed with * ao2_iterator_destroy() when the caller no longer needs it. * * If the function returns any objects, their refcount is incremented, * and the caller is in charge of decrementing them once done. * * Typically, ao2_callback() is used for two purposes: * - to perform some action (including removal from the container) on one * or more objects; in this case, cb_fn() can modify the object itself, * and to perform deletion should set CMP_MATCH on the matching objects, * and have OBJ_UNLINK set in flags. * - to look for a specific object in a container; in this case, cb_fn() * should not modify the object, but just return a combination of * CMP_MATCH and CMP_STOP on the desired object. * Other usages are also possible, of course. * * This function searches through a container and performs operations * on objects according on flags passed. * XXX describe better * The comparison is done calling the compare function set implicitly. * The arg pointer can be a pointer to an object or to a key, * we can say this looking at flags value. * If arg points to an object we will search for the object pointed * by this value, otherwise we search for a key value. * If the key is not unique we only find the first matching value. * * The use of flags argument is the follow: * * OBJ_UNLINK unlinks the object found * OBJ_NODATA on match, do return an object * Callbacks use OBJ_NODATA as a default * functions such as find() do * OBJ_MULTIPLE return multiple matches * Default is no. * OBJ_POINTER the pointer is an object pointer * OBJ_KEY the pointer is to a hashable key * * \note When the returned object is no longer in use, ao2_ref() should * be used to free the additional reference possibly created by this function. * * @{ */ #ifdef REF_DEBUG #define ao2_t_callback(c, flags, cb_fn, arg, tag) \ __ao2_callback_debug((c), (flags), (cb_fn), (arg), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_callback(c, flags, cb_fn, arg) \ __ao2_callback_debug((c), (flags), (cb_fn), (arg), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_t_callback(c, flags, cb_fn, arg, tag) \ __ao2_callback((c), (flags), (cb_fn), (arg)) #define ao2_callback(c, flags, cb_fn, arg) \ __ao2_callback((c), (flags), (cb_fn), (arg)) #endif void *__ao2_callback_debug(struct ao2_container *c, enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, const char *tag, const char *file, int line, const char *func); void *__ao2_callback(struct ao2_container *c, enum search_flags flags, ao2_callback_fn *cb_fn, void *arg); /*! @} */ /*! \brief * ao2_callback_data() is a generic function that applies cb_fn() to all objects * in a container. It is functionally identical to ao2_callback() except that * instead of taking an ao2_callback_fn *, it takes an ao2_callback_data_fn *, and * allows the caller to pass in arbitrary data. * * This call would be used instead of ao2_callback() when the caller needs to pass * OBJ_POINTER as part of the flags argument (which in turn requires passing in a * prototype ao2 object for 'arg') and also needs access to other non-global data * to complete it's comparison or task. * * See the documentation for ao2_callback() for argument descriptions. * * \see ao2_callback() */ #ifdef REF_DEBUG #define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag) \ __ao2_callback_data_debug((container), (flags), (cb_fn), (arg), (data), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_callback_data(container, flags, cb_fn, arg, data) \ __ao2_callback_data_debug((container), (flags), (cb_fn), (arg), (data), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag) \ __ao2_callback_data((container), (flags), (cb_fn), (arg), (data)) #define ao2_callback_data(container, flags, cb_fn, arg, data) \ __ao2_callback_data((container), (flags), (cb_fn), (arg), (data)) #endif void *__ao2_callback_data_debug(struct ao2_container *c, enum search_flags flags, ao2_callback_data_fn *cb_fn, void *arg, void *data, const char *tag, const char *file, int line, const char *func); void *__ao2_callback_data(struct ao2_container *c, enum search_flags flags, ao2_callback_data_fn *cb_fn, void *arg, void *data); /*! ao2_find() is a short hand for ao2_callback(c, flags, c->cmp_fn, arg) * XXX possibly change order of arguments ? */ #ifdef REF_DEBUG #define ao2_t_find(container, arg, flags, tag) \ __ao2_find_debug((container), (arg), (flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_find(container, arg, flags) \ __ao2_find_debug((container), (arg), (flags), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_t_find(container, arg, flags, tag) \ __ao2_find((container), (arg), (flags)) #define ao2_find(container, arg, flags) \ __ao2_find((container), (arg), (flags)) #endif void *__ao2_find_debug(struct ao2_container *c, const void *arg, enum search_flags flags, const char *tag, const char *file, int line, const char *func); void *__ao2_find(struct ao2_container *c, const void *arg, enum search_flags flags); /*! \brief * * * When we need to walk through a container, we use an * ao2_iterator to keep track of the current position. * * Because the navigation is typically done without holding the * lock on the container across the loop, objects can be inserted or deleted * or moved while we work. As a consequence, there is no guarantee that * we manage to touch all the elements in the container, and it is possible * that we touch the same object multiple times. * * However, within the current hash table container, the following is true: * - It is not possible to miss an object in the container while iterating * unless it gets added after the iteration begins and is added to a bucket * that is before the one the current object is in. In this case, even if * you locked the container around the entire iteration loop, you still would * not see this object, because it would still be waiting on the container * lock so that it can be added. * - It would be extremely rare to see an object twice. The only way this can * happen is if an object got unlinked from the container and added again * during the same iteration. Furthermore, when the object gets added back, * it has to be in the current or later bucket for it to be seen again. * * An iterator must be first initialized with ao2_iterator_init(), * then we can use o = ao2_iterator_next() to move from one * element to the next. Remember that the object returned by * ao2_iterator_next() has its refcount incremented, * and the reference must be explicitly released when done with it. * * In addition, ao2_iterator_init() will hold a reference to the container * being iterated, which will be freed when ao2_iterator_destroy() is called * to free up the resources used by the iterator (if any). * * Example: * * \code * * struct ao2_container *c = ... // the container we want to iterate on * struct ao2_iterator i; * struct my_obj *o; * * i = ao2_iterator_init(c, flags); * * while ((o = ao2_iterator_next(&i))) { * ... do something on o ... * ao2_ref(o, -1); * } * * ao2_iterator_destroy(&i); * * \endcode * */ /*! \brief * The astobj2 iterator * * \note You are not supposed to know the internals of an iterator! * We would like the iterator to be opaque, unfortunately * its size needs to be known if we want to store it around * without too much trouble. * Anyways... * The iterator has a pointer to the container, and a flags * field specifying various things e.g. whether the container * should be locked or not while navigating on it. * The iterator "points" to the current object, which is identified * by three values: * * - a bucket number; * - the object_id, which is also the container version number * when the object was inserted. This identifies the object * uniquely, however reaching the desired object requires * scanning a list. * - a pointer, and a container version when we saved the pointer. * If the container has not changed its version number, then we * can safely follow the pointer to reach the object in constant time. * * Details are in the implementation of ao2_iterator_next() * A freshly-initialized iterator has bucket=0, version=0. */ struct ao2_iterator { /*! the container */ struct ao2_container *c; /*! operation flags */ int flags; /*! current bucket */ int bucket; /*! container version */ unsigned int c_version; /*! pointer to the current object */ void *obj; /*! container version when the object was created */ unsigned int version; }; /*! Flags that can be passed to ao2_iterator_init() to modify the behavior * of the iterator. */ enum ao2_iterator_flags { /*! * \brief Assume that the ao2_container is already locked. * * \note For ao2_containers that have mutexes, no locking will * be done. * * \note For ao2_containers that have RWLOCKs, the lock will be * promoted to write mode as needed. The lock will be returned * to the original locked state. * * \note Only use this flag if the ao2_container is manually * locked already. */ AO2_ITERATOR_DONTLOCK = (1 << 0), /*! * Indicates that the iterator was dynamically allocated by * astobj2 API and should be freed by ao2_iterator_destroy(). */ AO2_ITERATOR_MALLOCD = (1 << 1), /*! * Indicates that before the iterator returns an object from * the container being iterated, the object should be unlinked * from the container. */ AO2_ITERATOR_UNLINK = (1 << 2), }; /*! * \brief Create an iterator for a container * * \param c the container * \param flags one or more flags from ao2_iterator_flags * * \retval the constructed iterator * * \note This function does \b not take a pointer to an iterator; * rather, it returns an iterator structure that should be * assigned to (overwriting) an existing iterator structure * allocated on the stack or on the heap. * * This function will take a reference on the container being iterated. * */ struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags); /*! * \brief Destroy a container iterator * * \param iter the iterator to destroy * * \retval none * * This function will release the container reference held by the iterator * and any other resources it may be holding. * */ #if defined(TEST_FRAMEWORK) void ao2_iterator_destroy(struct ao2_iterator *iter) __attribute__((noinline)); #else void ao2_iterator_destroy(struct ao2_iterator *iter); #endif #ifdef REF_DEBUG #define ao2_t_iterator_next(iter, tag) __ao2_iterator_next_debug((iter), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_iterator_next(iter) __ao2_iterator_next_debug((iter), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_t_iterator_next(iter, tag) __ao2_iterator_next((iter)) #define ao2_iterator_next(iter) __ao2_iterator_next((iter)) #endif void *__ao2_iterator_next_debug(struct ao2_iterator *iter, const char *tag, const char *file, int line, const char *func); void *__ao2_iterator_next(struct ao2_iterator *iter); /* extra functions */ void ao2_bt(void); /* backtrace */ /*! gcc __attribute__(cleanup()) functions * \note they must be able to handle NULL parameters because most of the * allocation/find functions can fail and we don't want to try to tear * down a NULL */ void __ao2_cleanup(void *obj); void __ao2_cleanup_debug(void *obj, const char *file, int line, const char *function); #ifdef REF_DEBUG #define ao2_cleanup(obj) __ao2_cleanup_debug((obj), __FILE__, __LINE__, __PRETTY_FUNCTION__) #else #define ao2_cleanup(obj) __ao2_cleanup(obj) #endif void ao2_iterator_cleanup(struct ao2_iterator *iter); #endif /* _ASTERISK_ASTOBJ2_H */ asterisk-11.7.0/include/asterisk/pval.h0000644000175000007640000002423211406762731017742 0ustar sharkyjerryweb#ifndef _ASTERISK_PVAL_H #define _ASTERISK_PVAL_H /* whatever includes this, better include asterisk/lock.h and asterisk/hashtab.h */ typedef enum { PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */ PV_MACRO, /* 1 */ PV_CONTEXT, /* 2 */ PV_MACRO_CALL, /* 3 */ PV_APPLICATION_CALL, /* 4 */ PV_CASE, /* 5 */ PV_PATTERN, /* 6 */ PV_DEFAULT, /* 7 */ PV_CATCH, /* 8 */ PV_SWITCHES, /* 9 */ PV_ESWITCHES, /* 10 */ PV_INCLUDES, /* 11 */ PV_STATEMENTBLOCK, /* 12 */ PV_VARDEC, /* you know, var=val; */ /* 13 */ PV_GOTO, /* 14 */ PV_LABEL, /* 15 */ PV_FOR, /* 16 */ PV_WHILE, /* 17 */ PV_BREAK, /* 18 */ PV_RETURN, /* 19 */ PV_CONTINUE, /* 20 */ PV_IF, /* 21 */ PV_IFTIME, /* 22 */ PV_RANDOM, /* 23 */ PV_SWITCH, /* 24 */ PV_EXTENSION, /* 25 */ PV_IGNOREPAT, /* 26 */ PV_GLOBALS, /* 27 */ PV_LOCALVARDEC, /* 28 */ } pvaltype; /* why this horrible mess? It's always been a tradeoff-- tons of structs, each storing it's specific lists of goodies, or a 'simple' single struct, with lots of fields, that catches all uses at once. Either you have a long list of struct names and subnames, or you have a long list of field names, and where/how they are used. I'm going with a single struct, using unions to reduce storage. Some simple generalizations, and a long list of types, and a book about what is used with what types.... Sorry! */ struct pval { pvaltype type; int startline; int endline; int startcol; int endcol; char *filename; union { char *str; /* wow, used almost everywhere! */ struct pval *list; /* used in SWITCHES, ESWITCHES, INCLUDES, STATEMENTBLOCK, GOTO */ struct pval *statements;/* used in EXTENSION */ char *for_init; /* used in FOR */ } u1; struct pval *u1_last; /* to build in-order lists -- looks like we only need one */ union { struct pval *arglist; /* used in macro_call, application_call, MACRO def, also attached to PWORD, the 4 timevals for includes */ struct pval *statements; /* used in case, default, catch, while's statement, CONTEXT elements, GLOBALS */ char *val; /* used in VARDEC */ char *for_test; /* used in FOR */ struct pval *goto_target; /* used in GOTO */ } u2; union { char *for_inc; /* used in FOR */ struct pval *else_statements; /* used in IF */ struct pval *macro_statements; /* used in MACRO */ int abstract; /* used for context 1=abstract; 2=extend; 3=both */ char *hints; /* used in EXTENSION */ int goto_target_in_case; /* used in GOTO */ struct ael_extension *compiled_label; struct pval *extend; /* to link extended contexts to the 'original' */ } u3; union { struct pval *for_statements; /* used in PV_FOR */ int regexten; /* used in EXTENSION */ } u4; struct pval *next; /* the pval at the end of this ptr will ALWAYS be of the same type as this one! EXCEPT for objects of the different types, that are in the same list, like contexts & macros, etc */ struct pval *dad; /* the 'container' of this struct instance */ struct pval *prev; /* the opposite of the 'next' pointer */ } ; typedef struct pval pval; #ifndef AAL_ARGCHECK /* for the time being, short circuit all the AAL related structures without permanently removing the code; after/during the AAL development, this code can be properly re-instated */ /* null definitions for structs passed down the infrastructure */ struct argapp { struct argapp *next; }; #endif struct ast_context; #ifdef AAL_ARGCHECK int option_matches_j( struct argdesc *should, pval *is, struct argapp *app); int option_matches( struct argdesc *should, pval *is, struct argapp *app); int ael_is_funcname(char *name); #endif int do_pbx_load_module(void); int count_labels_in_current_context(char *label); int check_app_args(pval *appcall, pval *arglist, struct argapp *app); void check_pval(pval *item, struct argapp *apps, int in_globals); void check_pval_item(pval *item, struct argapp *apps, int in_globals); void check_switch_expr(pval *item, struct argapp *apps); void ast_expr_register_extra_error_info(char *errmsg); void ast_expr_clear_extra_error_info(void); int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan); struct pval *find_macro(char *name); struct pval *find_context(char *name); struct pval *find_context(char *name); struct pval *find_macro(char *name); struct ael_priority *new_prio(void); struct ael_extension *new_exten(void); void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten); void destroy_extensions(struct ael_extension *exten); /* static void linkexten(struct ael_extension *exten, struct ael_extension *add); static void gen_prios(struct ael_extension *exten, char *label, pval *statement, struct ael_extension *mother_exten, struct ast_context *context ); */ void set_priorities(struct ael_extension *exten); void add_extensions(struct ael_extension *exten); int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root); void destroy_pval(pval *item); void destroy_pval_item(pval *item); int is_float(char *arg ); int is_int(char *arg ); int is_empty(char *arg); /* PVAL PI */ pval *pvalCreateNode( pvaltype type ); pvaltype pvalObjectGetType( pval *p ); void pvalWordSetString( pval *p, char *str); char *pvalWordGetString( pval *p ); void pvalMacroSetName( pval *p, char *name); char *pvalMacroGetName( pval *p ); void pvalMacroSetArglist( pval *p, pval *arglist ); void pvalMacroAddArg( pval *p, pval *arg ); pval *pvalMacroWalkArgs( pval *p, pval **arg ); void pvalMacroAddStatement( pval *p, pval *statement ); pval *pvalMacroWalkStatements( pval *p, pval **next_statement ); void pvalContextSetName( pval *p, char *name); char *pvalContextGetName( pval *p ); void pvalContextSetAbstract( pval *p ); void pvalContextUnsetAbstract( pval *p ); int pvalContextGetAbstract( pval *p ); void pvalContextAddStatement( pval *p, pval *statement); pval *pvalContextWalkStatements( pval *p, pval **statements ); void pvalMacroCallSetMacroName( pval *p, char *name ); char* pvalMacroCallGetMacroName( pval *p ); void pvalMacroCallSetArglist( pval *p, pval *arglist ); void pvalMacroCallAddArg( pval *p, pval *arg ); pval *pvalMacroCallWalkArgs( pval *p, pval **args ); void pvalAppCallSetAppName( pval *p, char *name ); char* pvalAppCallGetAppName( pval *p ); void pvalAppCallSetArglist( pval *p, pval *arglist ); void pvalAppCallAddArg( pval *p, pval *arg ); pval *pvalAppCallWalkArgs( pval *p, pval **args ); void pvalCasePatSetVal( pval *p, char *val ); char* pvalCasePatGetVal( pval *p ); void pvalCasePatDefAddStatement( pval *p, pval *statement ); pval *pvalCasePatDefWalkStatements( pval *p, pval **statement ); void pvalCatchSetExtName( pval *p, char *name ); char* pvalCatchGetExtName( pval *p ); void pvalCatchSetStatement( pval *p, pval *statement ); pval *pvalCatchGetStatement( pval *p ); void pvalSwitchesAddSwitch( pval *p, char *name ); char* pvalSwitchesWalkNames( pval *p, pval **next_item ); void pvalESwitchesAddSwitch( pval *p, char *name ); char* pvalESwitchesWalkNames( pval *p, pval **next_item ); void pvalIncludesAddInclude( pval *p, const char *include ); void pvalIncludesAddIncludeWithTimeConstraints( pval *p, const char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range ); void pvalIncludeGetTimeConstraints( pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range ); char* pvalIncludesWalk( pval *p, pval **next_item ); void pvalStatementBlockAddStatement( pval *p, pval *statement); pval *pvalStatementBlockWalkStatements( pval *p, pval **next_statement); void pvalVarDecSetVarname( pval *p, char *name ); void pvalVarDecSetValue( pval *p, char *value ); char* pvalVarDecGetVarname( pval *p ); char* pvalVarDecGetValue( pval *p ); void pvalGotoSetTarget( pval *p, char *context, char *exten, char *label ); void pvalGotoGetTarget( pval *p, char **context, char **exten, char **label ); void pvalLabelSetName( pval *p, char *name ); char* pvalLabelGetName( pval *p ); void pvalForSetInit( pval *p, char *init ); void pvalForSetTest( pval *p, char *test ); void pvalForSetInc( pval *p, char *inc ); void pvalForSetStatement( pval *p, pval *statement ); char* pvalForGetInit( pval *p ); char* pvalForGetTest( pval *p ); char* pvalForGetInc( pval *p ); pval* pvalForGetStatement( pval *p ); void pvalIfSetCondition( pval *p, char *expr ); char* pvalIfGetCondition( pval *p ); void pvalIfTimeSetCondition( pval *p, char *hour_range, char *dow_range, char *dom_range, char *mon_range ); /* time range format: 24-hour format begin-end|dow range|dom range|month range */ void pvalIfTimeGetCondition( pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range ); void pvalRandomSetCondition( pval *p, char *percent ); char* pvalRandomGetCondition( pval *p ); void pvalConditionalSetThenStatement( pval *p, pval *statement ); void pvalConditionalSetElseStatement( pval *p, pval *statement ); pval* pvalConditionalGetThenStatement( pval *p ); pval* pvalConditionalGetElseStatement( pval *p ); void pvalSwitchSetTestexpr( pval *p, char *expr ); char* pvalSwitchGetTestexpr( pval *p ); void pvalSwitchAddCase( pval *p, pval *Case ); pval* pvalSwitchWalkCases( pval *p, pval **next_case ); void pvalExtenSetName( pval *p, char *name ); char *pvalExtenGetName( pval *p ); void pvalExtenSetRegexten( pval *p ); void pvalExtenUnSetRegexten( pval *p ); int pvalExtenGetRegexten( pval *p ); void pvalExtenSetHints( pval *p, char *hints ); char* pvalExtenGetHints( pval *p ); void pvalExtenSetStatement( pval *p, pval *statement ); pval* pvalExtenGetStatement( pval *p ); void pvalIgnorePatSetPattern( pval *p, char *pat ); char* pvalIgnorePatGetPattern( pval *p ); void pvalGlobalsAddStatement( pval *p, pval *statement ); pval* pvalGlobalsWalkStatements( pval *p, pval **next_statement ); void pvalTopLevAddObject( pval *p, pval *contextOrObj ); pval* pvalTopLevWalkObjects( pval *p, pval **next_obj ); int pvalCheckType( pval *p, char *funcname, pvaltype type ); #endif asterisk-11.7.0/include/asterisk/datastore.h0000644000175000007640000000547111200013053020744 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007 - 2008, Digium, Inc. * * 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 Asterisk datastore objects */ #ifndef _ASTERISK_DATASTORE_H #define _ASTERISK_DATASTORE_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/linkedlists.h" /*! \brief Structure for a data store type */ struct ast_datastore_info { const char *type; /*!< Type of data store */ void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */ void (*destroy)(void *data); /*!< Destroy function */ /*! * \brief Fix up channel references * * \arg data The datastore data * \arg old_chan The old channel owning the datastore * \arg new_chan The new channel owning the datastore * * This is exactly like the fixup callback of the channel technology interface. * It allows a datastore to fix any pointers it saved to the owning channel * in case that the owning channel has changed. Generally, this would happen * when the datastore is set to be inherited, and a masquerade occurs. * * \return nothing. */ void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan); }; /*! \brief Structure for a data store object */ struct ast_datastore { const char *uid; /*!< Unique data store identifier */ void *data; /*!< Contained data */ const struct ast_datastore_info *info; /*!< Data store type information */ unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */ AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */ }; /*! * \brief Create a data store object * \param[in] info information describing the data store object * \param[in] uid unique identifer * \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc */ struct ast_datastore * attribute_malloc __ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid, const char *file, int line, const char *function); #define ast_datastore_alloc(info, uid) __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief Free a data store object * \param[in] datastore datastore to free * \version 1.6.1 moved here and renamed from ast_channel_datastore_free */ int ast_datastore_free(struct ast_datastore *datastore); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_DATASTORE_H */ asterisk-11.7.0/include/asterisk/dsp.h0000644000175000007640000001433411676663404017576 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Convenient Signal Processing routines */ #ifndef _ASTERISK_DSP_H #define _ASTERISK_DSP_H #define DSP_FEATURE_SILENCE_SUPPRESS (1 << 0) #define DSP_FEATURE_BUSY_DETECT (1 << 1) #define DSP_FEATURE_DIGIT_DETECT (1 << 3) #define DSP_FEATURE_FAX_DETECT (1 << 4) #define DSP_DIGITMODE_DTMF 0 /*!< Detect DTMF digits */ #define DSP_DIGITMODE_MF 1 /*!< Detect MF digits */ #define DSP_DIGITMODE_NOQUELCH (1 << 8) /*!< Do not quelch DTMF from in-band */ #define DSP_DIGITMODE_MUTECONF (1 << 9) /*!< Mute conference */ #define DSP_DIGITMODE_MUTEMAX (1 << 10) /*!< Delay audio by a frame to try to extra quelch */ #define DSP_DIGITMODE_RELAXDTMF (1 << 11) /*!< "Radio" mode (relaxed DTMF) */ #define DSP_PROGRESS_TALK (1 << 16) /*!< Enable talk detection */ #define DSP_PROGRESS_RINGING (1 << 17) /*!< Enable calling tone detection */ #define DSP_PROGRESS_BUSY (1 << 18) /*!< Enable busy tone detection */ #define DSP_PROGRESS_CONGESTION (1 << 19) /*!< Enable congestion tone detection */ #define DSP_FEATURE_CALL_PROGRESS (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION) #define DSP_FEATURE_WAITDIALTONE (1 << 20) /*!< Enable dial tone detection */ #define DSP_FAXMODE_DETECT_CNG (1 << 0) #define DSP_FAXMODE_DETECT_CED (1 << 1) #define DSP_FAXMODE_DETECT_SQUELCH (1 << 2) #define DSP_FAXMODE_DETECT_ALL (DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED) #define DSP_TONE_STATE_SILENCE 0 #define DSP_TONE_STATE_RINGING 1 #define DSP_TONE_STATE_DIALTONE 2 #define DSP_TONE_STATE_TALKING 3 #define DSP_TONE_STATE_BUSY 4 #define DSP_TONE_STATE_SPECIAL1 5 #define DSP_TONE_STATE_SPECIAL2 6 #define DSP_TONE_STATE_SPECIAL3 7 #define DSP_TONE_STATE_HUNGUP 8 struct ast_dsp; struct ast_dsp_busy_pattern { /*! Number of elements. */ int length; /*! Pattern elements in on/off time durations. */ int pattern[4]; }; enum threshold { /* Array offsets */ THRESHOLD_SILENCE = 0, /* Always the last */ THRESHOLD_MAX = 1, }; /*! \brief Allocates a new dsp with a specific internal sample rate used * during processing. */ struct ast_dsp *ast_dsp_new_with_rate(unsigned int sample_rate); /*! \brief Allocates a new dsp, assumes 8khz for internal sample rate */ struct ast_dsp *ast_dsp_new(void); void ast_dsp_free(struct ast_dsp *dsp); /*! \brief Retrieve the sample rate this DSP structure was * created with */ unsigned int ast_dsp_get_sample_rate(const struct ast_dsp *dsp); /*! \brief Set threshold value for silence */ void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold); /*! \brief Set number of required cadences for busy */ void ast_dsp_set_busy_count(struct ast_dsp *dsp, int cadences); /*! \brief Set expected lengths of the busy tone */ void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence); /*! \brief Scans for progress indication in audio */ int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf); /*! \brief Set zone for doing progress detection */ int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone); /*! \brief Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress, all dependent upon which features are enabled */ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf); /*! \brief Return non-zero if this is silence. Updates "totalsilence" with the total number of seconds of silence */ int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence); /*! \brief Return non-zero if this is silence. Updates "totalsilence" with the total number of seconds of silence. Returns the average energy of the samples in the frame in frames_energy variable. */ int ast_dsp_silence_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence, int *frames_energy); /*! * \brief Return non-zero if this is noise. Updates "totalnoise" with the total * number of seconds of noise * \since 1.6.1 */ int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise); /*! \brief Return non-zero if historically this should be a busy, request that ast_dsp_silence has already been called */ int ast_dsp_busydetect(struct ast_dsp *dsp); /*! \brief Return non-zero if DTMF hit was found */ int ast_dsp_digitdetect(struct ast_dsp *dsp, struct ast_frame *f); /*! \brief Reset total silence count */ void ast_dsp_reset(struct ast_dsp *dsp); /*! \brief Reset DTMF detector */ void ast_dsp_digitreset(struct ast_dsp *dsp); /*! \brief Select feature set */ void ast_dsp_set_features(struct ast_dsp *dsp, int features); /*! \brief Get pending DTMF/MF digits */ int ast_dsp_getdigits(struct ast_dsp *dsp, char *buf, int max); /*! \brief Set digit mode * \version 1.6.1 renamed from ast_dsp_digitmode to ast_dsp_set_digitmode */ int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode); /*! \brief Set fax mode */ int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode); /*! * \brief Returns true if DSP code was muting any fragment of the last processed frame. * Muting (squelching) happens when DSP code removes DTMF/MF/generic tones from the audio * \since 1.6.1 */ int ast_dsp_was_muted(struct ast_dsp *dsp); /*! \brief Get tstate (Tone State) */ int ast_dsp_get_tstate(struct ast_dsp *dsp); /*! \brief Get tcount (Threshold counter) */ int ast_dsp_get_tcount(struct ast_dsp *dsp); /*! * \brief Get silence threshold from dsp.conf * \since 1.6.1 */ int ast_dsp_get_threshold_from_settings(enum threshold which); /*! * \brief Reloads dsp settings from dsp.conf * \since 1.6.1 */ int ast_dsp_reload(void); /*! * \brief Load dsp settings from dsp.conf * \since 1.6.1 */ int ast_dsp_init(void); #endif /* _ASTERISK_DSP_H */ asterisk-11.7.0/include/asterisk/fskmodem.h0000644000175000007640000000143011041174377020576 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2008, Digium, Inc. * * Mark Spencer * * 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 FSK Modem Support * \note Includes code and algorithms from the Zapata library. */ #include "asterisk.h" #ifdef INTEGER_CALLERID #include "fskmodem_int.h" #else #include "fskmodem_float.h" #endif asterisk-11.7.0/include/asterisk/cdr.h0000644000175000007640000003414511672731673017562 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Call Detail Record API * * \author Mark Spencer */ #ifndef _ASTERISK_CDR_H #define _ASTERISK_CDR_H #include #include "asterisk/data.h" /*! * \brief CDR Flags */ enum { AST_CDR_FLAG_KEEP_VARS = (1 << 0), AST_CDR_FLAG_POSTED = (1 << 1), AST_CDR_FLAG_LOCKED = (1 << 2), AST_CDR_FLAG_CHILD = (1 << 3), AST_CDR_FLAG_POST_DISABLED = (1 << 4), AST_CDR_FLAG_BRIDGED = (1 << 5), AST_CDR_FLAG_MAIN = (1 << 6), AST_CDR_FLAG_ENABLE = (1 << 7), AST_CDR_FLAG_ANSLOCKED = (1 << 8), AST_CDR_FLAG_DONT_TOUCH = (1 << 9), AST_CDR_FLAG_POST_ENABLE = (1 << 10), AST_CDR_FLAG_DIALED = (1 << 11), AST_CDR_FLAG_ORIGINATED = (1 << 12), }; /*! * \brief CDR Flags - Disposition */ enum { AST_CDR_NOANSWER = 0, AST_CDR_NULL = (1 << 0), AST_CDR_FAILED = (1 << 1), AST_CDR_BUSY = (1 << 2), AST_CDR_ANSWERED = (1 << 3), AST_CDR_CONGESTION = (1 << 4), }; /*! * \brief CDR AMA Flags */ enum { AST_CDR_OMIT = 1, AST_CDR_BILLING = 2, AST_CDR_DOCUMENTATION = 3, }; #define AST_MAX_USER_FIELD 256 #define AST_MAX_ACCOUNT_CODE 20 /* Include channel.h after relevant declarations it will need */ #include "asterisk/channel.h" #include "asterisk/utils.h" /*! * \brief Responsible for call detail data */ struct ast_cdr { /*! Caller*ID with text */ char clid[AST_MAX_EXTENSION]; /*! Caller*ID number */ char src[AST_MAX_EXTENSION]; /*! Destination extension */ char dst[AST_MAX_EXTENSION]; /*! Destination context */ char dcontext[AST_MAX_EXTENSION]; char channel[AST_MAX_EXTENSION]; /*! Destination channel if appropriate */ char dstchannel[AST_MAX_EXTENSION]; /*! Last application if appropriate */ char lastapp[AST_MAX_EXTENSION]; /*! Last application data */ char lastdata[AST_MAX_EXTENSION]; struct timeval start; struct timeval answer; struct timeval end; /*! Total time in system, in seconds */ long int duration; /*! Total time call is up, in seconds */ long int billsec; /*! What happened to the call */ long int disposition; /*! What flags to use */ long int amaflags; /*! What account number to use */ char accountcode[AST_MAX_ACCOUNT_CODE]; /*! Account number of the last person we talked to */ char peeraccount[AST_MAX_ACCOUNT_CODE]; /*! flags */ unsigned int flags; /*! Unique Channel Identifier * 150 = 127 (max systemname) + "-" + 10 (epoch timestamp) + "." + 10 (monotonically incrementing integer) + NULL */ char uniqueid[150]; /* Linked group Identifier */ char linkedid[32]; /*! User field */ char userfield[AST_MAX_USER_FIELD]; /*! Sequence field */ int sequence; /*! A linked list for variables */ struct varshead varshead; struct ast_cdr *next; }; int ast_cdr_isset_unanswered(void); int ast_cdr_isset_congestion(void); void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw); int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur); int ast_cdr_serialize_variables(struct ast_cdr *cdr, struct ast_str **buf, char delim, char sep, int recur); void ast_cdr_free_vars(struct ast_cdr *cdr, int recur); int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr); /*! * \brief CDR backend callback * \warning CDR backends should NOT attempt to access the channel associated * with a CDR record. This channel is not guaranteed to exist when the CDR * backend is invoked. */ typedef int (*ast_cdrbe)(struct ast_cdr *cdr); /*! \brief Return TRUE if CDR subsystem is enabled */ int check_cdr_enabled(void); /*! * \brief Allocate a CDR record * \retval a malloc'd ast_cdr structure * \retval NULL on error (malloc failure) */ struct ast_cdr *ast_cdr_alloc(void); /*! * \brief Duplicate a record and increment the sequence number. * \param cdr the record to duplicate * \retval a malloc'd ast_cdr structure, * \retval NULL on error (malloc failure) * \see ast_cdr_dup() * \see ast_cdr_dup_unique_swap() */ struct ast_cdr *ast_cdr_dup_unique(struct ast_cdr *cdr); /*! * \brief Duplicate a record and increment the sequence number of the old * record. * \param cdr the record to duplicate * \retval a malloc'd ast_cdr structure, * \retval NULL on error (malloc failure) * \note This version increments the original CDR's sequence number rather than * the duplicate's sequence number. The effect is as if the original CDR's * sequence number was swapped with the duplicate's sequence number. * * \see ast_cdr_dup() * \see ast_cdr_dup_unique() */ struct ast_cdr *ast_cdr_dup_unique_swap(struct ast_cdr *cdr); /*! * \brief Duplicate a record * \param cdr the record to duplicate * \retval a malloc'd ast_cdr structure, * \retval NULL on error (malloc failure) * \see ast_cdr_dup_unique() * \see ast_cdr_dup_unique_swap() */ struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr); /*! * \brief Free a CDR record * \param cdr ast_cdr structure to free * Returns nothing */ void ast_cdr_free(struct ast_cdr *cdr); /*! * \brief Discard and free a CDR record * \param cdr ast_cdr structure to free * Returns nothing -- same as free, but no checks or complaints */ void ast_cdr_discard(struct ast_cdr *cdr); /*! * \brief Initialize based on a channel * \param cdr Call Detail Record to use for channel * \param chan Channel to bind CDR with * Initializes a CDR and associates it with a particular channel * \note The channel should be locked before calling. * \return 0 by default */ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan); /*! * \brief Initialize based on a channel * \param cdr Call Detail Record to use for channel * \param chan Channel to bind CDR with * Initializes a CDR and associates it with a particular channel * \note The channel should be locked before calling. * \return 0 by default */ int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan); /*! * \brief Register a CDR handling engine * \param name name associated with the particular CDR handler * \param desc description of the CDR handler * \param be function pointer to a CDR handler * Used to register a Call Detail Record handler. * \retval 0 on success. * \retval -1 on error */ int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be); /*! * \brief Unregister a CDR handling engine * \param name name of CDR handler to unregister * Unregisters a CDR by it's name */ void ast_cdr_unregister(const char *name); /*! * \brief Start a call * \param cdr the cdr you wish to associate with the call * Starts all CDR stuff necessary for monitoring a call * Returns nothing */ void ast_cdr_start(struct ast_cdr *cdr); /*! \brief Answer a call * \param cdr the cdr you wish to associate with the call * Starts all CDR stuff necessary for doing CDR when answering a call * \note NULL argument is just fine. */ void ast_cdr_answer(struct ast_cdr *cdr); /*! * \brief A call wasn't answered * \param cdr the cdr you wish to associate with the call * Marks the channel disposition as "NO ANSWER" * Will skip CDR's in chain with ANS_LOCK bit set. (see * forkCDR() application. */ extern void ast_cdr_noanswer(struct ast_cdr *cdr); /*! * \brief A call was set to congestion * \param cdr the cdr you wish to associate with the call * Markst he channel disposition as "CONGESTION" * Will skip CDR's in chain with ANS_LOCK bit set. (see * forkCDR() application */ extern void ast_cdr_congestion(struct ast_cdr *cdr); /*! * \brief Busy a call * \param cdr the cdr you wish to associate with the call * Marks the channel disposition as "BUSY" * Will skip CDR's in chain with ANS_LOCK bit set. (see * forkCDR() application. * Returns nothing */ void ast_cdr_busy(struct ast_cdr *cdr); /*! * \brief Fail a call * \param cdr the cdr you wish to associate with the call * Marks the channel disposition as "FAILED" * Will skip CDR's in chain with ANS_LOCK bit set. (see * forkCDR() application. * Returns nothing */ void ast_cdr_failed(struct ast_cdr *cdr); /*! * \brief Save the result of the call based on the AST_CAUSE_* * \param cdr the cdr you wish to associate with the call * \param cause the AST_CAUSE_* * Returns nothing */ int ast_cdr_disposition(struct ast_cdr *cdr, int cause); /*! * \brief End a call * \param cdr the cdr you have associated the call with * Registers the end of call time in the cdr structure. * Returns nothing */ void ast_cdr_end(struct ast_cdr *cdr); /*! * \brief Detaches the detail record for posting (and freeing) either now or at a * later time in bulk with other records during batch mode operation. * \param cdr Which CDR to detach from the channel thread * Prevents the channel thread from blocking on the CDR handling * Returns nothing */ void ast_cdr_detach(struct ast_cdr *cdr); /*! * \brief Spawns (possibly) a new thread to submit a batch of CDRs to the backend engines * \param shutdown Whether or not we are shutting down * Blocks the asterisk shutdown procedures until the CDR data is submitted. * Returns nothing */ void ast_cdr_submit_batch(int shutdown); /*! * \brief Set the destination channel, if there was one * \param cdr Which cdr it's applied to * \param chan Channel to which dest will be * Sets the destination channel the CDR is applied to * Returns nothing */ void ast_cdr_setdestchan(struct ast_cdr *cdr, const char *chan); /*! * \brief Set the last executed application * \param cdr which cdr to act upon * \param app the name of the app you wish to change it to * \param data the data you want in the data field of app you set it to * Changes the value of the last executed app * Returns nothing */ void ast_cdr_setapp(struct ast_cdr *cdr, const char *app, const char *data); /*! * \brief Set the answer time for a call * \param cdr the cdr you wish to associate with the call * \param t the answer time * Starts all CDR stuff necessary for doing CDR when answering a call * NULL argument is just fine. */ void ast_cdr_setanswer(struct ast_cdr *cdr, struct timeval t); /*! * \brief Set the disposition for a call * \param cdr the cdr you wish to associate with the call * \param disposition the new disposition * Set the disposition on a call. * NULL argument is just fine. */ void ast_cdr_setdisposition(struct ast_cdr *cdr, long int disposition); /*! * \brief Convert a string to a detail record AMA flag * \param flag string form of flag * Converts the string form of the flag to the binary form. * \return the binary form of the flag */ int ast_cdr_amaflags2int(const char *flag); /*! * \brief Disposition to a string * \param disposition input binary form * Converts the binary form of a disposition to string form. * \return a pointer to the string form */ char *ast_cdr_disp2str(int disposition); /*! * \brief Reset the detail record, optionally posting it first * \param cdr which cdr to act upon * \param flags |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it * |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's */ void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags); /*! Reset the detail record times, flags */ /*! * \param cdr which cdr to act upon * \param flags |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it * |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's */ void ast_cdr_specialized_reset(struct ast_cdr *cdr, struct ast_flags *flags); /*! Flags to a string */ /*! * \param flags binary flag * Converts binary flags to string flags * Returns string with flag name */ char *ast_cdr_flags2str(int flags); /*! * \brief Move the non-null data from the "from" cdr to the "to" cdr * \param to the cdr to get the goodies * \param from the cdr to give the goodies */ void ast_cdr_merge(struct ast_cdr *to, struct ast_cdr *from); /*! * \brief Set account code, will generate AMI event * \note The channel should be locked before calling. */ int ast_cdr_setaccount(struct ast_channel *chan, const char *account); /*! * \brief Set the peer account * \note The channel should be locked before calling. */ int ast_cdr_setpeeraccount(struct ast_channel *chan, const char *account); /*! * \brief Set AMA flags for channel * \note The channel should be locked before calling. */ int ast_cdr_setamaflags(struct ast_channel *chan, const char *amaflags); /*! * \brief Set CDR user field for channel (stored in CDR) * \note The channel should be locked before calling. */ int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield); /*! * \brief Append to CDR user field for channel (stored in CDR) * \note The channel should be locked before calling. */ int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield); /*! * \brief Update CDR on a channel * \note The channel should be locked before calling. */ int ast_cdr_update(struct ast_channel *chan); extern int ast_default_amaflags; extern char ast_default_accountcode[AST_MAX_ACCOUNT_CODE]; struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr); /*! \brief Reload the configuration file cdr.conf and start/stop CDR scheduling thread */ int ast_cdr_engine_reload(void); /*! \brief Load the configuration file cdr.conf and possibly start the CDR scheduling thread */ int ast_cdr_engine_init(void); /*! Submit any remaining CDRs and prepare for shutdown */ void ast_cdr_engine_term(void); /*! * \brief * \param[in] tree Where to insert the cdr. * \param[in] cdr The cdr structure to insert in 'tree'. * \param[in] recur Go throw all the cdr levels. * \retval <0 on error. * \retval 0 on success. */ int ast_cdr_data_add_structure(struct ast_data *tree, struct ast_cdr *cdr, int recur); #endif /* _ASTERISK_CDR_H */ asterisk-11.7.0/include/asterisk/heap.h0000644000175000007640000001711611364117221017707 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Digium, Inc. * * Russell Bryant * * 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 Max Heap data structure * \author Russell Bryant */ #ifndef __AST_HEAP_H__ #define __AST_HEAP_H__ /*! * \brief A max heap. * * \note Thread-safety is left to the user of the API. The heap API provides * no locking of its own. If the heap will be accessed by multiple threads, * then a lock must be used to ensure that only a single operation is * done on the heap at a time. For the sake of convenience, a lock is * provided for the user of the API to use if another lock is not already * available to protect the heap. */ struct ast_heap; /*! * \brief Function type for comparing nodes in a heap * * \param elm1 the first element * \param elm2 the second element * * \retval negative if elm1 < elm2 * \retval 0 if elm1 == elm2 * \retval positive if elm1 > elm2 * * \note This implementation is of a max heap. However, if a min heap is * desired, simply swap the return values of this function. * * \since 1.6.1 */ typedef int (*ast_heap_cmp_fn)(void *elm1, void *elm2); /*! * \brief Create a max heap * * \param init_height The initial height of the heap to allocate space for. * To start out, there will be room for (2 ^ init_height) - 1 entries. * However, the heap will grow as needed. * \param cmp_fn The function that should be used to compare elements in the heap. * \param index_offset This parameter is optional, but must be provided to be able * to use ast_heap_remove(). This is the number of bytes into the element * where an ssize_t has been made available for the heap's internal * use. The heap will use this field to keep track of the element's current * position in the heap. The offsetof() macro is useful for providing a * proper value for this argument. If ast_heap_remove() will not be used, * then a negative value can be provided to indicate that no field for an * offset has been allocated. * * Example Usage: * * \code * * struct myobj { * int foo; * int bar; * char stuff[8]; * char things[8]; * ssize_t __heap_index; * }; * * ... * * static int myobj_cmp(void *obj1, void *obj2); * * ... * * struct ast_heap *h; * * h = ast_heap_create(8, myobj_cmp, offsetof(struct myobj, __heap_index)); * * \endcode * * \return An instance of a max heap * \since 1.6.1 */ #ifdef MALLOC_DEBUG struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, ssize_t index_offset, const char *file, int lineno, const char *func); #define ast_heap_create(a,b,c) _ast_heap_create(a,b,c,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, ssize_t index_offset); #endif /*! * \brief Destroy a max heap * * \param h the heap to destroy * * \return NULL for convenience * \since 1.6.1 */ struct ast_heap *ast_heap_destroy(struct ast_heap *h); /*! * \brief Push an element on to a heap * * \param h the heap being added to * \param elm the element being put on the heap * * \retval 0 success * \retval non-zero failure * \since 1.6.1 */ #ifdef MALLOC_DEBUG int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func); #define ast_heap_push(a,b) _ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else int ast_heap_push(struct ast_heap *h, void *elm); #endif /*! * \brief Pop the max element off of the heap * * \param h the heap * * \return this will return the element on the top of the heap, which has the * largest value according to the element comparison function that was * provided when the heap was created. The element will be removed before * being returned. * \since 1.6.1 */ void *ast_heap_pop(struct ast_heap *h); /*! * \brief Remove a specific element from a heap * * \param h the heap to remove from * \param elm the element to remove * * \return elm, if the removal was successful, or NULL if it failed * * \note the index_offset parameter to ast_heap_create() is required to be able * to use this function. * \since 1.6.1 */ void *ast_heap_remove(struct ast_heap *h, void *elm); /*! * \brief Peek at an element on a heap * * \param h the heap * \param index index of the element to return. The first element is at index 1, * and the last element is at the index == the size of the heap. * * \return an element at the specified index on the heap. This element will \b not * be removed before being returned. * * \note If this function is being used in combination with ast_heap_size() for * purposes of traversing the heap, the heap must be locked for the entire * duration of the traversal. * * Example code for a traversal: * \code * * struct ast_heap *h; * * ... * * size_t size, i; * void *cur_obj; * * ast_heap_rdlock(h); * * size = ast_heap_size(h); * * for (i = 1; i <= size && (cur_obj = ast_heap_peek(h, i)); i++) { * ... Do stuff with cur_obj ... * } * * ast_heap_unlock(h); * * \endcode * \since 1.6.1 */ void *ast_heap_peek(struct ast_heap *h, unsigned int index); /*! * \brief Get the current size of a heap * * \param h the heap * * \return the number of elements currently in the heap * \since 1.6.1 */ size_t ast_heap_size(struct ast_heap *h); /*! * \brief Write-Lock a heap * * \param h the heap * * A lock is provided for convenience. It can be assumed that none of the * ast_heap API calls are thread safe. This lock does not have to be used * if another one is already available to protect the heap. * * \return see the documentation for pthread_rwlock_wrlock() * \since 1.6.1 */ int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line); /*! * \brief Read-Lock a heap * * \param h the heap * * A lock is provided for convenience. It can be assumed that none of the * ast_heap API calls are thread safe. This lock does not have to be used * if another one is already available to protect the heap. * * \return see the documentation for pthread_rwlock_rdlock() * \since 1.6.1 */ int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line); /*! * \brief Unlock a heap * * \param h the heap * * \return see the documentation for pthread_rwlock_unlock() * \since 1.6.1 */ int __ast_heap_unlock(struct ast_heap *h, const char *file, const char *func, int line); #define ast_heap_wrlock(h) __ast_heap_wrlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define ast_heap_rdlock(h) __ast_heap_rdlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define ast_heap_unlock(h) __ast_heap_unlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__) /*! * \brief Verify that a heap has been properly constructed * * \param h a heap * * \retval 0 success * \retval non-zero failure * * \note This function is mostly for debugging purposes. It traverses an existing * heap and verifies that every node is properly placed relative to its children. * \since 1.6.1 */ int ast_heap_verify(struct ast_heap *h); #endif /* __AST_HEAP_H__ */ asterisk-11.7.0/include/asterisk/xml.h0000644000175000007640000001452211403452732017573 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008, Eliel C. Sardanons (LU1ALY) * * 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. */ #ifndef _ASTERISK_XML_H #define _ASTERISK_XML_H /*! \file * \brief Asterisk XML abstraction layer */ struct ast_xml_node; struct ast_xml_doc; /*! * \brief Initialize the XML library implementation. * This function is used to setup everything needed * to start working with the xml implementation. * \retval 0 On success. * \retval 1 On error. */ int ast_xml_init(void); /*! * \brief Cleanup library allocated global data. * \retval 0 On success. * \retval 1 On error. */ int ast_xml_finish(void); /*! * \brief Open an XML document. * \param filename Document path. * \retval NULL on error. * \retval The ast_xml_doc reference to the open document. */ struct ast_xml_doc *ast_xml_open(char *filename); /*! * \brief Create a XML document. * \retval NULL on error. * \retval non-NULL The allocated document structure. */ struct ast_xml_doc *ast_xml_new(void); /*! * \brief Create a XML node. * \param name The name of the node to be created. * \retval NULL on error. * \retval non-NULL The allocated node structe. */ struct ast_xml_node *ast_xml_new_node(const char *name); /*! * \brief Add a child node inside a passed parent node. * \param parent The pointer of the parent node. * \param child_name The name of the child node to add. * \retval NULL on error. * \retval non-NULL The created child node pointer. */ struct ast_xml_node *ast_xml_new_child(struct ast_xml_node *parent, const char *child_name); /*! * \brief Add a child node, to a specified parent node. * \param parent Where to add the child node. * \param child The child node to add. * \retval NULL on error. * \retval non-NULL The add child node on success. */ struct ast_xml_node *ast_xml_add_child(struct ast_xml_node *parent, struct ast_xml_node *child); /*! * \brief Close an already open document and free the used * structure. * \retval doc The document reference. */ void ast_xml_close(struct ast_xml_doc *doc); /*! \brief Open an XML document that resides in memory. * \param buffer The address where the document is stored * \param size The number of bytes in the document * \retval NULL on error. * \retval The ast_xml_doc reference to the open document. */ struct ast_xml_doc *ast_xml_read_memory(char *buffer, size_t size); /*! * \brief Specify the root node of a XML document. * \param doc The document pointer. * \param node A pointer to the node we want to set as root node. */ void ast_xml_set_root(struct ast_xml_doc *doc, struct ast_xml_node *node); /*! * \brief Get the document root node. * \param doc Document reference * \retval NULL on error * \retval The root node on success. */ struct ast_xml_node *ast_xml_get_root(struct ast_xml_doc *doc); /*! * \brief Free node * \param node Node to be released. */ void ast_xml_free_node(struct ast_xml_node *node); /*! * \brief Free an attribute returned by ast_xml_get_attribute() * \param attribute pointer to be freed. */ void ast_xml_free_attr(const char *attribute); /*! * \brief Get the document based on a node. * \param node A node that is part of the dom. * \returns The dom pointer where this node resides. */ struct ast_xml_doc *ast_xml_get_doc(struct ast_xml_node *node); /*! * \brief Free a content element that was returned by ast_xml_get_text() * \param text text to be freed. */ void ast_xml_free_text(const char *text); /*! * \brief Get a node attribute by name * \param node Node where to search the attribute. * \param attrname Attribute name. * \retval NULL on error * \retval The attribute value on success. */ const char *ast_xml_get_attribute(struct ast_xml_node *node, const char *attrname); /*! * \brief Set an attribute to a node. * \param node In which node we want to insert the attribute. * \param name The attribute name. * \param value The attribute value. * \retval 0 on success. * \retval -1 on error. */ int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value); /*! * \brief Find a node element by name. * \param root_node This is the node starting point. * \param name Node name to find. * \param attrname attribute name to match (if NULL it won't be matched). * \param attrvalue attribute value to match (if NULL it won't be matched). * \retval NULL if not found. * \retval The node on success. */ struct ast_xml_node *ast_xml_find_element(struct ast_xml_node *root_node, const char *name, const char *attrname, const char *attrvalue); struct ast_xml_ns *ast_xml_find_namespace(struct ast_xml_doc *doc, struct ast_xml_node *node, const char *ns_name); const char *ast_xml_get_ns_href(struct ast_xml_ns *ns); /*! * \brief Get an element content string. * \param node Node from where to get the string. * \retval NULL on error. * \retval The text content of node. */ const char *ast_xml_get_text(struct ast_xml_node *node); /*! * \brief Set an element content string. * \param node Node from where to set the content string. * \param content The text to insert in the node. */ void ast_xml_set_text(struct ast_xml_node *node, const char *content); /*! * \brief Get the name of a node. */ const char *ast_xml_node_get_name(struct ast_xml_node *node); /*! * \brief Get the node's children. */ struct ast_xml_node *ast_xml_node_get_children(struct ast_xml_node *node); /*! * \brief Get the next node in the same level. */ struct ast_xml_node *ast_xml_node_get_next(struct ast_xml_node *node); /*! * \brief Get the previous node in the same leve. */ struct ast_xml_node *ast_xml_node_get_prev(struct ast_xml_node *node); /*! * \brief Get the parent of a specified node. */ struct ast_xml_node *ast_xml_node_get_parent(struct ast_xml_node *node); /*! * \brief Dump the specified document to a file. */ int ast_xml_doc_dump_file(FILE *output, struct ast_xml_doc *doc); /* Features using ast_xml_ */ #ifdef HAVE_LIBXML2 #define AST_XML_DOCS #endif #endif /* _ASTERISK_XML_H */ asterisk-11.7.0/include/asterisk/message.h0000644000175000007640000001715011763214744020427 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * Russell Bryant * * 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 Out-of-call text message support * * \author Russell Bryant * * The purpose of this API is to provide support for text messages that * are not session based. The messages are passed into the Asterisk core * to be routed through the dialplan and potentially sent back out through * a message technology that has been registered through this API. */ #ifndef __AST_MESSAGE_H__ #define __AST_MESSAGE_H__ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! * \brief A text message. * * This is an opaque type that represents a text message. */ struct ast_msg; /*! * \brief A message technology * * A message technology is capable of transmitting text messages. */ struct ast_msg_tech { /*! * \brief Name of this message technology * * This is the name that comes at the beginning of a URI for messages * that should be sent to this message technology implementation. * For example, messages sent to "xmpp:rbryant@digium.com" would be * passed to the ast_msg_tech with a name of "xmpp". */ const char * const name; /*! * \brief Send a message. * * \param msg the message to send * \param to the URI of where the message is being sent * \param from the URI of where the message was sent from * * The fields of the ast_msg are guaranteed not to change during the * duration of this function call. * * \retval 0 success * \retval non-zero failure */ int (* const msg_send)(const struct ast_msg *msg, const char *to, const char *from); }; /*! * \brief Register a message technology * * \retval 0 success * \retval non-zero failure */ int ast_msg_tech_register(const struct ast_msg_tech *tech); /*! * \brief Unregister a message technology. * * \retval 0 success * \retval non-zero failure */ int ast_msg_tech_unregister(const struct ast_msg_tech *tech); /*! * \brief Allocate a message. * * Allocate a message for the purposes of passing it into the Asterisk core * to be routed through the dialplan. If ast_msg_queue() is not called, this * message must be destroyed using ast_msg_destroy(). Otherwise, the message * core code will take care of it. * * \return A message object. This function will return NULL if an allocation * error occurs. */ struct ast_msg *ast_msg_alloc(void); /*! * \brief Destroy an ast_msg * * This should only be called on a message if it was not * passed on to ast_msg_queue(). * * \return NULL, always. */ struct ast_msg *ast_msg_destroy(struct ast_msg *msg); /*! * \brief Bump a msg's ref count */ struct ast_msg *ast_msg_ref(struct ast_msg *msg); /*! * \brief Set the 'to' URI of a message * * \retval 0 success * \retval -1 failure */ int __attribute__((format(printf, 2, 3))) ast_msg_set_to(struct ast_msg *msg, const char *fmt, ...); /*! * \brief Set the 'from' URI of a message * * \retval 0 success * \retval -1 failure */ int __attribute__((format(printf, 2, 3))) ast_msg_set_from(struct ast_msg *msg, const char *fmt, ...); /*! * \brief Set the 'body' text of a message (in UTF-8) * * \retval 0 success * \retval -1 failure */ int __attribute__((format(printf, 2, 3))) ast_msg_set_body(struct ast_msg *msg, const char *fmt, ...); /*! * \brief Set the dialplan context for this message * * \retval 0 success * \retval -1 failure */ int __attribute__((format(printf, 2, 3))) ast_msg_set_context(struct ast_msg *msg, const char *fmt, ...); /*! * \brief Set the dialplan extension for this message * * \retval 0 success * \retval -1 failure */ int __attribute__((format(printf, 2, 3))) ast_msg_set_exten(struct ast_msg *msg, const char *fmt, ...); /*! * \brief Set a variable on the message going to the dialplan. * \note Setting a variable that already exists overwrites the existing variable value * * \param name Name of variable to set * \param value Value of variable to set * * \retval 0 success * \retval -1 failure */ int ast_msg_set_var(struct ast_msg *msg, const char *name, const char *value); /*! * \brief Set a variable on the message being sent to a message tech directly. * \note Setting a variable that already exists overwrites the existing variable value * * \param name Name of variable to set * \param value Value of variable to set * * \retval 0 success * \retval -1 failure */ int ast_msg_set_var_outbound(struct ast_msg *msg, const char *name, const char *value); /*! * \brief Get the specified variable on the message * \note The return value is valid only as long as the ast_message is valid. Hold a reference * to the message if you plan on storing the return value. Do re-set the same * message var name while holding a pointer to the result of this function. * * \return The value associated with variable "name". NULL if variable not found. */ const char *ast_msg_get_var(struct ast_msg *msg, const char *name); /*! * \brief Get the body of a message. * \note The return value is valid only as long as the ast_message is valid. Hold a reference * to the message if you plan on storing the return value. * * \return The body of the messsage, encoded in UTF-8. */ const char *ast_msg_get_body(const struct ast_msg *msg); /*! * \brief Queue a message for routing through the dialplan. * * Regardless of the return value of this function, this funciton will take * care of ensuring that the message object is properly destroyed when needed. * * \retval 0 message successfully queued * \retval non-zero failure, message not sent to dialplan */ int ast_msg_queue(struct ast_msg *msg); /*! * \brief Send a msg directly to an endpoint. * * Regardless of the return value of this function, this funciton will take * care of ensuring that the message object is properly destroyed when needed. * * \retval 0 message successfully queued to be sent out * \retval non-zero failure, message not get sent out. */ int ast_msg_send(struct ast_msg *msg, const char *to, const char *from); /*! * \brief Opaque iterator for msg variables */ struct ast_msg_var_iterator; /*! * \brief Create a new message variable iterator * \param msg A message whose variables are to be iterated over * * \return An opaque pointer to the new iterator */ struct ast_msg_var_iterator *ast_msg_var_iterator_init(const struct ast_msg *msg); /*! * \brief Get the next variable name and value that is set for sending outbound * \param msg The message with the variables * \param i An iterator created with ast_msg_var_iterator_init * \param name A pointer to the name result pointer * \param value A pointer to the value result pointer * * \retval 0 No more entries * \retval 1 Valid entry */ int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iterator *i, const char **name, const char **value); /*! * \brief Destroy a message variable iterator * \param i Iterator to be destroyed */ void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *i); /*! * \brief Unref a message var from inside an iterator loop */ void ast_msg_var_unref_current(struct ast_msg_var_iterator *i); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* __AST_MESSAGE_H__ */ asterisk-11.7.0/include/asterisk/cel.h0000644000175000007640000002016711756746350017555 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008 - 2009, Digium, Inc. * * 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 Call Event Logging API * * \todo TODO: There some event types that have been defined here, but are not * yet used anywhere in the code. It would be really awesome if someone * went through and had Asterisk generate these events where it is * appropriate to do so. The defined, but unused events are: * CONF_ENTER, CONF_EXIT, CONF_START, CONF_END, 3WAY_START, 3WAY_END, * TRANSFER, and HOOKFLASH. */ #ifndef __AST_CEL_H__ #define __AST_CEL_H__ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/event.h" /*! * \brief AMA Flags * * \note This must much up with the AST_CDR_* defines for AMA flags. */ enum ast_cel_ama_flag { AST_CEL_AMA_FLAG_NONE, AST_CEL_AMA_FLAG_OMIT, AST_CEL_AMA_FLAG_BILLING, AST_CEL_AMA_FLAG_DOCUMENTATION, /*! \brief Must be final entry */ AST_CEL_AMA_FLAG_TOTAL, }; /*! * \brief CEL event types */ enum ast_cel_event_type { /*! \brief channel birth */ AST_CEL_CHANNEL_START = 1, /*! \brief channel end */ AST_CEL_CHANNEL_END = 2, /*! \brief hangup terminates connection */ AST_CEL_HANGUP = 3, /*! \brief A ringing phone is answered */ AST_CEL_ANSWER = 4, /*! \brief an app starts */ AST_CEL_APP_START = 5, /*! \brief an app ends */ AST_CEL_APP_END = 6, /*! \brief a bridge is established */ AST_CEL_BRIDGE_START = 7, /*! \brief a bridge is torn down */ AST_CEL_BRIDGE_END = 8, /*! \brief a conference is started */ AST_CEL_CONF_START = 9, /*! \brief a conference is ended */ AST_CEL_CONF_END = 10, /*! \brief a channel is parked */ AST_CEL_PARK_START = 11, /*! \brief channel out of the park */ AST_CEL_PARK_END = 12, /*! \brief a transfer occurs */ AST_CEL_BLINDTRANSFER = 13, /*! \brief a transfer occurs */ AST_CEL_ATTENDEDTRANSFER = 14, /*! \brief a transfer occurs */ AST_CEL_TRANSFER = 15, /*! \brief a 3-way conference, usually part of a transfer */ AST_CEL_HOOKFLASH = 16, /*! \brief a 3-way conference, usually part of a transfer */ AST_CEL_3WAY_START = 17, /*! \brief a 3-way conference, usually part of a transfer */ AST_CEL_3WAY_END = 18, /*! \brief channel enters a conference */ AST_CEL_CONF_ENTER = 19, /*! \brief channel exits a conference */ AST_CEL_CONF_EXIT = 20, /*! \brief a user-defined event, the event name field should be set */ AST_CEL_USER_DEFINED = 21, /*! \brief the last channel with the given linkedid is retired */ AST_CEL_LINKEDID_END = 22, /*! \brief a masquerade happened to alter the participants on a bridge */ AST_CEL_BRIDGE_UPDATE = 23, /*! \brief a directed pickup was performed on this channel */ AST_CEL_PICKUP = 24, /*! \brief this call was forwarded somewhere else */ AST_CEL_FORWARD = 25, }; /*! * \brief Check to see if CEL is enabled * * \since 1.8 * * \retval zero not enabled * \retval non-zero enabled */ unsigned int ast_cel_check_enabled(void); /*! * \brief Allocate a CEL record * * \since 1.8 * * \note The CEL record must be destroyed with ast_cel_destroy(). * * \retval non-NULL an allocated ast_cel structure * \retval NULL error */ struct ast_cel *ast_cel_alloc(void); /*! * \brief Destroy a CEL record. * * \param cel the record to destroy * * \since 1.8 * * \return nothing. */ void ast_cel_destroy(struct ast_cel *cel); /*! * \brief Get the name of a CEL event type * * \param type the type to get the name of * * \since 1.8 * * \return the string representation of the type */ const char *ast_cel_get_type_name(enum ast_cel_event_type type); /*! * \brief Get the event type from a string * * \param name the event type name as a string * * \since 1.8 * * \return the ast_cel_event_type given by the string */ enum ast_cel_event_type ast_cel_str_to_event_type(const char *name); /*! * \brief Convert AMA flag to printable string * * \param[in] flag the flag to convert to a string * * \since 1.8 * * \return the string representation of the flag */ const char *ast_cel_get_ama_flag_name(enum ast_cel_ama_flag flag); /*! * \brief Check and potentially retire a Linked ID * * \param chan channel that is being destroyed or its linkedid is changing * * \since 1.8 * * If at least one CEL backend is looking for CEL_LINKEDID_END * events, this function will check if the given channel is the last * active channel with that linkedid, and if it is, emit a * CEL_LINKEDID_END event. * * \return nothing */ void ast_cel_check_retire_linkedid(struct ast_channel *chan); /*! * \brief Inform CEL that a new linkedid is being used * \since 11 * * \retval -1 error * \retval 0 success */ int ast_cel_linkedid_ref(const char *linkedid); /*! * \brief Create a fake channel from data in a CEL event * * \note * This function creates a fake channel containing the * serialized channel data in the given cel event. It should be * released with ast_channel_unref() but could be released with * ast_channel_release(). * * \param event the CEL event * * \since 1.8 * * \return a channel with the data filled in, or NULL on error * * \todo This function is \b very expensive, especially given that some CEL backends * use it on \b every CEL event. This function really needs to go away at * some point. */ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event *event); /*! * \brief Report a channel event * * \param chan This argument is required. This is the primary channel associated with * this channel event. * \param event_type This is the type of call event being reported. * \param userdefevname This is an optional custom name for the call event. * \param extra This is an optional opaque field that will go into the "CEL_EXTRA" * information element of the call event. * \param peer2 All CEL events contain a "peer name" information element. The first * place the code will look to get a peer name is from the bridged channel to * chan. If chan has no bridged channel and peer2 is specified, then the name * of peer2 will go into the "peer name" field. If neither are available, the * peer name field will be blank. * * \since 1.8 * * \pre chan and peer2 are both unlocked * * \retval 0 success * \retval non-zero failure */ int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2); /*! * \brief Helper struct for getting the fields out of a CEL event */ struct ast_cel_event_record { /*! * \brief struct ABI version * \note This \b must be incremented when the struct changes. */ #define AST_CEL_EVENT_RECORD_VERSION 2 /*! * \brief struct ABI version * \note This \b must stay as the first member. */ uint32_t version; enum ast_cel_event_type event_type; struct timeval event_time; const char *event_name; const char *user_defined_name; const char *caller_id_name; const char *caller_id_num; const char *caller_id_ani; const char *caller_id_rdnis; const char *caller_id_dnid; const char *extension; const char *context; const char *channel_name; const char *application_name; const char *application_data; const char *account_code; const char *peer_account; const char *unique_id; const char *linked_id; uint amaflag; const char *user_field; const char *peer; const char *extra; }; /*! * \brief Fill in an ast_cel_event_record from a CEL event * * \param[in] event the CEL event * \param[out] r the ast_cel_event_record to fill in * * \since 1.8 * * \retval 0 success * \retval non-zero failure */ int ast_cel_fill_record(const struct ast_event *event, struct ast_cel_event_record *r); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* __AST_CEL_H__ */ asterisk-11.7.0/include/asterisk/threadstorage.h0000644000175000007640000001651011403452732021626 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2006, Digium, Inc. * * Russell Bryant * * 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 threadstorage.h * \author Russell Bryant * \brief Definitions to aid in the use of thread local storage * * \arg \ref AstThreadStorage */ /*! * \page AstThreadStorage The Asterisk Thread Storage API * * * The POSIX threads (pthreads) API provides the ability to define thread * specific data. The functions and structures defined here are intended * to centralize the code that is commonly used when using thread local * storage. * * The motivation for using this code in Asterisk is for situations where * storing data on a thread-specific basis can provide some amount of * performance benefit. For example, there are some call types in Asterisk * where ast_frame structures must be allocated very rapidly (easily 50, 100, * 200 times a second). Instead of doing the equivalent of that many calls * to malloc() and free() per second, thread local storage is used to keep a * list of unused frame structures so that they can be continuously reused. * * - \ref threadstorage.h */ #ifndef ASTERISK_THREADSTORAGE_H #define ASTERISK_THREADSTORAGE_H #include "asterisk/utils.h" #include "asterisk/inline_api.h" /*! * \brief data for a thread locally stored variable */ struct ast_threadstorage { pthread_once_t once; /*!< Ensure that the key is only initialized by one thread */ pthread_key_t key; /*!< The key used to retrieve this thread's data */ void (*key_init)(void); /*!< The function that initializes the key */ int (*custom_init)(void *); /*!< Custom initialization function specific to the object */ }; #if defined(DEBUG_THREADLOCALS) void __ast_threadstorage_object_add(void *key, size_t len, const char *file, const char *function, unsigned int line); void __ast_threadstorage_object_remove(void *key); void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len); #endif /* defined(DEBUG_THREADLOCALS) */ /*! * \brief Define a thread storage variable * * \param name The name of the thread storage object * * This macro would be used to declare an instance of thread storage in a file. * * Example usage: * \code * AST_THREADSTORAGE(my_buf); * \endcode */ #define AST_THREADSTORAGE(name) \ AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr, static) #define AST_THREADSTORAGE_PUBLIC(name) \ AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr,) #define AST_THREADSTORAGE_EXTERNAL(name) \ extern struct ast_threadstorage name /*! * \brief Define a thread storage variable, with custom initialization and cleanup * * \param a The name of the thread storage object * \param b This is a custom function that will be called after each thread specific * object is allocated, with the allocated block of memory passed * as the argument. * \param c This is a custom function that will be called instead of ast_free * when the thread goes away. Note that if this is used, it *MUST* * call free on the allocated memory. * * Example usage: * \code * AST_THREADSTORAGE_CUSTOM(my_buf, my_init, my_cleanup); * \endcode */ #define AST_THREADSTORAGE_CUSTOM(a,b,c) AST_THREADSTORAGE_CUSTOM_SCOPE(a,b,c,static) #if defined(PTHREAD_ONCE_INIT_NEEDS_BRACES) # define AST_PTHREAD_ONCE_INIT { PTHREAD_ONCE_INIT } #else # define AST_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #endif #if !defined(DEBUG_THREADLOCALS) #define AST_THREADSTORAGE_CUSTOM_SCOPE(name, c_init, c_cleanup, scope) \ static void __init_##name(void); \ scope struct ast_threadstorage name = { \ .once = AST_PTHREAD_ONCE_INIT, \ .key_init = __init_##name, \ .custom_init = c_init, \ }; \ static void __init_##name(void) \ { \ pthread_key_create(&(name).key, c_cleanup); \ } #else /* defined(DEBUG_THREADLOCALS) */ #define AST_THREADSTORAGE_CUSTOM_SCOPE(name, c_init, c_cleanup, scope) \ static void __init_##name(void); \ scope struct ast_threadstorage name = { \ .once = AST_PTHREAD_ONCE_INIT, \ .key_init = __init_##name, \ .custom_init = c_init, \ }; \ static void __cleanup_##name(void *data) \ { \ __ast_threadstorage_object_remove(data); \ c_cleanup(data); \ } \ static void __init_##name(void) \ { \ pthread_key_create(&(name).key, __cleanup_##name); \ } #endif /* defined(DEBUG_THREADLOCALS) */ /*! * \brief Retrieve thread storage * * \param ts This is a pointer to the thread storage structure declared by using * the AST_THREADSTORAGE macro. If declared with * AST_THREADSTORAGE(my_buf), then this argument would be (&my_buf). * \param init_size This is the amount of space to be allocated the first time * this thread requests its data. Thus, this should be the size that the * code accessing this thread storage is assuming the size to be. * * \return This function will return the thread local storage associated with * the thread storage management variable passed as the first argument. * The result will be NULL in the case of a memory allocation error. * * Example usage: * \code * AST_THREADSTORAGE(my_buf); * #define MY_BUF_SIZE 128 * ... * void my_func(const char *fmt, ...) * { * void *buf; * * if (!(buf = ast_threadstorage_get(&my_buf, MY_BUF_SIZE))) * return; * ... * } * \endcode */ #if !defined(DEBUG_THREADLOCALS) AST_INLINE_API( void *ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size), { void *buf; pthread_once(&ts->once, ts->key_init); if (!(buf = pthread_getspecific(ts->key))) { if (!(buf = ast_calloc(1, init_size))) return NULL; if (ts->custom_init && ts->custom_init(buf)) { free(buf); return NULL; } pthread_setspecific(ts->key, buf); } return buf; } ) #else /* defined(DEBUG_THREADLOCALS) */ AST_INLINE_API( void *__ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size, const char *file, const char *function, unsigned int line), { void *buf; pthread_once(&ts->once, ts->key_init); if (!(buf = pthread_getspecific(ts->key))) { if (!(buf = ast_calloc(1, init_size))) return NULL; if (ts->custom_init && ts->custom_init(buf)) { free(buf); return NULL; } pthread_setspecific(ts->key, buf); __ast_threadstorage_object_add(buf, init_size, file, function, line); } return buf; } ) #define ast_threadstorage_get(ts, init_size) __ast_threadstorage_get(ts, init_size, __FILE__, __PRETTY_FUNCTION__, __LINE__) #endif /* defined(DEBUG_THREADLOCALS) */ #endif /* ASTERISK_THREADSTORAGE_H */ asterisk-11.7.0/include/asterisk/compat.h0000644000175000007640000001052512076603347020264 0ustar sharkyjerryweb/* * Asterisk -- A telephony toolkit for Linux. * * Copyright (C) 1999-2006, Digium, Inc. * * Mark Spencer * * This program is free software, distributed under the terms of * the GNU General Public License */ /*! \file * \brief General Definitions for Asterisk top level program * Included by asterisk.h to handle platform-specific issues * especially those related to header files. */ #include "asterisk/compiler.h" #ifndef _COMPAT_H #define _COMPAT_H #ifndef __STDC_VERSION__ /* flex output wants to find this defined. */ #define __STDC_VERSION__ 0 #endif #ifdef HAVE_INTTYPES_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STDDEF_H #include #endif #ifdef HAVE_STDINT_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_ALLOCA_H #include /* not necessarily present - could be in stdlib */ #elif defined(HAVE_ALLOCA) && defined(__MINGW32__) #include /* see if it is here... */ #endif #include /* this is always present */ #ifdef HAVE_STRING_H #include #endif #ifndef AST_POLL_COMPAT #include #else #include "asterisk/poll-compat.h" #endif #ifndef HAVE_LLONG_MAX #define LLONG_MAX 9223372036854775807LL #endif #ifndef HAVE_CLOSEFROM void closefrom(int lowfd); #endif #if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt, ...); #endif #ifndef HAVE_FFSLL int ffsll(long long n); #endif #ifndef HAVE_GETLOADAVG int getloadavg(double *list, int nelem); #endif #ifndef HAVE_HTONLL uint64_t htonll(uint64_t host64); #endif #ifndef HAVE_MKDTEMP char *mkdtemp(char *template_s); #endif #ifndef HAVE_NTOHLL uint64_t ntohll(uint64_t net64); #endif #ifndef HAVE_SETENV int setenv(const char *name, const char *value, int overwrite); #endif #ifndef HAVE_STRCASESTR char *strcasestr(const char *, const char *); #endif #if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) char *strndup(const char *, size_t); #endif #ifndef HAVE_STRNLEN size_t strnlen(const char *, size_t); #endif #ifndef HAVE_STRSEP char* strsep(char** str, const char* delims); #endif #ifndef HAVE_STRTOQ uint64_t strtoq(const char *nptr, char **endptr, int base); #endif #ifndef HAVE_UNSETENV int unsetenv(const char *name); #endif #if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap); #endif #ifndef HAVE_TIMERSUB void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff); #endif #define strlcat __use__ast_str__functions_not__strlcat__ #define strlcpy __use__ast_copy_string__not__strlcpy__ #include #ifdef SOLARIS #define __BEGIN_DECLS #define __END_DECLS #ifndef __P #define __P(p) p #endif #include #include #include #include #include #include #include #include #include #ifndef BYTE_ORDER #define LITTLE_ENDIAN 1234 #define BIG_ENDIAN 4321 #ifdef __sparc__ #define BYTE_ORDER BIG_ENDIAN #else #define BYTE_ORDER LITTLE_ENDIAN #endif #endif #ifndef __BYTE_ORDER #define __LITTLE_ENDIAN LITTLE_ENDIAN #define __BIG_ENDIAN BIG_ENDIAN #define __BYTE_ORDER BYTE_ORDER #endif #ifndef __BIT_TYPES_DEFINED__ #define __BIT_TYPES_DEFINED__ typedef unsigned char u_int8_t; typedef unsigned short u_int16_t; typedef unsigned int u_int32_t; typedef unsigned int uint; #endif #endif /* SOLARIS */ #ifdef __CYGWIN__ #define _WIN32_WINNT 0x0500 #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 46 #endif #endif /* __CYGWIN__ */ #ifdef __CYGWIN__ typedef unsigned long long uint64_t; #endif /* glob compat stuff */ #if defined(__Darwin__) || defined(__CYGWIN__) #define GLOB_ABORTED GLOB_ABEND #endif #include #if !defined(HAVE_GLOB_NOMAGIC) || !defined(HAVE_GLOB_BRACE) #define MY_GLOB_FLAGS GLOB_NOCHECK #else #define MY_GLOB_FLAGS (GLOB_NOMAGIC | GLOB_BRACE) #endif #ifndef HAVE_ROUNDF #ifdef HAVE_ROUND #define roundf(x) ((float)round(x)) #else float roundf(float x); #endif #endif #endif asterisk-11.7.0/include/asterisk/astosp.h0000644000175000007640000000162510526677265020323 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Open Settlement Protocol (OSP) */ #ifndef _ASTERISK_OSP_H #define _ASTERISK_OSP_H #define AST_OSP_SUCCESS ((char*)"SUCCESS") /* Return status, success */ #define AST_OSP_FAILED ((char*)"FAILED") /* Return status, failed */ #define AST_OSP_ERROR ((char*)"ERROR") /* Return status, error */ #endif /* _ASTERISK_OSP_H */ asterisk-11.7.0/include/asterisk/musiconhold.h0000644000175000007640000000333310646556514021330 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Music on hold handling */ #ifndef _ASTERISK_MOH_H #define _ASTERISK_MOH_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! * \brief Turn on music on hold on a given channel * * \param chan The channel structure that will get music on hold * \param mclass The class to use if the musicclass is not currently set on * the channel structure. * \param interpclass The class to use if the musicclass is not currently set on * the channel structure or in the mclass argument. * * \retval Zero on success * \retval non-zero on failure */ int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass); /*! Turn off music on hold on a given channel */ void ast_moh_stop(struct ast_channel *chan); void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *, const char *), void (*stop_ptr)(struct ast_channel *), void (*cleanup_ptr)(struct ast_channel *)); void ast_uninstall_music_functions(void); void ast_moh_cleanup(struct ast_channel *chan); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_MOH_H */ asterisk-11.7.0/include/asterisk/doxyref.h0000644000175000007640000006020012045106335020443 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * 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 * * This is the main header file used for generating miscellaneous developer * documentation using doxygen. This also pulls in all of the documentation * that is in include/asterisk/doxygen/. */ /* * The following is for Doxygen Developer's documentation generated * by running "make progdocs" with doxygen installed on your * system. */ /*! * \page DevDoc Asterisk Developer's Documentation - Appendices * * \section devpolicy Development and Release Policies * \arg \ref CodeGuide : The must-read document for all developers * \arg \ref CommitMessages : Information on formatting and special tags for commit messages * \arg \ref ReleaseStatus : The current support level for various Asterisk releases * \arg \ref ReleasePolicies : Asterisk Release and Commit Policies * \arg \ref Reviewboard : Reviewboard Usage and Guidelines * \arg \ref MantisWorkflow : Workflow Guidelines for Asterisk Open Source Issue Tracker * \arg \ref AsteriskGitHowto : How to setup a local GIT mirror of the Asterisk SVN repository * \arg \ref AstCREDITS : A Thank You to contributors (unfortunately out of date) * * \section apisandinterfaces Asterisk APIs and Interfaces * \arg \ref AstAPI * \arg \ref AstAPIChanges * \arg \ref Def_Channel : What's a channel, anyway? * \arg \ref channel_drivers : Existing channel drivers * \arg \ref AstAMI : The Call management socket API * \arg \ref AstARA : A generic data storage and retrieval API for Asterisk * \arg \ref AstDUNDi : A way to find phone services dynamically by using the DUNDi protocol * \arg \ref AJI_intro : The Asterisk Jabber Interface * \arg \ref AstCDR * \arg \ref AstVar * \arg \ref AstVideo * \arg \ref AstENUM : The IETF way to redirect from phone numbers to VoIP calls * \arg \ref AstHTTP * \arg \ref AstSpeech * * \section debugconfig Debugging and Configuration References * \arg \ref AstREADME : General Administrator README file * \arg \ref AstDebug : Hints on debugging * \arg \ref extref * \arg \ref ConfigFiles * \arg \ref SoundFiles included in the Asterisk distribution * * \section weblinks Web sites * \arg \b Main: Asterisk Developer's website http://www.asterisk.org/developers/ * \arg \b Bugs: The Issue Tracker https://issues.asterisk.org * \arg \b Lists: List Server http://lists.digium.com * \arg \b Wiki: The Asterisk Wiki http://wiki.asterisk..org * \arg \b Docs: The Asterisk Documentation Project http://www.asteriskdocs.org * \arg \b Digium: The Asterisk Company http://www.digium.com */ /*! * \page CodeGuide Coding Guidelines * \AsteriskTrunkWarning * \section Coding Guidelines * This file is in the /doc directory in your Asterisk source tree. * Make sure to stay up to date with the latest guidelines. * \verbinclude CODING-GUIDELINES */ /*! * \page AstAPI Asterisk API * \section Asteriskapi Asterisk API * Some generic documents on the Asterisk architecture * * \arg \ref AstThreadStorage * \arg \ref DataStores * \arg \ref AstExtState * \arg \ref AstDataRetrieval * * \subsection model_txt Generic Model * Description of call model: * Incoming Call: * Channel backend waits for a RING or equivalent on some sort of * interface. Typically this is done in its own thread. When a RING is * detected, the backend should create a channel structure and then call * ast_pbx_start() on that channel, which will create a thread to monitor * that interface. At this point, the PBX and/or applications it launches * will manage the interface, and it need not be monitored by the * aforementioned thread. When the applications are finished, the requisite * hangup function will be called, at which the channel can be considered to * be no longer valid, and the thread that controls it will imminently be * terminated. * * * \todo Link to wiki content * \subsection channel_txt Channels * \arg See \ref Def_Channel */ /*! * \page AstAPIChanges Asterisk API Changes * * \section Changes161 Version 1.6.1 * \li ast_install_vm_functions() * \li vmwi_generate() * \li ast_channel_datastore_alloc() * \li ast_channel_datastore_free() * \li ast_channel_cmpwhentohangup() * \li ast_channel_setwhentohangup() * \li ast_settimeout() * \li ast_datastore_alloc() * \li ast_datastore_free() * \li ast_device_state_changed() * \li ast_device_state_changed_literal() * \li ast_dnsmgr_get() * \li ast_dnsmgr_lookup() * \li ast_dsp_set_digitmode() * \li ast_get_txt() * \li ast_event_unsubscribe() * \li localized_context_find_or_create() * \li localized_merge_contexts_and_delete() * \li ast_console_puts_mutable() * \li ast_rtp_get_quality() * \li ast_tcptls_client_start() * \li ast_tcptls_server_start() * \li ast_tcptls_server_stop() * * \section Changes162 Version 1.6.2 * * \section Changes18 Version 1.8 * \li ast_channel_alloc() */ /*! * \page AstDebug Debugging * \section debug Debugging * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace * for more information */ /*! * \page AstSpeech The Generic Speech Recognition API * \section debug The Generic Speech Recognition API * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/Speech+Recognition+API * for more information */ /*! * \page DataStores Channel Data Stores * \section debug Channel Data Stores * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/Asterisk+Channel+Data+Stores * for more information */ /*! * \page AstAMI AMI - The Manager Interface * \section ami AMI - The manager Interface * \arg \link Config_ami Configuration file \endlink * \arg \ref manager.c * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/Asterisk+Manager+Interface+%28AMI%29 * for more information */ /*! * \page AstARA ARA - The Asterisk Realtime Interface * \section realtime ARA - a generic API to storage and retrieval * Implemented in \ref config.c * Implemented in \ref pbx_realtime.c * https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration */ /*! * \page AstDUNDi DUNDi * * DUNDi is a peer-to-peer system for locating Internet gateways to telephony * services. Unlike traditional centralized services (such as the remarkably * simple and concise ENUM standard), DUNDi is fully-distributed with no * centralized authority whatsoever. * * DUNDi is not itself a Voice-over IP signaling or media protocol. Instead, * it publishes routes which are in turn accessed via industry standard * protocols such as IAX, SIP and H.323. * * \par References * \arg DUNDi is documented at http://www.dundi.com * \arg Implemented in \ref pbx_dundi.c and \ref dundi-parser.c * \arg Configuration in \ref dundi.conf */ /*! * \page AstCDR CDR - Call Data Records and billing * \section cdr Call Data Records * \par See also * \arg \ref cdr.c * \arg \ref cdr_drivers * \arg \ref Config_cdr CDR configuration files * * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/CDR+Storage+Backends * for more information */ /*! * \page AstREADME README * \verbinclude README */ /*! * \page AstCREDITS CREDITS * \verbinclude CREDITS */ /*! * \page AstVideo Video support in Asterisk * \section sectAstVideo Video support in Asterisk * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/Video+Telephony * for more information */ /*! * \page AstVar Globally predefined channel variables * \section globchan Globally predefined channel variables * * More and more of these variables are being replaced by dialplan functions. * Some still exist though and some that does still exist needs to move to * dialplan functions. * * See also * - \ref pbx_retrieve_variable() * - \ref AstChanVar * * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/Channel+Variables * for more information */ /*! * \page AstChanVar Asterisk Dialplan Variables * Asterisk Dialplan variables are divided into three groups: * - Predefined global variables, handled by the PBX core * - Global variables, that exist for the duration of the pbx execution * - Channel variables, that exist during a channel * * Global variables are reachable in all channels, all of the time. * Channel variables are only reachable within the channel. * * For more information on the predefined variables, see \ref AstVar * * Global and Channel variables: * - Names are Case insensitive * - Names that start with a character, but are alphanumeric * - Global variables are defined and reached with the GLOBAL() dialplan function * and the set application, like * * exten => 1234,1,set(GLOBAL(myvariable)=tomteluva) * * - \ref func_global.c * * - Channel variables are defined with the set() dialplan application * * exten => 1234,1,set(xmasattribute=tomtegröt) * * - Some channels also supports setting channel variables with the \b setvar= * configuraiton option for a device or line. * * \section AstChanVar_globalvars Global Variables * Global variables can also be set in the [globals] section of extensions.conf. The * setting \b clearglobalvars in extensions.conf [general] section affects whether * or not the global variables defined in \b globals are reset at dialplan reload. * * There are CLI commands to change and read global variables. This can be handy * to reset counters at midnight from an external script. * * \section AstChanVar_devnotes Developer notes * Variable handling is managed within \ref pbx.c * You need to include pbx.h to reach these functions. * - \ref pbx_builtin_setvar_helper() * - \ref pbx_builtin_getvar_helper() * * The variables is a linked list stored in the channel data structure * with the list starting at varshead in struct ast_channel */ /*! * \page AstENUM ENUM * \section enumreadme ENUM * \arg Configuration: \ref Config_enum * \arg \ref enum.c * \arg \ref func_enum.c * * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/The+ENUMLOOKUP+Dialplan+Function * for more information */ /*! * \page ConfigFiles Configuration files * \section config Main configuration files * \arg \link Config_ast asterisk.conf - the main configuration file \endlink * \arg \link Config_ext extensions.conf - The Dial Plan \endlink * \arg \link Config_mod modules.conf - which modules to load and not to load \endlink * \arg \link Config_fea features.conf - call features (transfer, parking, etc) \endlink * \section chanconf Channel configuration files * \arg \link Config_iax IAX2 configuration \endlink * \arg \link Config_sip SIP configuration \endlink * \arg \link Config_mgcp MGCP configuration \endlink * \arg \link Config_rtp RTP configuration \endlink * \arg \link Config_dahdi DAHDI configuration \endlink * \arg \link Config_oss OSS (sound card) configuration \endlink * \arg \link Config_alsa ALSA (sound card) configuration \endlink * \arg \link Config_agent Agent (proxy channel) configuration \endlink * \arg \link Config_misdn MISDN Experimental ISDN BRI channel configuration \endlink * \arg \link Config_h323 H.323 configuration \endlink * \section appconf Application configuration files * \arg \link Config_mm Meetme (conference bridge) configuration \endlink * \arg \link Config_qu Queue system configuration \endlink * \arg \link Config_vm Voicemail configuration \endlink * \arg \link Config_followme Followme configuration \endlink * \section cdrconf CDR configuration files * \arg \link Config_cdr CDR configuration \endlink * \arg \link cdr_csv Default CDR driver configuration \endlink * \arg \link cdr_custom Custom CDR driver configuration \endlink * \arg \link cdr_ami Manager CDR driver configuration \endlink * \arg \link cdr_odbc ODBC CDR driver configuration \endlink * \arg \link cdr_adaptive_odbc Adaptive ODBC CDR driver configuration \endlink * \arg \link cdr_pgsql PostgreSQL CDR driver configuration \endlink * \arg \link cdr_radius RADIUS CDR driver configuration \endlink * \arg \link cdr_sqlite SQLite 2 CDR driver configuration \endlink * \arg \link cdr_sqlite3_custom SQLite 3 CDR driver configuration \endlink * \arg \link cdr_syslog Syslog CDR driver configuration \endlink * \arg \link cdr_tds FreeTDS CDR driver configuration (Microsoft SQL Server) \endlink * \section miscconf Miscellenaous configuration files * \arg \link Config_adsi ADSI configuration \endlink * \arg \link Config_ami AMI - Manager configuration \endlink * \arg \link Config_ara Realtime configuration \endlink * \arg \link Config_codec Codec configuration \endlink * \arg \link Config_dun DUNDi configuration \endlink * \arg \link Config_enum ENUM configuration \endlink * \arg \link Config_moh Music on Hold configuration \endlink * \arg \link Config_vm Voicemail configuration \endlink * \arg \link res_config_sqlite SQLite Resource driver configuration \endlink */ /*! * \page Config_ast Asterisk.conf * \verbinclude asterisk-conf.txt */ /*! * \page Config_mod Modules configuration * All res_ resource modules are loaded with globals on, which means * that non-static functions are callable from other modules. * * If you want your non res_* module to export functions to other modules * you have to include it in the [global] section. * \verbinclude modules.conf.sample */ /*! * \page Config_fea Call features configuration * \par See also * \arg \ref features.c : Call feature implementation * \section featconf features.conf * \verbinclude features.conf.sample */ /*! * \page Config_followme Followme: An application for simple follow-me calls * \section followmeconf Followme.conf * - See app_followme.c * \verbinclude followme.conf.sample */ /*! * \page Config_ext Extensions.conf - the Dial Plan * \section dialplan Extensions.conf * \verbinclude extensions.conf.sample */ /*! * \page Config_iax IAX2 configuration * IAX2 is implemented in \ref chan_iax2.c * \arg \link Config_iax iax.conf Configuration file example \endlink * \section iaxreadme IAX2 * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/Inter-Asterisk+eXchange+protocol%2C+version+2+%28IAX2%29 * for more information * \section Config_iax IAX Configuration example * \verbinclude iax.conf.sample * \section iaxjitter IAX Jitterbuffer information * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/IAX2+Jitterbuffer * for more information */ /*! * \page Config_iax IAX configuration * \arg Implemented in \ref chan_iax2.c * \section iaxconf iax.conf * \verbinclude iax.conf.sample */ /*! * \page Config_sip SIP configuration * Also see \ref Config_rtp RTP configuration * \arg Implemented in \ref chan_sip.c * \section sipconf sip.conf * \verbinclude sip.conf.sample * * \arg \b Back \ref chanconf */ /*! * \page Config_mgcp MGCP configuration * Also see \ref Config_rtp RTP configuration * \arg Implemented in \ref chan_mgcp.c * \section mgcpconf mgcp.conf * \verbinclude mgcp.conf.sample */ /*! * \page README_misdn MISDN documentation * \arg See \ref Config_misdn * \section mISDN configuration * Please see the documentation on the wiki at * https://wiki.asterisk.org/wiki/display/AST/mISDN * for more information */ /*! * \page Config_misdn MISDN configuration * \arg Implemented in \ref chan_misdn.c * \arg \ref README_misdn * \arg See the mISDN home page: http://www.isdn4linux.de/mISDN/ * \section misdnconf misdn.conf * \verbinclude misdn.conf.sample */ /*! * \page Config_vm VoiceMail configuration * \section vmconf voicemail.conf * \arg Implemented in \ref app_voicemail.c * \verbinclude voicemail.conf.sample */ /*! * \page Config_dahdi DAHDI configuration * \section dahdiconf dahdi.conf * \arg Implemented in \ref chan_dahdi.c * \verbinclude dahdi.conf.sample */ /*! * \page Config_h323 H.323 channel driver information * This is the configuration of the H.323 channel driver within the Asterisk * distribution. There's another one, called OH323, in asterisk-addons * \arg Implemented in \ref chan_h323.c * \section h323conf h323.conf * \ref chan_h323.c */ /*! * \page Config_oss OSS configuration * \section ossconf oss.conf * \arg Implemented in \ref chan_oss.c * \verbinclude oss.conf.sample */ /*! * \page Config_alsa ALSA configuration * \section alsaconf alsa.conf * \arg Implemented in \ref chan_alsa.c * \verbinclude alsa.conf.sample */ /*! * \page Config_agent Agent configuration * \section agentconf agents.conf * The agent channel is a proxy channel for queues * \arg Implemented in \ref chan_agent.c * \verbinclude agents.conf.sample */ /*! * \page Config_rtp RTP configuration * \arg Implemented in \ref rtp.c * Used in \ref chan_sip.c and \ref chan_mgcp.c (and various H.323 channels) * \section rtpconf rtp.conf * \verbinclude rtp.conf.sample */ /*! * \page Config_dun DUNDi Configuration * \arg See also \ref AstDUNDi * \section dundiconf dundi.conf * \verbinclude dundi.conf.sample */ /*! * \page Config_enum ENUM Configuration * \section enumconf enum.conf * \arg See also \ref enumreadme * \arg Implemented in \ref func_enum.c and \ref enum.c * \verbinclude enum.conf.sample */ /*! * \page cdr_csv Default CDR driver configuration * \par See also * \arg \ref cdrconf * \arg Implemented in \ref cdr_csv.c * \verbinclude cdr_csv.conf.sample */ /*! * \page cdr_custom Custom CDR Configuration * \par See also * \arg \ref cdrconf * \arg Implemented in \ref cdr_custom.c * \verbinclude cdr_custom.conf.sample */ /*! * \page cdr_ami Manager CDR driver configuration * \par See also * \arg \ref cdrconf * \arg \ref AstAMI * \arg Implemented in \ref cdr_manager.c * \verbinclude cdr_manager.conf.sample */ /*! * \page cdr_odbc ODBC CDR driver configuration * \arg See also \ref cdrconf * \arg Implemented in \ref cdr_odbc.c * \verbinclude cdr_odbc.conf.sample * See also: * \arg http://www.unixodbc.org */ /*! * \page cdr_odbc Adaptive ODBC CDR driver configuration * \arg See also \ref cdrconf * \arg Implemented in \ref cdr_adaptive_odbc.c * \verbinclude cdr_adaptive_odbc.conf.sample * See also: * \arg http://www.unixodbc.org */ /*! * \page cdr_pgsql PostgreSQL CDR driver configuration * \arg See also \ref cdrconf * \arg Implemented in \ref cdr_pgsql.c * See also: * \arg http://www.postgresql.org * \verbinclude cdr_pgsql.conf.sample */ /*! * \page cdr_radius RADIUS CDR driver configuration * \arg See also \ref cdrconf * \arg Implemented in \ref cdr_radius.c * \verbinclude cdr_radius.conf.sample */ /*! * \page cdr_sqlite SQLite 2 CDR driver configuration * \arg See also \ref cdrconf * \arg Implemented in \ref cdr_sqlite.c * See also: * \arg http://www.sqlite.org */ /*! * \page cdr_sqlite3_custom SQLite 3 CDR driver configuration * \arg See also \ref cdrconf * \arg Implemented in \ref cdr_sqlite3_custom.c * See also: * \arg http://www.sqlite.org * \verbinclude cdr_sqlite3_custom.conf.sample */ /*! * \page cdr_syslog Syslog CDR driver configuration * \arg See also \ref cdrconf * \arg \ref cdr_syslog.c * \verbinclude cdr_syslog.conf.sample */ /*! * \page cdr_tds FreeTDS CDR driver configuration * \arg See also \ref cdrconf * See also: * \arg http://www.freetds.org * \verbinclude cdr_tds.conf.sample */ /*! * \page Config_cdr CDR configuration * \par See also * \arg \ref cdr_drivers * \arg \link Config_cdr CDR configuration \endlink * \arg \link cdr_csv Default CDR driver configuration \endlink * \arg \link cdr_custom Custom CDR driver configuration \endlink * \arg \link cdr_ami Manager CDR driver configuration \endlink * \arg \link cdr_odbc ODBC CDR driver configuration \endlink * \arg \link cdr_adaptive_odbc Adaptive ODBC CDR driver configuration \endlink * \arg \link cdr_pgsql PostgreSQL CDR driver configuration \endlink * \arg \link cdr_radius RADIUS CDR driver configuration \endlink * \arg \link cdr_sqlite SQLite 2 CDR driver configuration \endlink * \arg \link cdr_sqlite3_custom SQLite 3 CDR driver configuration \endlink * \arg \link cdr_syslog Syslog CDR driver configuration \endlink * \arg \link cdr_tds FreeTDS CDR driver configuration (Microsoft SQL Server) \endlink * \verbinclude cdr.conf.sample */ /*! * \page Config_moh Music on Hold Configuration * \arg Implemented in \ref res_musiconhold.c * \section mohconf musiconhold.conf * \verbinclude musiconhold.conf.sample */ /*! * \page Config_adsi ADSI Configuration * \section adsiconf adsi.conf * \verbinclude adsi.conf.sample */ /*! * \page Config_codec CODEC Configuration * \section codecsconf codecs.conf * \verbinclude codecs.conf.sample */ /*! * \page Config_ara REALTIME Configuration * \arg See also: \arg \link AstARA \endlink * \section extconf extconfig.conf * \verbinclude extconfig.conf.sample */ /*! * \page Config_ami AMI configuration * \arg See also: \arg \link AstAMI \endlink * \section amiconf manager.conf * \verbinclude manager.conf.sample */ /*! * \page Config_qu ACD - Queue system configuration * \arg Implemented in \ref app_queue.c * \section quconf queues.conf * \verbinclude queues.conf.sample */ /*! * \page Config_mm Meetme - The conference bridge configuration * \arg Implemented in \ref app_meetme.c * \section mmconf meetme.conf * \verbinclude meetme.conf.sample */ /*! * \page SoundFiles Sound files * \section SecSound Asterisk Sound files * Asterisk includes a large number of sound files. Many of these * are used by applications and demo scripts within asterisk. * * Additional sound files are available in the asterisk-addons * repository on svn.digium.com */ /*! * \addtogroup cdr_drivers Module: CDR Drivers * \section CDR_generic Asterisk CDR Drivers * \brief CDR drivers are loaded dynamically, each loaded CDR driver produce * a billing record for each call. * \arg \ref Config_mod "Modules Configuration" * \arg \ref Config_cdr "CDR Configuration" */ /*! * \addtogroup channel_drivers Module: Asterisk Channel Drivers * \section channel_generic Asterisk Channel Drivers * \brief Channel drivers are loaded dynamically. * \arg \ref Config_mod "Modules Configuration" */ /*! * \addtogroup applications Module: Dial plan applications * \section app_generic Asterisk Dial Plan Applications * \brief Applications support the dialplan. They register dynamically with * \see ast_register_application() and unregister with * \see ast_unregister_application() * \par See also * \arg \ref functions */ /*! * \addtogroup functions Module: Dial plan functions * \section func_generic Asterisk Dial Plan Functions * \brief Functions support the dialplan. They do not change any property of a channel * or touch a channel in any way. * \par See also * \arg \ref applications * */ /*! * \addtogroup codecs Module: Codecs * \section codec_generic Asterisk Codec Modules * Codecs are referenced in configuration files by name * \par See also * \arg \ref formats */ /*! * \addtogroup formats Module: Media File Formats * \section codec_generic Asterisk Format drivers * Formats are modules that read or write media files to disk. * \par See also * \arg \ref codecs */ /*! * \addtogroup rtp_engines Module: RTP Engines * \section rtp_engine_blah Asterisk RTP Engines */ /*! * \page AstHTTP AMI over HTTP support * The http.c file includes support for manager transactions over * http. * \section ami AMI - The manager Interface * \arg \link Config_ami Configuration file \endlink */ /*! * \page res_config_sqlite SQLite Resource driver configuration * \arg Implemented in \ref res_config_sqlite.c * \arg Configuration file: * \verbinclude res_config_sqlite.conf * \arg SQL tables: * https://wiki.asterisk.org/wiki/display/AST/SQLite+Tables * \arg See also: * http://www.sqlite.org */ asterisk-11.7.0/include/asterisk/network.h0000644000175000007640000000555411024257423020470 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007, Digium, Inc. * * Luigi Rizzo * * 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 Wrapper for network related headers, * masking differences between various operating systems. * On passing, we also provide here trivial functions or * other simple wrappers to network-related functions. */ #ifndef _ASTERISK_NETWORK_H #define _ASTERISK_NETWORK_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /* * Include relevant network headers. * Our preferred choice are the standard BSD/linux/unix headers. * Missing them (e.g. for solaris or various windows environments), * we resort to whatever we find around, and provide local definitions * for the missing bits. */ #ifdef HAVE_ARPA_INET_H #include #include /* include early to override inet_ntoa */ #include #include #include #include #include #include #include #elif defined(HAVE_WINSOCK_H) #include typedef int socklen_t; #elif defined(HAVE_WINSOCK2_H) #include #include #else #error "don't know how to handle network functions here." #endif #ifndef HAVE_INET_ATON int inet_aton(const char *cp, struct in_addr *pin); #endif #ifndef IFNAMSIZ #define IFNAMSIZ 16 #endif #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 #endif /*! * \brief thread-safe replacement for inet_ntoa(). * * \note It is very important to note that even though this is a thread-safe * replacement for inet_ntoa(), it is *not* reentrant. In a single * thread, the result from a previous call to this function is no longer * valid once it is called again. If the result from multiple calls to * this function need to be kept or used at once, then the result must be * copied to a local buffer before calling this function again. */ const char *ast_inet_ntoa(struct in_addr ia); #ifdef inet_ntoa #undef inet_ntoa #endif #define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__ /*! \brief Compares the source address and port of two sockaddr_in */ static force_inline int inaddrcmp(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2) { return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) || (sin1->sin_port != sin2->sin_port)); } #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_NETWORK_H */ asterisk-11.7.0/include/asterisk/say.h0000644000175000007640000001614211436665416017602 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 numbers and dates (maybe words one day too) */ #ifndef _ASTERISK_SAY_H #define _ASTERISK_SAY_H #include "asterisk/channel.h" #include "asterisk/file.h" #include #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! \brief * The basic ast_say_* functions are implemented as function pointers, * initialized to the function say_stub() which simply returns an error. * Other interfaces, declared here as regular functions, are simply * wrappers around the basic functions. * * An implementation of the basic ast_say functions (e.g. from say.c or from * a dynamically loaded module) will just have to reassign the pointers * to the relevant functions to override the previous implementation. * * \todo XXX * As the conversion from the old implementation of say.c to the new * implementation will be completed, and the API suitably reworked by * removing redundant functions and/or arguments, this mechanism may be * reverted back to pure static functions, if needed. */ #if defined(SAY_STUBS) /* provide declarations for the *say*() functions * and initialize them to the stub function */ static int say_stub(struct ast_channel *chan, ...) { ast_log(LOG_WARNING, "no implementation for the say() functions\n"); return -1; }; #undef SAY_STUBS #define SAY_INIT(x) = (typeof (x))say_stub #define SAY_EXTERN #else #define SAY_INIT(x) #define SAY_EXTERN extern #endif /*! * \brief says a number * \param chan channel to say them number on * \param num number to say on the channel * \param ints which dtmf to interrupt on * \param lang language to speak the number * \param options set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural * \details * Vocally says a number on a given channel * \retval 0 on success * \retval DTMF digit on interrupt * \retval -1 on failure */ int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options); /*! \brief Same as \ref ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable */ SAY_EXTERN int (* ast_say_number_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_number_full); /*! * \brief says an enumeration * \param chan channel to say them enumeration on * \param num number to say on the channel * \param ints which dtmf to interrupt on * \param lang language to speak the enumeration * \param options set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural * \details * Vocally says an enumeration on a given channel (first, sencond, third, forth, thirtyfirst, hundredth, ....) * Especially useful for dates and messages. Says 'last' if num equals to INT_MAX * \retval 0 on success * \retval DTMF digit on interrupt * \retval -1 on failure */ int ast_say_enumeration(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options); /*! \brief Same as \ref ast_say_enumeration() with audiofd for received audio and returns 1 on ctrlfd being readable */ SAY_EXTERN int (* ast_say_enumeration_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_enumeration_full); /*! * \brief says digits * \param chan channel to act upon * \param num number to speak * \param ints which dtmf to interrupt on * \param lang language to speak * \details * Vocally says digits of a given number * \retval 0 on success * \retval DTMF if interrupted * \retval -1 on failure */ int ast_say_digits(struct ast_channel *chan, int num, const char *ints, const char *lang); /*! \brief Same as \ref ast_say_digits() with audiofd for received audio and returns 1 on ctrlfd being readable */ int ast_say_digits_full(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd); /*! * \brief says digits of a string * \param chan channel to act upon * \param num string to speak * \param ints which dtmf to interrupt on * \param lang language to speak in * \details * Vocally says the digits of a given string * \retval 0 on succes * \retval DTMF if interrupted * \retval -1 on failure */ int ast_say_digit_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang); /*! \brief Same as \ref ast_say_digit_str() with audiofd for received audio and returns 1 on ctrlfd being readable */ SAY_EXTERN int (* ast_say_digit_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_digit_str_full); /*! \brief * the generic 'say' routine, with the first chars in the string * defining the format to use */ SAY_EXTERN int (* ast_say_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_full); /*! \brief * function to pronounce character and phonetic strings */ int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang); SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full); int ast_say_phonetic_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang); SAY_EXTERN int (* ast_say_phonetic_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_phonetic_str_full); SAY_EXTERN int (* ast_say_datetime)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime); SAY_EXTERN int (* ast_say_time)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_time); SAY_EXTERN int (* ast_say_date)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_date); SAY_EXTERN int (* ast_say_datetime_from_now)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_datetime_from_now); SAY_EXTERN int (* ast_say_date_with_format)(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *timezone) SAY_INIT(ast_say_date_with_format); int ast_say_counted_noun(struct ast_channel *chan, int num, const char *noun); int ast_say_counted_adjective(struct ast_channel *chan, int num, const char *adjective, const char *gender); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_SAY_H */ asterisk-11.7.0/include/asterisk/abstract_jb.h0000644000175000007640000002075312003337356021255 0ustar sharkyjerryweb/* * abstract_jb: common implementation-independent jitterbuffer stuff * * Copyright (C) 2005, Attractel OOD * * Contributors: * Slav Klenov * * 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. * * A license has been granted to Digium (via disclaimer) for the use of * this code. */ /*! \file * * \brief Common implementation-independent jitterbuffer stuff. * * \author Slav Klenov */ #ifndef _ABSTRACT_JB_H_ #define _ABSTRACT_JB_H_ #include #include "asterisk/format.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif struct ast_frame; /* Configuration flags */ enum { AST_JB_ENABLED = (1 << 0), AST_JB_FORCED = (1 << 1), AST_JB_LOG = (1 << 2) }; enum ast_jb_type { AST_JB_FIXED, AST_JB_ADAPTIVE, }; /*! Abstract return codes */ enum { AST_JB_IMPL_OK, AST_JB_IMPL_DROP, AST_JB_IMPL_INTERP, AST_JB_IMPL_NOFRAME }; #define AST_JB_IMPL_NAME_SIZE 12 /*! * \brief General jitterbuffer configuration. */ struct ast_jb_conf { /*! \brief Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags. */ unsigned int flags; /*! \brief Max size of the jitterbuffer implementation. */ long max_size; /*! \brief Resynchronization threshold of the jitterbuffer implementation. */ long resync_threshold; /*! \brief Name of the jitterbuffer implementation to be used. */ char impl[AST_JB_IMPL_NAME_SIZE]; /*! \brief amount of additional jitterbuffer adjustment */ long target_extra; }; /* Jitterbuffer configuration property names */ #define AST_JB_CONF_PREFIX "jb" #define AST_JB_CONF_ENABLE "enable" #define AST_JB_CONF_FORCE "force" #define AST_JB_CONF_MAX_SIZE "maxsize" #define AST_JB_CONF_RESYNCH_THRESHOLD "resyncthreshold" #define AST_JB_CONF_TARGET_EXTRA "targetextra" #define AST_JB_CONF_IMPL "impl" #define AST_JB_CONF_LOG "log" /* Hooks for the abstract jb implementation */ /*! \brief Create */ typedef void * (*jb_create_impl)(struct ast_jb_conf *general_config); /*! \brief Destroy */ typedef void (*jb_destroy_impl)(void *jb); /*! \brief Put first frame */ typedef int (*jb_put_first_impl)(void *jb, struct ast_frame *fin, long now); /*! \brief Put frame */ typedef int (*jb_put_impl)(void *jb, struct ast_frame *fin, long now); /*! \brief Get frame for now */ typedef int (*jb_get_impl)(void *jb, struct ast_frame **fout, long now, long interpl); /*! \brief Get next */ typedef long (*jb_next_impl)(void *jb); /*! \brief Remove first frame */ typedef int (*jb_remove_impl)(void *jb, struct ast_frame **fout); /*! \brief Force resynch */ typedef void (*jb_force_resynch_impl)(void *jb); /*! \brief Empty and reset jb */ typedef void (*jb_empty_and_reset_impl)(void *jb); /*! * \brief Jitterbuffer implementation struct. */ struct ast_jb_impl { char name[AST_JB_IMPL_NAME_SIZE]; enum ast_jb_type type; jb_create_impl create; jb_destroy_impl destroy; jb_put_first_impl put_first; jb_put_impl put; jb_get_impl get; jb_next_impl next; jb_remove_impl remove; jb_force_resynch_impl force_resync; jb_empty_and_reset_impl empty_and_reset; }; /*! * \brief General jitterbuffer state. */ struct ast_jb { /*! \brief Jitterbuffer configuration. */ struct ast_jb_conf conf; /*! \brief Jitterbuffer implementation to be used. */ const struct ast_jb_impl *impl; /*! \brief Jitterbuffer object, passed to the implementation. */ void *jbobj; /*! \brief The time the jitterbuffer was created. */ struct timeval timebase; /*! \brief The time the next frame should be played. */ long next; /*! \brief Voice format of the last frame in. */ struct ast_format last_format; /*! \brief File for frame timestamp tracing. */ FILE *logfile; /*! \brief Jitterbuffer internal state flags. */ unsigned int flags; }; /*! * \brief Checks the need of a jb use in a generic bridge. * \param c0 first bridged channel. * \param c1 second bridged channel. * * Called from ast_generic_bridge() when two channels are entering in a bridge. * The function checks the need of a jitterbuffer, depending on both channel's * configuration and technology properties. As a result, this function sets * appropriate internal jb flags to the channels, determining further behaviour * of the bridged jitterbuffers. * * \retval zero if there are no jitter buffers in use * \retval non-zero if there are */ int ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1); /*! * \brief Calculates the time, left to the closest delivery moment in a bridge. * \param c0 first bridged channel. * \param c1 second bridged channel. * \param time_left bridge time limit, or -1 if not set. * * Called from ast_generic_bridge() to determine the maximum time to wait for * activity in ast_waitfor_n() call. If neihter of the channels is using jb, * this function returns the time limit passed. * * \return maximum time to wait. */ int ast_jb_get_when_to_wakeup(struct ast_channel *c0, struct ast_channel *c1, int time_left); /*! * \brief Puts a frame into a channel jitterbuffer. * \param chan channel. * \param f frame. * * Called from ast_generic_bridge() to put a frame into a channel's jitterbuffer. * The function will successfuly enqueue a frame if and only if: * 1. the channel is using a jitterbuffer (as determined by ast_jb_do_usecheck()), * 2. the frame's type is AST_FRAME_VOICE, * 3. the frame has timing info set and has length >= 2 ms, * 4. there is no some internal error happened (like failed memory allocation). * Frames, successfuly queued, should be delivered by the channel's jitterbuffer, * when their delivery time has came. * Frames, not successfuly queued, should be delivered immediately. * Dropped by the jb implementation frames are considered successfuly enqueued as * far as they should not be delivered at all. * * \retval 0 if the frame was queued * \retval -1 if not */ int ast_jb_put(struct ast_channel *chan, struct ast_frame *f); /*! * \brief Deliver the queued frames that should be delivered now for both channels. * \param c0 first bridged channel. * \param c1 second bridged channel. * * Called from ast_generic_bridge() to deliver any frames, that should be delivered * for the moment of invocation. Does nothing if neihter of the channels is using jb * or has any frames currently queued in. The function delivers frames usig ast_write() * each of the channels. */ void ast_jb_get_and_deliver(struct ast_channel *c0, struct ast_channel *c1); /*! * \brief Destroys jitterbuffer on a channel. * \param chan channel. * * Called from ast_channel_free() when a channel is destroyed. */ void ast_jb_destroy(struct ast_channel *chan); /*! * \brief Sets jitterbuffer configuration property. * \param conf configuration to store the property in. * \param varname property name. * \param value property value. * * Called from a channel driver to build a jitterbuffer configuration typically when * reading a configuration file. It is not necessary for a channel driver to know * each of the jb configuration property names. The jitterbuffer itself knows them. * The channel driver can pass each config var it reads through this function. It will * return 0 if the variable was consumed from the jb conf. * * \return zero if the property was set to the configuration, -1 if not. */ int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value); /*! * \brief Configures a jitterbuffer on a channel. * \param chan channel to configure. * \param conf configuration to apply. * * Called from a channel driver when a channel is created and its jitterbuffer needs * to be configured. */ void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf); /*! * \brief Copies a channel's jitterbuffer configuration. * \param chan channel. * \param conf destination. */ void ast_jb_get_config(const struct ast_channel *chan, struct ast_jb_conf *conf); /*! * \brief drops all frames from a jitterbuffer and resets it * \param c0 one channel of a bridge * \param c1 the other channel of the bridge */ void ast_jb_empty_and_reset(struct ast_channel *c0, struct ast_channel *c1); const struct ast_jb_impl *ast_jb_get_impl(enum ast_jb_type type); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ABSTRACT_JB_H_ */ asterisk-11.7.0/include/asterisk/srv.h0000644000175000007640000000700411357635676017624 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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. */ /* * DNS SRV record support */ #ifndef _ASTERISK_SRV_H #define _ASTERISK_SRV_H /*! \file srv.h \brief Support for DNS SRV records, used in to locate SIP services. \note Note: This SRV record support will respect the priority and weight elements of the records that are returned, but there are no provisions for retrying or failover between records. */ /*!\brief An opaque type, for lookup usage */ struct srv_context; /*!\brief Retrieve set of SRV lookups, in order * \param[in] context A pointer in which to hold the result * \param[in] service The service name to look up * \param[out] host Result host * \param[out] port Associated TCP portnum * \retval -1 Query failed * \retval 0 Result exists in host and port * \retval 1 No more results */ extern int ast_srv_lookup(struct srv_context **context, const char *service, const char **host, unsigned short *port); /*!\brief Cleanup resources associated with ast_srv_lookup * \param context Pointer passed into ast_srv_lookup */ void ast_srv_cleanup(struct srv_context **context); /*! Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup Only do SRV record lookup if you get a domain without a port. If you get a port #, it's a DNS host name. */ /*! \param chan Ast channel \param host host name (return value) \param hostlen Length of string "host" \param port Port number (return value) \param service Service tag for SRV lookup (like "_sip._udp" or "_stun._udp" */ extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service); /*! * \brief Get the number of records for a given SRV context * * \details * This is meant to be used after calling ast_srv_lookup, so that * one may retrieve the number of records returned during a specific * SRV lookup. * * \param context The context returned by ast_srv_lookup * \return Number of records in context */ unsigned int ast_srv_get_record_count(struct srv_context *context); /*! * \brief Retrieve details from a specific SRV record * * \details * After calling ast_srv_lookup, the srv_context will contain * the data from several records. You can retrieve the data * of a specific one by asking for a specific record number. The * records are sorted based on priority and secondarily based on * weight. See RFC 2782 for the exact sorting rules. * * \param context The context returned by ast_srv_lookup * \param record_num The 1-indexed record number to retrieve * \param[out] host The host portion of the record * \param[out] port The port portion of the record * \param[out] priority The priority portion of the record * \param[out] weight The weight portion of the record * \retval -1 Failed to retrieve information. Likely due to an out of * range record_num * \retval 0 Success */ int ast_srv_get_nth_record(struct srv_context *context, int record_num, const char **host, unsigned short *port, unsigned short *priority, unsigned short *weight); #endif /* _ASTERISK_SRV_H */ asterisk-11.7.0/include/asterisk/app.h0000644000175000007640000012312211766471115017560 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * 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 Application convenience functions, designed to give consistent * look and feel to Asterisk apps. */ #ifndef _ASTERISK_APP_H #define _ASTERISK_APP_H #include "asterisk/stringfields.h" #include "asterisk/strings.h" #include "asterisk/threadstorage.h" #include "asterisk/file.h" #include "asterisk/linkedlists.h" struct ast_flags64; #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif AST_THREADSTORAGE_EXTERNAL(ast_str_thread_global_buf); /* IVR stuff */ /*! \brief Callback function for IVR \return returns 0 on completion, -1 on hangup or digit if interrupted */ typedef int (*ast_ivr_callback)(struct ast_channel *chan, char *option, void *cbdata); typedef enum { AST_ACTION_UPONE, /*!< adata is unused */ AST_ACTION_EXIT, /*!< adata is the return value for ast_ivr_menu_run if channel was not hungup */ AST_ACTION_CALLBACK, /*!< adata is an ast_ivr_callback */ AST_ACTION_PLAYBACK, /*!< adata is file to play */ AST_ACTION_BACKGROUND, /*!< adata is file to play */ AST_ACTION_PLAYLIST, /*!< adata is list of files, separated by ; to play */ AST_ACTION_MENU, /*!< adata is a pointer to an ast_ivr_menu */ AST_ACTION_REPEAT, /*!< adata is max # of repeats, cast to a pointer */ AST_ACTION_RESTART, /*!< adata is like repeat, but resets repeats to 0 */ AST_ACTION_TRANSFER, /*!< adata is a string with exten\verbatim[@context]\endverbatim */ AST_ACTION_WAITOPTION, /*!< adata is a timeout, or 0 for defaults */ AST_ACTION_NOOP, /*!< adata is unused */ AST_ACTION_BACKLIST, /*!< adata is list of files separated by ; allows interruption */ } ast_ivr_action; /*! Special "options" are: \arg "s" - "start here (one time greeting)" \arg "g" - "greeting/instructions" \arg "t" - "timeout" \arg "h" - "hangup" \arg "i" - "invalid selection" */ struct ast_ivr_option { char *option; ast_ivr_action action; void *adata; }; struct ast_ivr_menu { char *title; /*!< Title of menu */ unsigned int flags; /*!< Flags */ struct ast_ivr_option *options; /*!< All options */ }; /*! * \brief Structure used for ast_copy_recording_to_vm in order to cleanly supply * data needed for making the recording from the recorded file. */ struct ast_vm_recording_data { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(context); AST_STRING_FIELD(mailbox); AST_STRING_FIELD(folder); AST_STRING_FIELD(recording_file); AST_STRING_FIELD(recording_ext); AST_STRING_FIELD(call_context); AST_STRING_FIELD(call_macrocontext); AST_STRING_FIELD(call_extension); AST_STRING_FIELD(call_callerchan); AST_STRING_FIELD(call_callerid); ); int call_priority; }; #define AST_IVR_FLAG_AUTORESTART (1 << 0) #define AST_IVR_DECLARE_MENU(holder, title, flags, foo...) \ static struct ast_ivr_option __options_##holder[] = foo;\ static struct ast_ivr_menu holder = { title, flags, __options_##holder } enum ast_timelen { TIMELEN_HOURS, TIMELEN_MINUTES, TIMELEN_SECONDS, TIMELEN_MILLISECONDS, }; /*! \brief Runs an IVR menu \return returns 0 on successful completion, -1 on hangup, or -2 on user error in menu */ int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata); /*! \brief Plays a stream and gets DTMF data from a channel * \param c Which channel one is interacting with * \param prompt File to pass to ast_streamfile (the one that you wish to play). * It is also valid for this to be multiple files concatenated by "&". * For example, "file1&file2&file3". * \param s The location where the DTMF data will be stored * \param maxlen Max Length of the data * \param timeout Timeout length waiting for data(in milliseconds). Set to 0 for standard timeout(six seconds), or -1 for no time out. * * This function was designed for application programmers for situations where they need * to play a message and then get some DTMF data in response to the message. If a digit * is pressed during playback, it will immediately break out of the message and continue * execution of your code. */ int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout); /*! \brief Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other full functions */ int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd); /*! * \brief Run a macro on a channel, placing an optional second channel into autoservice. * \since 11.0 * * \details * This is a shorthand method that makes it very easy to run a * macro on any given channel. It is perfectly reasonable to * supply a NULL autoservice_chan here in case there is no * channel to place into autoservice. * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \param autoservice_chan A channel to place into autoservice while the macro is run * \param macro_chan Channel to execute macro on. * \param macro_args Macro application argument string. * * \retval 0 success * \retval -1 on error */ int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args); /*! * \since 1.8 * \brief Run a macro on a channel, placing an optional second channel into autoservice. * * \details * This is a shorthand method that makes it very easy to run a * macro on any given channel. It is perfectly reasonable to * supply a NULL autoservice_chan here in case there is no * channel to place into autoservice. * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \param autoservice_chan A channel to place into autoservice while the macro is run * \param macro_chan Channel to execute macro on. * \param macro_name The name of the macro to run. * \param macro_args The arguments to pass to the macro. * * \retval 0 success * \retval -1 on error */ int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args); /*! * \brief Stack applications callback functions. */ struct ast_app_stack_funcs { /*! * Module reference pointer so the module will stick around * while a callback is active. */ void *module; /*! * \brief Callback for the routine to run a subroutine on a channel. * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \param chan Channel to execute subroutine on. * \param args Gosub application argument string. * \param ignore_hangup TRUE if a hangup does not stop execution of the routine. * * \retval 0 success * \retval -1 on error */ int (*run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup); /*! * \brief Add missing context/exten to Gosub application argument string. * * \param chan Channel to obtain context/exten. * \param args Gosub application argument string. * * \details * Fills in the optional context and exten from the given channel. * * \retval New-args Gosub argument string on success. Must be freed. * \retval NULL on error. */ const char *(*expand_sub_args)(struct ast_channel *chan, const char *args); /* Add new API calls to the end here. */ }; /*! * \since 11 * \brief Set stack application function callbacks * \param funcs Stack applications callback functions. */ void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs); /*! * \brief Add missing context/exten to subroutine argument string. * * \param chan Channel to obtain context/exten. * \param args Gosub application argument string. * * \details * Fills in the optional context and exten from the given channel. * * \retval New-args Gosub argument string on success. Must be freed. * \retval NULL on error. */ const char *ast_app_expand_sub_args(struct ast_channel *chan, const char *args); /*! * \since 11 * \brief Run a subroutine on a channel, placing an optional second channel into autoservice. * * \details * This is a shorthand method that makes it very easy to run a * subroutine on any given channel. It is perfectly reasonable * to supply a NULL autoservice_chan here in case there is no * channel to place into autoservice. * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \param autoservice_chan A channel to place into autoservice while the subroutine is run * \param sub_chan Channel to execute subroutine on. * \param sub_args Gosub application argument string. * \param ignore_hangup TRUE if a hangup does not stop execution of the routine. * * \retval 0 success * \retval -1 on error */ int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup); /*! * \since 11 * \brief Run a subroutine on a channel, placing an optional second channel into autoservice. * * \details * This is a shorthand method that makes it very easy to run a * subroutine on any given channel. It is perfectly reasonable * to supply a NULL autoservice_chan here in case there is no * channel to place into autoservice. * * \note Absolutely _NO_ channel locks should be held before calling this function. * * \param autoservice_chan A channel to place into autoservice while the subroutine is run * \param sub_chan Channel to execute subroutine on. * \param sub_location The location of the subroutine to run. * \param sub_args The arguments to pass to the subroutine. * \param ignore_hangup TRUE if a hangup does not stop execution of the routine. * * \retval 0 success * \retval -1 on error */ int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup); enum ast_vm_snapshot_sort_val { AST_VM_SNAPSHOT_SORT_BY_ID = 0, AST_VM_SNAPSHOT_SORT_BY_TIME, }; struct ast_vm_msg_snapshot { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(msg_id); AST_STRING_FIELD(callerid); AST_STRING_FIELD(callerchan); AST_STRING_FIELD(exten); AST_STRING_FIELD(origdate); AST_STRING_FIELD(origtime); AST_STRING_FIELD(duration); AST_STRING_FIELD(folder_name); AST_STRING_FIELD(flag); ); unsigned int msg_number; AST_LIST_ENTRY(ast_vm_msg_snapshot) msg; }; struct ast_vm_mailbox_snapshot { int total_msg_num; int folders; /* Things are not quite as they seem here. This points to an allocated array of lists. */ AST_LIST_HEAD_NOLOCK(, ast_vm_msg_snapshot) *snapshots; }; /*! * \brief Voicemail playback callback function definition * * \param channel to play the file back on. * \param location of file on disk * \param duration of file in seconds. This will be zero if msg is very short or * has an unknown duration. */ typedef void (ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration); /*! * \brief Set voicemail function callbacks * \param[in] has_voicemail_func set function pointer * \param[in] inboxcount_func set function pointer * \param[in] inboxcount2_func set function pointer * \param[in] messagecount_func set function pointer * \param[in] sayname_func set function pointer * \version 1.6.1 Added inboxcount2_func, sayname_func */ void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, const char *folder), int (*inboxcount_func)(const char *mailbox, int *newmsgs, int *oldmsgs), int (*inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs), int (*messagecount_func)(const char *context, const char *mailbox, const char *folder), int (*sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context), int (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data), const char *vm_index_to_foldername(int id), struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_create)(const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD), struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_destroy)(struct ast_vm_mailbox_snapshot *mailbox_snapshot), int (*vm_msg_move)(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder), int (*vm_msg_remove)(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[]), int (*vm_msg_forward)(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old), int (*vm_msg_play)(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb cb)); void ast_uninstall_vm_functions(void); #ifdef TEST_FRAMEWORK void ast_install_vm_test_functions(int (*vm_test_destroy_user)(const char *context, const char *mailbox), int (*vm_test_create_user)(const char *context, const char *mailbox)); void ast_uninstall_vm_test_functions(void); #endif /*! * \brief * param[in] vm_rec_data Contains data needed to make the recording. * retval 0 voicemail successfully created from recording. * retval -1 Failure */ int ast_app_copy_recording_to_vm(struct ast_vm_recording_data *vm_rec_data); /*! * \brief Determine if a given mailbox has any voicemail * If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the * number of messages in the "Urgent" folder. * \retval 1 Mailbox has voicemail * \retval 0 No new voicemail in specified mailbox * \retval -1 Failure * \since 1.0 */ int ast_app_has_voicemail(const char *mailbox, const char *folder); /*! * \brief Determine number of new/old messages in a mailbox * \since 1.0 * \param[in] mailbox Mailbox specification in the format mbox[@context][&mbox2[@context2]][...] * \param[out] newmsgs Number of messages in the "INBOX" folder. Includes number of messages in the "Urgent" folder, if any. * \param[out] oldmsgs Number of messages in the "Old" folder. * \retval 0 Success * \retval -1 Failure */ int ast_app_inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs); /*! * \brief Determine number of urgent/new/old messages in a mailbox * \param[in] mailbox the mailbox context to use * \param[out] urgentmsgs the urgent message count * \param[out] newmsgs the new message count * \param[out] oldmsgs the old message count * \return Returns 0 for success, negative upon error * \since 1.6.1 */ int ast_app_inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs); /*! * \brief Given a mailbox and context, play that mailbox owner's name to the channel specified * \param[in] chan Channel on which to play the name * \param[in] mailbox Mailbox number from which to retrieve the recording * \param[in] context Mailbox context from which to locate the mailbox number * \retval 0 Name played without interruption * \retval dtmf ASCII value of the DTMF which interrupted playback. * \retval -1 Unable to locate mailbox or hangup occurred. * \since 1.6.1 */ int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *context); /*! * \brief Check number of messages in a given context, mailbox, and folder * \since 1.4 * \param[in] context Mailbox context * \param[in] mailbox Mailbox number * \param[in] folder Mailbox folder * \return Number of messages in the given context, mailbox, and folder. If folder is NULL, folder "INBOX" is assumed. If folder is "INBOX", includes number of messages in the "Urgent" folder. */ int ast_app_messagecount(const char *context, const char *mailbox, const char *folder); /*! * \brief Return name of folder, given an id * \param[in] id Folder id * \return Name of folder */ const char *ast_vm_index_to_foldername(int id); /* * \brief Create a snapshot of a mailbox which contains information about every msg. * * \param mailbox, the mailbox to look for * \param context, the context to look for the mailbox in * \param folder, OPTIONAL. When not NULL only msgs from the specified folder will be included. * \param desending, list the msgs in descending order rather than ascending order. * \param combine_INBOX_and_OLD, When this argument is set, The OLD folder will be represented * in the INBOX folder of the snapshot. This allows the snapshot to represent the * OLD and INBOX messages in sorted order merged together. * * \retval snapshot on success * \retval NULL on failure */ struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD); /* * \brief destroy a snapshot * * \param mailbox_snapshot The snapshot to destroy. * \retval NULL */ struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot); /*! * \brief Move messages from one folder to another * * \param mailbox The mailbox to which the folders belong * \param context The voicemail context for the mailbox * \param num_msgs The number of messages to move * \param oldfolder The folder from where messages should be moved * \param old_msg_nums The message IDs of the messages to move * \param newfolder The folder to which messages should be moved * new folder. This array must be num_msgs sized. * * \retval -1 Failure * \retval 0 Success */ int ast_vm_msg_move(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder); /*! * \brief Remove/delete messages from a mailbox folder. * * \param mailbox The mailbox from which to delete messages * \param context The voicemail context for the mailbox * \param num_msgs The number of messages to delete * \param folder The folder from which to remove messages * \param msgs The message IDs of the messages to delete * * \retval -1 Failure * \retval 0 Success */ int ast_vm_msg_remove(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[]); /*! * \brief forward a message from one mailbox to another. * * \brief from_mailbox The original mailbox the message is being forwarded from * \brief from_context The voicemail context of the from_mailbox * \brief from_folder The folder from which the message is being forwarded * \brief to_mailbox The mailbox to forward the message to * \brief to_context The voicemail context of the to_mailbox * \brief to_folder The folder to which the message is being forwarded * \brief num_msgs The number of messages being forwarded * \brief msg_ids The message IDs of the messages in from_mailbox to forward * \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox. * Otherwise, the messages will remain in the from_mailbox. * * \retval -1 Failure * \retval 0 Success */ int ast_vm_msg_forward(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old); /*! * \brief Play a voicemail msg back on a channel. * * \param mailbox msg is in. * \param context of mailbox. * \param voicemail folder to look in. * \param message number in the voicemailbox to playback to the channel. * * \retval 0 success * \retval -1 failure */ int ast_vm_msg_play(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb cb); #ifdef TEST_FRAMEWORK int ast_vm_test_destroy_user(const char *context, const char *mailbox); int ast_vm_test_create_user(const char *context, const char *mailbox); #endif /*! \brief Safely spawn an external program while closing file descriptors \note This replaces the \b system call in all Asterisk modules */ int ast_safe_system(const char *s); /*! * \brief Replace the SIGCHLD handler * * Normally, Asterisk has a SIGCHLD handler that is cleaning up all zombie * processes from forking elsewhere in Asterisk. However, if you want to * wait*() on the process to retrieve information about it's exit status, * then this signal handler needs to be temporarily replaced. * * Code that executes this function *must* call ast_unreplace_sigchld() * after it is finished doing the wait*(). */ void ast_replace_sigchld(void); /*! * \brief Restore the SIGCHLD handler * * This function is called after a call to ast_replace_sigchld. It restores * the SIGCHLD handler that cleans up any zombie processes. */ void ast_unreplace_sigchld(void); /*! \brief Send DTMF to a channel \param chan The channel that will receive the DTMF frames \param peer (optional) Peer channel that will be autoserviced while the primary channel is receiving DTMF \param digits This is a string of characters representing the DTMF digits to be sent to the channel. Valid characters are "0123456789*#abcdABCD". Note: You can pass arguments 'f' or 'F', if you want to Flash the channel (if supported by the channel), or 'w' to add a 500 millisecond pause to the DTMF sequence. \param between This is the number of milliseconds to wait in between each DTMF digit. If zero milliseconds is specified, then the default value of 100 will be used. \param duration This is the duration that each DTMF digit should have. */ int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration); /*! \brief Stream a filename (or file descriptor) as a generator. */ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride); /*! * \brief Stream a file with fast forward, pause, reverse, restart. * \param chan * \param file filename * \param fwd, rev, stop, pause, restart, skipms, offsetms * * Before calling this function, set this to be the number * of ms to start from the beginning of the file. When the function * returns, it will be the number of ms from the beginning where the * playback stopped. Pass NULL if you don't care. */ int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms); /*! * \brief Stream a file with fast forward, pause, reverse, restart. * \param chan * \param file filename * \param fwd, rev, stop, pause, restart, skipms, offsetms * \param waitstream callback to invoke when fastforward or rewind occurrs. * * Before calling this function, set this to be the number * of ms to start from the beginning of the file. When the function * returns, it will be the number of ms from the beginning where the * playback stopped. Pass NULL if you don't care. */ int ast_control_streamfile_w_cb(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms, ast_waitstream_fr_cb cb); /*! \brief Play a stream and wait for a digit, returning the digit that was pressed */ int ast_play_and_wait(struct ast_channel *chan, const char *fn); /*! * \brief Record a file based on input from a channel * This function will play "auth-thankyou" upon successful recording. * * \param chan the channel being recorded * \param playfile Filename of sound to play before recording begins * \param recordfile Filename to save the recording * \param maxtime_sec Longest possible message length in seconds * \param fmt string containing all formats to be recorded delimited by '|' * \param duration pointer to integer for storing length of the recording * \param sound_duration pointer to integer for storing length of the recording minus all silence * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default * \param maxsilence_ms Length of time in milliseconds which will trigger a timeout from silence, -1 for default * \param path Optional filesystem path to unlock * \param acceptdtmf Character of DTMF to end and accept the recording * \param canceldtmf Character of DTMF to end and cancel the recording * * \retval -1 failure or hangup * \retval 'S' Recording ended from silence timeout * \retval 't' Recording ended from the message exceeding the maximum duration * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept. */ int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf); /*! * \brief Record a file based on input from a channel. Use default accept and cancel DTMF. * This function will play "auth-thankyou" upon successful recording. * * \param chan the channel being recorded * \param playfile Filename of sound to play before recording begins * \param recordfile Filename to save the recording * \param maxtime_sec Longest possible message length in seconds * \param fmt string containing all formats to be recorded delimited by '|' * \param duration pointer to integer for storing length of the recording * \param sound_duration pointer to integer for storing length of the recording minus all silence * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default * \param path Optional filesystem path to unlock * * \retval -1 failure or hangup * \retval 'S' Recording ended from silence timeout * \retval 't' Recording ended from the message exceeding the maximum duration * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept. */ int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path); /*! * \brief Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a little differently from normal recordings * This function will not play a success message due to post-recording control in the application this was added for. * * \param chan the channel being recorded * \param playfile Filename of sound to play before recording begins * \param recordfile Filename to save the recording * \param maxtime_sec Longest possible message length in seconds * \param fmt string containing all formats to be recorded delimited by '|' * \param duration pointer to integer for storing length of the recording * \param sound_duration pointer to integer for storing length of the recording minus all silence * \param beep whether to play a beep to prompt the recording * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default. * * \retval -1 failure or hangup * \retval 'S' Recording ended from silence timeout * \retval 't' Recording either exceeded maximum duration or the call was ended via DTMF */ int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms); enum ast_getdata_result { AST_GETDATA_FAILED = -1, AST_GETDATA_COMPLETE = 0, AST_GETDATA_TIMEOUT = 1, AST_GETDATA_INTERRUPTED = 2, /*! indicates a user terminated empty string rather than an empty string resulting * from a timeout or other factors */ AST_GETDATA_EMPTY_END_TERMINATED = 3, }; enum AST_LOCK_RESULT { AST_LOCK_SUCCESS = 0, AST_LOCK_TIMEOUT = -1, AST_LOCK_PATH_NOT_FOUND = -2, AST_LOCK_FAILURE = -3, }; /*! \brief Type of locking to use in ast_lock_path / ast_unlock_path */ enum AST_LOCK_TYPE { AST_LOCK_TYPE_LOCKFILE = 0, AST_LOCK_TYPE_FLOCK = 1, }; /*! * \brief Set the type of locks used by ast_lock_path() * \param type the locking type to use */ void ast_set_lock_type(enum AST_LOCK_TYPE type); /*! * \brief Lock a filesystem path. * \param path the path to be locked * \return one of \ref AST_LOCK_RESULT values */ enum AST_LOCK_RESULT ast_lock_path(const char *path); /*! \brief Unlock a path */ int ast_unlock_path(const char *path); /*! \brief Read a file into asterisk*/ char *ast_read_textfile(const char *file); struct ast_group_info; /*! \brief Split a group string into group and category, returning a default category if none is provided. */ int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max); /*! \brief Set the group for a channel, splitting the provided data into group and category, if specified. */ int ast_app_group_set_channel(struct ast_channel *chan, const char *data); /*! \brief Get the current channel count of the specified group and category. */ int ast_app_group_get_count(const char *group, const char *category); /*! \brief Get the current channel count of all groups that match the specified pattern and category. */ int ast_app_group_match_get_count(const char *groupmatch, const char *category); /*! \brief Discard all group counting for a channel */ int ast_app_group_discard(struct ast_channel *chan); /*! \brief Update all group counting for a channel to a new one */ int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan); /*! \brief Write Lock the group count list */ int ast_app_group_list_wrlock(void); /*! \brief Read Lock the group count list */ int ast_app_group_list_rdlock(void); /*! \brief Get the head of the group count list */ struct ast_group_info *ast_app_group_list_head(void); /*! \brief Unlock the group count list */ int ast_app_group_list_unlock(void); /*! \brief Define an application argument \param name The name of the argument */ #define AST_APP_ARG(name) char *name /*! \brief Declare a structure to hold an application's arguments. \param name The name of the structure \param arglist The list of arguments, defined using AST_APP_ARG This macro declares a structure intended to be used in a call to ast_app_separate_args(). The structure includes all the arguments specified, plus an argv array that overlays them and an argc argument counter. The arguments must be declared using AST_APP_ARG, and they will all be character pointers (strings). \note The structure is not initialized, as the call to ast_app_separate_args() will perform that function before parsing the arguments. */ #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(, arglist) name = { 0, } /*! \brief Define a structure type to hold an application's arguments. \param type The name of the structure type \param arglist The list of arguments, defined using AST_APP_ARG This macro defines a structure type intended to be used in a call to ast_app_separate_args(). The structure includes all the arguments specified, plus an argv array that overlays them and an argc argument counter. The arguments must be declared using AST_APP_ARG, and they will all be character pointers (strings). \note This defines a structure type, but does not declare an instance of the structure. That must be done separately. */ #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \ struct type { \ unsigned int argc; \ char *argv[0]; \ arglist \ } /*! \brief Performs the 'standard' argument separation process for an application. \param args An argument structure defined using AST_DECLARE_APP_ARGS \param parse A modifiable buffer containing the input to be parsed This function will separate the input string using the standard argument separator character ',' and fill in the provided structure, including the argc argument counter field. */ #define AST_STANDARD_APP_ARGS(args, parse) \ args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) #define AST_STANDARD_RAW_ARGS(args, parse) \ args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) /*! \brief Performs the 'nonstandard' argument separation process for an application. \param args An argument structure defined using AST_DECLARE_APP_ARGS \param parse A modifiable buffer containing the input to be parsed \param sep A nonstandard separator character This function will separate the input string using the nonstandard argument separator character and fill in the provided structure, including the argc argument counter field. */ #define AST_NONSTANDARD_APP_ARGS(args, parse, sep) \ args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) #define AST_NONSTANDARD_RAW_ARGS(args, parse, sep) \ args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) /*! \brief Separate a string into arguments in an array \param buf The string to be parsed (this must be a writable copy, as it will be modified) \param delim The character to be used to delimit arguments \param remove_chars Remove backslashes and quote characters, while parsing \param array An array of 'char *' to be filled in with pointers to the found arguments \param arraylen The number of elements in the array (i.e. the number of arguments you will accept) Note: if there are more arguments in the string than the array will hold, the last element of the array will contain the remaining arguments, not separated. The array will be completely zeroed by this function before it populates any entries. \return The number of arguments found, or zero if the function arguments are not valid. */ unsigned int __ast_app_separate_args(char *buf, char delim, int remove_chars, char **array, int arraylen); #define ast_app_separate_args(a,b,c,d) __ast_app_separate_args(a,b,1,c,d) /*! \brief A structure to hold the description of an application 'option'. Application 'options' are single-character flags that can be supplied to the application to affect its behavior; they can also optionally accept arguments enclosed in parenthesis. These structures are used by the ast_app_parse_options function, uses this data to fill in a flags structure (to indicate which options were supplied) and array of argument pointers (for those options that had arguments supplied). */ struct ast_app_option { /*! \brief The flag bit that represents this option. */ uint64_t flag; /*! \brief The index of the entry in the arguments array that should be used for this option's argument. */ unsigned int arg_index; }; #define BEGIN_OPTIONS { #define END_OPTIONS } /*! \brief Declares an array of options for an application. \param holder The name of the array to be created \param options The actual options to be placed into the array \sa ast_app_parse_options This macro declares a 'static const' array of \c struct \c ast_option elements to hold the list of available options for an application. Each option must be declared using either the AST_APP_OPTION() or AST_APP_OPTION_ARG() macros. Example usage: \code enum my_app_option_flags { OPT_JUMP = (1 << 0), OPT_BLAH = (1 << 1), OPT_BLORT = (1 << 2), }; enum my_app_option_args { OPT_ARG_BLAH = 0, OPT_ARG_BLORT, !! this entry tells how many possible arguments there are, and must be the last entry in the list OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(my_app_options, { AST_APP_OPTION('j', OPT_JUMP), AST_APP_OPTION_ARG('b', OPT_BLAH, OPT_ARG_BLAH), AST_APP_OPTION_BLORT('B', OPT_BLORT, OPT_ARG_BLORT), }); static int my_app_exec(struct ast_channel *chan, void *data) { char *options; struct ast_flags opts = { 0, }; char *opt_args[OPT_ARG_ARRAY_SIZE]; ... do any argument parsing here ... if (ast_app_parse_options(my_app_options, &opts, opt_args, options)) { return -1; } } \endcode */ #define AST_APP_OPTIONS(holder, options...) \ static const struct ast_app_option holder[128] = options /*! \brief Declares an application option that does not accept an argument. \param option The single character representing the option \param flagno The flag index to be set if this option is present \sa AST_APP_OPTIONS, ast_app_parse_options */ #define AST_APP_OPTION(option, flagno) \ [option] = { .flag = flagno } /*! \brief Declares an application option that accepts an argument. \param option The single character representing the option \param flagno The flag index to be set if this option is present \param argno The index into the argument array where the argument should be placed \sa AST_APP_OPTIONS, ast_app_parse_options */ #define AST_APP_OPTION_ARG(option, flagno, argno) \ [option] = { .flag = flagno, .arg_index = argno + 1 } /*! \brief Parses a string containing application options and sets flags/arguments. \param options The array of possible options declared with AST_APP_OPTIONS \param flags The flag structure to have option flags set \param args The array of argument pointers to hold arguments found \param optstr The string containing the options to be parsed \return zero for success, non-zero if an error occurs \sa AST_APP_OPTIONS */ int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr); /*! \brief Parses a string containing application options and sets flags/arguments. \param options The array of possible options declared with AST_APP_OPTIONS \param flags The 64-bit flag structure to have option flags set \param args The array of argument pointers to hold arguments found \param optstr The string containing the options to be parsed \return zero for success, non-zero if an error occurs \sa AST_APP_OPTIONS */ int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr); /*! \brief Given a list of options array, return an option string based on passed flags \param options The array of possible options declared with AST_APP_OPTIONS \param flags The flags of the options that you wish to populate the buffer with \param buf The buffer to fill with the string of options \param len The maximum length of buf */ void ast_app_options2str64(const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len); /*! \brief Present a dialtone and collect a certain length extension. \return Returns 1 on valid extension entered, -1 on hangup, or 0 on invalid extension. \note Note that if 'collect' holds digits already, new digits will be appended, so be sure it's initialized properly */ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout); /*! \brief Allow to record message and have a review option */ int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path); /*!\brief Decode an encoded control or extended ASCII character * \param[in] stream String to decode * \param[out] result Decoded character * \param[out] consumed Number of characters used in stream to encode the character * \retval -1 Stream is of zero length * \retval 0 Success */ int ast_get_encoded_char(const char *stream, char *result, size_t *consumed); /*!\brief Decode a stream of encoded control or extended ASCII characters * \param[in] stream Encoded string * \param[out] result Decoded string * \param[in] result_len Maximum size of the result buffer * \return A pointer to the result string */ char *ast_get_encoded_str(const char *stream, char *result, size_t result_len); /*! \brief Decode a stream of encoded control or extended ASCII characters */ int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream); /*! * \brief Common routine for child processes, to close all fds prior to exec(2) * \param[in] n starting file descriptor number for closing all higher file descriptors * \since 1.6.1 */ void ast_close_fds_above_n(int n); /*! * \brief Common routine to safely fork without a chance of a signal handler firing badly in the child * \param[in] stop_reaper flag to determine if sigchld handler is replaced or not * \since 1.6.1 */ int ast_safe_fork(int stop_reaper); /*! * \brief Common routine to cleanup after fork'ed process is complete (if reaping was stopped) * \since 1.6.1 */ void ast_safe_fork_cleanup(void); /*! * \brief Common routine to parse time lengths, with optional time unit specifier * \param[in] timestr String to parse * \param[in] defunit Default unit type * \param[out] result Resulting value, specified in milliseconds * \retval 0 Success * \retval -1 Failure * \since 1.8 */ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_APP_H */ asterisk-11.7.0/include/asterisk/utils.h0000644000175000007640000007003212205704266020134 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Utility functions */ #ifndef _ASTERISK_UTILS_H #define _ASTERISK_UTILS_H #include "asterisk/network.h" #include /* we want to override localtime_r */ #include #include #include "asterisk/lock.h" #include "asterisk/time.h" #include "asterisk/logger.h" #include "asterisk/localtime.h" #include "asterisk/stringfields.h" /*! \note \verbatim Note: It is very important to use only unsigned variables to hold bit flags, as otherwise you can fall prey to the compiler's sign-extension antics if you try to use the top two bits in your variable. The flag macros below use a set of compiler tricks to verify that the caller is using an "unsigned int" variable to hold the flags, and nothing else. If the caller uses any other type of variable, a warning message similar to this: warning: comparison of distinct pointer types lacks cast will be generated. The "dummy" variable below is used to make these comparisons. Also note that at -O2 or above, this type-safety checking does _not_ produce any additional object code at all. \endverbatim */ extern unsigned int __unsigned_int_flags_dummy; #define ast_test_flag(p,flag) ({ \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy) __x = 0; \ (void) (&__p == &__x); \ ((p)->flags & (flag)); \ }) #define ast_set_flag(p,flag) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy) __x = 0; \ (void) (&__p == &__x); \ ((p)->flags |= (flag)); \ } while(0) #define ast_clear_flag(p,flag) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy) __x = 0; \ (void) (&__p == &__x); \ ((p)->flags &= ~(flag)); \ } while(0) #define ast_copy_flags(dest,src,flagz) do { \ typeof ((dest)->flags) __d = (dest)->flags; \ typeof ((src)->flags) __s = (src)->flags; \ typeof (__unsigned_int_flags_dummy) __x = 0; \ (void) (&__d == &__x); \ (void) (&__s == &__x); \ (dest)->flags &= ~(flagz); \ (dest)->flags |= ((src)->flags & (flagz)); \ } while (0) #define ast_set2_flag(p,value,flag) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy) __x = 0; \ (void) (&__p == &__x); \ if (value) \ (p)->flags |= (flag); \ else \ (p)->flags &= ~(flag); \ } while (0) #define ast_set_flags_to(p,flag,value) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy) __x = 0; \ (void) (&__p == &__x); \ (p)->flags &= ~(flag); \ (p)->flags |= (value); \ } while (0) /* The following 64-bit flag code can most likely be erased after app_dial is reorganized to either reduce the large number of options, or handle them in some other way. At the time of this writing, app_dial would be the only user of 64-bit option flags */ extern uint64_t __unsigned_int_flags_dummy64; #define ast_test_flag64(p,flag) ({ \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy64) __x = 0; \ (void) (&__p == &__x); \ ((p)->flags & (flag)); \ }) #define ast_set_flag64(p,flag) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy64) __x = 0; \ (void) (&__p == &__x); \ ((p)->flags |= (flag)); \ } while(0) #define ast_clear_flag64(p,flag) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy64) __x = 0; \ (void) (&__p == &__x); \ ((p)->flags &= ~(flag)); \ } while(0) #define ast_copy_flags64(dest,src,flagz) do { \ typeof ((dest)->flags) __d = (dest)->flags; \ typeof ((src)->flags) __s = (src)->flags; \ typeof (__unsigned_int_flags_dummy64) __x = 0; \ (void) (&__d == &__x); \ (void) (&__s == &__x); \ (dest)->flags &= ~(flagz); \ (dest)->flags |= ((src)->flags & (flagz)); \ } while (0) #define ast_set2_flag64(p,value,flag) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy64) __x = 0; \ (void) (&__p == &__x); \ if (value) \ (p)->flags |= (flag); \ else \ (p)->flags &= ~(flag); \ } while (0) #define ast_set_flags_to64(p,flag,value) do { \ typeof ((p)->flags) __p = (p)->flags; \ typeof (__unsigned_int_flags_dummy64) __x = 0; \ (void) (&__p == &__x); \ (p)->flags &= ~(flag); \ (p)->flags |= (value); \ } while (0) /* Non-type checking variations for non-unsigned int flags. You should only use non-unsigned int flags where required by protocol etc and if you know what you're doing :) */ #define ast_test_flag_nonstd(p,flag) \ ((p)->flags & (flag)) #define ast_set_flag_nonstd(p,flag) do { \ ((p)->flags |= (flag)); \ } while(0) #define ast_clear_flag_nonstd(p,flag) do { \ ((p)->flags &= ~(flag)); \ } while(0) #define ast_copy_flags_nonstd(dest,src,flagz) do { \ (dest)->flags &= ~(flagz); \ (dest)->flags |= ((src)->flags & (flagz)); \ } while (0) #define ast_set2_flag_nonstd(p,value,flag) do { \ if (value) \ (p)->flags |= (flag); \ else \ (p)->flags &= ~(flag); \ } while (0) #define AST_FLAGS_ALL UINT_MAX /*! \brief Structure used to handle boolean flags */ struct ast_flags { unsigned int flags; }; /*! \brief Structure used to handle a large number of boolean flags == used only in app_dial? */ struct ast_flags64 { uint64_t flags; }; struct ast_hostent { struct hostent hp; char buf[1024]; }; /*! \brief Thread-safe gethostbyname function to use in Asterisk */ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp); /*! \brief Produces MD5 hash based on input string */ void ast_md5_hash(char *output, const char *input); /*! \brief Produces SHA1 hash based on input string */ void ast_sha1_hash(char *output, const char *input); /*! \brief Produces SHA1 hash based on input string, stored in uint8_t array */ void ast_sha1_hash_uint(uint8_t *digest, const char *input); int ast_base64encode_full(char *dst, const unsigned char *src, int srclen, int max, int linebreaks); #undef MIN #define MIN(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); ((__a > __b) ? __b : __a);}) #undef MAX #define MAX(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); ((__a < __b) ? __b : __a);}) #define SWAP(a,b) do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) /*! * \brief Encode data in base64 * \param dst the destination buffer * \param src the source data to be encoded * \param srclen the number of bytes present in the source buffer * \param max the maximum number of bytes to write into the destination * buffer, *including* the terminating NULL character. */ int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max); /*! * \brief Decode data from base64 * \param dst the destination buffer * \param src the source buffer * \param max The maximum number of bytes to write into the destination * buffer. Note that this function will not ensure that the * destination buffer is NULL terminated. So, in general, * this parameter should be sizeof(dst) - 1. */ int ast_base64decode(unsigned char *dst, const char *src, int max); #define AST_URI_ALPHANUM (1 << 0) #define AST_URI_MARK (1 << 1) #define AST_URI_UNRESERVED (AST_URI_ALPHANUM | AST_URI_MARK) #define AST_URI_LEGACY_SPACE (1 << 2) #define AST_URI_SIP_USER_UNRESERVED (1 << 20) extern const struct ast_flags ast_uri_http; extern const struct ast_flags ast_uri_http_legacy; extern const struct ast_flags ast_uri_sip_user; /*! * \brief Turn text string to URI-encoded %XX version * * This function encodes characters according to the rules presented in RFC * 2396 and/or RFC 3261 section 19.1.2 and section 25.1. * * Outbuf needs to have more memory allocated than the instring to have room * for the expansion. Every byte that is converted is replaced by three ASCII * characters. * * \param string string to be converted * \param outbuf resulting encoded string * \param buflen size of output buffer * \param spec flags describing how the encoding should be performed * \return a pointer to the uri encoded string */ char *ast_uri_encode(const char *string, char *outbuf, int buflen, struct ast_flags spec); /*! * \brief Decode URI, URN, URL (overwrite string) * * \note The ast_uri_http_legacy decode spec flag will cause this function to * decode '+' as ' '. * * \param s string to be decoded * \param spec flags describing how the decoding should be performed */ void ast_uri_decode(char *s, struct ast_flags spec); /*! ast_xml_escape \brief Escape reserved characters for use in XML. If \a outbuf is too short, the output string will be truncated. Regardless, the output will always be null terminated. \param string String to be converted \param outbuf Resulting encoded string \param buflen Size of output buffer \return 0 for success \return -1 if buflen is too short. */ int ast_xml_escape(const char *string, char *outbuf, size_t buflen); /*! * \brief Escape characters found in a quoted string. * * \note This function escapes quoted characters based on the 'qdtext' set of * allowed characters from RFC 3261 section 25.1. * * \param string string to be escaped * \param outbuf resulting escaped string * \param buflen size of output buffer * \return a pointer to the escaped string */ char *ast_escape_quoted(const char *string, char *outbuf, int buflen); static force_inline void ast_slinear_saturated_add(short *input, short *value) { int res; res = (int) *input + *value; if (res > 32767) *input = 32767; else if (res < -32768) *input = -32768; else *input = (short) res; } static force_inline void ast_slinear_saturated_subtract(short *input, short *value) { int res; res = (int) *input - *value; if (res > 32767) *input = 32767; else if (res < -32768) *input = -32768; else *input = (short) res; } static force_inline void ast_slinear_saturated_multiply(short *input, short *value) { int res; res = (int) *input * *value; if (res > 32767) *input = 32767; else if (res < -32768) *input = -32768; else *input = (short) res; } static force_inline void ast_slinear_saturated_divide(short *input, short *value) { *input /= *value; } #ifdef localtime_r #undef localtime_r #endif #define localtime_r __dont_use_localtime_r_use_ast_localtime_instead__ int ast_utils_init(void); int ast_wait_for_input(int fd, int ms); /*! * \brief Try to write string, but wait no more than ms milliseconds * before timing out. * * \note If you are calling ast_carefulwrite, it is assumed that you are calling * it on a file descriptor that _DOES_ have NONBLOCK set. This way, * there is only one system call made to do a write, unless we actually * have a need to wait. This way, we get better performance. */ int ast_carefulwrite(int fd, char *s, int len, int timeoutms); /*! * \brief Write data to a file stream with a timeout * * \param f the file stream to write to * \param fd the file description to poll on to know when the file stream can * be written to without blocking. * \param s the buffer to write from * \param len the number of bytes to write * \param timeoutms The maximum amount of time to block in this function trying * to write, specified in milliseconds. * * \note This function assumes that the associated file stream has been set up * as non-blocking. * * \retval 0 success * \retval -1 error */ int ast_careful_fwrite(FILE *f, int fd, const char *s, size_t len, int timeoutms); /* * Thread management support (should be moved to lock.h or a different header) */ #define AST_STACKSIZE (((sizeof(void *) * 8 * 8) - 16) * 1024) #if defined(LOW_MEMORY) #define AST_BACKGROUND_STACKSIZE (((sizeof(void *) * 8 * 2) - 16) * 1024) #else #define AST_BACKGROUND_STACKSIZE AST_STACKSIZE #endif void ast_register_thread(char *name); void ast_unregister_thread(void *id); int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize, const char *file, const char *caller, int line, const char *start_fn); int ast_pthread_create_detached_stack(pthread_t *thread, pthread_attr_t *attr, void*(*start_routine)(void *), void *data, size_t stacksize, const char *file, const char *caller, int line, const char *start_fn); #define ast_pthread_create(a, b, c, d) \ ast_pthread_create_stack(a, b, c, d, \ 0, __FILE__, __FUNCTION__, __LINE__, #c) #define ast_pthread_create_detached(a, b, c, d) \ ast_pthread_create_detached_stack(a, b, c, d, \ 0, __FILE__, __FUNCTION__, __LINE__, #c) #define ast_pthread_create_background(a, b, c, d) \ ast_pthread_create_stack(a, b, c, d, \ AST_BACKGROUND_STACKSIZE, \ __FILE__, __FUNCTION__, __LINE__, #c) #define ast_pthread_create_detached_background(a, b, c, d) \ ast_pthread_create_detached_stack(a, b, c, d, \ AST_BACKGROUND_STACKSIZE, \ __FILE__, __FUNCTION__, __LINE__, #c) /* End of thread management support */ /*! * \brief Replace '^' in a string with ',' * \param s String within which to replace characters */ void ast_replace_subargument_delimiter(char *s); /*! * \brief Process a string to find and replace characters * \param start The string to analyze * \param find The character to find * \param replace_with The character that will replace the one we are looking for */ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with); long int ast_random(void); #ifndef __AST_DEBUG_MALLOC #define ast_std_malloc malloc #define ast_std_calloc calloc #define ast_std_realloc realloc #define ast_std_free free /*! * \brief free() wrapper * * ast_free_ptr should be used when a function pointer for free() needs to be passed * as the argument to a function. Otherwise, astmm will cause seg faults. */ #define ast_free free #define ast_free_ptr ast_free #define MALLOC_FAILURE_MSG \ ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file); /*! * \brief A wrapper for malloc() * * ast_malloc() is a wrapper for malloc() that will generate an Asterisk log * message in the case that the allocation fails. * * The argument and return value are the same as malloc() */ #define ast_malloc(len) \ _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, const char *func), { void *p; if (!(p = malloc(len))) MALLOC_FAILURE_MSG; return p; } ) /*! * \brief A wrapper for calloc() * * ast_calloc() is a wrapper for calloc() that will generate an Asterisk log * message in the case that the allocation fails. * * The arguments and return value are the same as calloc() */ #define ast_calloc(num, len) \ _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func), { void *p; if (!(p = calloc(num, len))) MALLOC_FAILURE_MSG; return p; } ) /*! * \brief A wrapper for calloc() for use in cache pools * * ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log * message in the case that the allocation fails. When memory debugging is in use, * the memory allocated by this function will be marked as 'cache' so it can be * distinguished from normal memory allocations. * * The arguments and return value are the same as calloc() */ #define ast_calloc_cache(num, len) \ _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief A wrapper for realloc() * * ast_realloc() is a wrapper for realloc() that will generate an Asterisk log * message in the case that the allocation fails. * * The arguments and return value are the same as realloc() */ #define ast_realloc(p, len) \ _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), { void *newp; if (!(newp = realloc(p, len))) MALLOC_FAILURE_MSG; return newp; } ) /*! * \brief A wrapper for strdup() * * ast_strdup() is a wrapper for strdup() that will generate an Asterisk log * message in the case that the allocation fails. * * ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL * argument is provided, ast_strdup will return NULL without generating any * kind of error log message. * * The argument and return value are the same as strdup() */ #define ast_strdup(str) \ _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( char * attribute_malloc _ast_strdup(const char *str, const char *file, int lineno, const char *func), { char *newstr = NULL; if (str) { if (!(newstr = strdup(str))) MALLOC_FAILURE_MSG; } return newstr; } ) /*! * \brief A wrapper for strndup() * * ast_strndup() is a wrapper for strndup() that will generate an Asterisk log * message in the case that the allocation fails. * * ast_strndup(), unlike strndup(), can safely accept a NULL argument for the * string to duplicate. If a NULL argument is provided, ast_strdup will return * NULL without generating any kind of error log message. * * The arguments and return value are the same as strndup() */ #define ast_strndup(str, len) \ _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) AST_INLINE_API( char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func), { char *newstr = NULL; if (str) { if (!(newstr = strndup(str, len))) MALLOC_FAILURE_MSG; } return newstr; } ) /*! * \brief A wrapper for asprintf() * * ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log * message in the case that the allocation fails. * * The arguments and return value are the same as asprintf() */ #define ast_asprintf(ret, fmt, ...) \ _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) int __attribute__((format(printf, 5, 6))) _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...); /*! * \brief A wrapper for vasprintf() * * ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log * message in the case that the allocation fails. * * The arguments and return value are the same as vasprintf() */ #define ast_vasprintf(ret, fmt, ap) \ _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) AST_INLINE_API( __attribute__((format(printf, 5, 0))) int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap), { int res; if ((res = vasprintf(ret, fmt, ap)) == -1) MALLOC_FAILURE_MSG; return res; } ) #endif /* AST_DEBUG_MALLOC */ /*! \brief call __builtin_alloca to ensure we get gcc builtin semantics \param size The size of the buffer we want allocated This macro will attempt to allocate memory from the stack. If it fails you won't get a NULL returned, but a SEGFAULT if you're lucky. */ #define ast_alloca(size) __builtin_alloca(size) #if !defined(ast_strdupa) && defined(__GNUC__) /*! * \brief duplicate a string in memory from the stack * \param s The string to duplicate * * This macro will duplicate the given string. It returns a pointer to the stack * allocatted memory for the new string. */ #define ast_strdupa(s) \ (__extension__ \ ({ \ const char *__old = (s); \ size_t __len = strlen(__old) + 1; \ char *__new = __builtin_alloca(__len); \ memcpy (__new, __old, __len); \ __new; \ })) #endif /*! * \brief Disable PMTU discovery on a socket * \param sock The socket to manipulate * \return Nothing * * On Linux, UDP sockets default to sending packets with the Dont Fragment (DF) * bit set. This is supposedly done to allow the application to do PMTU * discovery, but Asterisk does not do this. * * Because of this, UDP packets sent by Asterisk that are larger than the MTU * of any hop in the path will be lost. This function can be called on a socket * to ensure that the DF bit will not be set. */ void ast_enable_packet_fragmentation(int sock); /*! * \brief Recursively create directory path * \param path The directory path to create * \param mode The permissions with which to try to create the directory * \return 0 on success or an error code otherwise * * Creates a directory path, creating parent directories as needed. */ int ast_mkdir(const char *path, int mode); #define ARRAY_LEN(a) (size_t) (sizeof(a) / sizeof(0[a])) /* Definition for Digest authorization */ struct ast_http_digest { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(username); AST_STRING_FIELD(nonce); AST_STRING_FIELD(uri); AST_STRING_FIELD(realm); AST_STRING_FIELD(domain); AST_STRING_FIELD(response); AST_STRING_FIELD(cnonce); AST_STRING_FIELD(opaque); AST_STRING_FIELD(nc); ); int qop; /* Flag set to 1, if we send/recv qop="quth" */ }; /*! * \brief Parse digest authorization header. * \return Returns -1 if we have no auth or something wrong with digest. * \note This function may be used for Digest request and responce header. * request arg is set to nonzero, if we parse Digest Request. * pedantic arg can be set to nonzero if we need to do addition Digest check. */ int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic); #ifdef AST_DEVMODE void __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function); #define ast_assert(a) _ast_assert(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) static void force_inline _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function) { if (__builtin_expect(!condition, 1)) { __ast_assert_failed(condition, condition_str, file, line, function); } } #else #define ast_assert(a) #endif /*! * \brief Force a crash if DO_CRASH is defined. * * \note If DO_CRASH is not defined then the function returns. * * \return Nothing */ void ast_do_crash(void); #include "asterisk/strings.h" /*! * \brief Return the number of bytes used in the alignment of type. * \param type * \return The number of bytes required for alignment. * * This is really just __alignof__(), but tucked away in this header so we * don't have to look at the nasty underscores in the source. */ #define ast_alignof(type) __alignof__(type) /*! * \brief Increase offset so it is a multiple of the required alignment of type. * \param offset The value that should be increased. * \param type The data type that offset should be aligned to. * \return The smallest multiple of alignof(type) larger than or equal to offset. * \see ast_make_room_for() * * Many systems prefer integers to be stored on aligned on memory locations. * This macro will increase an offset so a value of the supplied type can be * safely be stored on such a memory location. * * Examples: * ast_align_for(0x17, int64_t) ==> 0x18 * ast_align_for(0x18, int64_t) ==> 0x18 * ast_align_for(0x19, int64_t) ==> 0x20 * * Don't mind the ugliness, the compiler will optimize it. */ #define ast_align_for(offset, type) (((offset + __alignof__(type) - 1) / __alignof__(type)) * __alignof__(type)) /*! * \brief Increase offset by the required alignment of type and make sure it is * a multiple of said alignment. * \param offset The value that should be increased. * \param type The data type that room should be reserved for. * \return The smallest multiple of alignof(type) larger than or equal to offset * plus alignof(type). * \see ast_align_for() * * A use case for this is when prepending length fields of type int to a buffer. * If you keep the offset a multiple of the alignment of the integer type, * a next block of length+buffer will have the length field automatically * aligned. * * Examples: * ast_make_room_for(0x17, int64_t) ==> 0x20 * ast_make_room_for(0x18, int64_t) ==> 0x20 * ast_make_room_for(0x19, int64_t) ==> 0x28 * * Don't mind the ugliness, the compiler will optimize it. */ #define ast_make_room_for(offset, type) (((offset + (2 * __alignof__(type) - 1)) / __alignof__(type)) * __alignof__(type)) /*! * \brief An Entity ID is essentially a MAC address, brief and unique */ struct ast_eid { unsigned char eid[6]; } __attribute__((__packed__)); /*! * \brief Global EID * * This is set in asterisk.conf, or determined automatically by taking the mac * address of an Ethernet interface on the system. */ extern struct ast_eid ast_eid_default; /*! * \brief Fill in an ast_eid with the default eid of this machine * \since 1.6.1 */ void ast_set_default_eid(struct ast_eid *eid); /*! * \brief Convert an EID to a string * \since 1.6.1 */ char *ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid); /*! * \brief Convert a string into an EID * * This function expects an EID in the format: * 00:11:22:33:44:55 * * \return 0 success, non-zero failure * \since 1.6.1 */ int ast_str_to_eid(struct ast_eid *eid, const char *s); /*! * \brief Compare two EIDs * * \return 0 if the two are the same, non-zero otherwise * \since 1.6.1 */ int ast_eid_cmp(const struct ast_eid *eid1, const struct ast_eid *eid2); /*! * \brief Get current thread ID * \param None * \return the ID if platform is supported, else -1 */ int ast_get_tid(void); /*! * \brief Resolve a binary to a full pathname * \param binary Name of the executable to resolve * \param fullpath Buffer to hold the complete pathname * \param fullpath_size Size of \a fullpath * \retval NULL \a binary was not found or the environment variable PATH is not set * \return \a fullpath */ char *ast_utils_which(const char *binary, char *fullpath, size_t fullpath_size); /*! * \brief Declare a variable that will call a destructor function when it goes out of scope. * * Resource Allocation Is Initialization (RAII) variable declaration. * * \since 11.0 * \param vartype The type of the variable * \param varname The name of the variable * \param initval The initial value of the variable * \param dtor The destructor function of type' void func(vartype *)' * * \code * void mything_cleanup(struct mything *t) * { * if (t) { * ast_free(t->stuff); * } * } * * void do_stuff(const char *name) * { * RAII_VAR(struct mything *, thing, mything_alloc(name), mything_cleanup); * ... * } * * \note This macro is especially useful for working with ao2 objects. A common idiom * would be a function that needed to look up an ao2 object and might have several error * conditions after the allocation that would normally need to unref the ao2 object. * With RAII_VAR, it is possible to just return and leave the cleanup to the destructor * function. For example: * \code * void do_stuff(const char *name) * { * RAII_VAR(struct mything *, thing, find_mything(name), ao2_cleanup); * if (!thing) { * return; * } * if (error) { * return; * } * do_stuff_with_thing(thing); * } * \encode */ #define RAII_VAR(vartype, varname, initval, dtor) \ /* Prototype needed due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36774 */ \ auto void _dtor_ ## varname (vartype * v); \ void _dtor_ ## varname (vartype * v) { dtor(*v); } \ vartype varname __attribute__((cleanup(_dtor_ ## varname))) = (initval) #endif /* _ASTERISK_UTILS_H */ asterisk-11.7.0/include/asterisk/aoc.h0000644000175000007640000004230411401517207017531 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * David Vossel * * 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 Generic Advice of Charge encode and decode routines * * \author David Vossel */ #ifndef _AST_AOC_H_ #define _AST_AOC_H_ #include "asterisk/channel.h" #define AOC_CURRENCY_NAME_SIZE (10 + 1) /*! \brief Defines the currency multiplier for an aoc message. */ enum ast_aoc_currency_multiplier { AST_AOC_MULT_ONETHOUSANDTH = 1, AST_AOC_MULT_ONEHUNDREDTH, AST_AOC_MULT_ONETENTH, AST_AOC_MULT_ONE, AST_AOC_MULT_TEN, AST_AOC_MULT_HUNDRED, AST_AOC_MULT_THOUSAND, AST_AOC_MULT_NUM_ENTRIES, /* must remain the last item in enum, this is not a valid type */ }; /*! * \brief Defines the billing id options for an aoc message. * \note AOC-D is limited to NORMAL, REVERSE_CHARGE, and CREDIT_CARD. */ enum ast_aoc_billing_id { AST_AOC_BILLING_NA = 0, AST_AOC_BILLING_NORMAL, AST_AOC_BILLING_REVERSE_CHARGE, AST_AOC_BILLING_CREDIT_CARD, AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL, AST_AOC_BILLING_CALL_FWD_BUSY, AST_AOC_BILLING_CALL_FWD_NO_REPLY, AST_AOC_BILLING_CALL_DEFLECTION, AST_AOC_BILLING_CALL_TRANSFER, AST_AOC_BILLING_NUM_ENTRIES /* must remain the last item in enum, not a valid billing id */ }; enum ast_aoc_type { AST_AOC_REQUEST = 0, AST_AOC_S, AST_AOC_D, AST_AOC_E, /* aoc-e must remain the last item in this enum */ }; enum ast_aoc_charge_type { AST_AOC_CHARGE_NA = 0, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_UNIT, /* unit must remain the last item in enum */ }; enum ast_aoc_request { AST_AOC_REQUEST_S = (1 << 0), AST_AOC_REQUEST_D = (1 << 1), AST_AOC_REQUEST_E = (1 << 2), }; enum ast_aoc_total_type { AST_AOC_TOTAL = 0, AST_AOC_SUBTOTAL = 1, }; enum ast_aoc_time_scale { AST_AOC_TIME_SCALE_HUNDREDTH_SECOND, AST_AOC_TIME_SCALE_TENTH_SECOND, AST_AOC_TIME_SCALE_SECOND, AST_AOC_TIME_SCALE_TEN_SECOND, AST_AOC_TIME_SCALE_MINUTE, AST_AOC_TIME_SCALE_HOUR, AST_AOC_TIME_SCALE_DAY, }; struct ast_aoc_time { /*! LengthOfTimeUnit (Not valid if length is zero.) */ uint32_t length; uint16_t scale; }; struct ast_aoc_duration_rate { uint32_t amount; uint32_t time; /*! Not present if the granularity time is zero. */ uint32_t granularity_time; uint16_t multiplier; uint16_t time_scale; uint16_t granularity_time_scale; /*! Name of currency involved. Null terminated. */ char currency_name[AOC_CURRENCY_NAME_SIZE]; /*! * \brief Charging interval type * \details * continuousCharging(0), * stepFunction(1) */ uint8_t charging_type; }; enum ast_aoc_volume_unit { AST_AOC_VOLUME_UNIT_OCTET, AST_AOC_VOLUME_UNIT_SEGMENT, AST_AOC_VOLUME_UNIT_MESSAGE, }; struct ast_aoc_volume_rate { uint32_t amount; uint16_t multiplier; uint16_t volume_unit; char currency_name[AOC_CURRENCY_NAME_SIZE]; }; struct ast_aoc_flat_rate { uint32_t amount; uint16_t multiplier; /*! Name of currency involved. Null terminated. */ char currency_name[AOC_CURRENCY_NAME_SIZE]; }; enum ast_aoc_s_charged_item { AST_AOC_CHARGED_ITEM_NA, AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION, AST_AOC_CHARGED_ITEM_CALL_ATTEMPT, AST_AOC_CHARGED_ITEM_CALL_SETUP, AST_AOC_CHARGED_ITEM_USER_USER_INFO, AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE, }; enum ast_aoc_s_rate_type { AST_AOC_RATE_TYPE_NA, AST_AOC_RATE_TYPE_FREE, AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING, AST_AOC_RATE_TYPE_DURATION, AST_AOC_RATE_TYPE_FLAT, AST_AOC_RATE_TYPE_VOLUME, AST_AOC_RATE_TYPE_SPECIAL_CODE, }; struct ast_aoc_s_entry { uint16_t charged_item; uint16_t rate_type; /*! \brief Charge rate being applied. */ union { struct ast_aoc_duration_rate duration; struct ast_aoc_flat_rate flat; struct ast_aoc_volume_rate volume; uint16_t special_code; /* 1...10 */ } rate; } __attribute__((packed)); struct ast_aoc_unit_entry { char valid_amount; unsigned int amount; char valid_type; unsigned int type; /* 1 - 16 by ETSI standard */ }; enum AST_AOC_CHARGING_ASSOCIATION { AST_AOC_CHARGING_ASSOCIATION_NA, AST_AOC_CHARGING_ASSOCIATION_NUMBER, AST_AOC_CHARGING_ASSOCIATION_ID, }; struct ast_aoc_charging_association_number { uint8_t plan; char number[32]; } __attribute__((packed)); struct ast_aoc_charging_association { union { int32_t id; struct ast_aoc_charging_association_number number; } charge; /*! \see enum AST_AOC_CHARGING_ASSOCIATION */ uint8_t charging_type; } __attribute__((packed)); /*! \brief AOC Payload Header. Holds all the encoded AOC data to pass on the wire */ struct ast_aoc_encoded; /*! \brief Decoded AOC data. This value is used to set all the values in an AOC message before encoding.*/ struct ast_aoc_decoded; /*! * \brief creates a ast_aoc_decode object of a specific message type * \since 1.8 * * \param msg_type AOC-D, AOC-E, or AOC Request * \param charge_type this is ignored if message type is not AOC-D or AOC-E. * \param requests flags. This defines the types of AOC requested. This * field should only be set when the message type is AOC Request, * the value is ignored otherwise. * * \retval heap allocated ast_aoc_decoded object ptr on success * \retval NULL failure */ struct ast_aoc_decoded *ast_aoc_create(const enum ast_aoc_type msg_type, const enum ast_aoc_charge_type charge_type, const enum ast_aoc_request requests); /*! \brief free an ast_aoc_decoded object */ void *ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded); /*! \brief free an ast_aoc_encoded object */ void *ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded); /*! * \brief decodes an encoded aoc payload. * \since 1.8 * * \param encoded the encoded payload to decode. * \param size total size of encoded payload * \param chan ast channel, Optional for DEBUG output purposes * * \retval heap allocated ast_aoc_decoded object ptr on success * \retval NULL failure */ struct ast_aoc_decoded *ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan); /*! * \brief encodes a decoded aoc structure so it can be passed on the wire * \since 1.8 * * \param decoded the decoded struct to be encoded * \param out_size output parameter representing size of encoded data * \param chan ast channel, Optional for DEBUG output purposes * * \retval pointer to encoded data * \retval NULL failure */ struct ast_aoc_encoded *ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size, struct ast_channel *chan); /*! * \brief Sets the type of total for a AOC-D message * \since 1.8 * * \param decoded ast_aoc_decoded struct to set values on * \param type total type: TOTAL or SUBTOTAL * * \note If this value is not set, the default for the message is TOTAL * * \retval 0 success */ int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type); /*! * \brief Sets the currency values for a AOC-D or AOC-E message * \since 1.8 * * \param decoded ast_aoc_decoded struct to set values on * \param amount currency amount REQUIRED * \param multiplier currency multiplier REQUIRED, 0 or undefined value defaults to AST_AOC_MULT_ONE. * \param name currency name OPTIONAL * * \retval 0 success */ int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded, const unsigned int amount, const enum ast_aoc_currency_multiplier multiplier, const char *name); /*! * \brief Adds a unit entry into the list of units * \since 1.8 * * \param decoded ast_aoc_decoded struct to set values on * \param amount_is_present set this if the number of units is actually present. * \param amount number of units * \param type_is_present set this if the type value is present * \param type unit type * * \note If neither the amount nor the type is present, the entry will * not be added. * * \retval 0 success */ int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type); /*! * \brief set the billing id for a AOC-D or AST_AOC_E message * \since 1.8 * * \param decoded ast_aoc_decoded struct to set values on * \param id billing id * * \retval 0 success */ int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id); /*! * \brief set the charging association id for an AST_AOC_E message * \since 1.8 * * \param decoded ast_aoc_decoded struct to set values on * \param id charging association identifier * * \note If the association number was set, this will override that value. Only the id OR the * number can be set at a time, not both. * * \retval 0 success */ int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id); /*! * \brief set the charging accociation number for an AOC-E message * \since 1.8 * * \param decoded ast_aoc_decoded struct to set values on * \param num charging association number * \param plan charging association number plan and type-of-number fields * * \note If the association id was set, this will override that value. Only the id OR the * number can be set at a time, not both. * * \retval 0 success */ int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan); /*! * \brief Mark the AST_AOC_REQUEST message as a termination request. * \since 1.8 * * \param decoded ast_aoc_decoded struct to set values on * * \note A termination request indicates that the call has terminated, * but that the other side is waiting for a short period of time before * hanging up so it can get the final AOC-E message. * * \retval 0 success * \retval -1 failure */ int ast_aoc_set_termination_request(struct ast_aoc_decoded *decoded); /*! * \brief Add AOC-S duration rate entry * \since 1.8 * * \param decoded aoc decoded object to add entry to * \param charged_item ast_aoc_s_charged_item * \param amount currency amount * \param multiplier currency multiplier * \param currency_name truncated after 10 characters * \param time * \param time_scale from ast_aoc_time_scale enum * \param granularity_time (optional, set to 0 if not present); * \param granularity_time_scale (optional, set to 0 if not present); * \param step_function set to 1 if this is to use a step function, 0 if continuious * * \retval 0 success * \retval -1 failure */ int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name, unsigned long time, enum ast_aoc_time_scale time_scale, unsigned long granularity_time, enum ast_aoc_time_scale granularity_time_scale, int step_function); /*! * \brief Add AOC-S flat rate entry * \since 1.8 * * \param decoded aoc decoded object to add entry to * \param charged_item ast_aoc_s_charged_item * \param amount currency amount * \param multiplier currency multiplier * \param currency_name truncated after 10 characters * * \retval 0 success * \retval -1 failure */ int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name); /*! * \brief Add AOC-S volume rate entry * \since 1.8 * * \param decoded aoc decoded object to add entry to * \param charged_item ast_aoc_s_charged_item * \param volume_unit from ast_aoc_volume_unit enum * \param amount currency amount * \param multiplier currency multiplier * \param currency_name truncated after 10 characters * * \retval 0 success * \retval -1 failure */ int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, enum ast_aoc_volume_unit volume_unit, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name); /*! * \brief Add AOC-S special rate entry * \since 1.8 * * \param decoded aoc decoded object to add entry to * \param charged_item ast_aoc_s_charged_item * \param code special charging code * * \retval 0 success * \retval -1 failure */ int ast_aoc_s_add_rate_special_charge_code(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int code); /*! * \brief Add AOC-S indicating charge item is free * \since 1.8 * * \param decoded aoc decoded object to add entry to * \param charged_item ast_aoc_s_charged_item * \param from_beginning TRUE if the rate is free from beginning. * * \retval 0 success * \retval -1 failure */ int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, int from_beginning); /*! * \brief Add AOC-S entry indicating charge item is not available * \since 1.8 * * \param decoded aoc decoded object to add entry to * \param charged_item ast_aoc_s_charged_item * * \retval 0 success * \retval -1 failure */ int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item); /*! * \brief Add AOC-S special arrangement entry * \since 1.8 * * \param decoded aoc decoded object to add entry to * \param code special arrangement code * * \retval 0 success * \retval -1 failure */ int ast_aoc_s_add_special_arrangement(struct ast_aoc_decoded *decoded, unsigned int code); /*! * \brief Convert decoded aoc msg to string representation * \since 1.8 * * \param decoded ast_aoc_decoded struct to convert to string * \param msg dynamic heap allocated ast_str object to store string representation in * * \retval 0 success * \retval -1 failure */ int ast_aoc_decoded2str(const struct ast_aoc_decoded *decoded, struct ast_str **msg); /*! \brief generate AOC manager event for an AOC-S, AOC-D, or AOC-E msg */ int ast_aoc_manager_event(const struct ast_aoc_decoded *decoded, struct ast_channel *chan); /*! \brief get the message type, AOC-D, AOC-E, or AOC Request */ enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded); /*! \brief get the charging type for an AOC-D or AOC-E message */ enum ast_aoc_charge_type ast_aoc_get_charge_type(struct ast_aoc_decoded *decoded); /*! \brief get the types of AOC requested for when message type is AOC Request */ enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decoded); /*! \brief get the type of total for a AOC-D message */ enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decoded); /*! \brief get the currency amount for AOC-D and AOC-E messages*/ unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded); /*! \brief get the number rates associated with an AOC-S message */ unsigned int ast_aoc_s_get_count(struct ast_aoc_decoded *decoded); /*! * \brief get a specific AOC-S rate entry. * \since 1.8 * * \note This can be used in conjunction with ast_aoc_s_get_count to create * a unit entry iterator. */ const struct ast_aoc_s_entry *ast_aoc_s_get_rate_info(struct ast_aoc_decoded *decoded, unsigned int entry_number); /*! \brief get the number of unit entries for AOC-D and AOC-E messages*/ unsigned int ast_aoc_get_unit_count(struct ast_aoc_decoded *decoded); /*! * \brief get a specific unit entry. * \since 1.8 * * \note This can be used in conjunction with ast_aoc_get_unit_count to create * a unit entry iterator. */ const struct ast_aoc_unit_entry *ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number); /*! \brief get the currency multiplier for AOC-D and AOC-E messages */ enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded); /*! \brief get the currency multiplier for AOC-D and AOC-E messages in decimal format */ const char *ast_aoc_get_currency_multiplier_decimal(struct ast_aoc_decoded *decoded); /*! \brief get the currency name for AOC-D and AOC-E messages*/ const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded); /*! \brief get the billing id for AOC-D and AOC-E messages*/ enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decoded); /*! \brief get the charging association info for AOC-E messages*/ const struct ast_aoc_charging_association *ast_aoc_get_association_info(struct ast_aoc_decoded *decoded); /*! * \brief get whether or not the AST_AOC_REQUEST message as a termination request. * \since 1.8 * * \note a termination request indicates that the call has terminated, * but that the other side is waiting for a short period of time * before hanging up so it can get the final AOC-E message. * * \param decoded ast_aoc_decoded struct to get values on * * \retval 0 not a termination request * \retval 1 is a termination request */ int ast_aoc_get_termination_request(struct ast_aoc_decoded *decoded); /*! * \brief test aoc encode decode routines. * \since 1.8 * * \note This function verifies that a decoded message matches itself after * the encode decode routine. */ int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded); /*! \brief enable aoc cli options */ int ast_aoc_cli_init(void); #endif /* _AST_AOC_H_ */ asterisk-11.7.0/include/asterisk/privacy.h0000644000175000007640000000247710374426007020460 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Persistant data storage (akin to *doze registry) */ #ifndef _ASTERISK_PRIVACY_H #define _ASTERISK_PRIVACY_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define AST_PRIVACY_DENY (1 << 0) /* Don't bother ringing, send to voicemail */ #define AST_PRIVACY_ALLOW (1 << 1) /* Pass directly to me */ #define AST_PRIVACY_KILL (1 << 2) /* Play anti-telemarketer message and hangup */ #define AST_PRIVACY_TORTURE (1 << 3) /* Send directly to tele-torture */ #define AST_PRIVACY_UNKNOWN (1 << 16) int ast_privacy_check(char *dest, char *cid); int ast_privacy_set(char *dest, char *cid, int status); int ast_privacy_reset(char *dest); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_PRIVACY_H */ asterisk-11.7.0/include/asterisk/speech.h0000644000175000007640000001360411522553062020242 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2006, Digium, Inc. * * Joshua Colp * * 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 Generic Speech Recognition API */ #ifndef _ASTERISK_SPEECH_H #define _ASTERISK_SPEECH_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /* Speech structure flags */ enum ast_speech_flags { AST_SPEECH_QUIET = (1 << 0), /* Quiet down output... they are talking */ AST_SPEECH_SPOKE = (1 << 1), /* Speaker spoke! */ AST_SPEECH_HAVE_RESULTS = (1 << 2), /* Results are present */ }; /* Speech structure states - in order of expected change */ enum ast_speech_states { AST_SPEECH_STATE_NOT_READY = 0, /* Not ready to accept audio */ AST_SPEECH_STATE_READY, /* Accepting audio */ AST_SPEECH_STATE_WAIT, /* Wait for results to become available */ AST_SPEECH_STATE_DONE, /* Processing is all done */ }; enum ast_speech_results_type { AST_SPEECH_RESULTS_TYPE_NORMAL = 0, AST_SPEECH_RESULTS_TYPE_NBEST, }; /* Speech structure */ struct ast_speech { /*! Structure lock */ ast_mutex_t lock; /*! Set flags */ unsigned int flags; /*! Processing sound (used when engine is processing audio and getting results) */ char *processing_sound; /*! Current state of structure */ int state; /*! Expected write format */ struct ast_format format; /*! Data for speech engine */ void *data; /*! Cached results */ struct ast_speech_result *results; /*! Type of results we want */ enum ast_speech_results_type results_type; /*! Pointer to the engine used by this speech structure */ struct ast_speech_engine *engine; }; /* Speech recognition engine structure */ struct ast_speech_engine { /*! Name of speech engine */ char *name; /*! Set up the speech structure within the engine */ int (*create)(struct ast_speech *speech, struct ast_format *format); /*! Destroy any data set on the speech structure by the engine */ int (*destroy)(struct ast_speech *speech); /*! Load a local grammar on the speech structure */ int (*load)(struct ast_speech *speech, const char *grammar_name, const char *grammar); /*! Unload a local grammar */ int (*unload)(struct ast_speech *speech, const char *grammar_name); /*! Activate a loaded grammar */ int (*activate)(struct ast_speech *speech, const char *grammar_name); /*! Deactivate a loaded grammar */ int (*deactivate)(struct ast_speech *speech, const char *grammar_name); /*! Write audio to the speech engine */ int (*write)(struct ast_speech *speech, void *data, int len); /*! Signal DTMF was received */ int (*dtmf)(struct ast_speech *speech, const char *dtmf); /*! Prepare engine to accept audio */ int (*start)(struct ast_speech *speech); /*! Change an engine specific setting */ int (*change)(struct ast_speech *speech, const char *name, const char *value); /*! Change the type of results we want back */ int (*change_results_type)(struct ast_speech *speech, enum ast_speech_results_type results_type); /*! Try to get results */ struct ast_speech_result *(*get)(struct ast_speech *speech); /*! Accepted formats by the engine */ struct ast_format_cap *formats; AST_LIST_ENTRY(ast_speech_engine) list; }; /* Result structure */ struct ast_speech_result { /*! Recognized text */ char *text; /*! Result score */ int score; /*! NBest Alternative number if in NBest results type */ int nbest_num; /*! Matched grammar */ char *grammar; /*! List information */ AST_LIST_ENTRY(ast_speech_result) list; }; /*! \brief Activate a grammar on a speech structure */ int ast_speech_grammar_activate(struct ast_speech *speech, const char *grammar_name); /*! \brief Deactivate a grammar on a speech structure */ int ast_speech_grammar_deactivate(struct ast_speech *speech, const char *grammar_name); /*! \brief Load a grammar on a speech structure (not globally) */ int ast_speech_grammar_load(struct ast_speech *speech, const char *grammar_name, const char *grammar); /*! \brief Unload a grammar */ int ast_speech_grammar_unload(struct ast_speech *speech, const char *grammar_name); /*! \brief Get speech recognition results */ struct ast_speech_result *ast_speech_results_get(struct ast_speech *speech); /*! \brief Free a set of results */ int ast_speech_results_free(struct ast_speech_result *result); /*! \brief Indicate to the speech engine that audio is now going to start being written */ void ast_speech_start(struct ast_speech *speech); /*! \brief Create a new speech structure */ struct ast_speech *ast_speech_new(const char *engine_name, const struct ast_format_cap *formats); /*! \brief Destroy a speech structure */ int ast_speech_destroy(struct ast_speech *speech); /*! \brief Write audio to the speech engine */ int ast_speech_write(struct ast_speech *speech, void *data, int len); /*! \brief Signal to the engine that DTMF was received */ int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf); /*! \brief Change an engine specific attribute */ int ast_speech_change(struct ast_speech *speech, const char *name, const char *value); /*! \brief Change the type of results we want */ int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type); /*! \brief Change state of a speech structure */ int ast_speech_change_state(struct ast_speech *speech, int state); /*! \brief Register a speech recognition engine */ int ast_speech_register(struct ast_speech_engine *engine); /*! \brief Unregister a speech recognition engine */ int ast_speech_unregister(const char *engine_name); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_SPEECH_H */ asterisk-11.7.0/include/asterisk/indications.h0000644000175000007640000001520311710570464021300 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2002, Pauline Middelink * Copyright (C) 2009, Digium, Inc. * * 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 Tone Indication Support * * \author Pauline Middelink * \author Russell Bryant */ #ifndef _ASTERISK_INDICATIONS_H #define _ASTERISK_INDICATIONS_H #include "asterisk/astobj2.h" #include "asterisk/utils.h" #include "asterisk/data.h" /*! * \brief Description of a tone */ struct ast_tone_zone_sound { /*! \brief Name of the tone. For example, "busy". */ const char *name; /*! * \brief Description of a tone * * The format is a comma separated list of tone parts in the following format: * * Format: [!][M]freq[<+|*>freq2][/duration] * - '!' - means that the element is NOT repeated * - 'M' - interpret the frequencies as midi notes instead of frequencies * - freq - The first frequency * - freq2 - The second frequency (optional) * - '*' - modulate freq by freq2 at a fixed depth of 90% * - '+' - combine the frequencies * - duration - the length of the tone part (optional, forever if not specified) */ const char *data; /*! \brief Linked list fields for including in the list on an ast_tone_zone */ AST_LIST_ENTRY(ast_tone_zone_sound) entry; /*! \brief Flags only used internally */ union { uint32_t __padding; struct { unsigned int killme:1; }; }; }; #define MAX_TONEZONE_COUNTRY 16 /*! * \brief A set of tones for a given locale * * \note If a reference to this tone zone is held, then the country * is guaranteed not to change. It is safe to read it without * locking the tone zone. This is not the case for any other * field. */ struct ast_tone_zone { /*! \brief Country code that this set of tones is for */ char country[MAX_TONEZONE_COUNTRY]; /*! * \brief Text description of the given country. * * This is for nothing more than friendly display to a human. */ char description[40]; /*! \brief Number of ring cadence elements in the ringcadence array */ unsigned int nrringcadence; /*! * \brief Array of ring cadence parts * * Each element is an amount of time in milliseconds. The first element * is for time on, and from there it alternates between on and off. */ int *ringcadence; /*! \brief A list of tones for this locale */ AST_LIST_HEAD_NOLOCK(, ast_tone_zone_sound) tones; /*! \brief Flags only used internally */ union { uint32_t __padding; struct { unsigned int killme:1; }; }; }; /*! * \brief A description of a part of a tone * * The elements in this structure map to the format described for the data * part of the ast_tone_zone_sound struct. */ struct ast_tone_zone_part { unsigned int freq1; unsigned int freq2; unsigned int time; unsigned int modulate:1; unsigned int midinote:1; }; /*! * \brief Parse a tone part * * \param s The part of a tone to parse. This should be in the form described for * the data part of ast_tone_zone_sound. '!' should be removed if present. * \param tone_data An output parameter that contains the result of the parsing. * * \retval 0 success * \retval -1 failure, and the contents of tone_data are undefined */ int ast_tone_zone_part_parse(const char *s, struct ast_tone_zone_part *tone_data); /*! * \brief locate ast_tone_zone * * \param country country to find. If NULL is provided, get the default. * * \return a reference to the specified country if found or NULL if not found */ struct ast_tone_zone *ast_get_indication_zone(const char *country); /*! * \brief Locate a tone zone sound * * \param zone Zone to look in for a sound, if NULL, the default will be used * \param indication Sound to look for, such as "busy" * * \return a reference to the specified sound if it exists, NULL if not */ struct ast_tone_zone_sound *ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication); /*! * \brief Start playing a list of tones on a channel * * \param chan the channel to play tones on * \param vol volume * \param tonelist the list of tones to play, comma separated * \param interruptible whether or not this tone can be interrupted * * \retval 0 success * \retval non-zero failure */ int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible); /*! * \brief Stop playing tones on a channel * * \param chan the channel to stop tones on */ void ast_playtones_stop(struct ast_channel *chan); /*! * \brief Get the number of registered tone zones * * \return the total number of registered tone zones */ int ast_tone_zone_count(void); /*! * \brief Get an iterator for the available tone zones * * \note Use ao2_iterator_next() to iterate the tone zones. * \note Use ao2_iterator_destroy() to clean up. * * \return an initialized iterator */ struct ao2_iterator ast_tone_zone_iterator_init(void); /*! * \brief Lock an ast_tone_zone */ #define ast_tone_zone_lock(tz) ao2_lock(tz) /*! * \brief Unlock an ast_tone_zone */ #define ast_tone_zone_unlock(tz) ao2_unlock(tz) /*! * \brief Trylock an ast_tone_zone */ #define ast_tone_zone_trylock(tz) ao2_trylock(tz) /*! * \brief Release a reference to an ast_tone_zone * * \return NULL */ static inline struct ast_tone_zone *ast_tone_zone_unref(struct ast_tone_zone *tz) { ao2_ref(tz, -1); return NULL; } /*! * \brief Increase the reference count on an ast_tone_zone * * \return The tone zone provided as an argument */ static inline struct ast_tone_zone *ast_tone_zone_ref(struct ast_tone_zone *tz) { ao2_ref(tz, +1); return tz; } /*! * \brief Release a reference to an ast_tone_zone_sound * * \return NULL */ static inline struct ast_tone_zone_sound *ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts) { ao2_ref(ts, -1); return NULL; } /*! * \brief Increase the reference count on an ast_tone_zone_sound * * \return The tone zone sound provided as an argument */ static inline struct ast_tone_zone_sound *ast_tone_zone_sound_ref(struct ast_tone_zone_sound *ts) { ao2_ref(ts, +1); return ts; } /*! * \brief Add a tone_zone structure to the data tree specified. * * \retval <0 on error. * \retval 0 on success. */ int ast_tone_zone_data_add_structure(struct ast_data *tree, struct ast_tone_zone *zone); #endif /* _ASTERISK_INDICATIONS_H */ asterisk-11.7.0/include/asterisk/http_websocket.h0000644000175000007640000001534412031103526022013 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Digium, Inc. * * Joshua Colp * * 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. */ #ifndef _ASTERISK_HTTP_WEBSOCKET_H #define _ASTERISK_HTTP_WEBSOCKET_H #include "asterisk/optional_api.h" /*! * \file http_websocket.h * \brief Support for WebSocket connections within the Asterisk HTTP server. * * \author Joshua Colp * */ /*! \brief WebSocket operation codes */ enum ast_websocket_opcode { AST_WEBSOCKET_OPCODE_TEXT = 0x1, /*!< Text frame */ AST_WEBSOCKET_OPCODE_BINARY = 0x2, /*!< Binary frame */ AST_WEBSOCKET_OPCODE_PING = 0x9, /*!< Request that the other side respond with a pong */ AST_WEBSOCKET_OPCODE_PONG = 0xA, /*!< Response to a ping */ AST_WEBSOCKET_OPCODE_CLOSE = 0x8, /*!< Connection is being closed */ AST_WEBSOCKET_OPCODE_CONTINUATION = 0x0, /*!< Continuation of a previous frame */ }; /*! * \brief Opaque structure for WebSocket sessions */ struct ast_websocket; /*! * \brief Callback for when a new connection for a sub-protocol is established * * \param session A WebSocket session structure * \param parameters Parameters extracted from the request URI * \param headers Headers included in the request * * \note Once called the ownership of the session is transferred to the sub-protocol handler. It * is responsible for closing and cleaning up. * */ typedef void (*ast_websocket_callback)(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers); /*! * \brief Add a sub-protocol handler to the server * * \param name Name of the sub-protocol to register * \param callback Callback called when a new connection requesting the sub-protocol is established * * \retval 0 success * \retval -1 if sub-protocol handler could not be registered */ AST_OPTIONAL_API(int, ast_websocket_add_protocol, (const char *name, ast_websocket_callback callback), {return -1;}); /*! * \brief Remove a sub-protocol handler from the server * * \param name Name of the sub-protocol to unregister * \param callback Callback that was previously registered with the sub-protocol * * \retval 0 success * \retval -1 if sub-protocol was not found or if callback did not match */ AST_OPTIONAL_API(int, ast_websocket_remove_protocol, (const char *name, ast_websocket_callback callback), {return -1;}); /*! * \brief Read a WebSocket frame and handle it * * \param session Pointer to the WebSocket session * \param payload Pointer to a char* which will be populated with a pointer to the payload if present * \param payload_len Pointer to a uint64_t which will be populated with the length of the payload if present * \param opcode Pointer to an enum which will be populated with the opcode of the frame * \param fragmented Pointer to an int which is set to 1 if payload is fragmented and 0 if not * * \retval -1 on error * \retval 0 on success * * \note Once an AST_WEBSOCKET_OPCODE_CLOSE opcode is received the socket will be closed */ AST_OPTIONAL_API(int, ast_websocket_read, (struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented), {return -1;}); /*! * \brief Construct and transmit a WebSocket frame * * \param session Pointer to the WebSocket session * \param opcode WebSocket operation code to place in the frame * \param payload Optional pointer to a payload to add to the frame * \param actual_length Length of the payload (0 if no payload) * * \retval 0 if successfully written * \retval -1 if error occurred */ AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length), {return -1;}); /*! * \brief Close a WebSocket session by sending a message with the CLOSE opcode and an optional code * * \param session Pointer to the WebSocket session * \param reason Reason code for closing the session as defined in the RFC * * \retval 0 if successfully written * \retval -1 if error occurred */ AST_OPTIONAL_API(int, ast_websocket_close, (struct ast_websocket *session, uint16_t reason), {return -1;}); /*! * \brief Enable multi-frame reconstruction up to a certain number of bytes * * \param session Pointer to the WebSocket session * \param bytes If a reconstructed payload exceeds the specified number of bytes the payload will be returned * and upon reception of the next multi-frame a new reconstructed payload will begin. */ AST_OPTIONAL_API(void, ast_websocket_reconstruct_enable, (struct ast_websocket *session, size_t bytes), {return;}); /*! * \brief Disable multi-frame reconstruction * * \param session Pointer to the WebSocket session * * \note If reconstruction is disabled each message that is part of a multi-frame message will be sent up to * the user when ast_websocket_read is called. */ AST_OPTIONAL_API(void, ast_websocket_reconstruct_disable, (struct ast_websocket *session), {return;}); /*! * \brief Increase the reference count for a WebSocket session * * \param session Pointer to the WebSocket session */ AST_OPTIONAL_API(void, ast_websocket_ref, (struct ast_websocket *session), {return;}); /*! * \brief Decrease the reference count for a WebSocket session * * \param session Pointer to the WebSocket session */ AST_OPTIONAL_API(void, ast_websocket_unref, (struct ast_websocket *session), {return;}); /*! * \brief Get the file descriptor for a WebSocket session. * * \retval file descriptor * * \note You must *not* directly read from or write to this file descriptor. It should only be used for polling. */ AST_OPTIONAL_API(int, ast_websocket_fd, (struct ast_websocket *session), {return -1;}); /*! * \brief Get the remote address for a WebSocket connected session. * * \retval ast_sockaddr Remote address */ AST_OPTIONAL_API(struct ast_sockaddr *, ast_websocket_remote_address, (struct ast_websocket *session), {return NULL;}); /*! * \brief Get whether the WebSocket session is using a secure transport or not. * * \retval 0 if unsecure * \retval 1 if secure */ AST_OPTIONAL_API(int, ast_websocket_is_secure, (struct ast_websocket *session), {return -1;}); /*! * \brief Set the socket of a WebSocket session to be non-blocking. * * \retval 0 on success * \retval -1 on failure */ AST_OPTIONAL_API(int, ast_websocket_set_nonblock, (struct ast_websocket *session), {return -1;}); #endif asterisk-11.7.0/include/asterisk/channel_internal.h0000644000175000007640000000203411730157570022277 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2012, Digium, Inc. * * 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 Internal channel functions for channel.c to use */ #define ast_channel_internal_alloc(destructor) __ast_channel_internal_alloc(destructor, __FILE__, __LINE__, __PRETTY_FUNCTION__) struct ast_channel *__ast_channel_internal_alloc(void (*destructor)(void *obj), const char *file, int line, const char *function); void ast_channel_internal_finalize(struct ast_channel *chan); int ast_channel_internal_is_finalized(struct ast_channel *chan); void ast_channel_internal_cleanup(struct ast_channel *chan); asterisk-11.7.0/include/asterisk/event_defs.h0000644000175000007640000002364412071073763021127 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007 - 2008, Digium, Inc. * * Russell Bryant * * 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 * \author Russell Bryant * \brief Generic event system */ #ifndef AST_EVENT_DEFS_H #define AST_EVENT_DEFS_H /*! \brief Event types * \note These values can *never* change. */ enum ast_event_type { /*! Reserved to provide the ability to subscribe to all events. A specific * event should never have a payload of 0. */ AST_EVENT_ALL = 0x00, /*! This event type is reserved for use by third-party modules to create * custom events without having to modify this file. * \note There are no "custom" IE types, because IEs only have to be * unique to the event itself, not necessarily across all events. */ AST_EVENT_CUSTOM = 0x01, /*! Voicemail message waiting indication */ AST_EVENT_MWI = 0x02, /*! Someone has subscribed to events */ AST_EVENT_SUB = 0x03, /*! Someone has unsubscribed from events */ AST_EVENT_UNSUB = 0x04, /*! The aggregate state of a device across all servers configured to be * a part of a device state cluster has changed. */ AST_EVENT_DEVICE_STATE = 0x05, /*! The state of a device has changed on _one_ server. This should not be used * directly, in general. Use AST_EVENT_DEVICE_STATE instead. */ AST_EVENT_DEVICE_STATE_CHANGE = 0x06, /*! Channel Event Logging events */ AST_EVENT_CEL = 0x07, /*! A report of a security related event (see security_events.h) */ AST_EVENT_SECURITY = 0x08, /*! Used by res_stun_monitor to alert listeners to an exernal network address change. */ AST_EVENT_NETWORK_CHANGE = 0x09, /*! The presence state for a presence provider */ AST_EVENT_PRESENCE_STATE = 0x0a, /*! Used to alert listeners when a named ACL has changed. */ AST_EVENT_ACL_CHANGE = 0x0b, /*! Send out a ping for debugging distributed events */ AST_EVENT_PING = 0x0c, /*! Number of event types. This should be the last event type + 1 */ AST_EVENT_TOTAL = 0x0d, }; /*! \brief Event Information Element types */ enum ast_event_ie_type { /*! Used to terminate the arguments to event functions */ AST_EVENT_IE_END = -1, /*! * \brief Number of new messages * Used by: AST_EVENT_MWI * Payload type: UINT */ AST_EVENT_IE_NEWMSGS = 0x0001, /*! * \brief Number of * Used by: AST_EVENT_MWI * Payload type: UINT */ AST_EVENT_IE_OLDMSGS = 0x0002, /*! * \brief Mailbox name \verbatim (mailbox[@context]) \endverbatim * Used by: AST_EVENT_MWI * Payload type: STR */ AST_EVENT_IE_MAILBOX = 0x0003, /*! * \brief Unique ID * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB * Payload type: UINT */ AST_EVENT_IE_UNIQUEID = 0x0004, /*! * \brief Event type * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB * Payload type: UINT */ AST_EVENT_IE_EVENTTYPE = 0x0005, /*! * \brief Hint that someone cares that an IE exists * Used by: AST_EVENT_SUB * Payload type: UINT (ast_event_ie_type) */ AST_EVENT_IE_EXISTS = 0x0006, /*! * \brief Device Name * Used by AST_EVENT_DEVICE_STATE_CHANGE * Payload type: STR */ AST_EVENT_IE_DEVICE = 0x0007, /*! * \brief Generic State IE * Used by AST_EVENT_DEVICE_STATE_CHANGE * Payload type: UINT * The actual state values depend on the event which * this IE is a part of. */ AST_EVENT_IE_STATE = 0x0008, /*! * \brief Context IE * Used by AST_EVENT_MWI * Payload type: str */ AST_EVENT_IE_CONTEXT = 0x0009, /*! * \brief Channel Event Type * Used by: AST_EVENT_CEL * Payload type: UINT */ AST_EVENT_IE_CEL_EVENT_TYPE = 0x000a, /*! * \brief Channel Event Time (seconds) * Used by: AST_EVENT_CEL * Payload type: UINT */ AST_EVENT_IE_CEL_EVENT_TIME = 0x000b, /*! * \brief Channel Event Time (micro-seconds) * Used by: AST_EVENT_CEL * Payload type: UINT */ AST_EVENT_IE_CEL_EVENT_TIME_USEC = 0x000c, /*! * \brief Channel Event User Event Name * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_USEREVENT_NAME = 0x000d, /*! * \brief Channel Event CID name * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_CIDNAME = 0x000e, /*! * \brief Channel Event CID num * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_CIDNUM = 0x000f, /*! * \brief Channel Event extension name * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_EXTEN = 0x0010, /*! * \brief Channel Event context name * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_CONTEXT = 0x0011, /*! * \brief Channel Event channel name * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_CHANNAME = 0x0012, /*! * \brief Channel Event app name * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_APPNAME = 0x0013, /*! * \brief Channel Event app args/data * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_APPDATA = 0x0014, /*! * \brief Channel Event AMA flags * Used by: AST_EVENT_CEL * Payload type: UINT */ AST_EVENT_IE_CEL_AMAFLAGS = 0x0015, /*! * \brief Channel Event AccountCode * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_ACCTCODE = 0x0016, /*! * \brief Channel Event UniqueID * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_UNIQUEID = 0x0017, /*! * \brief Channel Event Userfield * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_USERFIELD = 0x0018, /*! * \brief Channel Event CID ANI field * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_CIDANI = 0x0019, /*! * \brief Channel Event CID RDNIS field * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_CIDRDNIS = 0x001a, /*! * \brief Channel Event CID dnid * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_CIDDNID = 0x001b, /*! * \brief Channel Event Peer -- for Things involving multiple channels, like BRIDGE * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_PEER = 0x001c, /*! * \brief Channel Event LinkedID * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_LINKEDID = 0x001d, /*! * \brief Channel Event peeraccount * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_PEERACCT = 0x001e, /*! * \brief Channel Event extra data * Used by: AST_EVENT_CEL * Payload type: STR */ AST_EVENT_IE_CEL_EXTRA = 0x001f, /*! * \brief Description * Used by: AST_EVENT_SUB, AST_EVENT_UNSUB * Payload type: STR */ AST_EVENT_IE_DESCRIPTION = 0x0020, /*! * \brief Entity ID * Used by All events * Payload type: RAW * This IE indicates which server the event originated from */ AST_EVENT_IE_EID = 0x0021, AST_EVENT_IE_SECURITY_EVENT = 0x0022, AST_EVENT_IE_EVENT_VERSION = 0x0023, AST_EVENT_IE_SERVICE = 0x0024, AST_EVENT_IE_MODULE = 0x0025, AST_EVENT_IE_ACCOUNT_ID = 0x0026, AST_EVENT_IE_SESSION_ID = 0x0027, AST_EVENT_IE_SESSION_TV = 0x0028, AST_EVENT_IE_ACL_NAME = 0x0029, AST_EVENT_IE_LOCAL_ADDR = 0x002a, AST_EVENT_IE_REMOTE_ADDR = 0x002b, AST_EVENT_IE_EVENT_TV = 0x002c, AST_EVENT_IE_REQUEST_TYPE = 0x002d, AST_EVENT_IE_REQUEST_PARAMS = 0x002e, AST_EVENT_IE_AUTH_METHOD = 0x002f, AST_EVENT_IE_SEVERITY = 0x0030, AST_EVENT_IE_EXPECTED_ADDR = 0x0031, AST_EVENT_IE_CHALLENGE = 0x0032, AST_EVENT_IE_RESPONSE = 0x0033, AST_EVENT_IE_EXPECTED_RESPONSE = 0x0034, AST_EVENT_IE_RECEIVED_CHALLENGE = 0x0035, AST_EVENT_IE_RECEIVED_HASH = 0x0036, AST_EVENT_IE_USING_PASSWORD = 0x0037, AST_EVENT_IE_ATTEMPTED_TRANSPORT = 0x0038, AST_EVENT_IE_PRESENCE_PROVIDER = 0x0039, AST_EVENT_IE_PRESENCE_STATE = 0x003a, AST_EVENT_IE_PRESENCE_SUBTYPE = 0x003b, AST_EVENT_IE_PRESENCE_MESSAGE = 0x003c, /*! * \brief Event non-cachability flag * Used by: All events * Payload type: UINT */ AST_EVENT_IE_CACHABLE = 0x003d, /*! \brief Must be the last IE value +1 */ AST_EVENT_IE_TOTAL = 0x003e, }; /*! * \brief Payload types for event information elements */ enum ast_event_ie_pltype { AST_EVENT_IE_PLTYPE_UNKNOWN = -1, /*! Just check if it exists, not the value */ AST_EVENT_IE_PLTYPE_EXISTS, /*! Unsigned Integer (Can be used for signed, too ...) */ AST_EVENT_IE_PLTYPE_UINT, /*! String */ AST_EVENT_IE_PLTYPE_STR, /*! Raw data, compared with memcmp */ AST_EVENT_IE_PLTYPE_RAW, /*! Bit flags (unsigned integer, compared using boolean logic) */ AST_EVENT_IE_PLTYPE_BITFLAGS, }; /*! * \brief Results for checking for subscribers * * \ref ast_event_check_subscriber() */ enum ast_event_subscriber_res { /*! No subscribers exist */ AST_EVENT_SUB_NONE, /*! At least one subscriber exists */ AST_EVENT_SUB_EXISTS, }; struct ast_event; struct ast_event_ie; struct ast_event_sub; struct ast_event_iterator; /*! * \brief supposed to be an opaque type * * This is only here so that it can be declared on the stack. */ struct ast_event_iterator { uint16_t event_len; const struct ast_event *event; struct ast_event_ie *ie; }; #endif /* AST_EVENT_DEFS_H */ asterisk-11.7.0/include/asterisk/buildinfo.h0000644000175000007640000000153111102363167020741 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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. */ #ifndef _ASTERISK_BUILDINFO_H #define _ASTERISK_BUILDINFO_H extern const char *ast_build_hostname; extern const char *ast_build_kernel; extern const char *ast_build_machine; extern const char *ast_build_os; extern const char *ast_build_date; extern const char *ast_build_user; #endif asterisk-11.7.0/include/asterisk/stun.h0000644000175000007640000000550411665767555020012 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2008, Digium, Inc. * * Mark Spencer * * 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 stun.h * \brief STUN support. * * STUN is defined in RFC 3489. */ #ifndef _ASTERISK_STUN_H #define _ASTERISK_STUN_H #include "asterisk/network.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif static const int STANDARD_STUN_PORT = 3478; enum ast_stun_result { AST_STUN_IGNORE = 0, AST_STUN_ACCEPT, }; struct stun_attr; /*! * \brief Generic STUN request. * * \param s The socket used to send the request. * \param dst If non null, the address of the STUN server. * Only needed if the socket is not bound or connected. * \param username If non null, add the username in the request. * \param answer If non null, the function waits for a response and * puts here the externally visible address. * * \details * Send a generic STUN request to the server specified, possibly * waiting for a reply and filling the answer parameter with the * externally visible address. Note that in this case the * request will be blocking. * * \note The interface may change slightly in the future. * * \retval 0 on success. * \retval <0 on error. * \retval >0 on timeout. */ int ast_stun_request(int s, struct sockaddr_in *dst, const char *username, struct sockaddr_in *answer); /*! \brief callback type to be invoked on stun responses. */ typedef int (stun_cb_f)(struct stun_attr *attr, void *arg); /*! * \brief handle an incoming STUN message. * * \param s Socket to send any response to. * \param src Address where packet came from. * \param data STUN packet buffer to process. * \param len Length of packet * \param stun_cb If not NULL, callback for each STUN attribute. * \param arg Arg to pass to callback. * * \details * Do some basic sanity checks on packet size and content, * try to extract a bit of information, and possibly reply. * At the moment this only processes BIND requests, and returns * the externally visible address of the request. * If a callback is specified, invoke it with the attribute. * * \retval AST_STUN_ACCEPT if responed to a STUN request * \retval AST_STUN_IGNORE * \retval -1 on error */ int ast_stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *data, size_t len, stun_cb_f *stun_cb, void *arg); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_STUN_H */ asterisk-11.7.0/include/asterisk/netsock2.h0000644000175000007640000004421211770230104020514 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2010, Digium, Inc. * * Viagénie * * 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 Network socket handling */ #ifndef _ASTERISK_NETSOCK2_H #define _ASTERISK_NETSOCK2_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include #include /*! * Values for address families that we support. This is reproduced from socket.h * because we do not want users to include that file. Only netsock2.c should * ever include socket.h. */ enum { AST_AF_UNSPEC = 0, AST_AF_INET = 2, AST_AF_INET6 = 10, }; /*! * \brief Socket address structure. * * \details * The first member is big enough to contain addresses of any * family. The second member contains the length (in bytes) used * in the first member. * * \note * Some BSDs have the length embedded in sockaddr structs. We * ignore them. (This is the right thing to do.) * * \note * It is important to always initialize ast_sockaddr before use * -- even if they are passed to ast_sockaddr_copy() as the * underlying storage could be bigger than what ends up being * copied -- leaving part of the data unitialized. */ struct ast_sockaddr { struct sockaddr_storage ss; socklen_t len; }; /*! * \brief * Convert an IPv4-mapped IPv6 address into an IPv4 address. * * \warning You should rarely need this function. Only call this * if you know what you're doing. * * \param addr The IPv4-mapped address to convert * \param mapped_addr The resulting IPv4 address * \retval 0 Unable to make the conversion * \retval 1 Successful conversion */ int ast_sockaddr_ipv4_mapped(const struct ast_sockaddr *addr, struct ast_sockaddr *ast_mapped); /*! * \since 1.8 * * \brief * Checks if the ast_sockaddr is null. "null" in this sense essentially * means uninitialized, or having a 0 length. * * \param addr Pointer to the ast_sockaddr we wish to check * \retval 1 \a addr is null * \retval 0 \a addr is non-null. */ static inline int ast_sockaddr_isnull(const struct ast_sockaddr *addr) { return !addr || addr->len == 0; } /*! * \since 1.8 * * \brief * Sets address \a addr to null. * * \retval void */ static inline void ast_sockaddr_setnull(struct ast_sockaddr *addr) { addr->len = 0; } /*! * \since 1.8 * * \brief * Copies the data from one ast_sockaddr to another * * \param dst The destination ast_sockaddr * \param src The source ast_sockaddr * \retval void */ static inline void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src) { memcpy(dst, src, src->len); dst->len = src->len; }; /*! * \since 1.8 * * \brief * Compares two ast_sockaddr structures * * \retval -1 \a a is lexicographically smaller than \a b * \retval 0 \a a is equal to \a b * \retval 1 \a b is lexicographically smaller than \a a */ int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b); /*! * \since 1.8 * * \brief * Compares the addresses of two ast_sockaddr structures. * * \retval -1 \a a is lexicographically smaller than \a b * \retval 0 \a a is equal to \a b * \retval 1 \a b is lexicographically smaller than \a a */ int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b); #define AST_SOCKADDR_STR_ADDR (1 << 0) #define AST_SOCKADDR_STR_PORT (1 << 1) #define AST_SOCKADDR_STR_BRACKETS (1 << 2) #define AST_SOCKADDR_STR_REMOTE (1 << 3) #define AST_SOCKADDR_STR_HOST (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_BRACKETS) #define AST_SOCKADDR_STR_DEFAULT (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT) #define AST_SOCKADDR_STR_ADDR_REMOTE (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_REMOTE) #define AST_SOCKADDR_STR_HOST_REMOTE (AST_SOCKADDR_STR_HOST | AST_SOCKADDR_STR_REMOTE) #define AST_SOCKADDR_STR_DEFAULT_REMOTE (AST_SOCKADDR_STR_DEFAULT | AST_SOCKADDR_STR_REMOTE) #define AST_SOCKADDR_STR_FORMAT_MASK (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT | AST_SOCKADDR_STR_BRACKETS) /*! * \since 1.8 * * \brief * Convert a socket address to a string. * * \details * This will be of the form a.b.c.d:xyz * for IPv4 and [a:b:c:...:d]:xyz for IPv6. * * This function is thread-safe. The returned string is on static * thread-specific storage. * * \param addr The input to be stringified * \param format one of the following: * AST_SOCKADDR_STR_DEFAULT: * a.b.c.d:xyz for IPv4 * [a:b:c:...:d]:xyz for IPv6. * AST_SOCKADDR_STR_ADDR: address only * a.b.c.d for IPv4 * a:b:c:...:d for IPv6. * AST_SOCKADDR_STR_HOST: address only, suitable for a URL * a.b.c.d for IPv4 * [a:b:c:...:d] for IPv6. * AST_SOCKADDR_STR_PORT: port only * * \note The string pointer returned by this function will point to a string that * will be changed whenever any form of ast_sockaddr_stringify_fmt is called on that * thread. Because of this, it is important that if you use this function, you use the * string before another use of this function is made elsewhere in the same thread. * The easiest way to accomplish this is by immediately copying the string to a buffer * with something like ast_strdupa. * * \retval "(null)" \a addr is null * \retval "" An error occurred during processing * \retval string The stringified form of the address */ char *ast_sockaddr_stringify_fmt(const struct ast_sockaddr *addr, int format); /*! * \since 1.8 * * \brief * Wrapper around ast_sockaddr_stringify_fmt() with default format * * \return same as ast_sockaddr_stringify_fmt() */ static inline char *ast_sockaddr_stringify(const struct ast_sockaddr *addr) { return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_DEFAULT); } /*! * \since 1.8 * * \brief * Wrapper around ast_sockaddr_stringify_fmt() with default format * * \note This address will be suitable for passing to a remote machine via the * application layer. For example, the scope-id on a link-local IPv6 address * will be stripped. * * \return same as ast_sockaddr_stringify_fmt() */ static inline char *ast_sockaddr_stringify_remote(const struct ast_sockaddr *addr) { return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_DEFAULT_REMOTE); } /*! * \since 1.8 * * \brief * Wrapper around ast_sockaddr_stringify_fmt() to return an address only * * \return same as ast_sockaddr_stringify_fmt() */ static inline char *ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr) { return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_ADDR); } /*! * \since 1.8 * * \brief * Wrapper around ast_sockaddr_stringify_fmt() to return an address only * * \note This address will be suitable for passing to a remote machine via the * application layer. For example, the scope-id on a link-local IPv6 address * will be stripped. * * \return same as ast_sockaddr_stringify_fmt() */ static inline char *ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr) { return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_ADDR_REMOTE); } /*! * \since 1.8 * * \brief * Wrapper around ast_sockaddr_stringify_fmt() to return an address only, * suitable for a URL (with brackets for IPv6). * * \return same as ast_sockaddr_stringify_fmt() */ static inline char *ast_sockaddr_stringify_host(const struct ast_sockaddr *addr) { return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_HOST); } /*! * \since 1.8 * * \brief * Wrapper around ast_sockaddr_stringify_fmt() to return an address only, * suitable for a URL (with brackets for IPv6). * * \note This address will be suitable for passing to a remote machine via the * application layer. For example, the scope-id on a link-local IPv6 address * will be stripped. * * \return same as ast_sockaddr_stringify_fmt() */ static inline char *ast_sockaddr_stringify_host_remote(const struct ast_sockaddr *addr) { return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_HOST_REMOTE); } /*! * \since 1.8 * * \brief * Wrapper around ast_sockaddr_stringify_fmt() to return a port only * * \return same as ast_sockaddr_stringify_fmt() */ static inline char *ast_sockaddr_stringify_port(const struct ast_sockaddr *addr) { return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_PORT); } /*! * \since 1.8 * * \brief * Splits a string into its host and port components * * \param str[in] The string to parse. May be modified by writing a NUL at the end of * the host part. * \param host[out] Pointer to the host component within \a str. * \param port[out] Pointer to the port component within \a str. * \param flags If set to zero, a port MAY be present. If set to PARSE_PORT_IGNORE, a * port MAY be present but will be ignored. If set to PARSE_PORT_REQUIRE, * a port MUST be present. If set to PARSE_PORT_FORBID, a port MUST NOT * be present. * * \retval 1 Success * \retval 0 Failure */ int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags); /*! * \since 1.8 * * \brief * Parse an IPv4 or IPv6 address string. * * \details * Parses a string containing an IPv4 or IPv6 address followed by an optional * port (separated by a colon) into a struct ast_sockaddr. The allowed formats * are the following: * * a.b.c.d * a.b.c.d:port * a:b:c:...:d * [a:b:c:...:d] * [a:b:c:...:d]:port * * Host names are NOT allowed. * * \param[out] addr The resulting ast_sockaddr. This MAY be NULL from * functions that are performing validity checks only, e.g. ast_parse_arg(). * \param str The string to parse * \param flags If set to zero, a port MAY be present. If set to * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to * PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a * port MUST NOT be present. * * \retval 1 Success * \retval 0 Failure */ int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags); /*! * \since 1.8 * * \brief * Parses a string with an IPv4 or IPv6 address and place results into an array * * \details * Parses a string containing a host name or an IPv4 or IPv6 address followed * by an optional port (separated by a colon). The result is returned into a * array of struct ast_sockaddr. Allowed formats for str are the following: * * hostname:port * host.example.com:port * a.b.c.d * a.b.c.d:port * a:b:c:...:d * [a:b:c:...:d] * [a:b:c:...:d]:port * * \param[out] addrs The resulting array of ast_sockaddrs * \param str The string to parse * \param flags If set to zero, a port MAY be present. If set to * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to * PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a * port MUST NOT be present. * * \param family Only addresses of the given family will be returned. Use 0 or * AST_AF_UNSPEC to get addresses of all families. * * \retval 0 Failure * \retval non-zero The number of elements in addrs array. */ int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family); /*! * \since 1.8 * * \brief * Get the port number of a socket address. * * \warning Do not use this function unless you really know what you are doing. * And "I want the port number" is not knowing what you are doing. * * \retval 0 Address is null * \retval non-zero The port number of the ast_sockaddr */ #define ast_sockaddr_port(addr) _ast_sockaddr_port(addr, __FILE__, __LINE__, __PRETTY_FUNCTION__) uint16_t _ast_sockaddr_port(const struct ast_sockaddr *addr, const char *file, int line, const char *func); /*! * \since 1.8 * * \brief * Sets the port number of a socket address. * * \warning Do not use this function unless you really know what you are doing. * And "I want the port number" is not knowing what you are doing. * * \param addr Address on which to set the port * \param port The port you wish to set the address to use * \retval void */ #define ast_sockaddr_set_port(addr,port) _ast_sockaddr_set_port(addr,port,__FILE__,__LINE__,__PRETTY_FUNCTION__) void _ast_sockaddr_set_port(struct ast_sockaddr *addr, uint16_t port, const char *file, int line, const char *func); /*! * \since 1.8 * * \brief * Get an IPv4 address of an ast_sockaddr * * \warning You should rarely need this function. Only use if you know what * you're doing. * \return IPv4 address in network byte order */ uint32_t ast_sockaddr_ipv4(const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Determine if the address is an IPv4 address * * \warning You should rarely need this function. Only use if you know what * you're doing. * \retval 1 This is an IPv4 address * \retval 0 This is an IPv6 or IPv4-mapped IPv6 address */ int ast_sockaddr_is_ipv4(const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Determine if this is an IPv4-mapped IPv6 address * * \warning You should rarely need this function. Only use if you know what * you're doing. * * \retval 1 This is an IPv4-mapped IPv6 address. * \retval 0 This is not an IPv4-mapped IPv6 address. */ int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr); /*! * \since 10.0 * * \brief * Determine if an IPv4 address is a multicast address * * \parm addr the address to check * * This function checks if an address is in the 224.0.0.0/4 network block. * * \return non-zero if this is a multicast address */ int ast_sockaddr_is_ipv4_multicast(const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Determine if this is a link-local IPv6 address * * \warning You should rarely need this function. Only use if you know what * you're doing. * * \retval 1 This is a link-local IPv6 address. * \retval 0 This is link-local IPv6 address. */ int ast_sockaddr_is_ipv6_link_local(const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Determine if this is an IPv6 address * * \warning You should rarely need this function. Only use if you know what * you're doing. * * \retval 1 This is an IPv6 or IPv4-mapped IPv6 address. * \retval 0 This is an IPv4 address. */ int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Determine if the address type is unspecified, or "any" address. * * \details * For IPv4, this would be the address 0.0.0.0, and for IPv6, * this would be the address ::. The port number is ignored. * * \retval 1 This is an "any" address * \retval 0 This is not an "any" address */ int ast_sockaddr_is_any(const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Computes a hash value from the address. The port is ignored. * * \retval 0 Unknown address family * \retval other A 32-bit hash derived from the address */ int ast_sockaddr_hash(const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Wrapper around accept(2) that uses struct ast_sockaddr. * * \details * For parameter and return information, see the man page for * accept(2). */ int ast_accept(int sockfd, struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Wrapper around bind(2) that uses struct ast_sockaddr. * * \details * For parameter and return information, see the man page for * bind(2). */ int ast_bind(int sockfd, const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Wrapper around connect(2) that uses struct ast_sockaddr. * * \details * For parameter and return information, see the man page for * connect(2). */ int ast_connect(int sockfd, const struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Wrapper around getsockname(2) that uses struct ast_sockaddr. * * \details * For parameter and return information, see the man page for * getsockname(2). */ int ast_getsockname(int sockfd, struct ast_sockaddr *addr); /*! * \since 1.8 * * \brief * Wrapper around recvfrom(2) that uses struct ast_sockaddr. * * \details * For parameter and return information, see the man page for * recvfrom(2). */ ssize_t ast_recvfrom(int sockfd, void *buf, size_t len, int flags, struct ast_sockaddr *src_addr); /*! * \since 1.8 * * \brief * Wrapper around sendto(2) that uses ast_sockaddr. * * \details * For parameter and * return information, see the man page for sendto(2) */ ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, const struct ast_sockaddr *dest_addr); /*! * \since 1.8 * * \brief * Set type of service * * \details * Set ToS ("Type of Service for IPv4 and "Traffic Class for IPv6) and * CoS (Linux's SO_PRIORITY) * * \param sockfd File descriptor for socket on which to set the parameters * \param tos The type of service for the socket * \param cos The cost of service for the socket * \param desc A text description of the socket in question. * \retval 0 Success * \retval -1 Error, with errno set to an appropriate value */ int ast_set_qos(int sockfd, int tos, int cos, const char *desc); /*! * These are backward compatibility functions that may be used by subsystems * that have not yet been converted to IPv6. They will be removed when all * subsystems are IPv6-ready. */ /*@{*/ /*! * \since 1.8 * * \brief * Converts a struct ast_sockaddr to a struct sockaddr_in. * * \param addr The ast_sockaddr to convert * \param[out] sin The resulting sockaddr_in struct * \retval nonzero Success * \retval zero Failure */ #define ast_sockaddr_to_sin(addr,sin) _ast_sockaddr_to_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__) int _ast_sockaddr_to_sin(const struct ast_sockaddr *addr, struct sockaddr_in *sin, const char *file, int line, const char *func); /*! * \since 1.8 * * \brief * Converts a struct sockaddr_in to a struct ast_sockaddr. * * \param sin The sockaddr_in to convert * \return an ast_sockaddr structure */ #define ast_sockaddr_from_sin(addr,sin) _ast_sockaddr_from_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__) void _ast_sockaddr_from_sin(struct ast_sockaddr *addr, const struct sockaddr_in *sin, const char *file, int line, const char *func); /*@}*/ #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_NETSOCK2_H */ asterisk-11.7.0/include/asterisk/channelstate.h0000644000175000007640000000330011357644124021442 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2010, Digium, Inc. * * 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 Channel states * \par See also: * \arg \ref Def_Channel * \arg \ref channel_drivers */ #ifndef __AST_CHANNELSTATE_H__ #define __AST_CHANNELSTATE_H__ #include "asterisk.h" /*! * \brief ast_channel states * * \note Bits 0-15 of state are reserved for the state (up/down) of the line * Bits 16-32 of state are reserved for flags */ enum ast_channel_state { AST_STATE_DOWN, /*!< Channel is down and available */ AST_STATE_RESERVED, /*!< Channel is down, but reserved */ AST_STATE_OFFHOOK, /*!< Channel is off hook */ AST_STATE_DIALING, /*!< Digits (or equivalent) have been dialed */ AST_STATE_RING, /*!< Line is ringing */ AST_STATE_RINGING, /*!< Remote end is ringing */ AST_STATE_UP, /*!< Line is up */ AST_STATE_BUSY, /*!< Line is busy */ AST_STATE_DIALING_OFFHOOK, /*!< Digits (or equivalent) have been dialed while offhook */ AST_STATE_PRERING, /*!< Channel has detected an incoming call and is waiting for ring */ AST_STATE_MUTE = (1 << 16), /*!< Do not transmit voice data */ }; /*! \brief Change the state of a channel */ int ast_setstate(struct ast_channel *chan, enum ast_channel_state); #endif /* __AST_CHANNELSTATE_H__ */ asterisk-11.7.0/include/asterisk/file.h0000644000175000007640000003102111763214744017713 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 Generic File Format Support. * Should be included by clients of the file handling routines. * File service providers should instead include mod_format.h */ #ifndef _ASTERISK_FILE_H #define _ASTERISK_FILE_H #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_MMAP #include #endif #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif struct ast_filestream; struct ast_format; /*! The maximum number of formats we expect to see in a format string */ #define AST_MAX_FORMATS 10 /*! Convenient for waiting */ #define AST_DIGIT_NONE "" #define AST_DIGIT_ANY "0123456789#*ABCD" #define AST_DIGIT_ANYNUM "0123456789" #define SEEK_FORCECUR 10 /*! The type of event associated with a ast_waitstream_fr_cb invocation */ enum ast_waitstream_fr_cb_values { AST_WAITSTREAM_CB_REWIND = 1, AST_WAITSTREAM_CB_FASTFORWARD, AST_WAITSTREAM_CB_START }; /*! * \brief callback used during dtmf controlled file playback to indicate * location of playback in a file after rewinding or fastfowarding * a file. */ typedef void (ast_waitstream_fr_cb)(struct ast_channel *chan, long ms, enum ast_waitstream_fr_cb_values val); /*! * \brief Streams a file * \param c channel to stream the file to * \param filename the name of the file you wish to stream, minus the extension * \param preflang the preferred language you wish to have the file streamed to you in * Prepares a channel for the streaming of a file. To start the stream, afterward do a ast_waitstream() on the channel * Also, it will stop any existing streams on the channel. * \retval 0 on success. * \retval -1 on failure. */ int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang); /*! * \brief stream file until digit * If the file name is non-empty, try to play it. * \note If digits == "" then we can simply check for non-zero. * \return 0 if success. * \retval -1 if error. * \retval digit if interrupted by a digit. */ int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits); /*! * \brief Stops a stream * * \param c The channel you wish to stop playback on * * Stop playback of a stream * * \retval 0 always * * \note The channel does not need to be locked before calling this function. */ int ast_stopstream(struct ast_channel *c); /*! * \brief Checks for the existence of a given file * \param filename name of the file you wish to check, minus the extension * \param fmt the format you wish to check (the extension) * \param preflang (the preferred language you wisht to find the file in) * See if a given file exists in a given format. If fmt is NULL, any format is accepted. * \retval 0, false. The file does not exist * \retval 1, true. The file does exist. */ int ast_fileexists(const char *filename, const char *fmt, const char *preflang); /*! * \brief Renames a file * \param oldname the name of the file you wish to act upon (minus the extension) * \param newname the name you wish to rename the file to (minus the extension) * \param fmt the format of the file * Rename a given file in a given format, or if fmt is NULL, then do so for all * \return -1 on failure */ int ast_filerename(const char *oldname, const char *newname, const char *fmt); /*! * \brief Deletes a file * \param filename name of the file you wish to delete (minus the extension) * \param fmt of the file * Delete a given file in a given format, or if fmt is NULL, then do so for all */ int ast_filedelete(const char *filename, const char *fmt); /*! * \brief Copies a file * \param oldname name of the file you wish to copy (minus extension) * \param newname name you wish the file to be copied to (minus extension) * \param fmt the format of the file * Copy a given file in a given format, or if fmt is NULL, then do so for all */ int ast_filecopy(const char *oldname, const char *newname, const char *fmt); /*! * \brief Waits for a stream to stop or digit to be pressed * \param c channel to waitstream on * \param breakon string of DTMF digits to break upon * Begins playback of a stream... * Wait for a stream to stop or for any one of a given digit to arrive, * \retval 0 if the stream finishes * \retval the character if it was interrupted, * \retval -1 on error */ int ast_waitstream(struct ast_channel *c, const char *breakon); /*! * \brief Waits for a stream to stop or digit matching a valid one digit exten to be pressed * \param c channel to waitstream on * \param context string of context to match digits to break upon * Begins playback of a stream... * Wait for a stream to stop or for any one of a valid extension digit to arrive, * \retval 0 if the stream finishes. * \retval the character if it was interrupted. * \retval -1 on error. */ int ast_waitstream_exten(struct ast_channel *c, const char *context); /*! * \brief Same as waitstream but allows stream to be forwarded or rewound * \param c channel to waitstream on * \param breakon string of DTMF digits to break upon * \param forward DTMF digit to fast forward upon * \param rewind DTMF digit to rewind upon * \param ms How many miliseconds to skip forward/back * Begins playback of a stream... * Wait for a stream to stop or for any one of a given digit to arrive, * \retval 0 if the stream finishes. * \retval the character if it was interrupted. * \retval -1 on error. */ int ast_waitstream_fr(struct ast_channel *c, const char *breakon, const char *forward, const char *rewind, int ms); /*! * \brief Same as waitstream_fr but allows a callback to be alerted when a user * fastforwards or rewinds the file. * \param c channel to waitstream on * \param breakon string of DTMF digits to break upon * \param forward DTMF digit to fast forward upon * \param rewind DTMF digit to rewind upon * \param ms How many milliseconds to skip forward/back * \param cb to call when rewind or fastfoward occurs. * Begins playback of a stream... * Wait for a stream to stop or for any one of a given digit to arrive, * \retval 0 if the stream finishes. * \retval the character if it was interrupted. * \retval -1 on error. */ int ast_waitstream_fr_w_cb(struct ast_channel *c, const char *breakon, const char *forward, const char *rewind, int ms, ast_waitstream_fr_cb cb); /*! * Same as waitstream, but with audio output to fd and monitored fd checking. * * \return 1 if monfd is ready for reading */ int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd); /*! * \brief Starts reading from a file * \param filename the name of the file to read from * \param type format of file you wish to read from * \param comment comment to go with * \param flags file flags * \param check (unimplemented, hence negligible) * \param mode Open mode * Open an incoming file stream. flags are flags for the open() command, and * if check is non-zero, then it will not read a file if there are any files that * start with that name and have an extension * Please note, this is a blocking function. Program execution will not return until ast_waitstream completes it's execution. * \retval a struct ast_filestream on success. * \retval NULL on failure. */ struct ast_filestream *ast_readfile(const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode); /*! * \brief Starts writing a file * \param filename the name of the file to write to * \param type format of file you wish to write out to * \param comment comment to go with * \param flags output file flags * \param check (unimplemented, hence negligible) * \param mode Open mode * Create an outgoing file stream. oflags are flags for the open() command, and * if check is non-zero, then it will not write a file if there are any files that * start with that name and have an extension * Please note, this is a blocking function. Program execution will not return until ast_waitstream completes it's execution. * \retval a struct ast_filestream on success. * \retval NULL on failure. */ struct ast_filestream *ast_writefile(const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode); /*! * \brief Writes a frame to a stream * \param fs filestream to write to * \param f frame to write to the filestream * Send a frame to a filestream -- note: does NOT free the frame, call ast_frfree manually * \retval 0 on success. * \retval -1 on failure. */ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f); /*! * \brief Closes a stream * \param f filestream to close * Close a playback or recording stream * \retval 0 on success. * \retval -1 on failure. */ int ast_closestream(struct ast_filestream *f); /*! * \brief Opens stream for use in seeking, playing * \param chan channel to work with * \param filename to use * \param preflang prefered language to use * \retval a ast_filestream pointer if it opens the file. * \retval NULL on error. */ struct ast_filestream *ast_openstream(struct ast_channel *chan, const char *filename, const char *preflang); /*! * \brief Opens stream for use in seeking, playing * \param chan channel to work with * \param filename to use * \param preflang prefered language to use * \param asis if set, don't clear generators * \retval a ast_filestream pointer if it opens the file. * \retval NULL on error. */ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char *filename, const char *preflang, int asis); /*! * \brief Opens stream for use in seeking, playing * \param chan channel to work with * \param filename to use * \param preflang prefered language to use * \retval a ast_filestream pointer if it opens the file. * \retval NULL on error. */ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *filename, const char *preflang); /*! * \brief Applys a open stream to a channel. * \param chan channel to work * \param s ast_filestream to apply * \retval 0 on success. * \retval -1 on failure. */ int ast_applystream(struct ast_channel *chan, struct ast_filestream *s); /*! * \brief Play a open stream on a channel. * \param s filestream to play * \retval 0 on success. * \retval -1 on failure. */ int ast_playstream(struct ast_filestream *s); /*! * \brief Seeks into stream * \param fs ast_filestream to perform seek on * \param sample_offset numbers of samples to seek * \param whence SEEK_SET, SEEK_CUR, SEEK_END * \retval 0 on success. * \retval -1 on failure. */ int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence); /*! * \brief Trunc stream at current location * \param fs filestream to act on * \retval 0 on success. * \retval -1 on failure. */ int ast_truncstream(struct ast_filestream *fs); /*! * \brief Fast forward stream ms * \param fs filestream to act on * \param ms milliseconds to move * \retval 0 on success. * \retval -1 on failure. */ int ast_stream_fastforward(struct ast_filestream *fs, off_t ms); /*! * \brief Rewind stream ms * \param fs filestream to act on * \param ms milliseconds to move * \retval 0 on success. * \retval -1 on failure. */ int ast_stream_rewind(struct ast_filestream *fs, off_t ms); /*! * \brief Tell where we are in a stream * \param fs fs to act on * \return a long as a sample offset into stream */ off_t ast_tellstream(struct ast_filestream *fs); /*! * \brief Read a frame from a filestream * \param s ast_filestream to act on * \return a frame. * \retval NULL if read failed. */ struct ast_frame *ast_readframe(struct ast_filestream *s); /*! Initialize file stuff */ /*! * Initializes all the various file stuff. Basically just registers the cli stuff * Returns 0 all the time */ int ast_file_init(void); #define AST_RESERVED_POINTERS 20 /*! Remove duplicate formats from a format string. */ /*! * \param fmts a format string, this string will be modified * \retval NULL error * \return a pointer to the reduced format string, this is a pointer to fmts */ char *ast_format_str_reduce(char *fmts); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_FILE_H */ asterisk-11.7.0/include/asterisk/doxygen/0000755000175000007640000000000012254071123020267 5ustar sharkyjerrywebasterisk-11.7.0/include/asterisk/doxygen/licensing.h0000644000175000007640000001064311167122640022422 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * 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 */ /*! * \page Licensing Asterisk Licensing Information * * \section license Asterisk License * \verbinclude LICENSE * * \section otherlicenses Licensing of 3rd Party Code * * This section contains a (not yet complete) list of libraries that are used * by various parts of Asterisk, including related licensing information. * * \subsection alsa_lib ALSA Library * \arg Library: libasound * \arg Website: http://www.alsa-project.org * \arg Used by: chan_alsa * \arg License: LGPL * * \subsection openssl_lib OpenSSL * \arg Library: libcrypto, libssl * \arg Website: http://www.openssl.org * \arg Used by: Asterisk core (TLS for manager and HTTP), res_crypto * \arg License: Apache 2.0 * \arg Note: An exception has been granted to allow linking of * OpenSSL with Asterisk. * * \subsection curl_lib Curl * \arg Library: libcurl * \arg Website: http://curl.haxx.se * \arg Used by: func_curl, res_config_curl, res_curl * \arg License: BSD * * \subsection portaudio_lib PortAudio * \arg Library: libportaudio * \arg Website: http://www.portaudio.com * \arg Used by: chan_console * \arg License: BSD * \arg Note: Even though PortAudio is licensed under a BSD style * license, PortAudio will make use of some audio interface, * depending on how it was built. That audio interface may * introduce additional licensing restrictions. On Linux, * this would most commonly be ALSA: \ref alsa_lib. * * \subsection rawlist Raw list of libraries that used by any part of Asterisk * \li c-client.a (app_voicemail with IMAP support) * \li libSDL-1.2.so.0 * \li libSaClm.so.2 * \li libSaEvt.so.2 * \li libX11.so.6 * \li libXau.so.6 * \li libXdmcp.so.6 * \li libasound.so.2 * \li libc.so.6 * \li libcom_err.so.2 * \li libcrypt.so.1 * \li libcrypto.so.0.9.8 (chan_h323) * \li libcurl.so.4 * \li libdirect-1.0.so.0 * \li libdirectfb-1.0.so.0 * \li libdl.so.2 * \li libexpat.so (chan_h323) * \li libfusion-1.0.so.0 * \li libgcc_s.so (chan_h323) * \li libgcrypt.so.11 (chan_h323) * \li libglib-2.0.so.0 * \li libgmime-2.0.so.2 * \li libgmodule-2.0.so.0 * \li libgnutls.so.13 (chan_h323) * \li libgobject-2.0.so.0 * \li libgpg-error.so.0 (chan_h323) * \li libgssapi_krb5.so.2 * \li libgthread-2.0.so.0 * \li libidn.so.11 * \li libiksemel.so.3 * \li libisdnnet.so * \li libjack.so.0 * \li libjpeg.so.62 * \li libk5crypto.so.3 * \li libkeyutils.so.1 * \li libkrb5.so.3 * \li libkrb5support.so.0 * \li liblber-2.4.so.2 (chan_h323) * \li libldap_r-2.4.so.2 (chan_h323) * \li libltdl.so.3 * \li liblua5.1.so.0 * \li libm.so.6 * \li libmISDN.so * \li libnbs.so.1 * \li libncurses.so.5 * \li libnetsnmp.so.15 * \li libnetsnmpagent.so.15 * \li libnetsnmphelpers.so.15 * \li libnetsnmpmibs.so.15 * \li libnsl.so.1 * \li libodbc.so.1 * \li libogg.so.0 * \li libopenh323.so (chan_h323) * \li libpcre.so.3 * \li libperl.so.5.8 * \li libportaudio.so.2 * \li libpq.so.5 * \li libpri.so.1.4 * \li libpt.so (chan_h323) * \li libpthread.so.0 * \li libradiusclient-ng.so.2 * \li libresample.so.1.0 * \li libresolv.so.2 (chan_h323) * \li librt.so.1 * \li libsasl2.so.2 (chan_h323) * \li libselinux.so.1 * \li libsensors.so.3 * \li libspandsp.so.1 * \li libspeex.so.1 * \li libsqlite.so.0 * \li libsqlite3.so.0 * \li libss7.so.1 * \li libssl.so.0.9.8 (chan_h323) * \li libstdc++.so (chan_h323, chan_vpb) * \li libsuppserv.so * \li libsybdb.so.5 * \li libsysfs.so.2 * \li libtasn1.so.3 (chan_h323) * \li libtds.so.4 * \li libtiff.so.4 * \li libtonezone.so.1.0 * \li libvorbis.so.0 * \li libvorbisenc.so.2 * \li libvpb.a (chan_vpb) * \li libwrap.so.0 * \li libxcb-xlib.so.0 * \li libxcb.so.1 * \li libz.so.1 (chan_h323) * \li linux-vdso.so.1 */ asterisk-11.7.0/include/asterisk/doxygen/reviewboard.h0000644000175000007640000001103011207603443022747 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * 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 */ /*! * \page Reviewboard Reviewboard Usage and Guidelines * * \AsteriskTrunkWarning * *


* * \section ReviewboardGuidelines Usage Guidelines * * Mantis (https://issues.asterisk.org) and Reviewboard (https://reviewboard.asterisk.org) * are both utilities that the Asterisk development community uses to help * track and review code being written for Asterisk. Since both systems * are used for posting patches, it is worth discussing when it is appropriate * to use reviewboard and when not. * * Here are the situations in which it is appropriate to post code to reviewboard: * - A committer has a patch that they would like to get some feedback on before * merging into one of the main branches. * - A committer or bug marshal has requested a contributor to post their patch * from Mantis on reviewboard to aid in the review process. This typically * happens with complex code contributions where reviewboard can help aid in * providing feedback. * * We do encourage all interested parties to participate in the review process. * However, aside from the cases mentioned above, we prefer that all code * submissions first go through Mantis. * * \note It is acceptable for a committer to post patches to reviewboard before * they are complete to get some feedback on the approach being taken. However, * if the code is not yet ready to be merged, it \b must be documented as such. * A review request with a patch proposed for merging should have documented * testing and should not have blatant coding guidelines violations. Lack of * these things is careless and shows disrespect for those reviewing your code. * *
* * \section ReviewboardPosting Posting Code to Reviewboard * * \subsection postreview Using post-review * * The easiest way to post a patch to reviewboard is by using the * post-review tool. We have post-review in our repotools svn repository. * \verbatim $ svn co http://svn.digium.com/svn/repotools \endverbatim * * Essentially, post-review is a script that will take the output of "svn * diff" and create a review request out of it for you. So, once you have * a working copy with the changes you expect in the output of "svn diff", * you just run the following command: * \verbatim $ post-review \endverbatim * * If it complains about not knowing which reviewboard server to use, add * the server option: * \verbatim $ post-review --server=https://reviewboard.asterisk.org \endverbatim * * \subsection postreviewnewfiles Dealing with New Files * * I have one final note about an oddity with using post-review. If you * maintain your code in a team branch, and the new code includes new * files, there are some additional steps you must take to get post-review * to behave properly. * * You would start by getting your changes applied to a trunk working copy: * \verbatim $ cd .../trunk \endverbatim * * Then, apply the changes from your branch: * \verbatim $ svn merge .../trunk .../team/group/my_new_code \endverbatim * * Now, the code is merged into your working copy. However, for a new * file, subversion treats it as a copy of existing content and not new * content, so new files don't show up in "svn diff" at this point. To get * it to show up in the diff, use the following commands so svn treats it * as new content and publishes it in the diff: * \verbatim $ svn revert my_new_file.c $ svn add my_new_file.c \endverbatim * * Now, it should work, and you can run "post-review" as usual. * * \subsection postreviewupdate Updating Patch on Existing Review Request * * Most of the time, a patch on reviewboard will require multiple iterations * before other sign off on it being ready to be merged. To update the diff * for an existing review request, you can use post-review and the -r option. * Apply the current version of the diff to a working copy as described above, * and then run the following command: * \verbatim $ post-review -r \endverbatim */ asterisk-11.7.0/include/asterisk/doxygen/commits.h0000644000175000007640000000775311324172625022135 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * 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 */ /*! * \page CommitMessages Guidelines for Commit Messages * * \AsteriskTrunkWarning * *
* * \section CommitMsgFormatting Commit Message Formatting * * The following illustrates the basic outline for commit messages: * \verbatim \endverbatim * * Some commit history viewers treat the first line of commit messages as the * summary for the commit. So, an effort should be made to format our commit * messages in that fashion. The verbose description may contain multiple * paragraphs, itemized lists, etc. Always end the first sentence (and any * subsequent sentences) with punctuation. * * Commit messages should be wrapped at 80 %columns. * * \note For trivial commits, such as "fix the build", or "fix spelling mistake", * the verbose description may not be necessary. * *
* * \section CommitMsgTags Special Tags for Commit Messages * * \subsection MantisTags Mantis (https://issues.asterisk.org/) * * To have a commit noted in an issue, use a tag of the form: * \arg (issue #1234) * * To have a commit automatically close an issue, use a tag of the form: * \arg (closes issue #1234) * * When making a commit for a mantis issue, it is easiest to use the * provided commit %message template functionality. It will format the * special tags appropriately, and will also include information about who * reported the issue, which patches are being applied, and who did testing. * * Assuming that you have bug marshal access (and if you have commit access, * it is pretty safe to assume that you do), you will find the commit %message * template section directly below the issue details section and above the * issue relationships section. You will have to click the '+' next to * "Commit message template" to make the contents of the section visible. * * Here is an example of what the template will generate for you: * \verbatim (closes issue #1234) Reported by: SomeGuy Patches: fix_bug_1234.diff uploaded by SomeDeveloper (license 5678) \endverbatim * * If the patch being committed was written by the person doing the commit, * and is not available to reference as an upload to the issue, there is no * need to include something like "fixed by me", as that will be the default * assumption when a specific patch is not referenced. * * \subsection ReviewBoardTags Review Board (https://reviewboard.asterisk.org/) * * To have a commit set a review request as submitted, include the full URL * to the review request. For example: * \arg Review: %https://reviewboard.asterisk.org/r/95/ * * \note The trailing slash in the review URL is required. * *
* * \section CommitMsgSvnmerge Commit Messages with svnmerge * * When using the svnmerge tool for merging changes between branches, use the * commit %message generated by svnmerge. The '-f' option to svnmerge allows * you to specify a file for svnmerge to write out a commit %message to. The * '-F' option to svn commit allows you to specify a file that contains the * commit %message. * * If you are using the expect script wrappers for svnmerge from repotools, * a commit %message is automatically placed in the file '../merge.msg'. * * For more detailed information about working with branches and merging, * see the following page on %asterisk.org: * \arg http://www.asterisk.org/developers/svn-branching-merging */ asterisk-11.7.0/include/asterisk/doxygen/mantisworkflow.h0000644000175000007640000002336611365651310023544 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * 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 */ /*! * \page MantisWorkflow Workflow Guidelines for Asterisk Open Source Issue Tracker * * \AsteriskTrunkWarning * *
* \section WorkflowDescription Description of the Issue Tracker Workflow * * (This document is most beneficial for Asterisk bug marshals, however it is good * reading for anyone who may be filing issues or wondering how the Asterisk Open * Source project moves issues through from filing to completion.) * * The workflow in the issue tracker should be handled in the following way: * * -# A bug is reported and is automatically placed in the 'New' status. * -# The Bug Marshall team should go through bugs in the 'New' status to determine * whether the report is valid (not a duplicate, hasn't already been fixed, not * a Digium tech support issue, etc.). Invalid reports should be set to * 'Closed' with the appropriate resolution set. Categories and descriptions * should be corrected at this point.[Note1]\n * Issues should also have enough information for a developer to either * reproduce the issue or determine where an issue exists (or both). If this is * not the case then the issue should be moved to 'Feedback' prior to moving * forward in the workflow. * -# The next step is to determine whether the report is about a bug or a * submission of a new feature: * -# BUG: A bug should be moved into the status 'Acknowledged' if enough * information has been provided by the reporter to either reproduce the * issue or clearly see where an issue may lie. The bug may also be * assigned to a developer for the creation of the initial patch, or * review of the issue.\n * Once a patch has been created for the issue and attached, the issue can * then be moved to the 'Confirmed' status. At this point, initial code * review and discussion about the patch will take place. Once an adequate * amount of support for the implementation of the patch is acquired, then * the bug can be moved to the 'Ready for Testing' status for wider * testing by the community. After the testing phase is complete and it * appears the issue is resolved, the patch can be committed by a * developer and closed. * -# FEATURE: As new features should be filed with a patch, it can be * immediately moved to the 'confirmed' status, making it ready for basic * formatting and code review. From there any changes to style or feel of * the patch based on feedback from the community can be discussed, and * changes to the patch made. It can then be moved forward to the 'Ready * for Testing' status. Once the feature has been merged, or a decision * has been made that it will not be merged, the issue should be taken to * 'Closed' with the appropriate resolution.[Note2] * -# If at any point in the workflow, an issue requires feedback from the original * poster of the issue, the status should be changed to 'Feedback'. Once the * required information has been provided, it should be placed back in the * appropriate point of the workflow. * -# If at any point in the workflow, a developer or bug marshal would like to * take responsibility for doing the work that is necessary to progress an * issue, the status can be changed to 'Assigned'. At that point the developer * assigned to the issue will be responsible for moving the issue to completion. * * \section WorkflowSummary Workflow Summary * * The following is a list of valid statuses and what they mean to the work flow. * * \subsection New New * This issue is awaiting review by bug marshals. Categorization and summaries * should be fixed as appropriate. * * \subsection Feedback * This issue requires feedback from the poster of the issue before any * additional progress in the workflow can be made. This may include providing * additional debugging information, or a backtrace with DONT_OPTIMIZE enabled, * for example. (See the doc/HOWTO_collect_debug_information.txt file in your * Asterisk source.) * * \subsection Acknowledged * This is a submitted bug which has no patch associated with it, but appears * to be a valid bug based on the description and provided debugging * information. * * \subsection Confirmed * The patch associated with this issue requires initial formatting and code * review, and may have some initial testing done. It is waiting for a * developer to confirm the patch will no longer need large changes made to it, * and is ready for wider testing from the community. This stage is used for * discussing the feel and style of a patch, in addition to the coding style * utilized. * * \subsection Ready For Testing * This is an issue which has a patch that is waiting for testing feedback from * the community after it has been deemed to no longer need larger changes. * * \subsection Assigned * A developer or bug marshal has taken responsibility for taking the necessary * steps to move forward in the workflow. Once the issue is ready to be * reviewed and feedback provided, it should be placed back into the * appropriate place of the workflow. * * \subsection Resolved * A resolution for this issue has been reached. This issue should immediately * be Closed. * * \subsection Closed * No further action is necessary for this issue. * * \section SeverityLevels Severity Levels * * Severity levels generally represent the number of users who are potentially * affected by the reported issue. * * \subsection Feature Feature * This issue is a new feature and will only be committed to Asterisk trunk. * Asterisk trunk is where future branches will be created and thus this * feature will only be found in future branches of Asterisk and not merged * into existing branches. (See Release Branch Commit Policy below.) * * \subsection Trivial Trivial * A trivial issue is something that either affects an insignificant number of * Asterisk users, or is a minimally invasive change that does not affect * functionality. * * \subsection Text Text * A text issue is typically something like a spelling fix, a clarifying of a * debugging or verbose message, or changes to documentation. * * \subsection Tweak Tweak * A tweak to the code the has the potential to either make code clearer to * read, or a change that could speed up processing in certain circumstances. * These changes are typically only a couple of lines. * * \subsection Minor Minor * An issue that does not affect a large number of Asterisk users, but not an * insignificant number. The number of lines of code and development effort to * resolve this issue could be non-trivial. * * \subsection Major Major * As issue that affects the majority of Asterisk users. The number of lines of * code and development effort required to resolve this issue could be * non-trivial. * * \subsection Crash Crash * An issue marked as a Crash is something that would cause Asterisk to be * unusable for a majority of Asterisk users and is an issue that causes a * deadlock or crash of the Asterisk process. * * \subsection Block Block * A blocking issue is an issue that must be resolved before the next release * of Asterisk as would affect a significant number of Asterisk users, or could * be a highly visible regression. A severity of block should only be set by * Asterisk bug marshals at their discretion. * * *** USERS SHOULD NOT FILE ISSUES WITH A SEVERITY OF BLOCK *** * * \section PriorityLevels Priority Levels * * Currently, the following priority levels are listed on the issue tracker: * - None * - Low * - Normal * - High * - Urgent * - Immediate * * However, at this time they are not utilized and all new issue should have a priority of 'Normal'. * * \section Notes Notes * * -# Using the "Need Triage" filter is useful for finding these issues quickly. * -# The issue tracker now has the ability to monitor the commits list, and if * the commit message contains something like, "(Closes issue #9999)", the bug * will be automatically closed.\n * See http://www.asterisk.org/doxygen/trunk/CommitMessages.html for more * information on commit messages. * * \section ReleaseBranchCommitPolicy Release Branch Commit Policy * * The code in the release branches should be changed as little as possible. The * only time the release branches will be changed is to fix a bug. New features * will never be included in the release branch unless a special exception is made * by the release branch maintainers. * * Sometimes it is difficult to determine whether a patch is considered to fix a * bug or if it is a new feature. Patches that are considered code cleanup, or to * improve performance, are NOT to be included in the release branches. Performance * issues will only be considered for the release branch if they are considered * significant, and should be approved by the maintainers. * * If there is ever a question about what should be included in the release branch, * the maintainers should be allowed to make the decision. */ asterisk-11.7.0/include/asterisk/doxygen/asterisk-git-howto.h0000644000175000007640000001671711270147214024222 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * 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 */ /*! * \page AsteriskGitHowto How to setup a local GIT mirror of the Asterisk SVN repository * * \AsteriskTrunkWarning * *
* * \section Introduction Introduction * This document will instruct you how to setup a local git mirror of the * Asterisk SVN repository. * * Why would you want that? for starters, it's a fast repository browser * and works well even when offline. More on why and why not at 'Pros and Cons' * in the end of this document. *
* * \section Setup Setup * * Make sure you have the package * \verbatim git-svn \endverbatim * * installed. It is part of the standard git distribution and included in * any recent Linux distribution. * * Next, get the files from this repository: * \verbatim git clone http://git.tzafrir.org.il/git/asterisk-tools.git \endverbatim * * Which will create the subdirectory 'asterisk-tools' under your working * directory. For the purpose of this HOWTO I assume that you will later * download Asterisk under the same directory. * * Now let's get Asterisk: * \verbatim git svn clone -s http://svn.digium.com/svn/asterisk \endverbatim * * This will download the whole /trunk , /tags and /branches hirarchies * to a new git repository under asterisk/ . * This will take a L O N G time. In the order of magnitude of a * day. If it stops in the middle: * \verbatim # cd asterisk; git svn fetch --fetch-all \endverbatim * * All commands as of this point are run from the newly-created subdirectory * 'asterisk' * \verbatim cd asterisk \endverbatim * * Next make your repository more compact: * * \note FIXME: I now get a .git subdirectory of the size of 135MB. This seems * overly large considering what I got a few monthes ago. * \verbatim git repack -a \endverbatim * * Now fix the menuselect bits. One possible venue is to use submodules. * This would require setting a separate menuselect repository . And * fixing the submodule references in every new tag to point to the right * place. I gave up at this stage, and instead reimplememented menuselect * \verbatim cp -a ../asterisk-tools/menuselect menuselect make -C menuselect dummies chmod +x menuselect/menuselect \endverbatim * * Next thing to do is ignore generated files. .gitignore is somewhat * like svn:ignore . Though it is possible to use one at the top * directory. Hence I decided to make it ignore itself as well: * \verbatim cp ../asterisk-tools/asterisk_gitignore .gitignore \endverbatim * * Now let's generate tags that will point to the tags/* branches. * e.g. tag 'v1.4.8' will point to the head of branch tags/1.4.8 . * If you don't like the extra 'v', just edit the sed command. * \verbatim ../asterisk-tools/update-tags \endverbatim * * Example configuration (refer to menuselect/menuselelct for more * information). For instance: res_snmp breaks building 1.4 from git: * \verbatim echo 'exclude res_snmp' >build_tools/conf \endverbatim * *
* * \section Update Update * The main Asterisk repository tends to get new commits occasionally. I * suppose you want those updates in your local copy. The following command * should normally be done from the master branch. If you actually use branches, * it is recommended to switch to it beforehand: * \verbatim git checkout master \endverbatim * * Next, get all updates. *
* * \section Usage Usage * * If you use git from the command-line, it is highly recommended to enable * programmable bash completion. The git command-line is way more complex * than svn, but the completion makes it usable: * * \verbatim asterisk$ git show v1.2.28 v1.2.28 v1.2.28.1 asterisk$ git show v1.2.28:c callerid.c channel.c cli.c coef_out.h contrib/ cdr/ channels/ codecs/ config.c cryptostub.c cdr.c chanvars.c coef_in.h configs/ cygwin/ asterisk$ git svn clone fetch log set-tree commit-diff find-rev propget show-externals create-ignore info proplist show-ignore dcommit init rebase asterisk$ git svn rebase --f --fetch-all --follow-parent \endverbatim * * Some useful commands: * \verbatim git svn rebase --fetch-all # pull updates from upstream man git-FOO # documentation for 'git FOO' # is any place on graph of branches: HEAD, name of a branch or # a tag, commit ID, and some others git show # The top commit in this tree (log + diff) git show :directory # directory listing git show :some/file # get that file git log # commit log up to that point git branch # shows local branches and in which one you are git branch -r # List remote branches. Such are SVN ones. \endverbatim * * For more information, see the man page gittutorial as well as * \arg http://git-scm.com/documentation * \verbatim git svn rebase --fetch-all \endverbatim * *
* * \section ProsAndCons Pros and Cons * * \subsection TheGood The Good * * Working off-line: * If you want to be able to use 'svn log' and 'svn diff' to a different * branch, now you can. * * Efficient repository browser: * With git you can effectively browse commit logs and working copies of * various branches. In fact, using it merely as a logs and versions * browser can be useful on its own. * * Branches really work: * With SVN merging a branch is complicated. Partially because lack of * separate merge tracking.With git you don't need the extra svnmerge: * changes that don't collide with your branch merge in a quick merge * operation. * * \subsection Limitations Limitations * * svn:externals : * does not really work well with git-svn (and similar systems: svk, * bzr-svn and hg-svn). Git has something called submodules that allows * emulating the basic functionality of svn:externals, but is not as * transparent. * * Commiting: * Not sure how safe it is to commit from such a copy. In most places I * see that it is not recommended to commit directly from git-svn. OTOH, * git has some tools that make it easy to prepare a patch set out of a * branch (e.g. git format-patch). * * IIRC there are also some issues for git-svn with https certificate * authentication in the first place. * * Tags: * /tags are branches. SVN tags are really branches that we pretend not * to change. And in fact in Asterisk we practically do change. But see * workaround below to generate tags from the tag branches. * * /team branches:: * At least with git 1.5.x you can't easily follow all the team branches. * This is due to a bug in their handling of wildcards in branches * description. I believe this has been resolved in 1.6 but I didn't get * to test that. Even if it will, it will require an extra step of manual * editing. * *
*/ asterisk-11.7.0/include/asterisk/doxygen/architecture.h0000644000175000007640000010476212023442006023130 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, Digium, Inc. * * Russell Bryant * * 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 * \author Russell Bryant */ /*! \page AsteriskArchitecture Asterisk Architecture Overview \author Russell Bryant \AsteriskTrunkWarning
\section ArchTOC Table of Contents -# \ref ArchIntro -# \ref ArchLayout -# \ref ArchInterfaces -# \ref ArchInterfaceCodec -# \ref ArchInterfaceFormat -# \ref ArchInterfaceAPIs -# \ref ArchInterfaceAMI -# \ref ArchInterfaceChannelDrivers -# \ref ArchInterfaceBridge -# \ref ArchInterfaceCDR -# \ref ArchInterfaceCEL -# \ref ArchInterfaceDialplanApps -# \ref ArchInterfaceDialplanFuncs -# \ref ArchInterfaceRTP -# \ref ArchInterfaceTiming -# \ref ArchThreadingModel -# \ref ArchChannelThreads -# \ref ArchMonitorThreads -# \ref ArchServiceThreads -# \ref ArchOtherThreads -# \ref ArchConcepts -# \ref ArchConceptBridging -# \ref ArchCodeFlows -# \ref ArchCodeFlowPlayback -# \ref ArchCodeFlowBridge -# \ref ArchDataStructures -# \ref ArchAstobj2 -# \ref ArchLinkedLists -# \ref ArchDLinkedLists -# \ref ArchHeap -# \ref ArchDebugging -# \ref ArchThreadDebugging -# \ref ArchMemoryDebugging
\section ArchIntro Introduction This section of the documentation includes an overview of the Asterisk architecture from a developer's point of view. For detailed API discussion, see the documentation associated with public API header files. This documentation assumes some knowledge of what Asterisk is and how to use it. The intent behind this documentation is to start looking at Asterisk from a high level and progressively dig deeper into the details. It begins with talking about the different types of components that make up Asterisk and eventually will go through interactions between these components in different use cases. Throughout this documentation, many links are also provided as references to more detailed information on related APIs, as well as the related source code to what is being discussed. Feedback and contributions to this documentation are very welcome. Please send your comments to the asterisk-dev mailing list on http://lists.digium.com/. Thank you, and enjoy Asterisk! \section ArchLayout Modular Architecture Asterisk is a highly modularized application. There is a core application that is built from the source in the main/ directory. However, it is not very useful by itself. There are many modules that are loaded at runtime. Asterisk modules have names that give an indication as to what functionality they provide, but the name is not special in any technical sense. When Asterisk loads a module, the module registers the functionality that it provides with the Asterisk core. -# Asterisk starts -# Asterisk loads modules -# Modules say "Hey Asterisk! I am a module. I can provide functionality X, Y, and Z. Let me know when you'd like to use my functionality!" \section ArchInterfaces Abstract Interface types There are many types of interfaces that modules can implement and register their implementations of with the Asterisk core. Any module is allowed to register as many of these different interfaces as they would like. Generally, related functionality is grouped into a single module. In this section, the types of interfaces are discussed. Later, there will be discussions about how different components interact in various scenarios. \subsection ArchInterfaceCodec Codec Interpreter An implementation of the codec interpreter interface provides the ability to convert between two codecs. Asterisk currently only has the ability to translate between audio codecs. These modules have no knowledge about phone calls or anything else about why they are being asked to convert audio. They just get audio samples as input in their specified input format, and are expected to provide audio in the specified output format. It is possible to have multiple paths to get from codec A to codec B once many codec implementations are registered. After modules have been loaded, Asterisk builds a translation table with measurements of the performance of each codec translator so that it can always find the best path to get from A to B. Codec modules typically live in the codecs/ directory in the source tree. For a list of codec interpreter implementations, see \ref codecs. For additional information on the codec interpreter API, see the interface definition in include/asterisk/translate.h. For core implementation details related to the codec interpreter API, see main/translate.c. \subsection ArchInterfaceFormat File Format Handler An implementation of the file format handler interface provides Asterisk the ability to read and optionally write files. File format handlers may provide access to audio, video, or image files. The interface for a file format handler is rather primitive. A module simply tells the Asterisk core that it can handle files with a given %extension, for example, ".wav". It also says that after reading the file, it will provide audio in the form of codec X. If a file format handler provides the ability to write out files, it also must specify what codec the audio should be in before provided to the file format handler. File format modules typically live in the formats/ directory in the source tree. For a list of file format handler implementations, see \ref formats. For additional information on the file format handler API, see the interface definition in include/asterisk/file.h. For core implementation details related to the file format API, see main/file.c. \subsection ArchInterfaceAPIs C API Providers There are some C APIs in Asterisk that are optional. Core APIs are built into the main application and are always available. Optional C APIs are provided by a module and are only available for use when the module is loaded. Some of these API providers also contain their own interfaces that other modules can implement and register. Modules that provide a C API typically live in the res/ directory in the source tree. Some examples of modules that provide C APIs (potentially among other things) are: - res_musiconhold.c - res_calendar.c - provides a calendar technology interface. - res_odbc.c - res_ael_share.c - res_crypto.c - res_curl.c - res_xmpp.c - res_monitor.c - res_smdi.c - res_speech.c - provides a speech recognition engine interface. \subsection ArchInterfaceAMI Manager Interface (AMI) Actions The Asterisk manager interface is a socket interface for monitoring and control of Asterisk. It is a core feature built in to the main application. However, modules can register %actions that may be requested by clients. Modules that register manager %actions typically do so as auxiliary functionality to complement whatever main functionality it provides. For example, a module that provides call conferencing services may have a manager action that will return the list of participants in a conference. \subsection ArchInterfaceCLI CLI Commands The Asterisk CLI is a feature implemented in the main application. Modules may register additional CLI commands. \subsection ArchInterfaceChannelDrivers Channel Drivers The Asterisk channel driver interface is the most complex and most important interface available. The Asterisk channel API provides the telephony protocol abstraction which allows all other Asterisk features to work independently of the telephony protocol in use. The specific interface that channel drivers implement is the ast_channel_tech interface. A channel driver must implement functions that perform various call signaling tasks. For example, they must implement a method for initiating a call and hanging up a call. The ast_channel data structure is the abstract channel data structure. Each ast_channel instance has an associated ast_channel_tech which identifies the channel type. An ast_channel instance represents one leg of a call (a connection between Asterisk and an endpoint). Channel drivers typically live in the channels/ directory in the source tree. For a list of channel driver implementations, see \ref channel_drivers. For additional information on the channel API, see include/asterisk/channel.h. For additional implementation details regarding the core ast_channel API, see main/channel.c. \subsection ArchInterfaceBridge Bridging Technologies Bridging is the operation which connects two or more channels together. A simple two channel bridge is a normal A to B phone call, while a multi-party bridge would be something like a 3-way call or a full conference call. The bridging API allows modules to register bridging technologies. An implementation of a bridging technology knows how to take two (or optionally more) channels and connect them together. Exactly how this happens is up to the implementation. This interface is used such that the code that needs to pass audio between channels doesn't need to know how it is done. Underneath, the conferencing may be done in the kernel (via DAHDI), via software methods inside of Asterisk, or could be done in hardware in the future if someone implemented a module to do so. At the time of this writing, the bridging API is still relatively new, so it is not used everywhere that bridging operations are performed. The ConfBridge dialplan application is a new conferencing application which has been implemented on top of this bridging API. Bridging technology modules typically live in the bridges/ directory in the source tree. For a list of bridge technology implementations, see \ref bridges. For additional information on the bridging API, see include/asterisk/bridging.h and include/asterisk/bridging_technology.h. For additional implementation details regarding the core bridging API, see main/bridging.c. \subsection ArchInterfaceCDR Call Detail Record (CDR) Handlers The Asterisk core implements functionality for keeping records of calls. These records are built while calls are processed and live in data structures. At the end of the call, these data structures are released. Before the records are thrown away, they are passed in to all of the registered CDR handlers. These handlers may write out the records to a file, post them to a database, etc. CDR modules typically live in the cdr directory in the source tree. For a list of CDR handlers, see \ref cdr_drivers. For additional information on the CDR API, see include/asterisk/cdr.h. For additional implementation details regarding CDR handling, see main/cdr.c. \subsection ArchInterfaceCEL Call Event Logging (CEL) Handlers The Asterisk core includes a generic event system that allows Asterisk components to report events that can be subscribed to by other parts of the system. One of the things built on this event system is Call Event Logging (CEL). CEL is similar to CDR in that they are both for tracking call history. While CDR records are typically have a one record to one call relationship, CEL events are many events to one call. The CEL modules look very similar to CDR modules. CEL modules typically live in the cel/ directory in the source tree. For a list of CEL handlers, see \ref cel_drivers. For additional information about the CEL API, see include/asterisk/cel.h. For additional implementation details for the CEL API, see main/cel.c. \subsection ArchInterfaceDialplanApps Dialplan Applications Dialplan applications implement features that interact with calls that can be executed from the Asterisk dialplan. For example, in extensions.conf: exten => 123,1,NoOp() In this case, NoOp is the application. Of course, NoOp doesn't actually do anything. These applications use a %number of APIs available in Asterisk to interact with the channel. One of the most important tasks of an application is to continuously read audio from the channel, and also write audio back to the channel. The details of how this is done is usually hidden behind an API call used to play a file or wait for digits to be pressed by a caller. In addition to interacting with the channel that originally executed the application, dialplan applications sometimes also create additional outbound channels. For example, the Dial() application creates an outbound channel and bridges it to the inbound channel. Further discussion about the functionality of applications will be discussed in detailed use cases. Dialplan applications are typically found in the apps/ directory in the source tree. For a list of dialplan applications, see \ref applications. For details on the API used to register an application with the Asterisk core, see include/asterisk/pbx.h. \subsection ArchInterfaceDialplanFuncs Dialplan Functions As the name suggests, dialplan functions, like dialplan applications, are primarily used from the Asterisk dialplan. Functions are used mostly in the same way that variables are used in the dialplan. They provide a read and/or write interface, with optional arguments. While they behave similarly to variables, they storage and retrieval of a value is more complex than a simple variable with a text value. For example, the CHANNEL() dialplan function allows you to access data on the current channel. exten => 123,1,NoOp(This channel has the name: ${CHANNEL(name)}) Dialplan functions are typically found in the funcs/ directory in the source tree. For a list of dialplan function implementations, see \ref functions. For details on the API used to register a dialplan function with the Asterisk core, see include/asterisk/pbx.h. \subsection ArchInterfaceRTP RTP Engines The Asterisk core provides an API for handling RTP streams. However, the actual handling of these streams is done by modules that implement the RTP engine interface. Implementations of an RTP engine typically live in the res/ directory of the source tree, and have a res_rtp_ prefix in their name. \subsection ArchInterfaceTiming Timing Interfaces The Asterisk core implements an API that can be used by components that need access to timing services. For example, a timer is used to send parts of an audio file at proper intervals when playing back a %sound file to a caller. The API relies on timing interface implementations to provide a source for reliable timing. Timing interface implementations are typically found in the res/ subdirectory of the source tree. For a list of timing interface implementations, see \ref timing_interfaces. For additional information on the timing API, see include/asterisk/timing.h. For additional implementation details for the timing API, see main/timing.c. \section ArchThreadingModel Asterisk Threading Model Asterisk is a very heavily multi threaded application. It uses the POSIX threads API to manage threads and related services such as locking. Almost all of the Asterisk code that interacts with pthreads does so by going through a set of wrappers used for debugging and code reduction. Threads in Asterisk can be classified as one of the following types: - Channel threads (sometimes referred to as PBX threads) - Network Monitor threads - Service connection threads - Other threads \subsection ArchChannelThreads Channel Threads A channel is a fundamental concept in Asterisk. Channels are either inbound or outbound. An inbound channel is created when a call comes in to the Asterisk system. These channels are the ones that execute the Asterisk dialplan. A thread is created for every channel that executes the dialplan. These threads are referred to as a channel thread. They are sometimes also referred to as a PBX thread, since one of the primary tasks of the thread is to execute the Asterisk dialplan for an inbound call. A channel thread starts out by only being responsible for a single Asterisk channel. However, there are cases where a second channel may also live in a channel thread. When an inbound channel executes an application such as Dial(), an outbound channel is created and bridged to the inbound channel once it answers. Dialplan applications always execute in the context of a channel thread. Dialplan functions \i almost always do, as well. However, it is possible to read and write dialplan functions from an asynchronous interface such as the Asterisk CLI or the manager interface (AMI). However, it is still always the channel thread that is the owner of the ast_channel data structure. \subsection ArchMonitorThreads Network Monitor Threads Network monitor threads exist in almost every major channel driver in Asterisk. They are responsible for monitoring whatever network they are connected to (whether that is an IP network, the PSTN, etc.) and monitor for incoming calls or other types of incoming %requests. They handle the initial connection setup steps such as authentication and dialed %number validation. Finally, once the call setup has been completed, the monitor threads will create an instance of an Asterisk channel (ast_channel), and start a channel thread to handle the call for the rest of its lifetime. \subsection ArchServiceThreads Service Connection Threads There are a %number of TCP based services that use threads, as well. Some examples include SIP and the AMI. In these cases, threads are used to handle each TCP connection. The Asterisk CLI also operates in a similar manner. However, instead of TCP, the Asterisk CLI operates using connections to a UNIX %domain socket. \subsection ArchOtherThreads Other Threads There are other miscellaneous threads throughout the system that perform a specific task. For example, the event API (include/asterisk/event.h) uses a thread internally (main/event.c) to handle asychronous event dispatching. The devicestate API (include/asterisk/devicestate.h) uses a thread internally (main/devicestate.c) to asynchronously process device state changes. \section ArchConcepts Other Architecture Concepts This section covers some other important Asterisk architecture concepts. \subsection ArchConceptBridging Channel Bridging As previously mentioned when discussing the bridging technology interface (\ref ArchInterfaceBridge), bridging is the act of connecting one or more channel together so that they may pass audio between each other. However, it was also mentioned that most of the code in Asterisk that does bridging today does not use this new bridging infrastructure. So, this section discusses the legacy bridging functionality that is used by the Dial() and Queue() applications. When one of these applications decides it would like to bridge two channels together, it does so by executing the ast_channel_bridge() API call. From there, there are two types of bridges that may occur. -# Generic Bridge: A generic bridge (ast_generic_bridge()) is a bridging method that works regardless of what channel technologies are in use. It passes all audio and signaling through the Asterisk abstract channel and frame interfaces so that they can be communicated between channel drivers of any type. While this is the most flexible, it is also the least efficient bridging method due to the levels of abstraction necessary. -# Native Bridge: Channel drivers have the option of implementing their own bridging functionality. Specifically, this means to implement the bridge callback in the ast_channel_tech structure. If two channels of the same type are bridged, a native bridge method is available, and Asterisk does not have a reason to force the call to stay in the core of Asterisk, then the native bridge function will be invoked. This allows channel drivers to take advantage of the fact that the channels are the same type to optimize bridge processing. In the case of a DAHDI channel, this may mean that the channels are bridged natively on hardware. In the case of SIP, this means that Asterisk can direct the audio to flow between the endpoints and only require the signaling to continue to flow through Asterisk. \section ArchCodeFlows Code Flow Examples Now that there has been discussion about the various components that make up Asterisk, this section goes through examples to demonstrate how these components work together to provide useful functionality. \subsection ArchCodeFlowPlayback SIP Call to File Playback This example consists of a call that comes in to Asterisk via the SIP protocol. Asterisk accepts this call, plays back a %sound file to the caller, and then hangs up. Example dialplan: exten => 5551212,1,Answer()
exten => 5551212,n,Playback(demo-congrats)
exten => 5551212,n,Hangup()
-# Call Setup: An incoming SIP INVITE begins this scenario. It is received by the SIP channel driver (chan_sip.c). Specifically, the monitor thread in chan_sip is responsible for handling this incoming request. Further, the monitor thread is responsible for completing any handshake necessary to complete the call setup process. -# Accept Call: Once the SIP channel driver has completed the call setup process, it accepts the call and initiates the call handling process in Asterisk. To do so, it must allocate an instance of an abstract channel (ast_channel) using the ast_channel_alloc() API call. This instance of an ast_channel will be referred to as a SIP channel. The SIP channel driver will take care of SIP specific channel initialization. Once the channel has been created and initialized, a channel thread is created to handle the call (ast_pbx_start()). -# Run the Dialplan:: The main loop that runs in the channel thread is the code responsible for looking for the proper extension and then executing it. This loop lives in ast_pbx_run() in main/pbx.c. -# Answer the Call:: Once the dialplan is being executed, the first application that is executed is Answer(). This application is a built in application that is defined in main/pbx.c. The Answer() application code simply executes the ast_answer() API call. This API call operates on an ast_channel. It handles generic ast_channel hangup processing, as well as executes the answer callback function defined in the associated ast_channel_tech for the active channel. In this case, the sip_answer() function in chan_sip.c will get executed to handle the SIP specific operations required to answer a call. -# Play the File: The next step of the dialplan says to play back a %sound file to the caller. The Playback() application will be executed. The code for this application is in apps/app_playback.c. The code in the application is pretty simple. It does argument handling and uses API calls to play back the file, ast_streamfile(), ast_waitstream(), and ast_stopstream(), which set up file playback, wait for the file to finish playing, and then free up resources. Some of the important operations of these API calls are described in steps here: -# Open a File: The file format API is responsible for opening the %sound file. It will start by looking for a file that is encoded in the same format that the channel is expecting to receive audio in. If that is not possible, it will find another type of file that can be translated into the codec that the channel is expecting. Once a file is found, the appropriate file format interface is invoked to handle reading the file and turning it into internal Asterisk audio frames. -# Set up Translation: If the encoding of the audio data in the file does not match what the channel is expecting, the file API will use the codec translation API to set up a translation path. The translate API will invoke the appropriate codec translation interface(s) to get from the source to the destination format in the most efficient way available. -# Feed Audio to the Caller: The file API will invoke the timer API to know how to send out audio frames from the file in proper intervals. At the same time, Asterisk must also continuously service the incoming audio from the channel since it will continue to arrive in real time. However, in this scenario, it will just get thrown away. -# Hang up the Call: Once the Playback() application has finished, the dialplan execution loop continues to the next step in the dialplan, which is Hangup(). This operates in a very similar manner to Answer() in that it handles channel type agnostic hangup handling, and then calls down into the SIP channel interface to handle SIP specific hangup processing. At this point, even if there were more steps in the dialplan, processing would stop since the channel has been hung up. The channel thread will exit the dialplan processing loop and destroy the ast_channel data structure. \subsection ArchCodeFlowBridge SIP to IAX2 Bridged Call This example consists of a call that comes in to Asterisk via the SIP protocol. Asterisk then makes an outbound call via the IAX2 protocol. When the far end over IAX2 answers, the call is bridged. Example dialplan: exten => 5551212,n,Dial(IAX2/mypeer)
-# Call Setup: An incoming SIP INVITE begins this scenario. It is received by the SIP channel driver (chan_sip.c). Specifically, the monitor thread in chan_sip is responsible for handling this incoming request. Further, the monitor thread is responsible for completing any handshake necessary to complete the call setup process. -# Accept Call: Once the SIP channel driver has completed the call setup process, it accepts the call and initiates the call handling process in Asterisk. To do so, it must allocate an instance of an abstract channel (ast_channel) using the ast_channel_alloc() API call. This instance of an ast_channel will be referred to as a SIP channel. The SIP channel driver will take care of SIP specific channel initialization. Once the channel has been created and initialized, a channel thread is created to handle the call (ast_pbx_start()). -# Run the Dialplan:: The main loop that runs in the channel thread is the code responsible for looking for the proper extension and then executing it. This loop lives in ast_pbx_run() in main/pbx.c. -# Execute Dial(): The only step in this dialplan is to execute the Dial() application. -# Create an Outbound Channel: The Dial() application needs to create an outbound ast_channel. It does this by first using the ast_request() API call to request a channel called IAX2/mypeer. This API call is a part of the core channel API (include/asterisk/channel.h). It will find a channel driver of type IAX2 and then execute the request callback in the appropriate ast_channel_tech interface. In this case, it is iax2_request() in channels/chan_iax2.c. This asks the IAX2 channel driver to allocate an ast_channel of type IAX2 and initialize it. The Dial() application will then execute the ast_call() API call for this new ast_channel. This will call into the call callback of the ast_channel_tech, iax2_call(), which requests that the IAX2 channel driver initiate the outbound call. -# Wait for Answer: At this point, the Dial() application waits for the outbound channel to answer the call. While it does this, it must continue to service the incoming audio on both the inbound and outbound channels. The loop that does this is very similar to every other channel servicing loop in Asterisk. The core features of a channel servicing loop include ast_waitfor() to wait for frames on a channel, and then ast_read() on a channel once frames are available. -# Handle Answer: Once the far end answers the call, the Dial() application will communicate this back to the inbound SIP channel. It does this by calling the ast_answer() core channel API call. -# Make Channels Compatible: Before the two ends of the call can be connected, Asterisk must make them compatible to talk to each other. Specifically, the two channels may be sending and expecting to receive audio in a different format than the other channel. The API call ast_channel_make_compatible() sets up translation paths for each channel by instantiating codec translators as necessary. -# Bridge the Channels: Now that both the inbound and outbound channels are fully established, they can be connected together. This connection between the two channels so that they can pass audio and signaling back and forth is referred to as a bridge. The API call that handles the bridge is ast_channel_bridge(). In this case, the main loop of the bridge is a generic bridge, ast_generic_bridge(), which is the type of bridge that works regardless of the two channel types. A generic bridge will almost always be used if the two channels are not of the same type. The core functionality of a bridge loop is ast_waitfor() on both channels. Then, when frames arrive on a channel, they are read using ast_read(). After reading a frame, they are written to the other channel using ast_write(). -# Breaking the Bridge: This bridge will continue until some event occurs that causes the bridge to be broken, and control to be returned back down to the Dial() application. For example, if one side of the call hangs up, the bridge will stop. -# Hanging Up:: After the bridge stops, control will return to the Dial() application. The application owns the outbound channel since that is where it was created. So, the outbound IAX2 channel will be destroyed before Dial() is complete. Destroying the channel is done by using the ast_hangup() API call. The application will return back to the dialplan processing loop. From there, the loop will see that there is nothing else to execute, so it will hangup on the inbound channel as well using the ast_hangup() function. ast_hangup() performs a number of channel type independent hangup tasks, but also executes the hangup callback of ast_channel_tech (sip_hangup()). Finally, the channel thread exits. \section ArchDataStructures Asterisk Data Structures Asterisk provides generic implementations of a number of data structures. \subsection ArchAstobj2 Astobj2 Astobj2 stands for the Asterisk Object model, version 2. The API is defined in include/asterisk/astobj2.h. Some internal implementation details for astobj2 can be found in main/astobj2.c. There is a version 1, and it still exists in the source tree. However, it is considered deprecated. Astobj2 provides reference counted object handling. It also provides a container interface for astobj2 objects. The container provided is a hash table. See the astobj2 API for more details about how to use it. Examples can be found all over the code base. \subsection ArchLinkedLists Linked Lists Asterisk provides a set of macros for handling linked lists. They are defined in include/asterisk/linkedlists.h. \subsection ArchDLinkedLists Doubly Linked Lists Asterisk provides a set of macros for handling doubly linked lists, as well. They are defined in include/asterisk/dlinkedlists.h. \subsection ArchHeap Heap Asterisk provides an implementation of the max heap data structure. The API is defined in include/asterisk/heap.h. The internal implementation details can be found in main/heap.c. \section ArchDebugging Asterisk Debugging Tools Asterisk includes a %number of built in debugging tools to help in diagnosing common types of problems. \subsection ArchThreadDebugging Thread Debugging Asterisk keeps track of a list of all active threads on the system. A list of threads can be viewed from the Asterisk CLI by running the command core show threads. Asterisk has a compile time option called DEBUG_THREADS. When this is on, the pthread wrapper API in Asterisk keeps track of additional information related to threads and locks to aid in debugging. In addition to just keeping a list of threads, Asterisk also maintains information about every lock that is currently held by any thread on the system. It also knows when a thread is blocking while attempting to acquire a lock. All of this information is extremely useful when debugging a deadlock. This data can be acquired from the Asterisk CLI by running the core show locks CLI command. The definitions of these wrappers can be found in include/asterisk/lock.h and include/asterisk/utils.h. Most of the implementation details can be found in main/utils.c. \subsection ArchMemoryDebugging Memory debugging Dynamic memory management in Asterisk is handled through a %number of wrappers defined in include/asterisk/utils.h. By default, all of these wrappers use the standard C library malloc(), free(), etc. functions. However, if Asterisk is compiled with the MALLOC_DEBUG option enabled, additional memory debugging is included. The Asterisk memory debugging system provides the following features: - Track all current allocations including their size and the file, function, and line %number where they were initiated. - When releasing memory, do some basic fence checking to see if anything wrote into the few bytes immediately surrounding an allocation. - Get notified when attempting to free invalid memory. A %number of CLI commands are provided to access data on the current set of memory allocations. Those are: - memory show summary - memory show allocations The implementation of this memory debugging system can be found in main/astmm.c.
Return to the \ref ArchTOC */ asterisk-11.7.0/include/asterisk/doxygen/releases.h0000644000175000007640000002567511207611523022263 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2009, Digium, Inc. * * 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 */ /*! * \page ReleaseStatus Asterisk Release Status * * @AsteriskTrunkWarning * * \section warranty Warranty * The following warranty applies to all open source releases of Asterisk: * * NO WARRANTY * * 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. * 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. * * \section releasestatustypes Release Status Types * * Release management is a essentially an agreement between the development * community and the %user community on what kind of updates can be expected * for Asterisk releases, and what types of changes these updates will contain. * Once these policies are established, the development community works very * hard to adhere to them. However, the development community does reserve * the right to make exceptions to these rules for special cases as the need * arises. * * Asterisk releases are in various states of maintenance. The states are * defined here: * * \arg None - This release series is receiving no updates whatsoever. * \arg Security-Only - This release series is receiving updates, but * only to address security issues. Security issues found and fixed in * this release series will be accompanied by a published security advisory * from the Asterisk project. * \arg Full-Support - This release series is receiving updates for all * types of bugs. * \arg Full-Development - Changes in this part of Asterisk include bug * fixes, as well as new %features and architectural improvements. * * \section AsteriskReleases Asterisk Maintenance Levels * * \htmlonly *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
NameSVN BranchStatusNotes
Asterisk 1.0/branches/1.0None
Asterisk 1.2/branches/1.2Security-Only
Asterisk 1.4/branches/1.4Full-Support
Asterisk 1.6.0/branches/1.6.0Full-Support
Asterisk 1.6.1/branches/1.6.1Full-SupportStill in beta
Asterisk trunk/trunkFull-DevelopmentNo releases are made directly from trunk.
* \endhtmlonly * * For more information on how and when Asterisk releases are made, see the * release policies page: * \arg \ref ReleasePolicies */ /*! * \page ReleasePolicies Asterisk Release and Commit Policies * * \AsteriskTrunkWarning * * \section releasestatus Asterisk Release Status * * For more information on the current status of each Asterisk release series, * please see the Asterisk Release Status page: * * \arg \ref ReleaseStatus * *
* * \section commitmonitoring Commit Monitoring * * To monitor commits to Asterisk and related projects, visit * http://lists.digium.com. The Digium * mailing list server hosts a %number of mailing lists for commits. * *
* * \section ast10policy Asterisk 1.0 * * \subsection svnbranch SVN Branch * * \arg /branches/1.0 * * \subsection ast10releases Release and Commit Policy * No more releases of Asterisk 1.0 will be made for any reason. * * No commits should be made to the Asterisk 1.0 branch. * *
* * \section ast12policy Asterisk 1.2 * * \subsection svnbranch SVN Branch * * \arg /branches/1.2 * * \subsection ast12releases Release and Commit Policy * * There will be no more scheduled releases of Asterisk 1.2. * * Commits to the Asterisk 1.2 branch should only address security issues or * regressions introduced by previous security fixes. For a security issue, the * commit should be accompanied by an * Asterisk Security Advisory * and an immediate release. When a commit goes in to fix a regression, the previous * security advisory that is related to the change that introduced the bug should get * updated to indicate that there is an updated version of the fix. A release should * be made immediately for these regression fixes, as well. * * \subsection ast12releasenumbers Release Numbering * * - 1.2.X - a release that contains new security fixes * - 1.2.X.Y - a release that contains fixes to the security patches released in * version 1.2.X * *
* * \section ast14policy Asterisk 1.4 * * \subsection svnbranch SVN Branch * * \arg /branches/1.4 * * \subsection ast14releases Release and Commit Policy * * Asterisk 1.4 is receiving regular bug fix release updates. An attempt is made to * make releases of every four to six weeks. Since this release series is receiving * changes for all types of bugs, the number of changes in a single release can be * significant. 1.4.X releases go through a release candidate testing cycle to help * catch any regressions that may have been introduced. * * Commits to Asterisk 1.4 must be to address bugs only. No new %features should be * introduced into Asterisk 1.4 to reduce the %number of changes to this established * release series. The only exceptions to this %rule are for cases where something * that may be considered a feature is needed to address a bug or security issue. * * \subsection ast14releasenumbers Release Numbering * * - 1.4.X - a release that contains new bug fixes to the 1.4 release series * - 1.4.X.Y - a release that contains very few changes on top of 1.4.X. This * may be for a security patch, or for a regression introduced in 1.4.X. * *
* * \section ast16policy Asterisk 1.6 * * \subsection svnbranch SVN Branch * * \arg /branches/1.6.* * * \subsection ast16releases Release and Commit Policy * * Asterisk 1.6 is managed in a different way than previous Asterisk release series. * From a high level, it was inspired by the release model used for Linux 2.6. * The intended time frame for 1.6.X releases is every 2 or 3 months. Each 1.6.X * release gets its own branch. The 1.6.X branches are branches off of trunk. * Once the branch is created, it only receives bug fixes. Each 1.6.X release goes * through a beta and release candidate testing cycle. * * After a 1.6.X release is published, it will be maintained until 1.6.[X + 3] is * released. While a 1.6.X release branch is still maintained, it will receive only * bug fixes. Periodic maintenance releases will be made and labeled as 1.6.X.Y. * 1.6.X.Y releases should go through a release candidate test cycle before being * published. * * For now, all previous 1.6 release will be maintained for security issues. Once * we have more 1.6 releases to deal with, this part of the policy will likely change. * * For some history on the motivations for Asterisk 1.6 release management, see the * first two sections of this * mailing list post. * * \subsection ast16releasenumbers Release Numbering * * - 1.6.X - a release that includes new functionality * - 1.6.X.Y - a release that contains fixes for bugs or security issues identified * in the 1.6.X release series. * *
* * \section asttrunk Asterisk Trunk * * \subsection svnbranch SVN Branch * * \arg /trunk * * \subsection asttrunkpolicy Release and Commit Policy * * No releases are ever made directly from Asterisk trunk. * * Asterisk trunk is used as the main development area for upcoming Asterisk 1.6 * releases. Commits to Asterisk trunk are not limited. They can be bug fixes, * new %features, and architectural improvements. However, for larger sets * of changes, developers should work with the Asterisk project leaders to * schedule them for inclusion. Care is taken not to include too many invasive * sets of changes for each new Asterisk 1.6 release. * * No changes should go into Asterisk trunk that are not ready to go into a * release. While the upcoming release will go through a beta and release * candidate test cycle, code should not be in trunk until the code has been * tested and reviewed such that there is reasonable belief that the code * is ready to go. * *
* * \section astteam Asterisk Team Branches * * \subsection svnbranch SVN Branch * * \arg /team/<developername> * * \subsection astteampolicy Release and Commit Policy * * The Asterisk subversion repository has a special directory called "team" * where developers can make their own personal development branches. This is * where new %features, bug fixes, and architectural improvements are developed * while they are in %progress. * * Just about anything goes as far as commits to this area goes. However, * developers should keep in mind that anything committed here, as well as * anywhere else on Digium's SVN server, falls under the contributor license * agreement. * * In addition to each developer having their own space for working on projects, * there is also a team/group folder where %group development efforts take place. * * Finally, in each developer folder, there is a folder called "private". This * is where developers can create branches for working on things that they are * not ready for the whole world to see. */ asterisk-11.7.0/include/asterisk/res_fax.h0000644000175000007640000002431311676663404020435 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008-2009, Digium, Inc. * * Dwayne M. Hubbard * Kevin P. Fleming * * 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. */ #ifndef _ASTERISK_RES_FAX_H #define _ASTERISK_RES_FAX_H #include #include #include #include #include #include #include #include #include /*! \brief capabilities for res_fax to locate a fax technology module */ enum ast_fax_capabilities { /*! SendFax is supported */ AST_FAX_TECH_SEND = (1 << 0), /*! ReceiveFax is supported */ AST_FAX_TECH_RECEIVE = (1 << 1), /*! Audio FAX session supported */ AST_FAX_TECH_AUDIO = (1 << 2), /*! T.38 FAX session supported */ AST_FAX_TECH_T38 = (1 << 3), /*! sending mulitple documents supported */ AST_FAX_TECH_MULTI_DOC = (1 << 4), /*! T.38 - T.30 Gateway */ AST_FAX_TECH_GATEWAY = (1 << 5), /*! V21 detection is supported */ AST_FAX_TECH_V21_DETECT = (1 << 6), }; /*! \brief fax modem capabilities */ enum ast_fax_modems { /*! V.17 */ AST_FAX_MODEM_V17 = (1 << 0), /*! V.27 */ AST_FAX_MODEM_V27 = (1 << 1), /*! V.29 */ AST_FAX_MODEM_V29 = (1 << 2), /*! V.34 */ AST_FAX_MODEM_V34 = (1 << 3), }; /*! \brief current state of a fax session */ enum ast_fax_state { /*! uninitialized state */ AST_FAX_STATE_UNINITIALIZED = 0, /*! initialized state */ AST_FAX_STATE_INITIALIZED, /*! fax resources open state */ AST_FAX_STATE_OPEN, /*! fax session in progress */ AST_FAX_STATE_ACTIVE, /*! fax session complete */ AST_FAX_STATE_COMPLETE, /*! reserved state */ AST_FAX_STATE_RESERVED, /*! inactive state */ AST_FAX_STATE_INACTIVE, }; /*! \brief fax session options */ enum ast_fax_optflag { /*! false/disable configuration override */ AST_FAX_OPTFLAG_FALSE = 0, /*! true/enable configuration override */ AST_FAX_OPTFLAG_TRUE, /*! use the configured default */ AST_FAX_OPTFLAG_DEFAULT, }; struct ast_fax_t38_parameters { unsigned int version; /*!< Supported T.38 version */ unsigned int max_ifp; /*!< Maximum IFP size supported */ enum ast_control_t38_rate rate; /*!< Maximum fax rate supported */ enum ast_control_t38_rate_management rate_management; /*!< Rate management setting */ unsigned int fill_bit_removal:1; /*!< Set if fill bit removal can be used */ unsigned int transcoding_mmr:1; /*!< Set if MMR transcoding can be used */ unsigned int transcoding_jbig:1; /*!< Set if JBIG transcoding can be used */ }; struct ast_fax_document { AST_LIST_ENTRY(ast_fax_document) next; char filename[0]; }; AST_LIST_HEAD_NOLOCK(ast_fax_documents, ast_fax_document); /*! \brief The data communicated between the high level applications and the generic fax function */ struct ast_fax_session_details { /*! fax session capability requirements. The caps field is used to select * the proper fax technology module before the session starts */ enum ast_fax_capabilities caps; /*! modem requirement for the session */ enum ast_fax_modems modems; /*! session id */ unsigned int id; /*! document(s) to be sent/received */ struct ast_fax_documents documents; AST_DECLARE_STRING_FIELDS( /*! resolution negotiated during the fax session. This is stored in the * FAXRESOLUTION channel variable when the fax session completes */ AST_STRING_FIELD(resolution); /*! transfer rate negotiated during the fax session. This is stored in the * FAXBITRATE channel variable when the fax session completes */ AST_STRING_FIELD(transfer_rate); /*! local station identification. This is set from the LOCALSTATIONID * channel variable before the fax session starts */ AST_STRING_FIELD(localstationid); /*! remote station identification. This is stored in the REMOTESTATIONID * channel variable after the fax session completes */ AST_STRING_FIELD(remotestationid); /*! headerinfo variable is set from the LOCALHEADERINFO channel variable * before the fax session starts */ AST_STRING_FIELD(headerinfo); /*! the result of the fax session */ AST_STRING_FIELD(result); /*! a more descriptive result string of the fax session */ AST_STRING_FIELD(resultstr); /*! the error reason of the fax session */ AST_STRING_FIELD(error); ); /*! the number of pages sent/received during a fax session */ unsigned int pages_transferred; /*! session details flags for options */ union { /*! dontuse dummy variable - do not ever use */ uint32_t dontuse; struct { /*! flag to send debug manager events */ uint32_t debug:2; /*! flag indicating the use of Error Correction Mode (ECM) */ uint32_t ecm:1; /*! flag indicating the sending of status manager events */ uint32_t statusevents:2; /*! allow audio mode FAX on T.38-capable channels */ uint32_t allow_audio:2; /*! indicating the session switched to T38 */ uint32_t switch_to_t38:1; /*! flag indicating whether CED should be sent (for receive mode) */ uint32_t send_ced:1; /*! flag indicating whether CNG should be sent (for send mode) */ uint32_t send_cng:1; /*! send a T.38 reinvite */ uint32_t request_t38:1; /*! a V.21 preamble was detected */ uint32_t v21_detected:1; }; } option; /*! override the minimum transmission rate with a channel variable */ unsigned int minrate; /*! override the maximum transmission rate with a channel varialbe */ unsigned int maxrate; /*! our T.38 session parameters, if any */ struct ast_fax_t38_parameters our_t38_parameters; /*! the other endpoint's T.38 session parameters, if any */ struct ast_fax_t38_parameters their_t38_parameters; /*! the id of the t.38 gateway framehook for this channel */ int gateway_id; /*! the timeout for this gateway in seconds */ int gateway_timeout; /*! the id of the faxdetect framehook for this channel */ int faxdetect_id; }; struct ast_fax_tech; struct ast_fax_debug_info; struct ast_fax_tech_token; /*! \brief The data required to handle a fax session */ struct ast_fax_session { /*! session id */ unsigned int id; /*! session file descriptor */ int fd; /*! fax session details structure */ struct ast_fax_session_details *details; /*! fax frames received */ unsigned long frames_received; /*! fax frames sent */ unsigned long frames_sent; /*! the fax technology callbacks */ const struct ast_fax_tech *tech; /*! private implementation pointer */ void *tech_pvt; /*! fax state */ enum ast_fax_state state; /*! name of the Asterisk channel using the fax session */ char *channame; /*! unique ID of the Asterisk channel using the fax session */ char *chan_uniqueid; /*! Asterisk channel using the fax session */ struct ast_channel *chan; /*! fax debugging structure */ struct ast_fax_debug_info *debug_info; /*! used to take variable-sized frames in and output frames of an expected size to the fax stack */ struct ast_smoother *smoother; }; /* if this overlaps with any AST_FRFLAG_* values, problems will occur */ #define AST_FAX_FRFLAG_GATEWAY (1 << 13) /*! \brief used to register a FAX technology module with res_fax */ struct ast_fax_tech { /*! the type of fax session supported with this ast_fax_tech structure */ const char * const type; /*! a short description of the fax technology */ const char * const description; /*! version string of the technology module */ const char * const version; /*! the ast_fax_capabilities supported by the fax technology */ const enum ast_fax_capabilities caps; /*! module information for the fax technology */ struct ast_module *module; /*! reserves a session for future use; returns a token */ struct ast_fax_tech_token *(* const reserve_session)(struct ast_fax_session *); /*! releases an unused session token */ void (* const release_token)(struct ast_fax_tech_token *); /*! creates a new fax session, optionally using a previously-reserved token */ void *(* const new_session)(struct ast_fax_session *, struct ast_fax_tech_token *); /*! destroys an existing fax session */ void (* const destroy_session)(struct ast_fax_session *); /*! sends an Asterisk frame to res_fax */ struct ast_frame *(* const read)(struct ast_fax_session *); /*! writes an Asterisk frame to the fax session */ int (* const write)(struct ast_fax_session *, const struct ast_frame *); /*! starts the fax session */ int (* const start_session)(struct ast_fax_session *); /*! cancels a fax session */ int (* const cancel_session)(struct ast_fax_session *); /*! initiates the generation of silence to the fax session */ int (* const generate_silence)(struct ast_fax_session *); /*! switches an existing dual-mode session from audio to T.38 */ int (* const switch_to_t38)(struct ast_fax_session *); /*! displays capabilities of the fax technology */ char * (* const cli_show_capabilities)(int); /*! displays details about the fax session */ char * (* const cli_show_session)(struct ast_fax_session *, int); /*! displays statistics from the fax technology module */ char * (* const cli_show_stats)(int); /*! displays settings from the fax technology module */ char * (* const cli_show_settings)(int); }; /*! \brief register a fax technology */ int ast_fax_tech_register(struct ast_fax_tech *tech); /*! \brief unregister a fax technology */ void ast_fax_tech_unregister(struct ast_fax_tech *tech); /*! \brief get the minimum supported fax rate */ unsigned int ast_fax_minrate(void); /*! \brief get the maxiumum supported fax rate */ unsigned int ast_fax_maxrate(void); /*! \brief convert an ast_fax_state to a string */ const char *ast_fax_state_to_str(enum ast_fax_state state); /*! * \brief Log message at FAX or recommended level * * The first four parameters can be represented with Asterisk's * LOG_* levels. In other words, this function may be called * like * * ast_fax_log(LOG_DEBUG, msg); */ void ast_fax_log(int level, const char *file, const int line, const char *function, const char *msg); #endif asterisk-11.7.0/include/asterisk/sha1.h0000644000175000007640000003444411645111665017641 0ustar sharkyjerryweb/**************************** sha.h ****************************/ /***************** See RFC 6234 for details. *******************/ /* Copyright (c) 2011 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Internet Society, IETF or IETF Trust, nor the names of specific contributors, may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _SHA1_H_ #define _SHA1_H_ /* * Description: * This file implements the Secure Hash Algorithms * as defined in the U.S. National Institute of Standards * and Technology Federal Information Processing Standards * Publication (FIPS PUB) 180-3 published in October 2008 * and formerly defined in its predecessors, FIPS PUB 180-1 * and FIP PUB 180-2. * * A combined document showing all algorithms is available at * http://csrc.nist.gov/publications/fips/ * fips180-3/fips180-3_final.pdf * * The five hashes are defined in these sizes: * SHA-1 20 byte / 160 bit * SHA-224 28 byte / 224 bit * SHA-256 32 byte / 256 bit * SHA-384 48 byte / 384 bit * SHA-512 64 byte / 512 bit * * Compilation Note: * These files may be compiled with two options: * USE_32BIT_ONLY - use 32-bit arithmetic only, for systems * without 64-bit integers * * USE_MODIFIED_MACROS - use alternate form of the SHA_Ch() * and SHA_Maj() macros that are equivalent * and potentially faster on many systems * */ #include /* * If you do not have the ISO standard stdint.h header file, then you * must typedef the following: * name meaning * uint64_t unsigned 64-bit integer * uint32_t unsigned 32-bit integer * uint8_t unsigned 8-bit integer (i.e., unsigned char) * int_least16_t integer of >= 16 bits * * See stdint-example.h */ #ifndef _SHA_enum_ #define _SHA_enum_ /* * All SHA functions return one of these values. */ enum { shaSuccess = 0, shaNull, /* Null pointer parameter */ shaInputTooLong, /* input data too long */ shaStateError, /* called Input after FinalBits or Result */ shaBadParam /* passed a bad parameter */ }; #endif /* _SHA_enum_ */ /* * These constants hold size information for each of the SHA * hashing operations */ enum { SHA1_Message_Block_Size = 64, SHA224_Message_Block_Size = 64, SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128, SHA512_Message_Block_Size = 128, USHA_Max_Message_Block_Size = SHA512_Message_Block_Size, SHA1HashSize = 20, SHA224HashSize = 28, SHA256HashSize = 32, SHA384HashSize = 48, SHA512HashSize = 64, USHAMaxHashSize = SHA512HashSize, SHA1HashSizeBits = 160, SHA224HashSizeBits = 224, SHA256HashSizeBits = 256, SHA384HashSizeBits = 384, SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits }; /* * These constants are used in the USHA (Unified SHA) functions. */ typedef enum SHAversion { SHA1, SHA224, SHA256, SHA384, SHA512 } SHAversion; /* * This structure will hold context information for the SHA-1 * hashing operation. */ typedef struct SHA1Context { uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ uint32_t Length_High; /* Message length in bits */ uint32_t Length_Low; /* Message length in bits */ int_least16_t Message_Block_Index; /* Message_Block array index */ /* 512-bit message blocks */ uint8_t Message_Block[SHA1_Message_Block_Size]; int Computed; /* Is the hash computed? */ int Corrupted; /* Cumulative corruption code */ } SHA1Context; /* * This structure will hold context information for the SHA-256 * hashing operation. */ typedef struct SHA256Context { uint32_t Intermediate_Hash[SHA256HashSize/4]; /* Message Digest */ uint32_t Length_High; /* Message length in bits */ uint32_t Length_Low; /* Message length in bits */ int_least16_t Message_Block_Index; /* Message_Block array index */ /* 512-bit message blocks */ uint8_t Message_Block[SHA256_Message_Block_Size]; int Computed; /* Is the hash computed? */ int Corrupted; /* Cumulative corruption code */ } SHA256Context; /* * This structure will hold context information for the SHA-512 * hashing operation. */ typedef struct SHA512Context { #ifdef USE_32BIT_ONLY uint32_t Intermediate_Hash[SHA512HashSize/4]; /* Message Digest */ uint32_t Length[4]; /* Message length in bits */ #else /* !USE_32BIT_ONLY */ uint64_t Intermediate_Hash[SHA512HashSize/8]; /* Message Digest */ uint64_t Length_High, Length_Low; /* Message length in bits */ #endif /* USE_32BIT_ONLY */ int_least16_t Message_Block_Index; /* Message_Block array index */ /* 1024-bit message blocks */ uint8_t Message_Block[SHA512_Message_Block_Size]; int Computed; /* Is the hash computed?*/ int Corrupted; /* Cumulative corruption code */ } SHA512Context; /* * This structure will hold context information for the SHA-224 * hashing operation. It uses the SHA-256 structure for computation. */ typedef struct SHA256Context SHA224Context; /* * This structure will hold context information for the SHA-384 * hashing operation. It uses the SHA-512 structure for computation. */ typedef struct SHA512Context SHA384Context; /* * This structure holds context information for all SHA * hashing operations. */ typedef struct USHAContext { int whichSha; /* which SHA is being used */ union { SHA1Context sha1Context; SHA224Context sha224Context; SHA256Context sha256Context; SHA384Context sha384Context; SHA512Context sha512Context; } ctx; } USHAContext; /* * This structure will hold context information for the HMAC * keyed-hashing operation. */ typedef struct HMACContext { int whichSha; /* which SHA is being used */ int hashSize; /* hash size of SHA being used */ int blockSize; /* block size of SHA being used */ USHAContext shaContext; /* SHA context */ unsigned char k_opad[USHA_Max_Message_Block_Size]; /* outer padding - key XORd with opad */ int Computed; /* Is the MAC computed? */ int Corrupted; /* Cumulative corruption code */ } HMACContext; /* * This structure will hold context information for the HKDF * extract-and-expand Key Derivation Functions. */ typedef struct HKDFContext { int whichSha; /* which SHA is being used */ HMACContext hmacContext; int hashSize; /* hash size of SHA being used */ unsigned char prk[USHAMaxHashSize]; /* pseudo-random key - output of hkdfInput */ int Computed; /* Is the key material computed? */ int Corrupted; /* Cumulative corruption code */ } HKDFContext; /* * Function Prototypes */ /* SHA-1 */ extern int SHA1Reset(SHA1Context *); extern int SHA1Input(SHA1Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA1FinalBits(SHA1Context *, uint8_t bits, unsigned int bit_count); extern int SHA1Result(SHA1Context *, uint8_t Message_Digest[SHA1HashSize]); /* SHA-224 */ extern int SHA224Reset(SHA224Context *); extern int SHA224Input(SHA224Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA224FinalBits(SHA224Context *, uint8_t bits, unsigned int bit_count); extern int SHA224Result(SHA224Context *, uint8_t Message_Digest[SHA224HashSize]); /* SHA-256 */ extern int SHA256Reset(SHA256Context *); extern int SHA256Input(SHA256Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA256FinalBits(SHA256Context *, uint8_t bits, unsigned int bit_count); extern int SHA256Result(SHA256Context *, uint8_t Message_Digest[SHA256HashSize]); /* SHA-384 */ extern int SHA384Reset(SHA384Context *); extern int SHA384Input(SHA384Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA384FinalBits(SHA384Context *, uint8_t bits, unsigned int bit_count); extern int SHA384Result(SHA384Context *, uint8_t Message_Digest[SHA384HashSize]); /* SHA-512 */ extern int SHA512Reset(SHA512Context *); extern int SHA512Input(SHA512Context *, const uint8_t *bytes, unsigned int bytecount); extern int SHA512FinalBits(SHA512Context *, uint8_t bits, unsigned int bit_count); extern int SHA512Result(SHA512Context *, uint8_t Message_Digest[SHA512HashSize]); /* Unified SHA functions, chosen by whichSha */ extern int USHAReset(USHAContext *context, SHAversion whichSha); extern int USHAInput(USHAContext *context, const uint8_t *bytes, unsigned int bytecount); extern int USHAFinalBits(USHAContext *context, uint8_t bits, unsigned int bit_count); extern int USHAResult(USHAContext *context, uint8_t Message_Digest[USHAMaxHashSize]); extern int USHABlockSize(enum SHAversion whichSha); extern int USHAHashSize(enum SHAversion whichSha); extern int USHAHashSizeBits(enum SHAversion whichSha); extern const char *USHAHashName(enum SHAversion whichSha); /* * HMAC Keyed-Hashing for Message Authentication, RFC 2104, * for all SHAs. * This interface allows a fixed-length text input to be used. */ extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */ const unsigned char *text, /* pointer to data stream */ int text_len, /* length of data stream */ const unsigned char *key, /* pointer to authentication key */ int key_len, /* length of authentication key */ uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */ /* * HMAC Keyed-Hashing for Message Authentication, RFC 2104, * for all SHAs. * This interface allows any length of text input to be used. */ extern int hmacReset(HMACContext *context, enum SHAversion whichSha, const unsigned char *key, int key_len); extern int hmacInput(HMACContext *context, const unsigned char *text, int text_len); extern int hmacFinalBits(HMACContext *context, uint8_t bits, unsigned int bit_count); extern int hmacResult(HMACContext *context, uint8_t digest[USHAMaxHashSize]); /* * HKDF HMAC-based Extract-and-Expand Key Derivation Function, * RFC 5869, for all SHAs. */ extern int hkdf(SHAversion whichSha, const unsigned char *salt, int salt_len, const unsigned char *ikm, int ikm_len, const unsigned char *info, int info_len, uint8_t okm[ ], int okm_len); extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt, int salt_len, const unsigned char *ikm, int ikm_len, uint8_t prk[USHAMaxHashSize]); extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ], int prk_len, const unsigned char *info, int info_len, uint8_t okm[ ], int okm_len); /* * HKDF HMAC-based Extract-and-Expand Key Derivation Function, * RFC 5869, for all SHAs. * This interface allows any length of text input to be used. */ extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha, const unsigned char *salt, int salt_len); extern int hkdfInput(HKDFContext *context, const unsigned char *ikm, int ikm_len); extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits, unsigned int ikm_bit_count); extern int hkdfResult(HKDFContext *context, uint8_t prk[USHAMaxHashSize], const unsigned char *info, int info_len, uint8_t okm[USHAMaxHashSize], int okm_len); /************************ sha-private.h ************************/ /***************** See RFC 6234 for details. *******************/ /* * These definitions are defined in FIPS 180-3, section 4.1. * Ch() and Maj() are defined identically in sections 4.1.1, * 4.1.2, and 4.1.3. * * The definitions used in FIPS 180-3 are as follows: */ #ifndef USE_MODIFIED_MACROS #define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) #define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #else /* USE_MODIFIED_MACROS */ /* * The following definitions are equivalent and potentially faster. */ #define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z)) #define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) #endif /* USE_MODIFIED_MACROS */ #define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z)) #endif /* _SHA1_H_ */ asterisk-11.7.0/include/asterisk/tcptls.h0000644000175000007640000002040212036041477020301 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 tcptls.h * * \brief Generic support for tcp/tls servers in Asterisk. * \note In order to have TLS/SSL support, we need the openssl libraries. * Still we can decide whether or not to use them by commenting * in or out the DO_SSL macro. * * TLS/SSL support is basically implemented by reading from a config file * (currently manager.conf, http.conf and sip.conf) the names of the certificate * files and cipher to use, and then run ssl_setup() to create an appropriate * data structure named ssl_ctx. * * If we support multiple domains, presumably we need to read multiple * certificates. * * When we are requested to open a TLS socket, we run make_file_from_fd() * on the socket, to do the necessary setup. At the moment the context's name * is hardwired in the function, but we can certainly make it into an extra * parameter to the function. * * We declare most of ssl support variables unconditionally, * because their number is small and this simplifies the code. * * \note The ssl-support variables (ssl_ctx, do_ssl, certfile, cipher) * and their setup should be moved to a more central place, e.g. asterisk.conf * and the source files that processes it. Similarly, ssl_setup() should * be run earlier in the startup process so modules have it available. * * \ref AstTlsOverview * * \todo For SIP, the SubjectAltNames should be checked on verification * of the certificate. (Check RFC 5922) * */ #ifndef _ASTERISK_TCPTLS_H #define _ASTERISK_TCPTLS_H #include "asterisk/netsock2.h" #include "asterisk/utils.h" #if defined(HAVE_OPENSSL) && (defined(HAVE_FUNOPEN) || defined(HAVE_FOPENCOOKIE)) #define DO_SSL /* comment in/out if you want to support ssl */ #endif #ifdef DO_SSL #include #include #else /* declare dummy types so we can define a pointer to them */ typedef struct {} SSL; typedef struct {} SSL_CTX; #endif /* DO_SSL */ /*! SSL support */ #define AST_CERTFILE "asterisk.pem" enum ast_ssl_flags { /*! Verify certificate when acting as server */ AST_SSL_VERIFY_CLIENT = (1 << 0), /*! Don't verify certificate when connecting to a server */ AST_SSL_DONT_VERIFY_SERVER = (1 << 1), /*! Don't compare "Common Name" against IP or hostname */ AST_SSL_IGNORE_COMMON_NAME = (1 << 2), /*! Use SSLv2 for outgoing client connections */ AST_SSL_SSLV2_CLIENT = (1 << 3), /*! Use SSLv3 for outgoing client connections */ AST_SSL_SSLV3_CLIENT = (1 << 4), /*! Use TLSv1 for outgoing client connections */ AST_SSL_TLSV1_CLIENT = (1 << 5) }; struct ast_tls_config { int enabled; char *certfile; char *pvtfile; char *cipher; char *cafile; char *capath; struct ast_flags flags; SSL_CTX *ssl_ctx; }; /*! \page AstTlsOverview TLS Implementation Overview * * The following code implements a generic mechanism for starting * services on a TCP or TLS socket. * The service is configured in the struct session_args, and * then started by calling server_start(desc) on the descriptor. * server_start() first verifies if an instance of the service is active, * and in case shuts it down. Then, if the service must be started, creates * a socket and a thread in charge of doing the accept(). * * The body of the thread is desc->accept_fn(desc), which the user can define * freely. We supply a sample implementation, server_root(), structured as an * infinite loop. At the beginning of each iteration it runs periodic_fn() * if defined (e.g. to perform some cleanup etc.) then issues a poll() * or equivalent with a timeout of 'poll_timeout' milliseconds, and if the * following accept() is successful it creates a thread in charge of * running the session, whose body is desc->worker_fn(). The argument of * worker_fn() is a struct ast_tcptls_session_instance, which contains the address * of the other party, a pointer to desc, the file descriptors (fd) on which * we can do a select/poll (but NOT I/O), and a FILE *on which we can do I/O. * We have both because we want to support plain and SSL sockets, and * going through a FILE * lets us provide the encryption/decryption * on the stream without using an auxiliary thread. */ /*! \brief * arguments for the accepting thread */ struct ast_tcptls_session_args { struct ast_sockaddr local_address; struct ast_sockaddr old_address; /*!< copy of the local or remote address depending on if its a client or server session */ struct ast_sockaddr remote_address; char hostname[MAXHOSTNAMELEN]; /*!< only necessary for SSL clients so we can compare to common name */ struct ast_tls_config *tls_cfg; /*!< points to the SSL configuration if any */ int accept_fd; int poll_timeout; /*! Server accept_fn thread ID used for external shutdown requests. */ pthread_t master; void *(*accept_fn)(void *); /*!< the function in charge of doing the accept */ void (*periodic_fn)(void *);/*!< something we may want to run before after select on the accept socket */ void *(*worker_fn)(void *); /*!< the function in charge of doing the actual work */ const char *name; }; /*! \brief * describes a server instance */ struct ast_tcptls_session_instance { FILE *f; /*!< fopen/funopen result */ int fd; /*!< the socket returned by accept() */ SSL *ssl; /*!< ssl state */ /* iint (*ssl_setup)(SSL *); */ int client; struct ast_sockaddr remote_address; struct ast_tcptls_session_args *parent; /* Sometimes, when an entity reads TCP data, multiple * logical messages might be read at the same time. In such * a circumstance, there needs to be a place to stash the * extra data. */ struct ast_str *overflow_buf; }; #if defined(HAVE_FUNOPEN) #define HOOK_T int #define LEN_T int #else #define HOOK_T ssize_t #define LEN_T size_t #endif /*! * \brief attempts to connect and start tcptls session, on error the tcptls_session's * ref count is decremented, fd and file are closed, and NULL is returned. */ struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_session_instance *tcptls_session); /* \brief Creates a client connection's ast_tcptls_session_instance. */ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_session_args *desc); void *ast_tcptls_server_root(void *); /*! * \brief Closes a tcptls session instance's file and/or file descriptor. * The tcptls_session will be set to NULL and it's file descriptor will be set to -1 * by this function. */ void ast_tcptls_close_session_file(struct ast_tcptls_session_instance *tcptls_session); /*! * \brief This is a generic (re)start routine for a TCP server, * which does the socket/bind/listen and starts a thread for handling * accept(). * \version 1.6.1 changed desc parameter to be of ast_tcptls_session_args type */ void ast_tcptls_server_start(struct ast_tcptls_session_args *desc); /*! * \brief Shutdown a running server if there is one * \version 1.6.1 changed desc parameter to be of ast_tcptls_session_args type */ void ast_tcptls_server_stop(struct ast_tcptls_session_args *desc); /*! * \brief Set up an SSL server * * \param cfg Configuration for the SSL server * \retval 1 Success * \retval 0 Failure */ int ast_ssl_setup(struct ast_tls_config *cfg); /*! * \brief free resources used by an SSL server * * \note This only needs to be called if ast_ssl_setup() was * directly called first. * \param cfg Configuration for the SSL server */ void ast_ssl_teardown(struct ast_tls_config *cfg); /*! * \brief Used to parse conf files containing tls/ssl options. */ int ast_tls_read_conf(struct ast_tls_config *tls_cfg, struct ast_tcptls_session_args *tls_desc, const char *varname, const char *value); HOOK_T ast_tcptls_server_read(struct ast_tcptls_session_instance *ser, void *buf, size_t count); HOOK_T ast_tcptls_server_write(struct ast_tcptls_session_instance *ser, const void *buf, size_t count); #endif /* _ASTERISK_TCPTLS_H */ asterisk-11.7.0/include/asterisk/syslog.h0000644000175000007640000000461311313741645020317 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009, malleable, LLC. * * Sean Bright * * 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 syslog.h * \brief Syslog support functions for Asterisk logging. */ #ifndef _ASTERISK_SYSLOG_H #define _ASTERISK_SYSLOG_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /*! * \since 1.8 * \brief Maps a syslog facility name from a string to a syslog facility * constant. * * \param facility Facility name to map (i.e. "daemon") * * \retval syslog facility constant (i.e. LOG_DAEMON) if found * \retval -1 if facility is not found */ int ast_syslog_facility(const char *facility); /*! * \since 1.8 * \brief Maps a syslog facility constant to a string. * * \param facility syslog facility constant to map (i.e. LOG_DAEMON) * * \retval facility name (i.e. "daemon") if found * \retval NULL if facility is not found */ const char *ast_syslog_facility_name(int facility); /*! * \since 1.8 * \brief Maps a syslog priority name from a string to a syslog priority * constant. * * \param priority Priority name to map (i.e. "notice") * * \retval syslog priority constant (i.e. LOG_NOTICE) if found * \retval -1 if priority is not found */ int ast_syslog_priority(const char *priority); /*! * \since 1.8 * \brief Maps a syslog priority constant to a string. * * \param priority syslog priority constant to map (i.e. LOG_NOTICE) * * \retval priority name (i.e. "notice") if found * \retval NULL if priority is not found */ const char *ast_syslog_priority_name(int priority); /*! * \since 1.8 * \brief Maps an Asterisk log level (i.e. LOG_ERROR) to a syslog priority * constant. * * \param level Asterisk log level constant (i.e. LOG_ERROR) * * \retval syslog priority constant (i.e. LOG_ERR) if found * \retval -1 if priority is not found */ int ast_syslog_priority_from_loglevel(int level); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_SYSLOG_H */ asterisk-11.7.0/include/asterisk/audiohook.h0000644000175000007640000003426411712260572020764 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2007, Digium, Inc. * * Joshua Colp * * 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 Audiohooks Architecture */ #ifndef _ASTERISK_AUDIOHOOK_H #define _ASTERISK_AUDIOHOOK_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif /* these two are used in struct ast_audiohook */ #include "asterisk/lock.h" #include "asterisk/linkedlists.h" #include "asterisk/slinfactory.h" enum ast_audiohook_type { AST_AUDIOHOOK_TYPE_SPY = 0, /*!< Audiohook wants to receive audio */ AST_AUDIOHOOK_TYPE_WHISPER, /*!< Audiohook wants to provide audio to be mixed with existing audio */ AST_AUDIOHOOK_TYPE_MANIPULATE, /*!< Audiohook wants to manipulate the audio */ }; enum ast_audiohook_status { AST_AUDIOHOOK_STATUS_NEW = 0, /*!< Audiohook was just created, not in use yet */ AST_AUDIOHOOK_STATUS_RUNNING, /*!< Audiohook is running on a channel */ AST_AUDIOHOOK_STATUS_SHUTDOWN, /*!< Audiohook is being shutdown */ AST_AUDIOHOOK_STATUS_DONE, /*!< Audiohook has shutdown and is not running on a channel any longer */ }; enum ast_audiohook_direction { AST_AUDIOHOOK_DIRECTION_READ = 0, /*!< Reading audio in */ AST_AUDIOHOOK_DIRECTION_WRITE, /*!< Writing audio out */ AST_AUDIOHOOK_DIRECTION_BOTH, /*!< Both reading audio in and writing audio out */ }; enum ast_audiohook_flags { AST_AUDIOHOOK_TRIGGER_MODE = (3 << 0), /*!< When audiohook should be triggered to do something */ AST_AUDIOHOOK_TRIGGER_READ = (1 << 0), /*!< Audiohook wants to be triggered when reading audio in */ AST_AUDIOHOOK_TRIGGER_WRITE = (2 << 0), /*!< Audiohook wants to be triggered when writing audio out */ AST_AUDIOHOOK_WANTS_DTMF = (1 << 2), /*!< Audiohook also wants to receive DTMF frames */ AST_AUDIOHOOK_TRIGGER_SYNC = (1 << 3), /*!< Audiohook wants to be triggered when both sides have combined audio available */ /*! Audiohooks with this flag set will not allow for a large amount of samples to build up on its * slinfactories. We will flush the factories if they contain too many samples. */ AST_AUDIOHOOK_SMALL_QUEUE = (1 << 4), AST_AUDIOHOOK_MUTE_READ = (1 << 5), /*!< audiohook should be mute frames read */ AST_AUDIOHOOK_MUTE_WRITE = (1 << 6), /*!< audiohook should be mute frames written */ }; enum ast_audiohook_init_flags { /*! Audiohook manipulate callback is capable of handling slinear at any sample rate. * Without enabling this flag on initialization the manipulation callback is guaranteed * 8khz audio only. */ AST_AUDIOHOOK_MANIPULATE_ALL_RATES = (1 << 0), }; struct ast_audiohook; /*! \brief Callback function for manipulate audiohook type * \param audiohook Audiohook structure * \param chan Channel * \param frame Frame of audio to manipulate * \param direction Direction frame came from * \return Returns 0 on success, -1 on failure. * \note An audiohook does not have any reference to a private data structure for manipulate * types. It is up to the manipulate callback to store this data via it's own method. * An example would be datastores. * \note The input frame should never be freed or corrupted during a manipulate callback. * If the callback has the potential to corrupt the frame's data during manipulation, * local data should be used for the manipulation and only copied to the frame on * success. * \note A failure return value indicates that the frame was not manipulated and that * is being returned in its original state. */ typedef int (*ast_audiohook_manipulate_callback)(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction); struct ast_audiohook_options { int read_volume; /*!< Volume adjustment on frames read from the channel the hook is on */ int write_volume; /*!< Volume adjustment on frames written to the channel the hook is on */ }; struct ast_audiohook { ast_mutex_t lock; /*!< Lock that protects the audiohook structure */ ast_cond_t trigger; /*!< Trigger condition (if enabled) */ enum ast_audiohook_type type; /*!< Type of audiohook */ enum ast_audiohook_status status; /*!< Status of the audiohook */ enum ast_audiohook_init_flags init_flags; /*!< Init flags */ const char *source; /*!< Who this audiohook ultimately belongs to */ unsigned int flags; /*!< Flags on the audiohook */ struct ast_slinfactory read_factory; /*!< Factory where frames read from the channel, or read from the whisper source will go through */ struct ast_slinfactory write_factory; /*!< Factory where frames written to the channel will go through */ struct timeval read_time; /*!< Last time read factory was fed */ struct timeval write_time; /*!< Last time write factory was fed */ struct ast_format format; /*!< Format translation path is setup as */ struct ast_trans_pvt *trans_pvt; /*!< Translation path for reading frames */ ast_audiohook_manipulate_callback manipulate_callback; /*!< Manipulation callback */ struct ast_audiohook_options options; /*!< Applicable options */ unsigned int hook_internal_samp_rate; /*!< internal read/write sample rate on the audiohook.*/ AST_LIST_ENTRY(ast_audiohook) list; /*!< Linked list information */ }; struct ast_audiohook_list; /*! \brief Initialize an audiohook structure * \param audiohook Audiohook structure * \param type Type of audiohook to initialize this as * \param source Who is initializing this audiohook * \param init flags * \return Returns 0 on success, -1 on failure */ int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags flags); /*! \brief Destroys an audiohook structure * \param audiohook Audiohook structure * \return Returns 0 on success, -1 on failure */ int ast_audiohook_destroy(struct ast_audiohook *audiohook); /*! \brief Writes a frame into the audiohook structure * \param audiohook Audiohook structure * \param direction Direction the audio frame came from * \param frame Frame to write in * \return Returns 0 on success, -1 on failure */ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction, struct ast_frame *frame); /*! \brief Reads a frame in from the audiohook structure * \param audiohook Audiohook structure * \param samples Number of samples wanted * \param direction Direction the audio frame came from * \param format Format of frame remote side wants back * \return Returns frame on success, NULL on failure */ struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, struct ast_format *format); /*! \brief Reads a frame in from the audiohook structure in mixed audio mode and copies read and write frame data to provided arguments. * \param audiohook Audiohook structure * \param samples Number of samples wanted * \param direction Direction the audio frame came from * \param format Format of frame remote side wants back * \param ast_frame read_frame - if available, we'll copy the read buffer to this. * \param ast_frame write_frame - if available, we'll copy the write buffer to this. * \return Returns frame on success, NULL on failure */ struct ast_frame *ast_audiohook_read_frame_all(struct ast_audiohook *audiohook, size_t samples, struct ast_format *format, struct ast_frame **read_frame, struct ast_frame **write_frame); /*! \brief Attach audiohook to channel * \param chan Channel * \param audiohook Audiohook structure * \return Returns 0 on success, -1 on failure */ int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook); /*! \brief Detach audiohook from channel * \param audiohook Audiohook structure * \return Returns 0 on success, -1 on failure */ int ast_audiohook_detach(struct ast_audiohook *audiohook); /*! \brief Detach audiohooks from list and destroy said list * \param audiohook_list List of audiohooks * \return Returns 0 on success, -1 on failure */ int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list); /*! \brief Move an audiohook from one channel to a new one * * \todo Currently only the first audiohook of a specific source found will be moved. * We should add the capability to move multiple audiohooks from a single source as well. * * \note It is required that both old_chan and new_chan are locked prior to calling * this function. Besides needing to protect the data within the channels, not locking * these channels can lead to a potential deadlock * * \param old_chan The source of the audiohook to move * \param new_chan The destination to which we want the audiohook to move * \param source The source of the audiohook we want to move */ void ast_audiohook_move_by_source(struct ast_channel *old_chan, struct ast_channel *new_chan, const char *source); /*! * \brief Detach specified source audiohook from channel * * \param chan Channel to detach from * \param source Name of source to detach * * \return Returns 0 on success, -1 on failure * * \note The channel does not need to be locked before calling this function. */ int ast_audiohook_detach_source(struct ast_channel *chan, const char *source); /*! * \brief Remove an audiohook from a specified channel * * \param chan Channel to remove from * \param audiohook Audiohook to remove * * \return Returns 0 on success, -1 on failure * * \note The channel does not need to be locked before calling this function */ int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook); /*! * \brief determines if a audiohook_list is empty or not. * * retval 0 false, 1 true */ int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list); /*! \brief Pass a frame off to be handled by the audiohook core * \param chan Channel that the list is coming off of * \param audiohook_list List of audiohooks * \param direction Direction frame is coming in from * \param frame The frame itself * \return Return frame on success, NULL on failure */ struct ast_frame *ast_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame); /*! \brief Update audiohook's status * \param audiohook Audiohook structure * \param audiohook status enum * * \note once status is updated to DONE, this function can not be used to set the * status back to any other setting. Setting DONE effectively locks the status as such. */ void ast_audiohook_update_status(struct ast_audiohook *audiohook, enum ast_audiohook_status status); /*! \brief Wait for audiohook trigger to be triggered * \param audiohook Audiohook to wait on */ void ast_audiohook_trigger_wait(struct ast_audiohook *audiohook); /*! \brief Find out how many audiohooks from a certain source exist on a given channel, regardless of status. \param chan The channel on which to find the spies \param source The audiohook's source \param type The type of audiohook \return Return the number of audiohooks which are from the source specified Note: Function performs nlocking. */ int ast_channel_audiohook_count_by_source(struct ast_channel *chan, const char *source, enum ast_audiohook_type type); /*! \brief Find out how many spies of a certain type exist on a given channel, and are in state running. \param chan The channel on which to find the spies \param source The source of the audiohook \param type The type of spy to look for \return Return the number of running audiohooks which are from the source specified Note: Function performs no locking. */ int ast_channel_audiohook_count_by_source_running(struct ast_channel *chan, const char *source, enum ast_audiohook_type type); /*! \brief Lock an audiohook * \param ah Audiohook structure */ #define ast_audiohook_lock(ah) ast_mutex_lock(&(ah)->lock) /*! \brief Unlock an audiohook * \param ah Audiohook structure */ #define ast_audiohook_unlock(ah) ast_mutex_unlock(&(ah)->lock) /*! * \brief Adjust the volume on frames read from or written to a channel * \param chan Channel to muck with * \param direction Direction to set on * \param volume Value to adjust the volume by * \return Returns 0 on success, -1 on failure * \since 1.6.1 */ int ast_audiohook_volume_set(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume); /*! * \brief Retrieve the volume adjustment value on frames read from or written to a channel * \param chan Channel to retrieve volume adjustment from * \param direction Direction to retrieve * \return Returns adjustment value * \since 1.6.1 */ int ast_audiohook_volume_get(struct ast_channel *chan, enum ast_audiohook_direction direction); /*! * \brief Adjust the volume on frames read from or written to a channel * \param chan Channel to muck with * \param direction Direction to increase * \param volume Value to adjust the adjustment by * \return Returns 0 on success, -1 on failure * \since 1.6.1 */ int ast_audiohook_volume_adjust(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume); /*! \brief Mute frames read from or written to a channel * \param chan Channel to muck with * \param source Type of audiohook * \param flag which direction to set / clear * \param clear set or clear muted frames on direction based on flag parameter * \retval 0 success * \retval -1 failure */ int ast_audiohook_set_mute(struct ast_channel *chan, const char *source, enum ast_audiohook_flags flag, int clear); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_AUDIOHOOK_H */ asterisk-11.7.0/include/asterisk/term.h0000644000175000007640000000512511341313546017741 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Handy terminal functions for vt* terms */ #ifndef _ASTERISK_TERM_H #define _ASTERISK_TERM_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define ESC 0x1b /*! \name Terminal Attributes */ /*@{ */ #define ATTR_RESET 0 #define ATTR_BRIGHT 1 #define ATTR_DIM 2 #define ATTR_UNDER 4 #define ATTR_BLINK 5 #define ATTR_REVER 7 #define ATTR_HIDDEN 8 /*@} */ /*! \name Terminal Colors */ /*@{ */ #define COLOR_BLACK 30 #define COLOR_GRAY (30 | 128) #define COLOR_RED 31 #define COLOR_BRRED (31 | 128) #define COLOR_GREEN 32 #define COLOR_BRGREEN (32 | 128) #define COLOR_BROWN 33 #define COLOR_YELLOW (33 | 128) #define COLOR_BLUE 34 #define COLOR_BRBLUE (34 | 128) #define COLOR_MAGENTA 35 #define COLOR_BRMAGENTA (35 | 128) #define COLOR_CYAN 36 #define COLOR_BRCYAN (36 | 128) #define COLOR_WHITE 37 #define COLOR_BRWHITE (37 | 128) /*@} */ /*! \brief Maximum number of characters needed for a color escape sequence, * plus a null char */ #define AST_TERM_MAX_ESCAPE_CHARS 23 char *term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout); /*! * \brief Append a color sequence to an ast_str * * \param str The string to append to * \param fgcolor foreground color * \param bgcolor background color * * \retval 0 success * \retval -1 failure */ int ast_term_color_code(struct ast_str **str, int fgcolor, int bgcolor); /*! * \brief Write a color sequence to a string * * \param outbuf the location to write to * \param fgcolor foreground color * \param bgcolor background color * \param maxout maximum number of characters to write * * \return outbuf */ char *term_color_code(char *outbuf, int fgcolor, int bgcolor, int maxout); char *term_strip(char *outbuf, const char *inbuf, int maxout); void term_filter_escapes(char *line); char *term_prompt(char *outbuf, const char *inbuf, int maxout); char *term_prep(void); char *term_end(void); char *term_quit(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_TERM_H */ asterisk-11.7.0/include/asterisk/agi.h0000644000175000007640000001226511417421273017536 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 AGI Extension interfaces - Asterisk Gateway Interface */ #ifndef _ASTERISK_AGI_H #define _ASTERISK_AGI_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/cli.h" #include "asterisk/xmldoc.h" #include "asterisk/optional_api.h" typedef struct agi_state { int fd; /*!< FD for general output */ int audio; /*!< FD for audio output */ int ctrl; /*!< FD for input control */ unsigned int fast:1; /*!< flag for fast agi or not */ struct ast_speech *speech; /*!< Speech structure for speech recognition */ } AGI; typedef struct agi_command { const char * const cmda[AST_MAX_CMD_LEN]; /*!< Null terminated list of the words of the command */ /*! Handler for the command (channel, AGI state, # of arguments, argument list). Returns RESULT_SHOWUSAGE for improper arguments */ int (* const handler)(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[]); /*! Summary of the command (< 60 characters) */ const char * const summary; /*! Detailed usage information */ const char * const usage; /*! Does this application run dead */ const int dead; /*! AGI command syntax description */ const char * const syntax; /*! See also content */ const char * const seealso; /*! Where the documentation come from. */ const enum ast_doc_src docsrc; /*! Pointer to module that registered the agi command */ struct ast_module *mod; /*! Linked list pointer */ AST_LIST_ENTRY(agi_command) list; } agi_command; /*! * \brief * * Registers an AGI command. * * \param mod Pointer to the module_info structure for the module that is registering the command * \param cmd Pointer to the descriptor for the command * \retval 1 on success * \retval 0 the command is already registered * \retval AST_OPTIONAL_API_UNAVAILABLE the module is not loaded. */ AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd), { return AST_OPTIONAL_API_UNAVAILABLE; }); /*! * \brief * * Unregisters an AGI command. * * \param mod Pointer to the module_info structure for the module that is unregistering the command * \param cmd Pointer to the descriptor for the command * \return 1 on success, 0 if the command was not already registered * */ AST_OPTIONAL_API(int, ast_agi_unregister, (struct ast_module *mod, agi_command *cmd), { return AST_OPTIONAL_API_UNAVAILABLE; }); /*! * \brief * * Registers a group of AGI commands, provided as an array of struct agi_command * entries. * * \param mod Pointer to the module_info structure for the module that is registering the commands * \param cmd Pointer to the first entry in the array of command descriptors * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded * * \note If any command fails to register, all commands previously registered during the operation * will be unregistered. In other words, this function registers all the provided commands, or none * of them. */ AST_OPTIONAL_API(int, ast_agi_register_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len), { return AST_OPTIONAL_API_UNAVAILABLE; }); /*! * \brief * * Unregisters a group of AGI commands, provided as an array of struct agi_command * entries. * * \param mod Pointer to the module_info structure for the module that is unregistering the commands * \param cmd Pointer to the first entry in the array of command descriptors * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded * * \note If any command fails to unregister, this function will continue to unregister the * remaining commands in the array; it will not reregister the already-unregistered commands. */ AST_OPTIONAL_API(int, ast_agi_unregister_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len), { return AST_OPTIONAL_API_UNAVAILABLE; }); /*! * \brief * * Sends a string of text to an application connected via AGI. * * \param fd The file descriptor for the AGI session (from struct agi_state) * \param chan Pointer to an associated Asterisk channel, if any * \param fmt printf-style format string * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded * */ AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send, (int fd, struct ast_channel *chan, char *fmt, ...), { return AST_OPTIONAL_API_UNAVAILABLE; }); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_AGI_H */ asterisk-11.7.0/include/asterisk/_private.h0000644000175000007640000000776612057207327020624 0ustar sharkyjerryweb/* * Prototypes for public functions only of internal interest, * normally not used by modules. * What goes here are typically *_init() routines. */ /*! \file * * \brief * Prototypes for public functions only of internal interest, * */ #ifndef _ASTERISK__PRIVATE_H #define _ASTERISK__PRIVATE_H int load_modules(unsigned int); /*!< Provided by loader.c */ int load_pbx(void); /*!< Provided by pbx.c */ int init_logger(void); /*!< Provided by logger.c */ void close_logger(void); /*!< Provided by logger.c */ void clean_time_zones(void); /*!< Provided by localtime.c */ int init_framer(void); /*!< Provided by frame.c */ int ast_term_init(void); /*!< Provided by term.c */ int astdb_init(void); /*!< Provided by db.c */ void ast_channels_init(void); /*!< Provided by channel.c */ void ast_builtins_init(void); /*!< Provided by cli.c */ int ast_cli_perms_init(int reload); /*!< Provided by cli.c */ int dnsmgr_init(void); /*!< Provided by dnsmgr.c */ void dnsmgr_start_refresh(void); /*!< Provided by dnsmgr.c */ int dnsmgr_reload(void); /*!< Provided by dnsmgr.c */ void threadstorage_init(void); /*!< Provided by threadstorage.c */ int ast_event_init(void); /*!< Provided by event.c */ int ast_device_state_engine_init(void); /*!< Provided by devicestate.c */ int astobj2_init(void); /*!< Provided by astobj2.c */ int ast_file_init(void); /*!< Provided by file.c */ int ast_features_init(void); /*!< Provided by features.c */ void ast_autoservice_init(void); /*!< Provided by autoservice.c */ int ast_data_init(void); /*!< Provided by data.c */ int ast_http_init(void); /*!< Provided by http.c */ int ast_http_reload(void); /*!< Provided by http.c */ int ast_tps_init(void); /*!< Provided by taskprocessor.c */ int ast_timing_init(void); /*!< Provided by timing.c */ int ast_indications_init(void); /*!< Provided by indications.c */ int ast_indications_reload(void);/*!< Provided by indications.c */ void ast_stun_init(void); /*!< Provided by stun.c */ int ast_cel_engine_init(void); /*!< Provided by cel.c */ int ast_cel_engine_reload(void); /*!< Provided by cel.c */ int ast_ssl_init(void); /*!< Provided by ssl.c */ int ast_test_init(void); /*!< Provided by test.c */ int ast_msg_init(void); /*!< Provided by message.c */ void ast_msg_shutdown(void); /*!< Provided by message.c */ /*! * \brief Reload asterisk modules. * \param name the name of the module to reload * * This function reloads the specified module, or if no modules are specified, * it will reload all loaded modules. * * \note Modules are reloaded using their reload() functions, not unloading * them and loading them again. * * \return 0 if the specified module was not found. * \retval 1 if the module was found but cannot be reloaded. * \retval -1 if a reload operation is already in progress. * \retval 2 if the specfied module was found and reloaded. */ int ast_module_reload(const char *name); /*! * \brief Process reload requests received during startup. * * This function requests that the loader execute the pending reload requests * that were queued during server startup. * * \note This function will do nothing if the server has not completely started * up. Once called, the reload queue is emptied, and further invocations * will have no affect. */ void ast_process_pending_reloads(void); /*! \brief Load XML documentation. Provided by xmldoc.c * \retval 1 on error. * \retval 0 on success. */ int ast_xmldoc_load_documentation(void); /*! * \brief Reload genericplc configuration value from codecs.conf * * Implementation is in main/channel.c */ int ast_plc_reload(void); /*! * \brief Init the ast_format attribute interface register container. */ int ast_format_attr_init(void); /*! * \brief Init the Asterisk global format list after all format attribute modules have been loaded */ int ast_format_list_init(void); /*! \brief initializes the rtp engine arrays */ int ast_rtp_engine_init(void); #endif /* _ASTERISK__PRIVATE_H */ asterisk-11.7.0/include/asterisk/extconf.h0000644000175000007640000002262611607704162020450 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007, Digium, Inc. * * Steve Murphy * * 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 External configuration handlers (realtime and static configuration) * \author Steve Murphy * */ #ifndef _ASTERISK_EXTCONF_H #define _ASTERISK_EXTCONF_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #ifdef NOTYET /* I'm going to define all the structs mentioned below, to avoid possible conflicts in declarations that might be introduced, if we just include the files that define them-- this may be unnecessary */ struct ast_comment { struct ast_comment *next; char cmt[0]; }; struct ast_variable { char *name; char *value; int lineno; int object; /*!< 0 for variable, 1 for object */ int blanklines; /*!< Number of blanklines following entry */ struct ast_comment *precomments; struct ast_comment *sameline; struct ast_variable *next; char stuff[0]; }; struct ast_category { char name[80]; int ignored; /*!< do not let user of the config see this category */ int include_level; struct ast_comment *precomments; struct ast_comment *sameline; struct ast_variable *root; struct ast_variable *last; struct ast_category *next; }; struct ast_config { struct ast_category *root; struct ast_category *last; struct ast_category *current; struct ast_category *last_browse; /*!< used to cache the last category supplied via category_browse */ int include_level; int max_include_level; }; /* ================== above: the config world; below, the dialplan world */ /*! \brief A registered application */ struct ast_app { int (*execute)(struct ast_channel *chan, void *data); AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(synopsis); /*!< Synopsis text for 'show applications' */ AST_STRING_FIELD(description); /*!< Description (help text) for 'show application <name>' */ AST_STRING_FIELD(syntax); /*!< Syntax text for 'core show applications' */ AST_STRING_FIELD(arguments); /*!< Arguments description */ AST_STRING_FIELD(seealso); /*!< See also */ ); enum ast_xmldoc_src docsrc; /*!< Where the documentation come from. */ AST_RWLIST_ENTRY(ast_app) list; /*!< Next app in list */ void *module; /*!< Module this app belongs to */ char name[0]; /*!< Name of the application */ }; /*! \brief An extension The dialplan is saved as a linked list with each context having it's own linked list of extensions - one item per priority. */ struct ast_exten { char *exten; /*!< Extension name */ int matchcid; /*!< Match caller id ? */ const char *cidmatch; /*!< Caller id to match for this extension */ int priority; /*!< Priority */ const char *label; /*!< Label */ struct ast_context *parent; /*!< The context this extension belongs to */ const char *app; /*!< Application to execute */ struct ast_app *cached_app; /*!< Cached location of application */ void *data; /*!< Data to use (arguments) */ void (*datad)(void *); /*!< Data destructor */ struct ast_exten *peer; /*!< Next higher priority with our extension */ const char *registrar; /*!< Registrar */ struct ast_exten *next; /*!< Extension with a greater ID */ char stuff[0]; }; /* from pbx.h */ typedef int (*ast_state_cb_type)(const char *context, const char *exten, enum ast_extension_states state, void *data); struct ast_timing { int hastime; /*!< If time construct exists */ unsigned int monthmask; /*!< Mask for month */ unsigned int daymask; /*!< Mask for date */ unsigned int dowmask; /*!< Mask for day of week (mon-sun) */ unsigned int minmask[24]; /*!< Mask for minute */ }; /*! \brief include= support in extensions.conf */ struct ast_include { const char *name; const char *rname; /*!< Context to include */ const char *registrar; /*!< Registrar */ int hastime; /*!< If time construct exists */ struct ast_timing timing; /*!< time construct */ struct ast_include *next; /*!< Link them together */ char stuff[0]; }; /*! \brief Switch statement in extensions.conf */ struct ast_sw { char *name; const char *registrar; /*!< Registrar */ char *data; /*!< Data load */ int eval; AST_LIST_ENTRY(ast_sw) list; char *tmpdata; char stuff[0]; }; /*! \brief Ignore patterns in dial plan */ struct ast_ignorepat { const char *registrar; struct ast_ignorepat *next; const char pattern[0]; }; /*! \brief An extension context */ struct ast_context { ast_rwlock_t lock; /*!< A lock to prevent multiple threads from clobbering the context */ struct ast_exten *root; /*!< The root of the list of extensions */ struct ast_context *next; /*!< Link them together */ struct ast_include *includes; /*!< Include other contexts */ struct ast_ignorepat *ignorepats; /*!< Patterns for which to continue playing dialtone */ const char *registrar; /*!< Registrar */ AST_LIST_HEAD_NOLOCK(, ast_sw) alts; /*!< Alternative switches */ ast_mutex_t macrolock; /*!< A lock to implement "exclusive" macros - held whilst a call is executing in the macro */ char name[0]; /*!< Name of the context */ }; #endif struct ast_config *localized_config_load(const char *filename); struct ast_config *localized_config_load_with_comments(const char *filename); struct ast_category *localized_category_get(const struct ast_config *config, const char *category_name); int localized_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator); struct ast_context *localized_walk_contexts(struct ast_context *con); struct ast_exten *localized_walk_context_extensions(struct ast_context *con, struct ast_exten *exten); struct ast_exten *localized_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority); struct ast_include *localized_walk_context_includes(struct ast_context *con, struct ast_include *inc); struct ast_sw *localized_walk_context_switches(struct ast_context *con, struct ast_sw *sw); void localized_context_destroy(struct ast_context *con, const char *registrar); int localized_pbx_load_module(void); /*! * \version 1.6.1 added tab parameter * \version 1.6.1 renamed function from localized_context_create to localized_context_find_or_create */ struct ast_context *localized_context_find_or_create(struct ast_context **extcontexts, void *tab, const char *name, const char *registrar); int localized_pbx_builtin_setvar(struct ast_channel *chan, const void *data); int localized_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar); int localized_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar); int localized_context_add_include2(struct ast_context *con, const char *value, const char *registrar); int localized_add_extension2(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void (*datad)(void *), const char *registrar); /*! * \version 1.6.1 added tab parameter */ void localized_merge_contexts_and_delete(struct ast_context **extcontexts, void *tab, const char *registrar); int localized_context_verify_includes(struct ast_context *con); void localized_use_conf_dir(void); void localized_use_local_dir(void); #ifndef _ASTERISK_PBX_H /*! * When looking up extensions, we can have different requests * identified by the 'action' argument, as follows. * Note that the coding is such that the low 4 bits are the * third argument to extension_match_core. */ enum ext_match_t { E_MATCHMORE = 0x00, /* extension can match but only with more 'digits' */ E_CANMATCH = 0x01, /* extension can match with or without more 'digits' */ E_MATCH = 0x02, /* extension is an exact match */ E_MATCH_MASK = 0x03, /* mask for the argument to extension_match_core() */ E_SPAWN = 0x12, /* want to spawn an extension. Requires exact match */ E_FINDLABEL = 0x22 /* returns the priority for a given label. Requires exact match */ }; #define AST_PBX_MAX_STACK 128 /* request and result for pbx_find_extension */ struct pbx_find_info { #if 0 const char *context; const char *exten; int priority; #endif char *incstack[AST_PBX_MAX_STACK]; /* filled during the search */ int stacklen; /* modified during the search */ int status; /* set on return */ struct ast_switch *swo; /* set on return */ const char *data; /* set on return */ const char *foundcontext; /* set on return */ }; #define STATUS_NO_CONTEXT 1 #define STATUS_NO_EXTENSION 2 #define STATUS_NO_PRIORITY 3 #define STATUS_NO_LABEL 4 #define STATUS_SUCCESS 5 #endif struct ast_exten *localized_find_extension(struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* _ASTERISK_PBX_H */ asterisk-11.7.0/include/asterisk/test.h0000644000175000007640000001762211624525720017761 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2009-2010, Digium, Inc. * * David Vossel * Russell Bryant * * 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 Test Framework API * * For an overview on how to use the test API, see \ref AstUnitTestAPI * * \author David Vossel * \author Russell Bryant */ #ifndef _AST_TEST_H_ #define _AST_TEST_H_ #ifdef TEST_FRAMEWORK #include "asterisk/cli.h" #include "asterisk/strings.h" #endif /*! \page AstUnitTestAPI Asterisk Unit Test API \section UnitTestAPIUsage How to Use the Unit Test API \subsection DefineTest Define a Test Create a callback function for the test using the AST_TEST_DEFINE macro. Each defined test has three arguments avaliable to it's test code. \param struct ast_test_info *info \param enum ast_test_command cmd \param struct ast_test *test While these arguments are not visible they are passed to every test function defined using the AST_TEST_DEFINE macro. Below is an example of how to define and write a test function. \code AST_TEST_DEFINE(sample_test_cb) \\The name of the callback function { \\The the function's body switch (cmd) { case TEST_INIT: info->name = "sample_test"; info->category = "main/test/"; info->summary = "sample test for example purpose"; info->description = "This demonstrates how to initialize a test function"; return AST_TEST_NOT_RUN; case TEST_EXECUTE: break; } \test code . . . if (fail) { \\ the following is just some example logic ast_test_status_update(test, "an error occured because..."); res = AST_RESULT_FAIL; } else { res = AST_RESULT_PASS } return res; \\ result must be of type enum ast_test_result_state } \endcode Details of the test execution, especially failure details, should be provided by using the ast_test_status_update() function. \subsection RegisterTest Register a Test Register the test using the AST_TEST_REGISTER macro. AST_TEST_REGISTER uses the callback function to retrieve all the information pertaining to a test, so the callback function is the only argument required for registering a test. AST_TEST_REGISTER(sample_test_cb); \\ Test callback function defined by AST_TEST_DEFINE Tests are unregestered by using the AST_TEST_UNREGISTER macro. AST_TEST_UNREGISTER(sample_test_cb); \\ Remove a registered test by callback function \subsection ExecuteTest Execute a Test Execute and generate test results via CLI commands CLI Examples: \code 'test show registered all' will show every registered test. 'test execute all' will execute every registered test. 'test show results all' will show detailed results for ever executed test 'test generate results xml' will generate a test report in xml format 'test generate results txt' will generate a test report in txt format \endcode */ /*! Macros used for defining and registering a test */ #ifdef TEST_FRAMEWORK #define AST_TEST_DEFINE(hdr) static enum ast_test_result_state hdr(struct ast_test_info *info, enum ast_test_command cmd, struct ast_test *test) #define AST_TEST_REGISTER(cb) ast_test_register(cb) #define AST_TEST_UNREGISTER(cb) ast_test_unregister(cb) #else #define AST_TEST_DEFINE(hdr) static enum ast_test_result_state attribute_unused hdr(struct ast_test_info *info, enum ast_test_command cmd, struct ast_test *test) #define AST_TEST_REGISTER(cb) #define AST_TEST_UNREGISTER(cb) #define ast_test_status_update(a,b,c...) #endif /*! Macros used for the Asterisk Test Suite AMI events */ #ifdef TEST_FRAMEWORK /*! * \brief Notifies the test suite of a change in application state * * \details * Raises a TestEvent manager event with a subtype of StateChange. Additional parameters * The fmt parameter allows additional parameters to be added to the manager event using * printf style statement formatting. * * \param state The state the application has changed to * \param fmt The message with format parameters to add to the manager event * * \returns 0 on success * \returns any other value on failure */ int __ast_test_suite_event_notify(const char *file, const char *func, int line, const char *state, const char *fmt, ...) __attribute__((format(printf, 5, 6))); /*! * \brief Notifies the test suite of a failed assert on an expression * * \details * If the expression provided evaluates to true, no action is taken. If the expression * evaluates to a false, a TestEvent manager event is raised with a subtype of Assert, notifying * the test suite that the expression failed to evaluate to true. * * \param exp The expression to evaluate * * \returns 0 on success * \returns any other value on failure */ int __ast_test_suite_assert_notify(const char *file, const char *func, int line, const char *exp); /*! * \ref __ast_test_suite_event_notify() */ #define ast_test_suite_event_notify(s, f, ...) \ __ast_test_suite_event_notify(__FILE__, __PRETTY_FUNCTION__, __LINE__, (s), (f), ## __VA_ARGS__) /*! * \ref __ast_test_suite_assert_notify() */ #define ast_test_suite_assert(exp) \ ( (exp) ? (void)0 : __ast_test_suite_assert_notify(__FILE__, __PRETTY_FUNCTION__, __LINE__, #exp)) #else #define ast_test_suite_event_notify(s, f, ...) (void)0; #define ast_test_suite_assert(exp) (void)0; #endif enum ast_test_result_state { AST_TEST_NOT_RUN, AST_TEST_PASS, AST_TEST_FAIL, }; enum ast_test_command { TEST_INIT, TEST_EXECUTE, }; /*! * \brief An Asterisk unit test. * * This is an opaque type. */ struct ast_test; /*! * \brief Contains all the initialization information required to store a new test definition */ struct ast_test_info { /*! \brief name of test, unique to category */ const char *name; /*! * \brief test category * * Tests are categorized in a directory tree style hierarchy. It is expected that * this string have both a leading and trailing forward slash ('/'). */ const char *category; /*! \brief optional short summary of test */ const char *summary; /*! \brief optional brief detailed description of test */ const char *description; }; #ifdef TEST_FRAMEWORK /*! * \brief Generic test callback function * * \param error buffer string for failure results * * \retval AST_TEST_PASS for pass * \retval AST_TEST_FAIL for failure */ typedef enum ast_test_result_state (ast_test_cb_t)(struct ast_test_info *info, enum ast_test_command cmd, struct ast_test *test); /*! * \brief unregisters a test with the test framework * * \param test callback function (required) * * \retval 0 success * \retval -1 failure */ int ast_test_unregister(ast_test_cb_t *cb); /*! * \brief registers a test with the test framework * * \param test callback function (required) * * \retval 0 success * \retval -1 failure */ int ast_test_register(ast_test_cb_t *cb); /*! * \brief update test's status during testing. * * \param test currently executing test * * \retval 0 success * \retval -1 failure */ int __ast_test_status_update(const char *file, const char *func, int line, struct ast_test *test, const char *fmt, ...) __attribute__((format(printf, 5, 6))); /*! * \ref __ast_test_status_update() */ #define ast_test_status_update(t, f, ...) __ast_test_status_update(__FILE__, __PRETTY_FUNCTION__, __LINE__, (t), (f), ## __VA_ARGS__) #endif /* TEST_FRAMEWORK */ #endif /* _AST_TEST_H */ asterisk-11.7.0/include/asterisk/sip_api.h0000644000175000007640000000404112035563076020420 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Digium, Inc. * * Mark Michelson * * 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. */ #ifndef __ASTERISK_SIP_H #define __ASTERISK_SIP_H #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #include "asterisk/optional_api.h" #include "asterisk/config.h" #define AST_SIP_API_VERSION 1 struct ast_sip_api_tech { const int version; const char *name; int (*sipinfo_send)(struct ast_channel *chan, struct ast_variable *headers, const char *content_type, const char *content, const char *useragent_filter); }; /*! * \brief Send a customized SIP INFO request * * \param headers The headers to add to the INFO request * \param content_type The content type header to add * \param conten The body of the INFO request * \param useragent_filter If non-NULL, only send the INFO if the * recipient's User-Agent contains useragent_filter as a substring * * \retval 0 Success * \retval non-zero Failure */ int ast_sipinfo_send(struct ast_channel *chan, struct ast_variable *headers, const char *content_type, const char *content, const char *useragent_filter); /*! * \brief Register a SIP API provider * * This will fail if a provider has already registered or if the * provider is using an incorrect version. * * \param provider The provider to register * \retval 0 Success * \retval -1 Failure */ int ast_sip_api_provider_register(const struct ast_sip_api_tech *provider); /*! * \brief Unregister a SIP API provider */ void ast_sip_api_provider_unregister(void); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif /* __ASTERISK_SIP_H */ asterisk-11.7.0/include/asterisk/poll-compat.h0000644000175000007640000000761111437627776021246 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * 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. */ /*---------------------------------------------------------------------------*\ $Id: poll-compat.h 284598 2010-09-02 05:02:54Z tilghman $ NAME poll - select(2)-based poll() emulation function for BSD systems. SYNOPSIS #include "poll.h" struct pollfd { int fd; short events; short revents; } int poll (struct pollfd *pArray, unsigned long n_fds, int timeout) DESCRIPTION This file, and the accompanying "poll.c", implement the System V poll(2) system call for BSD systems (which typically do not provide poll()). Poll() provides a method for multiplexing input and output on multiple open file descriptors; in traditional BSD systems, that capability is provided by select(). While the semantics of select() differ from those of poll(), poll() can be readily emulated in terms of select() -- which is how this function is implemented. REFERENCES Stevens, W. Richard. Unix Network Programming. Prentice-Hall, 1990. NOTES 1. This software requires an ANSI C compiler. LICENSE This software is released under the following license: Copyright (c) 1995-2002 Brian M. Clapper All rights reserved. Redistribution and use in source and binary forms are permitted provided that: (1) source distributions retain this entire copyright notice and comment; (2) modifications made to the software are prominently mentioned, and a copy of the original software (or a pointer to its location) are included; and (3) distributions including binaries display the following acknowledgement: "This product includes software developed by Brian M. Clapper " in the documentation or other materials provided with the distribution. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Effectively, this means you can do what you want with the software except remove this notice or take advantage of the author's name. If you modify the software and redistribute your modified version, you must indicate that your version is a modification of the original, and you must provide either a pointer to or a copy of the original. \*---------------------------------------------------------------------------*/ #ifndef __AST_POLL_COMPAT_H #define __AST_POLL_COMPAT_H #include "asterisk/select.h" #ifndef AST_POLL_COMPAT #include #define ast_poll(a, b, c) poll(a, b, c) #else /* AST_POLL_COMPAT */ #define POLLIN 0x01 #define POLLPRI 0x02 #define POLLOUT 0x04 #define POLLERR 0x08 #define POLLHUP 0x10 #define POLLNVAL 0x20 struct pollfd { int fd; short events; short revents; }; #ifdef __cplusplus extern "C" { #endif #define ast_poll(a, b, c) ast_internal_poll(a, b, c) int ast_internal_poll(struct pollfd *pArray, unsigned long n_fds, int timeout); #ifdef __cplusplus } #endif #endif /* AST_POLL_COMPAT */ /*! * \brief Same as poll(2), except the time is specified in microseconds and * the tv argument is modified to indicate the time remaining. */ int ast_poll2(struct pollfd *pArray, unsigned long n_fds, struct timeval *tv); /*! * \brief Shortcut for conversion of FD_ISSET to poll(2)-based */ static inline int ast_poll_fd_index(struct pollfd *haystack, int nfds, int needle) { int i; for (i = 0; i < nfds; i++) { if (haystack[i].fd == needle) { return i; } } return -1; } #endif /* __AST_POLL_COMPAT_H */ asterisk-11.7.0/include/solaris-compat/0000755000175000007640000000000012254071123017722 5ustar sharkyjerrywebasterisk-11.7.0/include/solaris-compat/sys/0000755000175000007640000000000012254071123020540 5ustar sharkyjerrywebasterisk-11.7.0/include/solaris-compat/sys/cdefs.h0000644000175000007640000000016410374426007022004 0ustar sharkyjerryweb#ifndef __SYS_CDEFS_H_ #define __SYS_CDEFS_H_ #define __BEGIN_DECLS #define __END_DECLS #define __P(p) p #endif asterisk-11.7.0/include/solaris-compat/sys/queue.h0000644000175000007640000006104510374426007022051 0ustar sharkyjerryweb/* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)queue.h 8.5 (Berkeley) 8/20/94 * $FreeBSD: src/sys/sys/queue.h,v 1.24.2.4 2000/05/05 01:41:41 archie Exp $ */ #ifndef _SYS_QUEUE_H_ #define _SYS_QUEUE_H_ /* * This file defines five types of data structures: singly-linked lists, * singly-linked tail queues, lists, tail queues, and circular queues. * * A singly-linked list is headed by a single forward pointer. The elements * are singly linked for minimum space and pointer manipulation overhead at * the expense of O(n) removal for arbitrary elements. New elements can be * added to the list after an existing element or at the head of the list. * Elements being removed from the head of the list should use the explicit * macro for this purpose for optimum efficiency. A singly-linked list may * only be traversed in the forward direction. Singly-linked lists are ideal * for applications with large datasets and few or no removals or for * implementing a LIFO queue. * * A singly-linked tail queue is headed by a pair of pointers, one to the * head of the list and the other to the tail of the list. The elements are * singly linked for minimum space and pointer manipulation overhead at the * expense of O(n) removal for arbitrary elements. New elements can be added * to the list after an existing element, at the head of the list, or at the * end of the list. Elements being removed from the head of the tail queue * should use the explicit macro for this purpose for optimum efficiency. * A singly-linked tail queue may only be traversed in the forward direction. * Singly-linked tail queues are ideal for applications with large datasets * and few or no removals or for implementing a FIFO queue. * * A list is headed by a single forward pointer (or an array of forward * pointers for a hash table header). The elements are doubly linked * so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before * or after an existing element or at the head of the list. A list * may only be traversed in the forward direction. * * A tail queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly * linked so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before or * after an existing element, at the head of the list, or at the end of * the list. A tail queue may be traversed in either direction. * * A circle queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly * linked so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before or after * an existing element, at the head of the list, or at the end of the list. * A circle queue may be traversed in either direction, but has a more * complex end of list detection. * * For details on the use of these macros, see the queue(3) manual page. * * * SLIST LIST STAILQ TAILQ CIRCLEQ * _HEAD + + + + + * _ENTRY + + + + + * _INIT + + + + + * _EMPTY + + + + + * _FIRST + + + + + * _NEXT + + + + + * _PREV - - - + + * _LAST - - + + + * _FOREACH + + + + + * _FOREACH_REVERSE - - - + + * _INSERT_HEAD + + + + + * _INSERT_BEFORE - + - + + * _INSERT_AFTER + + + + + * _INSERT_TAIL - - + + + * _REMOVE_HEAD + - + - - * _REMOVE + + + + + * */ /* * Singly-linked List definitions. */ #define SLIST_HEAD(name, type) \ struct name { \ struct type *slh_first; /* first element */ \ } #define SLIST_HEAD_INITIALIZER(head) \ { NULL } #define SLIST_ENTRY(type) \ struct { \ struct type *sle_next; /* next element */ \ } /* * Singly-linked List functions. */ #define SLIST_EMPTY(head) ((head)->slh_first == NULL) #define SLIST_FIRST(head) ((head)->slh_first) #define SLIST_FOREACH(var, head, field) \ for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) #define SLIST_INIT(head) { \ (head)->slh_first = NULL; \ } #define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ (elm)->field.sle_next = (slistelm)->field.sle_next; \ (slistelm)->field.sle_next = (elm); \ } while (0) #define SLIST_INSERT_HEAD(head, elm, field) do { \ (elm)->field.sle_next = (head)->slh_first; \ (head)->slh_first = (elm); \ } while (0) #define SLIST_NEXT(elm, field) ((elm)->field.sle_next) #define SLIST_REMOVE_HEAD(head, field) do { \ (head)->slh_first = (head)->slh_first->field.sle_next; \ } while (0) #define SLIST_REMOVE(head, elm, type, field) do { \ if ((head)->slh_first == (elm)) { \ SLIST_REMOVE_HEAD((head), field); \ } \ else { \ struct type *curelm = (head)->slh_first; \ while( curelm->field.sle_next != (elm) ) \ curelm = curelm->field.sle_next; \ curelm->field.sle_next = \ curelm->field.sle_next->field.sle_next; \ } \ } while (0) /* * Singly-linked Tail queue definitions. */ #define STAILQ_HEAD(name, type) \ struct name { \ struct type *stqh_first;/* first element */ \ struct type **stqh_last;/* addr of last next element */ \ } #define STAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).stqh_first } #define STAILQ_ENTRY(type) \ struct { \ struct type *stqe_next; /* next element */ \ } /* * Singly-linked Tail queue functions. */ #define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) #define STAILQ_INIT(head) do { \ (head)->stqh_first = NULL; \ (head)->stqh_last = &(head)->stqh_first; \ } while (0) #define STAILQ_FIRST(head) ((head)->stqh_first) #define STAILQ_LAST(head) (*(head)->stqh_last) #define STAILQ_FOREACH(var, head, field) \ for((var) = (head)->stqh_first; (var); (var) = (var)->field.stqe_next) #define STAILQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ (head)->stqh_last = &(elm)->field.stqe_next; \ (head)->stqh_first = (elm); \ } while (0) #define STAILQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.stqe_next = NULL; \ *(head)->stqh_last = (elm); \ (head)->stqh_last = &(elm)->field.stqe_next; \ } while (0) #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ if (((elm)->field.stqe_next = (tqelm)->field.stqe_next) == NULL)\ (head)->stqh_last = &(elm)->field.stqe_next; \ (tqelm)->field.stqe_next = (elm); \ } while (0) #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) #define STAILQ_REMOVE_HEAD(head, field) do { \ if (((head)->stqh_first = \ (head)->stqh_first->field.stqe_next) == NULL) \ (head)->stqh_last = &(head)->stqh_first; \ } while (0) #define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ if (((head)->stqh_first = (elm)->field.stqe_next) == NULL) \ (head)->stqh_last = &(head)->stqh_first; \ } while (0) #define STAILQ_REMOVE(head, elm, type, field) do { \ if ((head)->stqh_first == (elm)) { \ STAILQ_REMOVE_HEAD(head, field); \ } \ else { \ struct type *curelm = (head)->stqh_first; \ while( curelm->field.stqe_next != (elm) ) \ curelm = curelm->field.stqe_next; \ if((curelm->field.stqe_next = \ curelm->field.stqe_next->field.stqe_next) == NULL) \ (head)->stqh_last = &(curelm)->field.stqe_next; \ } \ } while (0) /* * List definitions. */ #define LIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ } #define LIST_HEAD_INITIALIZER(head) \ { NULL } #define LIST_ENTRY(type) \ struct { \ struct type *le_next; /* next element */ \ struct type **le_prev; /* address of previous next element */ \ } /* * List functions. */ #define LIST_EMPTY(head) ((head)->lh_first == NULL) #define LIST_FIRST(head) ((head)->lh_first) #define LIST_FOREACH(var, head, field) \ for((var) = (head)->lh_first; (var); (var) = (var)->field.le_next) #define LIST_INIT(head) do { \ (head)->lh_first = NULL; \ } while (0) #define LIST_INSERT_AFTER(listelm, elm, field) do { \ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ (listelm)->field.le_next->field.le_prev = \ &(elm)->field.le_next; \ (listelm)->field.le_next = (elm); \ (elm)->field.le_prev = &(listelm)->field.le_next; \ } while (0) #define LIST_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.le_prev = (listelm)->field.le_prev; \ (elm)->field.le_next = (listelm); \ *(listelm)->field.le_prev = (elm); \ (listelm)->field.le_prev = &(elm)->field.le_next; \ } while (0) #define LIST_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.le_next = (head)->lh_first) != NULL) \ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ (head)->lh_first = (elm); \ (elm)->field.le_prev = &(head)->lh_first; \ } while (0) #define LIST_NEXT(elm, field) ((elm)->field.le_next) #define LIST_REMOVE(elm, field) do { \ if ((elm)->field.le_next != NULL) \ (elm)->field.le_next->field.le_prev = \ (elm)->field.le_prev; \ *(elm)->field.le_prev = (elm)->field.le_next; \ } while (0) /* * Tail queue definitions. */ #define TAILQ_HEAD(name, type) \ struct name { \ struct type *tqh_first; /* first element */ \ struct type **tqh_last; /* addr of last next element */ \ } #define TAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).tqh_first } #define TAILQ_ENTRY(type) \ struct { \ struct type *tqe_next; /* next element */ \ struct type **tqe_prev; /* address of previous next element */ \ } /* * Tail queue functions. */ #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) #define TAILQ_FOREACH(var, head, field) \ for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field)) #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = TAILQ_LAST((head), headname); \ (var); \ (var) = TAILQ_PREV((var), headname, field)) #define TAILQ_FIRST(head) ((head)->tqh_first) #define TAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) #define TAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) #define TAILQ_INIT(head) do { \ (head)->tqh_first = NULL; \ (head)->tqh_last = &(head)->tqh_first; \ } while (0) #define TAILQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ (head)->tqh_first->field.tqe_prev = \ &(elm)->field.tqe_next; \ else \ (head)->tqh_last = &(elm)->field.tqe_next; \ (head)->tqh_first = (elm); \ (elm)->field.tqe_prev = &(head)->tqh_first; \ } while (0) #define TAILQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.tqe_next = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ *(head)->tqh_last = (elm); \ (head)->tqh_last = &(elm)->field.tqe_next; \ } while (0) #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ (elm)->field.tqe_next->field.tqe_prev = \ &(elm)->field.tqe_next; \ else \ (head)->tqh_last = &(elm)->field.tqe_next; \ (listelm)->field.tqe_next = (elm); \ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ } while (0) #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ (elm)->field.tqe_next = (listelm); \ *(listelm)->field.tqe_prev = (elm); \ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ } while (0) #define TAILQ_REMOVE(head, elm, field) do { \ if (((elm)->field.tqe_next) != NULL) \ (elm)->field.tqe_next->field.tqe_prev = \ (elm)->field.tqe_prev; \ else \ (head)->tqh_last = (elm)->field.tqe_prev; \ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ } while (0) /* * Circular queue definitions. */ #define CIRCLEQ_HEAD(name, type) \ struct name { \ struct type *cqh_first; /* first element */ \ struct type *cqh_last; /* last element */ \ } #define CIRCLEQ_ENTRY(type) \ struct { \ struct type *cqe_next; /* next element */ \ struct type *cqe_prev; /* previous element */ \ } /* * Circular queue functions. */ #define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) #define CIRCLEQ_FIRST(head) ((head)->cqh_first) #define CIRCLEQ_FOREACH(var, head, field) \ for((var) = (head)->cqh_first; \ (var) != (void *)(head); \ (var) = (var)->field.cqe_next) #define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ for((var) = (head)->cqh_last; \ (var) != (void *)(head); \ (var) = (var)->field.cqe_prev) #define CIRCLEQ_INIT(head) do { \ (head)->cqh_first = (void *)(head); \ (head)->cqh_last = (void *)(head); \ } while (0) #define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ (elm)->field.cqe_next = (listelm)->field.cqe_next; \ (elm)->field.cqe_prev = (listelm); \ if ((listelm)->field.cqe_next == (void *)(head)) \ (head)->cqh_last = (elm); \ else \ (listelm)->field.cqe_next->field.cqe_prev = (elm); \ (listelm)->field.cqe_next = (elm); \ } while (0) #define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ (elm)->field.cqe_next = (listelm); \ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ if ((listelm)->field.cqe_prev == (void *)(head)) \ (head)->cqh_first = (elm); \ else \ (listelm)->field.cqe_prev->field.cqe_next = (elm); \ (listelm)->field.cqe_prev = (elm); \ } while (0) #define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ (elm)->field.cqe_next = (head)->cqh_first; \ (elm)->field.cqe_prev = (void *)(head); \ if ((head)->cqh_last == (void *)(head)) \ (head)->cqh_last = (elm); \ else \ (head)->cqh_first->field.cqe_prev = (elm); \ (head)->cqh_first = (elm); \ } while (0) #define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.cqe_next = (void *)(head); \ (elm)->field.cqe_prev = (head)->cqh_last; \ if ((head)->cqh_first == (void *)(head)) \ (head)->cqh_first = (elm); \ else \ (head)->cqh_last->field.cqe_next = (elm); \ (head)->cqh_last = (elm); \ } while (0) #define CIRCLEQ_LAST(head) ((head)->cqh_last) #define CIRCLEQ_NEXT(elm,field) ((elm)->field.cqe_next) #define CIRCLEQ_PREV(elm,field) ((elm)->field.cqe_prev) #define CIRCLEQ_REMOVE(head, elm, field) do { \ if ((elm)->field.cqe_next == (void *)(head)) \ (head)->cqh_last = (elm)->field.cqe_prev; \ else \ (elm)->field.cqe_next->field.cqe_prev = \ (elm)->field.cqe_prev; \ if ((elm)->field.cqe_prev == (void *)(head)) \ (head)->cqh_first = (elm)->field.cqe_next; \ else \ (elm)->field.cqe_prev->field.cqe_next = \ (elm)->field.cqe_next; \ } while (0) #ifdef KERNEL /* * XXX insque() and remque() are an old way of handling certain queues. * They bogusly assumes that all queue heads look alike. */ struct quehead { struct quehead *qh_link; struct quehead *qh_rlink; }; #ifdef __GNUC__ static __inline void insque(void *a, void *b) { struct quehead *element = a, *head = b; element->qh_link = head->qh_link; element->qh_rlink = head; head->qh_link = element; element->qh_link->qh_rlink = element; } static __inline void remque(void *a) { struct quehead *element = a; element->qh_link->qh_rlink = element->qh_rlink; element->qh_rlink->qh_link = element->qh_link; element->qh_rlink = 0; } #else /* !__GNUC__ */ void insque __P((void *a, void *b)); void remque __P((void *a)); #endif /* __GNUC__ */ #endif /* KERNEL */ #endif /* !_SYS_QUEUE_H_ */ asterisk-11.7.0/include/solaris-compat/compat.h0000644000175000007640000000160410412404624021357 0ustar sharkyjerryweb#ifndef _SOLARIS_COMPAT_H #define _SOLARIS_COMPAT_H #define __BEGIN_DECLS #define __END_DECLS #ifndef __P #define __P(p) p #endif #include #include #include #include #include #include #include #ifndef BYTE_ORDER #define LITTLE_ENDIAN 1234 #define BIG_ENDIAN 4321 #ifdef __sparc__ #define BYTE_ORDER BIG_ENDIAN #else #define BYTE_ORDER LITTLE_ENDIAN #endif #endif #ifndef __BYTE_ORDER #define __LITTLE_ENDIAN LITTLE_ENDIAN #define __BIG_ENDIAN BIG_ENDIAN #define __BYTE_ORDER BYTE_ORDER #endif #ifndef __BIT_TYPES_DEFINED__ #define __BIT_TYPES_DEFINED__ typedef unsigned char u_int8_t; typedef unsigned short u_int16_t; typedef unsigned int u_int32_t; #endif char* strsep(char** str, const char* delims); int setenv(const char *name, const char *value, int overwrite); int unsetenv(const char *name); #endif asterisk-11.7.0/build_tools/0000755000175000007640000000000012254071117015664 5ustar sharkyjerrywebasterisk-11.7.0/build_tools/make_sample_voicemail0000755000175000007640000000137411506676323022136 0ustar sharkyjerryweb#!/bin/sh -e for lang in /en/ /fr/ /es/ do for format in ulaw alaw wav gsm g729 g722 do [ ! -f "${1}/sounds${lang}vm-isunavail.${format}" ] && continue mkdir -p "${2}/voicemail/default/1234${lang}" : > "${2}/voicemail/default/1234${lang}unavail.${format}" for file in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail do cat "${1}/sounds${lang}${file}.${format}" >> "${2}/voicemail/default/1234${lang}unavail.${format}" done : > "${2}/voicemail/default/1234${lang}busy.${format}" for file in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone do cat "${1}/sounds${lang}${file}.${format}" >> "${2}/voicemail/default/1234${lang}busy.${format}" done done done asterisk-11.7.0/build_tools/make_linker_version_script0000755000175000007640000000035311357402676023240 0ustar sharkyjerryweb#!/bin/sh test -f ${1}.exports.in && ${AWK} "{sub(\"LINKER_SYMBOL_PREFIX\", \"${2}\"); print;}" ${1}.exports.in > ${1}.exports && exit 0 test -f ${1}.exports.in || rm -f ${1}.exports && cp ${3}/default.exports ${1}.exports && exit 0 asterisk-11.7.0/build_tools/make_buildopts_h0000755000175000007640000000141311110656601021117 0ustar sharkyjerryweb#!/bin/sh cat << END /* * buildopts.h * Automatically generated */ END TMP=`${GREP} -e "^MENUSELECT_CFLAGS" menuselect.makeopts | sed 's/MENUSELECT_CFLAGS\=//g' | sed 's/-D//g'` for x in ${TMP}; do echo "#define ${x} 1" if test "x${BUILDOPTS}" != "x" ; then BUILDOPTS="${BUILDOPTS}, ${x}" else BUILDOPTS="${x}" fi done TMP=`${GREP} -e "^MENUSELECT_BUILD_DEPS" menuselect.makeopts | sed 's/MENUSELECT_BUILD_DEPS\=//g'` for x in ${TMP}; do x2=`echo ${x} | tr a-z A-Z` echo "#define AST_MODULE_${x2} 1" done if ${GREP} "AST_DEVMODE" makeopts | ${GREP} -q "yes" then echo "#define AST_DEVMODE 1" TMP="${TMP} AST_DEVMODE" fi BUILDSUM=`echo ${TMP} | ${MD5} | cut -c1-32` echo "#define AST_BUILDOPT_SUM \"${BUILDSUM}\"" echo "#define AST_BUILDOPTS \"${BUILDOPTS}\"" asterisk-11.7.0/build_tools/menuselect-deps.in0000644000175000007640000000261212131613047021310 0ustar sharkyjerrywebALSA=@PBX_ALSA@ BLUETOOTH=@PBX_BLUETOOTH@ COROSYNC=@PBX_COROSYNC@ CRYPTO=@PBX_CRYPTO@ BFD=@PBX_BFD@ BISON=@PBX_BISON@ CURL=@PBX_CURL@ DAHDI=@PBX_DAHDI@ DLADDR=@PBX_DLADDR@ FLEX=@PBX_FLEX@ FREETDS=@PBX_FREETDS@ GENERIC_ODBC=@PBX_GENERIC_ODBC@ GMIME=@PBX_GMIME@ GNU_LD=@GNU_LD@ GSM=@PBX_GSM@ ILBC=@PBX_ILBC@ GTK2=@PBX_GTK2@ H323=@PBX_H323@ HOARD=@PBX_HOARD@ ICAL=@PBX_ICAL@ ICONV=@PBX_ICONV@ IKSEMEL=@PBX_IKSEMEL@ IMAP_TK=@PBX_IMAP_TK@ IODBC=@PBX_IODBC@ ISDNNET=@PBX_ISDNNET@ IXJUSER=@PBX_IXJUSER@ JACK=@PBX_JACK@ KQUEUE=@PBX_KQUEUE@ LDAP=@PBX_LDAP@ LIBEDIT=@PBX_LIBEDIT@ LIBXML2=@PBX_LIBXML2@ LTDL=@PBX_LTDL@ LUA=@PBX_LUA@ MISDN=@PBX_MISDN@ MYSQLCLIENT=@PBX_MYSQLCLIENT@ NBS=@PBX_NBS@ NETSNMP=@PBX_NETSNMP@ NEWT=@PBX_NEWT@ NEON=@PBX_NEON@ NEON29=@PBX_NEON29@ OGG=@PBX_OGG@ OPENH323=@PBX_OPENH323@ OSPTK=@PBX_OSPTK@ OSS=@PBX_OSS@ PGSQL=@PBX_PGSQL@ POPT=@PBX_POPT@ PORTAUDIO=@PBX_PORTAUDIO@ PRI=@PBX_PRI@ OPENR2=@PBX_OPENR2@ RESAMPLE=@PBX_RESAMPLE@ RADIUS=@PBX_RADIUS@ LAUNCHD=@PBX_LAUNCHD@ SPANDSP=@PBX_SPANDSP@ SPEEX=@PBX_SPEEX@ SPEEXDSP=@PBX_SPEEXDSP@ SPEEX_PREPROCESS=@PBX_SPEEX_PREPROCESS@ SQLITE3=@PBX_SQLITE3@ SQLITE=@PBX_SQLITE@ SRTP=@PBX_SRTP@ SS7=@PBX_SS7@ OPENSSL=@PBX_OPENSSL@ SUPPSERV=@PBX_SUPPSERV@ SYSLOG=@PBX_SYSLOG@ TONEZONE=@PBX_TONEZONE@ UNIXODBC=@PBX_UNIXODBC@ UUID=@PBX_UUID@ VORBIS=@PBX_VORBIS@ VPB=@PBX_VPB@ WINARCH=@PBX_WINARCH@ ZLIB=@PBX_ZLIB@ TIMERFD=@PBX_TIMERFD@ NATIVE_ARCH=@AST_NATIVE_ARCH@ asterisk-11.7.0/build_tools/cflags.xml0000644000175000007640000000774412013565363017665 0ustar sharkyjerryweb core core extended yes core core bison flex no extended extended BFD DLADDR no core no hoard extended core extended no extended G711_NEW_ALGORITHM extended G711_NEW_ALGORITHM extended G711_NEW_ALGORITHM extended core BUSYDETECT_COMPARE_TONE_AND_SILENCE no extended BUSYDETECT_TONEONLY no extended no extended extended core yes native_arch asterisk-11.7.0/build_tools/sha1sum-sh0000755000175000007640000000207512133015136017602 0ustar sharkyjerryweb#!/bin/sh check=0 status=0 while [ x"$1" != x ]; do case $1 in -c) check=1 shift continue;; --status) status=1 shift continue;; -*) if [ $status = 0 ]; then echo "Unrecognized option $1" 1>&2 fi exit 1 ;; *) dst=$1 shift continue;; esac done if [ x"$dst" = x ]; then if [ $status = 0 ]; then echo "Usage: $0 [] " 1>&2 fi exit 1 fi if [ $check = 1 ]; then if [ -f $dst ]; then sum1=`cut -d' ' -f1 $dst` file=`cut -d' ' -f3 $dst` sum2=`openssl sha1 $file | cut -d' ' -f2` if [ x"$sum1" = x"$sum2" ]; then if [ $status = 0 ]; then echo "$dst: OK" fi exit 0 else if [ $status = 0 ]; then echo "$dst: FAILED" fi exit 1 fi else echo "$0: $dst: No such file or directory" 1>&2 exit 1 fi else if [ x"$status" = x1 ]; then echo "$0: the --status option is meaningful only when verifying checksums" 1>&2 exit 1 fi if [ -f $dst ]; then sum=`openssl sha1 $dst | cut -d' ' -f2` echo "$dst $sum" exit 0 else echo "$0: $dst: No such file or directory" 1>&2 exit 1 fi fi asterisk-11.7.0/build_tools/get_documentation.py0000644000175000007640000001344711772123406021762 0ustar sharkyjerryweb#! /usr/bin/env python # vin: sw=3 et: ''' Copyright (C) 2012, Digium, Inc. Matt Jordan This program is free software, distributed under the terms of the GNU General Public License Version 2. ''' import sys import os import xml.dom.minidom from xml.dom.minidom import Element def get_manager_event_method_type(candidate_string): if "ast_manager_event_multichan" in candidate_string: return "multichan" elif "ast_manager_event" in candidate_string: return "ast_manager_event" elif "manager_event" in candidate_string: return "manager_event" return "" def parse_manager_event_instance(xml_fragment): ''' Parse the information for a manager event Keyword Arguments: xml_fragment The XML fragment comment Returns: A well-formed XML fragment containing the comments passed in, as well as information obtained from the manager_event macro calls ''' def __node_contains_parameter(node, parameter): ''' Return whether or not a node contains a given parameter name ''' return any([n for n in node.getElementsByTagName("parameter") if __node_contains_attribute(n, parameter)]) def __node_contains_attribute(node, attribute_name): ''' Return whether or not a node contains a given attribute name ''' return any([attr for attr in node.attributes.items() if attr[1] == attribute_name]) candidate_lines = [] type = "" # Read the manager_event method call, which should occur after # the documentation block for line in sys.stdin: if len(line): candidate_lines.append(line) if ");" in line: break candidate_string = ''.join(candidate_lines) type = get_manager_event_method_type(candidate_string) if not type: # Unknown, return what we have return ''.join(xml_fragment) # strip off the macro name first_paren = candidate_string.index("(", 0) last_paren = candidate_string.rindex(");") candidate_string = candidate_string[first_paren + 1:last_paren] # split into parameter tokens func_parameter_tokens = candidate_string.split(',') if type == "manager_event" or type == "multichan": class_level = func_parameter_tokens[0].strip() event_type = func_parameter_tokens[1].strip() else: class_level = func_parameter_tokens[1].strip() event_type = func_parameter_tokens[2].strip() if type == "manager_event": event_parameters = func_parameter_tokens[2].strip() elif type == "ast_manager_event": event_parameters = func_parameter_tokens[3].strip() else: event_parameters = func_parameter_tokens[4].strip() parameter_tokens = event_parameters.replace("\"", "").split('\\r\\n') # Build the top level XML element information. Note that we temporarily # add the xi namespace in case any includes are used node_text = '' xml_fragment.insert(0, node_text % ('en_US', event_type.strip().replace("\"", ""), 'http://www.w3.org/2001/XInclude')) xml_fragment[1] = "" % (class_level) xml_fragment.insert(len(xml_fragment), "") # Turn the XML into a DOM to manage the rest of the node manipulations dom = xml.dom.minidom.parseString(''.join(xml_fragment)) # Get the syntax node if we have one; otherwise make one instance = dom.getElementsByTagName("managerEventInstance")[0] syntax = instance.getElementsByTagName("syntax") if not syntax: syntax = dom.createElement("syntax") instance.appendChild(syntax) # Move any existing parameter nodes over for node in instance.getElementsByTagName("parameter"): syntax.appendChild(node.cloneNode(True)) instance.removeChild(node) else: syntax = syntax[0] # Add parameters found in the method invocation that were not previously # documented for parameter in parameter_tokens: if not len(parameter): continue index = parameter.find(':') if index < 0: index = len(parameter) parameter = (parameter[:index].strip().replace("\"", "")) if ('%s' not in parameter and not __node_contains_parameter(syntax, parameter)): e = dom.createElement("parameter") e.setAttribute('name', parameter) syntax.appendChild(e) return dom.toxml().replace("", "").replace( 'xmlns:xi="http://www.w3.org/2001/XInclude"', '') def main(argv=None): if argv is None: argv = sys.argv in_doc = False xml_fragment = [] xml = [] line_number = 0 for line in sys.stdin: # Note: multiple places may have to read a line, so iterating over # readlines isn't possible. Break when a null line is returned line_number += 1 if not line: break line = line.strip() if ("/*** DOCUMENTATION" in line): in_doc = True elif ("***/" in line and in_doc): # Depending on what we're processing, determine if we need to do # any additional work in_doc = False if not xml_fragment: # Nothing read, move along continue if "" in xml_fragment[0]: xml.append(parse_manager_event_instance(xml_fragment)) else: xml.append(''.join(xml_fragment)) xml_fragment = [] elif (in_doc): xml_fragment.append("%s\n" % line) sys.stdout.write(''.join(xml)) return 0 if __name__ == "__main__": sys.exit(main() or 0) asterisk-11.7.0/build_tools/embed_modules.xml0000644000175000007640000000434711646125657021237 0ustar sharkyjerryweb gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended gnu_ld extended asterisk-11.7.0/build_tools/make_build_h0000755000175000007640000000065611370041045020217 0ustar sharkyjerryweb#!/bin/sh HOSTNAME=`uname -n` KERNEL=`uname -r` MACHINE=`uname -m` OS=`uname -s` USER=`id | awk -F")" '{print $1}'| awk -F"(" '{print $2}'` DATE=`date -u "+%Y-%m-%d %H:%M:%S"` cat << END /* * build.h * Automatically generated */ #define BUILD_HOSTNAME "${HOSTNAME}" #define BUILD_KERNEL "${KERNEL}" #define BUILD_MACHINE "${MACHINE}" #define BUILD_OS "${OS}" #define BUILD_DATE "${DATE} UTC" #define BUILD_USER "${USER}" END asterisk-11.7.0/build_tools/post_process_documentation.py0000644000175000007640000000660311772123406023722 0ustar sharkyjerryweb#! /usr/bin/env python # vin: sw=3 et: ''' Copyright (C) 2012, Digium, Inc. Matt Jordan This program is free software, distributed under the terms of the GNU General Public License Version 2. ''' import sys import os import optparse import xml.dom.minidom from xml.dom.minidom import Element, parse def merge_parameter_information(managerEvent): ''' Merge the parameter information across all managerEventInstances within a managerEvent node ''' def __swap_parameter_documentation(one, two): # See who has the better documentation and use it if (one.hasChildNodes()): two.parentNode.replaceChild(one.cloneNode(True), two) elif (two.hasChildNodes()): one.parentNode.replaceChild(two.cloneNode(True), one) def __merge_parameter(param, other_instances): # Compare the parameter to every other instance's set of parameters for other in other_instances: other_parameters = other.getElementsByTagName("parameter") match = [p for p in other_parameters if p.getAttribute('name') == param.getAttribute('name')] if (match): # See who has the better documentation and use it __swap_parameter_documentation(param, match[0]) instances = managerEvent.getElementsByTagName("managerEventInstance") merged = [] for instance in instances: others = [i for i in instances if i != instance] parameters = instance.getElementsByTagName("parameter") for parameter in parameters: if parameter not in merged: merged.append(parameter) __merge_parameter(parameter, others) def collapse_event_pair(managerEventOne, managerEventTwo): # Move all children of managerEventTwo to managerEventOne for node in managerEventTwo.childNodes: managerEventOne.appendChild(node.cloneNode(True)) return managerEventOne def collapse_manager_events(rootNode, managerEvents): events = {} for managerEvent in managerEvents: rootNode.removeChild(managerEvent) attr = managerEvent.getAttribute('name') if attr in events: # match, collapse the two managerEvents events[attr] = collapse_event_pair(events[attr], managerEvent) else: events[attr] = managerEvent # Combine parameter information and re-add the manager Events for k, event in events.items(): merge_parameter_information(event) rootNode.appendChild(event) return def main(argv=None): if argv is None: argv = sys.argv parser = optparse.OptionParser() parser.add_option('-i', '--input', dest='input_file', default='doc/core-full-en_US.xml', help='The XML file to process') parser.add_option('-o', '--output', dest='output_file', default='doc/core-en_US.xml', help='The XML file to create') (options, args) = parser.parse_args(argv) dom = parse(options.input_file) datasource = open(options.output_file, 'w') docs = dom.getElementsByTagName("docs")[0] managerEvents = dom.getElementsByTagName("managerEvent") if (managerEvents): collapse_manager_events(docs, managerEvents) dom.writexml(datasource) datasource.close() return 0 if __name__ == "__main__": sys.exit(main() or 0) asterisk-11.7.0/build_tools/make_linker_eo_script0000755000175000007640000000143710567200620022145 0ustar sharkyjerryweb#!/bin/sh cat << EOF SECTIONS { .text : { *(.text) } .data : { __${1}_data_start = . ; *(.data) __${1}_data_end = . ;} .rodata : { *(.rodata*) } .bss : { __${1}_bss_start = . ; *(.bss) __${1}_bss_end = . ;} .debug_abbrev : { *(.debug_abbrev) } .debug_info : { *(.debug_info) } .debug_line : { *(.debug_line) } .debug_macinfo : { *(.debug_macinfo) } .dtors : { *(.dtors) } .ctors : { *(.ctors) } .data.rel.local : { *(.data.rel.local) } .data.rel.ro.local : { *(.data.rel.ro.local) } .debug_frame : { *(.debug_frame) } .eh_frame : { *(.eh_frame) } .debug_loc : { *(.debug_loc) } .debug_pubname : { *(.debug_pubname) } .debug_aranges : { *(.debug_aranges) } .debug_ranges : { *(.debug_ranges) } .debug_str : { *(.debug_str) } .comment : { *(.comment) } .note.GNU-stack : { *(.note.GNU-stack) } } EOF asterisk-11.7.0/build_tools/get_moduleinfo0000644000175000007640000000014111054622332020601 0ustar sharkyjerryweb/\/\*\*\* MODULEINFO/ {printit=1; next} /\*\*\*\// {if (printit) exit} /.*/ {if (printit) print} asterisk-11.7.0/build_tools/get_makeopts0000644000175000007640000000013711054622332020270 0ustar sharkyjerryweb/\/\*\*\* MAKEOPTS/ {printit=1; next} /\*\*\*\// {if (printit) exit} /.*/ {if (printit) print} asterisk-11.7.0/build_tools/mkpkgconfig0000755000175000007640000000242411711604714020115 0ustar sharkyjerryweb#!/bin/sh PPATH="$1" ## Make sure we were called from Makefile if [ "x$ASTERISKVERSIONNUM" = "x" ]; then echo " ** Do not call this script directly" exit fi ## Create a pkgconfig spec file for 3rd party modules (pkg-config asterisk --cflags) if [ ! -d "$PPATH" ]; then exit fi #Solaris (and some others) don't have sed -r. perl -p is equivalent if [ `echo "xxx" | sed -r 's/x/y/g' 2>/dev/null | ${GREP} -c "yyy"` != 0 ]; then EXTREGEX="sed -r -e" else EXTREGEX="perl -pe" fi ## Clean out CFLAGS for the spec file. LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/\s*-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]\S*\s*//g' | \ ${EXTREGEX} 's/-I(include|\.\.\/include) //g' | \ ${EXTREGEX} 's/-DINSTALL_PREFIX=\S* //g' | \ ${EXTREGEX} 's/-DASTERISK_VERSION=\S* //g' | \ ${EXTREGEX} 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g'` cat < "$PPATH/asterisk.pc" install_prefix=$INSTALL_PREFIX version_number=$ASTERISKVERSIONNUM etcdir=$ASTETCDIR libdir=$ASTLIBDIR varlibdir=$ASTVARLIBDIR varrundir=$ASTVARRUNDIR spooldir=$ASTSPOOLDIR logdir=$ASTLOGDIR confpath=$ASTCONFPATH moddir=$ASTMODDIR agidir=$AGI_DIR Name: asterisk Description: Open Source PBX and telephony toolkit Version: $ASTERISKVERSION Libs: $LIBS Cflags: $LOCAL_CFLAGS EOF asterisk-11.7.0/build_tools/make_defaults_h0000755000175000007640000000202711711604714020730 0ustar sharkyjerryweb#!/bin/sh cat << END /* * defaults.h * Automatically generated from build options, * only used in main/asterisk.c */ #define DEFAULT_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}" #define DEFAULT_CONFIG_DIR "${INSTALL_PATH}${ASTETCDIR}" #define DEFAULT_MODULE_DIR "${INSTALL_PATH}${ASTMODDIR}" #define DEFAULT_AGI_DIR "${INSTALL_PATH}${AGI_DIR}" #define DEFAULT_LOG_DIR "${INSTALL_PATH}${ASTLOGDIR}" #define DEFAULT_RUN_DIR "${INSTALL_PATH}${ASTVARRUNDIR}" #define DEFAULT_SOCKET "${INSTALL_PATH}${ASTVARRUNDIR}/asterisk.ctl" #define DEFAULT_PID "${INSTALL_PATH}${ASTVARRUNDIR}/asterisk.pid" #define DEFAULT_VAR_DIR "${INSTALL_PATH}${ASTVARLIBDIR}" #define DEFAULT_DB "${INSTALL_PATH}${ASTDBDIR}/astdb" #define DEFAULT_DATA_DIR "${INSTALL_PATH}${ASTDATADIR}" #define DEFAULT_KEY_DIR "${INSTALL_PATH}${ASTDATADIR}/keys" #define DEFAULT_SPOOL_DIR "${INSTALL_PATH}${ASTSPOOLDIR}" #define DEFAULT_TMP_DIR "${INSTALL_PATH}${ASTSPOOLDIR}/tmp" #define DEFAULT_SBIN_DIR "${INSTALL_PATH}${ASTSBINDIR}" END asterisk-11.7.0/build_tools/find_missing_support_level0000755000175000007640000000011711766660300023252 0ustar sharkyjerryweb#!/bin/sh grep -r -L -e "support_level" * | grep -e "\.c$" -e "\.cxx$" | sort asterisk-11.7.0/build_tools/prep_tarball0000755000175000007640000000213512216360550020262 0ustar sharkyjerryweb#!/bin/sh -e # This script will be executed by the 'mkrelease' script to do any tasks # necessary during tarball creation of this project. # # It will be executed from the top-level directory of the project. make -C sounds MENUSELECT_CORE_SOUNDS=CORE-SOUNDS-EN-GSM MENUSELECT_MOH=MOH-OPSOUND-WAV WGET=wget DOWNLOAD=wget all branch=$1 if [ -z "$branch" ] then echo "No branch specified. Exiting." exit 1 fi hash unzip 2>&- || { echo >&2 "The unzip application is required but was not found. Aborting."; exit 1; } cd doc echo "Downloading the PDF and HTML documentation from the Asterisk wiki (this will take a minute) ..." wget https://wiki.asterisk.org/wiki/download/attachments/19005471/Asterisk-$branch-Reference.pdf wget https://wiki.asterisk.org/wiki/download/attachments/19005471/Asterisk-Admin-Guide.pdf wget https://wiki.asterisk.org/wiki/download/attachments/19005471/Asterisk-Admin-Guide-$branch.html.zip echo "Extracting HTML Admin Guide" unzip Asterisk-Admin-Guide-$branch.html.zip mv AST/ Asterisk-Admin-Guide/ rm -f Asterisk-Admin-Guide-$branch.html.zip echo "Documentation downloaded. Goodbye!" asterisk-11.7.0/build_tools/get_documentation0000644000175000007640000000013711272127254021323 0ustar sharkyjerryweb/\/\*\*\* DOCUMENTATION/ {printit=1; next} /\*\*\*\// {if (printit) exit} {if (printit) print} asterisk-11.7.0/build_tools/cflags-devmode.xml0000644000175000007640000000263112010307551021262 0ustar sharkyjerryweb extended extended extended DEBUG_THREADS extended extended extended extended extended extended extended asterisk-11.7.0/build_tools/make_version_c0000755000175000007640000000117711311525156020604 0ustar sharkyjerryweb#!/bin/sh if test ! -f .flavor ; then EXTRA="" elif test ! -f .version ; then aadkflavor=`cat .flavor` EXTRA=" (${aadkflavor})" else aadkver=`cat .version` aadkflavor=`cat .flavor` EXTRA=" (${aadkflavor} ${aadkver})" fi cat << END /* * version.c * Automatically generated */ #include "asterisk.h" #include "asterisk/ast_version.h" static const char asterisk_version[] = "${ASTERISKVERSION}${EXTRA}"; static const char asterisk_version_num[] = "${ASTERISKVERSIONNUM}"; const char *ast_get_version(void) { return asterisk_version; } const char *ast_get_version_num(void) { return asterisk_version_num; } END asterisk-11.7.0/build_tools/make_version0000755000175000007640000001143012040060072020262 0ustar sharkyjerryweb#!/bin/sh if [ -f ${1}/.version ]; then cat ${1}/.version elif [ -d ${1}/.svn ]; then PARTS=`LANG=C svn info ${1} | ${GREP} URL | ${AWK} '{print $2;}' | sed -e 's:^.*/svn/asterisk/::' | sed -e 's:/: :g'` BRANCH=0 TEAM=0 TAG=0 FEATURE=0 REV=`svnversion -c ${1} | cut -d: -f2` INTEGRATED=`LANG=C svn pg automerge-propname ${1}` if [ -z "${INTEGRATED}" ] ; then INTEGRATED=svnmerge-integrated fi BASE=`LANG=C svn pg ${INTEGRATED} ${1} | cut -d: -f1` if [ "${PARTS}" = "trunk" ] ; then echo SVN-trunk-r${REV} exit 0 fi for PART in $PARTS ; do if [ ${TAG} != 0 ] ; then if [ "${PART}" = "autotag_for_be" ] ; then continue fi if [ "${PART}" = "autotag_for_sx00i" ] ; then continue fi RESULT="${PART}" break fi if [ ${BRANCH} != 0 ] ; then RESULT="${RESULT}-${PART}" if [ ${FEATURE} != 0 ] ; then RESULT="${RESULT}-${FEATURE_NAME}" fi break fi if [ ${TEAM} != 0 ] ; then if [ -z "${RESULT}" ] ; then RESULT="${PART}" else RESULT="${RESULT}-${PART}" fi continue fi if [ "${PART}" = "certified" ] ; then FEATURE=1 FEATURE_NAME="cert" continue fi if [ "${PART}" = "branches" ] ; then BRANCH=1 RESULT="branch" continue fi if [ "${PART}" = "tags" ] ; then TAG=1 continue fi if [ "${PART}" = "team" ] ; then TEAM=1 continue fi done if [ ${TAG} != 0 ] ; then echo ${RESULT} else echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}} fi elif [ -d ${1}/.git ]; then if [ -z ${GIT} ]; then GIT="git" fi if ! command -v ${GIT} >/dev/null 2>&1; then echo "UNKNOWN__and_probably_unsupported" exit 1 fi # If the first log commit messages indicates that this is checked into # subversion, we'll just use the SVN- form of the revision. MODIFIED="" SVN_REV=`${GIT} log --pretty=full -1 | grep -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"` if [ -z "$SVN_REV" ]; then VERSION=GIT-`${GIT} describe --long --always --tags --dirty=M 2> /dev/null` if [ $? -ne 0 ]; then if [ "`${GIT} ls-files -m | wc -l`" != "0" ]; then MODIFIED="M" fi # Some older versions of git do not support all the above # options. VERSION=GIT-`${GIT} rev-parse --short --verify HEAD`${MODIFIED} fi echo ${VERSION} else PARTS=`LANG=C ${GIT} log --pretty=full | grep -F "git-svn-id:" | head -1 | awk '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'` BRANCH=0 TEAM=0 TAG=0 FEATURE=0 if [ "`${GIT} ls-files -m | wc -l`" != "0" ]; then MODIFIED="M" fi for PART in $PARTS ; do if [ ${TAG} != 0 ] ; then if [ "${PART}" = "autotag_for_be" ] ; then continue fi if [ "${PART}" = "autotag_for_sx00i" ] ; then continue fi RESULT="${PART}" break fi if [ ${BRANCH} != 0 ] ; then RESULT="${RESULT}-${PART}" if [ ${FEATURE} != 0 ] ; then RESULT="${RESULT}-${FEATURE_NAME}" fi break fi if [ ${TEAM} != 0 ] ; then if [ -z "${RESULT}" ] ; then RESULT="${PART}" else RESULT="${RESULT}-${PART}" fi continue fi if [ "${PART}" = "certified" ] ; then FEATURE=1 FEATURE_NAME="cert" continue fi if [ "${PART}" = "branches" ] ; then BRANCH=1 RESULT="branch" continue fi if [ "${PART}" = "tags" ] ; then TAG=1 continue fi if [ "${PART}" = "team" ] ; then TEAM=1 continue fi if [ "${PART}" = "trunk" ]; then echo SVN-trunk-r${SVN_REV}${MODIFIED} exit 0 fi done if [ ${TAG} != 0 ] ; then echo ${RESULT} else echo SVN-${RESULT##-}-r${SVN_REV}${MODIFIED} fi fi else echo "UNKNOWN__and_probably_unsupported" fi asterisk-11.7.0/keys/0000755000175000007640000000000012254071136014321 5ustar sharkyjerrywebasterisk-11.7.0/mkinstalldirs0000755000175000007640000000132410427665642016167 0ustar sharkyjerryweb#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs 25628 2006-05-08 16:02:42Z kpfleming $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here asterisk-11.7.0/CHANGES0000644000175000007640000042456212173063016014354 0ustar sharkyjerryweb============================================================================== === === This file documents the new and/or enhanced functionality added in === the Asterisk versions listed below. This file does NOT include === changes in behavior that would not be backwards compatible with === previous versions; for that information see the UPGRADE.txt file === and the other UPGRADE files for older releases. === ============================================================================== ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 10 to Asterisk 11 -------------------- ------------------------------------------------------------------------------ Build System ------------------- * The Asterisk build system will now build and install a shared library (libasteriskssl.so) used to wrap various initialization and shutdown functions from the libssl and libcrypto libraries provided by OpenSSL. This is done so that Asterisk can ensure that these functions do *not* get called by any modules that are loaded into Asterisk, since they should only be called once in any single process. If desired, this feature can be disabled by supplying the "--disable-asteriskssl" option to the configure script. * A new make target, 'full', has been added to the Makefile. This performs the same compilation actions as make all, but will also scan the entirety of each source file for documentation. This option is needed to generate AMI event documentation. Note that your system must have Python in order for this make target to succeed. * The optimization portion of the build system has been reworked to avoid broken builds on certain architectures. All architecture-specific optimization has been removed in favor of using -march=native to allow gcc to detect the environment in which it is running when possible. This can be toggled as BUILD_NATIVE under "Compiler Flags" in menuselect. * BUILD_CFLAGS and BUILD_LDFLAGS can now be passed to menuselect, e.g., make BUILD_CFLAGS="whatever" BUILD_LDFLAGS="whatever" * Remove "asterisk/version.h" in favor of "asterisk/ast_version.h". If you previously parsed the header file to obtain the version of Asterisk, you will now have to go through Asterisk to get the version information. Applications ------------------- Bridge ------------------- * Added 'F()' option. Similar to the dial option, this can be supplied with arguments indicating where the callee should go after the caller is hung up, or without options specified, the priority after the Queue will be used. ConfBridge ------------------- * Added menu action admin_toggle_mute_participants. This will mute / unmute all non-admin participants on a conference. The confbridge configuration file also allows for the default sounds played to all conference users when this occurs to be overriden using sound_participants_unmuted and sound_participants_muted. * Added menu action participant_count. This will playback the number of current participants in a conference. * Added announcement configuration option to user profile. If set the sound file will be played to the user, and only the user, upon joining the conference bridge. Dial ------------------- * Added 'b' and 'B' options to Dial that execute a Gosub on callee and caller channels respectively before the callee channels are called. ExternalIVR ------------------- * Added support for IPv6. * Add interrupt ('I') command to ExternalIVR. Sending this command from an external process will cause the current playlist to be cleared, including stopping any audio file that is currently playing. This is useful when you want to interrupt audio playback only when specific DTMF is entered by the caller. FollowMe ------------------- * A new option, 'I' has been added to app_followme. By setting this option, Asterisk will not update the caller with connected line changes when they occur. This is similar to app_dial and app_queue. * The 'N' option is now ignored if the call is already answered. * Added 'b' and 'B' options to FollowMe that execute a Gosub on callee and caller channels respectively before the callee channels are called. * The winning FollowMe outgoing call is now put on hold if the caller put it on hold. MixMonitor ------------------ * MixMonitor hooks now have IDs associated with them which can be used to assign a target to StopMixMonitor. Use of MixMonitor's i(variable) option will allow storage of the MixMontior ID in a channel variable. StopMixmonitor now accepts that ID as an argument. * Added 'm' option, which stores a copy of the recording as a voicemail in the indicated mailboxes. MySQL ------------------- * The connect action in app_mysql now allows you to specify a port number to connect to. This is useful if you run a MySQL server on a non-standard port number. OSP Applications ------------------- * Increased the default number of allowed destinations from 5 to 12. Page ------------------- * The app_page application now no longer depends on DAHDI or app_meetme. It has been re-architected to use app_confbridge internally. Queue ------------------- * Added queue options autopausebusy and autopauseunavail for automatically pausing a queue member when their device reports busy or congestion. * The 'ignorebusy' option for queue members has been deprecated in favor of the option 'ringinuse. Also a 'queue set ringinuse' CLI command has been added as well as an AMI action 'QueueMemberRingInUse' to set this variable on a per interface basis. Individual ringinuse values can now be set in queues.conf via an argument to member definitions. Lastly, the queue 'ringinuse' setting now only determines defaults for the per member 'ringinuse' setting and does not override per member settings like it does in earlier versions. * Added 'F()' option. Similar to the dial option, this can be supplied with arguments indicating where the callee should go after the caller is hung up, or without options specified, the priority after the Queue will be used. * Added new option log_member_name_as_agent, which will cause the membername to be logged in the agent field for ADDMEMBER and REMOVEMEMBER queue events if a state_interface has been set. * Add queue monitoring hints. exten => 8501,hint,Queue:markq. SayUnixTime ------------------ * Added 'j' option to SayUnixTime. SayUnixTime no longer auto jumps to extension when receiving DTMF. Use the 'j' option to enable extension jumping. Also changed arguments to SayUnixTime so that every option is truly optional even when using multiple options (so that j option could be used without having to manually specify timezone and format) There are other benefits, e.g., format can now be used without specifying time zone as well. Voicemail ------------------ * Addition of the VM_INFO function - see Function changes. * The imapserver, imapport, and imapflags configuration options can now be overriden on a user by user basis. * When voicemail plays a message's envelope with saycid set to yes, when reaching the caller id field it will play a recording of a file with the same base name as the sender's callerid if there is a similarly named file in /recordings/callerids/ * Voicemails now contains a unique message identifier "msg_id", which is stored in the message envelope with the sound files. IMAP backends will now store the message identifiers with a header of "X-Asterisk-VM-Message-ID". ODBC backends will store the message identifier in a "msg_id" column. See UPGRADE.txt for more information. * Added VoiceMailPlayMsg application. This application will play a single voicemail message from a mailbox. The result of the application, SUCCESS or FAILED, is stored in the channel variable VOICEMAIL_PLAYBACKSTATUS. Functions ------------------ * Hangup handlers can be attached to channels using the CHANNEL() function. Hangup handlers will run when the channel is hung up similar to the h extension. The hangup_handler_push option will push a GoSub compatible location in the dialplan onto the channel's hangup handler stack. The hangup_handler_pop option will remove the last added location, and optionally replace it with a new GoSub compatible location. The hangup_handler_wipe option will remove all locations on the stack, and optionally add a new location. * The expression parser now recognizes the ABS() absolute value function, which will convert negative floating point values to positive values. * FAXOPT(faxdetect) will enable a generic fax detect framehook for dialplan control of faxdetect. * Addition of the VM_INFO function that can be used to retrieve voicemail user information, such as the email address and full name. The MAILBOX_EXISTS dialplan function has been deprecated in favour of VM_INFO. * The REDIRECTING function now supports the redirecting original party id and reason. * Two new functions have been added: FEATURE() and FEATUREMAP(). FEATURE() lets you set some of the configuration options from the [general] section of features.conf on a per-channel basis. FEATUREMAP() lets you customize the key sequence used to activate built-in features, such as blindxfer, and automon. See the built-in documentation for details. * MESSAGE(from) for incoming SIP messages now returns "display-name" instead of simply the uri. This is the format that MessageSend() can use in the from parameter for outgoing SIP messages. * Added the PRESENCE_STATE function. This allows retrieving presence state information from any presence state provider. It also allows setting presence state information from a CustomPresence presence state provider. See AMI/CLI changes for related commands. * Added the AMI_CLIENT function to make manager account attributes available to the dialplan. It currently supports returning the current number of active sessions for a given account. * Added support for private party ID information to CALLERID, CONNECTEDLINE, and the REDIRECTING functions. Channel Drivers ------------------ chan_local ------------------ * Added a manager event "LocalBridge" for local channel call bridges between the two pseudo-channels created. chan_dahdi ------------------ * Added dialtone_detect option for analog ports to disconnect incoming calls when dialtone is detected. * Added option colp_send to send ISDN connected line information. Allowed settings are block, to not send any connected line information; connect, to send connected line information on initial connect; and update, to send information on any update during a call. Default is update. * Add options namedcallgroup and namedpickupgroup to support installations where a higher number of groups (>64) is required. * Added support to use private party ID information with PRI calls. chan_motif ------------------ * A new channel driver named chan_motif has been added which provides support for Google Talk and Jingle in a single channel driver. This new channel driver includes support for both audio and video, RFC2833 DTMF, all codecs supported by Asterisk, hold, unhold, and ringing notification. It is also compliant with the current Jingle specification, current Google Jingle specification, and the original Google Talk protocol. chan_ooh323 ------------------ * Added NAT support for RTP. Setting in config is 'nat', which can be set globally and overriden on a peer by peer basis. * Direct media functionality has been added. Options in config are: directmedia (directrtp) and directrtpsetup (earlydirect) * ChannelUpdate events now contain a CallRef header. chan_sip ------------------ * Asterisk will no longer substitute CID number for CID name in the display name field if CID number exists without a CID name. This change improves compatibility with certain device features such as Avaya IP500's directory lookup service. * A new setting for autocreatepeer (autocreatepeer=persistent) allows peers created using that setting to not be removed during SIP reload. * Added settings recordonfeature and recordofffeature. When receiving an INFO request with a "Record:" header, this will turn the requested feature on/off. Allowed values are 'automon', 'automixmon', and blank to disable. Note that dynamic features must be enabled and configured properly on the requesting channel for this to function properly. * Add support to realtime for the 'callbackextension' option. * When multiple peers exist with the same address, but differing callbackextension options, incoming requests that are matched by address will be matched to the peer with the matching callbackextension if it is available. * Two new NAT options, auto_force_rport and auto_comedia, have been added which set the force_rport and comedia options automatically if Asterisk detects that an incoming SIP request crossed a NAT after being sent by the remote endpoint. * The default global nat setting in sip.conf has been changed from force_rport to auto_force_rport. * NAT settings are now a combinable list of options. The equivalent of the deprecated nat=yes is nat=force_rport,comedia. nat=no behaves as before. * Adds an option send_diversion which can be disabled to prevent diversion headers from automatically being added to INVITE requests. * Add support for lightweight NAT keepalive. If enabled a blank packet will be sent to the remote host at a given interval to keep the NAT mapping open. This can be enabled using the keepalive configuration option. * Add option 'tonezone' to specify country code for indications. This option can be set both globally and overridden for specific peers. * The SIP Security Events Framework now supports IPv6. * Add a new setting for directmedia, 'outgoing', to alleviate INVITE glares between multiple user agents. When set, for directmedia reinvites, Asterisk will not send an immediate reinvite on an incoming call leg. This option is useful when peered with another SIP user agent that is known to send immediate direct media reinvites upon call establishment. * Add support for WebSocket transport. This can be configured using 'ws' or 'wss' as the transport. * Add options subminexpiry and submaxexpiry to set limits of subscription timer independently from registration timer settings. The setting of the registration timer limits still is done by options minexpiry, maxexpiry and defaultexpiry. For backwards compatibility the setting of minexpiry and maxexpiry also is used to configure the subscription timer limits if subminexpiry and submaxexpiry are not set in sip.conf. * Set registration timer limits to default values when reloading sip configuration and values are not set by configuration. * Add options namedcallgroup and namedpickupgroup to support installations where a higher number of groups (>64) is required. * When a MESSAGE request is received, the address the request was received from is now saved in the SIP_RECVADDR variable. * Add ANI2/OLI parsing for SIP. The "From" header in INVITE requests is now parsed for the presence of "isup-oli", "ss7-oli", or "oli" tags. If present, the ANI2/OLI information is set on the channel, which can be retrieved using the CALLERID function. * Peers can now be configured to support negotiation of ICE candidates using the setting icesupport. See res_rtp_asterisk changes for more information. * Added support for format attribute negotiation. See the Codecs changes for more information. * Extra headers specified with SIPAddHeader are sent with the REFER message when using Transfer application. See refer_addheaders in sip.conf.sample. * Added support to use private party ID information with calls. chan_skinny ------------------ * Added skinny version 17 protocol support. chan_unistim -------------------- * Added ability to use multiple lines for a single phone. This allows multiple calls to occur on a single phone, using callwaiting and switching between calls. * Added option 'sharpdial' allowing end dialing by pressing # key * Added option 'interdigit_timer' to control phone dial timeout * Added options 'cwstyle', 'cwvolume' controlling callwaiting appearance * Added global 'debug' option, that enables debug in channel driver * Added ability to translate on-screen menu in multiple languages. Tested on Russian languages. Supported encodings: ISO 8859-1, ISO 8859-2, ISO 8859-4, ISO 8859-5, ISO 2022-JP. Language controlled by 'language' and on-screen menu of phone * In addition to English added French and Russian languages for on-screen menus * Reworked dialing number input: added dialing by timeout, immediate dial on on dialplan compare, phone number length now not limited by screen size * Added ability to pickup a call using features.conf defined value and on-screen key chan_mISDN: ------------------ * Add options namedcallgroup and namedpickupgroup to support installations where a higher number of groups (>64) is required. * Added support to use private party ID information with calls. Core ------------------ * The minimum DTMF duration can now be configured in asterisk.conf as "mindtmfduration". The default value is (as before) set to 80 ms. (previously it was only available in source code) * Named ACLs can now be specified in acl.conf and used in configurations that use ACLs. As a general rule, if some derivative of 'permit' or 'deny' is used to specify an ACL, a similar form of 'acl' will add a named ACL to the working ACL. In addition, some CLI commands have been added to provide show information and allow for module reloading - see CLI Changes. * Rules in ACLs (specified using 'permit' and 'deny') can now contain multiple items (separated by commas), and items in the rule can be negated by prefixing them with '!'. This simplifies Asterisk Realtime configurations, since it is no longer necessray to control the order that the 'permit' and 'deny' columns are returned from queries. * DUNDi now allows the built in variables ${NUMBER}, ${IPADDR} and ${SECRET} to be used within the dynamic weight attribute when specifying a mapping. * CEL backends can now be configured to show "USER_DEFINED" in the EventName header, instead of putting the user defined event name there. When enabled the UserDefType header is added for user defined events. This feature is enabled with the setting show_user_defined. * Macro has been deprecated in favor of GoSub. For redirecting and connected line purposes use the following variables instead of their macro equivalents: REDIRECTING_SEND_SUB, REDIRECTING_SEND_SUB_ARGS, CONNECTED_LINE_SEND_SUB, CONNECTED_LINE_SEND_SUB_ARGS. For CCSS, use cc_callback_sub instead of cc_callback_macro in channel configurations. * Asterisk can now use a system-provided NetBSD editline library (libedit) if it is available. * Call files now support the "early_media" option to connect with an outgoing extension when early media is received. * Added support to use private party ID information with calls. AGI ------------------ * A new channel variable, AGIEXITONHANGUP, has been added which allows Asterisk to behave like it did in Asterisk 1.4 and earlier where the AGI application would exit immediately after a channel hangup is detected. * IPv6 addresses are now supported when using FastAGI (agi://). Hostnames are resolved and each address is attempted in turn until one succeeds or all fail. AMI (Asterisk Manager Interface) ------------------ * The originate action now has an option "EarlyMedia" that enables the call to bridge when we get early media in the call. Previously, early media was disregarded always when originating calls using AMI. * Added setvar= option to manager accounts (much like sip.conf) * Originate now generates an error response if the extension given is not found in the dialplan * MixMonitor will now show IDs associated with the mixmonitor upon creating them if the i(variable) option is used. StopMixMonitor will accept MixMonitorID as an option to close specific MixMonitors. * The SIPshowpeer manager action response field "SIP-Forcerport" has been updated to include information about peers configured with nat=auto_force_rport by returning "A" if auto_force_rport is set and nat is detected, and "a" if it is set and nat is not detected. "Y" and "N" are still returned if auto_force_rport is not enabled. * Added SIPpeerstatus manager command which will generate PeerStatus events similar to the existing PeerStatus events found in chan_sip on demand. * Hangup now can take a regular expression as the Channel option. If you want to hangup multiple channels, use /regex/ as the Channel option. Existing behavior to hanging up a single channel is unchanged, but if you pass a regex, the manager will send you a list of channels back that were hung up. * Support for IPv6 addresses has been added. * AMI Events can now be documented in the Asterisk source. Note that AMI event documentation is only generated when Asterisk is compiled using 'make full'. See the CLI section for commands to display AMI event information. * The AMI Hangup event now includes the AccountCode header so you can easily correlate with AMI Newchannel events. * The QueueMemberStatus, QueueMemberAdded, and QueueMember events now include the StateInterface of the queue member. * Added AMI event SessionTimeout in the Call category that is issued when a call is terminated due to either RTP stream inactivity or SIP session timer expiration. * CEL events can now contain a user defined header UserDefType. See core changes for more information. * OOH323 ChannelUpdate events now contain a CallRef header. * Added PresenceState command. This command will report the presence state for the given presence provider. * Added Parkinglots command. This will list all parking lots as a series of AMI Parkinglot events. * Added MessageSend command. This behaves in the same manner as the MessageSend application, and is a technolgoy agnostic mechanism to send out of call text messages. * Added "message" class authorization. This grants an account permission to send out of call messages. Write-only. CLI ------------------- * The "dialplan add include" command has been modified to create context a context if one does not already exist. For instance, "dialplan add include foo into bar" will create context "bar" if it does not already exist. * A "dialplan remove context" command has been added to remove a context from the dialplan * The "mixmonitor list " command will now show MixMonitor ID, and the filenames of all running mixmonitors on a channel. * The debug level of "pri set debug" is now a bitmask ranging from 0 to 15 if numeric instead of 0, 1, or 2. * "stun show status" will show a table describing how the STUN client is behaving. * "acl show [named acl]" will show information regarding a Named ACL. The acl module can be reloaded with "reload acl". * Added CLI command to display AMI event information - "manager show events", which shows a list of all known and documented AMI events, and "manager show event [event name]", which shows detail information about a specific AMI event. * The result of the CLI command "queue show" now includes the state interface information of the queue member. * The command "core set verbose" will now set a separate level of logging for each remote console without affecting any other console. * Added command "cdr show pgsql status" to check connection status * "sip show channel" will now display the complete route set. * Added "presencestate list" command. This command will list all custom presence states that have been set by using the PRESENCE_STATE dialplan function. * Added "presencestate change [,[,message[,options]]]" command. This changes a custom presence to a new state. Codecs ------------------- * Codec lists may now be modified by the '!' character, to allow succinct specification of a list of codecs allowed and disallowed, without the requirement to use two different keywords. For example, to specify all codecs except g729 and g723, one need only specify allow=all,!g729,!g723. * Add support for parsing SDP attributes, generating SDP attributes, and passing it through. This support includes codecs such as H.263, H.264, SILK, and CELT. You are able to set up a call and have attribute information pass. This should help considerably with video calls. * The iLBC codec can now use a system-provided iLBC library if one is installed, just like the GSM codec. DUNDi changes ------------- * Added CLI commands dundi show hints and dundi show cache which will list DUNDi 'DONTASK' hints in the cache and list all DUNDi cache entires respectively. Logging ------------------- * Asterisk version and build information is now logged at the beginning of a log file. * Threads belonging to a particular call are now linked with callids which get added to any log messages produced by those threads. Log messages can now be easily identified as involved with a certain call by looking at their call id. Call ids may also be attached to log messages for just about any case where it can be determined to be related to a particular call. * Each logging destination and console now have an independent notion of the current verbosity level. Logger.conf now allows an optional argument to the 'verbose' specifier, indicating the level of verbosity sent to that particular logging destination. Additionally, remote consoles now each have their own verbosity level. The command 'core set verbose' will now set a separate level for each remote console without affecting any other console. Music On Hold ------------------- * Added 'announcement' option which will play at the start of MOH and between songs in modes of MOH that can detect transitions between songs (eg. files, mp3, etc). Parking ------------------- * New per parking lot options: comebackcontext and comebackdialtime. See configs/features.conf.sample for more details. * Channel variable PARKER is now set when comebacktoorigin is disabled in a parking lot. * Channel variable PARKEDCALL is now set with the name of the parking lot when a timeout occurs. CDRs ------------------- CDR Postgresql Driver ------------------- * Added command "cdr show pgsql status" to check connection status CDR Adaptive ODBC Driver ------------------- * Added schema option for databases that support specifying a schema. Resource Modules ------------------- Calendars ------------------- * A CALENDAR_SUCCESS=1/0 channel variable is now set to show whether or not CALENDAR_WRITE has completed successfully. res_rtp_asterisk ------------------- * A new option, 'probation' has been added to rtp.conf RTP in strictrtp mode can now require more than 1 packet to exit learning mode with a new source (and by default requires 4). The probation option allows the user to change the required number of packets in sequence to any desired value. Use a value of 1 to essentially restore the old behavior. Also, with strictrtp on, Asterisk will now drop all packets until learning mode has successfully exited. These changes are based on how pjmedia handles media sources and source changes. * Add support for ICE/STUN/TURN in res_rtp_asterisk. This option can be enabled or disabled using the icesupport setting. A variety of other settings have been introduced to configure STUN/TURN connections. res_corosync ------------------- * A new module, res_corosync, has been introduced. This module uses the Corosync cluster enginer (http://www.corosync.org) to allow a local cluster of Asterisk servers to both Message Waiting Indication (MWI) and/or Device State (presence) information. This module is very similar to, and is a replacement for the res_ais module that was in previous releases of Asterisk. res_xmpp ------------------- * This module adds a cleaned up, drop-in replacement for res_jabber called res_xmpp. This provides the same externally facing functionality but is implemented differently internally. res_jabber has been deprecated in favor of res_xmpp; please see the UPGRADE.txt file for more information. Scripts ------------------- * The safe_asterisk script has been updated to allow several of its parameters to be set from environment variables. This also enables a custom run directory of Asterisk to be specified, instead of defaulting to /tmp. * The live_ast script will now look for the LIVE_AST_BASE_DIR variable and use its value to determine the directory to assume is the top-level directory of the source tree. If the variable is not set, it defaults to the current behavior and uses the current working directory. Queue ------------------- * Add queue available hint. exten => 8501,hint,Queue:markq_avail Note: the suffix '_avail' after the queuename. Reports 'InUse' for no logged in agents or no free agents. Reports 'Idle' when an agent is free. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 1.8 to Asterisk 10 ------------------- ------------------------------------------------------------------------------ Text Messaging -------------- * Asterisk now has protocol independent support for processing text messages outside of a call. Messages are routed through the Asterisk dialplan. SIP MESSAGE and XMPP are currently supported. There are options in jabber.conf and sip.conf to allow enabling these features. -> jabber.conf: see the "sendtodialplan" and "context" options. -> sip.conf: see the "accept_outofcall_message", "auth_message_requests" and "outofcall_message_context" options. The MESSAGE() dialplan function and MessageSend() application have been added to go along with this functionality. More detailed usage information can be found on the Asterisk wiki (http://wiki.asterisk.org/). * If real-time text support (T.140) is negotiated, it will be preferred for sending text via the SendText application. For example, via SIP, messages that were once sent via the SIP MESSAGE request would be sent via RTP if T.140 text is negotiated for a call. Parking ------- * parkedmusicclass can now be set for non-default parking lots. Asterisk Manager Interface -------------------------- * PeerStatus now includes Address and Port. * Added Hold events for when the remote party puts the call on and off hold for chan_dahdi ISDN channels. * Added new action MeetmeListRooms to list active conferences (shows same data as "meetme list" at the CLI). * DAHDIShowChannels, SIPshowpeer, SIPpeers, and IAXpeers now contains a Description field that is set by 'description' in the channel configuration file. * Added Uniqueid header to UserEvent. * Added new action FilterAdd to control event filters for the current session. This requires the system permission and uses the same filter syntax as filters that can be defined in manager.conf * The Unlink event is now a Bridge event with Bridgestatus: Unlink. Previous versions had some instances of the event converted, but others were left as-is. All Unlink events should now be converted to Bridge events. The AMI protocol version number was incremented to 1.2 as a result of this change. Asterisk HTTP Server -------------------------- * The HTTP Server can bind to IPv6 addresses. chan_dahdi -------------------------- * Busy tone patterns featuring 2 silence and 2 tone lengths can now be used with busydetect. usage example: busypattern=200,200,200,600 CLI Changes -------------------------- * New 'gtalk show settings' command showing the current settings loaded from gtalk.conf. * The 'logger reload' command now supports an optional argument, specifying an alternate configuration file to use. * 'dialplan add extension' command will now automatically create a context if the specified context does not exist with a message indicated it did so. * 'sip show peers', 'iax show peers', and 'dahdi show peers' now contains a Description field which can be populated with 'description' in the channel configuration files (sip.conf, iax2.conf, and chan_dahdi.conf). CDR -------------------------- * The filter option in cdr_adaptive_odbc now supports negating the argument, thus allowing records which do NOT match the specified filter. * Added ability to log CONGESTION calls to CDR CODECS -------------------------- * Ability to define custom SILK formats in codecs.conf. * Addition of speex32 audio format with translation. * CELT codec pass-through support and ability to define custom CELT formats in codecs.conf. * Ability to read raw signed linear files with sample rates ranging from 8khz - 192khz. The new file extensions introduced are .sln12, .sln24, .sln32, .sln44, .sln48, .sln96, .sln192. * Due to protocol limitations, channel drivers other than SIP (eg. IAX2, MGCP, Skinny, H.323, etc) can still only support the following codecs: Audio: ulaw, alaw, slin, slin16, g719, g722, g723, g726, g726aal2, g729, gsm, siren7, siren14, speex, speex16, ilbc, lpc10, adpcm Video: h261, h263, h263p, h264, mpeg4 Image: jpeg, png Text: red, t140 ConfBridge -------------------------- * New highly optimized and customizable ConfBridge application capable of mixing audio at sample rates ranging from 8khz-96khz. * CONFBRIDGE dialplan function capable of creating dynamic ConfBridge user and bridge profiles on a channel. * CONFBRIDGE_INFO dialplan function capable of retrieving information about a conference such as locked status and number of parties, admins, and marked users. * Addition of video_mode option in confbridge.conf for adding video support into a bridge profile. * Addition of the follow_talker video_mode in confbridge.conf. This video mode dynamically switches the video feed to always display the loudest talker supplying video in the conference. Dialplan Variables ------------------ * Added ASTETCDIR, ASTMODDIR, ASTVARLIBDIR, ASTDBDIR, ASTKEYDIR, ASTDATADIR, ASTAGIDIR, ASTSPOOLDIR, ASTRUNDIR, ASTLOGDIR which hold the equivalent variables from asterisk.conf. Dialplan Functions ------------------ * Addition of the JITTERBUFFER dialplan function. This function allows for jitterbuffering to occur on the read side of a channel. By using this function conference applications such as ConfBridge and MeetMe can have the rx streams jitterbuffered before conference mixing occurs. * Added DB_KEYS, which lists the next set of keys in the Asterisk database hierarchy. * Added STRREPLACE function. This function let's the user search a variable for a given string to replace with another string as many times as the user specifies or just throughout the whole string. * Added option to CHANNEL(pickupgroup) allow reading and setting the pickupgroup of channel. * Mark VALID_EXTEN() deprecated in favor of DIALPLAN_EXISTS() * Added extensions to chan_ooh323 in function CHANNEL() libpri channel driver (chan_dahdi) DAHDI changes -------------------------- * Added moh_signaling option to specify what to do when the channel's bridged peer puts the ISDN channel on hold. * Added display_send and display_receive options to control how the display ie is handled. To send display text from the dialplan use the SendText() application when the option is enabled. * Added mcid_send option to allow sending a MCID request on a span. Calendaring -------------------------- * Added setvar option to calendar.conf to allow setting channel variables on notification channels. * Added "calendar show types" CLI command to list registered calendar connectors. MixMonitor -------------------------- * Added two new options, r and t with file name arguments to record single direction (unmixed) audio recording separate from the bidirectional (mixed) recording. The mixed file name argument is optional now as long as at least one recording option is used. FollowMe -------------------------- * Added a new option, l, which will disable local call optimization for channels involved with the FollowMe thread. Use this option to improve compatability for a FollowMe call with certain dialplan apps, options, and functions. Meetme -------------------------- * Added option "k" that will automatically close the conference when there's only one person left when a user exits the conference. CEL -------------------------- * cel_pgsql now supports the 'extra' column for data added using the CELGenUserEvent() application. pbx_lua -------------------------- * Support for defining hints has been added to pbx_lua. See the 'hints' table in the sample extensions.lua file for syntax details. * Applications that perform jumps in the dialplan such as Goto will now execute properly. When pbx_lua detects that the context, extension, or priority we are executing on has changed it will immediately return control to the asterisk PBX engine. Currently the engine cannot detect a Goto to the priority after the currently executing priority. * An autoservice is now started by default for pbx_lua channels. It can be stopped and restarted using the autoservice_stop() and autoservice_start() functions. res_fax -------------------------- * The ReceiveFAXStatus and SendFAXStatus manager events have been consolidated into a FAXStatus event with an 'Operation' header that will be either 'send', 'receive', and 'gateway'. * T.38 gateway functionality has been added to res_fax (and res_fax_spandsp). Set FAXOPT(gateway)=yes to enable this functionality on a channel. This feature will handle converting a fax call between an audio T.30 fax terminal and an IFP T.38 fax terminal. SIP Changes ----------- * Add T38 support for REJECTED state where T.38 Negotiation is explicitly rejected. * Add option encryption_taglen to set auth taglen only 32 and 80 are supported currently. * SIP now generates security events using the Security Events Framework for REGISTER and INVITE. Queue changes ------------- * Added general option negative_penalty_invalid default off. when set members are seen as invalid/logged out when there penalty is negative. for realtime members when set remove from queue will set penalty to -1. * Added queue option autopausedelay when autopause is enabled it will be delayed for this number of seconds since last successful call if there was no prior call the agent will be autopaused immediately. * Added member option ignorebusy this when set and ringinuse is not will allow per member control of multiple calls as ringinuse does for the Queue. Applications ------------ * Added 'v' option to MeetMe to play voicemail greetings when a user joins/leaves a MeetMe conference * Added 'k' option to MeetMe to automatically kill the conference when there's only one participant left (much like a normal call bridge) * Added extra argument to Originate to set timeout. Asterisk Database ----------------- * The internal Asterisk database has been switched from Berkeley DB 1.86 to SQLite 3. An existing Berkeley astdb file can be converted with the astdb2sqlite3 utility in the UTILS section of menuselect. If an existing astdb is found and no astdb.sqlite3 exists, astdb2sqlite3 will be compiled automatically. Asterisk will convert an existing astdb to the SQLite3 version automatically at runtime. Asterisk Modules ---------------- * Modules marked as deprecated are no longer marked as building by default. Enabling these modules is still available via menuselect. IAX2 Changes ------------ * authdebug is now disabled by default. To enable this functionaility again set authdebug = yes in iax.conf. RTP Changes ----------- * The rtp.conf setting "strictrtp" is now enabled by default. In previous releases it was disabled. PBX Core -------- * The PBX core previously made a call with a non-existing extension test for extension s@default and jump there if the extension existed. This was a bad default behaviour and violated the principle of least surprise. It has therefore been changed in this release. It may affect some applications and configurations that rely on this behaviour. Most channel drivers have avoided this for many releases by testing whether the extension called exists before starting the PBX and generating a local error. This behaviour still exists and works as before. Extension "s" is used when no extension is given in a channel driver, like immediate answer in DAHDI or calling to a domain with no user part in a SIP uri. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 1.6.2 to Asterisk 1.8 ---------------- ------------------------------------------------------------------------------ SIP Changes ----------- * Due to potential username discovery vulnerabilities, the 'nat' setting in sip.conf now defaults to force_rport. It is very important that phones requiring nat=no be specifically set as such instead of relying on the default setting. If at all possible, all devices should have nat settings configured in the general section as opposed to configuring nat per-device. * Added preferred_codec_only option in sip.conf. This feature limits the joint codecs sent in response to an INVITE to the single most preferred codec. * Added SIP_CODEC_OUTBOUND dialplan variable which can be used to set the codec to be used for the outgoing call. It must be one of the codecs configured for the device. * Added tlsprivatekey option to sip.conf. This allows a separate .pem file to be used for holding a private key. If tlsprivatekey is not specified, tlscertfile is searched for both public and private key. * Added tlsclientmethod option to sip.conf. This allows the protocol for outbound client connections to be specified. * The sendrpid parameter has been expanded to include the options 'rpid' and 'pai'. Setting sendrpid to 'rpid' will cause Remote-Party-ID header to be sent (equivalent to setting sendrpid=yes) and setting sendrpid to 'pai' will cause P-Asserted-Identity header to be sent. * The 'ignoresdpversion' behavior has been made automatic when the SDP received is in response to a T.38 re-INVITE that Asterisk initiated. In this situation, since the call will fail if Asterisk does not process the incoming SDP, Asterisk will accept the SDP even if the SDP version number is not properly incremented, but will generate a warning in the log indicating that the SIP peer that sent the SDP should have the 'ignoresdpversion' option set. * The 'nat' option has now been been changed to have yes, no, force_rport, and comedia as valid values. Setting it to yes forces RFC 3581 behavior and enables symmetric RTP support. Setting it to no only enables RFC 3581 behavior if the remote side requests it and disables symmetric RTP support. Setting it to force_rport forces RFC 3581 behavior and disables symmetric RTP support. Setting it to comedia enables RFC 3581 behavior if the remote side requests it and enables symmetric RTP support. * Slave SIP channels now set HASH(SIP_CAUSE,) on each response. This permits the master channel to know how each channel dialled in a multi-channel setup resolved in an individual way. This carries a performance penalty and can be disabled in sip.conf using the 'storesipcause' option. * Added 'externtcpport' and 'externtlsport' options to allow custom port configuration for the externip and externhost options when tcp or tls is used. * Added support for message body (stored in content variable) to SIP NOTIFY message accessible via AMI and CLI. * Added 'media_address' configuration option which can be used to explicitly specify the IP address to use in the SDP for media (audio, video, and text) streams. * Added 'unsolicited_mailbox' configuration option which specifies the virtual mailbox that the new/old count should be stored on if an unsolicited MWI NOTIFY message is received. * Added 'use_q850_reason' configuration option for generating and parsing if available Reason: Q.850;cause= header. It is implemented in some gateways for better passing PRI/SS7 cause codes via SIP. * When dialing SIP peers, a new component may be added to the end of the dialstring to indicate that a specific remote IP address or host should be used when dialing the particular peer. The dialstring format is SIP/peer/exten/host_or_IP. * SRTP SDES support for encrypting calls to/from Asterisk over SIP. The ability to selectively force bridged channels to also be encrypted is also implemented. Branching in the dialplan can be done based on whether or not a channel has secure media and/or signaling. * Added directmediapermit/directmediadeny to limit which peers can send direct media to each other * Added the 'snom_aoc_enabled' option to turn on support for sending Advice of Charge messages to snom phones. * Added support for G.719 media streams. * Added support for 16khz signed linear media streams. * SIP is now able to bind to and communicate with IPv6 addresses. In addition, RTP has been outfitted with the same abilities. * Added support for setting the Max-Forwards: header in SIP requests. Setting is available in device configurations as well as in the dial plan. * Addition of the 'subscribe_network_change' option for turning on and off res_stun_monitor module support in chan_sip. * Addition of the 'auth_options_requests' option for turning on and off authentication for OPTIONS requests in chan_sip. Configuration files ------------------- * Add #tryinclude statement for config files. This provides the same functionality as the #include statement however an asterisk module will still load if the filename does not exist. Using the #include statement Asterisk will not allow the module to load. IAX2 Changes ----------- * Added rtsavesysname option into iax.conf to allow the systname to be saved on realtime updates. * Added the ability for chan_iax2 to inform the dialplan whether or not encryption is being used. This interoperates with the SIP SRTP implementation so that a secure SIP call can be bridged to a secure IAX call when the dialplan requires bridged channels to be "secure". * Addition of the 'subscribe_network_change' option for turning on and off res_stun_monitor module support in chan_iax. MGCP Changes ------------ * Added ability to preset channel variables on indicated lines with the setvar configuration option. Also, clearvars=all resets the list of variables back to none. * PacketCable NCS 1.0 support has been added for Docsis/Eurodocsis Networks. See configs/res_pktccops.conf for more information. XMPP Google Talk/Jingle changes ------------------------------- * Added the externip option to gtalk.conf. * Added the stunaddr option to gtalk.conf which allows for the automatic retrieval of the external ip from a stun server. Applications ------------ * Added 'p' option to PickupChan() to allow for picking up channel by the first match to a partial channel name. * Added .m3u support for Mp3Player application. * Added progress option to the app_dial D() option. When progress DTMF is present, those values are sent immediately upon receiving a PROGRESS message regardless if the call has been answered or not. * Added functionality to the app_dial F() option to continue with execution at the current location when no parameters are provided. * Added the 'a' option to app_dial to answer the calling channel before any announcements or macros are executed. * Modified app_dial to set answertime when the called channel answers even if the called channel hangs up during playback of an announcement. * Modified app_dial 'r' option to support an additional parameter to play an indication tone from indications.conf * Added c() option to app_chanspy. This option allows custom DTMF to be set to cycle through the next available channel. By default this is still '*'. * Added x() option to app_chanspy. This option allows DTMF to be set to exit the application. * The Voicemail application has been improved to automatically ignore messages that only contain silence. * If you set maxmsg to 0 in voicemail.conf, Voicemail will consider the associated mailbox(es) to be greetings-only. * The ChanSpy application now has the 'S' option, which makes the application automatically exit once it hits a point where no more channels are available to spy on. * The ChanSpy application also now has the 'E' option, which spies on a single channel and exits when that channel hangs up. * The MeetMe application now turns on the DENOISE() function by default, for each participant. In our tests, this has significantly decreased background noise (especially noisy data centers). * Voicemail now permits storage of secrets in a separate file, located in the spool directory of each individual user. The control for this is located in the "passwordlocation" option in voicemail.conf. Please see the sample configuration for more information. * The ChanIsAvail application now exposes the returned cause code using a separate variable, AVAILCAUSECODE, instead of overwriting the device state in AVAILSTATUS. * Added 'd' option to app_followme. This option disables the "Please hold" announcement. * Added 'y' option to app_record. This option enables a mode where any DTMF digit received will terminate recording. * Voicemail now supports per mailbox settings for folders when using IMAP storage. Previously the folder could only be set per context, but has now been extended using the imapfolder option. * Voicemail now supports per mailbox settings for nextaftercmd and minsecs. * Voicemail now allows the pager date format to be specified separately from the email date format. * New applications JabberJoin, JabberLeave, and JabberSendGroup have been added to allow joining, leaving, and sending text to group chats. * MeetMe has a new option 'G' to play an announcement before joining a conference. * Page has a new option 'A(x)' which will playback an announcement simultaneously to all paged phones (and optionally excluding the caller's one using the new option 'n') before the call is bridged. * The 'f' option to Dial has been augmented to take an optional argument. If no argument is provided, the 'f' option works as it always has. If an argument is provided, then the connected party information of all outgoing channels created during the Dial will be set to the argument passed to the 'f' option. * Dial now inherits the GOSUB_RETVAL from the peer, when the U() option runs a Gosub on the peer. * The OSP lookup application adds in/outbound network ID, optional security, number portability, QoS reporting, destination IP port, custom info and service type features. * Added new application VMSayName that will play the recorded name of the voicemail user if it exists, otherwise will play the mailbox number. * Added custom device states to ConfBridge bridges. Use 'confbridge:' to retrieve state for a particular bridge, where is the conference name * app_directory now allows exiting at any time using the operator or pound key. * Voicemail now supports setting a locale per-mailbox. * Two new applications are provided for declining counting phrases in multiple languages. See the application notes for SayCountedNoun and SayCountedAdj for more information. * Voicemail now runs the externnotify script when pollmailboxes is activated and notices a change. * Voicemail now includes rdnis within msgXXXX.txt file. * ExternalIVR now supports IPv6 addresses. * Added 'D' command to ExternalIVR. Details are available on the Asterisk wiki at https://wiki.asterisk.org/wiki/x/oQBB * ParkedCall and Park can now specify the parking lot to use. Dialplan Functions ------------------ * SRVQUERY and SRVRESULT functions added. This can be used to query and iterate over SRV records associated with a specific service. From the CLI, type 'core show function SRVQUERY' and 'core show function SRVRESULT' for more details on how these may be used. * PITCH_SHIFT dialplan function added. This function can be used to modify the pitch of a channel's tx and rx audio streams. * Added new dialplan functions CONNECTEDLINE and REDIRECTING which permits setting various connected line and redirecting party information. * CALLERID and CONNECTEDLINE dialplan functions have been extended to support ISDN subaddressing. * The CHANNEL() function now supports the "name" and "checkhangup" options. * For DAHDI channels, the CHANNEL() dialplan function now allows the dialplan to request changes in the configuration of the active echo canceller on the channel (if any), for the current call only. The syntax is: exten => s,n,Set(CHANNEL(echocan_mode)=off) The possible values are: on - normal mode (the echo canceller is actually reinitialized) off - disabled fax - FAX/data mode (NLP disabled if possible, otherwise completely disabled) voice - voice mode (returns from FAX mode, reverting the changes that were made when FAX mode was requested) * Added new dialplan function MASTER_CHANNEL(), which permits retrieving and setting variables on the channel which created the current channel. Administrators should take care to avoid naming conflicts, when multiple channels are dialled at once, especially when used with the Local channel construct (which all could set variables on the master channel). Usage of the HASH() dialplan function, with the key set to the name of the slave channel, is one approach that will avoid conflicts. * Added new dialplan function MUTEAUDIO() for muting inbound and/or outbound audio in a channel. * func_odbc now allows multiple row results to be retrieved without using mode=multirow. If rowlimit is set, then additional rows may be retrieved from the same query by using the name of the function which retrieved the first row as an argument to ODBC_FETCH(). * Added JABBER_RECEIVE, which permits receiving XMPP messages from the dialplan. This function returns the content of the received message. * Added REPLACE, which searches a given variable name for a set of characters, then either replaces them with a single character or deletes them. * Added PASSTHRU, which literally passes the same argument back as its return value. The intent is to be able to use a literal string argument to functions that currently require a variable name as an argument. * HASH-associated variables now can be inherited across channel creation, by prefixing the name of the hash at assignment with the appropriate number of underscores, just like variables. * GROUP_MATCH_COUNT has been improved to allow regex matching on category * CHANNEL(secure_bridge_signaling) and CHANNEL(secure_bridge_media) to set/get whether or not channels that are bridged to the current channel will be required to have secure signaling and/or media. * CHANNEL(secure_signaling) and CHANNEL(secure_media) to get whether or not the current channel has secure signaling and/or media. * For DAHDI/ISDN channels, the CHANNEL() dialplan function now supports the "no_media_path" option. Returns "0" if there is a B channel associated with the call. Returns "1" if no B channel is associated with the call. The call is either on hold or is a call waiting call. * Added option to dialplan function CDR(), the 'f' option allows for high resolution times for billsec and duration fields. * FILE() now supports line-mode and writing. * Added FIELDNUM(), which returns the 1-based offset of a field in a list. * FRAME_TRACE(), for tracking internal ast_frames on a channel. Dialplan Variables ------------------ * Added DYNAMIC_FEATURENAME which holds the last triggered dynamic feature. * Added DYNAMIC_PEERNAME which holds the unique channel name on the other side and is set when a dynamic feature is triggered. * Added PARKINGLOT which can be used with parkeddynamic feature.conf option to dynamically create a new parking lot matching the value this varible is set to. * Added PARKINGDYNAMIC which represents the template parkinglot defined in features.conf that should be the base for dynamic parkinglots. * Added PARKINGDYNCONTEXT which tells what context a newly created dynamic parkinglot should have. * Added PARKINGDYNEXTEN which tells what parking exten a newly created dynamic parkinglot should have. * Added PARKINGDYNPOS which holds what parking positions a dynamic parkinglot should have. Queue changes ------------- * Added "ready" option to QUEUE_MEMBER counting to count free agents whose wrap-up timeout has expired. * Added 'R' option to app_queue. This option stops moh and indicates ringing to the caller when an Agent's phone is ringing. This can be used to indicate to the caller that their call is about to be picked up, which is nice when one has been on hold for an extened period of time. * A new config option, penaltymemberslimit, has been added to queues.conf. When set this option will disregard penalty settings when a queue has too few members. * A new option, 'I' has been added to both app_queue and app_dial. By setting this option, Asterisk will not update the caller with connected line changes or redirecting party changes when they occur. * A 'relative-periodic-announce' option has been added to queues.conf. When enabled, this option will cause periodic announce times to be calculated from the end of announcements rather than from the beginning. * The autopause option in queues.conf can be passed a new value, "all." The result is that if a member becomes auto-paused, he will be paused in all queues for which he is a member, not just the queue that failed to reach the member. * Added dialplan function QUEUE_EXISTS to check if a queue exists * The queue logger now allows events to optionally propagate to a file, even when realtime logging is turned on. Additionally, realtime logging supports sending the event arguments to 5 individual fields, although it will fallback to the previous data definition, if the new table layout is not found. mISDN channel driver (chan_misdn) changes ---------------------------------------- * Added display_connected parameter to misdn.conf to put a display string in the CONNECT message containing the connected name and/or number if the presentation setting permits it. * Added display_setup parameter to misdn.conf to put a display string in the SETUP message containing the caller name and/or number if the presentation setting permits it. * Made misdn.conf parameters localdialplan and cpndialplan take a -1 to indicate the dialplan settings are to be obtained from the asterisk channel. * Made misdn.conf parameter callerid accept the "name" format used by the rest of the system. * Made use the nationalprefix and internationalprefix misdn.conf parameters to prefix any received number from the ISDN link if that number has the corresponding Type-Of-Number. NOTE: This includes comparing the incoming call's dialed number against the MSN list. * Added the following new parameters: unknownprefix, netspecificprefix, subscriberprefix, and abbreviatedprefix in misdn.conf to prefix any received number from the ISDN link if that number has the corresponding Type-Of-Number. * Added new dialplan application misdn_command which permits controlling the CCBS/CCNR functionality. * Added new dialplan function mISDN_CC which permits retrieval of various values from an active call completion record. * For PTP, you should manually send the COLR of the redirected-to party for an incomming redirected call if the incoming call could experience further redirects. Just set the REDIRECTING(to-num,i) = ${EXTEN} and set the REDIRECTING(to-pres) to the COLR. A call has been redirected if the REDIRECTING(from-num) is not empty. * For outgoing PTP redirected calls, you now need to use the inhibit(i) option on all of the REDIRECTING statements before dialing the redirected-to party. You still have to set the REDIRECTING(to-xxx,i) and the REDIRECTING(from-xxx,i) values. The PTP call will update the redirecting-to presentation (COLR) when it becomes available. * Added outgoing_colp parameter to misdn.conf to filter outgoing COLP information. thirdparty mISDN enhancements ----------------------------- mISDN has been modified by Digium, Inc. to greatly expand facility message support to allow: * Enhanced COLP support for call diversion and transfer. * CCBS/CCNR support. The latest modified mISDN v1.1.x based version is available at: http://svn.digium.com/svn/thirdparty/mISDN/trunk http://svn.digium.com/svn/thirdparty/mISDNuser/trunk Tagged versions of the modified mISDN code are available under: http://svn.digium.com/svn/thirdparty/mISDN/tags http://svn.digium.com/svn/thirdparty/mISDNuser/tags libpri channel driver (chan_dahdi) DAHDI changes ------------------------------------------- * The channel variable PRIREDIRECTREASON is now just a status variable and it is also deprecated. Use the REDIRECTING(reason) dialplan function to read and alter the reason. * For Q.SIG and ETSI PRI/BRI-PTP, you should manually send the COLR of the redirected-to party for an incomming redirected call if the incoming call could experience further redirects. Just set the REDIRECTING(to-num,i) = CALLERID(dnid) and set the REDIRECTING(to-pres) to the COLR. A call has been redirected if the REDIRECTING(count) is not zero. * For outgoing Q.SIG and ETSI PRI/BRI-PTP redirected calls, you need to use the inhibit(i) option on all of the REDIRECTING statements before dialing the redirected-to party. You still have to set the REDIRECTING(to-xxx,i) and the REDIRECTING(from-xxx,i) values. The call will update the redirecting-to presentation (COLR) when it becomes available. * Added the ability to ignore calls that are not in a Multiple Subscriber Number (MSN) list for PTMP CPE interfaces. * Added dynamic range compression support for dahdi channels. It is configured via the rxdrc and txdrc parameters in chan_dahdi.conf. * Added support for ISDN calling and called subaddress with partial support for connected line subaddress. * Added support for BRI PTMP NT mode. (Requires latest LibPRI.) * Added handling of received HOLD/RETRIEVE messages and the optional ability to transfer a held call on disconnect similar to an analog phone. * Added CallRerouting/CallDeflection support for Q.SIG, ETSI PTP, ETSI PTMP. Will reroute/deflect an outgoing call when receive the message. Can use the DAHDISendCallreroutingFacility to send the message for the supported switches. * Added standard location to add options to chan_dahdi dialing: Dial(DAHDI/g1[/extension[/options]]) Current options: K() R Reverse charging indication * Added Reverse Charging Indication (Collect calls) send/receive option. Send reverse charging in SETUP message with the chan_dahdi R dialing option. Dial(DAHDI/g1/extension/R) Access received reverse charge in SETUP message by: ${CHANNEL(reversecharge)} (requires latest LibPRI) * Added ability to send/receive keypad digits in the SETUP message. Send keypad digits in SETUP message with the chan_dahdi K() dialing option. Dial(DAHDI/g1/[extension]/K()) Access any received keypad digits in SETUP message by: ${CHANNEL(keypad_digits)} (requires latest LibPRI) * Added ability to send and receive ETSI Explicit Call Transfer (ECT) messages to eliminate tromboned calls. A tromboned call goes out an interface and comes back into the same interface. Tromboned calls happen because of call routing, call deflection, call forwarding, and call transfer. * Added the ability to send and receive ETSI Advice-Of-Charge messages. * Added the ability to support call waiting calls. (The SETUP has no B channel assigned.) * Added Malicious Call ID (MCID) event to the AMI call event class. * Added Message Waiting Indication (MWI) support for ISDN PTMP endpoints (phones). Asterisk Manager Interface -------------------------- * The Hangup action now accepts a Cause header which may be used to set the channel's hangup cause. * sslprivatekey option added to manager.conf and http.conf. Adds the ability to specify a separate .pem file to hold a private key. By default sslcert is used to hold both the public and private key. * Options in manager.conf and http.conf with the 'ssl' prefix have been replaced for options containing the 'tls' prefix. For example, 'sslenable' is now 'tlsenable'. This has been done in effort to keep ssl and tls options consistent across all .conf files. All affected sample.conf files have been modified to reflect this change. Previous options such as 'sslenable' still work, but options with the 'tls' prefix are preferred. * Added a MuteAudio AMI action for muting inbound and/or outbound audio in a channel. (res_mutestream.so) * The configuration file manager.conf now supports a channelvars option, which specifies a list of channel variables to include in each channel-oriented event. * The redirect command now has new parameters ExtraContext, ExtraExtension, and ExtraPriority to allow redirecting the second channel to a different location than the first. * Added new event "JabberStatus" in the Jabber module to monitor buddies status. * Added a "MixMonitorMute" AMI action for muting inbound and/or outbound audio in a MixMonitor recording. * The 'iax2 show peers' output is now similar to the expected output of 'sip show peers'. * Added Advice-Of-Charge events (AOC-S, AOC-D, and AOC-E) in the new aoc event class. * Added Advice-Of-Charge manager action, AOCMessage, for generating AOC-D and AOC-E messages on a channel. * A DBGetComplete event now follows a DBGetResponse, to make the DBGet action conform more closely to similar events. * Added a new eventfilter option per user to allow whitelisting and blacklisting of events. * Added optional parkinglot variable for park command. * Added ConnectedLineNum and ConnectedLineName headers to AMI events/responses if CallerIDNum and CallerIDName headers are also present. Channel Event Logging --------------------- * A new interface, CEL, is introduced here. CEL logs single events, much like the AMI, but it differs from the AMI in that it logs to db backends much like CDR does; is based on the event subsystem introduced by Russell, and can share in all its benefits; allows multiple backends to operate like CDR; is specialized to event data that would be of concern to billing sytems, like CDR. Backends for logging and accounting calls have been produced, but a new CDR backend is still in development. CDR --- * 'linkedid' and 'peeraccount' are new CDR fields available to CDR aficionados. linkedid is based on uniqueID, but spreads to other channels as transfers, dials, etc are performed. Thus the pieces of CDR can be grouped into multilegged sets. * Multiple files and formats can now be specified in cdr_custom.conf. * cdr_syslog has been added which allows CDRs to be written directly to syslog. See configs/cdr_syslog.conf.sample for more information. * A 'sequence' field has been added to CDRs which can be combined with linkedid or uniqueid to uniquely identify a CDR. * Handling of billsec and duration field has changed. If your table definition specifies those fields as float,double or similar they will now be logged with microsecond accuracy instead of a whole integer. Calendaring for Asterisk ------------------------ * A new set of modules were added supporing calendar integration with Asterisk. Dialplan functions for reading from and writing to calendars are included, as well as the ability to execute dialplan logic upon calendar event notifications. iCalendar, CalDAV, and Exchange Server calendars (via res_calendar_exchange for Exchange Server 2003 with no write or attendee support, and res_calendar_ews for Exchange Server 2007+ with full write and attendee support) are supported (Exchange 2003 support does not support forms-based authentication). Call Completion Supplementary Services for Asterisk --------------------------------------------------- * Call completion support has been added for SIP, DAHDI/ISDN, and DAHDI/analog. DAHDI/ISDN supports call completion for the following switch types: EuroIsdn(ETSI) for PTP and PTMP modes, and Qsig. See https://wiki.asterisk.org/wiki/x/2ABQ for details. Multicast RTP Support --------------------- * A new RTP engine and channel driver have been added which supports Multicast RTP. The channel driver can be used with the Page application to perform multicast RTP paging. The dial string format is: MulticastRTP/// Type can be either basic or linksys. Destination is the IP address and port for the RTP packets. Control address is specific to the linksys type and is used for sending the control packets unique to them. Security Events Framework ------------------------- * Asterisk has a new C API for reporting security events. The module res_security_log sends these events to the "security" logger level. Currently, AMI is the only Asterisk component that reports security events. However, SIP support will be coming soon. For more information on the security events framework, see the "Asterisk Security Framework" section of the Asterisk wiki at https://wiki.asterisk.org/wiki/x/wgBQ * SIP support was added in Asterisk 10 * This API now supports IPv6 addresses Fax --- * A technology independent fax frontend (res_fax) has been added to Asterisk. * A spandsp based fax backend (res_fax_spandsp) has been added. * The app_fax module has been deprecated in favor of the res_fax module and the new res_fax_spandsp backend. * The SendFAX and ReceiveFAX applications now send their log messages to a 'fax' logger level, instead of to the generic logger levels. To see these messages, the system's logger.conf file will need to direct the 'fax' logger level to one or more destinations; the logger.conf.sample file includes an example of how to do this. Note that if the 'fax' logger level is *not* directed to at least one destination, log messages generated by these applications will be lost, and that if the 'fax' logger level is directed to the console, the 'core set verbose' and 'core set debug' CLI commands will have no effect on whether the messages appear on the console or not. Miscellaneous ------------- * The transmit_silence_during_record option in asterisk.conf.sample has been removed. Now, in order to enable transmitting silence during record the transmit_silence option should be used. transmit_silence_during_record remains a valid option, but defaults to the behavior of the transmit_silence option. * Addition of the Unit Test Framework API for managing registration and execution of unit tests with the purpose of verifying the operation of C functions. * SendText is now implemented in chan_gtalk and chan_jingle. It will simply send XMPP text messages to the remote JID. * Modules.conf has a new option - "require" - that marks a module as critical for the execution of Asterisk. If one of the required modules fail to load, Asterisk will exit with a return code set to 2. * An 'X' option has been added to the asterisk application which enables #exec support. This allows #exec to be used in asterisk.conf. * jabber.conf supports a new option auth_policy that toggles auto user registration. * A new lockconfdir option has been added to asterisk.conf to protect the configuration directory (/etc/asterisk by default) during reloads. * The parkeddynamic option has been added to features.conf to enable the creation of dynamic parkinglots. * chan_dahdi now supports reporting alarms over AMI either by channel or span via the reportalarms config option. * chan_dahdi supports dialing configuring and dialing by device file name. DAHDI/span-name!local!1 will use /dev/dahdi/span-name/local/1 . Likewise it may appear in chan_dahdi.conf as 'channel => span-name!local!1'. * A new options for chan_dahdi.conf: 'ignore_failed_channels'. Boolean. False by default. If set, chan_dahdi will ignore failed 'channel' entries. Handy for the above name-based syntax as it does not depend on initialization order. * The Realtime dialplan switch now caches entries for 1 second. This provides a significant increase in performance (about 3X) for installations using this switchtype. * Distributed devicestate now supports the use of the XMPP protocol, in addition to AIS. For more information, please see the Distributed Device State section of the Asterisk wiki at https://wiki.asterisk.org/wiki/x/jw4iAQ * The addition of G.719 pass-through support. * Added support for 16khz Speex audio. This can be enabled by using 'allow=speex16' during device configuration. * The UNISTIM channel driver (chan_unistim) has been updated to support devices that have less than 3 lines on the LCD. * Realtime now supports database failover. See the sample extconfig.conf for details. * The addition of improved translation path building for wideband codecs. Sample rate changes during translation are now avoided unless absolutely necessary. * The addition of the res_stun_monitor module for monitoring and reacting to network changes while behind a NAT. * DTMF: Normal and Reverse Twist acceptance values can be set in dsp.conf. DTMF Valid/Invalid number of hits/misses can be set in dsp.conf. These allow support for any Administration. Default is AT&T values. CLI Changes ----------- * The 'core set debug' and 'core set verbose' commands, in previous versions, could optionally accept a filename, to apply the setting only to the code generated from that source file when Asterisk was built. However, there are some modules in Asterisk that are composed of multiple source files, so this did not result in the behavior that users expected. In this version, 'core set debug' and 'core set verbose' can optionally accept *module* names instead (with or without the .so extension), which applies the setting to the entire module specified, regardless of which source files it was built from. * New 'manager show settings' command showing the current settings loaded from manager.conf. * Added 'all' keyword to the CLI command "channel request hangup" so that you can send the channel hangup request to all channels. * Added a "core reload" CLI command that executes a global reload of Asterisk. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 1.6.1 to Asterisk 1.6.2 ------------- ------------------------------------------------------------------------------ SIP Changes ----------- * Added support for SUBSCRIBE/NOTIFY with dialog-info based call pickups. Snom phones use this for call pickup of extensions that the phone is subscribed to. * Added support for setting the domain in the URI for caller of an outbound call by using the SIPFROMDOMAIN channel variable. * Added a new configuration option "remotesecret" for authentication to remote services. For backwards compatibility, "secret" still has the same function as before, but now you can configure both a remote secret and a local secret for mutual authentication. * If the channel variable ATTENDED_TRANSFER_COMPLETE_SOUND is set, the sound will be played to the target of an attended transfer * Added two new configuration options, "qualifygap" and "qualifypeers", which allow finer control over how many peers Asterisk will qualify and the gap between them when all peers need to be qualified at the same time. * Added a new 'ignoresdpversion' option to sip.conf. When this is enabled (either globally or for a specific peer), chan_sip will treat any SDP data it receives as new data and update the media stream accordingly. By default, Asterisk will only modify the media stream if the SDP session version received is different from the current SDP session version. This option is required to interoperate with devices that have non-standard SDP session version implementations (observed with Microsoft OCS). This option is disabled by default. * The parsing of register => lines in sip.conf has been modified to allow a port to be present in the "user" portion. Please see the sip.conf.sample file for more information * Added support for subscribing to MWI on a remote server and making the status available as a mailbox. Please see the sip.conf.sample file for more information. * Added a function to remove SIP headers added in the dialplan before the first INVITE is generated - SIPRemoveHeader() * Channel variables set with setvar= in a device configuration is now set both for inbound and outbound calls. * Added support for ITU G.722.1 and G.722.1C (Siren7 and Siren14) media streams. IAX2 changes ------------ * Added immediate option to iax.conf * Added forceencryption option to iax.conf * Added Encryption and Trunk status to manager command "iaxpeers" Skinny Changes -------------- * The configuration file now holds separate sections for devices and lines. Please have a look at configs/skinny.conf.sample and change your skinny.conf accordingly. DAHDI Changes ------------- * chan_dahdi now supports MFC/R2 signaling when Asterisk is compiled with support for LibOpenR2. http://www.libopenr2.org/ * The UK option waitfordialtone has been added for use with BT analog lines. * Added a 'faxbuffers' configuration option to chan_dahdi.conf. This option is used in conjunction with the 'faxdetect' configuration option. When 'faxbuffers' is used and fax tones are detected, the channel will dynamically switch to the configured faxbuffers policy. For example, to use 6 buffers and a 'full' buffer policy for a fax transmission, add: faxbuffers=>6,full The faxbuffers configuration will be in affect until the call is torn down. * Added service message support for 4ESS/5ESS switches. Dialplan Functions ------------------ * For DAHDI channels, the CHANNEL() dialplan function now supports changing the channel's buffer policy (for the current call only), using this syntax: exten => s,n,Set(CHANNEL(buffers)=6,full) This would change the channel to the 'full' buffer policy and 6 (six) buffers. Possible options for this setting are the same as those in chan_dahdi.conf. * Added a new dialplan function, CURLOPT, which permits setting various options that may be useful with the CURL dialplan function, such as cookies, proxies, connection timeouts, passwords, etc. * Permit the syntax and synopsis fields of the corresponding dialplan functions to be individually set from func_odbc.conf. * Added debugging CLI functions to func_odbc, 'odbc read' and 'odbc write'. * func_odbc now may specify an insert query to execute, when the write query affects 0 rows (usually indicating that no such row exists). * Added a new dialplan function, LISTFILTER, which permits removing elements from a set list, by name. Uses the same general syntax as the existing CUT and FIELDQTY dialplan functions, which also manage lists. * Added REALTIME_FIELD and REALTIME_HASH, which should aid users in better obtaining realtime data from the dialplan. * Added LOCAL_PEEK, which allows access to variables in any stack frame within a subroutine when using the GoSub() and Return() applications. * Added AUDIOHOOK_INHERIT. For information on its use, please see the output of "core show function AUDIOHOOK_INHERIT" from the CLI * Added AES_ENCRYPT. For information on its use, please see the output of "core show function AES_ENCRYPT" from the CLI * Added AES_DECRYPT. For information on its use, please see the output of "core show function AES_DECRYPT" from the CLI * func_odbc now supports database transactions across multiple queries. Applications ------------ * Scheduled meetme conferences may now have their end times extended by using MeetMeAdmin. * app_authenticate now gives the ability to select a prompt other than the default. * app_directory now pays attention to the searchcontexts setting in voicemail.conf and will look through all contexts, if no context is specified in the initial argument. * A new application, Originate, has been introduced, that allows asynchronous call origination from the dialplan. * Voicemail now permits setting the emailsubject and emailbody per mailbox, in addition to the setting in the "general" context. * Added ConfBridge dialplan application which does conference bridges without DAHDI. For information on its use, please see the output of "core show application ConfBridge" from the CLI. Miscellaneous ------------- * The Asterisk CLI has a new command, "channel redirect", which is similar in operation to the AMI Redirect action. * extensions.conf now allows you to use keyword "same" to define an extension without actually specifying an extension. It uses exactly the same pattern as previously used on the last "exten" line. For example: exten => 123,1,NoOp(something) same => n,SomethingElse() * musiconhold.conf classes of type 'files' can now use relative directory paths, which are interpreted as relative to the astvarlibdir setting in asterisk.conf. * All deprecated CLI commands are removed from the sourcecode. They are now handled by the new clialiases module. See cli_aliases.conf.sample file. * Times within timespecs are now accurate down to the minute. This is a change from historical Asterisk, which only provided timespecs rounded to the nearest even (read: evenly divisible by 2) minute mark. * The realtime switch now supports an option flag, 'p', which disables searches for pattern matches. * In addition to a time range and date range, timespecs now accept a 5th optional argument, timezone. This allows you to perform time checks on alternate timezones, especially if those daylight savings time ranges vary from your machine's native timezone. See GotoIfTime, ExecIfTime, IFTIME(), and timed includes. * The contrib/scripts/ directory now has a script called sip_nat_settings that will give you the correct output for an asterisk box behind nat. It will give you the externhost and localnet settings. * The Asterisk core now supports ITU G.722.1 and G.722.1C media streams, and can connect calls in passthrough mode, as well as record and play back files. * Successful and unsuccessful call pickup can now be alerted through sounds, by using pickupsound and pickupfailsound in features.conf. * ASTVARRUNDIR is now set to $(localstatedir)/run/asterisk by default. This means the asterisk pid file will now be in /var/run/asterisk/asterisk.pid on LINUX instead of the /var/run/asterisk.pid where it used to be. This will make installs as non-root easier to manage. CDR --- * The cdr.conf file must exist and be correctly programmed in order for CDR records to be written; they will no longer be explicitly written. Asterisk Manager Interface -------------------------- * When using the AMI over HTTP, you can now include a 'SuppressEvents' header (with a non-empty value) in your request. If you do this, any pending AMI events will *not* be included in the response to your request as they would normally, but will be left in the event queue for the next request you make to retrieve. For some applications, this will allow you to guarantee that you will only see events in responses to 'WaitEvent' actions, and can better know when to expect them. To know whether the Asterisk server supports this header or not, your client can inspect the first response back from the server to see if it includes this header: Pragma: SuppressEvents If this is included, the server supports event suppression. * Added 4 new Actions to list skinny device(s) and line(s) SKINNYdevices SKINNYshowdevice SKINNYlines SKINNYshowline LDAP Schema File Additions -------------------------- * Added AsteriskDialplan, AsteriskAccount and AsteriskMailbox objectClasses to allow standalone dialplan, account and mailbox entries (STRUCTURAL) * Added new Fields: - AstAccountLanguage, AstAccountTransport, AstAccountPromiscRedir, - AstAccountAccountCode, AstAccountSetVar, AstAccountAllowOverlap, - AstAccountVideoSupport, AstAccountIgnoreSDPVersion * Removed redundant IPaddr (there's already IPAddress) - Gives more configuration Flags for SIP-Users available (tested) - Allows to create Asterisk Attributes in defined Asterisk ObjectClasses without extensibleObject (which really should be the last resort); gives also additional possibilities for LDAP-filter ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 1.6.0 to Asterisk 1.6.1 ------------- ------------------------------------------------------------------------------ Device State Handling --------------------- * The event infrastructure in Asterisk got another big update to help support distributed events. It currently supports distributed device state and distributed Voicemail MWI (Message Waiting Indication). A new module has been merged, res_ais, which facilitates communicating events between servers. It uses the SAForum AIS (Service Availability Forum Application Interface Specification) CLM (Cluster Management) and EVT (Event) services to maintain a cluster of Asterisk servers, and to share events between them. For more information on setting this up, refer to the Distributed Device State section of the Asterisk wiki at https://wiki.asterisk.org/wiki/x/jw4iAQ Dialplan Functions ------------------ * Added a new dialplan function, AST_CONFIG(), which allows you to access variables from an Asterisk configuration file. * The JACK_HOOK function now has a c() option to supply a custom client name. * Added two new dialplan functions from libspeex for audio gain control and denoise, AGC() and DENOISE(). Both functions can be applied to the tx and rx directions of a channel from the dialplan. * The SMDI_MSG_RETRIEVE function now has the ability to search for SMDI messages based on other parameters. The default is still to search based on the forwarding station ID. However, there are new options that allow you to search based on the message desk terminal ID, or the message desk number. * TIMEOUT() has been modified to be accurate down to the millisecond. * ENUM*() functions now include the following new options: - 'u' returns the full URI and does not strip off the URI-scheme. - 's' triggers ISN specific rewriting - 'i' looks for branches into an Infrastructure ENUM tree - 'd' for a direct DNS lookup without any flipping of digits. * TXCIDNAME() has a new zone-suffix parameter (which defaults to 'e164.arpa') * CHANNEL() now has options for the maximum, minimum, and standard or normal deviation of jitter, rtt, and loss for a call using chan_sip. DAHDI channel driver (chan_dahdi) Changes ---------------------------------------- * Channels can now be configured using named sections in chan_dahdi.conf, just like other channel drivers, including the use of templates. * The default for pridialplan has changed from 'national' to 'unknown'. PBX Changes ----------- * It is now possible to specify a pattern match as a hint. Once a phone subscribes to something that matches the pattern a hint will be created using the contents and variables evaluated. * Dialplan matching has been extended to allow an extension to return to the PBX core to wait for more digits. This is done by using the new dialplan application called "Incomplete". This will permit a whole new level of extension control, by giving the administrator more control over early matches employing one of the short-circuit pattern match operators. Note that custom applications can trigger this same behavior by returning the special value AST_PBX_INCOMPLETE. Application Changes ------------------- * Directory now permits both first and last names to be matched at the same time. In addition, the number of digits to enter of the name can be set in the arguments to Directory; previously, you could enter only 3, regardless of how many names are in your company. For large companies, this should be quite helpful. * Voicemail now permits a mailbox setting to wrap around from first to last messages, if the "messagewrap" option is set to a true value. * Voicemail now permits an external script to be run, for password validation. The script should output "VALID" or "INVALID" on stdout, depending upon the wish to validate or invalidate the password given. Arguments are: "mailbox" "context" "oldpass" "newpass". See the sample voicemail.conf for more details * Dial has a new option: F(context^extension^pri), which permits a callee to continue in the dialplan, at the specified label, if the caller hangs up. * ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the technology name (e.g. SIP, IAX, etc) of the channel being spied on. * The Jack application now has a c() option to supply a custom client name. * Chanspy has a new option, 'B', which can be used to "barge" on a call. This is like the pre-existing whisper mode, except that the spy can also talk to the participant on the bridged channel as well. * Chanspy has a new option, 'n', which will allow for the spied-on party's name to be spoken instead of the channel name or number. For more information on the use of this option, issue the command "core show application ChanSpy" from the Asterisk CLI. * Chanspy has a new option, 'd', which allows the spy to use DTMF to swap between spy modes. Use of this feature overrides the typical use of numeric DTMF. In other words, if using the 'd' option, it is not possible to enter a number to append to the first argument to Chanspy(). Pressing 4 will change to spy mode, pressing 5 will change to whisper mode, and pressing 6 will change to barge mode. * ExternalIVR now takes several options that affect the way it performs, as well as having several new commands. Please see the External IVR page on the Asterisk wiki for complete documentation: https://wiki.asterisk.org/wiki/x/oQBB * Added ability to communicate over a TCP socket instead of forking a child process for the ExternalIVR application. * ChanIsAvail has a new option, 'a', which will return all available channels instead of just the first one if you give the function more then one channel to check. * PrivacyManager now takes an option where you can specify a context where the given number will be matched. This way you have more control over who is allowed and it stops the people who blindly enter 10 digits. * ForkCDR has new options: 'a' updates the answer time on the new CDR; 'A' locks answer times, disposition, on orig CDR against updates; 'D' Copies the disposition from the orig CDR to the new CDR after reset; 'e' sets the 'end' time on the original CDR; 'R' prevents the new CDR from being reset; 's(var=val)' adds/changes the 'var' variable on the original CDR; 'T' forces ast_cdr_end(), ast_cdr_answer(), obey the LOCKED flag on cdr's in the chain, and also the ast_cdr_setvar() func. * The Dial() application no longer copies the language used by the caller to the callee's channel. If you desire for the caller's channel's language to be used for file playback to the callee, then the file specified may be prepended with "${CHANNEL(language)}/" . * SendImage() no longer hangs up the channel on error; instead, it sets the status variable SENDIMAGESTATUS to one of 'SUCCESS', 'FAILURE', or 'UNSUPPORTED'. This change makes SendImage() more consistent with other applications. * Park has a new option, 's', which silences the announcement of the parking space number. * A non-numeric, zero, or negative timeout specified to Dial() will now be interpreted as invalid input and will be assumed to mean that no timeout is desired. SIP Changes ----------- * Added DNS manager support to registrations for peers referencing peer entries. DNS manager runs in the background which allows DNS lookups to be run asynchronously as well as periodically updating the IP address. These properties allow for better performance as well as recovery in the event of an IP change. * Performance improvements via using hash tables (astobj2) and doubly-linked lists to improve load/reload of large numbers of peers/users by ~40x (for large lists of peers). These changes also provide performance improvements for call setup and tear down. * Added ability to specify registration expiry time on a per registration basis in the register line. * Added support for T140 RED - redundancy in T.140 to prevent text loss due to lost packets. * Added t38pt_usertpsource option. See sip.conf.sample for details. * Added SIPnotify AMI command, for sending arbitrary SIP notify commands. * 'sip show peers' and 'sip show users' display their entries sorted in alphabetical order, as opposed to the order they were in, in the config file or database. * Videosupport now supports an additional option, "always", which always sets up video RTP ports, even on clients that don't support it. This helps with callfiles and certain transfers to ensure that if two video phones are connected, they will always share video feeds. IAX Changes ----------- * Existing DNS manager lookups extended to check for SRV records. * IAX2 encryption support has been improved to support periodic key rotation within a call for enhanced security. The option "keyrotate" has been provided to disable this functionality to preserve backwards compatibility with older versions of IAX2 that do not support key rotation. CLI Changes ----------- * New CLI command, "data get [ []]" which retrieves the data tree based on the given . * New CLI command "data show providers" that will display all the registered callbacks. * New CLI command, "config reload " which reloads any module that references that particular configuration file. Also added "config list" which shows which configuration files are in use. * New CLI commands, "pri show version" and "ss7 show version" that will display which version of libpri and libss7 are being used, respectively. A new API call was added so trunk will now have to be compiled against a versions of libpri and libss7 that have them or it will not know that these libraries exist. * The commands "core show globals", "core set global" and "core set chanvar" has been deprecated in favor of the more semanticly correct "dialplan show globals", "dialplan set chanvar" and "dialplan set global". * New CLI command "dialplan show chanvar" to list all variables associated with a given channel. DNS manager changes ------------------- * Addresses managed by DNS manager now can check to see if there is a DNS SRV record for a given domain and will use that hostname/port if present. AMI - The manager (TCP/TLS/HTTP) -------------------------------- * The Status command now takes an optional list of variables to display along with channel status. * The QueueEntry event now also includes the channel's uniqueid ODBC Changes ------------ * res_odbc no longer has a limit of 1023 total possible unshared connections, as some people were running into this limit. This limit has been increased to 4.2 billion. Queue changes ------------- * The TRANSFER queue log entry now includes the the caller's original position in the transferred-from queue. * A new configuration option, "timeoutpriority" has been added. Please see the section labeled "QUEUE TIMING OPTIONS" in configs/queues.conf.sample for a detailed explanation of the option as well as an explanation about timeout options in general * Added a new option - C - for forcing the "answered elsewhere" flag on cancellation of calls in to members of the queue. This is to avoid the call to a member of a queue having the call listed as a "missed call". Realtime changes ---------------- * Several (ODBC, Postgres, MySQL, SQLite) realtime drivers have been given adaptive capabilities. What this means in practical terms is that if your realtime table lacks critical fields, Asterisk will now emit warnings to that effect. Also, some of the realtime drivers have the ability (if configured) to automatically add those columns to the table with the correct type and length. Miscellaneous ------------- * The channel variable ATTENDED_TRANSFER_COMPLETE_SOUND can now be set using the 'setvar' option to cause a given audio file to be played upon completion of an attended transfer. Currently it works for DAHDI, IAX2, SIP, and Skinny channels only. * You can now compile Asterisk against the Hoard Memory Allocator, see the Hoard page on the Asterisk wiki for more information: https://wiki.asterisk.org/wiki/x/pQBB * Config file variables may now be appended to, by using the '+=' append operator. This is most helpful when working with long SQL queries in func_odbc.conf, as the queries no longer need to be specified on a single line. * CDR config file, cdr.conf, has an added option, "initiatedseconds", which will add a second to the billsec when the ending time is set, if the number in the microseconds field of the end time is greater than the number of microseconds in the answer time. This allows users to count the 'initiated' seconds in their billing records. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 1.4.X to Asterisk 1.6.0 ------------- ------------------------------------------------------------------------------ AMI - The manager (TCP/TLS/HTTP) -------------------------------- * Manager has undergone a lot of changes, all of them documented on the Asterisk wiki at https://wiki.asterisk.org/wiki/x/tQBB * Manager version has changed to 1.1 * Added a new action 'CoreShowChannels' to list currently defined channels and some information about them. * Added a new action 'SIPshowregistry' to list SIP registrations. * Added TLS support for the manager interface and HTTP server * Added the URI redirect option for the built-in HTTP server * The output of CallerID in Manager events is now more consistent. CallerIDNum is used for number and CallerIDName for name. * Enable https support for builtin web server. See configs/http.conf.sample for details. * Added a new action, GetConfigJSON, which can return the contents of an Asterisk configuration file in JSON format. This is intended to help improve the performance of AJAX applications using the manager interface over HTTP. * SIP and IAX manager events now use "ChannelType" in all cases where we indicate channel driver. Previously, we used a mixture of "Channel" and "ChannelDriver" headers. * Added a "Bridge" action which allows you to bridge any two channels that are currently active on the system. * Added a "ListAllVoicemailUsers" action that allows you to get a list of all the voicemail users setup. * Added 'DBDel' and 'DBDelTree' manager commands. * cdr_manager now reports events via the "cdr" level, separating it from the very verbose "call" level. * Manager users are now stored in memory. If you change the manager account list (delete or add accounts) you need to reload manager. * Added Masquerade manager event for when a masquerade happens between two channels. * Added "manager reload" command for the CLI * Lots of commands that only provided information are now allowed under the Reporting privilege, instead of only under Call or System. * The IAX* commands now require either System or Reporting privilege, to mirror the privileges of the SIP* commands. * Added ability to retrieve list of categories in a config file. * Added ability to retrieve the content of a particular category. * Added ability to empty a context. * Created new action to create a new file. * Updated delete action to allow deletion by line number with respect to category. * Added new action insert to add new variable to category at specified line. * Updated action newcat to allow new category to be inserted in file above another existing category. * Added new event "JitterBufStats" in the IAX2 channel * Originate now requires the Originate privilege and, if you want to call out to a subshell, it requires the System privilege, as well. This was done to enhance manager security. * Originate now accepts codec settings with "Codecs: alaw, ulaw, h264" * New command: Atxfer. See https://wiki.asterisk.org/wiki/x/uABB for more details or manager show command Atxfer from the CLI * New command: IAXregistry. See https://wiki.asterisk.org/wiki/x/uABB for more details or manager show command IAXregistry from the CLI Dialplan functions ------------------ * Added the DEVICE_STATE() dialplan function which allows retrieving any device state in the dialplan, as well as creating custom device states that are controllable from the dialplan. * Extend CALLERID() function with "pres" and "ton" parameters to fetch string representation of calling number presentation indicator and numeric representation of type of calling number value. * MailboxExists converted to dialplan function * A new option to Dial() for telling IP phones not to count the call as "missed" when dial times out and cancels. * Added LOCK(), TRYLOCK(), and UNLOCK(), which provide a single level dialplan mutex. No deadlocks are possible, as LOCK() only allows a single lock to be held for any given channel. Also, locks are automatically freed when a channel is hung up. * Added HINT() dialplan function that allows retrieving hint information. Hints are mappings between extensions and devices for the sake of determining the state of an extension. This function can retrieve the list of devices or the name associated with a hint. * Added EXTENSION_STATE() dialplan function which allows retrieving the state of any extension. * Added SYSINFO() dialplan function which allows retrieval of system information * Added a new dialplan function, DIALPLAN_EXISTS(), which allows you to check for the existence of a dialplan target. * Added two new dialplan functions, TOUPPER and TOLOWER, which convert a string to upper and lower case, respectively. * When bridging, Asterisk sets the BRIDGEPVTCALLID to the channel drivers unique ID for the call (not the Asterisk call ID or unique ID), provided that the channel driver supports this. For SIP, you get the SIP call-ID for the bridged channel which you can store in the CDR with a custom field. CLI Changes ----------- * Added CLI permissions, config file: cli_permissions.conf default is to allow all commands for every local user/group. Also this new feature added three new CLI commands: - cli check permissions {|@|@} [] - cli reload permissions - cli show permissions * New CLI command "core show hint" (usage: core show hint ) * New CLI command "core show settings" * Added 'core show channels count' CLI command. * Added the ability to set the core debug and verbose values on a per-file basis. * Added 'queue pause member' and 'queue unpause member' CLI commands * Ability to set process limits ("ulimit") without restarting Asterisk * Enhanced "agi debug" to print the channel name as a prefix to the debug output to make debugging on busy systems much easier. * New CLI commands "dialplan set extenpatternmatching true/false" * New CLI command: "core set chanvar" to set a channel variable from the CLI. * Added an easy way to execute Asterisk CLI commands at startup. Any commands listed in the startup_commands section of cli.conf will get executed. * Added a CLI command, "devstate change", which allows you to set custom device states from the func_devstate module that provides the DEVICE_STATE() function and handling of the "Custom:" devices. * New CLI command: "sip show sched" which shows all ast_sched entries for sip, sorted into the different possible callbacks, with the number of entries currently scheduled for each. Gives you a feel for how busy the sip channel driver is. * Added 'skinny show lines verbose' CLI command. This will show the subs for every channel. * Cleanup another bunch of CLI commands. Now all modules follow the same schema. (Done by lmadsen, junky and mvanbaak during the devcon 2008) SIP changes ----------- * Added a new 'faxdetect=yes|no' configuration option to sip.conf. When this option is enabled, Asterisk will watch for a CNG tone in the incoming audio for a received call. If it is detected, the channel will jump to the 'fax' extension in the dialplan. * The default SIP useragent= identifier now includes the Asterisk version * A new option, match_auth_username in sip.conf changes the matching of incoming requests. If set, and the incoming request carries authentication info, the username to match in the users list is taken from the Digest header rather than from the From: field. This feature is considered experimental. * The "musiconhold" and "musicclass" settings in sip.conf are now removed, since they where replaced by "mohsuggest" and "mohinterpret" in version 1.4 * The "localmask" setting was removed in version 1.2 and the reminder about it being removed is now also removed. * A new option "busylevel" for setting a level of calls where asterisk reports a device as busy, to separate it from call-limit. This value is also added to the SIP_PEER dialplan function. * A new realtime family called "sipregs" is now supported to store SIP registration data. If this family is defined, "sippeers" will be used for configuration and "sipregs" for registrations. If it's not defined, "sippeers" will be used for registration data, as before. * The SIPPEER function have new options for port address, call and pickup groups * Added support for T.140 realtime text in SIP/RTP * The "checkmwi" option has been removed from sip.conf, as it is no longer required due to the restructuring of how MWI is handled. See the descriptions in this file of the "pollmailboxes" and "pollfreq" options to voicemail.conf for more information. * Added rtpdest option to CHANNEL() dialplan function. * Added SIPREFERRINGCONTEXT and SIPREFERREDBYHDR variables which are set when a transfer takes place. * SIP now adds a header to the CANCEL if the call was answered by another phone in the same dial command, or if the new c option in dial() is used. * The new default is that 100 Trying is not sent on REGISTER attempts as the RFC specifically states it is not needed. For phones, however, that do require it the "registertrying" option has been added so it can be enabled. * A new option called "callcounter" (global/peer/user level) enables call counters needed for better status reports needed for queues and SIP subscriptions. (Call-Limit was previously used to enable this functionality). * New settings for timer T1 and timer B on a global level or per device. This makes it possible to force timeout faster on non-responsive SIP servers. These settings are considered advanced, so don't use them unless you have a problem. * Added a dial string option to be able to set the To: header in an INVITE to any SIP uri. * Added a new global and per-peer option, qualifyfreq, which allows you to configure the qualify frequency. * Added SIP Session Timers support (RFC 4028). This prevents stuck SIP sessions that were not properly torn down due to network or endpoint failures during an established SIP session. * Added experimental TCP and TLS support for SIP. See https://wiki.asterisk.org/wiki/x/ygBB and configs/sip.conf.sample for more information on how it is used. * Added a new configuration option "authfailureevents" that enables manager events when a peer can't authenticate properly. * Added DNS manager support to registrations for peers not referencing a peer entry. IAX2 changes ------------ * Added the trunkmaxsize configuration option to chan_iax2. * Added the srvlookup option to iax.conf * Added support for OSP. The token is set and retrieved through the CHANNEL() dialplan function. XMPP Google Talk/Jingle changes ------------------------------- * Added the bindaddr option to gtalk.conf. Skinny changes ------------- * Added skinny show device, skinny show line, and skinny show settings CLI commands. * Proper codec support in chan_skinny. * Added settings for IP and Ethernet QoS requests MGCP changes ------------ * Added separate settings for media QoS in mgcp.conf Console Channel Driver changes ------------------------------ * Added experimental support for video send & receive to chan_oss. This requires SDL and ffmpeg/avcodec, plus Video4Linux or X11 to act as a video source. Phone channel changes (chan_phone) ---------------------------------- * Added G729 passthrough support to chan_phone for Sigma Designs boards. H.323 channel Changes --------------------- * H323 remote hold notification support added (by NOTIFY message and/or H.450 supplementary service) Local channel changes --------------------- * The device state functionality in the Local channel driver has been updated to indicate INUSE or NOT_INUSE when a Local channel is being used as opposed to just UNKNOWN if the extension exists. * Added jitterbuffer support for chan_local. This allows you to use the generic jitterbuffer on incoming calls going to Asterisk applications. For example, this would allow you to use a jitterbuffer for an incoming SIP call to Voicemail by putting a Local channel in the middle. This feature is enabled by using the 'j' option in the Dial string to the Local channel in conjunction with the existing 'n' option for local channels. * A 'b' option has been added which causes chan_local to return the actual channel that is behind it when queried. This is useful for transfer scenarios as the actual channel will be transferred, not the Local channel. Agent channel changes ---------------------- * The ackcall and endcall options are now supplemented with options acceptdtmf and enddtmf. These allow for the DTMF keypress to be configurable. The options default to their old hard-coded values ('#' and '*' respectively) so this should not break any existing agent installations. DAHDI channel driver (chan_dahdi) Changes ---------------------------------------- * SS7 support (via libss7 library) * In India, some carriers transmit CID via dtmf. Some code has been added that will handle some situations. The cidstart=polarity_IN choice has been added for those carriers that transmit CID via dtmf after a polarity change. * CID matching information is now shown when doing 'dialplan show'. * Added dahdi show version CLI command. * Added setvar support to chan_dahdi.conf channel entries. * Added two new options: mwimonitor and mwimonitornotify. These options allow you to enable MWI monitoring on FXO lines. When the MWI state changes, the script specified in the mwimonitornotify option is executed. An internal event indicating the new state of the mailbox is also generated, so that the normal MWI facilities in Asterisk work as usual. * Added signalling type 'auto', which attempts to use the same signalling type for a channel as configured in DAHDI. This is primarily designed for analog ports, but will also work for digital ports that are configured for FXS or FXO signalling types. This mode is also the default now, so if your chan_dahdi.conf does not specify signalling for a channel (which is unlikely as the sample configuration file has always recommended specifying it for every channel) then the 'auto' mode will be used for that channel if possible. * Added a 'dahdi set dnd' command to allow CLI control of the Do-Not-Disturb state for a channel; also ensured that the DNDState Manager event is emitted no matter how the DND state is set or cleared. New Channel Drivers ------------------- * Added a new channel driver, chan_unistim. See the Asterisk wiki at https://wiki.asterisk.org/wiki/x/vgsiAQ and configs/unistim.conf.sample for details. This new channel driver allows you to use Nortel i2002, i2004, and i2050 phones with Asterisk. * Added a new channel driver, chan_console, which uses portaudio as a cross platform audio interface. It was written as a channel driver that would work with Mac CoreAudio, but portaudio supports a number of other audio interfaces, as well. Note that this channel driver requires v19 or higher of portaudio; older versions have a different API. DUNDi changes ------------- * Added the ability to specify arguments to the Dial application when using the DUNDi switch in the dialplan. * Added the ability to set weights for responses dynamically. This can be done using a global variable or a dialplan function. Using the SHELL() function would allow you to have an external script set the weight for each response. * Added two new dialplan functions, DUNDIQUERY and DUNDIRESULT. These functions will allow you to initiate a DUNDi query from the dialplan, find out how many results there are, and access each one. * Added the ability to specifiy a port for a dundi peer. ENUM changes ------------ * Added two new dialplan functions, ENUMQUERY and ENUMRESULT. These functions will allow you to initiate an ENUM lookup from the dialplan, and Asterisk will cache the results. ENUMRESULT can be used to access the results without doing multiple DNS queries. Voicemail Changes ----------------- * Added the ability to customize which sound files are used for some of the prompts within the Voicemail application by changing them in voicemail.conf * Added the ability for the "voicemail show users" CLI command to show users configured by the dynamic realtime configuration method. * MWI (Message Waiting Indication) handling has been significantly restructured internally to Asterisk. It is now totally event based instead of polling based. The voicemail application will notify other modules that have subscribed to MWI events when something in the mailbox changes. This also means that if any other entity outside of Asterisk is changing the contents of mailboxes, then the voicemail application still needs to poll for changes. Examples of situations that would require this option are web interfaces to voicemail or an email client in the case of using IMAP storage. So, two new options have been added to voicemail.conf to account for this: "pollmailboxes" and "pollfreq". See the sample configuration file for details. * Added "tw" language support * Added support for storage of greetings using an IMAP server * Added ability to customize forward, reverse, stop, and pause keys for message playback * SMDI is now enabled in voicemail using the smdienable option. * A "lockmode" option has been added to asterisk.conf to configure the file locking method used for voicemail, and potentially other things in the future. The default is the old behavior, lockfile. However, there is a new method, "flock", that uses a different method for situations where the lockfile will not work, such as on SMB/CIFS mounts. * Added the ability to backup deleted messages, to ease recovery in the case that a user accidentally deletes a message, and discovers that they need it. * Reworked the SMDI interface in Asterisk. The new way to access SMDI information is through the new functions, SMDI_MSG_RETRIEVE() and SMDI_MSG(). The file smdi.conf can now be configured with options to map SMDI station IDs to Asterisk voicemail boxes. The SMDI interface can also poll for MWI changes when some outside entity is modifying the state of the mailbox (such as IMAP storage or a web interface of some kind). * Added the support for marking messages as "urgent." There are two methods to accomplish this. One is to pass the 'U' option to VoiceMail(). Another way to mark a message as urgent is to specify "review=yes" in voicemail.conf. Doing this will cause allow the user to mark the message as urgent after he has recorded a voicemail by following the voice instructions. When listening to voicemails using VoiceMailMain urgent messages will be presented before other messages Queue changes ------------- * Added the general option 'shared_lastcall' so that member's wrapuptime may be used across multiple queues. * Added QUEUE_VARIABLES function to set queue variables added setqueuevar and setqueueentryvar options for each queue, see queues.conf.sample for details. * Added keepstats option to queues.conf which will keep queue statistics during a reload. * setinterfacevar option in queues.conf also now sets a variable called MEMBERNAME which contains the member's name. * Added 'Strategy' field to manager event QueueParams which represents the queue strategy in use. * Added option to run macro when a queue member is connected to a caller, see queues.conf.sample for details. * app_queue now has a 'loose' option which is almost exactly like 'strict' except it does not count paused queue members as unavailable. * Added min-announce-frequency option to queues.conf which allows you to control the minimum amount of time between queue announcements for use when the caller's queue position changes frequently. * Added additional information to EXITWITHTIMEOUT and EXITWITHKEY events in the queue log. * Added ability for non-realtime queues to have realtime members * Added the "linear" strategy to queues. * Added the "wrandom" strategy to queues. * Added new channel variable QUEUE_MIN_PENALTY * QUEUE_MAX_PENALTY and QUEUE_MIN_PENALTY may be adjusted in mid-call by defining rules in queuerules.conf. See configs/queuerules.conf.sample for details * Added a new parameter for member definition, called state_interface. This may be used so that a member may be called via one interface but have a different interface's device state reported. * Added new CLI and Manager commands relating to reloading queues. From the CLI, see "queue reload", "queue reset stats". Also see "manager show command QueueReload" and "manager show command QueueReset." * New configuration option: randomperiodicannounce. If a list of periodic announcements is specified by the periodic-announce option, then one will be chosen randomly when it is time to play a periodic announcment * New configuration options: announce-position now takes two more values in addition to "yes" and "no." Two new options, "limit" and "more," are allowed. These are tied to another option, announce-position-limit. By setting announce-position to "limit" callers will only have their position announced if their position is less than what is specified by announce-position-limit. If announce-position is set to "more" then callers beyond the position specified by announce-position-limit will be told that their are more than announce-position-limit callers waiting. * Two new queue log events have been added. An ADDMEMBER event will be logged when a realtime queue member is added and a REMOVEMEMBER event will be logged when a realtime queue member is removed. Since there is no calling channel associated with these events, the string "REALTIME" is placed where the channel's unique id is typically placed. * The configuration method for the "joinempty" and "leavewhenempty" options has changed to a comma-separated list of methods of determining member availability instead of vague terms such as "yes," "loose," "no," and "strict." These old four values are still accepted for backwards-compatibility, though. * The average talktime is now calculated on queues. This information is reported via the CLI commands "queue show" and "queues show"; through the AMI events AgentComplete, QueueSummary, and QueueParams; and through the channelvariable QUEUETALKTIME if setinterfacevar=yes is set for the queue. MeetMe Changes -------------- * The 'o' option to provide an optimization has been removed and its functionality has been enabled by default. * When a conference is created, the UNIQUEID of the channel that caused it to be created is stored. Then, every channel that joins the conference will have the MEETMEUNIQUEID channel variable set with this ID. This can be used to relate callers that come and go from long standing conferences. * Added a new application, MeetMeChannelAdmin, which is similar to MeetMeAdmin, except it does operations on a channel by name, instead of number in a conference. This is a very useful feature in combination with the 'X' option to ChanSpy. * Added 'C' option to Meetme which causes a caller to continue in the dialplan when kicked out. * Added new RealTime functionality to provide support for scheduled conferencing. This includes optional messages to the caller if they attempt to join before the schedule start time, or to allow the caller to join the conference early. Also included is optional support for limiting the number of callers per RealTime conference. * Added the S() and L() options to the MeetMe application. These are pretty much identical to the S() and L() options to Dial(). They let you set timeouts for the conference, as well as have warning sounds played to let the caller know how much time is left, and when it is running out. * Added the ability to do "meetme concise" with the "meetme" CLI command. This extends the concise capabilities of this CLI command to include listing all conferences, instead of an addition to the other sub commands for the "meetme" command. * Added the ability to specify the music on hold class used to play into the conference when there is only one member and the M option is used. * Added MEETME_INFO dialplan function which provides a way to query various properties of a Meetme conference. * Added new admin features: *81: Roll call, *82: eject all, *83: mute all, and *84: record in-conf Other Dialplan Application Changes ---------------------------------- * Argument support for Gosub application * From the to-do lists: straighten out the app timeout args: Wait() app now really does 0.3 seconds- was truncating arg to an int. WaitExten() same as Wait(). Congestion() - Now takes floating pt. argument. Busy() - now takes floating pt. argument. Read() - timeout now can be floating pt. WaitForRing() now takes floating pt timeout arg. SpeechBackground() -- clarified in the docstrings that the timeout is an integer seconds. * Added 's' option to Page application. * Added an optional timeout argument to the Page application. * Added 'E', 'V', and 'P' commands to ExternalIVR. * Added 'o' and 'X' options to Chanspy. * Added a new dialplan application, Bridge, which allows you to bridge the calling channel to any other active channel on the system. * Added the ability to specify a music on hold class to play instead of ringing for the SLATrunk application. * The Read application no longer exits the dialplan on error. Instead, it sets READSTATUS to ERROR, which you can catch and handle separately. * Added 'm' option to Directory, which lists out names, 8 at a time, instead of asking for verification of each name, one at a time. * Privacy() no longer uses privacy.conf, as all options are specifyable as direct options to the app. * AMD() has a new "maximum word length" option. "show application AMD" from the CLI for more details * GotoIfTime() now may branch based on a "false" condition, like other Goto-related applications * The ChannelRedirect application no longer exits the dialplan if the given channel does not exist. It will now set the CHANNELREDIRECT_STATUS variable to SUCCESS upon success or NOCHANNEL if the given channel was not found. * The silencethreshold setting that was previously configurable in multiple applications is now settable globally via dsp.conf. Music On Hold Changes --------------------- * A new option, "digit", has been added for music on hold classes in musiconhold.conf. If this is set for a music on hold class, a caller listening to music on hold can press this digit to switch to listening to this music on hold class. * Support for realtime music on hold has been added. * In conjunction with the realtime music on hold, a general section has been added to musiconhold.conf, its sole variable is cachertclasses. If this is set, then music on hold classes found in realtime will be cached in memory. AEL Changes ----------- * AEL upgraded to use the Gosub with Arguments instead of Macro application, to hopefully reduce the problems seen with the artificially low stack ceiling that Macro bumps into. Macros can only call other Macros to a depth of 7. Tests run using gosub, show depths limited only by virtual memory. A small test demonstrated recursive call depths of 100,000 without problems. -- in addition to this, all apps that allowed a macro to be called, as in Dial, queues, etc, are now allowing a gosub call in similar fashion. * AEL now generates LOCAL(argname) declarations when it Set()'s the each arg name to the value of ${ARG1}, ${ARG2), etc. That makes the arguments local in scope. The user can define their own local variables in macros, now, by saying "local myvar=someval;" or using Set() in this fashion: Set(LOCAL(myvar)=someval); ("local" is now an AEL keyword). * utils/conf2ael introduced. Will convert an extensions.conf file into extensions.ael. Very crude and unfinished, but will be improved as time goes by. Should be useful for a first pass at conversion. * aelparse will now read extensions.conf to see if a referenced macro or context is there before issueing a warning. * AEL parser sets a local channel variable ~~EXTEN~~, to preserve the value of ${EXTEN} thru switch statements. * New operator in $[...] expressions: the ~~ operator serves as a concatenation operator. AT THE MOMENT, it is really only necessary and useful in AEL, especially in if() expressions. Operation: ${a} ~~ ${b| with force both a and b to strings, strip any enclosing double-quotes, and evaluate to the value of a concatenated with the value of b. For example if a is set to "xyz" and b has the value "abc", then ${a} ~~ ${b| would evaluate to xyzabc . Call Features (res_features) Changes ------------------------------------ * Added the parkedcalltransfers option to features.conf * Added parkedcallparking option to control one touch parking w/ parking pickup * Added parkedcallhangup option to control disconnect feature w/ parking pickup * Added parkedcallrecording option to control one-touch record w/ parking pickup * Added parkedcallparking, parkedcallhangup, parkedcallrecording, and parkedcalltransfers option support for multiple parking lots. * Added BRIDGE_FEATURES variable to set available features for a channel * The built-in method for doing attended transfers has been updated to include some new options that allow you to have the transferee sent back to the person that did the transfer if the transfer is not successful. See the options "atxferdropcall", "atxferloopdelay", and "atxfercallbackretries" in features.conf.sample. * Added support for configuring named groups of custom call features in features.conf. This means that features can be written a single time, and then mapped into groups of features for different key mappings or easier access control. * Updated the ParkedCall application to allow you to not specify a parking extension. If you don't specify a parking space to pick up, it will grab the first one available. * Added cli command 'features reload' to reload call features from features.conf * Moved into core asterisk binary. * Changed the default setting for featuredigittimeout to 2000 ms from 500 ms. * Added the ability for custom parking lots to be configured with their own parking extension with the parkext option. Language Support Changes ------------------------ * Brazilian Portuguese (pt-BR) in VM, and say.c was added * Added support for the Hungarian language for saying numbers, dates, and times. AGI Changes ----------- * Added SPEECH commands for speech recognition. A complete listing can be found using agi show. * If app_stack is loaded, GOSUB is a native AGI command that may be used to invoke subroutines in the dialplan. Note that calling EXEC with Gosub does not behave as expected; the native command needs to be used, instead. * Added the ability to perform SRV lookups on fast AGI calls. To use this feature, simply use hagi: instead of agi: as the protocol portion of the URI parameter to the AGI function call in your dial plan. Also note that specifying a port number in the AGI URI will disable SRV lookups, even if you use the hagi: protocol. * No longer support MSG_OOB flag on HANGUP. Logger changes -------------- * Added rotatestrategy option to logger.conf, along with two new options: "timestamp" which will use the time to name the logger files instead of sequence number; and "rotate", which rotates the names of the log files, similar to the way syslog rotates files. * Added exec_after_rotate option to logger.conf, which allows a system command to be run after rotation. This is primarily useful with rotatestrategy=rotate, to allow a limit on the number of log files kept and to ensure that the oldest log file gets deleted. * Added realtime support for the queue log Call Detail Records ------------------- * The cdr_manager module has a [mappings] feature, like cdr_custom, to add fields to the manager event from the CDR variables. * Added cdr_adaptive_odbc, a new module that adapts to the structure of your backend database CDR table. Specifically, additional, non-standard columns are supported, merely by setting the corresponding CDR variable in your dialplan. In addition, you may alias any column to another name (for example, if you want the 'src' CDR variable to be column 'ANI' in the DB, simply "alias src => ANI" in the configuration file). Records may be posted to more than one backend, simply by specifying multiple categories in the configuration file. And finally, you may filter which CDRs get posted to each backend, by specifying a filter (which the record must match) for the particular category. Filters are additive (meaning all rules must match to post that CDR). * The Postgres CDR module now supports some features of the cdr_adaptive_odbc module. Specifically, you may add additional columns into the table and they will be set, if you set the corresponding CDR variable name. Also, if you omit columns in your database table, they will be silently skipped (but a record will still be inserted, based on what columns remain). Note that the other two features from cdr_adaptive_odbc (alias and filter) are not currently supported. * The ResetCDR application now has an 'e' option that re-enables a CDR if it has been disabled using the NoCDR application. Miscellaneous New Modules ------------------------- * Added a new CDR module, cdr_sqlite3_custom. * Added a new realtime configuration module, res_config_sqlite * Added a new codec translation module, codec_resample, which re-samples signed linear audio between 8 kHz and 16 kHz to help support wideband codecs. * Added a new module, res_phoneprov, which allows auto-provisioning of phones based on configuration templates that use Asterisk dialplan function and variable substitution. It should be possible to create phone profiles and templates that work for the majority of phones provisioned over http. It is currently only intended to provision a single user account per phone. An example profile and set of templates for Polycom phones is provided. NOTE: Polycom firmware is not included, but should be placed in AST_DATA_DIR/phoneprov/configs to match up with the included templates. * Added a new module, app_jack, which provides interfaces to JACK, the Jack Audio Connection Kit (http://www.jackaudio.org/). Two interfaces are provided; there is a JACK() application, and a JACK_HOOK() function. Both interfaces create an input and output JACK port. The application makes these ports the endpoint of the call. The audio coming from the channel goes out the output port and whatever comes back in on the input port is what gets sent to the channel. The JACK_HOOK() function turns on a JACK audiohook on the channel. This lets you run the audio coming from a channel through JACK, and whatever comes back in is what gets forwarded on as the channel's audio. This is very useful for building custom vocoders or doing recording or analysis of the channel's audio in another application. * Added a new module, res_config_curl, which permits using a HTTP POST url to retrieve, create, update, and delete realtime information from a remote web server. Note that this module requires func_curl.so to be loaded for backend functionality. * Added a new module, res_config_ldap, which permits the use of an LDAP server for realtime data access. * Added support for writing and running your dialplan in lua using the pbx_lua module. See configs/extensions.lua.sample for examples of how to do this. Miscellaneous ------------- * Ability to use libcap to set high ToS bits when non-root on Linux. If configure is unable to find libcap then you can use --with-cap to specify the path. * Added maxfiles option to options section of asterisk.conf which allows you to specify what Asterisk should set as the maximum number of open files when it loads. * Added the jittertargetextra configuration option. * Added support for setting the CoS for VLAN traffic (802.1p). See the sample configuration files for the IP channel drivers. The new option is "cos". This information is also documented on the Asterisk wiki at https://wiki.asterisk.org/wiki/x/EYBG * When originating a call using AMI or pbx_spool that fails the reason for failure will now be available in the failed extension using the REASON dialplan variable. * Added support for reading the TOUCH_MONITOR_PREFIX channel variable. It allows you to configure a prefix for auto-monitor recordings. * A new extension pattern matching algorithm, based on a trie, is introduced here, that could noticeably speed up mid-sized to large dialplans. It is NOT used by default, as duplicating the behaviour of the old pattern matcher is still under development. A config file option, in extensions.conf, in the [general] section, called "extenpatternmatchingnew", is by default set to false; setting that to true will force the use of the new algorithm. Also, the cli commands "dialplan set extenpatternmatchingnew true/false" can be used to switch the algorithms at run time. * A new option when starting a remote asterisk (rasterisk, asterisk -r) for specifying which socket to use to connect to the running Asterisk daemon (-s) * Performance enhancements to the sched facility, which is used in the channel drivers, etc. Added hashtabs and doubly-linked lists to speed up deletion; start at the beginning or end of list to speed up insertion. * Added Doubly-linked lists after the fashion of linkedlists.h. They are in dlinkedlists.h. Doubly-linked lists feature fast deletion times. Added regression tests to the tests/ dir, also. * Added a refcount trace feature to astobj2 for those trying to balance object creation, deletion; work, play; space and time. See the notes in astobj2.h. Also, see utils/refcounter as well, as a quick way to find unbalanced refcounts in what could be a sea of objects that were balanced. * Added logging to 'make update' command. See update.log * Added strictrtp option to rtp.conf. If enabled this will drop RTP packets that do not come from the remote party. * Added the 'n' option to the SpeechBackground application to tell it to not answer the channel if it has not already been answered. * Added a compiler flag, CHANNEL_TRACE, which permits channel tracing to be turned on, via the CHANNEL(trace) dialplan function. Could be useful for dialplan debugging. * iLBC source code no longer included (see UPGRADE.txt for details) * If compiled with DETECT_DEADLOCKS enabled and if you have glibc, then if deadlock is detected, a backtrace of the stack which led to the lock calls will be output to the CLI. * If compiled with DEBUG_THREADS enabled and if you have glibc, then issuing the "core show locks" CLI command will give lock information output as well as a backtrace of the stack which led to the lock calls. * users.conf now sports an optional alternateexts property, which permits allocation of additional extensions which will reach the specified user. * A new option for the configure script, --enable-internal-poll, has been added for use with systems which may have a buggy implementation of the poll system call. If you notice odd behavior such as the CLI being unresponsive on remote consoles, you may want to try using this option. This option is enabled by default on Darwin systems since it is known that the Darwin poll() implementation has odd issues. Timer Changes -------------------- * In addition to timing from DAHDI, there is a new timing module called res_timing_timerfd. In order to use this, you must be running Linux with a kernel version 2.6.25 or newer as well as glibc 2.8 or newer. The configure script will be able to tell if you have the requirements. From menuselect, select res_timing_timerfd from the Resource Modules menu. asterisk-11.7.0/codecs/0000755000175000007640000000000012254244576014620 5ustar sharkyjerrywebasterisk-11.7.0/codecs/g722/0000755000175000007640000000000012254071136015267 5ustar sharkyjerrywebasterisk-11.7.0/codecs/g722/g722_encode.c0000644000175000007640000002573711203326554017447 0ustar sharkyjerryweb/* * SpanDSP - a series of DSP components for telephony * * g722_encode.c - The ITU G.722 codec, encode part. * * Written by Steve Underwood * * Copyright (C) 2005 Steve Underwood * * All rights reserved. * * Despite my general liking of the GPL, I place my own contributions * to this code in the public domain for the benefit of all mankind - * even the slimy ones who might try to proprietize my work and use it * to my detriment. * * Based on a single channel 64kbps only G.722 codec which is: * ***** Copyright (c) CMU 1993 ***** * Computer Science, Speech Group * Chengxiang Lu and Alex Hauptmann * * $Id: g722_encode.c 194722 2009-05-15 17:59:08Z russell $ */ /*! \file */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #if 0 #include #endif #include "g722.h" #if !defined(FALSE) #define FALSE 0 #endif #if !defined(TRUE) #define TRUE (!FALSE) #endif static __inline__ int16_t saturate(int32_t amp) { int16_t amp16; /* Hopefully this is optimised for the common case - not clipping */ amp16 = (int16_t) amp; if (amp == amp16) return amp16; if (amp > INT16_MAX) return INT16_MAX; return INT16_MIN; } /*- End of function --------------------------------------------------------*/ static void block4(g722_encode_state_t *s, int band, int d) { int wd1; int wd2; int wd3; int i; /* Block 4, RECONS */ s->band[band].d[0] = d; s->band[band].r[0] = saturate(s->band[band].s + d); /* Block 4, PARREC */ s->band[band].p[0] = saturate(s->band[band].sz + d); /* Block 4, UPPOL2 */ for (i = 0; i < 3; i++) s->band[band].sg[i] = s->band[band].p[i] >> 15; wd1 = saturate(s->band[band].a[1] << 2); wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1; if (wd2 > 32767) wd2 = 32767; wd3 = (wd2 >> 7) + ((s->band[band].sg[0] == s->band[band].sg[2]) ? 128 : -128); wd3 += (s->band[band].a[2]*32512) >> 15; if (wd3 > 12288) wd3 = 12288; else if (wd3 < -12288) wd3 = -12288; s->band[band].ap[2] = wd3; /* Block 4, UPPOL1 */ s->band[band].sg[0] = s->band[band].p[0] >> 15; s->band[band].sg[1] = s->band[band].p[1] >> 15; wd1 = (s->band[band].sg[0] == s->band[band].sg[1]) ? 192 : -192; wd2 = (s->band[band].a[1]*32640) >> 15; s->band[band].ap[1] = saturate(wd1 + wd2); wd3 = saturate(15360 - s->band[band].ap[2]); if (s->band[band].ap[1] > wd3) s->band[band].ap[1] = wd3; else if (s->band[band].ap[1] < -wd3) s->band[band].ap[1] = -wd3; /* Block 4, UPZERO */ wd1 = (d == 0) ? 0 : 128; s->band[band].sg[0] = d >> 15; for (i = 1; i < 7; i++) { s->band[band].sg[i] = s->band[band].d[i] >> 15; wd2 = (s->band[band].sg[i] == s->band[band].sg[0]) ? wd1 : -wd1; wd3 = (s->band[band].b[i]*32640) >> 15; s->band[band].bp[i] = saturate(wd2 + wd3); } /* Block 4, DELAYA */ for (i = 6; i > 0; i--) { s->band[band].d[i] = s->band[band].d[i - 1]; s->band[band].b[i] = s->band[band].bp[i]; } for (i = 2; i > 0; i--) { s->band[band].r[i] = s->band[band].r[i - 1]; s->band[band].p[i] = s->band[band].p[i - 1]; s->band[band].a[i] = s->band[band].ap[i]; } /* Block 4, FILTEP */ wd1 = saturate(s->band[band].r[1] + s->band[band].r[1]); wd1 = (s->band[band].a[1]*wd1) >> 15; wd2 = saturate(s->band[band].r[2] + s->band[band].r[2]); wd2 = (s->band[band].a[2]*wd2) >> 15; s->band[band].sp = saturate(wd1 + wd2); /* Block 4, FILTEZ */ s->band[band].sz = 0; for (i = 6; i > 0; i--) { wd1 = saturate(s->band[band].d[i] + s->band[band].d[i]); s->band[band].sz += (s->band[band].b[i]*wd1) >> 15; } s->band[band].sz = saturate(s->band[band].sz); /* Block 4, PREDIC */ s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); } /*- End of function --------------------------------------------------------*/ g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options) { if (s == NULL) { if ((s = (g722_encode_state_t *) malloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); if (rate == 48000) s->bits_per_sample = 6; else if (rate == 56000) s->bits_per_sample = 7; else s->bits_per_sample = 8; if ((options & G722_SAMPLE_RATE_8000)) s->eight_k = TRUE; if ((options & G722_PACKED) && s->bits_per_sample != 8) s->packed = TRUE; else s->packed = FALSE; s->band[0].det = 32; s->band[1].det = 8; return s; } /*- End of function --------------------------------------------------------*/ int g722_encode_release(g722_encode_state_t *s) { free(s); return 0; } /*- End of function --------------------------------------------------------*/ int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len) { static const int q6[32] = { 0, 35, 72, 110, 150, 190, 233, 276, 323, 370, 422, 473, 530, 587, 650, 714, 786, 858, 940, 1023, 1121, 1219, 1339, 1458, 1612, 1765, 1980, 2195, 2557, 2919, 0, 0 }; static const int iln[32] = { 0, 63, 62, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 0 }; static const int ilp[32] = { 0, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 0 }; static const int wl[8] = { -60, -30, 58, 172, 334, 538, 1198, 3042 }; static const int rl42[16] = { 0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0 }; static const int ilb[32] = { 2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383, 2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834, 2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371, 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008 }; static const int qm4[16] = { 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200, 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0 }; static const int qm2[4] = { -7408, -1616, 7408, 1616 }; static const int qmf_coeffs[12] = { 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, }; static const int ihn[3] = {0, 1, 0}; static const int ihp[3] = {0, 3, 2}; static const int wh[3] = {0, -214, 798}; static const int rh2[4] = {2, 1, 2, 1}; int dlow; int dhigh; int el; int wd; int wd1; int ril; int wd2; int il4; int ih2; int wd3; int eh; int mih; int i; int j; /* Low and high band PCM from the QMF */ int xlow; int xhigh; int g722_bytes; /* Even and odd tap accumulators */ int sumeven; int sumodd; int ihigh; int ilow; int code; g722_bytes = 0; xhigh = 0; for (j = 0; j < len; ) { if (s->itu_test_mode) { xlow = xhigh = amp[j++] >> 1; } else { if (s->eight_k) { xlow = amp[j++] >> 1; } else { /* Apply the transmit QMF */ /* Shuffle the buffer down */ for (i = 0; i < 22; i++) s->x[i] = s->x[i + 2]; s->x[22] = amp[j++]; s->x[23] = amp[j++]; /* Discard every other QMF output */ sumeven = 0; sumodd = 0; for (i = 0; i < 12; i++) { sumodd += s->x[2*i]*qmf_coeffs[i]; sumeven += s->x[2*i + 1]*qmf_coeffs[11 - i]; } xlow = (sumeven + sumodd) >> 14; xhigh = (sumeven - sumodd) >> 14; } } /* Block 1L, SUBTRA */ el = saturate(xlow - s->band[0].s); /* Block 1L, QUANTL */ wd = (el >= 0) ? el : -(el + 1); for (i = 1; i < 30; i++) { wd1 = (q6[i]*s->band[0].det) >> 12; if (wd < wd1) break; } ilow = (el < 0) ? iln[i] : ilp[i]; /* Block 2L, INVQAL */ ril = ilow >> 2; wd2 = qm4[ril]; dlow = (s->band[0].det*wd2) >> 15; /* Block 3L, LOGSCL */ il4 = rl42[ril]; wd = (s->band[0].nb*127) >> 7; s->band[0].nb = wd + wl[il4]; if (s->band[0].nb < 0) s->band[0].nb = 0; else if (s->band[0].nb > 18432) s->band[0].nb = 18432; /* Block 3L, SCALEL */ wd1 = (s->band[0].nb >> 6) & 31; wd2 = 8 - (s->band[0].nb >> 11); wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); s->band[0].det = wd3 << 2; block4(s, 0, dlow); if (s->eight_k) { /* Just leave the high bits as zero */ code = (0xC0 | ilow) >> (8 - s->bits_per_sample); } else { /* Block 1H, SUBTRA */ eh = saturate(xhigh - s->band[1].s); /* Block 1H, QUANTH */ wd = (eh >= 0) ? eh : -(eh + 1); wd1 = (564*s->band[1].det) >> 12; mih = (wd >= wd1) ? 2 : 1; ihigh = (eh < 0) ? ihn[mih] : ihp[mih]; /* Block 2H, INVQAH */ wd2 = qm2[ihigh]; dhigh = (s->band[1].det*wd2) >> 15; /* Block 3H, LOGSCH */ ih2 = rh2[ihigh]; wd = (s->band[1].nb*127) >> 7; s->band[1].nb = wd + wh[ih2]; if (s->band[1].nb < 0) s->band[1].nb = 0; else if (s->band[1].nb > 22528) s->band[1].nb = 22528; /* Block 3H, SCALEH */ wd1 = (s->band[1].nb >> 6) & 31; wd2 = 10 - (s->band[1].nb >> 11); wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); s->band[1].det = wd3 << 2; block4(s, 1, dhigh); code = ((ihigh << 6) | ilow) >> (8 - s->bits_per_sample); } if (s->packed) { /* Pack the code bits */ s->out_buffer |= (code << s->out_bits); s->out_bits += s->bits_per_sample; if (s->out_bits >= 8) { g722_data[g722_bytes++] = (uint8_t) (s->out_buffer & 0xFF); s->out_bits -= 8; s->out_buffer >>= 8; } } else { g722_data[g722_bytes++] = (uint8_t) code; } } return g722_bytes; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ asterisk-11.7.0/codecs/g722/g722.h0000644000175000007640000000705610543671307016136 0ustar sharkyjerryweb/* * SpanDSP - a series of DSP components for telephony * * g722.h - The ITU G.722 codec. * * Written by Steve Underwood * * Copyright (C) 2005 Steve Underwood * * Despite my general liking of the GPL, I place my own contributions * to this code in the public domain for the benefit of all mankind - * even the slimy ones who might try to proprietize my work and use it * to my detriment. * * Based on a single channel G.722 codec which is: * ***** Copyright (c) CMU 1993 ***** * Computer Science, Speech Group * Chengxiang Lu and Alex Hauptmann * * $Id: g722.h 48959 2006-12-25 06:42:15Z rizzo $ */ /*! \file */ #if !defined(_G722_H_) #define _G722_H_ /*! \page g722_page G.722 encoding and decoding \section g722_page_sec_1 What does it do? The G.722 module is a bit exact implementation of the ITU G.722 specification for all three specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests. To allow fast and flexible interworking with narrow band telephony, the encoder and decoder support an option for the linear audio to be an 8k samples/second stream. In this mode the codec is considerably faster, and still fully compatible with wideband terminals using G.722. \section g722_page_sec_2 How does it work? ???. */ enum { G722_SAMPLE_RATE_8000 = 0x0001, G722_PACKED = 0x0002 }; #ifndef INT16_MAX #define INT16_MAX 32767 #endif #ifndef INT16_MIN #define INT16_MIN (-32768) #endif typedef struct { /*! TRUE if the operating in the special ITU test mode, with the band split filters disabled. */ int itu_test_mode; /*! TRUE if the G.722 data is packed */ int packed; /*! TRUE if encode from 8k samples/second */ int eight_k; /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ int bits_per_sample; /*! Signal history for the QMF */ int x[24]; struct { int s; int sp; int sz; int r[3]; int a[3]; int ap[3]; int p[3]; int d[7]; int b[7]; int bp[7]; int sg[7]; int nb; int det; } band[2]; unsigned int in_buffer; int in_bits; unsigned int out_buffer; int out_bits; } g722_encode_state_t; typedef struct { /*! TRUE if the operating in the special ITU test mode, with the band split filters disabled. */ int itu_test_mode; /*! TRUE if the G.722 data is packed */ int packed; /*! TRUE if decode to 8k samples/second */ int eight_k; /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ int bits_per_sample; /*! Signal history for the QMF */ int x[24]; struct { int s; int sp; int sz; int r[3]; int a[3]; int ap[3]; int p[3]; int d[7]; int b[7]; int bp[7]; int sg[7]; int nb; int det; } band[2]; unsigned int in_buffer; int in_bits; unsigned int out_buffer; int out_bits; } g722_decode_state_t; #ifdef __cplusplus extern "C" { #endif g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options); int g722_encode_release(g722_encode_state_t *s); int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len); g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options); int g722_decode_release(g722_decode_state_t *s); int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/codecs/g722/g722_decode.c0000644000175000007640000002625711203326554017433 0ustar sharkyjerryweb/* * SpanDSP - a series of DSP components for telephony * * g722_decode.c - The ITU G.722 codec, decode part. * * Written by Steve Underwood * * Copyright (C) 2005 Steve Underwood * * Despite my general liking of the GPL, I place my own contributions * to this code in the public domain for the benefit of all mankind - * even the slimy ones who might try to proprietize my work and use it * to my detriment. * * Based in part on a single channel G.722 codec which is: * * Copyright (c) CMU 1993 * Computer Science, Speech Group * Chengxiang Lu and Alex Hauptmann * * $Id: g722_decode.c 194722 2009-05-15 17:59:08Z russell $ */ /*! \file */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #if 0 #include #endif #include "g722.h" #if !defined(FALSE) #define FALSE 0 #endif #if !defined(TRUE) #define TRUE (!FALSE) #endif static __inline__ int16_t saturate(int32_t amp) { int16_t amp16; /* Hopefully this is optimised for the common case - not clipping */ amp16 = (int16_t) amp; if (amp == amp16) return amp16; if (amp > INT16_MAX) return INT16_MAX; return INT16_MIN; } /*- End of function --------------------------------------------------------*/ static void block4(g722_decode_state_t *s, int band, int d); static void block4(g722_decode_state_t *s, int band, int d) { int wd1; int wd2; int wd3; int i; /* Block 4, RECONS */ s->band[band].d[0] = d; s->band[band].r[0] = saturate(s->band[band].s + d); /* Block 4, PARREC */ s->band[band].p[0] = saturate(s->band[band].sz + d); /* Block 4, UPPOL2 */ for (i = 0; i < 3; i++) s->band[band].sg[i] = s->band[band].p[i] >> 15; wd1 = saturate(s->band[band].a[1] << 2); wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1; if (wd2 > 32767) wd2 = 32767; wd3 = (s->band[band].sg[0] == s->band[band].sg[2]) ? 128 : -128; wd3 += (wd2 >> 7); wd3 += (s->band[band].a[2]*32512) >> 15; if (wd3 > 12288) wd3 = 12288; else if (wd3 < -12288) wd3 = -12288; s->band[band].ap[2] = wd3; /* Block 4, UPPOL1 */ s->band[band].sg[0] = s->band[band].p[0] >> 15; s->band[band].sg[1] = s->band[band].p[1] >> 15; wd1 = (s->band[band].sg[0] == s->band[band].sg[1]) ? 192 : -192; wd2 = (s->band[band].a[1]*32640) >> 15; s->band[band].ap[1] = saturate(wd1 + wd2); wd3 = saturate(15360 - s->band[band].ap[2]); if (s->band[band].ap[1] > wd3) s->band[band].ap[1] = wd3; else if (s->band[band].ap[1] < -wd3) s->band[band].ap[1] = -wd3; /* Block 4, UPZERO */ wd1 = (d == 0) ? 0 : 128; s->band[band].sg[0] = d >> 15; for (i = 1; i < 7; i++) { s->band[band].sg[i] = s->band[band].d[i] >> 15; wd2 = (s->band[band].sg[i] == s->band[band].sg[0]) ? wd1 : -wd1; wd3 = (s->band[band].b[i]*32640) >> 15; s->band[band].bp[i] = saturate(wd2 + wd3); } /* Block 4, DELAYA */ for (i = 6; i > 0; i--) { s->band[band].d[i] = s->band[band].d[i - 1]; s->band[band].b[i] = s->band[band].bp[i]; } for (i = 2; i > 0; i--) { s->band[band].r[i] = s->band[band].r[i - 1]; s->band[band].p[i] = s->band[band].p[i - 1]; s->band[band].a[i] = s->band[band].ap[i]; } /* Block 4, FILTEP */ wd1 = saturate(s->band[band].r[1] + s->band[band].r[1]); wd1 = (s->band[band].a[1]*wd1) >> 15; wd2 = saturate(s->band[band].r[2] + s->band[band].r[2]); wd2 = (s->band[band].a[2]*wd2) >> 15; s->band[band].sp = saturate(wd1 + wd2); /* Block 4, FILTEZ */ s->band[band].sz = 0; for (i = 6; i > 0; i--) { wd1 = saturate(s->band[band].d[i] + s->band[band].d[i]); s->band[band].sz += (s->band[band].b[i]*wd1) >> 15; } s->band[band].sz = saturate(s->band[band].sz); /* Block 4, PREDIC */ s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); } /*- End of function --------------------------------------------------------*/ g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options) { if (s == NULL) { if ((s = (g722_decode_state_t *) malloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); if (rate == 48000) s->bits_per_sample = 6; else if (rate == 56000) s->bits_per_sample = 7; else s->bits_per_sample = 8; if ((options & G722_SAMPLE_RATE_8000)) s->eight_k = TRUE; if ((options & G722_PACKED) && s->bits_per_sample != 8) s->packed = TRUE; else s->packed = FALSE; s->band[0].det = 32; s->band[1].det = 8; return s; } /*- End of function --------------------------------------------------------*/ int g722_decode_release(g722_decode_state_t *s) { free(s); return 0; } /*- End of function --------------------------------------------------------*/ int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len) { static const int wl[8] = {-60, -30, 58, 172, 334, 538, 1198, 3042 }; static const int rl42[16] = {0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0 }; static const int ilb[32] = { 2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383, 2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834, 2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371, 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008 }; static const int wh[3] = {0, -214, 798}; static const int rh2[4] = {2, 1, 2, 1}; static const int qm2[4] = {-7408, -1616, 7408, 1616}; static const int qm4[16] = { 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200, 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0 }; static const int qm5[32] = { -280, -280, -23352, -17560, -14120, -11664, -9752, -8184, -6864, -5712, -4696, -3784, -2960, -2208, -1520, -880, 23352, 17560, 14120, 11664, 9752, 8184, 6864, 5712, 4696, 3784, 2960, 2208, 1520, 880, 280, -280 }; static const int qm6[64] = { -136, -136, -136, -136, -24808, -21904, -19008, -16704, -14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856, -7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576, -3168, -2776, -2400, -2032, -1688, -1360, -1040, -728, 24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192, 10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456, 4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032, 1688, 1360, 1040, 728, 432, 136, -432, -136 }; static const int qmf_coeffs[12] = { 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, }; int dlowt; int rlow; int ihigh; int dhigh; int rhigh; int xout1; int xout2; int wd1; int wd2; int wd3; int code; int outlen; int i; int j; outlen = 0; rhigh = 0; for (j = 0; j < len; ) { if (s->packed) { /* Unpack the code bits */ if (s->in_bits < s->bits_per_sample) { s->in_buffer |= (g722_data[j++] << s->in_bits); s->in_bits += 8; } code = s->in_buffer & ((1 << s->bits_per_sample) - 1); s->in_buffer >>= s->bits_per_sample; s->in_bits -= s->bits_per_sample; } else { code = g722_data[j++]; } switch (s->bits_per_sample) { default: case 8: wd1 = code & 0x3F; ihigh = (code >> 6) & 0x03; wd2 = qm6[wd1]; wd1 >>= 2; break; case 7: wd1 = code & 0x1F; ihigh = (code >> 5) & 0x03; wd2 = qm5[wd1]; wd1 >>= 1; break; case 6: wd1 = code & 0x0F; ihigh = (code >> 4) & 0x03; wd2 = qm4[wd1]; break; } /* Block 5L, LOW BAND INVQBL */ wd2 = (s->band[0].det*wd2) >> 15; /* Block 5L, RECONS */ rlow = s->band[0].s + wd2; /* Block 6L, LIMIT */ if (rlow > 16383) rlow = 16383; else if (rlow < -16384) rlow = -16384; /* Block 2L, INVQAL */ wd2 = qm4[wd1]; dlowt = (s->band[0].det*wd2) >> 15; /* Block 3L, LOGSCL */ wd2 = rl42[wd1]; wd1 = (s->band[0].nb*127) >> 7; wd1 += wl[wd2]; if (wd1 < 0) wd1 = 0; else if (wd1 > 18432) wd1 = 18432; s->band[0].nb = wd1; /* Block 3L, SCALEL */ wd1 = (s->band[0].nb >> 6) & 31; wd2 = 8 - (s->band[0].nb >> 11); wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); s->band[0].det = wd3 << 2; block4(s, 0, dlowt); if (!s->eight_k) { /* Block 2H, INVQAH */ wd2 = qm2[ihigh]; dhigh = (s->band[1].det*wd2) >> 15; /* Block 5H, RECONS */ rhigh = dhigh + s->band[1].s; /* Block 6H, LIMIT */ if (rhigh > 16383) rhigh = 16383; else if (rhigh < -16384) rhigh = -16384; /* Block 2H, INVQAH */ wd2 = rh2[ihigh]; wd1 = (s->band[1].nb*127) >> 7; wd1 += wh[wd2]; if (wd1 < 0) wd1 = 0; else if (wd1 > 22528) wd1 = 22528; s->band[1].nb = wd1; /* Block 3H, SCALEH */ wd1 = (s->band[1].nb >> 6) & 31; wd2 = 10 - (s->band[1].nb >> 11); wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); s->band[1].det = wd3 << 2; block4(s, 1, dhigh); } if (s->itu_test_mode) { amp[outlen++] = (int16_t) (rlow << 1); amp[outlen++] = (int16_t) (rhigh << 1); } else { if (s->eight_k) { amp[outlen++] = (int16_t) (rlow << 1); } else { /* Apply the receive QMF */ for (i = 0; i < 22; i++) s->x[i] = s->x[i + 2]; s->x[22] = rlow + rhigh; s->x[23] = rlow - rhigh; xout1 = 0; xout2 = 0; for (i = 0; i < 12; i++) { xout2 += s->x[2*i]*qmf_coeffs[i]; xout1 += s->x[2*i + 1]*qmf_coeffs[11 - i]; } amp[outlen++] = (int16_t) (xout1 >> 11); amp[outlen++] = (int16_t) (xout2 >> 11); } } } return outlen; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ asterisk-11.7.0/codecs/ex_ulaw.h0000644000175000007640000000175011522553062016426 0ustar sharkyjerryweb/*! \file * \brief 8-bit data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_ulaw[] = { 0x00, 0x03, 0x06, 0x09, 0x0c, 0x0f, 0x12, 0x15, 0x10, 0x18, 0x1b, 0x1e, 0x21, 0x24, 0x27, 0x2a, 0x20, 0x2d, 0x30, 0x33, 0x36, 0x39, 0x3c, 0x3f, 0x30, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x51, 0x54, 0x40, 0x57, 0x5a, 0x5d, 0x60, 0x63, 0x66, 0x69, 0x50, 0x6c, 0x6f, 0x72, 0x75, 0x78, 0x7b, 0x7e, 0x60, 0x81, 0x84, 0x87, 0x8a, 0x8d, 0x90, 0x93, 0x70, 0x96, 0x99, 0x9c, 0x9f, 0xa2, 0xa5, 0xa8, 0x80, 0xab, 0xae, 0xb1, 0xb4, 0xb7, 0xba, 0xbd, 0x90, 0xc0, 0xc3, 0xc6, 0xc9, 0xcc, 0xcf, 0xd2, }; static struct ast_frame *ulaw_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_ulaw), .samples = ARRAY_LEN(ex_ulaw), .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_ulaw, }; ast_format_set(&f.subclass.format, AST_FORMAT_ULAW, 0); return &f; } asterisk-11.7.0/codecs/codec_lpc10.c0000644000175000007640000001556311607650606017046 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * The lpc10 code is from a library used by nautilus, modified to be a bit * nicer to the compiler. * See http://www.arl.wustl.edu/~jaf/ * * 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 Translate between signed linear and LPC10 (Linear Predictor Code) * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/translate.h" #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/utils.h" #include "lpc10/lpc10.h" /* Sample frame data */ #include "asterisk/slin.h" #include "ex_lpc10.h" /* We use a very strange format here... I have no idea why... The frames are 180 samples long, which isn't even an even number of milliseconds... Not only that but we hvae to waste two bits of each frame to keep them ending on a byte boundary because the frames are 54 bits long */ #define LPC10_BYTES_IN_COMPRESSED_FRAME (LPC10_BITS_IN_COMPRESSED_FRAME + 7)/8 #define BUFFER_SAMPLES 8000 struct lpc10_coder_pvt { union { struct lpc10_encoder_state *enc; struct lpc10_decoder_state *dec; } lpc10; /* Enough to store a full second */ short buf[BUFFER_SAMPLES]; int longer; }; static int lpc10_enc_new(struct ast_trans_pvt *pvt) { struct lpc10_coder_pvt *tmp = pvt->pvt; return (tmp->lpc10.enc = create_lpc10_encoder_state()) ? 0 : -1; } static int lpc10_dec_new(struct ast_trans_pvt *pvt) { struct lpc10_coder_pvt *tmp = pvt->pvt; return (tmp->lpc10.dec = create_lpc10_decoder_state()) ? 0 : -1; } static void extract_bits(INT32 *bits, unsigned char *c) { int x; for (x=0;x> (x & 7))) bits[x] = 1; else bits[x] = 0; if ((x & 7) == 7) c++; } } /* XXX note lpc10_encode() produces one bit per word in bits[] */ static void build_bits(unsigned char *c, INT32 *bits) { unsigned char mask=0x80; int x; *c = 0; for (x=0;x> 1; if ((x % 8)==7) { c++; *c = 0; mask = 0x80; } } } static int lpc10tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct lpc10_coder_pvt *tmp = pvt->pvt; int16_t *dst = pvt->outbuf.i16; int len = 0; while (len + LPC10_BYTES_IN_COMPRESSED_FRAME <= f->datalen) { int x; float tmpbuf[LPC10_SAMPLES_PER_FRAME]; INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME]; /* XXX see note */ if (pvt->samples + LPC10_SAMPLES_PER_FRAME > BUFFER_SAMPLES) { ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } extract_bits(bits, f->data.ptr + len); if (lpc10_decode(bits, tmpbuf, tmp->lpc10.dec)) { ast_log(LOG_WARNING, "Invalid lpc10 data\n"); return -1; } for (x=0;xsamples + x] = (int16_t)(32768.0 * tmpbuf[x]); } pvt->samples += LPC10_SAMPLES_PER_FRAME; pvt->datalen += 2*LPC10_SAMPLES_PER_FRAME; len += LPC10_BYTES_IN_COMPRESSED_FRAME; } if (len != f->datalen) printf("Decoded %d, expected %d\n", len, f->datalen); return 0; } static int lintolpc10_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct lpc10_coder_pvt *tmp = pvt->pvt; /* Just add the frames to our stream */ if (pvt->samples + f->samples > BUFFER_SAMPLES) { ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } static struct ast_frame *lintolpc10_frameout(struct ast_trans_pvt *pvt) { struct lpc10_coder_pvt *tmp = pvt->pvt; int x; int datalen = 0; /* output frame */ int samples = 0; /* output samples */ float tmpbuf[LPC10_SAMPLES_PER_FRAME]; INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME]; /* XXX what ??? */ /* We can't work on anything less than a frame in size */ if (pvt->samples < LPC10_SAMPLES_PER_FRAME) return NULL; while (pvt->samples >= LPC10_SAMPLES_PER_FRAME) { /* Encode a frame of data */ for (x=0;xbuf[x + samples] / 32768.0; lpc10_encode(tmpbuf, bits, tmp->lpc10.enc); build_bits(pvt->outbuf.uc + datalen, bits); datalen += LPC10_BYTES_IN_COMPRESSED_FRAME; samples += LPC10_SAMPLES_PER_FRAME; pvt->samples -= LPC10_SAMPLES_PER_FRAME; /* Use one of the two left over bits to record if this is a 22 or 23 ms frame... important for IAX use */ tmp->longer = 1 - tmp->longer; } /* Move the data at the end of the buffer to the front */ if (pvt->samples) memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); return ast_trans_frameout(pvt, datalen, samples); } static void lpc10_destroy(struct ast_trans_pvt *arg) { struct lpc10_coder_pvt *pvt = arg->pvt; /* Enc and DEC are both just allocated, so they can be freed */ ast_free(pvt->lpc10.enc); } static struct ast_translator lpc10tolin = { .name = "lpc10tolin", .newpvt = lpc10_dec_new, .framein = lpc10tolin_framein, .destroy = lpc10_destroy, .sample = lpc10_sample, .desc_size = sizeof(struct lpc10_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, }; static struct ast_translator lintolpc10 = { .name = "lintolpc10", .newpvt = lpc10_enc_new, .framein = lintolpc10_framein, .frameout = lintolpc10_frameout, .destroy = lpc10_destroy, .sample = slin8_sample, .desc_size = sizeof(struct lpc10_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = LPC10_BYTES_IN_COMPRESSED_FRAME * (1 + BUFFER_SAMPLES / LPC10_SAMPLES_PER_FRAME), }; static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res; res = ast_unregister_translator(&lintolpc10); res |= ast_unregister_translator(&lpc10tolin); return res; } static int load_module(void) { int res; ast_format_set(&lpc10tolin.src_format, AST_FORMAT_LPC10, 0); ast_format_set(&lpc10tolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintolpc10.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintolpc10.dst_format, AST_FORMAT_LPC10, 0); res = ast_register_translator(&lpc10tolin); if (!res) res = ast_register_translator(&lintolpc10); else ast_unregister_translator(&lpc10tolin); if (res) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "LPC10 2.4kbps Coder/Decoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/ex_lpc10.h0000644000175000007640000000125111522553062016371 0ustar sharkyjerryweb/*! \file * \brief * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_lpc10[] = { 0x01, 0x08, 0x31, 0x08, 0x31, 0x80, 0x30, }; static struct ast_frame *lpc10_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_lpc10), /* All frames are 22 ms long (maybe a little more -- why did he choose LPC10_SAMPLES_PER_FRAME sample frames anyway?? */ .samples = LPC10_SAMPLES_PER_FRAME, .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_lpc10, }; ast_format_set(&f.subclass.format, AST_FORMAT_LPC10, 0); return &f; } asterisk-11.7.0/codecs/codec_g722.c0000644000175000007640000001331011607650606016574 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2008, Digium, Inc. * * Matthew Fredrickson * Russell Bryant * * Special thanks to Steve Underwood for the implementation * and for doing the 8khz<->g.722 direct translation code. * * 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 codec_g722.c - translate between signed linear and ITU G.722-64kbps * * \author Matthew Fredrickson * \author Russell Bryant * * \arg http://soft-switch.org/downloads/non-gpl-bits.tgz * \arg http://lists.digium.com/pipermail/asterisk-dev/2006-September/022866.html * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/linkedlists.h" #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/translate.h" #include "asterisk/utils.h" #define BUFFER_SAMPLES 8096 /* size for the translation buffers */ #define BUF_SHIFT 5 #include "g722/g722.h" /* Sample frame data */ #include "asterisk/slin.h" #include "ex_g722.h" struct g722_encoder_pvt { g722_encode_state_t g722; }; struct g722_decoder_pvt { g722_decode_state_t g722; }; /*! \brief init a new instance of g722_encoder_pvt. */ static int lintog722_new(struct ast_trans_pvt *pvt) { struct g722_encoder_pvt *tmp = pvt->pvt; g722_encode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); return 0; } static int lin16tog722_new(struct ast_trans_pvt *pvt) { struct g722_encoder_pvt *tmp = pvt->pvt; g722_encode_init(&tmp->g722, 64000, 0); return 0; } /*! \brief init a new instance of g722_encoder_pvt. */ static int g722tolin_new(struct ast_trans_pvt *pvt) { struct g722_decoder_pvt *tmp = pvt->pvt; g722_decode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); return 0; } static int g722tolin16_new(struct ast_trans_pvt *pvt) { struct g722_decoder_pvt *tmp = pvt->pvt; g722_decode_init(&tmp->g722, 64000, 0); return 0; } static int g722tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g722_decoder_pvt *tmp = pvt->pvt; int out_samples; int in_samples; /* g722_decode expects the samples to be in the invalid samples / 2 format */ in_samples = f->samples / 2; out_samples = g722_decode(&tmp->g722, &pvt->outbuf.i16[pvt->samples * sizeof(int16_t)], (uint8_t *) f->data.ptr, in_samples); pvt->samples += out_samples; pvt->datalen += (out_samples * sizeof(int16_t)); return 0; } static int lintog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g722_encoder_pvt *tmp = pvt->pvt; int outlen; outlen = g722_encode(&tmp->g722, (&pvt->outbuf.ui8[pvt->datalen]), (int16_t *) f->data.ptr, f->samples); pvt->samples += outlen * 2; pvt->datalen += outlen; return 0; } static struct ast_translator g722tolin = { .name = "g722tolin", .newpvt = g722tolin_new, /* same for both directions */ .framein = g722tolin_framein, .sample = g722_sample, .desc_size = sizeof(struct g722_decoder_pvt), .buffer_samples = BUFFER_SAMPLES / sizeof(int16_t), .buf_size = BUFFER_SAMPLES, }; static struct ast_translator lintog722 = { .name = "lintog722", .newpvt = lintog722_new, /* same for both directions */ .framein = lintog722_framein, .sample = slin8_sample, .desc_size = sizeof(struct g722_encoder_pvt), .buffer_samples = BUFFER_SAMPLES * 2, .buf_size = BUFFER_SAMPLES, }; static struct ast_translator g722tolin16 = { .name = "g722tolin16", .newpvt = g722tolin16_new, /* same for both directions */ .framein = g722tolin_framein, .sample = g722_sample, .desc_size = sizeof(struct g722_decoder_pvt), .buffer_samples = BUFFER_SAMPLES / sizeof(int16_t), .buf_size = BUFFER_SAMPLES, }; static struct ast_translator lin16tog722 = { .name = "lin16tog722", .newpvt = lin16tog722_new, /* same for both directions */ .framein = lintog722_framein, .sample = slin16_sample, .desc_size = sizeof(struct g722_encoder_pvt), .buffer_samples = BUFFER_SAMPLES * 2, .buf_size = BUFFER_SAMPLES, }; static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res = 0; res |= ast_unregister_translator(&g722tolin); res |= ast_unregister_translator(&lintog722); res |= ast_unregister_translator(&g722tolin16); res |= ast_unregister_translator(&lin16tog722); return res; } static int load_module(void) { int res = 0; ast_format_set(&g722tolin.src_format, AST_FORMAT_G722, 0); ast_format_set(&g722tolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintog722.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintog722.dst_format, AST_FORMAT_G722, 0); ast_format_set(&g722tolin16.src_format, AST_FORMAT_G722, 0); ast_format_set(&g722tolin16.dst_format, AST_FORMAT_SLINEAR16, 0); ast_format_set(&lin16tog722.src_format, AST_FORMAT_SLINEAR16, 0); ast_format_set(&lin16tog722.dst_format, AST_FORMAT_G722, 0); res |= ast_register_translator(&g722tolin); res |= ast_register_translator(&lintog722); res |= ast_register_translator(&g722tolin16); res |= ast_register_translator(&lin16tog722); if (res) { unload_module(); return AST_MODULE_LOAD_FAILURE; } return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ITU G.722-64kbps G722 Transcoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/ex_gsm.h0000644000175000007640000000134211522553062016241 0ustar sharkyjerryweb/*! \file * \brief 8-bit raw data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_gsm[] = { 0xda, 0xa6, 0xac, 0x2d, 0xa3, 0x50, 0x00, 0x49, 0x24, 0x92, 0x49, 0x24, 0x50, 0x40, 0x49, 0x24, 0x92, 0x37, 0x24, 0x52, 0x00, 0x49, 0x24, 0x92, 0x47, 0x24, 0x50, 0x80, 0x46, 0xe3, 0x6d, 0xb8, 0xdc, }; static struct ast_frame *gsm_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_gsm), /* All frames are 20 ms long */ .samples = GSM_SAMPLES, .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_gsm, }; ast_format_set(&f.subclass.format, AST_FORMAT_GSM, 0); return &f; } asterisk-11.7.0/codecs/ex_speex.h0000644000175000007640000000345711522553062016610 0ustar sharkyjerryweb/*! \file * \brief Random Data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_speex[] = { 0x2e, 0x8e, 0x0f, 0x9a, 0x20, 0000, 0x01, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x91, 0000, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdc, 0x80, 0x5f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x98, 0x7f, 0xff, 0xff, 0xff, 0xe8, 0xff, 0xf7, 0x80, }; static struct ast_frame *speex_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_speex), /* All frames are 20 ms long */ .samples = SPEEX_SAMPLES, .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_speex, }; ast_format_set(&f.subclass.format, AST_FORMAT_SPEEX, 0); return &f; } static uint8_t ex_speex16[] = { 0x3f, 0x78, 0x89, 0x14, 0x4a, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0x06, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x30, 0x5f, 0xff, 0xfd, 0xbb, 0xee, 0x30, 0x56, 0xff, 0xf8, 0x74, 0x54, 0x31, 0xe6, 0xfe, 0x71, 0xdc, 0xca, 0x44, 0x6a, 0x43, 0x75, 0xae, 0x31, 0x7a, 0x50, 0xd9, 0xfc, 0x93, 0x13, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0x3a, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xba, 0xb0, 0xab, 0xab, 0xab, 0xd9, 0x37, 0xab, 0xab, 0xb4, 0x34, 0xe9, 0x0b, 0xd4, 0x2f, 0x13, 0x4c, 0xf0, 0xef, 0x8d, 0xdd, 0x99, 0xc7 }; static struct ast_frame *speex16_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_speex16), /* All frames are 20 ms long */ .samples = SPEEX_SAMPLES, .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_speex16, }; ast_format_set(&f.subclass.format, AST_FORMAT_SPEEX16, 0); return &f; } asterisk-11.7.0/codecs/ex_adpcm.h0000644000175000007640000000140311522553062016535 0ustar sharkyjerryweb/*! \file * \brief 4-bit ADPCM data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_adpcm[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static struct ast_frame *adpcm_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_adpcm), .samples = ARRAY_LEN(ex_adpcm) * 2, .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_adpcm, }; ast_format_set(&f.subclass.format, AST_FORMAT_ADPCM, 0); return &f; } asterisk-11.7.0/codecs/codec_g726.c0000644000175000007640000005503211743336444016611 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * Kevin P. Fleming * * Based on frompcm.c and topcm.c from the Emiliano MIPL browser/ * interpreter. See http://www.bsdtelephony.com.mx * * 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 codec_g726.c - translate between signed linear and ITU G.726-32kbps (both RFC3551 and AAL2 codeword packing) * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 362307 $") #include "asterisk/lock.h" #include "asterisk/linkedlists.h" #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/translate.h" #include "asterisk/utils.h" #define WANT_ASM #include "log2comp.h" /* define NOT_BLI to use a faster but not bit-level identical version */ /* #define NOT_BLI */ #if defined(NOT_BLI) # if defined(_MSC_VER) typedef __int64 sint64; # elif defined(__GNUC__) typedef long long sint64; # else # error 64-bit integer type is not defined for your compiler/platform # endif #endif #define BUFFER_SAMPLES 8096 /* size for the translation buffers */ #define BUF_SHIFT 5 /* Sample frame data */ #include "asterisk/slin.h" #include "ex_g726.h" /* * The following is the definition of the state structure * used by the G.726 encoder and decoder to preserve their internal * state between successive calls. The meanings of the majority * of the state structure fields are explained in detail in the * CCITT Recommendation G.721. The field names are essentially identical * to variable names in the bit level description of the coding algorithm * included in this Recommendation. */ struct g726_state { long yl; /* Locked or steady state step size multiplier. */ int yu; /* Unlocked or non-steady state step size multiplier. */ int dms; /* Short term energy estimate. */ int dml; /* Long term energy estimate. */ int ap; /* Linear weighting coefficient of 'yl' and 'yu'. */ int a[2]; /* Coefficients of pole portion of prediction filter. * stored as fixed-point 1==2^14 */ int b[6]; /* Coefficients of zero portion of prediction filter. * stored as fixed-point 1==2^14 */ int pk[2]; /* Signs of previous two samples of a partially * reconstructed signal. */ int dq[6]; /* Previous 6 samples of the quantized difference signal * stored as fixed point 1==2^12, * or in internal floating point format */ int sr[2]; /* Previous 2 samples of the quantized difference signal * stored as fixed point 1==2^12, * or in internal floating point format */ int td; /* delayed tone detect, new in 1988 version */ }; static int qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400}; /* * Maps G.721 code word to reconstructed scale factor normalized log * magnitude values. */ static int _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425, 425, 373, 323, 273, 213, 135, 4, -2048}; /* Maps G.721 code word to log of scale factor multiplier. */ static int _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122, 1122, 355, 198, 112, 64, 41, 18, -12}; /* * Maps G.721 code words to a set of values whose long and short * term averages are computed and then compared to give an indication * how stationary (steady state) the signal is. */ static int _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00, 0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0}; /* * g72x_init_state() * * This routine initializes and/or resets the g726_state structure * pointed to by 'state_ptr'. * All the initial state values are specified in the CCITT G.721 document. */ static void g726_init_state(struct g726_state *state_ptr) { int cnta; state_ptr->yl = 34816; state_ptr->yu = 544; state_ptr->dms = 0; state_ptr->dml = 0; state_ptr->ap = 0; for (cnta = 0; cnta < 2; cnta++) { state_ptr->a[cnta] = 0; state_ptr->pk[cnta] = 0; #ifdef NOT_BLI state_ptr->sr[cnta] = 1; #else state_ptr->sr[cnta] = 32; #endif } for (cnta = 0; cnta < 6; cnta++) { state_ptr->b[cnta] = 0; #ifdef NOT_BLI state_ptr->dq[cnta] = 1; #else state_ptr->dq[cnta] = 32; #endif } state_ptr->td = 0; } /* * quan() * * quantizes the input val against the table of integers. * It returns i if table[i - 1] <= val < table[i]. * * Using linear search for simple coding. */ static int quan(int val, int *table, int size) { int i; for (i = 0; i < size && val >= *table; ++i, ++table) ; return i; } #ifdef NOT_BLI /* faster non-identical version */ /* * predictor_zero() * * computes the estimated signal from 6-zero predictor. * */ static int predictor_zero(struct g726_state *state_ptr) { /* divide by 2 is necessary here to handle negative numbers correctly */ int i; sint64 sezi; for (sezi = 0, i = 0; i < 6; i++) /* ACCUM */ sezi += (sint64)state_ptr->b[i] * state_ptr->dq[i]; return (int)(sezi >> 13) / 2 /* 2^14 */; } /* * predictor_pole() * * computes the estimated signal from 2-pole predictor. * */ static int predictor_pole(struct g726_state *state_ptr) { /* divide by 2 is necessary here to handle negative numbers correctly */ return (int)(((sint64)state_ptr->a[1] * state_ptr->sr[1] + (sint64)state_ptr->a[0] * state_ptr->sr[0]) >> 13) / 2 /* 2^14 */; } #else /* NOT_BLI - identical version */ /* * fmult() * * returns the integer product of the fixed-point number "an" (1==2^12) and * "floating point" representation (4-bit exponent, 6-bit mantessa) "srn". */ static int fmult(int an, int srn) { int anmag, anexp, anmant; int wanexp, wanmant; int retval; anmag = (an > 0) ? an : ((-an) & 0x1FFF); anexp = ilog2(anmag) - 5; anmant = (anmag == 0) ? 32 : (anexp >= 0) ? anmag >> anexp : anmag << -anexp; wanexp = anexp + ((srn >> 6) & 0xF) - 13; wanmant = (anmant * (srn & 077) + 0x30) >> 4; retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) : (wanmant >> -wanexp); return (((an ^ srn) < 0) ? -retval : retval); } static int predictor_zero(struct g726_state *state_ptr) { int i; int sezi; for (sezi = 0, i = 0; i < 6; i++) /* ACCUM */ sezi += fmult(state_ptr->b[i] >> 2, state_ptr->dq[i]); return sezi; } static int predictor_pole(struct g726_state *state_ptr) { return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) + fmult(state_ptr->a[0] >> 2, state_ptr->sr[0])); } #endif /* NOT_BLI */ /* * step_size() * * computes the quantization step size of the adaptive quantizer. * */ static int step_size(struct g726_state *state_ptr) { int y, dif, al; if (state_ptr->ap >= 256) { return state_ptr->yu; } y = state_ptr->yl >> 6; dif = state_ptr->yu - y; al = state_ptr->ap >> 2; if (dif > 0) { y += (dif * al) >> 6; } else if (dif < 0) { y += (dif * al + 0x3F) >> 6; } return y; } /* * quantize() * * Given a raw sample, 'd', of the difference signal and a * quantization step size scale factor, 'y', this routine returns the * ADPCM codeword to which that sample gets quantized. The step * size scale factor division operation is done in the log base 2 domain * as a subtraction. */ static int quantize( int d, /* Raw difference signal sample */ int y, /* Step size multiplier */ int *table, /* quantization table */ int size) /* table size of integers */ { int dqm; /* Magnitude of 'd' */ int exp; /* Integer part of base 2 log of 'd' */ int mant; /* Fractional part of base 2 log */ int dl; /* Log of magnitude of 'd' */ int dln; /* Step size scale factor normalized log */ int i; /* * LOG * * Compute base 2 log of 'd', and store in 'dl'. */ dqm = abs(d); exp = ilog2(dqm); if (exp < 0) { exp = 0; } mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */ dl = (exp << 7) | mant; /* * SUBTB * * "Divide" by step size multiplier. */ dln = dl - (y >> 2); /* * QUAN * * Obtain codword i for 'd'. */ i = quan(dln, table, size); if (d < 0) { /* take 1's complement of i */ return ((size << 1) + 1 - i); } else if (i == 0) { /* take 1's complement of 0 */ return ((size << 1) + 1); /* new in 1988 */ } else { return i; } } /* * reconstruct() * * Returns reconstructed difference signal 'dq' obtained from * codeword 'i' and quantization step size scale factor 'y'. * Multiplication is performed in log base 2 domain as addition. */ static int reconstruct( int sign, /* 0 for non-negative value */ int dqln, /* G.72x codeword */ int y) /* Step size multiplier */ { int dql; /* Log of 'dq' magnitude */ int dex; /* Integer part of log */ int dqt; int dq; /* Reconstructed difference signal sample */ dql = dqln + (y >> 2); /* ADDA */ if (dql < 0) { #ifdef NOT_BLI return (sign) ? -1 : 1; #else return (sign) ? -0x8000 : 0; #endif } else { /* ANTILOG */ dex = (dql >> 7) & 15; dqt = 128 + (dql & 127); #ifdef NOT_BLI dq = ((dqt << 19) >> (14 - dex)); return (sign) ? -dq : dq; #else dq = (dqt << 7) >> (14 - dex); return (sign) ? (dq - 0x8000) : dq; #endif } } /* * update() * * updates the state variables for each output code */ static void update( int code_size, /* distinguish 723_40 with others */ int y, /* quantizer step size */ int wi, /* scale factor multiplier */ int fi, /* for long/short term energies */ int dq, /* quantized prediction difference */ int sr, /* reconstructed signal */ int dqsez, /* difference from 2-pole predictor */ struct g726_state *state_ptr) /* coder state pointer */ { int cnt; int mag; /* Adaptive predictor, FLOAT A */ #ifndef NOT_BLI int exp; #endif int a2p=0; /* LIMC */ int a1ul; /* UPA1 */ int pks1; /* UPA2 */ int fa1; int tr; /* tone/transition detector */ int ylint, thr2, dqthr; int ylfrac, thr1; int pk0; pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */ #ifdef NOT_BLI mag = abs(dq / 0x1000); /* prediction difference magnitude */ #else mag = dq & 0x7FFF; /* prediction difference magnitude */ #endif /* TRANS */ ylint = state_ptr->yl >> 15; /* exponent part of yl */ ylfrac = (state_ptr->yl >> 10) & 0x1F; /* fractional part of yl */ thr1 = (32 + ylfrac) << ylint; /* threshold */ thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */ dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */ if (state_ptr->td == 0) { /* signal supposed voice */ tr = 0; } else if (mag <= dqthr) { /* supposed data, but small mag */ tr = 0; /* treated as voice */ } else { /* signal is data (modem) */ tr = 1; } /* * Quantizer scale factor adaptation. */ /* FUNCTW & FILTD & DELAY */ /* update non-steady state step size multiplier */ state_ptr->yu = y + ((wi - y) >> 5); /* LIMB */ if (state_ptr->yu < 544) { /* 544 <= yu <= 5120 */ state_ptr->yu = 544; } else if (state_ptr->yu > 5120) { state_ptr->yu = 5120; } /* FILTE & DELAY */ /* update steady state step size multiplier */ state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6); /* * Adaptive predictor coefficients. */ if (tr == 1) { /* reset a's and b's for modem signal */ state_ptr->a[0] = 0; state_ptr->a[1] = 0; state_ptr->b[0] = 0; state_ptr->b[1] = 0; state_ptr->b[2] = 0; state_ptr->b[3] = 0; state_ptr->b[4] = 0; state_ptr->b[5] = 0; } else { /* update a's and b's */ pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */ /* update predictor pole a[1] */ a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7); if (dqsez != 0) { fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0]; if (fa1 < -8191) { /* a2p = function of fa1 */ a2p -= 0x100; } else if (fa1 > 8191) { a2p += 0xFF; } else { a2p += fa1 >> 5; } if (pk0 ^ state_ptr->pk[1]) { /* LIMC */ if (a2p <= -12160) { a2p = -12288; } else if (a2p >= 12416) { a2p = 12288; } else { a2p -= 0x80; } } else if (a2p <= -12416) { a2p = -12288; } else if (a2p >= 12160) { a2p = 12288; } else { a2p += 0x80; } } /* TRIGB & DELAY */ state_ptr->a[1] = a2p; /* UPA1 */ /* update predictor pole a[0] */ state_ptr->a[0] -= state_ptr->a[0] >> 8; if (dqsez != 0) { if (pks1 == 0) state_ptr->a[0] += 192; else state_ptr->a[0] -= 192; } /* LIMD */ a1ul = 15360 - a2p; if (state_ptr->a[0] < -a1ul) { state_ptr->a[0] = -a1ul; } else if (state_ptr->a[0] > a1ul) { state_ptr->a[0] = a1ul; } /* UPB : update predictor zeros b[6] */ for (cnt = 0; cnt < 6; cnt++) { if (code_size == 5) { /* for 40Kbps G.723 */ state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9; } else { /* for G.721 and 24Kbps G.723 */ state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8; } if (mag) { /* XOR */ if ((dq ^ state_ptr->dq[cnt]) >= 0) { state_ptr->b[cnt] += 128; } else { state_ptr->b[cnt] -= 128; } } } } for (cnt = 5; cnt > 0; cnt--) state_ptr->dq[cnt] = state_ptr->dq[cnt-1]; #ifdef NOT_BLI state_ptr->dq[0] = dq; #else /* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */ if (mag == 0) { state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0x20 - 0x400; } else { exp = ilog2(mag) + 1; state_ptr->dq[0] = (dq >= 0) ? (exp << 6) + ((mag << 6) >> exp) : (exp << 6) + ((mag << 6) >> exp) - 0x400; } #endif state_ptr->sr[1] = state_ptr->sr[0]; #ifdef NOT_BLI state_ptr->sr[0] = sr; #else /* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */ if (sr == 0) { state_ptr->sr[0] = 0x20; } else if (sr > 0) { exp = ilog2(sr) + 1; state_ptr->sr[0] = (exp << 6) + ((sr << 6) >> exp); } else if (sr > -0x8000) { mag = -sr; exp = ilog2(mag) + 1; state_ptr->sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400; } else state_ptr->sr[0] = 0x20 - 0x400; #endif /* DELAY A */ state_ptr->pk[1] = state_ptr->pk[0]; state_ptr->pk[0] = pk0; /* TONE */ if (tr == 1) { /* this sample has been treated as data */ state_ptr->td = 0; /* next one will be treated as voice */ } else if (a2p < -11776) { /* small sample-to-sample correlation */ state_ptr->td = 1; /* signal may be data */ } else { /* signal is voice */ state_ptr->td = 0; } /* * Adaptation speed control. */ state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */ state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */ if (tr == 1) { state_ptr->ap = 256; } else if (y < 1536) { /* SUBTC */ state_ptr->ap += (0x200 - state_ptr->ap) >> 4; } else if (state_ptr->td == 1) { state_ptr->ap += (0x200 - state_ptr->ap) >> 4; } else if (abs((state_ptr->dms << 2) - state_ptr->dml) >= (state_ptr->dml >> 3)) { state_ptr->ap += (0x200 - state_ptr->ap) >> 4; } else { state_ptr->ap += (-state_ptr->ap) >> 4; } } /* * g726_decode() * * Description: * * Decodes a 4-bit code of G.726-32 encoded data of i and * returns the resulting linear PCM, A-law or u-law value. * return -1 for unknown out_coding value. */ static int g726_decode(int i, struct g726_state *state_ptr) { int sezi, sez, se; /* ACCUM */ int y; /* MIX */ int sr; /* ADDB */ int dq; int dqsez; i &= 0x0f; /* mask to get proper bits */ #ifdef NOT_BLI sezi = predictor_zero(state_ptr); sez = sezi; se = sezi + predictor_pole(state_ptr); /* estimated signal */ #else sezi = predictor_zero(state_ptr); sez = sezi >> 1; se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */ #endif y = step_size(state_ptr); /* dynamic quantizer step size */ dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized diff. */ #ifdef NOT_BLI sr = se + dq; /* reconst. signal */ dqsez = dq + sez; /* pole prediction diff. */ #else sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */ dqsez = sr - se + sez; /* pole prediction diff. */ #endif update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); #ifdef NOT_BLI return (sr >> 10); /* sr was 26-bit dynamic range */ #else return (sr << 2); /* sr was 14-bit dynamic range */ #endif } /* * g726_encode() * * Encodes the input vale of linear PCM, A-law or u-law data sl and returns * the resulting code. -1 is returned for unknown input coding value. */ static int g726_encode(int sl, struct g726_state *state_ptr) { int sezi, se, sez; /* ACCUM */ int d; /* SUBTA */ int sr; /* ADDB */ int y; /* MIX */ int dqsez; /* ADDC */ int dq, i; #ifdef NOT_BLI sl <<= 10; /* 26-bit dynamic range */ sezi = predictor_zero(state_ptr); sez = sezi; se = sezi + predictor_pole(state_ptr); /* estimated signal */ #else sl >>= 2; /* 14-bit dynamic range */ sezi = predictor_zero(state_ptr); sez = sezi >> 1; se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */ #endif d = sl - se; /* estimation difference */ /* quantize the prediction difference */ y = step_size(state_ptr); /* quantizer step size */ #ifdef NOT_BLI d /= 0x1000; #endif i = quantize(d, y, qtab_721, 7); /* i = G726 code */ dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */ #ifdef NOT_BLI sr = se + dq; /* reconst. signal */ dqsez = dq + sez; /* pole prediction diff. */ #else sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */ dqsez = sr - se + sez; /* pole prediction diff. */ #endif update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); return i; } /* * Private workspace for translating signed linear signals to G726. * Don't bother to define two distinct structs. */ struct g726_coder_pvt { /* buffer any odd byte in input - 0x80 + (value & 0xf) if present */ unsigned char next_flag; struct g726_state g726; }; /*! \brief init a new instance of g726_coder_pvt. */ static int lintog726_new(struct ast_trans_pvt *pvt) { struct g726_coder_pvt *tmp = pvt->pvt; g726_init_state(&tmp->g726); return 0; } /*! \brief decode packed 4-bit G726 values (AAL2 packing) and store in buffer. */ static int g726aal2tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; unsigned char *src = f->data.ptr; int16_t *dst = pvt->outbuf.i16 + pvt->samples; unsigned int i; for (i = 0; i < f->datalen; i++) { *dst++ = g726_decode((src[i] >> 4) & 0xf, &tmp->g726); *dst++ = g726_decode(src[i] & 0x0f, &tmp->g726); } pvt->samples += f->samples; pvt->datalen += 2 * f->samples; /* 2 bytes/sample */ return 0; } /*! \brief compress and store data (4-bit G726 samples, AAL2 packing) in outbuf */ static int lintog726aal2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; int16_t *src = f->data.ptr; unsigned int i; for (i = 0; i < f->samples; i++) { unsigned char d = g726_encode(src[i], &tmp->g726); /* this sample */ if (tmp->next_flag & 0x80) { /* merge with leftover sample */ pvt->outbuf.c[pvt->datalen++] = ((tmp->next_flag & 0xf)<< 4) | d; pvt->samples += 2; /* 2 samples per byte */ tmp->next_flag = 0; } else { tmp->next_flag = 0x80 | d; } } return 0; } /*! \brief decode packed 4-bit G726 values (RFC3551 packing) and store in buffer. */ static int g726tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; unsigned char *src = f->data.ptr; int16_t *dst = pvt->outbuf.i16 + pvt->samples; unsigned int i; for (i = 0; i < f->datalen; i++) { *dst++ = g726_decode(src[i] & 0x0f, &tmp->g726); *dst++ = g726_decode((src[i] >> 4) & 0xf, &tmp->g726); } pvt->samples += f->samples; pvt->datalen += 2 * f->samples; /* 2 bytes/sample */ return 0; } /*! \brief compress and store data (4-bit G726 samples, RFC3551 packing) in outbuf */ static int lintog726_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; int16_t *src = f->data.ptr; unsigned int i; for (i = 0; i < f->samples; i++) { unsigned char d = g726_encode(src[i], &tmp->g726); /* this sample */ if (tmp->next_flag & 0x80) { /* merge with leftover sample */ pvt->outbuf.c[pvt->datalen++] = (d << 4) | (tmp->next_flag & 0xf); pvt->samples += 2; /* 2 samples per byte */ tmp->next_flag = 0; } else { tmp->next_flag = 0x80 | d; } } return 0; } static struct ast_translator g726tolin = { .name = "g726tolin", .newpvt = lintog726_new, /* same for both directions */ .framein = g726tolin_framein, .sample = g726_sample, .desc_size = sizeof(struct g726_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, }; static struct ast_translator lintog726 = { .name = "lintog726", .newpvt = lintog726_new, /* same for both directions */ .framein = lintog726_framein, .sample = slin8_sample, .desc_size = sizeof(struct g726_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES/2, }; static struct ast_translator g726aal2tolin = { .name = "g726aal2tolin", .newpvt = lintog726_new, /* same for both directions */ .framein = g726aal2tolin_framein, .sample = g726_sample, .desc_size = sizeof(struct g726_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, }; static struct ast_translator lintog726aal2 = { .name = "lintog726aal2", .newpvt = lintog726_new, /* same for both directions */ .framein = lintog726aal2_framein, .sample = slin8_sample, .desc_size = sizeof(struct g726_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES / 2, }; static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res = 0; res |= ast_unregister_translator(&g726tolin); res |= ast_unregister_translator(&lintog726); res |= ast_unregister_translator(&g726aal2tolin); res |= ast_unregister_translator(&lintog726aal2); return res; } static int load_module(void) { int res = 0; ast_format_set(&g726tolin.src_format, AST_FORMAT_G726, 0); ast_format_set(&g726tolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintog726.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintog726.dst_format, AST_FORMAT_G726, 0); ast_format_set(&g726aal2tolin.src_format, AST_FORMAT_G726_AAL2, 0); ast_format_set(&g726aal2tolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintog726aal2.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintog726aal2.dst_format, AST_FORMAT_G726_AAL2, 0); res |= ast_register_translator(&g726tolin); res |= ast_register_translator(&lintog726); res |= ast_register_translator(&g726aal2tolin); res |= ast_register_translator(&lintog726aal2); if (res) { unload_module(); return AST_MODULE_LOAD_FAILURE; } return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ITU G.726-32kbps G726 Transcoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/speex/0000755000175000007640000000000012254071136015732 5ustar sharkyjerrywebasterisk-11.7.0/codecs/speex/resample_sse.h0000644000175000007640000001112711531040421020555 0ustar sharkyjerryweb/* Copyright (C) 2007-2008 Jean-Marc Valin * Copyright (C) 2008 Thorvald Natvig */ /** @file resample_sse.h @brief Resampler functions (SSE version) */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #define OVERRIDE_INNER_PRODUCT_SINGLE static inline float inner_product_single(const float *a, const float *b, unsigned int len) { int i; float ret; __m128 sum = _mm_setzero_ps(); for (i=0;i #define OVERRIDE_INNER_PRODUCT_DOUBLE static inline double inner_product_double(const float *a, const float *b, unsigned int len) { int i; double ret; __m128d sum = _mm_setzero_pd(); __m128 t; for (i=0;i (b) ? (a) : (b)) /**< Maximum 16-bit value. */ #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */ #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ #ifdef FIXED_POINT typedef spx_int16_t spx_word16_t; typedef spx_int32_t spx_word32_t; typedef spx_word32_t spx_mem_t; typedef spx_word16_t spx_coef_t; typedef spx_word16_t spx_lsp_t; typedef spx_word32_t spx_sig_t; #define Q15ONE 32767 #define LPC_SCALING 8192 #define SIG_SCALING 16384 #define LSP_SCALING 8192. #define GAMMA_SCALING 32768. #define GAIN_SCALING 64 #define GAIN_SCALING_1 0.015625 #define LPC_SHIFT 13 #define LSP_SHIFT 13 #define SIG_SHIFT 14 #define GAIN_SHIFT 6 #define VERY_SMALL 0 #define VERY_LARGE32 ((spx_word32_t)2147483647) #define VERY_LARGE16 ((spx_word16_t)32767) #define Q15_ONE ((spx_word16_t)32767) #ifdef FIXED_DEBUG #include "fixed_debug.h" #else #include "fixed_generic.h" #ifdef ARM5E_ASM #include "fixed_arm5e.h" #elif defined (ARM4_ASM) #include "fixed_arm4.h" #elif defined (BFIN_ASM) #include "fixed_bfin.h" #endif #endif #else typedef float spx_mem_t; typedef float spx_coef_t; typedef float spx_lsp_t; typedef float spx_sig_t; typedef float spx_word16_t; typedef float spx_word32_t; #define Q15ONE 1.0f #define LPC_SCALING 1.f #define SIG_SCALING 1.f #define LSP_SCALING 1.f #define GAMMA_SCALING 1.f #define GAIN_SCALING 1.f #define GAIN_SCALING_1 1.f #define VERY_SMALL 1e-15f #define VERY_LARGE32 1e15f #define VERY_LARGE16 1e15f #define Q15_ONE ((spx_word16_t)1.f) #define QCONST16(x,bits) (x) #define QCONST32(x,bits) (x) #define NEG16(x) (-(x)) #define NEG32(x) (-(x)) #define EXTRACT16(x) (x) #define EXTEND32(x) (x) #define SHR16(a,shift) (a) #define SHL16(a,shift) (a) #define SHR32(a,shift) (a) #define SHL32(a,shift) (a) #define PSHR16(a,shift) (a) #define PSHR32(a,shift) (a) #define VSHR32(a,shift) (a) #define SATURATE16(x,a) (x) #define SATURATE32(x,a) (x) #define PSHR(a,shift) (a) #define SHR(a,shift) (a) #define SHL(a,shift) (a) #define SATURATE(x,a) (x) #define ADD16(a,b) ((a)+(b)) #define SUB16(a,b) ((a)-(b)) #define ADD32(a,b) ((a)+(b)) #define SUB32(a,b) ((a)-(b)) #define MULT16_16_16(a,b) ((a)*(b)) #define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) #define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) #define MULT16_32_Q11(a,b) ((a)*(b)) #define MULT16_32_Q13(a,b) ((a)*(b)) #define MULT16_32_Q14(a,b) ((a)*(b)) #define MULT16_32_Q15(a,b) ((a)*(b)) #define MULT16_32_P15(a,b) ((a)*(b)) #define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) #define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) #define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) #define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) #define MULT16_16_Q11_32(a,b) ((a)*(b)) #define MULT16_16_Q13(a,b) ((a)*(b)) #define MULT16_16_Q14(a,b) ((a)*(b)) #define MULT16_16_Q15(a,b) ((a)*(b)) #define MULT16_16_P15(a,b) ((a)*(b)) #define MULT16_16_P13(a,b) ((a)*(b)) #define MULT16_16_P14(a,b) ((a)*(b)) #define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) #define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) #define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) #define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) #endif #if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) /* 2 on TI C5x DSP */ #define BYTES_PER_CHAR 2 #define BITS_PER_CHAR 16 #define LOG2_BITS_PER_CHAR 4 #else #define BYTES_PER_CHAR 1 #define BITS_PER_CHAR 8 #define LOG2_BITS_PER_CHAR 3 #endif #ifdef FIXED_DEBUG extern long long spx_mips; #endif #endif asterisk-11.7.0/codecs/speex/stack_alloc.h0000644000175000007640000000645511531040421020362 0ustar sharkyjerryweb/* Copyright (C) 2002 Jean-Marc Valin */ /** @file stack_alloc.h @brief Temporary memory allocation on stack */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef STACK_ALLOC_H #define STACK_ALLOC_H #ifdef USE_ALLOCA # ifdef WIN32 # include # else # ifdef HAVE_ALLOCA_H # include # else # include # endif # endif #endif /** * @def ALIGN(stack, size) * * Aligns the stack to a 'size' boundary * * @param stack Stack * @param size New size boundary */ /** * @def PUSH(stack, size, type) * * Allocates 'size' elements of type 'type' on the stack * * @param stack Stack * @param size Number of elements * @param type Type of element */ /** * @def VARDECL(var) * * Declare variable on stack * * @param var Variable to declare */ /** * @def ALLOC(var, size, type) * * Allocate 'size' elements of 'type' on stack * * @param var Name of variable to allocate * @param size Number of elements * @param type Type of element */ #ifdef ENABLE_VALGRIND #include #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) #define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) #else #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) #endif #if defined(VAR_ARRAYS) #define VARDECL(var) #define ALLOC(var, size, type) type var[size] #elif defined(USE_ALLOCA) #define VARDECL(var) var #define ALLOC(var, size, type) var = alloca(sizeof(type)*(size)) #else #define VARDECL(var) var #define ALLOC(var, size, type) var = PUSH(stack, size, type) #endif #endif asterisk-11.7.0/codecs/speex/fixed_generic.h0000644000175000007640000001213611531040421020667 0ustar sharkyjerryweb/* Copyright (C) 2003 Jean-Marc Valin */ /** @file fixed_generic.h @brief Generic fixed-point operations */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FIXED_GENERIC_H #define FIXED_GENERIC_H #define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) #define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) #define NEG16(x) (-(x)) #define NEG32(x) (-(x)) #define EXTRACT16(x) ((spx_word16_t)(x)) #define EXTEND32(x) ((spx_word32_t)(x)) #define SHR16(a,shift) ((a) >> (shift)) #define SHL16(a,shift) ((a) << (shift)) #define SHR32(a,shift) ((a) >> (shift)) #define SHL32(a,shift) ((a) << (shift)) #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift)) #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) #define SHR(a,shift) ((a) >> (shift)) #define SHL(a,shift) ((spx_word32_t)(a) << (shift)) #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift)) #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) #define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b))) #define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b)) #define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b)) #define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b)) /* result fits in 16 bits */ #define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b)))) /* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */ #define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b))) #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) #define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12)) #define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13)) #define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14)) #define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)) #define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))) #define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15)) #define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)) #define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) #define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11))) #define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13))) #define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13))) #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) #define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) #define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) #define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) #define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15)) #define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b)))) #define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b)))) #define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b))) #define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b))) #endif asterisk-11.7.0/codecs/speex/resample.c0000644000175000007640000011720411531040421017701 0ustar sharkyjerryweb/* Copyright (C) 2007-2008 Jean-Marc Valin Copyright (C) 2008 Thorvald Natvig File: resample.c Arbitrary resampling code Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* The design goals of this code are: - Very fast algorithm - SIMD-friendly algorithm - Low memory requirement - Good *perceptual* quality (and not best SNR) Warning: This resampler is relatively new. Although I think I got rid of all the major bugs and I don't expect the API to change anymore, there may be something I've missed. So use with caution. This algorithm is based on this original resampling algorithm: Smith, Julius O. Digital Audio Resampling Home Page Center for Computer Research in Music and Acoustics (CCRMA), Stanford University, 2007. Web published at http://www-ccrma.stanford.edu/~jos/resample/. There is one main difference, though. This resampler uses cubic interpolation instead of linear interpolation in the above paper. This makes the table much smaller and makes it possible to compute that table on a per-stream basis. In turn, being able to tweak the table for each stream makes it possible to both reduce complexity on simple ratios (e.g. 2/3), and get rid of the rounding operations in the inner loop. The latter both reduces CPU time and makes the algorithm more SIMD-friendly. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include static void *speex_alloc (int size) {return calloc(size,1);} static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);} static void speex_free (void *ptr) {free(ptr);} #include "speex_resampler.h" #include "arch.h" #include "stack_alloc.h" #include #ifndef M_PI #define M_PI 3.14159263 #endif #ifdef FIXED_POINT #define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x))) #else #define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 : floor(.5+(x)))) #endif #define IMAX(a,b) ((a) > (b) ? (a) : (b)) #define IMIN(a,b) ((a) < (b) ? (a) : (b)) #ifndef NULL #define NULL 0 #endif #ifdef _USE_SSE #include "resample_sse.h" #endif /* Numer of elements to allocate on the stack */ #ifdef VAR_ARRAYS #define FIXED_STACK_ALLOC 8192 #else #define FIXED_STACK_ALLOC 1024 #endif typedef int (*resampler_basic_func)(SpeexResamplerState *, spx_uint32_t , const spx_word16_t *, spx_uint32_t *, spx_word16_t *, spx_uint32_t *); struct SpeexResamplerState_ { spx_uint32_t in_rate; spx_uint32_t out_rate; spx_uint32_t num_rate; spx_uint32_t den_rate; int quality; spx_uint32_t nb_channels; spx_uint32_t filt_len; spx_uint32_t mem_alloc_size; spx_uint32_t buffer_size; int int_advance; int frac_advance; float cutoff; spx_uint32_t oversample; int initialised; int started; /* These are per-channel */ spx_int32_t *last_sample; spx_uint32_t *samp_frac_num; spx_uint32_t *magic_samples; spx_word16_t *mem; spx_word16_t *sinc_table; spx_uint32_t sinc_table_length; resampler_basic_func resampler_ptr; int in_stride; int out_stride; } ; static double kaiser12_table[68] = { 0.99859849, 1.00000000, 0.99859849, 0.99440475, 0.98745105, 0.97779076, 0.96549770, 0.95066529, 0.93340547, 0.91384741, 0.89213598, 0.86843014, 0.84290116, 0.81573067, 0.78710866, 0.75723148, 0.72629970, 0.69451601, 0.66208321, 0.62920216, 0.59606986, 0.56287762, 0.52980938, 0.49704014, 0.46473455, 0.43304576, 0.40211431, 0.37206735, 0.34301800, 0.31506490, 0.28829195, 0.26276832, 0.23854851, 0.21567274, 0.19416736, 0.17404546, 0.15530766, 0.13794294, 0.12192957, 0.10723616, 0.09382272, 0.08164178, 0.07063950, 0.06075685, 0.05193064, 0.04409466, 0.03718069, 0.03111947, 0.02584161, 0.02127838, 0.01736250, 0.01402878, 0.01121463, 0.00886058, 0.00691064, 0.00531256, 0.00401805, 0.00298291, 0.00216702, 0.00153438, 0.00105297, 0.00069463, 0.00043489, 0.00025272, 0.00013031, 0.0000527734, 0.00001000, 0.00000000}; /* static double kaiser12_table[36] = { 0.99440475, 1.00000000, 0.99440475, 0.97779076, 0.95066529, 0.91384741, 0.86843014, 0.81573067, 0.75723148, 0.69451601, 0.62920216, 0.56287762, 0.49704014, 0.43304576, 0.37206735, 0.31506490, 0.26276832, 0.21567274, 0.17404546, 0.13794294, 0.10723616, 0.08164178, 0.06075685, 0.04409466, 0.03111947, 0.02127838, 0.01402878, 0.00886058, 0.00531256, 0.00298291, 0.00153438, 0.00069463, 0.00025272, 0.0000527734, 0.00000500, 0.00000000}; */ static double kaiser10_table[36] = { 0.99537781, 1.00000000, 0.99537781, 0.98162644, 0.95908712, 0.92831446, 0.89005583, 0.84522401, 0.79486424, 0.74011713, 0.68217934, 0.62226347, 0.56155915, 0.50119680, 0.44221549, 0.38553619, 0.33194107, 0.28205962, 0.23636152, 0.19515633, 0.15859932, 0.12670280, 0.09935205, 0.07632451, 0.05731132, 0.04193980, 0.02979584, 0.02044510, 0.01345224, 0.00839739, 0.00488951, 0.00257636, 0.00115101, 0.00035515, 0.00000000, 0.00000000}; static double kaiser8_table[36] = { 0.99635258, 1.00000000, 0.99635258, 0.98548012, 0.96759014, 0.94302200, 0.91223751, 0.87580811, 0.83439927, 0.78875245, 0.73966538, 0.68797126, 0.63451750, 0.58014482, 0.52566725, 0.47185369, 0.41941150, 0.36897272, 0.32108304, 0.27619388, 0.23465776, 0.19672670, 0.16255380, 0.13219758, 0.10562887, 0.08273982, 0.06335451, 0.04724088, 0.03412321, 0.02369490, 0.01563093, 0.00959968, 0.00527363, 0.00233883, 0.00050000, 0.00000000}; static double kaiser6_table[36] = { 0.99733006, 1.00000000, 0.99733006, 0.98935595, 0.97618418, 0.95799003, 0.93501423, 0.90755855, 0.87598009, 0.84068475, 0.80211977, 0.76076565, 0.71712752, 0.67172623, 0.62508937, 0.57774224, 0.53019925, 0.48295561, 0.43647969, 0.39120616, 0.34752997, 0.30580127, 0.26632152, 0.22934058, 0.19505503, 0.16360756, 0.13508755, 0.10953262, 0.08693120, 0.06722600, 0.05031820, 0.03607231, 0.02432151, 0.01487334, 0.00752000, 0.00000000}; struct FuncDef { double *table; int oversample; }; static struct FuncDef _KAISER12 = {kaiser12_table, 64}; #define KAISER12 (&_KAISER12) /*static struct FuncDef _KAISER12 = {kaiser12_table, 32}; #define KAISER12 (&_KAISER12)*/ static struct FuncDef _KAISER10 = {kaiser10_table, 32}; #define KAISER10 (&_KAISER10) static struct FuncDef _KAISER8 = {kaiser8_table, 32}; #define KAISER8 (&_KAISER8) static struct FuncDef _KAISER6 = {kaiser6_table, 32}; #define KAISER6 (&_KAISER6) struct QualityMapping { int base_length; int oversample; float downsample_bandwidth; float upsample_bandwidth; struct FuncDef *window_func; }; /* This table maps conversion quality to internal parameters. There are two reasons that explain why the up-sampling bandwidth is larger than the down-sampling bandwidth: 1) When up-sampling, we can assume that the spectrum is already attenuated close to the Nyquist rate (from an A/D or a previous resampling filter) 2) Any aliasing that occurs very close to the Nyquist rate will be masked by the sinusoids/noise just below the Nyquist rate (guaranteed only for up-sampling). */ static const struct QualityMapping quality_map[11] = { { 8, 4, 0.830f, 0.860f, KAISER6 }, /* Q0 */ { 16, 4, 0.850f, 0.880f, KAISER6 }, /* Q1 */ { 32, 4, 0.882f, 0.910f, KAISER6 }, /* Q2 */ /* 82.3% cutoff ( ~60 dB stop) 6 */ { 48, 8, 0.895f, 0.917f, KAISER8 }, /* Q3 */ /* 84.9% cutoff ( ~80 dB stop) 8 */ { 64, 8, 0.921f, 0.940f, KAISER8 }, /* Q4 */ /* 88.7% cutoff ( ~80 dB stop) 8 */ { 80, 16, 0.922f, 0.940f, KAISER10}, /* Q5 */ /* 89.1% cutoff (~100 dB stop) 10 */ { 96, 16, 0.940f, 0.945f, KAISER10}, /* Q6 */ /* 91.5% cutoff (~100 dB stop) 10 */ {128, 16, 0.950f, 0.950f, KAISER10}, /* Q7 */ /* 93.1% cutoff (~100 dB stop) 10 */ {160, 16, 0.960f, 0.960f, KAISER10}, /* Q8 */ /* 94.5% cutoff (~100 dB stop) 10 */ {192, 32, 0.968f, 0.968f, KAISER12}, /* Q9 */ /* 95.5% cutoff (~100 dB stop) 10 */ {256, 32, 0.975f, 0.975f, KAISER12}, /* Q10 */ /* 96.6% cutoff (~100 dB stop) 10 */ }; /*8,24,40,56,80,104,128,160,200,256,320*/ static double compute_func(float x, struct FuncDef *func) { float y, frac; double interp[4]; int ind; y = x*func->oversample; ind = (int)floor(y); frac = (y-ind); /* CSE with handle the repeated powers */ interp[3] = -0.1666666667*frac + 0.1666666667*(frac*frac*frac); interp[2] = frac + 0.5*(frac*frac) - 0.5*(frac*frac*frac); /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ interp[0] = -0.3333333333*frac + 0.5*(frac*frac) - 0.1666666667*(frac*frac*frac); /* Just to make sure we don't have rounding problems */ interp[1] = 1.f-interp[3]-interp[2]-interp[0]; /*sum = frac*accum[1] + (1-frac)*accum[2];*/ return interp[0]*func->table[ind] + interp[1]*func->table[ind+1] + interp[2]*func->table[ind+2] + interp[3]*func->table[ind+3]; } #if 0 #include int main(int argc, char **argv) { int i; for (i=0;i<256;i++) { printf ("%f\n", compute_func(i/256., KAISER12)); } return 0; } #endif #ifdef FIXED_POINT /* The slow way of computing a sinc for the table. Should improve that some day */ static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) { /*fprintf (stderr, "%f ", x);*/ float xx = x * cutoff; if (fabs(x)<1e-6f) return WORD2INT(32768.*cutoff); else if (fabs(x) > .5f*N) return 0; /*FIXME: Can it really be any slower than this? */ return WORD2INT(32768.*cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func)); } #else /* The slow way of computing a sinc for the table. Should improve that some day */ static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) { /*fprintf (stderr, "%f ", x);*/ float xx = x * cutoff; if (fabs(x)<1e-6) return cutoff; else if (fabs(x) > .5*N) return 0; /*FIXME: Can it really be any slower than this? */ return cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func); } #endif #ifdef FIXED_POINT static void cubic_coef(spx_word16_t x, spx_word16_t interp[4]) { /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation but I know it's MMSE-optimal on a sinc */ spx_word16_t x2, x3; x2 = MULT16_16_P15(x, x); x3 = MULT16_16_P15(x, x2); interp[0] = PSHR32(MULT16_16(QCONST16(-0.16667f, 15),x) + MULT16_16(QCONST16(0.16667f, 15),x3),15); interp[1] = EXTRACT16(EXTEND32(x) + SHR32(SUB32(EXTEND32(x2),EXTEND32(x3)),1)); interp[3] = PSHR32(MULT16_16(QCONST16(-0.33333f, 15),x) + MULT16_16(QCONST16(.5f,15),x2) - MULT16_16(QCONST16(0.16667f, 15),x3),15); /* Just to make sure we don't have rounding problems */ interp[2] = Q15_ONE-interp[0]-interp[1]-interp[3]; if (interp[2]<32767) interp[2]+=1; } #else static void cubic_coef(spx_word16_t frac, spx_word16_t interp[4]) { /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation but I know it's MMSE-optimal on a sinc */ interp[0] = -0.16667f*frac + 0.16667f*frac*frac*frac; interp[1] = frac + 0.5f*frac*frac - 0.5f*frac*frac*frac; /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ interp[3] = -0.33333f*frac + 0.5f*frac*frac - 0.16667f*frac*frac*frac; /* Just to make sure we don't have rounding problems */ interp[2] = 1.-interp[0]-interp[1]-interp[3]; } #endif static int resampler_basic_direct_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) { const int N = st->filt_len; int out_sample = 0; int last_sample = st->last_sample[channel_index]; spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; const spx_word16_t *sinc_table = st->sinc_table; const int out_stride = st->out_stride; const int int_advance = st->int_advance; const int frac_advance = st->frac_advance; const spx_uint32_t den_rate = st->den_rate; spx_word32_t sum; int j; while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) { const spx_word16_t *sinc = & sinc_table[samp_frac_num*N]; const spx_word16_t *iptr = & in[last_sample]; #ifndef OVERRIDE_INNER_PRODUCT_SINGLE float accum[4] = {0,0,0,0}; for(j=0;j= den_rate) { samp_frac_num -= den_rate; last_sample++; } } st->last_sample[channel_index] = last_sample; st->samp_frac_num[channel_index] = samp_frac_num; return out_sample; } #ifdef FIXED_POINT #else /* This is the same as the previous function, except with a double-precision accumulator */ static int resampler_basic_direct_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) { const int N = st->filt_len; int out_sample = 0; int last_sample = st->last_sample[channel_index]; spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; const spx_word16_t *sinc_table = st->sinc_table; const int out_stride = st->out_stride; const int int_advance = st->int_advance; const int frac_advance = st->frac_advance; const spx_uint32_t den_rate = st->den_rate; double sum; int j; while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) { const spx_word16_t *sinc = & sinc_table[samp_frac_num*N]; const spx_word16_t *iptr = & in[last_sample]; #ifndef OVERRIDE_INNER_PRODUCT_DOUBLE double accum[4] = {0,0,0,0}; for(j=0;j= den_rate) { samp_frac_num -= den_rate; last_sample++; } } st->last_sample[channel_index] = last_sample; st->samp_frac_num[channel_index] = samp_frac_num; return out_sample; } #endif static int resampler_basic_interpolate_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) { const int N = st->filt_len; int out_sample = 0; int last_sample = st->last_sample[channel_index]; spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; const int out_stride = st->out_stride; const int int_advance = st->int_advance; const int frac_advance = st->frac_advance; const spx_uint32_t den_rate = st->den_rate; int j; spx_word32_t sum; while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) { const spx_word16_t *iptr = & in[last_sample]; const int offset = samp_frac_num*st->oversample/st->den_rate; #ifdef FIXED_POINT const spx_word16_t frac = PDIV32(SHL32((samp_frac_num*st->oversample) % st->den_rate,15),st->den_rate); #else const spx_word16_t frac = ((float)((samp_frac_num*st->oversample) % st->den_rate))/st->den_rate; #endif spx_word16_t interp[4]; #ifndef OVERRIDE_INTERPOLATE_PRODUCT_SINGLE spx_word32_t accum[4] = {0,0,0,0}; for(j=0;jsinc_table[4+(j+1)*st->oversample-offset-2]); accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); } cubic_coef(frac, interp); sum = MULT16_32_Q15(interp[0],accum[0]) + MULT16_32_Q15(interp[1],accum[1]) + MULT16_32_Q15(interp[2],accum[2]) + MULT16_32_Q15(interp[3],accum[3]); #else cubic_coef(frac, interp); sum = interpolate_product_single(iptr, st->sinc_table + st->oversample + 4 - offset - 2, N, st->oversample, interp); #endif out[out_stride * out_sample++] = PSHR32(sum,15); last_sample += int_advance; samp_frac_num += frac_advance; if (samp_frac_num >= den_rate) { samp_frac_num -= den_rate; last_sample++; } } st->last_sample[channel_index] = last_sample; st->samp_frac_num[channel_index] = samp_frac_num; return out_sample; } #ifdef FIXED_POINT #else /* This is the same as the previous function, except with a double-precision accumulator */ static int resampler_basic_interpolate_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) { const int N = st->filt_len; int out_sample = 0; int last_sample = st->last_sample[channel_index]; spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; const int out_stride = st->out_stride; const int int_advance = st->int_advance; const int frac_advance = st->frac_advance; const spx_uint32_t den_rate = st->den_rate; int j; spx_word32_t sum; while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) { const spx_word16_t *iptr = & in[last_sample]; const int offset = samp_frac_num*st->oversample/st->den_rate; #ifdef FIXED_POINT const spx_word16_t frac = PDIV32(SHL32((samp_frac_num*st->oversample) % st->den_rate,15),st->den_rate); #else const spx_word16_t frac = ((float)((samp_frac_num*st->oversample) % st->den_rate))/st->den_rate; #endif spx_word16_t interp[4]; #ifndef OVERRIDE_INTERPOLATE_PRODUCT_DOUBLE double accum[4] = {0,0,0,0}; for(j=0;jsinc_table[4+(j+1)*st->oversample-offset-2]); accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); } cubic_coef(frac, interp); sum = MULT16_32_Q15(interp[0],accum[0]) + MULT16_32_Q15(interp[1],accum[1]) + MULT16_32_Q15(interp[2],accum[2]) + MULT16_32_Q15(interp[3],accum[3]); #else cubic_coef(frac, interp); sum = interpolate_product_double(iptr, st->sinc_table + st->oversample + 4 - offset - 2, N, st->oversample, interp); #endif out[out_stride * out_sample++] = PSHR32(sum,15); last_sample += int_advance; samp_frac_num += frac_advance; if (samp_frac_num >= den_rate) { samp_frac_num -= den_rate; last_sample++; } } st->last_sample[channel_index] = last_sample; st->samp_frac_num[channel_index] = samp_frac_num; return out_sample; } #endif static void update_filter(SpeexResamplerState *st) { spx_uint32_t old_length; old_length = st->filt_len; st->oversample = quality_map[st->quality].oversample; st->filt_len = quality_map[st->quality].base_length; if (st->num_rate > st->den_rate) { /* down-sampling */ st->cutoff = quality_map[st->quality].downsample_bandwidth * st->den_rate / st->num_rate; /* FIXME: divide the numerator and denominator by a certain amount if they're too large */ st->filt_len = st->filt_len*st->num_rate / st->den_rate; /* Round down to make sure we have a multiple of 4 */ st->filt_len &= (~0x3); if (2*st->den_rate < st->num_rate) st->oversample >>= 1; if (4*st->den_rate < st->num_rate) st->oversample >>= 1; if (8*st->den_rate < st->num_rate) st->oversample >>= 1; if (16*st->den_rate < st->num_rate) st->oversample >>= 1; if (st->oversample < 1) st->oversample = 1; } else { /* up-sampling */ st->cutoff = quality_map[st->quality].upsample_bandwidth; } /* Choose the resampling type that requires the least amount of memory */ if (st->den_rate <= st->oversample) { spx_uint32_t i; if (!st->sinc_table) st->sinc_table = (spx_word16_t *)speex_alloc(st->filt_len*st->den_rate*sizeof(spx_word16_t)); else if (st->sinc_table_length < st->filt_len*st->den_rate) { st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,st->filt_len*st->den_rate*sizeof(spx_word16_t)); st->sinc_table_length = st->filt_len*st->den_rate; } for (i=0;iden_rate;i++) { spx_int32_t j; for (j=0;jfilt_len;j++) { st->sinc_table[i*st->filt_len+j] = sinc(st->cutoff,((j-(spx_int32_t)st->filt_len/2+1)-((float)i)/st->den_rate), st->filt_len, quality_map[st->quality].window_func); } } #ifdef FIXED_POINT st->resampler_ptr = resampler_basic_direct_single; #else if (st->quality>8) st->resampler_ptr = resampler_basic_direct_double; else st->resampler_ptr = resampler_basic_direct_single; #endif /*fprintf (stderr, "resampler uses direct sinc table and normalised cutoff %f\n", cutoff);*/ } else { spx_int32_t i; if (!st->sinc_table) st->sinc_table = (spx_word16_t *)speex_alloc((st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); else if (st->sinc_table_length < st->filt_len*st->oversample+8) { st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,(st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); st->sinc_table_length = st->filt_len*st->oversample+8; } for (i=-4;i<(spx_int32_t)(st->oversample*st->filt_len+4);i++) st->sinc_table[i+4] = sinc(st->cutoff,(i/(float)st->oversample - st->filt_len/2), st->filt_len, quality_map[st->quality].window_func); #ifdef FIXED_POINT st->resampler_ptr = resampler_basic_interpolate_single; #else if (st->quality>8) st->resampler_ptr = resampler_basic_interpolate_double; else st->resampler_ptr = resampler_basic_interpolate_single; #endif /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff);*/ } st->int_advance = st->num_rate/st->den_rate; st->frac_advance = st->num_rate%st->den_rate; /* Here's the place where we update the filter memory to take into account the change in filter length. It's probably the messiest part of the code due to handling of lots of corner cases. */ if (!st->mem) { spx_uint32_t i; st->mem_alloc_size = st->filt_len-1 + st->buffer_size; st->mem = (spx_word16_t*)speex_alloc(st->nb_channels*st->mem_alloc_size * sizeof(spx_word16_t)); for (i=0;inb_channels*st->mem_alloc_size;i++) st->mem[i] = 0; /*speex_warning("init filter");*/ } else if (!st->started) { spx_uint32_t i; st->mem_alloc_size = st->filt_len-1 + st->buffer_size; st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*st->mem_alloc_size * sizeof(spx_word16_t)); for (i=0;inb_channels*st->mem_alloc_size;i++) st->mem[i] = 0; /*speex_warning("reinit filter");*/ } else if (st->filt_len > old_length) { spx_int32_t i; /* Increase the filter length */ /*speex_warning("increase filter size");*/ int old_alloc_size = st->mem_alloc_size; if ((st->filt_len-1 + st->buffer_size) > st->mem_alloc_size) { st->mem_alloc_size = st->filt_len-1 + st->buffer_size; st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*st->mem_alloc_size * sizeof(spx_word16_t)); } for (i=st->nb_channels-1;i>=0;i--) { spx_int32_t j; spx_uint32_t olen = old_length; /*if (st->magic_samples[i])*/ { /* Try and remove the magic samples as if nothing had happened */ /* FIXME: This is wrong but for now we need it to avoid going over the array bounds */ olen = old_length + 2*st->magic_samples[i]; for (j=old_length-2+st->magic_samples[i];j>=0;j--) st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]] = st->mem[i*old_alloc_size+j]; for (j=0;jmagic_samples[i];j++) st->mem[i*st->mem_alloc_size+j] = 0; st->magic_samples[i] = 0; } if (st->filt_len > olen) { /* If the new filter length is still bigger than the "augmented" length */ /* Copy data going backward */ for (j=0;jmem[i*st->mem_alloc_size+(st->filt_len-2-j)] = st->mem[i*st->mem_alloc_size+(olen-2-j)]; /* Then put zeros for lack of anything better */ for (;jfilt_len-1;j++) st->mem[i*st->mem_alloc_size+(st->filt_len-2-j)] = 0; /* Adjust last_sample */ st->last_sample[i] += (st->filt_len - olen)/2; } else { /* Put back some of the magic! */ st->magic_samples[i] = (olen - st->filt_len)/2; for (j=0;jfilt_len-1+st->magic_samples[i];j++) st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; } } } else if (st->filt_len < old_length) { spx_uint32_t i; /* Reduce filter length, this a bit tricky. We need to store some of the memory as "magic" samples so they can be used directly as input the next time(s) */ for (i=0;inb_channels;i++) { spx_uint32_t j; spx_uint32_t old_magic = st->magic_samples[i]; st->magic_samples[i] = (old_length - st->filt_len)/2; /* We must copy some of the memory that's no longer used */ /* Copy data going backward */ for (j=0;jfilt_len-1+st->magic_samples[i]+old_magic;j++) st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; st->magic_samples[i] += old_magic; } } } SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) { return speex_resampler_init_frac(nb_channels, in_rate, out_rate, in_rate, out_rate, quality, err); } SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) { spx_uint32_t i; SpeexResamplerState *st; if (quality > 10 || quality < 0) { if (err) *err = RESAMPLER_ERR_INVALID_ARG; return NULL; } st = (SpeexResamplerState *)speex_alloc(sizeof(SpeexResamplerState)); st->initialised = 0; st->started = 0; st->in_rate = 0; st->out_rate = 0; st->num_rate = 0; st->den_rate = 0; st->quality = -1; st->sinc_table_length = 0; st->mem_alloc_size = 0; st->filt_len = 0; st->mem = 0; st->resampler_ptr = 0; st->cutoff = 1.f; st->nb_channels = nb_channels; st->in_stride = 1; st->out_stride = 1; #ifdef FIXED_POINT st->buffer_size = 160; #else st->buffer_size = 160; #endif /* Per channel data */ st->last_sample = (spx_int32_t*)speex_alloc(nb_channels*sizeof(int)); st->magic_samples = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(int)); st->samp_frac_num = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(int)); for (i=0;ilast_sample[i] = 0; st->magic_samples[i] = 0; st->samp_frac_num[i] = 0; } speex_resampler_set_quality(st, quality); speex_resampler_set_rate_frac(st, ratio_num, ratio_den, in_rate, out_rate); update_filter(st); st->initialised = 1; if (err) *err = RESAMPLER_ERR_SUCCESS; return st; } void speex_resampler_destroy(SpeexResamplerState *st) { speex_free(st->mem); speex_free(st->sinc_table); speex_free(st->last_sample); speex_free(st->magic_samples); speex_free(st->samp_frac_num); speex_free(st); } static int speex_resampler_process_native(SpeexResamplerState *st, spx_uint32_t channel_index, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) { int j=0; const int N = st->filt_len; int out_sample = 0; spx_word16_t *mem = st->mem + channel_index * st->mem_alloc_size; spx_uint32_t ilen; st->started = 1; /* Call the right resampler through the function ptr */ out_sample = st->resampler_ptr(st, channel_index, mem, in_len, out, out_len); if (st->last_sample[channel_index] < (spx_int32_t)*in_len) *in_len = st->last_sample[channel_index]; *out_len = out_sample; st->last_sample[channel_index] -= *in_len; ilen = *in_len; for(j=0;jmagic_samples[channel_index]; spx_word16_t *mem = st->mem + channel_index * st->mem_alloc_size; const int N = st->filt_len; speex_resampler_process_native(st, channel_index, &tmp_in_len, *out, &out_len); st->magic_samples[channel_index] -= tmp_in_len; /* If we couldn't process all "magic" input samples, save the rest for next time */ if (st->magic_samples[channel_index]) { spx_uint32_t i; for (i=0;imagic_samples[channel_index];i++) mem[N-1+i]=mem[N-1+i+tmp_in_len]; } *out += out_len*st->out_stride; return out_len; } #ifdef FIXED_POINT int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) #else int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) #endif { int j; spx_uint32_t ilen = *in_len; spx_uint32_t olen = *out_len; spx_word16_t *x = st->mem + channel_index * st->mem_alloc_size; const int filt_offs = st->filt_len - 1; const spx_uint32_t xlen = st->mem_alloc_size - filt_offs; const int istride = st->in_stride; if (st->magic_samples[channel_index]) olen -= speex_resampler_magic(st, channel_index, &out, olen); if (! st->magic_samples[channel_index]) { while (ilen && olen) { spx_uint32_t ichunk = (ilen > xlen) ? xlen : ilen; spx_uint32_t ochunk = olen; if (in) { for(j=0;jout_stride; if (in) in += ichunk * istride; } } *in_len -= ilen; *out_len -= olen; return RESAMPLER_ERR_SUCCESS; } #ifdef FIXED_POINT int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) #else int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) #endif { int j; const int istride_save = st->in_stride; const int ostride_save = st->out_stride; spx_uint32_t ilen = *in_len; spx_uint32_t olen = *out_len; spx_word16_t *x = st->mem + channel_index * st->mem_alloc_size; const spx_uint32_t xlen = st->mem_alloc_size - (st->filt_len - 1); #ifdef VAR_ARRAYS const unsigned int ylen = (olen < FIXED_STACK_ALLOC) ? olen : FIXED_STACK_ALLOC; VARDECL(spx_word16_t *ystack); ALLOC(ystack, ylen, spx_word16_t); #else const unsigned int ylen = FIXED_STACK_ALLOC; spx_word16_t ystack[FIXED_STACK_ALLOC]; #endif st->out_stride = 1; while (ilen && olen) { spx_word16_t *y = ystack; spx_uint32_t ichunk = (ilen > xlen) ? xlen : ilen; spx_uint32_t ochunk = (olen > ylen) ? ylen : olen; spx_uint32_t omagic = 0; if (st->magic_samples[channel_index]) { omagic = speex_resampler_magic(st, channel_index, &y, ochunk); ochunk -= omagic; olen -= omagic; } if (! st->magic_samples[channel_index]) { if (in) { for(j=0;jfilt_len-1]=WORD2INT(in[j*istride_save]); #else x[j+st->filt_len-1]=in[j*istride_save]; #endif } else { for(j=0;jfilt_len-1]=0; } speex_resampler_process_native(st, channel_index, &ichunk, y, &ochunk); } else { ichunk = 0; ochunk = 0; } for (j=0;jout_stride = ostride_save; *in_len -= ilen; *out_len -= olen; return RESAMPLER_ERR_SUCCESS; } int speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) { spx_uint32_t i; int istride_save, ostride_save; spx_uint32_t bak_len = *out_len; istride_save = st->in_stride; ostride_save = st->out_stride; st->in_stride = st->out_stride = st->nb_channels; for (i=0;inb_channels;i++) { *out_len = bak_len; if (in != NULL) speex_resampler_process_float(st, i, in+i, in_len, out+i, out_len); else speex_resampler_process_float(st, i, NULL, in_len, out+i, out_len); } st->in_stride = istride_save; st->out_stride = ostride_save; return RESAMPLER_ERR_SUCCESS; } int speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) { spx_uint32_t i; int istride_save, ostride_save; spx_uint32_t bak_len = *out_len; istride_save = st->in_stride; ostride_save = st->out_stride; st->in_stride = st->out_stride = st->nb_channels; for (i=0;inb_channels;i++) { *out_len = bak_len; if (in != NULL) speex_resampler_process_int(st, i, in+i, in_len, out+i, out_len); else speex_resampler_process_int(st, i, NULL, in_len, out+i, out_len); } st->in_stride = istride_save; st->out_stride = ostride_save; return RESAMPLER_ERR_SUCCESS; } int speex_resampler_set_rate(SpeexResamplerState *st, spx_uint32_t in_rate, spx_uint32_t out_rate) { return speex_resampler_set_rate_frac(st, in_rate, out_rate, in_rate, out_rate); } void speex_resampler_get_rate(SpeexResamplerState *st, spx_uint32_t *in_rate, spx_uint32_t *out_rate) { *in_rate = st->in_rate; *out_rate = st->out_rate; } int speex_resampler_set_rate_frac(SpeexResamplerState *st, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate) { spx_uint32_t fact; spx_uint32_t old_den; spx_uint32_t i; if (st->in_rate == in_rate && st->out_rate == out_rate && st->num_rate == ratio_num && st->den_rate == ratio_den) return RESAMPLER_ERR_SUCCESS; old_den = st->den_rate; st->in_rate = in_rate; st->out_rate = out_rate; st->num_rate = ratio_num; st->den_rate = ratio_den; /* FIXME: This is terribly inefficient, but who cares (at least for now)? */ for (fact=2;fact<=IMIN(st->num_rate, st->den_rate);fact++) { while ((st->num_rate % fact == 0) && (st->den_rate % fact == 0)) { st->num_rate /= fact; st->den_rate /= fact; } } if (old_den > 0) { for (i=0;inb_channels;i++) { st->samp_frac_num[i]=st->samp_frac_num[i]*st->den_rate/old_den; /* Safety net */ if (st->samp_frac_num[i] >= st->den_rate) st->samp_frac_num[i] = st->den_rate-1; } } if (st->initialised) update_filter(st); return RESAMPLER_ERR_SUCCESS; } void speex_resampler_get_ratio(SpeexResamplerState *st, spx_uint32_t *ratio_num, spx_uint32_t *ratio_den) { *ratio_num = st->num_rate; *ratio_den = st->den_rate; } int speex_resampler_set_quality(SpeexResamplerState *st, int quality) { if (quality > 10 || quality < 0) return RESAMPLER_ERR_INVALID_ARG; if (st->quality == quality) return RESAMPLER_ERR_SUCCESS; st->quality = quality; if (st->initialised) update_filter(st); return RESAMPLER_ERR_SUCCESS; } void speex_resampler_get_quality(SpeexResamplerState *st, int *quality) { *quality = st->quality; } void speex_resampler_set_input_stride(SpeexResamplerState *st, spx_uint32_t stride) { st->in_stride = stride; } void speex_resampler_get_input_stride(SpeexResamplerState *st, spx_uint32_t *stride) { *stride = st->in_stride; } void speex_resampler_set_output_stride(SpeexResamplerState *st, spx_uint32_t stride) { st->out_stride = stride; } void speex_resampler_get_output_stride(SpeexResamplerState *st, spx_uint32_t *stride) { *stride = st->out_stride; } int speex_resampler_get_input_latency(SpeexResamplerState *st) { return st->filt_len / 2; } int speex_resampler_get_output_latency(SpeexResamplerState *st) { return ((st->filt_len / 2) * st->den_rate + (st->num_rate >> 1)) / st->num_rate; } int speex_resampler_skip_zeros(SpeexResamplerState *st) { spx_uint32_t i; for (i=0;inb_channels;i++) st->last_sample[i] = st->filt_len/2; return RESAMPLER_ERR_SUCCESS; } int speex_resampler_reset_mem(SpeexResamplerState *st) { spx_uint32_t i; for (i=0;inb_channels*(st->filt_len-1);i++) st->mem[i] = 0; return RESAMPLER_ERR_SUCCESS; } const char *speex_resampler_strerror(int err) { switch (err) { case RESAMPLER_ERR_SUCCESS: return "Success."; case RESAMPLER_ERR_ALLOC_FAILED: return "Memory allocation failed."; case RESAMPLER_ERR_BAD_STATE: return "Bad resampler state."; case RESAMPLER_ERR_INVALID_ARG: return "Invalid argument."; case RESAMPLER_ERR_PTR_OVERLAP: return "Input and output buffers overlap."; default: return "Unknown error. Bad error code or strange version mismatch."; } } asterisk-11.7.0/codecs/speex/speex_resampler.h0000644000175000007640000003456611531040421021305 0ustar sharkyjerryweb/* Copyright (C) 2007 Jean-Marc Valin File: speex_resampler.h Resampling code The design goals of this code are: - Very fast algorithm - Low memory requirement - Good *perceptual* quality (and not best SNR) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef SPEEX_RESAMPLER_H #define SPEEX_RESAMPLER_H #define OUTSIDE_SPEEX #ifdef OUTSIDE_SPEEX /********* WARNING: MENTAL SANITY ENDS HERE *************/ /* If the resampler is defined outside of Speex, we change the symbol names so that there won't be any clash if linking with Speex later on. */ #define RANDOM_PREFIX ast #ifndef RANDOM_PREFIX #error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes" #endif #define CAT_PREFIX2(a,b) a ## b #define CAT_PREFIX(a,b) CAT_PREFIX2(a, b) #define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init) #define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac) #define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy) #define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float) #define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int) #define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float) #define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int) #define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate) #define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate) #define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac) #define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio) #define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality) #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality) #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride) #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride) #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride) #define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency) #define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency) #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros) #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror) #define spx_int16_t short #define spx_int32_t int #define spx_uint16_t unsigned short #define spx_uint32_t unsigned int #else /* OUTSIDE_SPEEX */ #include "speex/speex_types.h" #endif /* OUTSIDE_SPEEX */ #ifdef __cplusplus extern "C" { #endif #define SPEEX_RESAMPLER_QUALITY_MAX 10 #define SPEEX_RESAMPLER_QUALITY_MIN 0 #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 #define SPEEX_RESAMPLER_QUALITY_VOIP 3 #define SPEEX_RESAMPLER_QUALITY_DESKTOP 5 enum { RESAMPLER_ERR_SUCCESS = 0, RESAMPLER_ERR_ALLOC_FAILED = 1, RESAMPLER_ERR_BAD_STATE = 2, RESAMPLER_ERR_INVALID_ARG = 3, RESAMPLER_ERR_PTR_OVERLAP = 4, RESAMPLER_ERR_MAX_ERROR }; struct SpeexResamplerState_; typedef struct SpeexResamplerState_ SpeexResamplerState; /** Create a new resampler with integer input and output rates. * @param nb_channels Number of channels to be processed * @param in_rate Input sampling rate (integer number of Hz). * @param out_rate Output sampling rate (integer number of Hz). * @param quality Resampling quality between 0 and 10, where 0 has poor quality * and 10 has very high quality. * @return Newly created resampler state * @retval NULL Error: not enough memory */ SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err); /** Create a new resampler with fractional input/output rates. The sampling * rate ratio is an arbitrary rational number with both the numerator and * denominator being 32-bit integers. * @param nb_channels Number of channels to be processed * @param ratio_num Numerator of the sampling rate ratio * @param ratio_den Denominator of the sampling rate ratio * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). * @param quality Resampling quality between 0 and 10, where 0 has poor quality * and 10 has very high quality. * @return Newly created resampler state * @retval NULL Error: not enough memory */ SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err); /** Destroy a resampler state. * @param st Resampler state */ void speex_resampler_destroy(SpeexResamplerState *st); /** Resample a float array. The input and output buffers must *not* overlap. * @param st Resampler state * @param channel_index Index of the channel to process for the multi-channel * base (0 otherwise) * @param in Input buffer * @param in_len Number of input samples in the input buffer. Returns the * number of samples processed * @param out Output buffer * @param out_len Size of the output buffer. Returns the number of samples written */ int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len); /** Resample an int array. The input and output buffers must *not* overlap. * @param st Resampler state * @param channel_index Index of the channel to process for the multi-channel * base (0 otherwise) * @param in Input buffer * @param in_len Number of input samples in the input buffer. Returns the number * of samples processed * @param out Output buffer * @param out_len Size of the output buffer. Returns the number of samples written */ int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len); /** Resample an interleaved float array. The input and output buffers must *not* overlap. * @param st Resampler state * @param in Input buffer * @param in_len Number of input samples in the input buffer. Returns the number * of samples processed. This is all per-channel. * @param out Output buffer * @param out_len Size of the output buffer. Returns the number of samples written. * This is all per-channel. */ int speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len); /** Resample an interleaved int array. The input and output buffers must *not* overlap. * @param st Resampler state * @param in Input buffer * @param in_len Number of input samples in the input buffer. Returns the number * of samples processed. This is all per-channel. * @param out Output buffer * @param out_len Size of the output buffer. Returns the number of samples written. * This is all per-channel. */ int speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len); /** Set (change) the input/output sampling rates (integer value). * @param st Resampler state * @param in_rate Input sampling rate (integer number of Hz). * @param out_rate Output sampling rate (integer number of Hz). */ int speex_resampler_set_rate(SpeexResamplerState *st, spx_uint32_t in_rate, spx_uint32_t out_rate); /** Get the current input/output sampling rates (integer value). * @param st Resampler state * @param in_rate Input sampling rate (integer number of Hz) copied. * @param out_rate Output sampling rate (integer number of Hz) copied. */ void speex_resampler_get_rate(SpeexResamplerState *st, spx_uint32_t *in_rate, spx_uint32_t *out_rate); /** Set (change) the input/output sampling rates and resampling ratio * (fractional values in Hz supported). * @param st Resampler state * @param ratio_num Numerator of the sampling rate ratio * @param ratio_den Denominator of the sampling rate ratio * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). */ int speex_resampler_set_rate_frac(SpeexResamplerState *st, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate); /** Get the current resampling ratio. This will be reduced to the least * common denominator. * @param st Resampler state * @param ratio_num Numerator of the sampling rate ratio copied * @param ratio_den Denominator of the sampling rate ratio copied */ void speex_resampler_get_ratio(SpeexResamplerState *st, spx_uint32_t *ratio_num, spx_uint32_t *ratio_den); /** Set (change) the conversion quality. * @param st Resampler state * @param quality Resampling quality between 0 and 10, where 0 has poor * quality and 10 has very high quality. */ int speex_resampler_set_quality(SpeexResamplerState *st, int quality); /** Get the conversion quality. * @param st Resampler state * @param quality Resampling quality between 0 and 10, where 0 has poor * quality and 10 has very high quality. */ void speex_resampler_get_quality(SpeexResamplerState *st, int *quality); /** Set (change) the input stride. * @param st Resampler state * @param stride Input stride */ void speex_resampler_set_input_stride(SpeexResamplerState *st, spx_uint32_t stride); /** Get the input stride. * @param st Resampler state * @param stride Input stride copied */ void speex_resampler_get_input_stride(SpeexResamplerState *st, spx_uint32_t *stride); /** Set (change) the output stride. * @param st Resampler state * @param stride Output stride */ void speex_resampler_set_output_stride(SpeexResamplerState *st, spx_uint32_t stride); /** Get the output stride. * @param st Resampler state copied * @param stride Output stride */ void speex_resampler_get_output_stride(SpeexResamplerState *st, spx_uint32_t *stride); /** Get the latency in input samples introduced by the resampler. * @param st Resampler state */ int speex_resampler_get_input_latency(SpeexResamplerState *st); /** Get the latency in output samples introduced by the resampler. * @param st Resampler state */ int speex_resampler_get_output_latency(SpeexResamplerState *st); /** Make sure that the first samples to go out of the resamplers don't have * leading zeros. This is only useful before starting to use a newly created * resampler. It is recommended to use that when resampling an audio file, as * it will generate a file with the same length. For real-time processing, * it is probably easier not to use this call (so that the output duration * is the same for the first frame). * @param st Resampler state */ int speex_resampler_skip_zeros(SpeexResamplerState *st); /** Reset a resampler so a new (unrelated) stream can be processed. * @param st Resampler state */ int speex_resampler_reset_mem(SpeexResamplerState *st); /** Returns the English meaning for an error code * @param err Error code * @return English string */ const char *speex_resampler_strerror(int err); #ifdef __cplusplus } #endif #endif asterisk-11.7.0/codecs/ex_g726.h0000644000175000007640000000142711522553062016144 0ustar sharkyjerryweb/*! \file * \brief 4-bit G.726 data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_g726[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static struct ast_frame *g726_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_g726), .samples = ARRAY_LEN(ex_g726) * 2, /* 2 samples per byte */ .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_g726, }; ast_format_set(&f.subclass.format, AST_FORMAT_G726, 0); return &f; } asterisk-11.7.0/codecs/log2comp.h0000644000175000007640000000266610770013337016513 0ustar sharkyjerryweb/*! \file * \brief log2comp.h - various base 2 log computation versions * * Asterisk -- A telephony toolkit for Linux. * * \author Alex Volkov * * Copyright (c) 2004 - 2005, Digium Inc. * * This program is free software, distributed under the terms of * the GNU General Public License * * Define WANT_ASM before including this file to use assembly * whenever possible */ #if defined(_MSC_VER) # define inline __inline #elif defined(__GNUC__) # define inline __inline__ #else # define inline #endif #if defined(WANT_ASM) && defined(_MSC_VER) && defined(_M_IX86) /* MS C Inline Asm */ # pragma warning( disable : 4035 ) static inline int ilog2(int val) { __asm { xor eax, eax dec eax bsr eax, val }} # pragma warning( default : 4035 ) #elif defined(WANT_ASM) && defined(__GNUC__) && (defined(__i386__) || defined(i386)) /* GNU Inline Asm */ static inline int ilog2(int val) { int a; __asm__ ("\ xorl %0, %0 ;\ decl %0 ;\ bsrl %1, %0 ;\ " : "=&r" (a) : "mr" (val) : "cc" ); return a; } #elif defined(WANT_ASM) && defined(__GNUC__) && defined(__powerpc__) static inline int ilog2(int val) { int a; __asm__ ("cntlzw %0,%1" : "=r" (a) : "r" (val) ); return 31-a; } #else /* no ASM for this compiler and/or platform */ /* rather slow base 2 log computation * Using looped shift. */ static inline int ilog2(int val) { int i; for (i = -1; val; ++i, val >>= 1) ; return (i); } #endif asterisk-11.7.0/codecs/gsm/0000755000175000007640000000000012254071136015374 5ustar sharkyjerrywebasterisk-11.7.0/codecs/gsm/libgsm.vcproj0000644000175000007640000001063310407614672020107 0ustar sharkyjerryweb asterisk-11.7.0/codecs/gsm/inc/0000755000175000007640000000000012254071136016145 5ustar sharkyjerrywebasterisk-11.7.0/codecs/gsm/inc/private.h0000644000175000007640000002023410773263432017777 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /*$Header$*/ #ifndef PRIVATE_H #define PRIVATE_H typedef short word; /* 16 bit signed int */ typedef long longword; /* 32 bit signed int */ typedef unsigned short uword; /* unsigned word */ typedef unsigned long ulongword; /* unsigned longword */ struct gsm_state { word dp0[ 280 ]; word z1; /* preprocessing.c, Offset_com. */ longword L_z2; /* Offset_com. */ int mp; /* Preemphasis */ word u[8]; /* short_term_aly_filter.c */ word LARpp[2][8]; /* */ word j; /* */ word ltp_cut; /* long_term.c, LTP crosscorr. */ word nrp; /* 40 */ /* long_term.c, synthesis */ word v[9]; /* short_term.c, synthesis */ word msr; /* decoder.c, Postprocessing */ char verbose; /* only used if !NDEBUG */ char fast; /* only used if FAST */ char wav_fmt; /* only used if WAV49 defined */ unsigned char frame_index; /* odd/even chaining */ unsigned char frame_chain; /* half-byte to carry forward */ }; #define MIN_WORD (-32767 - 1) #define MAX_WORD 32767 #define MIN_LONGWORD (-2147483647 - 1) #define MAX_LONGWORD 2147483647 #ifdef SASR /* flag: >> is a signed arithmetic shift right */ #undef SASR #define SASR(x, by) ((x) >> (by)) #else #define SASR(x, by) ((x) >= 0 ? (x) >> (by) : (~(-((x) + 1) >> (by)))) #endif /* SASR */ #include "proto.h" /* * Prototypes from add.c */ extern word gsm_mult P((word a, word b)); extern longword gsm_L_mult P((word a, word b)); extern word gsm_mult_r P((word a, word b)); extern word gsm_div P((word num, word denum)); extern word gsm_add P(( word a, word b )); extern longword gsm_L_add P(( longword a, longword b )); extern word gsm_sub P((word a, word b)); extern longword gsm_L_sub P((longword a, longword b)); extern word gsm_abs P((word a)); extern word gsm_norm P(( longword a )); extern longword gsm_L_asl P((longword a, int n)); extern word gsm_asl P((word a, int n)); extern longword gsm_L_asr P((longword a, int n)); extern word gsm_asr P((word a, int n)); /* * Inlined functions from add.h */ /* * #define GSM_MULT_R(a, b) (* word a, word b, !(a == b == MIN_WORD) *) \ * (0x0FFFF & SASR(((longword)(a) * (longword)(b) + 16384), 15)) */ #define GSM_MULT_R(a, b) /* word a, word b, !(a == b == MIN_WORD) */ \ (SASR( ((longword)(a) * (longword)(b) + 16384), 15 )) # define GSM_MULT(a,b) /* word a, word b, !(a == b == MIN_WORD) */ \ (SASR( ((longword)(a) * (longword)(b)), 15 )) # define GSM_L_MULT(a, b) /* word a, word b */ \ (((longword)(a) * (longword)(b)) << 1) #if defined(__GNUC__) && defined(__i386__) static __inline__ int GSM_L_ADD(int a, int b) { __asm__ __volatile__( "addl %2,%0; jno 0f; movl $0x7fffffff,%0; adcl $0,%0; 0:" : "=&r" (a) : "0" (a), "ir" (b) : "cc" ); return(a); } static __inline__ short GSM_ADD(short a, short b) { __asm__ __volatile__( "addw %2,%0; jno 0f; movw $0x7fff,%0; adcw $0,%0; 0:" : "=&r" (a) : "0" (a), "ir" (b) : "cc" ); return(a); } static __inline__ short GSM_SUB(short a, short b) { __asm__ __volatile__( "subw %2,%0; jno 0f; movw $0x7fff,%0; adcw $0,%0; 0:" : "=&r" (a) : "0" (a), "ir" (b) : "cc" ); return(a); } #else #ifdef WIN32 #define inline __inline #define __inline__ __inline #endif # define GSM_L_ADD(a, b) \ ( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \ : (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \ >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \ : ((b) <= 0 ? (a) + (b) \ : (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \ ? MAX_LONGWORD : utmp)) static inline word GSM_ADD(longword a, longword b) { register longword ltmp; ltmp = a + b; return (word)((ulongword) (ltmp - MIN_WORD) > MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp); }; static inline word GSM_SUB(longword a, longword b) { register longword ltmp; ltmp = a - b; return (word)(ltmp >= MAX_WORD ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp); }; #endif # define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a)) /* Use these if necessary: # define GSM_MULT_R(a, b) gsm_mult_r(a, b) # define GSM_MULT(a, b) gsm_mult(a, b) # define GSM_L_MULT(a, b) gsm_L_mult(a, b) # define GSM_L_ADD(a, b) gsm_L_add(a, b) # define GSM_ADD(a, b) gsm_add(a, b) # define GSM_SUB(a, b) gsm_sub(a, b) # define GSM_ABS(a) gsm_abs(a) */ /* * More prototypes from implementations.. */ extern void Gsm_Coder P(( struct gsm_state * S, word * s, /* [0..159] samples IN */ word * LARc, /* [0..7] LAR coefficients OUT */ word * Nc, /* [0..3] LTP lag OUT */ word * bc, /* [0..3] coded LTP gain OUT */ word * Mc, /* [0..3] RPE grid selection OUT */ word * xmaxc,/* [0..3] Coded maximum amplitude OUT */ word * xMc /* [13*4] normalized RPE samples OUT */)); extern void Gsm_Long_Term_Predictor P(( /* 4x for 160 samples */ struct gsm_state * S, word * d, /* [0..39] residual signal IN */ word * dp, /* [-120..-1] d' IN */ word * e, /* [0..40] OUT */ word * dpp, /* [0..40] OUT */ word * Nc, /* correlation lag OUT */ word * bc /* gain factor OUT */)); extern void Gsm_LPC_Analysis P(( struct gsm_state * S, word * s, /* 0..159 signals IN/OUT */ word * LARc)); /* 0..7 LARc's OUT */ extern void Gsm_Preprocess P(( struct gsm_state * S, word * s, word * so)); extern void Gsm_Encoding P(( struct gsm_state * S, word * e, word * ep, word * xmaxc, word * Mc, word * xMc)); extern void Gsm_Short_Term_Analysis_Filter P(( struct gsm_state * S, word * LARc, /* coded log area ratio [0..7] IN */ word * d /* st res. signal [0..159] IN/OUT */)); extern void Gsm_Decoder P(( struct gsm_state * S, word * LARcr, /* [0..7] IN */ word * Ncr, /* [0..3] IN */ word * bcr, /* [0..3] IN */ word * Mcr, /* [0..3] IN */ word * xmaxcr, /* [0..3] IN */ word * xMcr, /* [0..13*4] IN */ word * s)); /* [0..159] OUT */ extern void Gsm_Decoding P(( struct gsm_state * S, word xmaxcr, word Mcr, word * xMcr, /* [0..12] IN */ word * erp)); /* [0..39] OUT */ extern void Gsm_Long_Term_Synthesis_Filtering P(( struct gsm_state* S, word Ncr, word bcr, word * erp, /* [0..39] IN */ word * drp)); /* [-120..-1] IN, [0..40] OUT */ void Gsm_RPE_Decoding P(( struct gsm_state *S, word xmaxcr, word Mcr, word * xMcr, /* [0..12], 3 bits IN */ word * erp)); /* [0..39] OUT */ void Gsm_RPE_Encoding P(( struct gsm_state * S, word * e, /* -5..-1][0..39][40..44 IN/OUT */ word * xmaxc, /* OUT */ word * Mc, /* OUT */ word * xMc)); /* [0..12] OUT */ extern void Gsm_Short_Term_Synthesis_Filter P(( struct gsm_state * S, word * LARcr, /* log area ratios [0..7] IN */ word * drp, /* received d [0...39] IN */ word * s)); /* signal s [0..159] OUT */ extern void Gsm_Update_of_reconstructed_short_time_residual_signal P(( word * dpp, /* [0...39] IN */ word * ep, /* [0...39] IN */ word * dp)); /* [-120...-1] IN/OUT */ /* * Tables from table.c */ #ifndef GSM_TABLE_C extern word gsm_A[8], gsm_B[8], gsm_MIC[8], gsm_MAC[8]; extern word gsm_INVA[8]; extern word gsm_DLB[4], gsm_QLB[4]; extern word gsm_H[11]; extern word gsm_NRFAC[8]; extern word gsm_FAC[8]; #endif /* GSM_TABLE_C */ /* * Debugging */ #ifdef NDEBUG # define gsm_debug_words(a, b, c, d) /* nil */ # define gsm_debug_longwords(a, b, c, d) /* nil */ # define gsm_debug_word(a, b) /* nil */ # define gsm_debug_longword(a, b) /* nil */ #else /* !NDEBUG => DEBUG */ extern void gsm_debug_words P((char * name, int, int, word *)); extern void gsm_debug_longwords P((char * name, int, int, longword *)); extern void gsm_debug_longword P((char * name, longword)); extern void gsm_debug_word P((char * name, word)); #endif /* !NDEBUG */ #include "unproto.h" #endif /* PRIVATE_H */ asterisk-11.7.0/codecs/gsm/inc/config.h0000644000175000007640000000254310374426007017571 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /*$Header$*/ #ifndef CONFIG_H #define CONFIG_H #if 0 efine SIGHANDLER_T int /* signal handlers are void */ efine HAS_SYSV_SIGNAL 1 /* sigs not blocked/reset? */ #endif #define HAS_STDLIB_H 1 /* /usr/include/stdlib.h */ #if 0 efine HAS_LIMITS_H 1 /* /usr/include/limits.h */ #endif #define HAS_FCNTL_H 1 /* /usr/include/fcntl.h */ #if 0 efine HAS_ERRNO_DECL 1 /* errno.h declares errno */ #endif #define HAS_FSTAT 1 /* fstat syscall */ #define HAS_FCHMOD 1 /* fchmod syscall */ #define HAS_CHMOD 1 /* chmod syscall */ #define HAS_FCHOWN 1 /* fchown syscall */ #define HAS_CHOWN 1 /* chown syscall */ #if 0 efine HAS__FSETMODE 1 /* _fsetmode -- set file mode */ #endif #define HAS_STRING_H 1 /* /usr/include/string.h */ #if 0 efine HAS_STRINGS_H 1 /* /usr/include/strings.h */ #endif #define HAS_UNISTD_H 1 /* /usr/include/unistd.h */ #define HAS_UTIME 1 /* POSIX utime(path, times) */ #if 0 efine HAS_UTIMES 1 /* use utimes() syscall instead */ #endif #define HAS_UTIME_H 1 /* UTIME header file */ #if 0 efine HAS_UTIMBUF 1 /* struct utimbuf */ efine HAS_UTIMEUSEC 1 /* microseconds in utimbuf? */ #endif #endif /* CONFIG_H */ asterisk-11.7.0/codecs/gsm/inc/proto.h0000644000175000007640000000276610566122515017476 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /*$Header$*/ #ifndef PROTO_H #define PROTO_H #ifdef __cplusplus # define NeedFunctionPrototypes 1 #endif #ifdef __STDC__ # define NeedFunctionPrototypes 1 #endif #ifdef _NO_PROTO # undef NeedFunctionPrototypes #endif #undef P /* gnu stdio.h actually defines this... */ #undef P0 #undef P1 #undef P2 #undef P3 #undef P4 #undef P5 #undef P6 #undef P7 #undef P8 #if NeedFunctionPrototypes # define P( protos ) protos # define P0() (void) # define P1(x, a) (a) # define P2(x, a, b) (a, b) # define P3(x, a, b, c) (a, b, c) # define P4(x, a, b, c, d) (a, b, c, d) # define P5(x, a, b, c, d, e) (a, b, c, d, e) # define P6(x, a, b, c, d, e, f) (a, b, c, d, e, f) # define P7(x, a, b, c, d, e, f, g) (a, b, c, d, e, f, g) # define P8(x, a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g, h) #else /* !NeedFunctionPrototypes */ # define P( protos ) ( /* protos */ ) # define P0() () # define P1(x, a) x a; # define P2(x, a, b) x a; b; # define P3(x, a, b, c) x a; b; c; # define P4(x, a, b, c, d) x a; b; c; d; # define P5(x, a, b, c, d, e) x a; b; c; d; e; # define P6(x, a, b, c, d, e, f) x a; b; c; d; e; f; # define P7(x, a, b, c, d, e, f, g) x a; b; c; d; e; f; g; # define P8(x, a, b, c, d, e, f, g, h) x a; b; c; d; e; f; g; h; #endif /* !NeedFunctionPrototypes */ #endif /* PROTO_H */ asterisk-11.7.0/codecs/gsm/inc/gsm.h0000644000175000007640000000307410374426007017112 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /*$Header$*/ #ifndef GSM_H #define GSM_H #ifdef __cplusplus # define NeedFunctionPrototypes 1 #endif #if __STDC__ # define NeedFunctionPrototypes 1 #endif #ifdef _NO_PROTO # undef NeedFunctionPrototypes #endif #ifdef NeedFunctionPrototypes # include /* for FILE * */ #endif #undef GSM_P #if NeedFunctionPrototypes # define GSM_P( protos ) protos #else # define GSM_P( protos ) ( /* protos */ ) #endif /* * Interface */ typedef struct gsm_state * gsm; typedef short gsm_signal; /* signed 16 bit */ typedef unsigned char gsm_byte; typedef gsm_byte gsm_frame[33]; /* 33 * 8 bits */ #define GSM_MAGIC 0xD /* 13 kbit/s RPE-LTP */ #define GSM_PATCHLEVEL 10 #define GSM_MINOR 0 #define GSM_MAJOR 1 #define GSM_OPT_VERBOSE 1 #define GSM_OPT_FAST 2 #define GSM_OPT_LTP_CUT 3 #define GSM_OPT_WAV49 4 #define GSM_OPT_FRAME_INDEX 5 #define GSM_OPT_FRAME_CHAIN 6 extern gsm gsm_create GSM_P((void)); extern void gsm_destroy GSM_P((gsm)); extern int gsm_print GSM_P((FILE *, gsm, gsm_byte *)); extern int gsm_option GSM_P((gsm, int, int *)); extern void gsm_encode GSM_P((gsm, gsm_signal *, gsm_byte *)); extern int gsm_decode GSM_P((gsm, gsm_byte *, gsm_signal *)); extern int gsm_explode GSM_P((gsm, gsm_byte *, gsm_signal *)); extern void gsm_implode GSM_P((gsm, gsm_signal *, gsm_byte *)); #undef GSM_P #endif /* GSM_H */ asterisk-11.7.0/codecs/gsm/inc/unproto.h0000644000175000007640000000057710374426007020037 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /*$Header$*/ #ifdef PROTO_H /* sic */ #undef PROTO_H #undef P #undef P0 #undef P1 #undef P2 #undef P3 #undef P4 #undef P5 #undef P6 #undef P7 #undef P8 #endif /* PROTO_H */ asterisk-11.7.0/codecs/gsm/src/0000755000175000007640000000000012254071136016163 5ustar sharkyjerrywebasterisk-11.7.0/codecs/gsm/src/rpe.c0000644000175000007640000002543110374426007017124 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include #include #include "private.h" #include "gsm.h" #include "proto.h" /* 4.2.13 .. 4.2.17 RPE ENCODING SECTION */ /* 4.2.13 */ #ifdef K6OPT #include "k6opt.h" #else static void Weighting_filter P2((e, x), register word * e, /* signal [-5..0.39.44] IN */ word * x /* signal [0..39] OUT */ ) /* * The coefficients of the weighting filter are stored in a table * (see table 4.4). The following scaling is used: * * H[0..10] = integer( real_H[ 0..10] * 8192 ); */ { /* word wt[ 50 ]; */ register longword L_result; register int k /* , i */ ; /* Initialization of a temporary working array wt[0...49] */ /* for (k = 0; k <= 4; k++) wt[k] = 0; * for (k = 5; k <= 44; k++) wt[k] = *e++; * for (k = 45; k <= 49; k++) wt[k] = 0; * * (e[-5..-1] and e[40..44] are allocated by the caller, * are initially zero and are not written anywhere.) */ e -= 5; /* Compute the signal x[0..39] */ for (k = 0; k <= 39; k++) { L_result = 8192 >> 1; /* for (i = 0; i <= 10; i++) { * L_temp = GSM_L_MULT( wt[k+i], gsm_H[i] ); * L_result = GSM_L_ADD( L_result, L_temp ); * } */ #undef STEP #define STEP( i, H ) (e[ k + i ] * (longword)H) /* Every one of these multiplications is done twice -- * but I don't see an elegant way to optimize this. * Do you? */ #ifdef STUPID_COMPILER L_result += STEP( 0, -134 ) ; L_result += STEP( 1, -374 ) ; /* + STEP( 2, 0 ) */ L_result += STEP( 3, 2054 ) ; L_result += STEP( 4, 5741 ) ; L_result += STEP( 5, 8192 ) ; L_result += STEP( 6, 5741 ) ; L_result += STEP( 7, 2054 ) ; /* + STEP( 8, 0 ) */ L_result += STEP( 9, -374 ) ; L_result += STEP( 10, -134 ) ; #else L_result += STEP( 0, -134 ) + STEP( 1, -374 ) /* + STEP( 2, 0 ) */ + STEP( 3, 2054 ) + STEP( 4, 5741 ) + STEP( 5, 8192 ) + STEP( 6, 5741 ) + STEP( 7, 2054 ) /* + STEP( 8, 0 ) */ + STEP( 9, -374 ) + STEP(10, -134 ) ; #endif /* L_result = GSM_L_ADD( L_result, L_result ); (* scaling(x2) *) * L_result = GSM_L_ADD( L_result, L_result ); (* scaling(x4) *) * * x[k] = SASR( L_result, 16 ); */ /* 2 adds vs. >>16 => 14, minus one shift to compensate for * those we lost when replacing L_MULT by '*'. */ L_result = SASR( L_result, 13 ); x[k] = (word)( L_result < MIN_WORD ? MIN_WORD : (L_result > MAX_WORD ? MAX_WORD : L_result )); } } #endif /* K6OPT */ /* 4.2.14 */ static void RPE_grid_selection P3((x,xM,Mc_out), word * x, /* [0..39] IN */ word * xM, /* [0..12] OUT */ word * Mc_out /* OUT */ ) /* * The signal x[0..39] is used to select the RPE grid which is * represented by Mc. */ { /* register word temp1; */ register int /* m, */ i; register longword L_result, L_temp; longword EM; /* xxx should be L_EM? */ word Mc; longword L_common_0_3; EM = 0; Mc = 0; /* for (m = 0; m <= 3; m++) { * L_result = 0; * * * for (i = 0; i <= 12; i++) { * * temp1 = SASR( x[m + 3*i], 2 ); * * assert(temp1 != MIN_WORD); * * L_temp = GSM_L_MULT( temp1, temp1 ); * L_result = GSM_L_ADD( L_temp, L_result ); * } * * if (L_result > EM) { * Mc = m; * EM = L_result; * } * } */ #undef STEP #define STEP( m, i ) L_temp = SASR( x[m + 3 * i], 2 ); \ L_result += L_temp * L_temp; /* common part of 0 and 3 */ L_result = 0; STEP( 0, 1 ); STEP( 0, 2 ); STEP( 0, 3 ); STEP( 0, 4 ); STEP( 0, 5 ); STEP( 0, 6 ); STEP( 0, 7 ); STEP( 0, 8 ); STEP( 0, 9 ); STEP( 0, 10); STEP( 0, 11); STEP( 0, 12); L_common_0_3 = L_result; /* i = 0 */ STEP( 0, 0 ); L_result <<= 1; /* implicit in L_MULT */ EM = L_result; /* i = 1 */ L_result = 0; STEP( 1, 0 ); STEP( 1, 1 ); STEP( 1, 2 ); STEP( 1, 3 ); STEP( 1, 4 ); STEP( 1, 5 ); STEP( 1, 6 ); STEP( 1, 7 ); STEP( 1, 8 ); STEP( 1, 9 ); STEP( 1, 10); STEP( 1, 11); STEP( 1, 12); L_result <<= 1; if (L_result > EM) { Mc = 1; EM = L_result; } /* i = 2 */ L_result = 0; STEP( 2, 0 ); STEP( 2, 1 ); STEP( 2, 2 ); STEP( 2, 3 ); STEP( 2, 4 ); STEP( 2, 5 ); STEP( 2, 6 ); STEP( 2, 7 ); STEP( 2, 8 ); STEP( 2, 9 ); STEP( 2, 10); STEP( 2, 11); STEP( 2, 12); L_result <<= 1; if (L_result > EM) { Mc = 2; EM = L_result; } /* i = 3 */ L_result = L_common_0_3; STEP( 3, 12 ); L_result <<= 1; if (L_result > EM) { Mc = 3; EM = L_result; } /**/ /* Down-sampling by a factor 3 to get the selected xM[0..12] * RPE sequence. */ for (i = 0; i <= 12; i ++) xM[i] = x[Mc + 3*i]; *Mc_out = Mc; } /* 4.12.15 */ static void APCM_quantization_xmaxc_to_exp_mant P3((xmaxc,exp_out,mant_out), word xmaxc, /* IN */ word * exp_out, /* OUT */ word * mant_out ) /* OUT */ { word exp, mant; /* Compute exponent and mantissa of the decoded version of xmaxc */ exp = 0; if (xmaxc > 15) exp = SASR(xmaxc, 3) - 1; mant = xmaxc - (exp << 3); if (mant == 0) { exp = -4; mant = 7; } else { while (mant <= 7) { mant = mant << 1 | 1; exp--; } mant -= 8; } assert( exp >= -4 && exp <= 6 ); assert( mant >= 0 && mant <= 7 ); *exp_out = exp; *mant_out = mant; } static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out), word * xM, /* [0..12] IN */ word * xMc, /* [0..12] OUT */ word * mant_out, /* OUT */ word * exp_out, /* OUT */ word * xmaxc_out /* OUT */ ) { int i, itest; word xmax, xmaxc, temp, temp1, temp2; word exp, mant; /* Find the maximum absolute value xmax of xM[0..12]. */ xmax = 0; for (i = 0; i <= 12; i++) { temp = xM[i]; temp = GSM_ABS(temp); if (temp > xmax) xmax = temp; } /* Qantizing and coding of xmax to get xmaxc. */ exp = 0; temp = SASR( xmax, 9 ); itest = 0; for (i = 0; i <= 5; i++) { itest |= (temp <= 0); temp = SASR( temp, 1 ); assert(exp <= 5); if (itest == 0) exp++; /* exp = add (exp, 1) */ } assert(exp <= 6 && exp >= 0); temp = exp + 5; assert(temp <= 11 && temp >= 0); xmaxc = gsm_add( SASR(xmax, temp), exp << 3 ); /* Quantizing and coding of the xM[0..12] RPE sequence * to get the xMc[0..12] */ APCM_quantization_xmaxc_to_exp_mant( xmaxc, &exp, &mant ); /* This computation uses the fact that the decoded version of xmaxc * can be calculated by using the exponent and the mantissa part of * xmaxc (logarithmic table). * So, this method avoids any division and uses only a scaling * of the RPE samples by a function of the exponent. A direct * multiplication by the inverse of the mantissa (NRFAC[0..7] * found in table 4.5) gives the 3 bit coded version xMc[0..12] * of the RPE samples. */ /* Direct computation of xMc[0..12] using table 4.5 */ assert( exp <= 4096 && exp >= -4096); assert( mant >= 0 && mant <= 7 ); temp1 = 6 - exp; /* normalization by the exponent */ temp2 = gsm_NRFAC[ mant ]; /* inverse mantissa */ for (i = 0; i <= 12; i++) { assert(temp1 >= 0 && temp1 < 16); temp = xM[i] << temp1; temp = (word)GSM_MULT( temp, temp2 ); temp = SASR(temp, 12); xMc[i] = temp + 4; /* see note below */ } /* NOTE: This equation is used to make all the xMc[i] positive. */ *mant_out = mant; *exp_out = exp; *xmaxc_out = xmaxc; } /* 4.2.16 */ static void APCM_inverse_quantization P4((xMc,mant,exp,xMp), register word * xMc, /* [0..12] IN */ word mant, word exp, register word * xMp) /* [0..12] OUT */ /* * This part is for decoding the RPE sequence of coded xMc[0..12] * samples to obtain the xMp[0..12] array. Table 4.6 is used to get * the mantissa of xmaxc (FAC[0..7]). */ { int i; word temp, temp1, temp2, temp3; assert( mant >= 0 && mant <= 7 ); temp1 = gsm_FAC[ mant ]; /* see 4.2-15 for mant */ temp2 = gsm_sub( 6, exp ); /* see 4.2-15 for exp */ temp3 = gsm_asl( 1, gsm_sub( temp2, 1 )); for (i = 13; i--;) { assert( *xMc <= 7 && *xMc >= 0 ); /* 3 bit unsigned */ /* temp = gsm_sub( *xMc++ << 1, 7 ); */ temp = (*xMc++ << 1) - 7; /* restore sign */ assert( temp <= 7 && temp >= -7 ); /* 4 bit signed */ temp <<= 12; /* 16 bit signed */ temp = (word)GSM_MULT_R( temp1, temp ); temp = GSM_ADD( temp, temp3 ); *xMp++ = gsm_asr( temp, temp2 ); } } /* 4.2.17 */ static void RPE_grid_positioning P3((Mc,xMp,ep), word Mc, /* grid position IN */ register word * xMp, /* [0..12] IN */ register word * ep /* [0..39] OUT */ ) /* * This procedure computes the reconstructed long term residual signal * ep[0..39] for the LTP analysis filter. The inputs are the Mc * which is the grid position selection and the xMp[0..12] decoded * RPE samples which are upsampled by a factor of 3 by inserting zero * values. */ { int i = 13; assert(0 <= Mc && Mc <= 3); switch (Mc) { case 3: *ep++ = 0; case 2: do { *ep++ = 0; case 1: *ep++ = 0; case 0: *ep++ = *xMp++; } while (--i); } while (++Mc < 4) *ep++ = 0; /* int i, k; for (k = 0; k <= 39; k++) ep[k] = 0; for (i = 0; i <= 12; i++) { ep[ Mc + (3*i) ] = xMp[i]; } */ } /* 4.2.18 */ /* This procedure adds the reconstructed long term residual signal * ep[0..39] to the estimated signal dpp[0..39] from the long term * analysis filter to compute the reconstructed short term residual * signal dp[-40..-1]; also the reconstructed short term residual * array dp[-120..-41] is updated. */ #if 0 /* Has been inlined in code.c */ void Gsm_Update_of_reconstructed_short_time_residual_signal P3((dpp, ep, dp), word * dpp, /* [0...39] IN */ word * ep, /* [0...39] IN */ word * dp) /* [-120...-1] IN/OUT */ { int k; for (k = 0; k <= 79; k++) dp[ -120 + k ] = dp[ -80 + k ]; for (k = 0; k <= 39; k++) dp[ -40 + k ] = gsm_add( ep[k], dpp[k] ); } #endif /* Has been inlined in code.c */ void Gsm_RPE_Encoding P5((S,e,xmaxc,Mc,xMc), struct gsm_state * S, word * e, /* -5..-1][0..39][40..44 IN/OUT */ word * xmaxc, /* OUT */ word * Mc, /* OUT */ word * xMc) /* [0..12] OUT */ { word x[40]; word xM[13], xMp[13]; word mant, exp; Weighting_filter(e, x); RPE_grid_selection(x, xM, Mc); APCM_quantization( xM, xMc, &mant, &exp, xmaxc); APCM_inverse_quantization( xMc, mant, exp, xMp); RPE_grid_positioning( *Mc, xMp, e ); } void Gsm_RPE_Decoding P5((S, xmaxcr, Mcr, xMcr, erp), struct gsm_state * S, word xmaxcr, word Mcr, word * xMcr, /* [0..12], 3 bits IN */ word * erp /* [0..39] OUT */ ) { word exp, mant; word xMp[ 13 ]; APCM_quantization_xmaxc_to_exp_mant( xmaxcr, &exp, &mant ); APCM_inverse_quantization( xMcr, mant, exp, xMp ); RPE_grid_positioning( Mcr, xMp, erp ); } asterisk-11.7.0/codecs/gsm/src/add.c0000644000175000007640000001257110374426007017067 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ /* * See private.h for the more commonly used macro versions. */ #include #include #include "private.h" #include "gsm.h" #include "proto.h" #define saturate(x) \ ((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x)) word gsm_add P2((a,b), word a, word b) { longword sum = (longword)a + (longword)b; return (word)saturate(sum); } word gsm_sub P2((a,b), word a, word b) { longword diff = (longword)a - (longword)b; return (word)saturate(diff); } word gsm_mult P2((a,b), word a, word b) { if (a == MIN_WORD && b == MIN_WORD) return MAX_WORD; else return (word)SASR( (longword)a * (longword)b, 15 ); } word gsm_mult_r P2((a,b), word a, word b) { if (b == MIN_WORD && a == MIN_WORD) return MAX_WORD; else { longword prod = (longword)a * (longword)b + 16384; prod >>= 15; return (word)(prod & 0xFFFF); } } word gsm_abs P1((a), word a) { return a < 0 ? (a == MIN_WORD ? MAX_WORD : -a) : a; } longword gsm_L_mult P2((a,b),word a, word b) { assert( a != MIN_WORD || b != MIN_WORD ); return ((longword)a * (longword)b) << 1; } longword gsm_L_add P2((a,b), longword a, longword b) { if (a < 0) { if (b >= 0) return a + b; else { ulongword A = (ulongword)-(a + 1) + (ulongword)-(b + 1); return A >= MAX_LONGWORD ? MIN_LONGWORD :-(longword)A-2; } } else if (b <= 0) return a + b; else { ulongword A = (ulongword)a + (ulongword)b; return A > MAX_LONGWORD ? MAX_LONGWORD : A; } } longword gsm_L_sub P2((a,b), longword a, longword b) { if (a >= 0) { if (b >= 0) return a - b; else { /* a>=0, b<0 */ ulongword A = (ulongword)a + -(b + 1); return A >= MAX_LONGWORD ? MAX_LONGWORD : (A + 1); } } else if (b <= 0) return a - b; else { /* a<0, b>0 */ ulongword A = (ulongword)-(a + 1) + b; return A >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)A - 1; } } static unsigned char const bitoff[ 256 ] = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 }; word gsm_norm P1((a), longword a ) /* * the number of left shifts needed to normalize the 32 bit * variable L_var1 for positive values on the interval * * with minimum of * minimum of 1073741824 (01000000000000000000000000000000) and * maximum of 2147483647 (01111111111111111111111111111111) * * * and for negative values on the interval with * minimum of -2147483648 (-10000000000000000000000000000000) and * maximum of -1073741824 ( -1000000000000000000000000000000). * * in order to normalize the result, the following * operation must be done: L_norm_var1 = L_var1 << norm( L_var1 ); * * (That's 'ffs', only from the left, not the right..) */ { assert(a != 0); if (a < 0) { if (a <= -1073741824) return 0; a = ~a; } return a & 0xffff0000 ? ( a & 0xff000000 ? -1 + bitoff[ 0xFF & (a >> 24) ] : 7 + bitoff[ 0xFF & (a >> 16) ] ) : ( a & 0xff00 ? 15 + bitoff[ 0xFF & (a >> 8) ] : 23 + bitoff[ 0xFF & a ] ); } longword gsm_L_asl P2((a,n), longword a, int n) { if (n >= 32) return 0; if (n <= -32) return -(a < 0); if (n < 0) return gsm_L_asr(a, -n); return a << n; } word gsm_asl P2((a,n), word a, int n) { if (n >= 16) return 0; if (n <= -16) return -(a < 0); if (n < 0) return gsm_asr(a, -n); return a << n; } longword gsm_L_asr P2((a,n), longword a, int n) { if (n >= 32) return -(a < 0); if (n <= -32) return 0; if (n < 0) return a << -n; # ifdef SASR return a >> n; # else if (a >= 0) return a >> n; else return -(longword)( -(ulongword)a >> n ); # endif } word gsm_asr P2((a,n), word a, int n) { if (n >= 16) return -(a < 0); if (n <= -16) return 0; if (n < 0) return a << -n; # ifdef SASR return a >> n; # else if (a >= 0) return a >> n; else return -(word)( -(uword)a >> n ); # endif } /* * (From p. 46, end of section 4.2.5) * * NOTE: The following lines gives [sic] one correct implementation * of the div(num, denum) arithmetic operation. Compute div * which is the integer division of num by denum: with denum * >= num > 0 */ word gsm_div P2((num,denum), word num, word denum) { longword L_num = num; longword L_denum = denum; word div = 0; int k = 15; /* The parameter num sometimes becomes zero. * Although this is explicitly guarded against in 4.2.5, * we assume that the result should then be zero as well. */ /* assert(num != 0); */ assert(num >= 0 && denum >= num); if (num == 0) return 0; while (k--) { div <<= 1; L_num <<= 1; if (L_num >= L_denum) { L_num -= L_denum; div++; } } return div; } asterisk-11.7.0/codecs/gsm/src/code.c0000644000175000007640000000462112041300312017225 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "config.h" #ifdef HAS_STRING_H #include #else # include "proto.h" extern char * memcpy P((char *, char *, int)); #endif #include "private.h" #include "gsm.h" #include "proto.h" /* * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER */ void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc), struct gsm_state * S, word * s, /* [0..159] samples IN */ /* * The RPE-LTD coder works on a frame by frame basis. The length of * the frame is equal to 160 samples. Some computations are done * once per frame to produce at the output of the coder the * LARc[1..8] parameters which are the coded LAR coefficients and * also to realize the inverse filtering operation for the entire * frame (160 samples of signal d[0..159]). These parts produce at * the output of the coder: */ word * LARc, /* [0..7] LAR coefficients OUT */ /* * Procedure 4.2.11 to 4.2.18 are to be executed four times per * frame. That means once for each sub-segment RPE-LTP analysis of * 40 samples. These parts produce at the output of the coder: */ word * Nc, /* [0..3] LTP lag OUT */ word * bc, /* [0..3] coded LTP gain OUT */ word * Mc, /* [0..3] RPE grid selection OUT */ word * xmaxc,/* [0..3] Coded maximum amplitude OUT */ word * xMc /* [13*4] normalized RPE samples OUT */ ) { int k; word * dp = S->dp0 + 120; /* [ -120...-1 ] */ word * dpp = dp; /* [ 0...39 ] */ word e[50]; word so[160]; memset(e,0,sizeof e); Gsm_Preprocess (S, s, so); Gsm_LPC_Analysis (S, so, LARc); Gsm_Short_Term_Analysis_Filter (S, LARc, so); for (k = 0; k <= 3; k++, xMc += 13) { Gsm_Long_Term_Predictor ( S, so+k*40, /* d [0..39] IN */ dp, /* dp [-120..-1] IN */ e + 5, /* e [0..39] OUT */ dpp, /* dpp [0..39] OUT */ Nc++, bc++); Gsm_RPE_Encoding ( S, e + 5, /* e ][0..39][ IN/OUT */ xmaxc++, Mc++, xMc ); /* * Gsm_Update_of_reconstructed_short_time_residual_signal * ( dpp, e + 5, dp ); */ { register int i; for (i = 0; i <= 39; i++) dp[ i ] = GSM_ADD( e[5 + i], dpp[i] ); } dp += 40; dpp += 40; } (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160), 120 * sizeof(*S->dp0) ); } asterisk-11.7.0/codecs/gsm/src/k6opt.h0000644000175000007640000000377210374426007017412 0ustar sharkyjerryweb/* k6opt.h vector functions optimized for MMX extensions to x86 * * Copyright (C) 1999 by Stanley J. Brooks * * Any use of this software is permitted provided that this notice is not * removed and that neither the authors nor the Technische Universitaet Berlin * are deemed to have made any representations as to the suitability of this * software for any purpose nor are held responsible for any defects of * this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE; * not even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. * * Chicago, 03.12.1999 * Stanley J. Brooks */ extern void Weighting_filter P2((e, x), const word * e, /* signal [-5..0.39.44] IN */ word * x /* signal [0..39] OUT */ ) ; extern longword k6maxcc P3((wt,dp,Nc_out), const word *wt, const word *dp, word * Nc_out /* OUT */ ) ; /* * k6maxmin(p,n,out[]) * input p[n] is array of shorts (require n>0) * returns (long) maximum absolute value.. * if out!=NULL, also returns out[0] the maximum and out[1] the minimum */ extern longword k6maxmin P3((p,n,out), const word *p, int n, word *out /* out[0] is max, out[1] is min */ ) ; extern longword k6iprod P3((p,q,n), const word *p, const word *q, int n ) ; /* * k6vsraw(p,n,bits) * input p[n] is array of shorts (require n>0) * shift/round each to the right by bits>=0 bits. */ extern void k6vsraw P3((p,n,bits), const word *p, int n, int bits ) ; /* * k6vsllw(p,n,bits) * input p[n] is array of shorts (require n>0) * shift each to the left by bits>=0 bits. */ extern void k6vsllw P3((p,n,bits), const word *p, int n, int bits ) ; #if 1 /* there isn't any significant speed gain from mmx here: */ extern void Short_term_analysis_filteringx P4((u0,rp0,k_n,s), register word * u0, register word * rp0, /* [0..7] IN */ register int k_n, /* k_end - k_start */ register word * s /* [0..n-1] IN/OUT */ ) ; /* #define Short_term_analysis_filtering Short_term_analysis_filteringx */ #endif asterisk-11.7.0/codecs/gsm/src/gsm_create.c0000644000175000007640000000137410374426007020447 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ static char const ident[] = "$Header$"; #include "config.h" #ifdef HAS_STRING_H #include #else # include "proto.h" extern char * memset P((char *, int, int)); #endif #ifdef HAS_STDLIB_H # include #else # ifdef HAS_MALLOC_H # include # else extern char * malloc(); # endif #endif #include #include "gsm.h" #include "private.h" #include "proto.h" gsm gsm_create P0() { gsm r; r = (gsm)malloc(sizeof(struct gsm_state)); if (!r) return r; memset((char *)r, 0, sizeof(*r)); r->nrp = 40; return r; } asterisk-11.7.0/codecs/gsm/src/gsm_option.c0000644000175000007640000000213110374426007020504 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "private.h" #include "gsm.h" #include "proto.h" int gsm_option P3((r, opt, val), gsm r, int opt, int * val) { int result = -1; switch (opt) { case GSM_OPT_LTP_CUT: #ifdef LTP_CUT result = r->ltp_cut; if (val) r->ltp_cut = *val; #endif break; case GSM_OPT_VERBOSE: #ifndef NDEBUG result = r->verbose; if (val) r->verbose = *val; #endif break; case GSM_OPT_FAST: #if defined(FAST) && defined(USE_FLOAT_MUL) result = r->fast; if (val) r->fast = !!*val; #endif break; case GSM_OPT_FRAME_CHAIN: #ifdef WAV49 result = r->frame_chain; if (val) r->frame_chain = *val; #endif break; case GSM_OPT_FRAME_INDEX: #ifdef WAV49 result = r->frame_index; if (val) r->frame_index = *val; #endif break; case GSM_OPT_WAV49: #ifdef WAV49 result = r->wav_fmt; if (val) r->wav_fmt = !!*val; #endif break; default: break; } return result; } asterisk-11.7.0/codecs/gsm/src/short_term.c0000644000175000007640000002565210374426007020531 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include #include #include "private.h" #include "gsm.h" #include "proto.h" #ifdef K6OPT #include "k6opt.h" #define Short_term_analysis_filtering Short_term_analysis_filteringx #endif /* * SHORT TERM ANALYSIS FILTERING SECTION */ /* 4.2.8 */ static void Decoding_of_the_coded_Log_Area_Ratios P2((LARc,LARpp), word * LARc, /* coded log area ratio [0..7] IN */ word * LARpp) /* out: decoded .. */ { register word temp1 /* , temp2 */; /* This procedure requires for efficient implementation * two tables. * * INVA[1..8] = integer( (32768 * 8) / real_A[1..8]) * MIC[1..8] = minimum value of the LARc[1..8] */ /* Compute the LARpp[1..8] */ /* for (i = 1; i <= 8; i++, B++, MIC++, INVA++, LARc++, LARpp++) { * * temp1 = GSM_ADD( *LARc, *MIC ) << 10; * temp2 = *B << 1; * temp1 = GSM_SUB( temp1, temp2 ); * * assert(*INVA != MIN_WORD); * * temp1 = GSM_MULT_R( *INVA, temp1 ); * *LARpp = GSM_ADD( temp1, temp1 ); * } */ #undef STEP #define STEP( B, MIC, INVA ) \ temp1 = GSM_ADD( *LARc++, MIC ) << 10; \ temp1 = GSM_SUB( temp1, B << 1 ); \ temp1 = (word)GSM_MULT_R( INVA, temp1 ); \ *LARpp++ = GSM_ADD( temp1, temp1 ); STEP( 0, -32, 13107 ); STEP( 0, -32, 13107 ); STEP( 2048, -16, 13107 ); STEP( -2560, -16, 13107 ); STEP( 94, -8, 19223 ); STEP( -1792, -8, 17476 ); STEP( -341, -4, 31454 ); STEP( -1144, -4, 29708 ); /* NOTE: the addition of *MIC is used to restore * the sign of *LARc. */ } /* 4.2.9 */ /* Computation of the quantized reflection coefficients */ /* 4.2.9.1 Interpolation of the LARpp[1..8] to get the LARp[1..8] */ /* * Within each frame of 160 analyzed speech samples the short term * analysis and synthesis filters operate with four different sets of * coefficients, derived from the previous set of decoded LARs(LARpp(j-1)) * and the actual set of decoded LARs (LARpp(j)) * * (Initial value: LARpp(j-1)[1..8] = 0.) */ static void Coefficients_0_12 P3((LARpp_j_1, LARpp_j, LARp), register word * LARpp_j_1, register word * LARpp_j, register word * LARp) { register int i; for (i = 1; i <= 8; i++, LARp++, LARpp_j_1++, LARpp_j++) { *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 )); *LARp = GSM_ADD( *LARp, SASR( *LARpp_j_1, 1)); } } static void Coefficients_13_26 P3((LARpp_j_1, LARpp_j, LARp), register word * LARpp_j_1, register word * LARpp_j, register word * LARp) { register int i; for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) { *LARp = GSM_ADD( SASR( *LARpp_j_1, 1), SASR( *LARpp_j, 1 )); } } static void Coefficients_27_39 P3((LARpp_j_1, LARpp_j, LARp), register word * LARpp_j_1, register word * LARpp_j, register word * LARp) { register int i; for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) { *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 )); *LARp = GSM_ADD( *LARp, SASR( *LARpp_j, 1 )); } } static void Coefficients_40_159 P2((LARpp_j, LARp), register word * LARpp_j, register word * LARp) { register int i; for (i = 1; i <= 8; i++, LARp++, LARpp_j++) *LARp = *LARpp_j; } /* 4.2.9.2 */ static void LARp_to_rp P1((LARp), register word * LARp) /* [0..7] IN/OUT */ /* * The input of this procedure is the interpolated LARp[0..7] array. * The reflection coefficients, rp[i], are used in the analysis * filter and in the synthesis filter. */ { register int i; register word temp; for (i = 1; i <= 8; i++, LARp++) { /* temp = GSM_ABS( *LARp ); * * if (temp < 11059) temp <<= 1; * else if (temp < 20070) temp += 11059; * else temp = GSM_ADD( temp >> 2, 26112 ); * * *LARp = *LARp < 0 ? -temp : temp; */ if (*LARp < 0) { temp = *LARp == MIN_WORD ? MAX_WORD : -(*LARp); *LARp = - ((temp < 11059) ? temp << 1 : ((temp < 20070) ? temp + 11059 : GSM_ADD( temp >> 2, 26112 ))); } else { temp = *LARp; *LARp = (temp < 11059) ? temp << 1 : ((temp < 20070) ? temp + 11059 : GSM_ADD( temp >> 2, 26112 )); } } } /* 4.2.10 */ #ifndef Short_term_analysis_filtering /* SJB Remark: * I tried 2 MMX versions of this function, neither is significantly * faster than the C version which follows. MMX might be useful if * one were processing 2 input streams in parallel. */ static void Short_term_analysis_filtering P4((u0,rp0,k_n,s), register word * u0, register word * rp0, /* [0..7] IN */ register int k_n, /* k_end - k_start */ register word * s /* [0..n-1] IN/OUT */ ) /* * This procedure computes the short term residual signal d[..] to be fed * to the RPE-LTP loop from the s[..] signal and from the local rp[..] * array (quantized reflection coefficients). As the call of this * procedure can be done in many ways (see the interpolation of the LAR * coefficient), it is assumed that the computation begins with index * k_start (for arrays d[..] and s[..]) and stops with index k_end * (k_start and k_end are defined in 4.2.9.1). This procedure also * needs to keep the array u0[0..7] in memory for each call. */ { register word * u_top = u0 + 8; register word * s_top = s + k_n; while (s < s_top) { register word *u, *rp ; register longword di, u_out; di = u_out = *s; for (rp=rp0, u=u0; u>15); di = di + (((rpi*ui)+0x4000)>>15); /* make the common case fastest: */ if ((u_out == (word)u_out) && (di == (word)di)) continue; /* otherwise do slower fixup (saturation) */ if (u_out>MAX_WORD) u_out=MAX_WORD; else if (u_outMAX_WORD) di=MAX_WORD; else if (div; register int i; register longword sri; while (k--) { sri = *wt++; for (i = 8; i--;) { register longword tmp1, tmp2; /* sri = GSM_SUB( sri, gsm_mult_r( rrp[i], v[i] ) ); */ tmp1 = rrp[i]; tmp2 = v[i]; tmp2 = (( tmp1 * tmp2 + 16384) >> 15) ; /* saturation done below */ sri -= tmp2; if (sri != (word)sri) { sri = (sri<0)? MIN_WORD:MAX_WORD; } /* v[i+1] = GSM_ADD( v[i], gsm_mult_r( rrp[i], sri ) ); */ tmp1 = (( tmp1 * sri + 16384) >> 15) ; /* saturation done below */ tmp1 += v[i]; if (tmp1 != (word)tmp1) { tmp1 = (tmp1<0)? MIN_WORD:MAX_WORD; } v[i+1] = (word)tmp1; } *sr++ = v[0] = (word)sri; } } #if defined(FAST) && defined(USE_FLOAT_MUL) static void Fast_Short_term_synthesis_filtering P5((S,rrp,k,wt,sr), struct gsm_state * S, register word * rrp, /* [0..7] IN */ register int k, /* k_end - k_start */ register word * wt, /* [0..k-1] IN */ register word * sr /* [0..k-1] OUT */ ) { register word * v = S->v; register int i; float va[9], rrpa[8]; register float scalef = 3.0517578125e-5, temp; for (i = 0; i < 8; ++i) { va[i] = v[i]; rrpa[i] = (float)rrp[i] * scalef; } while (k--) { register float sri = *wt++; for (i = 8; i--;) { sri -= rrpa[i] * va[i]; if (sri < -32768.) sri = -32768.; else if (sri > 32767.) sri = 32767.; temp = va[i] + rrpa[i] * sri; if (temp < -32768.) temp = -32768.; else if (temp > 32767.) temp = 32767.; va[i+1] = temp; } *sr++ = va[0] = sri; } for (i = 0; i < 9; ++i) v[i] = va[i]; } #endif /* defined(FAST) && defined(USE_FLOAT_MUL) */ void Gsm_Short_Term_Analysis_Filter P3((S,LARc,s), struct gsm_state * S, word * LARc, /* coded log area ratio [0..7] IN */ word * s /* signal [0..159] IN/OUT */ ) { word * LARpp_j = S->LARpp[ S->j ]; word * LARpp_j_1 = S->LARpp[ S->j ^= 1 ]; word LARp[8]; #undef FILTER #if defined(FAST) && defined(USE_FLOAT_MUL) # define FILTER (* (S->fast \ ? Fast_Short_term_analysis_filtering \ : Short_term_analysis_filtering )) #else # define FILTER Short_term_analysis_filtering #endif Decoding_of_the_coded_Log_Area_Ratios( LARc, LARpp_j ); Coefficients_0_12( LARpp_j_1, LARpp_j, LARp ); LARp_to_rp( LARp ); FILTER( S->u, LARp, 13, s); Coefficients_13_26( LARpp_j_1, LARpp_j, LARp); LARp_to_rp( LARp ); FILTER( S->u, LARp, 14, s + 13); Coefficients_27_39( LARpp_j_1, LARpp_j, LARp); LARp_to_rp( LARp ); FILTER( S->u, LARp, 13, s + 27); Coefficients_40_159( LARpp_j, LARp); LARp_to_rp( LARp ); FILTER( S->u, LARp, 120, s + 40); } void Gsm_Short_Term_Synthesis_Filter P4((S, LARcr, wt, s), struct gsm_state * S, word * LARcr, /* received log area ratios [0..7] IN */ word * wt, /* received d [0..159] IN */ word * s /* signal s [0..159] OUT */ ) { word * LARpp_j = S->LARpp[ S->j ]; word * LARpp_j_1 = S->LARpp[ S->j ^=1 ]; word LARp[8]; #undef FILTER #if defined(FAST) && defined(USE_FLOAT_MUL) # define FILTER (* (S->fast \ ? Fast_Short_term_synthesis_filtering \ : Short_term_synthesis_filtering )) #else # define FILTER Short_term_synthesis_filtering #endif Decoding_of_the_coded_Log_Area_Ratios( LARcr, LARpp_j ); Coefficients_0_12( LARpp_j_1, LARpp_j, LARp ); LARp_to_rp( LARp ); FILTER( S, LARp, 13, wt, s ); Coefficients_13_26( LARpp_j_1, LARpp_j, LARp); LARp_to_rp( LARp ); FILTER( S, LARp, 14, wt + 13, s + 13 ); Coefficients_27_39( LARpp_j_1, LARpp_j, LARp); LARp_to_rp( LARp ); FILTER( S, LARp, 13, wt + 27, s + 27 ); Coefficients_40_159( LARpp_j, LARp ); LARp_to_rp( LARp ); FILTER(S, LARp, 120, wt + 40, s + 40); } asterisk-11.7.0/codecs/gsm/src/lpc.c0000644000175000007640000001642510671606023017115 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include #include #include "private.h" #include "gsm.h" #include "proto.h" #ifdef K6OPT #include "k6opt.h" #endif #undef P /* * 4.2.4 .. 4.2.7 LPC ANALYSIS SECTION */ /* 4.2.4 */ static void Autocorrelation P2((s, L_ACF), word * s, /* [0..159] IN/OUT */ longword * L_ACF) /* [0..8] OUT */ /* * The goal is to compute the array L_ACF[k]. The signal s[i] must * be scaled in order to avoid an overflow situation. */ { #ifndef K6OPT register int k, i; word temp; #endif word smax, scalauto; #ifdef USE_FLOAT_MUL float float_s[160]; #endif /* Dynamic scaling of the array s[0..159] */ /* Search for the maximum. */ #ifndef K6OPT smax = 0; for (k = 0; k <= 159; k++) { temp = GSM_ABS( s[k] ); if (temp > smax) smax = temp; } #else { longword lmax; lmax = k6maxmin(s,160,NULL); smax = (lmax > MAX_WORD) ? MAX_WORD : lmax; } #endif /* Computation of the scaling factor. */ if (smax == 0) scalauto = 0; else { assert(smax > 0); scalauto = 4 - gsm_norm( (longword)smax << 16 );/* sub(4,..) */ } /* Scaling of the array s[0...159] */ if (scalauto > 0) { # ifndef K6OPT # ifdef USE_FLOAT_MUL # define SCALE(n) \ case n: for (k = 0; k <= 159; k++) \ float_s[k] = (float) \ (s[k] = GSM_MULT_R(s[k], 16384 >> (n-1)));\ break; # else # define SCALE(n) \ case n: for (k = 0; k <= 159; k++) \ s[k] = (word)GSM_MULT_R( s[k], 16384 >> (n-1) );\ break; # endif /* USE_FLOAT_MUL */ switch (scalauto) { SCALE(1) SCALE(2) SCALE(3) SCALE(4) } # undef SCALE # else /* K6OPT */ k6vsraw(s,160,scalauto); # endif } # ifdef USE_FLOAT_MUL else for (k = 0; k <= 159; k++) float_s[k] = (float) s[k]; # endif /* Compute the L_ACF[..]. */ #ifndef K6OPT { # ifdef USE_FLOAT_MUL register float * sp = float_s; register float sl = *sp; # define STEP(k) L_ACF[k] += (longword)(sl * sp[ -(k) ]); # else word * sp = s; word sl = *sp; # define STEP(k) L_ACF[k] += ((longword)sl * sp[ -(k) ]); # endif # define NEXTI sl = *++sp for (k = 9; k--; L_ACF[k] = 0) ; STEP (0); NEXTI; STEP(0); STEP(1); NEXTI; STEP(0); STEP(1); STEP(2); NEXTI; STEP(0); STEP(1); STEP(2); STEP(3); NEXTI; STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); NEXTI; STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); STEP(5); NEXTI; STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); STEP(5); STEP(6); NEXTI; STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); STEP(5); STEP(6); STEP(7); for (i = 8; i <= 159; i++) { NEXTI; STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); STEP(5); STEP(6); STEP(7); STEP(8); } for (k = 9; k--; L_ACF[k] <<= 1) ; } #else { int k; for (k=0; k<9; k++) { L_ACF[k] = 2*k6iprod(s,s+k,160-k); } } #endif /* Rescaling of the array s[0..159] */ if (scalauto > 0) { assert(scalauto <= 4); #ifndef K6OPT for (k = 160; k--; *s++ <<= scalauto) ; # else /* K6OPT */ k6vsllw(s,160,scalauto); # endif } } #if defined(USE_FLOAT_MUL) && defined(FAST) static void Fast_Autocorrelation P2((s, L_ACF), word * s, /* [0..159] IN/OUT */ longword * L_ACF) /* [0..8] OUT */ { register int k, i; float f_L_ACF[9]; float scale; float s_f[160]; register float *sf = s_f; for (i = 0; i < 160; ++i) sf[i] = s[i]; for (k = 0; k <= 8; k++) { register float L_temp2 = 0; register float *sfl = sf - k; for (i = k; i < 160; ++i) L_temp2 += sf[i] * sfl[i]; f_L_ACF[k] = L_temp2; } scale = MAX_LONGWORD / f_L_ACF[0]; for (k = 0; k <= 8; k++) { L_ACF[k] = f_L_ACF[k] * scale; } } #endif /* defined (USE_FLOAT_MUL) && defined (FAST) */ /* 4.2.5 */ static void Reflection_coefficients P2( (L_ACF, r), longword * L_ACF, /* 0...8 IN */ register word * r /* 0...7 OUT */ ) { register int i, m, n; register word temp; word ACF[9]; /* 0..8 */ word P[ 9]; /* 0..8 */ word K[ 9]; /* 2..8 */ /* Schur recursion with 16 bits arithmetic. */ if (L_ACF[0] == 0) { for (i = 8; i--; *r++ = 0) ; return; } assert( L_ACF[0] != 0 ); temp = gsm_norm( L_ACF[0] ); assert(temp >= 0 && temp < 32); /* ? overflow ? */ for (i = 0; i <= 8; i++) ACF[i] = (word)SASR( L_ACF[i] << temp, 16 ); /* Initialize array P[..] and K[..] for the recursion. */ for (i = 1; i <= 7; i++) K[ i ] = ACF[ i ]; for (i = 0; i <= 8; i++) P[ i ] = ACF[ i ]; /* Compute reflection coefficients */ for (n = 1; n <= 8; n++, r++) { temp = P[1]; temp = GSM_ABS(temp); if (P[0] < temp) { for (i = n; i <= 8; i++) *r++ = 0; return; } *r = gsm_div( temp, P[0] ); assert(*r >= 0); if (P[1] > 0) *r = -*r; /* r[n] = sub(0, r[n]) */ assert (*r != MIN_WORD); if (n == 8) return; /* Schur recursion */ temp = (word)GSM_MULT_R( P[1], *r ); P[0] = GSM_ADD( P[0], temp ); for (m = 1; m <= 8 - n; m++) { temp = (word)GSM_MULT_R( K[ m ], *r ); P[m] = GSM_ADD( P[ m+1 ], temp ); temp = (word)GSM_MULT_R( P[ m+1 ], *r ); K[m] = GSM_ADD( K[ m ], temp ); } } } /* 4.2.6 */ static void Transformation_to_Log_Area_Ratios P1((r), register word * r /* 0..7 IN/OUT */ ) /* * The following scaling for r[..] and LAR[..] has been used: * * r[..] = integer( real_r[..]*32768. ); -1 <= real_r < 1. * LAR[..] = integer( real_LAR[..] * 16384 ); * with -1.625 <= real_LAR <= 1.625 */ { register word temp; register int i; /* Computation of the LAR[0..7] from the r[0..7] */ for (i = 1; i <= 8; i++, r++) { temp = *r; temp = GSM_ABS(temp); assert(temp >= 0); if (temp < 22118) { temp >>= 1; } else if (temp < 31130) { assert( temp >= 11059 ); temp -= 11059; } else { assert( temp >= 26112 ); temp -= 26112; temp <<= 2; } *r = *r < 0 ? -temp : temp; assert( *r != MIN_WORD ); } } /* 4.2.7 */ static void Quantization_and_coding P1((LAR), register word * LAR /* [0..7] IN/OUT */ ) { register word temp; /* This procedure needs four tables; the following equations * give the optimum scaling for the constants: * * A[0..7] = integer( real_A[0..7] * 1024 ) * B[0..7] = integer( real_B[0..7] * 512 ) * MAC[0..7] = maximum of the LARc[0..7] * MIC[0..7] = minimum of the LARc[0..7] */ # undef STEP # define STEP( A, B, MAC, MIC ) \ temp = (word)GSM_MULT( A, *LAR ); \ temp = GSM_ADD( temp, B ); \ temp = GSM_ADD( temp, 256 ); \ temp = (word)SASR( temp, 9 ); \ *LAR = temp>MAC ? MAC - MIC : (tempfast) Fast_Autocorrelation (s, L_ACF ); else #endif Autocorrelation (s, L_ACF ); Reflection_coefficients (L_ACF, LARc ); Transformation_to_Log_Area_Ratios (LARc); Quantization_and_coding (LARc); } asterisk-11.7.0/codecs/gsm/src/gsm_print.c0000644000175000007640000001135010374426007020333 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include #include "private.h" #include "gsm.h" #include "proto.h" int gsm_print P3((f, s, c), FILE * f, gsm s, gsm_byte * c) { word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4]; /* GSM_MAGIC = (*c >> 4) & 0xF; */ if (((*c >> 4) & 0x0F) != GSM_MAGIC) return -1; LARc[0] = (*c++ & 0xF) << 2; /* 1 */ LARc[0] |= (*c >> 6) & 0x3; LARc[1] = *c++ & 0x3F; LARc[2] = (*c >> 3) & 0x1F; LARc[3] = (*c++ & 0x7) << 2; LARc[3] |= (*c >> 6) & 0x3; LARc[4] = (*c >> 2) & 0xF; LARc[5] = (*c++ & 0x3) << 2; LARc[5] |= (*c >> 6) & 0x3; LARc[6] = (*c >> 3) & 0x7; LARc[7] = *c++ & 0x7; Nc[0] = (*c >> 1) & 0x7F; bc[0] = (*c++ & 0x1) << 1; bc[0] |= (*c >> 7) & 0x1; Mc[0] = (*c >> 5) & 0x3; xmaxc[0] = (*c++ & 0x1F) << 1; xmaxc[0] |= (*c >> 7) & 0x1; xmc[0] = (*c >> 4) & 0x7; xmc[1] = (*c >> 1) & 0x7; xmc[2] = (*c++ & 0x1) << 2; xmc[2] |= (*c >> 6) & 0x3; xmc[3] = (*c >> 3) & 0x7; xmc[4] = *c++ & 0x7; xmc[5] = (*c >> 5) & 0x7; xmc[6] = (*c >> 2) & 0x7; xmc[7] = (*c++ & 0x3) << 1; /* 10 */ xmc[7] |= (*c >> 7) & 0x1; xmc[8] = (*c >> 4) & 0x7; xmc[9] = (*c >> 1) & 0x7; xmc[10] = (*c++ & 0x1) << 2; xmc[10] |= (*c >> 6) & 0x3; xmc[11] = (*c >> 3) & 0x7; xmc[12] = *c++ & 0x7; Nc[1] = (*c >> 1) & 0x7F; bc[1] = (*c++ & 0x1) << 1; bc[1] |= (*c >> 7) & 0x1; Mc[1] = (*c >> 5) & 0x3; xmaxc[1] = (*c++ & 0x1F) << 1; xmaxc[1] |= (*c >> 7) & 0x1; xmc[13] = (*c >> 4) & 0x7; xmc[14] = (*c >> 1) & 0x7; xmc[15] = (*c++ & 0x1) << 2; xmc[15] |= (*c >> 6) & 0x3; xmc[16] = (*c >> 3) & 0x7; xmc[17] = *c++ & 0x7; xmc[18] = (*c >> 5) & 0x7; xmc[19] = (*c >> 2) & 0x7; xmc[20] = (*c++ & 0x3) << 1; xmc[20] |= (*c >> 7) & 0x1; xmc[21] = (*c >> 4) & 0x7; xmc[22] = (*c >> 1) & 0x7; xmc[23] = (*c++ & 0x1) << 2; xmc[23] |= (*c >> 6) & 0x3; xmc[24] = (*c >> 3) & 0x7; xmc[25] = *c++ & 0x7; Nc[2] = (*c >> 1) & 0x7F; bc[2] = (*c++ & 0x1) << 1; /* 20 */ bc[2] |= (*c >> 7) & 0x1; Mc[2] = (*c >> 5) & 0x3; xmaxc[2] = (*c++ & 0x1F) << 1; xmaxc[2] |= (*c >> 7) & 0x1; xmc[26] = (*c >> 4) & 0x7; xmc[27] = (*c >> 1) & 0x7; xmc[28] = (*c++ & 0x1) << 2; xmc[28] |= (*c >> 6) & 0x3; xmc[29] = (*c >> 3) & 0x7; xmc[30] = *c++ & 0x7; xmc[31] = (*c >> 5) & 0x7; xmc[32] = (*c >> 2) & 0x7; xmc[33] = (*c++ & 0x3) << 1; xmc[33] |= (*c >> 7) & 0x1; xmc[34] = (*c >> 4) & 0x7; xmc[35] = (*c >> 1) & 0x7; xmc[36] = (*c++ & 0x1) << 2; xmc[36] |= (*c >> 6) & 0x3; xmc[37] = (*c >> 3) & 0x7; xmc[38] = *c++ & 0x7; Nc[3] = (*c >> 1) & 0x7F; bc[3] = (*c++ & 0x1) << 1; bc[3] |= (*c >> 7) & 0x1; Mc[3] = (*c >> 5) & 0x3; xmaxc[3] = (*c++ & 0x1F) << 1; xmaxc[3] |= (*c >> 7) & 0x1; xmc[39] = (*c >> 4) & 0x7; xmc[40] = (*c >> 1) & 0x7; xmc[41] = (*c++ & 0x1) << 2; xmc[41] |= (*c >> 6) & 0x3; xmc[42] = (*c >> 3) & 0x7; xmc[43] = *c++ & 0x7; /* 30 */ xmc[44] = (*c >> 5) & 0x7; xmc[45] = (*c >> 2) & 0x7; xmc[46] = (*c++ & 0x3) << 1; xmc[46] |= (*c >> 7) & 0x1; xmc[47] = (*c >> 4) & 0x7; xmc[48] = (*c >> 1) & 0x7; xmc[49] = (*c++ & 0x1) << 2; xmc[49] |= (*c >> 6) & 0x3; xmc[50] = (*c >> 3) & 0x7; xmc[51] = *c & 0x7; /* 33 */ fprintf(f, "LARc:\t%2.2d %2.2d %2.2d %2.2d %2.2d %2.2d %2.2d %2.2d\n", LARc[0],LARc[1],LARc[2],LARc[3],LARc[4],LARc[5],LARc[6],LARc[7]); fprintf(f, "#1: Nc %4.4d bc %d Mc %d xmaxc %d\n", Nc[0], bc[0], Mc[0], xmaxc[0]); fprintf(f, "\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", xmc[0],xmc[1],xmc[2],xmc[3],xmc[4],xmc[5],xmc[6], xmc[7],xmc[8],xmc[9],xmc[10],xmc[11],xmc[12] ); fprintf(f, "#2: Nc %4.4d bc %d Mc %d xmaxc %d\n", Nc[1], bc[1], Mc[1], xmaxc[1]); fprintf(f, "\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", xmc[13+0],xmc[13+1],xmc[13+2],xmc[13+3],xmc[13+4],xmc[13+5], xmc[13+6], xmc[13+7],xmc[13+8],xmc[13+9],xmc[13+10],xmc[13+11], xmc[13+12] ); fprintf(f, "#3: Nc %4.4d bc %d Mc %d xmaxc %d\n", Nc[2], bc[2], Mc[2], xmaxc[2]); fprintf(f, "\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", xmc[26+0],xmc[26+1],xmc[26+2],xmc[26+3],xmc[26+4],xmc[26+5], xmc[26+6], xmc[26+7],xmc[26+8],xmc[26+9],xmc[26+10],xmc[26+11], xmc[26+12] ); fprintf(f, "#4: Nc %4.4d bc %d Mc %d xmaxc %d\n", Nc[3], bc[3], Mc[3], xmaxc[3]); fprintf(f, "\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", xmc[39+0],xmc[39+1],xmc[39+2],xmc[39+3],xmc[39+4],xmc[39+5], xmc[39+6], xmc[39+7],xmc[39+8],xmc[39+9],xmc[39+10],xmc[39+11], xmc[39+12] ); return 0; } asterisk-11.7.0/codecs/gsm/src/preprocess.c0000644000175000007640000000553510453503265020526 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include #include #include "private.h" #include "gsm.h" #include "proto.h" /* 4.2.0 .. 4.2.3 PREPROCESSING SECTION * * After A-law to linear conversion (or directly from the * Ato D converter) the following scaling is assumed for * input to the RPE-LTP algorithm: * * in: 0.1.....................12 * S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.* * * Where S is the sign bit, v a valid bit, and * a "don't care" bit. * The original signal is called sop[..] * * out: 0.1................... 12 * S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.0 */ void Gsm_Preprocess P3((S, s, so), struct gsm_state * S, word * s, word * so ) /* [0..159] IN/OUT */ { word z1 = S->z1; longword L_z2 = S->L_z2; word mp = S->mp; word s1; word SO; ulongword utmp; /* for L_ADD */ register int k = 160; (void) utmp; while (k--) { /* 4.2.1 Downscaling of the input signal */ /* SO = SASR( *s, 3 ) << 2;*/ SO = SASR( *s, 1 ) & ~3; s++; assert (SO >= -0x4000); /* downscaled by */ assert (SO <= 0x3FFC); /* previous routine. */ /* 4.2.2 Offset compensation * * This part implements a high-pass filter and requires extended * arithmetic precision for the recursive part of this filter. * The input of this procedure is the array so[0...159] and the * output the array sof[ 0...159 ]. */ /* Compute the non-recursive part */ s1 = SO - z1; /* s1 = gsm_sub( *so, z1 ); */ z1 = SO; assert(s1 != MIN_WORD); /* SJB Remark: float might be faster than the mess that follows */ /* Compute the recursive part */ /* Execution of a 31 bv 16 bits multiplication */ { word msp; #ifndef __GNUC__ word lsp; #endif longword L_s2; longword L_temp; L_s2 = s1; L_s2 <<= 15; #ifndef __GNUC__ msp = (word)SASR( L_z2, 15 ); lsp = (word)(L_z2 & 0x7fff); /* gsm_L_sub(L_z2,(msp<<15)); */ L_s2 += GSM_MULT_R( lsp, 32735 ); L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/ L_z2 = GSM_L_ADD( L_temp, L_s2 ); /* above does L_z2 = L_z2 * 0x7fd5/0x8000 + L_s2 */ #else L_z2 = ((long long)L_z2*32735 + 0x4000)>>15; /* alternate (ansi) version of above line does slightly different rounding: * L_temp = L_z2 >> 9; * L_temp += L_temp >> 5; * L_temp = (++L_temp) >> 1; * L_z2 = L_z2 - L_temp; */ L_z2 = GSM_L_ADD(L_z2,L_s2); #endif /* Compute sof[k] with rounding */ L_temp = GSM_L_ADD( L_z2, 16384 ); /* 4.2.3 Preemphasis */ msp = (word)GSM_MULT_R( mp, -28180 ); mp = (word)SASR( L_temp, 15 ); *so++ = GSM_ADD( mp, msp ); } } S->z1 = z1; S->L_z2 = L_z2; S->mp = mp; } asterisk-11.7.0/codecs/gsm/src/decode.c0000644000175000007640000000264510374426007017563 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include #include "private.h" #include "gsm.h" #include "proto.h" /* * 4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER */ static void Postprocessing P2((S,s), struct gsm_state * S, register word * s) { register int k; register word msr = S->msr; register word tmp; for (k = 160; k--; s++) { tmp = (word)GSM_MULT_R( msr, 28180 ); msr = GSM_ADD(*s, tmp); /* Deemphasis */ *s = GSM_ADD(msr, msr) & 0xFFF8; /* Truncation & Upscaling */ } S->msr = msr; } void Gsm_Decoder P8((S,LARcr, Ncr,bcr,Mcr,xmaxcr,xMcr,s), struct gsm_state * S, word * LARcr, /* [0..7] IN */ word * Ncr, /* [0..3] IN */ word * bcr, /* [0..3] IN */ word * Mcr, /* [0..3] IN */ word * xmaxcr, /* [0..3] IN */ word * xMcr, /* [0..13*4] IN */ word * s) /* [0..159] OUT */ { int j, k; word erp[40], wt[160]; word * drp = S->dp0 + 120; for (j=0; j <= 3; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13) { Gsm_RPE_Decoding( S, *xmaxcr, *Mcr, xMcr, erp ); Gsm_Long_Term_Synthesis_Filtering( S, *Ncr, *bcr, erp, drp ); for (k = 0; k <= 39; k++) wt[ j * 40 + k ] = drp[ k ]; } Gsm_Short_Term_Synthesis_Filter( S, LARcr, wt, s ); Postprocessing(S, s); } asterisk-11.7.0/codecs/gsm/src/long_term.c0000644000175000007640000005604210671606023020324 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include #include #include "private.h" #include "gsm.h" #include "proto.h" #ifdef K6OPT #include "k6opt.h" #endif /* * 4.2.11 .. 4.2.12 LONG TERM PREDICTOR (LTP) SECTION */ /* * This module computes the LTP gain (bc) and the LTP lag (Nc) * for the long term analysis filter. This is done by calculating a * maximum of the cross-correlation function between the current * sub-segment short term residual signal d[0..39] (output of * the short term analysis filter; for simplification the index * of this array begins at 0 and ends at 39 for each sub-segment of the * RPE-LTP analysis) and the previous reconstructed short term * residual signal dp[ -120 .. -1 ]. A dynamic scaling must be * performed to avoid overflow. */ /* The next procedure exists in six versions. First two integer * version (if USE_FLOAT_MUL is not defined); then four floating * point versions, twice with proper scaling (USE_FLOAT_MUL defined), * once without (USE_FLOAT_MUL and FAST defined, and fast run-time * option used). Every pair has first a Cut version (see the -C * option to toast or the LTP_CUT option to gsm_option()), then the * uncut one. (For a detailed explanation of why this is altogether * a bad idea, see Henry Spencer and Geoff Collyer, ``#ifdef Considered * Harmful''.) */ #ifndef USE_FLOAT_MUL #ifdef LTP_CUT static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), struct gsm_state * st, register word * d, /* [0..39] IN */ register word * dp, /* [-120..-1] IN */ word * bc_out, /* OUT */ word * Nc_out /* OUT */ ) { register int k, lambda; word Nc, bc; word wt[40]; longword L_result; longword L_max, L_power; word R, S, dmax, scal, best_k; word ltp_cut; register word temp, wt_k; /* Search of the optimum scaling of d[0..39]. */ dmax = 0; for (k = 0; k <= 39; k++) { temp = d[k]; temp = GSM_ABS( temp ); if (temp > dmax) { dmax = temp; best_k = k; } } temp = 0; if (dmax == 0) scal = 0; else { assert(dmax > 0); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; assert(scal >= 0); /* Search for the maximum cross-correlation and coding of the LTP lag */ L_max = 0; Nc = 40; /* index for the maximum cross-correlation */ wt_k = SASR(d[best_k], scal); for (lambda = 40; lambda <= 120; lambda++) { L_result = (longword)wt_k * dp[best_k - lambda]; if (L_result > L_max) { Nc = lambda; L_max = L_result; } } *Nc_out = Nc; L_max <<= 1; /* Rescaling of L_max */ assert(scal <= 100 && scal >= -100); L_max = L_max >> (6 - scal); /* sub(6, scal) */ assert( Nc <= 120 && Nc >= 40); /* Compute the power of the reconstructed short term residual * signal dp[..] */ L_power = 0; for (k = 0; k <= 39; k++) { register longword L_temp; L_temp = SASR( dp[k - Nc], 3 ); L_power += L_temp * L_temp; } L_power <<= 1; /* from L_MULT */ /* Normalization of L_max and L_power */ if (L_max <= 0) { *bc_out = 0; return; } if (L_max >= L_power) { *bc_out = 3; return; } temp = gsm_norm( L_power ); R = SASR( L_max << temp, 16 ); S = SASR( L_power << temp, 16 ); /* Coding of the LTP gain */ /* Table 4.3a must be used to obtain the level DLB[i] for the * quantization of the LTP gain b to get the coded version bc. */ for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; *bc_out = bc; } #endif /* LTP_CUT */ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), register word * d, /* [0..39] IN */ register word * dp, /* [-120..-1] IN */ word * bc_out, /* OUT */ word * Nc_out /* OUT */ ) { register int k; #ifndef K6OPT register int lambda; #endif word Nc, bc; word wt[40]; longword L_max, L_power; word R, S, dmax, scal; register word temp; /* Search of the optimum scaling of d[0..39]. */ dmax = 0; for (k = 0; k <= 39; k++) { temp = d[k]; temp = GSM_ABS( temp ); if (temp > dmax) dmax = temp; } temp = 0; if (dmax == 0) scal = 0; else { assert(dmax > 0); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; assert(scal >= 0); /* Initialization of a working array wt */ for (k = 0; k <= 39; k++) wt[k] = SASR( d[k], scal ); /* Search for the maximum cross-correlation and coding of the LTP lag */ # ifdef K6OPT L_max = k6maxcc(wt,dp,&Nc); # else L_max = 0; Nc = 40; /* index for the maximum cross-correlation */ for (lambda = 40; lambda <= 120; lambda++) { # undef STEP # define STEP(k) (longword)wt[k] * dp[k - lambda] register longword L_result; L_result = STEP(0) ; L_result += STEP(1) ; L_result += STEP(2) ; L_result += STEP(3) ; L_result += STEP(4) ; L_result += STEP(5) ; L_result += STEP(6) ; L_result += STEP(7) ; L_result += STEP(8) ; L_result += STEP(9) ; L_result += STEP(10) ; L_result += STEP(11) ; L_result += STEP(12) ; L_result += STEP(13) ; L_result += STEP(14) ; L_result += STEP(15) ; L_result += STEP(16) ; L_result += STEP(17) ; L_result += STEP(18) ; L_result += STEP(19) ; L_result += STEP(20) ; L_result += STEP(21) ; L_result += STEP(22) ; L_result += STEP(23) ; L_result += STEP(24) ; L_result += STEP(25) ; L_result += STEP(26) ; L_result += STEP(27) ; L_result += STEP(28) ; L_result += STEP(29) ; L_result += STEP(30) ; L_result += STEP(31) ; L_result += STEP(32) ; L_result += STEP(33) ; L_result += STEP(34) ; L_result += STEP(35) ; L_result += STEP(36) ; L_result += STEP(37) ; L_result += STEP(38) ; L_result += STEP(39) ; if (L_result > L_max) { Nc = lambda; L_max = L_result; } } # endif *Nc_out = Nc; L_max <<= 1; /* Rescaling of L_max */ assert(scal <= 100 && scal >= -100); L_max = L_max >> (6 - scal); /* sub(6, scal) */ assert( Nc <= 120 && Nc >= 40); /* Compute the power of the reconstructed short term residual * signal dp[..] */ L_power = 0; for (k = 0; k <= 39; k++) { register longword L_temp; L_temp = SASR( dp[k - Nc], 3 ); L_power += L_temp * L_temp; } L_power <<= 1; /* from L_MULT */ /* Normalization of L_max and L_power */ if (L_max <= 0) { *bc_out = 0; return; } if (L_max >= L_power) { *bc_out = 3; return; } temp = gsm_norm( L_power ); R = (word)SASR( L_max << temp, 16 ); S = (word)SASR( L_power << temp, 16 ); /* Coding of the LTP gain */ /* Table 4.3a must be used to obtain the level DLB[i] for the * quantization of the LTP gain b to get the coded version bc. */ for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; *bc_out = bc; } #else /* USE_FLOAT_MUL */ #ifdef LTP_CUT static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), struct gsm_state * st, /* IN */ register word * d, /* [0..39] IN */ register word * dp, /* [-120..-1] IN */ word * bc_out, /* OUT */ word * Nc_out /* OUT */ ) { register int k, lambda; word Nc, bc; word ltp_cut; float wt_float[40]; float dp_float_base[120], * dp_float = dp_float_base + 120; longword L_max, L_power; word R, S, dmax, scal; register word temp; /* Search of the optimum scaling of d[0..39]. */ dmax = 0; for (k = 0; k <= 39; k++) { temp = d[k]; temp = GSM_ABS( temp ); if (temp > dmax) dmax = temp; } temp = 0; if (dmax == 0) scal = 0; else { assert(dmax > 0); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; assert(scal >= 0); ltp_cut = (longword)SASR(dmax, scal) * st->ltp_cut / 100; /* Initialization of a working array wt */ for (k = 0; k < 40; k++) { register word w = SASR( d[k], scal ); if (w < 0 ? w > -ltp_cut : w < ltp_cut) { wt_float[k] = 0.0; } else { wt_float[k] = w; } } for (k = -120; k < 0; k++) dp_float[k] = dp[k]; /* Search for the maximum cross-correlation and coding of the LTP lag */ L_max = 0; Nc = 40; /* index for the maximum cross-correlation */ for (lambda = 40; lambda <= 120; lambda += 9) { /* Calculate L_result for l = lambda .. lambda + 9. */ register float *lp = dp_float - lambda; register float W; register float a = lp[-8], b = lp[-7], c = lp[-6], d = lp[-5], e = lp[-4], f = lp[-3], g = lp[-2], h = lp[-1]; register float E; register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, S5 = 0, S6 = 0, S7 = 0, S8 = 0; # undef STEP # define STEP(K, a, b, c, d, e, f, g, h) \ if ((W = wt_float[K]) != 0.0) { \ E = W * a; S8 += E; \ E = W * b; S7 += E; \ E = W * c; S6 += E; \ E = W * d; S5 += E; \ E = W * e; S4 += E; \ E = W * f; S3 += E; \ E = W * g; S2 += E; \ E = W * h; S1 += E; \ a = lp[K]; \ E = W * a; S0 += E; } else (a = lp[K]) # define STEP_A(K) STEP(K, a, b, c, d, e, f, g, h) # define STEP_B(K) STEP(K, b, c, d, e, f, g, h, a) # define STEP_C(K) STEP(K, c, d, e, f, g, h, a, b) # define STEP_D(K) STEP(K, d, e, f, g, h, a, b, c) # define STEP_E(K) STEP(K, e, f, g, h, a, b, c, d) # define STEP_F(K) STEP(K, f, g, h, a, b, c, d, e) # define STEP_G(K) STEP(K, g, h, a, b, c, d, e, f) # define STEP_H(K) STEP(K, h, a, b, c, d, e, f, g) STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3); STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7); STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11); STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15); STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19); STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23); STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27); STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31); STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35); STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39); if (S0 > L_max) { L_max = S0; Nc = lambda; } if (S1 > L_max) { L_max = S1; Nc = lambda + 1; } if (S2 > L_max) { L_max = S2; Nc = lambda + 2; } if (S3 > L_max) { L_max = S3; Nc = lambda + 3; } if (S4 > L_max) { L_max = S4; Nc = lambda + 4; } if (S5 > L_max) { L_max = S5; Nc = lambda + 5; } if (S6 > L_max) { L_max = S6; Nc = lambda + 6; } if (S7 > L_max) { L_max = S7; Nc = lambda + 7; } if (S8 > L_max) { L_max = S8; Nc = lambda + 8; } } *Nc_out = Nc; L_max <<= 1; /* Rescaling of L_max */ assert(scal <= 100 && scal >= -100); L_max = L_max >> (6 - scal); /* sub(6, scal) */ assert( Nc <= 120 && Nc >= 40); /* Compute the power of the reconstructed short term residual * signal dp[..] */ L_power = 0; for (k = 0; k <= 39; k++) { register longword L_temp; L_temp = SASR( dp[k - Nc], 3 ); L_power += L_temp * L_temp; } L_power <<= 1; /* from L_MULT */ /* Normalization of L_max and L_power */ if (L_max <= 0) { *bc_out = 0; return; } if (L_max >= L_power) { *bc_out = 3; return; } temp = gsm_norm( L_power ); R = SASR( L_max << temp, 16 ); S = SASR( L_power << temp, 16 ); /* Coding of the LTP gain */ /* Table 4.3a must be used to obtain the level DLB[i] for the * quantization of the LTP gain b to get the coded version bc. */ for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; *bc_out = bc; } #endif /* LTP_CUT */ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), register word * d, /* [0..39] IN */ register word * dp, /* [-120..-1] IN */ word * bc_out, /* OUT */ word * Nc_out /* OUT */ ) { register int k, lambda; word Nc, bc; float wt_float[40]; float dp_float_base[120], * dp_float = dp_float_base + 120; longword L_max, L_power; word R, S, dmax, scal; register word temp; /* Search of the optimum scaling of d[0..39]. */ dmax = 0; for (k = 0; k <= 39; k++) { temp = d[k]; temp = GSM_ABS( temp ); if (temp > dmax) dmax = temp; } temp = 0; if (dmax == 0) scal = 0; else { assert(dmax > 0); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; assert(scal >= 0); /* Initialization of a working array wt */ for (k = 0; k < 40; k++) wt_float[k] = SASR( d[k], scal ); for (k = -120; k < 0; k++) dp_float[k] = dp[k]; /* Search for the maximum cross-correlation and coding of the LTP lag */ L_max = 0; Nc = 40; /* index for the maximum cross-correlation */ for (lambda = 40; lambda <= 120; lambda += 9) { /* Calculate L_result for l = lambda .. lambda + 9. */ register float *lp = dp_float - lambda; register float W; register float a = lp[-8], b = lp[-7], c = lp[-6], d = lp[-5], e = lp[-4], f = lp[-3], g = lp[-2], h = lp[-1]; register float E; register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, S5 = 0, S6 = 0, S7 = 0, S8 = 0; # undef STEP # define STEP(K, a, b, c, d, e, f, g, h) \ W = wt_float[K]; \ E = W * a; S8 += E; \ E = W * b; S7 += E; \ E = W * c; S6 += E; \ E = W * d; S5 += E; \ E = W * e; S4 += E; \ E = W * f; S3 += E; \ E = W * g; S2 += E; \ E = W * h; S1 += E; \ a = lp[K]; \ E = W * a; S0 += E # define STEP_A(K) STEP(K, a, b, c, d, e, f, g, h) # define STEP_B(K) STEP(K, b, c, d, e, f, g, h, a) # define STEP_C(K) STEP(K, c, d, e, f, g, h, a, b) # define STEP_D(K) STEP(K, d, e, f, g, h, a, b, c) # define STEP_E(K) STEP(K, e, f, g, h, a, b, c, d) # define STEP_F(K) STEP(K, f, g, h, a, b, c, d, e) # define STEP_G(K) STEP(K, g, h, a, b, c, d, e, f) # define STEP_H(K) STEP(K, h, a, b, c, d, e, f, g) STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3); STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7); STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11); STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15); STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19); STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23); STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27); STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31); STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35); STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39); if (S0 > L_max) { L_max = S0; Nc = lambda; } if (S1 > L_max) { L_max = S1; Nc = lambda + 1; } if (S2 > L_max) { L_max = S2; Nc = lambda + 2; } if (S3 > L_max) { L_max = S3; Nc = lambda + 3; } if (S4 > L_max) { L_max = S4; Nc = lambda + 4; } if (S5 > L_max) { L_max = S5; Nc = lambda + 5; } if (S6 > L_max) { L_max = S6; Nc = lambda + 6; } if (S7 > L_max) { L_max = S7; Nc = lambda + 7; } if (S8 > L_max) { L_max = S8; Nc = lambda + 8; } } *Nc_out = Nc; L_max <<= 1; /* Rescaling of L_max */ assert(scal <= 100 && scal >= -100); L_max = L_max >> (6 - scal); /* sub(6, scal) */ assert( Nc <= 120 && Nc >= 40); /* Compute the power of the reconstructed short term residual * signal dp[..] */ L_power = 0; for (k = 0; k <= 39; k++) { register longword L_temp; L_temp = SASR( dp[k - Nc], 3 ); L_power += L_temp * L_temp; } L_power <<= 1; /* from L_MULT */ /* Normalization of L_max and L_power */ if (L_max <= 0) { *bc_out = 0; return; } if (L_max >= L_power) { *bc_out = 3; return; } temp = gsm_norm( L_power ); R = SASR( L_max << temp, 16 ); S = SASR( L_power << temp, 16 ); /* Coding of the LTP gain */ /* Table 4.3a must be used to obtain the level DLB[i] for the * quantization of the LTP gain b to get the coded version bc. */ for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; *bc_out = bc; } #ifdef FAST #ifdef LTP_CUT static void Cut_Fast_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), struct gsm_state * st, /* IN */ register word * d, /* [0..39] IN */ register word * dp, /* [-120..-1] IN */ word * bc_out, /* OUT */ word * Nc_out /* OUT */ ) { register int k, lambda; register float wt_float; word Nc, bc; word wt_max, best_k, ltp_cut; float dp_float_base[120], * dp_float = dp_float_base + 120; register float L_result, L_max, L_power; wt_max = 0; for (k = 0; k < 40; ++k) { if ( d[k] > wt_max) wt_max = d[best_k = k]; else if (-d[k] > wt_max) wt_max = -d[best_k = k]; } assert(wt_max >= 0); wt_float = (float)wt_max; for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k]; /* Search for the maximum cross-correlation and coding of the LTP lag */ L_max = 0; Nc = 40; /* index for the maximum cross-correlation */ for (lambda = 40; lambda <= 120; lambda++) { L_result = wt_float * dp_float[best_k - lambda]; if (L_result > L_max) { Nc = lambda; L_max = L_result; } } *Nc_out = Nc; if (L_max <= 0.) { *bc_out = 0; return; } /* Compute the power of the reconstructed short term residual * signal dp[..] */ dp_float -= Nc; L_power = 0; for (k = 0; k < 40; ++k) { register float f = dp_float[k]; L_power += f * f; } if (L_max >= L_power) { *bc_out = 3; return; } /* Coding of the LTP gain * Table 4.3a must be used to obtain the level DLB[i] for the * quantization of the LTP gain b to get the coded version bc. */ lambda = L_max / L_power * 32768.; for (bc = 0; bc <= 2; ++bc) if (lambda <= gsm_DLB[bc]) break; *bc_out = bc; } #endif /* LTP_CUT */ static void Fast_Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), register word * d, /* [0..39] IN */ register word * dp, /* [-120..-1] IN */ word * bc_out, /* OUT */ word * Nc_out /* OUT */ ) { register int k, lambda; word Nc, bc; float wt_float[40]; float dp_float_base[120], * dp_float = dp_float_base + 120; register float L_max, L_power; for (k = 0; k < 40; ++k) wt_float[k] = (float)d[k]; for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k]; /* Search for the maximum cross-correlation and coding of the LTP lag */ L_max = 0; Nc = 40; /* index for the maximum cross-correlation */ for (lambda = 40; lambda <= 120; lambda += 9) { /* Calculate L_result for l = lambda .. lambda + 9. */ register float *lp = dp_float - lambda; register float W; register float a = lp[-8], b = lp[-7], c = lp[-6], d = lp[-5], e = lp[-4], f = lp[-3], g = lp[-2], h = lp[-1]; register float E; register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, S5 = 0, S6 = 0, S7 = 0, S8 = 0; # undef STEP # define STEP(K, a, b, c, d, e, f, g, h) \ W = wt_float[K]; \ E = W * a; S8 += E; \ E = W * b; S7 += E; \ E = W * c; S6 += E; \ E = W * d; S5 += E; \ E = W * e; S4 += E; \ E = W * f; S3 += E; \ E = W * g; S2 += E; \ E = W * h; S1 += E; \ a = lp[K]; \ E = W * a; S0 += E # define STEP_A(K) STEP(K, a, b, c, d, e, f, g, h) # define STEP_B(K) STEP(K, b, c, d, e, f, g, h, a) # define STEP_C(K) STEP(K, c, d, e, f, g, h, a, b) # define STEP_D(K) STEP(K, d, e, f, g, h, a, b, c) # define STEP_E(K) STEP(K, e, f, g, h, a, b, c, d) # define STEP_F(K) STEP(K, f, g, h, a, b, c, d, e) # define STEP_G(K) STEP(K, g, h, a, b, c, d, e, f) # define STEP_H(K) STEP(K, h, a, b, c, d, e, f, g) STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3); STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7); STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11); STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15); STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19); STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23); STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27); STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31); STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35); STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39); if (S0 > L_max) { L_max = S0; Nc = lambda; } if (S1 > L_max) { L_max = S1; Nc = lambda + 1; } if (S2 > L_max) { L_max = S2; Nc = lambda + 2; } if (S3 > L_max) { L_max = S3; Nc = lambda + 3; } if (S4 > L_max) { L_max = S4; Nc = lambda + 4; } if (S5 > L_max) { L_max = S5; Nc = lambda + 5; } if (S6 > L_max) { L_max = S6; Nc = lambda + 6; } if (S7 > L_max) { L_max = S7; Nc = lambda + 7; } if (S8 > L_max) { L_max = S8; Nc = lambda + 8; } } *Nc_out = Nc; if (L_max <= 0.) { *bc_out = 0; return; } /* Compute the power of the reconstructed short term residual * signal dp[..] */ dp_float -= Nc; L_power = 0; for (k = 0; k < 40; ++k) { register float f = dp_float[k]; L_power += f * f; } if (L_max >= L_power) { *bc_out = 3; return; } /* Coding of the LTP gain * Table 4.3a must be used to obtain the level DLB[i] for the * quantization of the LTP gain b to get the coded version bc. */ lambda = L_max / L_power * 32768.; for (bc = 0; bc <= 2; ++bc) if (lambda <= gsm_DLB[bc]) break; *bc_out = bc; } #endif /* FAST */ #endif /* USE_FLOAT_MUL */ /* 4.2.12 */ static void Long_term_analysis_filtering P6((bc,Nc,dp,d,dpp,e), word bc, /* IN */ word Nc, /* IN */ register word * dp, /* previous d [-120..-1] IN */ register word * d, /* d [0..39] IN */ register word * dpp, /* estimate [0..39] OUT */ register word * e /* long term res. signal [0..39] OUT */ ) /* * In this part, we have to decode the bc parameter to compute * the samples of the estimate dpp[0..39]. The decoding of bc needs the * use of table 4.3b. The long term residual signal e[0..39] * is then calculated to be fed to the RPE encoding section. */ { register int k; # undef STEP # define STEP(BP) \ for (k = 0; k <= 39; k++) { \ dpp[k] = (word)GSM_MULT_R( BP, dp[k - Nc]); \ e[k] = GSM_SUB( d[k], dpp[k] ); \ } switch (bc) { case 0: STEP( 3277 ); break; case 1: STEP( 11469 ); break; case 2: STEP( 21299 ); break; case 3: STEP( 32767 ); break; } } void Gsm_Long_Term_Predictor P7((S,d,dp,e,dpp,Nc,bc), /* 4x for 160 samples */ struct gsm_state * S, word * d, /* [0..39] residual signal IN */ word * dp, /* [-120..-1] d' IN */ word * e, /* [0..39] OUT */ word * dpp, /* [0..39] OUT */ word * Nc, /* correlation lag OUT */ word * bc /* gain factor OUT */ ) { assert( d ); assert( dp ); assert( e ); assert( dpp); assert( Nc ); assert( bc ); #if defined(FAST) && defined(USE_FLOAT_MUL) if (S->fast) #if defined (LTP_CUT) if (S->ltp_cut) Cut_Fast_Calculation_of_the_LTP_parameters(S, d, dp, bc, Nc); else #endif /* LTP_CUT */ Fast_Calculation_of_the_LTP_parameters(d, dp, bc, Nc ); else #endif /* FAST & USE_FLOAT_MUL */ #ifdef LTP_CUT if (S->ltp_cut) Cut_Calculation_of_the_LTP_parameters(S, d, dp, bc, Nc); else #endif Calculation_of_the_LTP_parameters(d, dp, bc, Nc); Long_term_analysis_filtering( *bc, *Nc, dp, d, dpp, e ); } /* 4.3.2 */ void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp), struct gsm_state * S, word Ncr, word bcr, register word * erp, /* [0..39] IN */ register word * drp /* [-120..-1] IN, [-120..40] OUT */ ) /* * This procedure uses the bcr and Ncr parameter to realize the * long term synthesis filtering. The decoding of bcr needs * table 4.3b. */ { register int k; word brp, drpp, Nr; /* Check the limits of Nr. */ Nr = Ncr < 40 || Ncr > 120 ? S->nrp : Ncr; S->nrp = Nr; assert(Nr >= 40 && Nr <= 120); /* Decoding of the LTP gain bcr */ brp = gsm_QLB[ bcr ]; /* Computation of the reconstructed short term residual * signal drp[0..39] */ assert(brp != MIN_WORD); for (k = 0; k <= 39; k++) { drpp = (word)GSM_MULT_R( brp, drp[ k - Nr ] ); drp[k] = GSM_ADD( erp[k], drpp ); } /* * Update of the reconstructed short term residual signal * drp[ -1..-120 ] */ for (k = 0; k <= 119; k++) drp[ -120 + k ] = drp[ -80 + k ]; } asterisk-11.7.0/codecs/gsm/src/k6opt.s0000644000175000007640000000000011741571773017414 0ustar sharkyjerrywebasterisk-11.7.0/codecs/gsm/src/debug.c0000644000175000007640000000266110374426007017424 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "private.h" #ifndef NDEBUG /* If NDEBUG _is_ defined and no debugging should be performed, * calls to functions in this module are #defined to nothing * in private.h. */ #include #include "proto.h" void gsm_debug_words P4( (name, from, to, ptr), char * name, int from, int to, word * ptr) { int nprinted = 0; fprintf( stderr, "%s [%d .. %d]: ", name, from, to ); while (from <= to) { fprintf(stderr, "%d ", ptr[ from ] ); from++; if (nprinted++ >= 7) { nprinted = 0; if (from < to) putc('\n', stderr); } } putc('\n', stderr); } void gsm_debug_longwords P4( (name, from, to, ptr), char * name, int from, int to, longword * ptr) { int nprinted = 0; fprintf( stderr, "%s [%d .. %d]: ", name, from, to ); while (from <= to) { fprintf(stderr, "%d ", ptr[ from ] ); from++; if (nprinted++ >= 7) { nprinted = 0; if (from < to) putc('\n', stderr); } } putc('\n', stderr); } void gsm_debug_longword P2( (name, value), char * name, longword value ) { fprintf(stderr, "%s: %d\n", name, (long)value ); } void gsm_debug_word P2( (name, value), char * name, word value ) { fprintf(stderr, "%s: %d\n", name, (long)value); } #endif asterisk-11.7.0/codecs/gsm/src/gsm_encode.c0000644000175000007640000002610610374426007020441 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "private.h" #include "gsm.h" #include "proto.h" void gsm_encode P3((s, source, c), gsm s, gsm_signal * source, gsm_byte * c) { word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4]; Gsm_Coder(s, source, LARc, Nc, bc, Mc, xmaxc, xmc); /* variable size GSM_MAGIC 4 LARc[0] 6 LARc[1] 6 LARc[2] 5 LARc[3] 5 LARc[4] 4 LARc[5] 4 LARc[6] 3 LARc[7] 3 Nc[0] 7 bc[0] 2 Mc[0] 2 xmaxc[0] 6 xmc[0] 3 xmc[1] 3 xmc[2] 3 xmc[3] 3 xmc[4] 3 xmc[5] 3 xmc[6] 3 xmc[7] 3 xmc[8] 3 xmc[9] 3 xmc[10] 3 xmc[11] 3 xmc[12] 3 Nc[1] 7 bc[1] 2 Mc[1] 2 xmaxc[1] 6 xmc[13] 3 xmc[14] 3 xmc[15] 3 xmc[16] 3 xmc[17] 3 xmc[18] 3 xmc[19] 3 xmc[20] 3 xmc[21] 3 xmc[22] 3 xmc[23] 3 xmc[24] 3 xmc[25] 3 Nc[2] 7 bc[2] 2 Mc[2] 2 xmaxc[2] 6 xmc[26] 3 xmc[27] 3 xmc[28] 3 xmc[29] 3 xmc[30] 3 xmc[31] 3 xmc[32] 3 xmc[33] 3 xmc[34] 3 xmc[35] 3 xmc[36] 3 xmc[37] 3 xmc[38] 3 Nc[3] 7 bc[3] 2 Mc[3] 2 xmaxc[3] 6 xmc[39] 3 xmc[40] 3 xmc[41] 3 xmc[42] 3 xmc[43] 3 xmc[44] 3 xmc[45] 3 xmc[46] 3 xmc[47] 3 xmc[48] 3 xmc[49] 3 xmc[50] 3 xmc[51] 3 */ #ifdef WAV49 if (s->wav_fmt) { s->frame_index = !s->frame_index; if (s->frame_index) { uword sr; sr = 0; sr = sr >> 6 | LARc[0] << 10; sr = sr >> 6 | LARc[1] << 10; *c++ = sr >> 4; sr = sr >> 5 | LARc[2] << 11; *c++ = sr >> 7; sr = sr >> 5 | LARc[3] << 11; sr = sr >> 4 | LARc[4] << 12; *c++ = sr >> 6; sr = sr >> 4 | LARc[5] << 12; sr = sr >> 3 | LARc[6] << 13; *c++ = sr >> 7; sr = sr >> 3 | LARc[7] << 13; sr = sr >> 7 | Nc[0] << 9; *c++ = sr >> 5; sr = sr >> 2 | bc[0] << 14; sr = sr >> 2 | Mc[0] << 14; sr = sr >> 6 | xmaxc[0] << 10; *c++ = sr >> 3; sr = sr >> 3 | xmc[0] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[1] << 13; sr = sr >> 3 | xmc[2] << 13; sr = sr >> 3 | xmc[3] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[4] << 13; sr = sr >> 3 | xmc[5] << 13; sr = sr >> 3 | xmc[6] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[7] << 13; sr = sr >> 3 | xmc[8] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[9] << 13; sr = sr >> 3 | xmc[10] << 13; sr = sr >> 3 | xmc[11] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[12] << 13; sr = sr >> 7 | Nc[1] << 9; *c++ = sr >> 5; sr = sr >> 2 | bc[1] << 14; sr = sr >> 2 | Mc[1] << 14; sr = sr >> 6 | xmaxc[1] << 10; *c++ = sr >> 3; sr = sr >> 3 | xmc[13] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[14] << 13; sr = sr >> 3 | xmc[15] << 13; sr = sr >> 3 | xmc[16] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[17] << 13; sr = sr >> 3 | xmc[18] << 13; sr = sr >> 3 | xmc[19] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[20] << 13; sr = sr >> 3 | xmc[21] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[22] << 13; sr = sr >> 3 | xmc[23] << 13; sr = sr >> 3 | xmc[24] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[25] << 13; sr = sr >> 7 | Nc[2] << 9; *c++ = sr >> 5; sr = sr >> 2 | bc[2] << 14; sr = sr >> 2 | Mc[2] << 14; sr = sr >> 6 | xmaxc[2] << 10; *c++ = sr >> 3; sr = sr >> 3 | xmc[26] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[27] << 13; sr = sr >> 3 | xmc[28] << 13; sr = sr >> 3 | xmc[29] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[30] << 13; sr = sr >> 3 | xmc[31] << 13; sr = sr >> 3 | xmc[32] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[33] << 13; sr = sr >> 3 | xmc[34] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[35] << 13; sr = sr >> 3 | xmc[36] << 13; sr = sr >> 3 | xmc[37] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[38] << 13; sr = sr >> 7 | Nc[3] << 9; *c++ = sr >> 5; sr = sr >> 2 | bc[3] << 14; sr = sr >> 2 | Mc[3] << 14; sr = sr >> 6 | xmaxc[3] << 10; *c++ = sr >> 3; sr = sr >> 3 | xmc[39] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[40] << 13; sr = sr >> 3 | xmc[41] << 13; sr = sr >> 3 | xmc[42] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[43] << 13; sr = sr >> 3 | xmc[44] << 13; sr = sr >> 3 | xmc[45] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[46] << 13; sr = sr >> 3 | xmc[47] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[48] << 13; sr = sr >> 3 | xmc[49] << 13; sr = sr >> 3 | xmc[50] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[51] << 13; sr = sr >> 4; *c = sr >> 8; s->frame_chain = *c; } else { uword sr; sr = 0; sr = sr >> 4 | s->frame_chain << 12; sr = sr >> 6 | LARc[0] << 10; *c++ = sr >> 6; sr = sr >> 6 | LARc[1] << 10; *c++ = sr >> 8; sr = sr >> 5 | LARc[2] << 11; sr = sr >> 5 | LARc[3] << 11; *c++ = sr >> 6; sr = sr >> 4 | LARc[4] << 12; sr = sr >> 4 | LARc[5] << 12; *c++ = sr >> 6; sr = sr >> 3 | LARc[6] << 13; sr = sr >> 3 | LARc[7] << 13; *c++ = sr >> 8; sr = sr >> 7 | Nc[0] << 9; sr = sr >> 2 | bc[0] << 14; *c++ = sr >> 7; sr = sr >> 2 | Mc[0] << 14; sr = sr >> 6 | xmaxc[0] << 10; *c++ = sr >> 7; sr = sr >> 3 | xmc[0] << 13; sr = sr >> 3 | xmc[1] << 13; sr = sr >> 3 | xmc[2] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[3] << 13; sr = sr >> 3 | xmc[4] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[5] << 13; sr = sr >> 3 | xmc[6] << 13; sr = sr >> 3 | xmc[7] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[8] << 13; sr = sr >> 3 | xmc[9] << 13; sr = sr >> 3 | xmc[10] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[11] << 13; sr = sr >> 3 | xmc[12] << 13; *c++ = sr >> 8; sr = sr >> 7 | Nc[1] << 9; sr = sr >> 2 | bc[1] << 14; *c++ = sr >> 7; sr = sr >> 2 | Mc[1] << 14; sr = sr >> 6 | xmaxc[1] << 10; *c++ = sr >> 7; sr = sr >> 3 | xmc[13] << 13; sr = sr >> 3 | xmc[14] << 13; sr = sr >> 3 | xmc[15] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[16] << 13; sr = sr >> 3 | xmc[17] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[18] << 13; sr = sr >> 3 | xmc[19] << 13; sr = sr >> 3 | xmc[20] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[21] << 13; sr = sr >> 3 | xmc[22] << 13; sr = sr >> 3 | xmc[23] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[24] << 13; sr = sr >> 3 | xmc[25] << 13; *c++ = sr >> 8; sr = sr >> 7 | Nc[2] << 9; sr = sr >> 2 | bc[2] << 14; *c++ = sr >> 7; sr = sr >> 2 | Mc[2] << 14; sr = sr >> 6 | xmaxc[2] << 10; *c++ = sr >> 7; sr = sr >> 3 | xmc[26] << 13; sr = sr >> 3 | xmc[27] << 13; sr = sr >> 3 | xmc[28] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[29] << 13; sr = sr >> 3 | xmc[30] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[31] << 13; sr = sr >> 3 | xmc[32] << 13; sr = sr >> 3 | xmc[33] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[34] << 13; sr = sr >> 3 | xmc[35] << 13; sr = sr >> 3 | xmc[36] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[37] << 13; sr = sr >> 3 | xmc[38] << 13; *c++ = sr >> 8; sr = sr >> 7 | Nc[3] << 9; sr = sr >> 2 | bc[3] << 14; *c++ = sr >> 7; sr = sr >> 2 | Mc[3] << 14; sr = sr >> 6 | xmaxc[3] << 10; *c++ = sr >> 7; sr = sr >> 3 | xmc[39] << 13; sr = sr >> 3 | xmc[40] << 13; sr = sr >> 3 | xmc[41] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[42] << 13; sr = sr >> 3 | xmc[43] << 13; *c++ = sr >> 8; sr = sr >> 3 | xmc[44] << 13; sr = sr >> 3 | xmc[45] << 13; sr = sr >> 3 | xmc[46] << 13; *c++ = sr >> 7; sr = sr >> 3 | xmc[47] << 13; sr = sr >> 3 | xmc[48] << 13; sr = sr >> 3 | xmc[49] << 13; *c++ = sr >> 6; sr = sr >> 3 | xmc[50] << 13; sr = sr >> 3 | xmc[51] << 13; *c++ = sr >> 8; } } else #endif /* WAV49 */ { *c++ = ((GSM_MAGIC & 0xF) << 4) /* 1 */ | ((LARc[0] >> 2) & 0xF); *c++ = ((LARc[0] & 0x3) << 6) | (LARc[1] & 0x3F); *c++ = ((LARc[2] & 0x1F) << 3) | ((LARc[3] >> 2) & 0x7); *c++ = ((LARc[3] & 0x3) << 6) | ((LARc[4] & 0xF) << 2) | ((LARc[5] >> 2) & 0x3); *c++ = ((LARc[5] & 0x3) << 6) | ((LARc[6] & 0x7) << 3) | (LARc[7] & 0x7); *c++ = ((Nc[0] & 0x7F) << 1) | ((bc[0] >> 1) & 0x1); *c++ = ((bc[0] & 0x1) << 7) | ((Mc[0] & 0x3) << 5) | ((xmaxc[0] >> 1) & 0x1F); *c++ = ((xmaxc[0] & 0x1) << 7) | ((xmc[0] & 0x7) << 4) | ((xmc[1] & 0x7) << 1) | ((xmc[2] >> 2) & 0x1); *c++ = ((xmc[2] & 0x3) << 6) | ((xmc[3] & 0x7) << 3) | (xmc[4] & 0x7); *c++ = ((xmc[5] & 0x7) << 5) /* 10 */ | ((xmc[6] & 0x7) << 2) | ((xmc[7] >> 1) & 0x3); *c++ = ((xmc[7] & 0x1) << 7) | ((xmc[8] & 0x7) << 4) | ((xmc[9] & 0x7) << 1) | ((xmc[10] >> 2) & 0x1); *c++ = ((xmc[10] & 0x3) << 6) | ((xmc[11] & 0x7) << 3) | (xmc[12] & 0x7); *c++ = ((Nc[1] & 0x7F) << 1) | ((bc[1] >> 1) & 0x1); *c++ = ((bc[1] & 0x1) << 7) | ((Mc[1] & 0x3) << 5) | ((xmaxc[1] >> 1) & 0x1F); *c++ = ((xmaxc[1] & 0x1) << 7) | ((xmc[13] & 0x7) << 4) | ((xmc[14] & 0x7) << 1) | ((xmc[15] >> 2) & 0x1); *c++ = ((xmc[15] & 0x3) << 6) | ((xmc[16] & 0x7) << 3) | (xmc[17] & 0x7); *c++ = ((xmc[18] & 0x7) << 5) | ((xmc[19] & 0x7) << 2) | ((xmc[20] >> 1) & 0x3); *c++ = ((xmc[20] & 0x1) << 7) | ((xmc[21] & 0x7) << 4) | ((xmc[22] & 0x7) << 1) | ((xmc[23] >> 2) & 0x1); *c++ = ((xmc[23] & 0x3) << 6) | ((xmc[24] & 0x7) << 3) | (xmc[25] & 0x7); *c++ = ((Nc[2] & 0x7F) << 1) /* 20 */ | ((bc[2] >> 1) & 0x1); *c++ = ((bc[2] & 0x1) << 7) | ((Mc[2] & 0x3) << 5) | ((xmaxc[2] >> 1) & 0x1F); *c++ = ((xmaxc[2] & 0x1) << 7) | ((xmc[26] & 0x7) << 4) | ((xmc[27] & 0x7) << 1) | ((xmc[28] >> 2) & 0x1); *c++ = ((xmc[28] & 0x3) << 6) | ((xmc[29] & 0x7) << 3) | (xmc[30] & 0x7); *c++ = ((xmc[31] & 0x7) << 5) | ((xmc[32] & 0x7) << 2) | ((xmc[33] >> 1) & 0x3); *c++ = ((xmc[33] & 0x1) << 7) | ((xmc[34] & 0x7) << 4) | ((xmc[35] & 0x7) << 1) | ((xmc[36] >> 2) & 0x1); *c++ = ((xmc[36] & 0x3) << 6) | ((xmc[37] & 0x7) << 3) | (xmc[38] & 0x7); *c++ = ((Nc[3] & 0x7F) << 1) | ((bc[3] >> 1) & 0x1); *c++ = ((bc[3] & 0x1) << 7) | ((Mc[3] & 0x3) << 5) | ((xmaxc[3] >> 1) & 0x1F); *c++ = ((xmaxc[3] & 0x1) << 7) | ((xmc[39] & 0x7) << 4) | ((xmc[40] & 0x7) << 1) | ((xmc[41] >> 2) & 0x1); *c++ = ((xmc[41] & 0x3) << 6) /* 30 */ | ((xmc[42] & 0x7) << 3) | (xmc[43] & 0x7); *c++ = ((xmc[44] & 0x7) << 5) | ((xmc[45] & 0x7) << 2) | ((xmc[46] >> 1) & 0x3); *c++ = ((xmc[46] & 0x1) << 7) | ((xmc[47] & 0x7) << 4) | ((xmc[48] & 0x7) << 1) | ((xmc[49] >> 2) & 0x1); *c++ = ((xmc[49] & 0x3) << 6) | ((xmc[50] & 0x7) << 3) | (xmc[51] & 0x7); } } asterisk-11.7.0/codecs/gsm/src/gsm_decode.c0000644000175000007640000002451610374426007020432 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "private.h" #include "gsm.h" #include "proto.h" int gsm_decode P3((s, c, target), gsm s, gsm_byte * c, gsm_signal * target) { word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4]; #ifdef WAV49 if (s->wav_fmt) { uword sr = 0; s->frame_index = !s->frame_index; if (s->frame_index) { sr = *c++; LARc[0] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 2; LARc[1] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 4; LARc[2] = sr & 0x1f; sr >>= 5; LARc[3] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 2; LARc[4] = sr & 0xf; sr >>= 4; LARc[5] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; /* 5 */ LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[0] = sr & 0x7f; sr >>= 7; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[0] = sr & 0x3f; sr >>= 6; xmc[0] = sr & 0x7; sr >>= 3; sr = *c++; xmc[1] = sr & 0x7; sr >>= 3; xmc[2] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; xmc[5] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 10 */ xmc[6] = sr & 0x7; sr >>= 3; xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; sr = *c++; xmc[9] = sr & 0x7; sr >>= 3; xmc[10] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[1] = sr & 0x7f; sr >>= 7; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[1] = sr & 0x3f; sr >>= 6; xmc[13] = sr & 0x7; sr >>= 3; sr = *c++; /* 15 */ xmc[14] = sr & 0x7; sr >>= 3; xmc[15] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; xmc[18] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[19] = sr & 0x7; sr >>= 3; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; sr = *c++; xmc[22] = sr & 0x7; sr >>= 3; xmc[23] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; /* 20 */ Nc[2] = sr & 0x7f; sr >>= 7; bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[2] = sr & 0x3f; sr >>= 6; xmc[26] = sr & 0x7; sr >>= 3; sr = *c++; xmc[27] = sr & 0x7; sr >>= 3; xmc[28] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; xmc[31] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[32] = sr & 0x7; sr >>= 3; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; sr = *c++; /* 25 */ xmc[35] = sr & 0x7; sr >>= 3; xmc[36] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[3] = sr & 0x7f; sr >>= 7; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[3] = sr & 0x3f; sr >>= 6; xmc[39] = sr & 0x7; sr >>= 3; sr = *c++; xmc[40] = sr & 0x7; sr >>= 3; xmc[41] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 30 */ xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; xmc[44] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[45] = sr & 0x7; sr >>= 3; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; sr = *c++; xmc[48] = sr & 0x7; sr >>= 3; xmc[49] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; s->frame_chain = sr & 0xf; } else { sr = s->frame_chain; sr |= (uword)*c++ << 4; /* 1 */ LARc[0] = sr & 0x3f; sr >>= 6; LARc[1] = sr & 0x3f; sr >>= 6; sr = *c++; LARc[2] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 3; LARc[3] = sr & 0x1f; sr >>= 5; LARc[4] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; LARc[5] = sr & 0xf; sr >>= 4; LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr = *c++; /* 5 */ Nc[0] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[0] = sr & 0x3f; sr >>= 6; xmc[0] = sr & 0x7; sr >>= 3; xmc[1] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[2] = sr & 0x7; sr >>= 3; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; sr = *c++; xmc[5] = sr & 0x7; sr >>= 3; xmc[6] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 10 */ xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; xmc[9] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[10] = sr & 0x7; sr >>= 3; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr = *c++; Nc[1] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[1] = sr & 0x3f; sr >>= 6; xmc[13] = sr & 0x7; sr >>= 3; xmc[14] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 15 */ xmc[15] = sr & 0x7; sr >>= 3; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; sr = *c++; xmc[18] = sr & 0x7; sr >>= 3; xmc[19] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; xmc[22] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[23] = sr & 0x7; sr >>= 3; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr = *c++; Nc[2] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; /* 20 */ bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[2] = sr & 0x3f; sr >>= 6; xmc[26] = sr & 0x7; sr >>= 3; xmc[27] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[28] = sr & 0x7; sr >>= 3; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; sr = *c++; xmc[31] = sr & 0x7; sr >>= 3; xmc[32] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; xmc[35] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 25 */ xmc[36] = sr & 0x7; sr >>= 3; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr = *c++; Nc[3] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[3] = sr & 0x3f; sr >>= 6; xmc[39] = sr & 0x7; sr >>= 3; xmc[40] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[41] = sr & 0x7; sr >>= 3; xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; sr = *c++; /* 30 */ xmc[44] = sr & 0x7; sr >>= 3; xmc[45] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; xmc[48] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[49] = sr & 0x7; sr >>= 3; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; } } else #endif { /* GSM_MAGIC = (*c >> 4) & 0xF; */ if (((*c >> 4) & 0x0F) != GSM_MAGIC) return -1; LARc[0] = (*c++ & 0xF) << 2; /* 1 */ LARc[0] |= (*c >> 6) & 0x3; LARc[1] = *c++ & 0x3F; LARc[2] = (*c >> 3) & 0x1F; LARc[3] = (*c++ & 0x7) << 2; LARc[3] |= (*c >> 6) & 0x3; LARc[4] = (*c >> 2) & 0xF; LARc[5] = (*c++ & 0x3) << 2; LARc[5] |= (*c >> 6) & 0x3; LARc[6] = (*c >> 3) & 0x7; LARc[7] = *c++ & 0x7; Nc[0] = (*c >> 1) & 0x7F; bc[0] = (*c++ & 0x1) << 1; bc[0] |= (*c >> 7) & 0x1; Mc[0] = (*c >> 5) & 0x3; xmaxc[0] = (*c++ & 0x1F) << 1; xmaxc[0] |= (*c >> 7) & 0x1; xmc[0] = (*c >> 4) & 0x7; xmc[1] = (*c >> 1) & 0x7; xmc[2] = (*c++ & 0x1) << 2; xmc[2] |= (*c >> 6) & 0x3; xmc[3] = (*c >> 3) & 0x7; xmc[4] = *c++ & 0x7; xmc[5] = (*c >> 5) & 0x7; xmc[6] = (*c >> 2) & 0x7; xmc[7] = (*c++ & 0x3) << 1; /* 10 */ xmc[7] |= (*c >> 7) & 0x1; xmc[8] = (*c >> 4) & 0x7; xmc[9] = (*c >> 1) & 0x7; xmc[10] = (*c++ & 0x1) << 2; xmc[10] |= (*c >> 6) & 0x3; xmc[11] = (*c >> 3) & 0x7; xmc[12] = *c++ & 0x7; Nc[1] = (*c >> 1) & 0x7F; bc[1] = (*c++ & 0x1) << 1; bc[1] |= (*c >> 7) & 0x1; Mc[1] = (*c >> 5) & 0x3; xmaxc[1] = (*c++ & 0x1F) << 1; xmaxc[1] |= (*c >> 7) & 0x1; xmc[13] = (*c >> 4) & 0x7; xmc[14] = (*c >> 1) & 0x7; xmc[15] = (*c++ & 0x1) << 2; xmc[15] |= (*c >> 6) & 0x3; xmc[16] = (*c >> 3) & 0x7; xmc[17] = *c++ & 0x7; xmc[18] = (*c >> 5) & 0x7; xmc[19] = (*c >> 2) & 0x7; xmc[20] = (*c++ & 0x3) << 1; xmc[20] |= (*c >> 7) & 0x1; xmc[21] = (*c >> 4) & 0x7; xmc[22] = (*c >> 1) & 0x7; xmc[23] = (*c++ & 0x1) << 2; xmc[23] |= (*c >> 6) & 0x3; xmc[24] = (*c >> 3) & 0x7; xmc[25] = *c++ & 0x7; Nc[2] = (*c >> 1) & 0x7F; bc[2] = (*c++ & 0x1) << 1; /* 20 */ bc[2] |= (*c >> 7) & 0x1; Mc[2] = (*c >> 5) & 0x3; xmaxc[2] = (*c++ & 0x1F) << 1; xmaxc[2] |= (*c >> 7) & 0x1; xmc[26] = (*c >> 4) & 0x7; xmc[27] = (*c >> 1) & 0x7; xmc[28] = (*c++ & 0x1) << 2; xmc[28] |= (*c >> 6) & 0x3; xmc[29] = (*c >> 3) & 0x7; xmc[30] = *c++ & 0x7; xmc[31] = (*c >> 5) & 0x7; xmc[32] = (*c >> 2) & 0x7; xmc[33] = (*c++ & 0x3) << 1; xmc[33] |= (*c >> 7) & 0x1; xmc[34] = (*c >> 4) & 0x7; xmc[35] = (*c >> 1) & 0x7; xmc[36] = (*c++ & 0x1) << 2; xmc[36] |= (*c >> 6) & 0x3; xmc[37] = (*c >> 3) & 0x7; xmc[38] = *c++ & 0x7; Nc[3] = (*c >> 1) & 0x7F; bc[3] = (*c++ & 0x1) << 1; bc[3] |= (*c >> 7) & 0x1; Mc[3] = (*c >> 5) & 0x3; xmaxc[3] = (*c++ & 0x1F) << 1; xmaxc[3] |= (*c >> 7) & 0x1; xmc[39] = (*c >> 4) & 0x7; xmc[40] = (*c >> 1) & 0x7; xmc[41] = (*c++ & 0x1) << 2; xmc[41] |= (*c >> 6) & 0x3; xmc[42] = (*c >> 3) & 0x7; xmc[43] = *c++ & 0x7; /* 30 */ xmc[44] = (*c >> 5) & 0x7; xmc[45] = (*c >> 2) & 0x7; xmc[46] = (*c++ & 0x3) << 1; xmc[46] |= (*c >> 7) & 0x1; xmc[47] = (*c >> 4) & 0x7; xmc[48] = (*c >> 1) & 0x7; xmc[49] = (*c++ & 0x1) << 2; xmc[49] |= (*c >> 6) & 0x3; xmc[50] = (*c >> 3) & 0x7; xmc[51] = *c & 0x7; /* 33 */ } Gsm_Decoder(s, LARc, Nc, bc, Mc, xmaxc, xmc, target); return 0; } asterisk-11.7.0/codecs/gsm/src/gsm_destroy.c0000644000175000007640000000072511216466526020702 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "gsm.h" #include "config.h" #include "proto.h" #ifdef HAS_STDLIB_H # include #else # ifdef HAS_MALLOC_H # include # else extern void free(); # endif #endif void gsm_destroy P1((S), gsm S) { free((char *)S); } asterisk-11.7.0/codecs/gsm/src/table.c0000644000175000007640000000401410374426007017417 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ /* Most of these tables are inlined at their point of use. */ /* 4.4 TABLES USED IN THE FIXED POINT IMPLEMENTATION OF THE RPE-LTP * CODER AND DECODER * * (Most of them inlined, so watch out.) */ #define GSM_TABLE_C #include "private.h" #include "gsm.h" /* Table 4.1 Quantization of the Log.-Area Ratios */ /* i 1 2 3 4 5 6 7 8 */ word gsm_A[8] = {20480, 20480, 20480, 20480, 13964, 15360, 8534, 9036}; word gsm_B[8] = { 0, 0, 2048, -2560, 94, -1792, -341, -1144}; word gsm_MIC[8] = { -32, -32, -16, -16, -8, -8, -4, -4 }; word gsm_MAC[8] = { 31, 31, 15, 15, 7, 7, 3, 3 }; /* Table 4.2 Tabulation of 1/A[1..8] */ word gsm_INVA[8]={ 13107, 13107, 13107, 13107, 19223, 17476, 31454, 29708 }; /* Table 4.3a Decision level of the LTP gain quantizer */ /* bc 0 1 2 3 */ word gsm_DLB[4] = { 6554, 16384, 26214, 32767 }; /* Table 4.3b Quantization levels of the LTP gain quantizer */ /* bc 0 1 2 3 */ word gsm_QLB[4] = { 3277, 11469, 21299, 32767 }; /* Table 4.4 Coefficients of the weighting filter */ /* i 0 1 2 3 4 5 6 7 8 9 10 */ word gsm_H[11] = {-134, -374, 0, 2054, 5741, 8192, 5741, 2054, 0, -374, -134 }; /* Table 4.5 Normalized inverse mantissa used to compute xM/xmax */ /* i 0 1 2 3 4 5 6 7 */ word gsm_NRFAC[8] = { 29128, 26215, 23832, 21846, 20165, 18725, 17476, 16384 }; /* Table 4.6 Normalized direct mantissa used to compute xM/xmax */ /* i 0 1 2 3 4 5 6 7 */ word gsm_FAC[8] = { 18431, 20479, 22527, 24575, 26623, 28671, 30719, 32767 }; asterisk-11.7.0/codecs/gsm/src/gsm_implode.c0000644000175000007640000003114610374426007020635 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "private.h" #include "gsm.h" #include "proto.h" void gsm_implode P3((s, source, c), gsm s, gsm_signal * source, gsm_byte * c) { /* variable size index GSM_MAGIC 4 - LARc[0] 6 0 LARc[1] 6 1 LARc[2] 5 2 LARc[3] 5 3 LARc[4] 4 4 LARc[5] 4 5 LARc[6] 3 6 LARc[7] 3 7 Nc[0] 7 8 bc[0] 2 9 Mc[0] 2 10 xmaxc[0] 6 11 xmc[0] 3 12 xmc[1] 3 13 xmc[2] 3 14 xmc[3] 3 15 xmc[4] 3 16 xmc[5] 3 17 xmc[6] 3 18 xmc[7] 3 19 xmc[8] 3 20 xmc[9] 3 21 xmc[10] 3 22 xmc[11] 3 23 xmc[12] 3 24 Nc[1] 7 25 bc[1] 2 26 Mc[1] 2 27 xmaxc[1] 6 28 xmc[13] 3 29 xmc[14] 3 30 xmc[15] 3 31 xmc[16] 3 32 xmc[17] 3 33 xmc[18] 3 34 xmc[19] 3 35 xmc[20] 3 36 xmc[21] 3 37 xmc[22] 3 38 xmc[23] 3 39 xmc[24] 3 40 xmc[25] 3 41 Nc[2] 7 42 bc[2] 2 43 Mc[2] 2 44 xmaxc[2] 6 45 xmc[26] 3 46 xmc[27] 3 47 xmc[28] 3 48 xmc[29] 3 49 xmc[30] 3 50 xmc[31] 3 51 xmc[32] 3 52 xmc[33] 3 53 xmc[34] 3 54 xmc[35] 3 55 xmc[36] 3 56 xmc[37] 3 57 xmc[38] 3 58 Nc[3] 7 59 bc[3] 2 60 Mc[3] 2 61 xmaxc[3] 6 62 xmc[39] 3 63 xmc[40] 3 64 xmc[41] 3 65 xmc[42] 3 66 xmc[43] 3 67 xmc[44] 3 68 xmc[45] 3 69 xmc[46] 3 70 xmc[47] 3 71 xmc[48] 3 72 xmc[49] 3 73 xmc[50] 3 74 xmc[51] 3 75 */ /* There are 76 parameters per frame. The first eight are * unique. The remaining 68 are four identical subframes of * 17 parameters each. gsm_implode converts from a representation * of these parameters as values in one array of signed words * to the "packed" version of a GSM frame. */ # define LARc source # define Nc *((gsm_signal (*) [17])(source + 8)) # define bc *((gsm_signal (*) [17])(source + 9)) # define Mc *((gsm_signal (*) [17])(source + 10)) # define xmaxc *((gsm_signal (*) [17])(source + 11)) #ifdef WAV49 if (s->wav_fmt) { uword sr = 0; if (s->frame_index == 0) { sr = *c++; LARc[0] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 2; LARc[1] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 4; LARc[2] = sr & 0x1f; sr >>= 5; LARc[3] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 2; LARc[4] = sr & 0xf; sr >>= 4; LARc[5] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; /* 5 */ LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[0] = sr & 0x7f; sr >>= 7; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[0] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 12) xmc[0] = sr & 0x7; sr >>= 3; sr = *c++; xmc[1] = sr & 0x7; sr >>= 3; xmc[2] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; xmc[5] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 10 */ xmc[6] = sr & 0x7; sr >>= 3; xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; sr = *c++; xmc[9] = sr & 0x7; sr >>= 3; xmc[10] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[1] = sr & 0x7f; sr >>= 7; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[1] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 29 - 13) xmc[13] = sr & 0x7; sr >>= 3; sr = *c++; /* 15 */ xmc[14] = sr & 0x7; sr >>= 3; xmc[15] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; xmc[18] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[19] = sr & 0x7; sr >>= 3; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; sr = *c++; xmc[22] = sr & 0x7; sr >>= 3; xmc[23] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; /* 20 */ Nc[2] = sr & 0x7f; sr >>= 7; bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[2] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 46 - 26) xmc[26] = sr & 0x7; sr >>= 3; sr = *c++; xmc[27] = sr & 0x7; sr >>= 3; xmc[28] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; xmc[31] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[32] = sr & 0x7; sr >>= 3; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; sr = *c++; /* 25 */ xmc[35] = sr & 0x7; sr >>= 3; xmc[36] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[3] = sr & 0x7f; sr >>= 7; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[3] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 63 - 39) xmc[39] = sr & 0x7; sr >>= 3; sr = *c++; xmc[40] = sr & 0x7; sr >>= 3; xmc[41] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 30 */ xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; xmc[44] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[45] = sr & 0x7; sr >>= 3; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; sr = *c++; xmc[48] = sr & 0x7; sr >>= 3; xmc[49] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; s->frame_chain = sr & 0xf; } else { sr = s->frame_chain; sr |= (uword)*c++ << 4; /* 1 */ LARc[0] = sr & 0x3f; sr >>= 6; LARc[1] = sr & 0x3f; sr >>= 6; sr = *c++; LARc[2] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 3; LARc[3] = sr & 0x1f; sr >>= 5; LARc[4] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; LARc[5] = sr & 0xf; sr >>= 4; LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr = *c++; /* 5 */ Nc[0] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[0] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 12) xmc[0] = sr & 0x7; sr >>= 3; xmc[1] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[2] = sr & 0x7; sr >>= 3; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; sr = *c++; xmc[5] = sr & 0x7; sr >>= 3; xmc[6] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 10 */ xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; xmc[9] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[10] = sr & 0x7; sr >>= 3; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr = *c++; Nc[1] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[1] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 29 - 13) xmc[13] = sr & 0x7; sr >>= 3; xmc[14] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 15 */ xmc[15] = sr & 0x7; sr >>= 3; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; sr = *c++; xmc[18] = sr & 0x7; sr >>= 3; xmc[19] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; xmc[22] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[23] = sr & 0x7; sr >>= 3; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr = *c++; Nc[2] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; /* 20 */ bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[2] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 46 - 26) xmc[26] = sr & 0x7; sr >>= 3; xmc[27] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[28] = sr & 0x7; sr >>= 3; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; sr = *c++; xmc[31] = sr & 0x7; sr >>= 3; xmc[32] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; xmc[35] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 25 */ xmc[36] = sr & 0x7; sr >>= 3; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr = *c++; Nc[3] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[3] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (source + 63 - 39) xmc[39] = sr & 0x7; sr >>= 3; xmc[40] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[41] = sr & 0x7; sr >>= 3; xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; sr = *c++; /* 30 */ xmc[44] = sr & 0x7; sr >>= 3; xmc[45] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; xmc[48] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[49] = sr & 0x7; sr >>= 3; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; } } else #endif { *c++ = ((GSM_MAGIC & 0xF) << 4) /* 1 */ | ((LARc[0] >> 2) & 0xF); *c++ = ((LARc[0] & 0x3) << 6) | (LARc[1] & 0x3F); *c++ = ((LARc[2] & 0x1F) << 3) | ((LARc[3] >> 2) & 0x7); *c++ = ((LARc[3] & 0x3) << 6) | ((LARc[4] & 0xF) << 2) | ((LARc[5] >> 2) & 0x3); *c++ = ((LARc[5] & 0x3) << 6) | ((LARc[6] & 0x7) << 3) | (LARc[7] & 0x7); *c++ = ((Nc[0] & 0x7F) << 1) | ((bc[0] >> 1) & 0x1); *c++ = ((bc[0] & 0x1) << 7) | ((Mc[0] & 0x3) << 5) | ((xmaxc[0] >> 1) & 0x1F); *c++ = ((xmaxc[0] & 0x1) << 7) #undef xmc #define xmc (source + 12) | ((xmc[0] & 0x7) << 4) | ((xmc[1] & 0x7) << 1) | ((xmc[2] >> 2) & 0x1); *c++ = ((xmc[2] & 0x3) << 6) | ((xmc[3] & 0x7) << 3) | (xmc[4] & 0x7); *c++ = ((xmc[5] & 0x7) << 5) /* 10 */ | ((xmc[6] & 0x7) << 2) | ((xmc[7] >> 1) & 0x3); *c++ = ((xmc[7] & 0x1) << 7) | ((xmc[8] & 0x7) << 4) | ((xmc[9] & 0x7) << 1) | ((xmc[10] >> 2) & 0x1); *c++ = ((xmc[10] & 0x3) << 6) | ((xmc[11] & 0x7) << 3) | (xmc[12] & 0x7); *c++ = ((Nc[1] & 0x7F) << 1) | ((bc[1] >> 1) & 0x1); *c++ = ((bc[1] & 0x1) << 7) | ((Mc[1] & 0x3) << 5) | ((xmaxc[1] >> 1) & 0x1F); *c++ = ((xmaxc[1] & 0x1) << 7) #undef xmc #define xmc (source + 29 - 13) | ((xmc[13] & 0x7) << 4) | ((xmc[14] & 0x7) << 1) | ((xmc[15] >> 2) & 0x1); *c++ = ((xmc[15] & 0x3) << 6) | ((xmc[16] & 0x7) << 3) | (xmc[17] & 0x7); *c++ = ((xmc[18] & 0x7) << 5) | ((xmc[19] & 0x7) << 2) | ((xmc[20] >> 1) & 0x3); *c++ = ((xmc[20] & 0x1) << 7) | ((xmc[21] & 0x7) << 4) | ((xmc[22] & 0x7) << 1) | ((xmc[23] >> 2) & 0x1); *c++ = ((xmc[23] & 0x3) << 6) | ((xmc[24] & 0x7) << 3) | (xmc[25] & 0x7); *c++ = ((Nc[2] & 0x7F) << 1) /* 20 */ | ((bc[2] >> 1) & 0x1); *c++ = ((bc[2] & 0x1) << 7) | ((Mc[2] & 0x3) << 5) | ((xmaxc[2] >> 1) & 0x1F); *c++ = ((xmaxc[2] & 0x1) << 7) #undef xmc #define xmc (source + 46 - 26) | ((xmc[26] & 0x7) << 4) | ((xmc[27] & 0x7) << 1) | ((xmc[28] >> 2) & 0x1); *c++ = ((xmc[28] & 0x3) << 6) | ((xmc[29] & 0x7) << 3) | (xmc[30] & 0x7); *c++ = ((xmc[31] & 0x7) << 5) | ((xmc[32] & 0x7) << 2) | ((xmc[33] >> 1) & 0x3); *c++ = ((xmc[33] & 0x1) << 7) | ((xmc[34] & 0x7) << 4) | ((xmc[35] & 0x7) << 1) | ((xmc[36] >> 2) & 0x1); *c++ = ((xmc[36] & 0x3) << 6) | ((xmc[37] & 0x7) << 3) | (xmc[38] & 0x7); *c++ = ((Nc[3] & 0x7F) << 1) | ((bc[3] >> 1) & 0x1); *c++ = ((bc[3] & 0x1) << 7) | ((Mc[3] & 0x3) << 5) | ((xmaxc[3] >> 1) & 0x1F); *c++ = ((xmaxc[3] & 0x1) << 7) #undef xmc #define xmc (source + 63 - 39) | ((xmc[39] & 0x7) << 4) | ((xmc[40] & 0x7) << 1) | ((xmc[41] >> 2) & 0x1); *c++ = ((xmc[41] & 0x3) << 6) /* 30 */ | ((xmc[42] & 0x7) << 3) | (xmc[43] & 0x7); *c++ = ((xmc[44] & 0x7) << 5) | ((xmc[45] & 0x7) << 2) | ((xmc[46] >> 1) & 0x3); *c++ = ((xmc[46] & 0x1) << 7) | ((xmc[47] & 0x7) << 4) | ((xmc[48] & 0x7) << 1) | ((xmc[49] >> 2) & 0x1); *c++ = ((xmc[49] & 0x3) << 6) | ((xmc[50] & 0x7) << 3) | (xmc[51] & 0x7); } } asterisk-11.7.0/codecs/gsm/src/gsm_explode.c0000644000175000007640000002547710374426007020656 0ustar sharkyjerryweb/* * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische * Universitaet Berlin. See the accompanying file "COPYRIGHT" for * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ /* $Header$ */ #include "private.h" #include "gsm.h" #include "proto.h" int gsm_explode P3((s, c, target), gsm s, gsm_byte * c, gsm_signal * target) { # define LARc target # define Nc *((gsm_signal (*) [17])(target + 8)) # define bc *((gsm_signal (*) [17])(target + 9)) # define Mc *((gsm_signal (*) [17])(target + 10)) # define xmaxc *((gsm_signal (*) [17])(target + 11)) #ifdef WAV49 if (s->wav_fmt) { uword sr = 0; if (s->frame_index == 1) { sr = *c++; LARc[0] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 2; LARc[1] = sr & 0x3f; sr >>= 6; sr |= (uword)*c++ << 4; LARc[2] = sr & 0x1f; sr >>= 5; LARc[3] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 2; LARc[4] = sr & 0xf; sr >>= 4; LARc[5] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; /* 5 */ LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[0] = sr & 0x7f; sr >>= 7; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[0] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 12) xmc[0] = sr & 0x7; sr >>= 3; sr = *c++; xmc[1] = sr & 0x7; sr >>= 3; xmc[2] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; xmc[5] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 10 */ xmc[6] = sr & 0x7; sr >>= 3; xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; sr = *c++; xmc[9] = sr & 0x7; sr >>= 3; xmc[10] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[1] = sr & 0x7f; sr >>= 7; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[1] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 29 - 13) xmc[13] = sr & 0x7; sr >>= 3; sr = *c++; /* 15 */ xmc[14] = sr & 0x7; sr >>= 3; xmc[15] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; xmc[18] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[19] = sr & 0x7; sr >>= 3; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; sr = *c++; xmc[22] = sr & 0x7; sr >>= 3; xmc[23] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; /* 20 */ Nc[2] = sr & 0x7f; sr >>= 7; bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[2] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 46 - 26) xmc[26] = sr & 0x7; sr >>= 3; sr = *c++; xmc[27] = sr & 0x7; sr >>= 3; xmc[28] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; xmc[31] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[32] = sr & 0x7; sr >>= 3; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; sr = *c++; /* 25 */ xmc[35] = sr & 0x7; sr >>= 3; xmc[36] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 4; Nc[3] = sr & 0x7f; sr >>= 7; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 1; xmaxc[3] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 63 - 39) xmc[39] = sr & 0x7; sr >>= 3; sr = *c++; xmc[40] = sr & 0x7; sr >>= 3; xmc[41] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 30 */ xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; xmc[44] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[45] = sr & 0x7; sr >>= 3; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; sr = *c++; xmc[48] = sr & 0x7; sr >>= 3; xmc[49] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; s->frame_chain = sr & 0xf; } else { sr = s->frame_chain; sr |= (uword)*c++ << 4; /* 1 */ LARc[0] = sr & 0x3f; sr >>= 6; LARc[1] = sr & 0x3f; sr >>= 6; sr = *c++; LARc[2] = sr & 0x1f; sr >>= 5; sr |= (uword)*c++ << 3; LARc[3] = sr & 0x1f; sr >>= 5; LARc[4] = sr & 0xf; sr >>= 4; sr |= (uword)*c++ << 2; LARc[5] = sr & 0xf; sr >>= 4; LARc[6] = sr & 0x7; sr >>= 3; LARc[7] = sr & 0x7; sr >>= 3; sr = *c++; /* 5 */ Nc[0] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[0] = sr & 0x3; sr >>= 2; Mc[0] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[0] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 12) xmc[0] = sr & 0x7; sr >>= 3; xmc[1] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[2] = sr & 0x7; sr >>= 3; xmc[3] = sr & 0x7; sr >>= 3; xmc[4] = sr & 0x7; sr >>= 3; sr = *c++; xmc[5] = sr & 0x7; sr >>= 3; xmc[6] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; /* 10 */ xmc[7] = sr & 0x7; sr >>= 3; xmc[8] = sr & 0x7; sr >>= 3; xmc[9] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[10] = sr & 0x7; sr >>= 3; xmc[11] = sr & 0x7; sr >>= 3; xmc[12] = sr & 0x7; sr >>= 3; sr = *c++; Nc[1] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[1] = sr & 0x3; sr >>= 2; Mc[1] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[1] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 29 - 13) xmc[13] = sr & 0x7; sr >>= 3; xmc[14] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 15 */ xmc[15] = sr & 0x7; sr >>= 3; xmc[16] = sr & 0x7; sr >>= 3; xmc[17] = sr & 0x7; sr >>= 3; sr = *c++; xmc[18] = sr & 0x7; sr >>= 3; xmc[19] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[20] = sr & 0x7; sr >>= 3; xmc[21] = sr & 0x7; sr >>= 3; xmc[22] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[23] = sr & 0x7; sr >>= 3; xmc[24] = sr & 0x7; sr >>= 3; xmc[25] = sr & 0x7; sr >>= 3; sr = *c++; Nc[2] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; /* 20 */ bc[2] = sr & 0x3; sr >>= 2; Mc[2] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[2] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 46 - 26) xmc[26] = sr & 0x7; sr >>= 3; xmc[27] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[28] = sr & 0x7; sr >>= 3; xmc[29] = sr & 0x7; sr >>= 3; xmc[30] = sr & 0x7; sr >>= 3; sr = *c++; xmc[31] = sr & 0x7; sr >>= 3; xmc[32] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[33] = sr & 0x7; sr >>= 3; xmc[34] = sr & 0x7; sr >>= 3; xmc[35] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; /* 25 */ xmc[36] = sr & 0x7; sr >>= 3; xmc[37] = sr & 0x7; sr >>= 3; xmc[38] = sr & 0x7; sr >>= 3; sr = *c++; Nc[3] = sr & 0x7f; sr >>= 7; sr |= (uword)*c++ << 1; bc[3] = sr & 0x3; sr >>= 2; Mc[3] = sr & 0x3; sr >>= 2; sr |= (uword)*c++ << 5; xmaxc[3] = sr & 0x3f; sr >>= 6; #undef xmc #define xmc (target + 63 - 39) xmc[39] = sr & 0x7; sr >>= 3; xmc[40] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[41] = sr & 0x7; sr >>= 3; xmc[42] = sr & 0x7; sr >>= 3; xmc[43] = sr & 0x7; sr >>= 3; sr = *c++; /* 30 */ xmc[44] = sr & 0x7; sr >>= 3; xmc[45] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 2; xmc[46] = sr & 0x7; sr >>= 3; xmc[47] = sr & 0x7; sr >>= 3; xmc[48] = sr & 0x7; sr >>= 3; sr |= (uword)*c++ << 1; xmc[49] = sr & 0x7; sr >>= 3; xmc[50] = sr & 0x7; sr >>= 3; xmc[51] = sr & 0x7; sr >>= 3; } } else #endif { /* GSM_MAGIC = (*c >> 4) & 0xF; */ if (((*c >> 4) & 0x0F) != GSM_MAGIC) return -1; LARc[0] = (*c++ & 0xF) << 2; /* 1 */ LARc[0] |= (*c >> 6) & 0x3; LARc[1] = *c++ & 0x3F; LARc[2] = (*c >> 3) & 0x1F; LARc[3] = (*c++ & 0x7) << 2; LARc[3] |= (*c >> 6) & 0x3; LARc[4] = (*c >> 2) & 0xF; LARc[5] = (*c++ & 0x3) << 2; LARc[5] |= (*c >> 6) & 0x3; LARc[6] = (*c >> 3) & 0x7; LARc[7] = *c++ & 0x7; Nc[0] = (*c >> 1) & 0x7F; bc[0] = (*c++ & 0x1) << 1; bc[0] |= (*c >> 7) & 0x1; Mc[0] = (*c >> 5) & 0x3; xmaxc[0] = (*c++ & 0x1F) << 1; xmaxc[0] |= (*c >> 7) & 0x1; #undef xmc #define xmc (target + 12) xmc[0] = (*c >> 4) & 0x7; xmc[1] = (*c >> 1) & 0x7; xmc[2] = (*c++ & 0x1) << 2; xmc[2] |= (*c >> 6) & 0x3; xmc[3] = (*c >> 3) & 0x7; xmc[4] = *c++ & 0x7; xmc[5] = (*c >> 5) & 0x7; xmc[6] = (*c >> 2) & 0x7; xmc[7] = (*c++ & 0x3) << 1; /* 10 */ xmc[7] |= (*c >> 7) & 0x1; xmc[8] = (*c >> 4) & 0x7; xmc[9] = (*c >> 1) & 0x7; xmc[10] = (*c++ & 0x1) << 2; xmc[10] |= (*c >> 6) & 0x3; xmc[11] = (*c >> 3) & 0x7; xmc[12] = *c++ & 0x7; Nc[1] = (*c >> 1) & 0x7F; bc[1] = (*c++ & 0x1) << 1; bc[1] |= (*c >> 7) & 0x1; Mc[1] = (*c >> 5) & 0x3; xmaxc[1] = (*c++ & 0x1F) << 1; xmaxc[1] |= (*c >> 7) & 0x1; #undef xmc #define xmc (target + 29 - 13) xmc[13] = (*c >> 4) & 0x7; xmc[14] = (*c >> 1) & 0x7; xmc[15] = (*c++ & 0x1) << 2; xmc[15] |= (*c >> 6) & 0x3; xmc[16] = (*c >> 3) & 0x7; xmc[17] = *c++ & 0x7; xmc[18] = (*c >> 5) & 0x7; xmc[19] = (*c >> 2) & 0x7; xmc[20] = (*c++ & 0x3) << 1; xmc[20] |= (*c >> 7) & 0x1; xmc[21] = (*c >> 4) & 0x7; xmc[22] = (*c >> 1) & 0x7; xmc[23] = (*c++ & 0x1) << 2; xmc[23] |= (*c >> 6) & 0x3; xmc[24] = (*c >> 3) & 0x7; xmc[25] = *c++ & 0x7; Nc[2] = (*c >> 1) & 0x7F; bc[2] = (*c++ & 0x1) << 1; /* 20 */ bc[2] |= (*c >> 7) & 0x1; Mc[2] = (*c >> 5) & 0x3; xmaxc[2] = (*c++ & 0x1F) << 1; xmaxc[2] |= (*c >> 7) & 0x1; #undef xmc #define xmc (target + 46 - 26) xmc[26] = (*c >> 4) & 0x7; xmc[27] = (*c >> 1) & 0x7; xmc[28] = (*c++ & 0x1) << 2; xmc[28] |= (*c >> 6) & 0x3; xmc[29] = (*c >> 3) & 0x7; xmc[30] = *c++ & 0x7; xmc[31] = (*c >> 5) & 0x7; xmc[32] = (*c >> 2) & 0x7; xmc[33] = (*c++ & 0x3) << 1; xmc[33] |= (*c >> 7) & 0x1; xmc[34] = (*c >> 4) & 0x7; xmc[35] = (*c >> 1) & 0x7; xmc[36] = (*c++ & 0x1) << 2; xmc[36] |= (*c >> 6) & 0x3; xmc[37] = (*c >> 3) & 0x7; xmc[38] = *c++ & 0x7; Nc[3] = (*c >> 1) & 0x7F; bc[3] = (*c++ & 0x1) << 1; bc[3] |= (*c >> 7) & 0x1; Mc[3] = (*c >> 5) & 0x3; xmaxc[3] = (*c++ & 0x1F) << 1; xmaxc[3] |= (*c >> 7) & 0x1; #undef xmc #define xmc (target + 63 - 39) xmc[39] = (*c >> 4) & 0x7; xmc[40] = (*c >> 1) & 0x7; xmc[41] = (*c++ & 0x1) << 2; xmc[41] |= (*c >> 6) & 0x3; xmc[42] = (*c >> 3) & 0x7; xmc[43] = *c++ & 0x7; /* 30 */ xmc[44] = (*c >> 5) & 0x7; xmc[45] = (*c >> 2) & 0x7; xmc[46] = (*c++ & 0x3) << 1; xmc[46] |= (*c >> 7) & 0x1; xmc[47] = (*c >> 4) & 0x7; xmc[48] = (*c >> 1) & 0x7; xmc[49] = (*c++ & 0x1) << 2; xmc[49] |= (*c >> 6) & 0x3; xmc[50] = (*c >> 3) & 0x7; xmc[51] = *c & 0x7; /* 33 */ } return 0; } asterisk-11.7.0/codecs/gsm/Makefile0000644000175000007640000003050111741571773017047 0ustar sharkyjerryweb# Copyright 1992-1996 by Jutta Degener and Carsten Bormann, Technische # Universitaet Berlin. See the accompanying file "COPYRIGHT" for # details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. # Machine- or installation dependent flags you should configure to port SASR = -DSASR ######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1) #MULHACK = -DUSE_FLOAT_MUL ######### Define this if your host multiplies floats faster than integers, ######### e.g. on a SPARCstation. #FAST = -DFAST ######### Define together with USE_FLOAT_MUL to enable the GSM library's ######### approximation option for incorrect, but good-enough results. # LTP_CUT = -DLTP_CUT LTP_CUT = ######### Define to enable the GSM library's long-term correlation ######### approximation option---faster, but worse; works for ######### both integer and floating point multiplications. ######### This flag is still in the experimental stage. WAV49 = -DWAV49 #WAV49 = ######### Define to enable the GSM library's option to pack GSM frames ######### in the style used by the WAV #49 format. If you want to write ######### a tool that produces .WAV files which contain GSM-encoded data, ######### define this, and read about the GSM_OPT_WAV49 option in the ######### manual page on gsm_option(3). #K6OPT = -DK6OPT #K6OPT = ######### Define to enable MMXTM optimizations for x86 architecture CPU's ######### which support MMX instructions. This should be newer pentiums, ######### ppro's, etc, as well as the AMD K6 and K7. The compile will ######### probably require gcc. # Due to the gsm codec beeing broken when compiled with gcc version 4.2 # and optimization higher than -O2 we are checking for that version and # set the optimization to -O2 in this case. ifeq ($(shell $(CC) -v 2>&1 | awk '/^gcc version/ { split($$3, v, "."); printf "%s.%s\n", v[1], v[2]; }' ),4.2) OPTIMIZE=-O2 endif PG = #PG = -g -pg ######### Profiling flags. If you don't know what that means, leave it blank. # Choose a compiler. The code works both with ANSI and K&R-C. # Use -DNeedFunctionPrototypes to compile with, -UNeedFunctionPrototypes to # compile without, function prototypes in the header files. # # You can use the -DSTUPID_COMPILER to circumvent some compilers' # static limits regarding the number of subexpressions in a statement. # CC = cc # CCFLAGS = -c -DSTUPID_COMPILER # CC = /usr/lang/acc # CCFLAGS = -c -O CCFLAGS += -c -DNeedFunctionPrototypes=1 -funroll-loops $(OPTIMIZE) # LD = gcc # LDFLAGS = # If your compiler needs additional flags/libraries, regardless of # the source compiled, configure them here. # CCINC = -I/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1/include ######### Includes needed by $(CC) # LDINC = -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1 ######### Library paths needed by $(LD) # LDLIB = -lgcc ######### Additional libraries needed by $(LD) # Where do you want to install libraries, binaries, a header file # and the manual pages? # # Leave INSTALL_ROOT empty (or just don't execute "make install") to # not install gsm and toast outside of this directory. INSTALL_ROOT = # Where do you want to install the gsm library, header file, and manpages? # # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of # this directory. GSM_INSTALL_ROOT = $(INSTALL_ROOT) GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3 # Where do you want to install the toast binaries and their manpage? # # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside # of this directory. TOAST_INSTALL_ROOT = $(INSTALL_ROOT) TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1 # Other tools SHELL = /bin/sh LN = ln BASENAME = basename AR = ar ARFLAGS = cr RMFLAGS = -f FIND = find COMPRESS = compress COMPRESSFLAGS = # RANLIB = true RANLIB = ranlib # # You shouldn't have to configure below this line if you're porting. # # Local Directories ROOT = . ADDTST = $(ROOT)/add-test TST = $(ROOT)/tst MAN = $(ROOT)/man BIN = $(ROOT)/bin SRC = $(ROOT)/src LIB = $(ROOT)/lib TLS = $(ROOT)/tls INC = $(ROOT)/inc # Flags DEBUG = -DNDEBUG ######### Remove -DNDEBUG to enable assertions. _ASTCFLAGS += $(PG) $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) \ $(LTP_CUT) $(WAV49) $(K6OPT) $(CCINC) -I$(INC) ######### It's $(CC) $(CFLAGS) LFLAGS = $(PG) $(LDFLAGS) $(LDINC) ######### It's $(LD) $(LFLAGS) # Targets LIBGSM = $(LIB)/libgsm.a LIBGSMSO= $(LIB)/libgsm.so TOAST = $(BIN)/toast UNTOAST = $(BIN)/untoast TCAT = $(BIN)/tcat # Headers GSM_HEADERS = $(INC)/gsm.h HEADERS = $(INC)/proto.h \ $(INC)/unproto.h \ $(INC)/config.h \ $(INC)/private.h \ $(INC)/gsm.h \ $(INC)/toast.h \ $(TLS)/taste.h # Sources GSM_SOURCES = $(SRC)/add.c \ $(SRC)/code.c \ $(SRC)/debug.c \ $(SRC)/decode.c \ $(SRC)/long_term.c \ $(SRC)/lpc.c \ $(SRC)/preprocess.c \ $(SRC)/rpe.c \ $(SRC)/gsm_destroy.c \ $(SRC)/gsm_decode.c \ $(SRC)/gsm_encode.c \ $(SRC)/gsm_explode.c \ $(SRC)/gsm_implode.c \ $(SRC)/gsm_create.c \ $(SRC)/gsm_print.c \ $(SRC)/gsm_option.c \ $(SRC)/short_term.c \ $(SRC)/table.c TOAST_SOURCES = $(SRC)/toast.c \ $(SRC)/toast_lin.c \ $(SRC)/toast_ulaw.c \ $(SRC)/toast_alaw.c \ $(SRC)/toast_audio.c SOURCES = $(GSM_SOURCES) \ $(TOAST_SOURCES) \ $(ADDTST)/add_test.c \ $(TLS)/sour.c \ $(TLS)/ginger.c \ $(TLS)/sour1.dta \ $(TLS)/sour2.dta \ $(TLS)/bitter.c \ $(TLS)/bitter.dta \ $(TLS)/taste.c \ $(TLS)/sweet.c \ $(TST)/cod2lin.c \ $(TST)/cod2txt.c \ $(TST)/gsm2cod.c \ $(TST)/lin2cod.c \ $(TST)/lin2txt.c # Object files GSM_OBJECTS = $(SRC)/add.o \ $(SRC)/code.o \ $(SRC)/debug.o \ $(SRC)/decode.o \ $(SRC)/long_term.o \ $(SRC)/lpc.o \ $(SRC)/preprocess.o \ $(SRC)/rpe.o \ $(SRC)/gsm_destroy.o \ $(SRC)/gsm_decode.o \ $(SRC)/gsm_encode.o \ $(SRC)/gsm_explode.o \ $(SRC)/gsm_implode.o \ $(SRC)/gsm_create.o \ $(SRC)/gsm_print.o \ $(SRC)/gsm_option.o \ $(SRC)/short_term.o \ $(SRC)/table.o TOAST_OBJECTS = $(SRC)/toast.o \ $(SRC)/toast_lin.o \ $(SRC)/toast_ulaw.o \ $(SRC)/toast_alaw.o \ $(SRC)/toast_audio.o OBJECTS = $(GSM_OBJECTS) $(TOAST_OBJECTS) # Manuals GSM_MANUALS = $(MAN)/gsm.3 \ $(MAN)/gsm_explode.3 \ $(MAN)/gsm_option.3 \ $(MAN)/gsm_print.3 TOAST_MANUALS = $(MAN)/toast.1 MANUALS = $(GSM_MANUALS) $(TOAST_MANUALS) $(MAN)/bitter.1 # Other stuff in the distribution STUFF = ChangeLog \ INSTALL \ MACHINES \ MANIFEST \ Makefile \ README \ $(ADDTST)/add_test.dta \ $(TLS)/bitter.dta \ $(TST)/run # Install targets GSM_INSTALL_TARGETS = \ $(GSM_INSTALL_LIB)/libgsm.a \ $(GSM_INSTALL_INC)/gsm.h \ $(GSM_INSTALL_MAN)/gsm.3 \ $(GSM_INSTALL_MAN)/gsm_explode.3 \ $(GSM_INSTALL_MAN)/gsm_option.3 \ $(GSM_INSTALL_MAN)/gsm_print.3 TOAST_INSTALL_TARGETS = \ $(TOAST_INSTALL_BIN)/toast \ $(TOAST_INSTALL_BIN)/tcat \ $(TOAST_INSTALL_BIN)/untoast \ $(TOAST_INSTALL_MAN)/toast.1 # Default rules include $(ASTTOPDIR)/Makefile.rules # Target rules all: $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST) @-echo $(ROOT): Done. tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result @-echo tst: Done. addtst: $(ADDTST)/add $(ADDTST)/add_test.dta $(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null @-echo addtst: Done. misc: $(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger \ $(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod @-echo misc: Done. install: toastinstall gsminstall @-echo install: Done. # The basic API: libgsm $(LIBGSMSO): $(LIB) $(GSM_OBJECTS) $(LD) -o $@.1.0.10 -shared -Xlinker -soname -Xlinker libgsm.so.1 $(GSM_OBJECTS) -lc ln -fs libgsm.so.1.0.10 lib/libgsm.so.1 ln -fs libgsm.so.1.0.10 lib/libgsm.so $(LIBGSM): $(GSM_OBJECTS) $(ECHO_PREFIX) echo " [AR] $^ -> $@" $(CMD_PREFIX) $(AR) cr $@ $^ $(CMD_PREFIX) $(RANLIB) $@ # Toast, Untoast and Tcat -- the compress-like frontends to gsm. $(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSM) $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB) $(UNTOAST): $(BIN) $(TOAST) -rm $(RMFLAGS) $(UNTOAST) $(LN) toast $(UNTOAST) $(TCAT): $(BIN) $(TOAST) -rm $(RMFLAGS) $(TCAT) $(LN) toast $(TCAT) # The local bin and lib directories $(BIN): if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi $(LIB): if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi # Installation gsminstall: -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \ $(MAKE) $(GSM_INSTALL_TARGETS) ; \ fi toastinstall: -if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then \ $(MAKE) $(TOAST_INSTALL_TARGETS); \ fi gsmuninstall: -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \ rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \ fi toastuninstall: -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then \ rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \ fi $(TOAST_INSTALL_BIN)/toast: $(TOAST) -rm $@ cp $(TOAST) $@ chmod 755 $@ $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast -rm $@ ln $? $@ $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast -rm $@ ln $? $@ $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1 -rm $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3 -rm $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3 -rm $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3 -rm $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3 -rm $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h -rm $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM) -rm $@ cp $? $@ chmod 444 $@ # Distribution dist: gsm-1.0.tar.Z @echo dist: Done. gsm-1.0.tar.Z: $(STUFF) $(SOURCES) $(HEADERS) $(MANUALS) ( cd $(ROOT)/..; \ tar cvf - `cat $(ROOT)/gsm-1.0/MANIFEST \ | sed '/^#/d'` \ ) | $(COMPRESS) $(COMPRESSFLAGS) > $(ROOT)/gsm-1.0.tar.Z # Clean uninstall: toastuninstall gsmuninstall @-echo uninstall: Done. semi-clean: -rm $(RMFLAGS) */*.o \ $(TST)/lin2cod $(TST)/lin2txt \ $(TST)/cod2lin $(TST)/cod2txt \ $(TST)/gsm2cod \ $(TST)/*.*.* -$(FIND) . \( -name core -o -name foo \) \ -print | xargs rm $(RMFLAGS) clean: semi-clean -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \ $(TOAST) $(TCAT) $(UNTOAST) \ $(ROOT)/gsm-1.0.tar.Z rm -rf lib rm -f .*.d *.i */*.i # Two tools that helped me generate gsm_encode.c and gsm_decode.c, # but aren't generally needed to port this. $(TLS)/sweet: $(TLS)/sweet.o $(TLS)/taste.o $(LD) $(LFLAGS) -o $(TLS)/sweet \ $(TLS)/sweet.o $(TLS)/taste.o $(LDLIB) $(TLS)/bitter: $(TLS)/bitter.o $(TLS)/taste.o $(LD) $(LFLAGS) -o $(TLS)/bitter \ $(TLS)/bitter.o $(TLS)/taste.o $(LDLIB) # A version of the same family that Jeff Chilton used to implement # the WAV #49 GSM format. $(TLS)/ginger: $(TLS)/ginger.o $(TLS)/taste.o $(LD) $(LFLAGS) -o $(TLS)/ginger \ $(TLS)/ginger.o $(TLS)/taste.o $(LDLIB) $(TLS)/sour: $(TLS)/sour.o $(TLS)/taste.o $(LD) $(LFLAGS) -o $(TLS)/sour \ $(TLS)/sour.o $(TLS)/taste.o $(LDLIB) # Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the # basic arithmetic functions work as intended. $(ADDTST)/add: $(ADDTST)/add_test.o $(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB) # Various conversion programs between linear, text, .gsm and the code # format used by the tests we ran (.cod). We paid for the test data, # so I guess we can't just provide them with this package. Still, # if you happen to have them lying around, here's the code. # # You can use gsm2cod | cod2txt independently to look at what's # coded inside the compressed frames, although this shouldn't be # hard to roll on your own using the gsm_print() function from # the API. $(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run ( cd $(TST); ./run ) $(TST)/lin2txt: $(TST)/lin2txt.o $(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/lin2txt \ $(TST)/lin2txt.o $(LIBGSM) $(LDLIB) $(TST)/lin2cod: $(TST)/lin2cod.o $(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/lin2cod \ $(TST)/lin2cod.o $(LIBGSM) $(LDLIB) $(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/gsm2cod \ $(TST)/gsm2cod.o $(LIBGSM) $(LDLIB) $(TST)/cod2txt: $(TST)/cod2txt.o $(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/cod2txt \ $(TST)/cod2txt.o $(LIBGSM) $(LDLIB) $(TST)/cod2lin: $(TST)/cod2lin.o $(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/cod2lin \ $(TST)/cod2lin.o $(LIBGSM) $(LDLIB) asterisk-11.7.0/codecs/gsm/COPYRIGHT0000644000175000007640000000126210374426007016672 0ustar sharkyjerrywebCopyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, Technische Universitaet Berlin Any use of this software is permitted provided that this notice is not removed and that neither the authors nor the Technische Universitaet Berlin are deemed to have made any representations as to the suitability of this software for any purpose nor are held responsible for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. As a matter of courtesy, the authors request to be informed about uses this software has found, about bugs in this software, and about any improvements that may be of general interest. Berlin, 28.11.1994 Jutta Degener Carsten Bormann asterisk-11.7.0/codecs/gsm/README0000644000175000007640000000320710374426007016260 0ustar sharkyjerryweb GSM 06.10 13 kbit/s RPE/LTP speech compression available -------------------------------------------------------- The Communications and Operating Systems Research Group (KBS) at the Technische Universitaet Berlin is currently working on a set of UNIX-based tools for computer-mediated telecooperation that will be made freely available. As part of this effort we are publishing an implementation of the European GSM 06.10 provisional standard for full-rate speech transcoding, prI-ETS 300 036, which uses RPE/LTP (residual pulse excitation/long term prediction) coding at 13 kbit/s. GSM 06.10 compresses frames of 160 13-bit samples (8 kHz sampling rate, i.e. a frame rate of 50 Hz) into 260 bits; for compatibility with typical UNIX applications, our implementation turns frames of 160 16-bit linear samples into 33-byte frames (1650 Bytes/s). The quality of the algorithm is good enough for reliable speaker recognition; even music often survives transcoding in recognizable form (given the bandwidth limitations of 8 kHz sampling rate). The interfaces offered are a front end modelled after compress(1), and a library API. Compression and decompression run faster than realtime on most SPARCstations. The implementation has been verified against the ETSI standard test patterns. Jutta Degener (jutta@cs.tu-berlin.de) Carsten Bormann (cabo@cs.tu-berlin.de) Communications and Operating Systems Research Group, TU Berlin Fax: +49.30.31425156, Phone: +49.30.31424315 -- Copyright 1992 by Jutta Degener and Carsten Bormann, Technische Universitaet Berlin. See the accompanying file "COPYRIGHT" for details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. asterisk-11.7.0/codecs/codec_resample.c0000644000175000007640000000712312132104742017715 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2011, Digium, Inc. * * Russell Bryant * David Vossel * * 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 Resample slinear audio * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" #include "speex/speex_resampler.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 385582 $") #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/slin.h" #define OUTBUF_SIZE 8096 static struct ast_translator *translators; static int trans_size; static int id_list[] = { AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR12, AST_FORMAT_SLINEAR16, AST_FORMAT_SLINEAR24, AST_FORMAT_SLINEAR32, AST_FORMAT_SLINEAR44, AST_FORMAT_SLINEAR48, AST_FORMAT_SLINEAR96, AST_FORMAT_SLINEAR192, }; static int resamp_new(struct ast_trans_pvt *pvt) { int err; if (!(pvt->pvt = speex_resampler_init(1, ast_format_rate(&pvt->t->src_format), ast_format_rate(&pvt->t->dst_format), 5, &err))) { return -1; } return 0; } static void resamp_destroy(struct ast_trans_pvt *pvt) { SpeexResamplerState *resamp_pvt = pvt->pvt; speex_resampler_destroy(resamp_pvt); } static int resamp_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { SpeexResamplerState *resamp_pvt = pvt->pvt; unsigned int out_samples = (OUTBUF_SIZE / sizeof(int16_t)) - pvt->samples; unsigned int in_samples; if (!f->datalen) { return -1; } in_samples = f->datalen / 2; speex_resampler_process_int(resamp_pvt, 0, f->data.ptr, &in_samples, pvt->outbuf.i16 + pvt->samples, &out_samples); pvt->samples += out_samples; pvt->datalen += out_samples * 2; return 0; } static int unload_module(void) { int res = 0; int idx; for (idx = 0; idx < trans_size; idx++) { res |= ast_unregister_translator(&translators[idx]); } ast_free(translators); return res; } static int load_module(void) { int res = 0; int x, y, idx = 0; trans_size = ARRAY_LEN(id_list) * (ARRAY_LEN(id_list) - 1); if (!(translators = ast_calloc(1, sizeof(struct ast_translator) * trans_size))) { return AST_MODULE_LOAD_FAILURE; } for (x = 0; x < ARRAY_LEN(id_list); x++) { for (y = 0; y < ARRAY_LEN(id_list); y++) { if (x == y) { continue; } translators[idx].newpvt = resamp_new; translators[idx].destroy = resamp_destroy; translators[idx].framein = resamp_framein; translators[idx].desc_size = 0; translators[idx].buffer_samples = (OUTBUF_SIZE / sizeof(int16_t)); translators[idx].buf_size = OUTBUF_SIZE; ast_format_set(&translators[idx].src_format, id_list[x], 0); ast_format_set(&translators[idx].dst_format, id_list[y], 0); snprintf(translators[idx].name, sizeof(translators[idx].name), "slin %dkhz -> %dkhz", ast_format_rate(&translators[idx].src_format), ast_format_rate(&translators[idx].dst_format)); res |= ast_register_translator(&translators[idx]); idx++; } } /* in case ast_register_translator() failed, we call unload_module() and ast_unregister_translator won't fail.*/ if (res) { unload_module(); return AST_MODULE_LOAD_FAILURE; } return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SLIN Resampling Codec"); asterisk-11.7.0/codecs/codec_dahdi.c0000644000175000007640000004324012060463612017162 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * DAHDI native transcoding support * * Copyright (C) 1999 - 2008, Digium, Inc. * * Mark Spencer * Kevin P. Fleming * * 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 Translate between various formats natively through DAHDI transcoding * * \ingroup codecs */ /*** MODULEINFO core dahdi ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 377383 $") #include #include #include #include #include #include #include "asterisk/lock.h" #include "asterisk/translate.h" #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/cli.h" #include "asterisk/channel.h" #include "asterisk/utils.h" #include "asterisk/linkedlists.h" #include "asterisk/ulaw.h" #define BUFFER_SIZE 8000 #define G723_SAMPLES 240 #define G729_SAMPLES 160 #define ULAW_SAMPLES 160 #ifndef DAHDI_FORMAT_MAX_AUDIO #define DAHDI_FORMAT_G723_1 (1 << 0) #define DAHDI_FORMAT_GSM (1 << 1) #define DAHDI_FORMAT_ULAW (1 << 2) #define DAHDI_FORMAT_ALAW (1 << 3) #define DAHDI_FORMAT_G726 (1 << 4) #define DAHDI_FORMAT_ADPCM (1 << 5) #define DAHDI_FORMAT_SLINEAR (1 << 6) #define DAHDI_FORMAT_LPC10 (1 << 7) #define DAHDI_FORMAT_G729A (1 << 8) #define DAHDI_FORMAT_SPEEX (1 << 9) #define DAHDI_FORMAT_ILBC (1 << 10) #endif static struct channel_usage { int total; int encoders; int decoders; } channels; static char *handle_cli_transcoder_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static struct ast_cli_entry cli[] = { AST_CLI_DEFINE(handle_cli_transcoder_show, "Display DAHDI transcoder utilization.") }; struct format_map { unsigned int map[32][32]; }; static struct format_map global_format_map = { { { 0 } } }; struct translator { struct ast_translator t; AST_LIST_ENTRY(translator) entry; }; static AST_LIST_HEAD_STATIC(translators, translator); struct codec_dahdi_pvt { int fd; struct dahdi_transcoder_formats fmts; unsigned int softslin:1; unsigned int fake:2; uint16_t required_samples; uint16_t samples_in_buffer; uint16_t samples_written_to_hardware; uint8_t ulaw_buffer[1024]; }; /* Only used by a decoder */ static int ulawtolin(struct ast_trans_pvt *pvt, int samples) { struct codec_dahdi_pvt *dahdip = pvt->pvt; int i = samples; uint8_t *src = &dahdip->ulaw_buffer[0]; int16_t *dst = pvt->outbuf.i16 + pvt->datalen; /* convert and copy in outbuf */ while (i--) { *dst++ = AST_MULAW(*src++); } return 0; } /* Only used by an encoder. */ static int lintoulaw(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct codec_dahdi_pvt *dahdip = pvt->pvt; int i = f->samples; uint8_t *dst = &dahdip->ulaw_buffer[dahdip->samples_in_buffer]; int16_t *src = f->data.ptr; if (dahdip->samples_in_buffer + i > sizeof(dahdip->ulaw_buffer)) { ast_log(LOG_ERROR, "Out of buffer space!\n"); return -i; } while (i--) { *dst++ = AST_LIN2MU(*src++); } dahdip->samples_in_buffer += f->samples; return 0; } static char *handle_cli_transcoder_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct channel_usage copy; switch (cmd) { case CLI_INIT: e->command = "transcoder show"; e->usage = "Usage: transcoder show\n" " Displays channel utilization of DAHDI transcoder(s).\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != 2) return CLI_SHOWUSAGE; copy = channels; if (copy.total == 0) ast_cli(a->fd, "No DAHDI transcoders found.\n"); else ast_cli(a->fd, "%d/%d encoders/decoders of %d channels are in use.\n", copy.encoders, copy.decoders, copy.total); return CLI_SUCCESS; } static void dahdi_write_frame(struct codec_dahdi_pvt *dahdip, const uint8_t *buffer, const ssize_t count) { int res; if (!count) return; res = write(dahdip->fd, buffer, count); if (-1 == res) { ast_log(LOG_ERROR, "Failed to write to transcoder: %s\n", strerror(errno)); } if (count != res) { ast_log(LOG_ERROR, "Requested write of %zd bytes, but only wrote %d bytes.\n", count, res); } } static int dahdi_encoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct codec_dahdi_pvt *dahdip = pvt->pvt; if (!f->subclass.format.id) { /* We're just faking a return for calculation purposes. */ dahdip->fake = 2; pvt->samples = f->samples; return 0; } /* Buffer up the packets and send them to the hardware if we * have enough samples set up. */ if (dahdip->softslin) { if (lintoulaw(pvt, f)) { return -1; } } else { /* NOTE: If softslin support is not needed, and the sample * size is equal to the required sample size, we wouldn't * need this copy operation. But at the time this was * written, only softslin is supported. */ if (dahdip->samples_in_buffer + f->samples > sizeof(dahdip->ulaw_buffer)) { ast_log(LOG_ERROR, "Out of buffer space.\n"); return -1; } memcpy(&dahdip->ulaw_buffer[dahdip->samples_in_buffer], f->data.ptr, f->samples); dahdip->samples_in_buffer += f->samples; } while (dahdip->samples_in_buffer >= dahdip->required_samples) { dahdi_write_frame(dahdip, dahdip->ulaw_buffer, dahdip->required_samples); dahdip->samples_written_to_hardware += dahdip->required_samples; dahdip->samples_in_buffer -= dahdip->required_samples; if (dahdip->samples_in_buffer) { /* Shift any remaining bytes down. */ memmove(dahdip->ulaw_buffer, &dahdip->ulaw_buffer[dahdip->required_samples], dahdip->samples_in_buffer); } } pvt->samples += f->samples; pvt->datalen = 0; return -1; } static void dahdi_wait_for_packet(int fd) { struct pollfd p = {0}; p.fd = fd; p.events = POLLIN; poll(&p, 1, 10); } static struct ast_frame *dahdi_encoder_frameout(struct ast_trans_pvt *pvt) { struct codec_dahdi_pvt *dahdip = pvt->pvt; int res; if (2 == dahdip->fake) { dahdip->fake = 1; pvt->f.frametype = AST_FRAME_VOICE; ast_format_clear(&pvt->f.subclass.format); pvt->f.samples = dahdip->required_samples; pvt->f.data.ptr = NULL; pvt->f.offset = 0; pvt->f.datalen = 0; pvt->f.mallocd = 0; pvt->samples = 0; return ast_frisolate(&pvt->f); } else if (1 == dahdip->fake) { dahdip->fake = 0; return NULL; } if (dahdip->samples_written_to_hardware >= dahdip->required_samples) { dahdi_wait_for_packet(dahdip->fd); } res = read(dahdip->fd, pvt->outbuf.c + pvt->datalen, pvt->t->buf_size - pvt->datalen); if (-1 == res) { if (EWOULDBLOCK == errno) { /* Nothing waiting... */ return NULL; } else { ast_log(LOG_ERROR, "Failed to read from transcoder: %s\n", strerror(errno)); return NULL; } } else { pvt->f.datalen = res; pvt->f.frametype = AST_FRAME_VOICE; ast_format_copy(&pvt->f.subclass.format, &pvt->t->dst_format); pvt->f.mallocd = 0; pvt->f.offset = AST_FRIENDLY_OFFSET; pvt->f.src = pvt->t->name; pvt->f.data.ptr = pvt->outbuf.c; pvt->f.samples = ast_codec_get_samples(&pvt->f); dahdip->samples_written_to_hardware = (dahdip->samples_written_to_hardware >= pvt->f.samples) ? dahdip->samples_written_to_hardware - pvt->f.samples : 0; pvt->samples = 0; pvt->datalen = 0; return ast_frisolate(&pvt->f); } /* Shouldn't get here... */ return NULL; } static int dahdi_decoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct codec_dahdi_pvt *dahdip = pvt->pvt; if (!f->subclass.format.id) { /* We're just faking a return for calculation purposes. */ dahdip->fake = 2; pvt->samples = f->samples; return 0; } if (!f->datalen) { if (f->samples != dahdip->required_samples) { ast_log(LOG_ERROR, "%d != %d %d\n", f->samples, dahdip->required_samples, f->datalen); } } dahdi_write_frame(dahdip, f->data.ptr, f->datalen); dahdip->samples_written_to_hardware += f->samples; pvt->samples += f->samples; pvt->datalen = 0; return -1; } static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt) { int res; struct codec_dahdi_pvt *dahdip = pvt->pvt; if (2 == dahdip->fake) { dahdip->fake = 1; pvt->f.frametype = AST_FRAME_VOICE; ast_format_clear(&pvt->f.subclass.format); pvt->f.samples = dahdip->required_samples; pvt->f.data.ptr = NULL; pvt->f.offset = 0; pvt->f.datalen = 0; pvt->f.mallocd = 0; pvt->samples = 0; return ast_frisolate(&pvt->f); } else if (1 == dahdip->fake) { pvt->samples = 0; dahdip->fake = 0; return NULL; } if (dahdip->samples_written_to_hardware >= ULAW_SAMPLES) { dahdi_wait_for_packet(dahdip->fd); } /* Let's check to see if there is a new frame for us.... */ if (dahdip->softslin) { res = read(dahdip->fd, dahdip->ulaw_buffer, sizeof(dahdip->ulaw_buffer)); } else { res = read(dahdip->fd, pvt->outbuf.c + pvt->datalen, pvt->t->buf_size - pvt->datalen); } if (-1 == res) { if (EWOULDBLOCK == errno) { /* Nothing waiting... */ return NULL; } else { ast_log(LOG_ERROR, "Failed to read from transcoder: %s\n", strerror(errno)); return NULL; } } else { if (dahdip->softslin) { ulawtolin(pvt, res); pvt->f.datalen = res * 2; } else { pvt->f.datalen = res; } pvt->datalen = 0; pvt->f.frametype = AST_FRAME_VOICE; ast_format_copy(&pvt->f.subclass.format, &pvt->t->dst_format); pvt->f.mallocd = 0; pvt->f.offset = AST_FRIENDLY_OFFSET; pvt->f.src = pvt->t->name; pvt->f.data.ptr = pvt->outbuf.c; pvt->f.samples = res; pvt->samples = 0; dahdip->samples_written_to_hardware = (dahdip->samples_written_to_hardware >= res) ? dahdip->samples_written_to_hardware - res : 0; return ast_frisolate(&pvt->f); } /* Shouldn't get here... */ return NULL; } static void dahdi_destroy(struct ast_trans_pvt *pvt) { struct codec_dahdi_pvt *dahdip = pvt->pvt; switch (ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) { case AST_FORMAT_G729A: case AST_FORMAT_G723_1: ast_atomic_fetchadd_int(&channels.encoders, -1); break; default: ast_atomic_fetchadd_int(&channels.decoders, -1); break; } close(dahdip->fd); } static int dahdi_translate(struct ast_trans_pvt *pvt, struct ast_format *dst_format, struct ast_format *src_format) { /* Request translation through zap if possible */ int fd; struct codec_dahdi_pvt *dahdip = pvt->pvt; int flags; int tried_once = 0; const char *dev_filename = "/dev/dahdi/transcode"; if ((fd = open(dev_filename, O_RDWR)) < 0) { ast_log(LOG_ERROR, "Failed to open %s: %s\n", dev_filename, strerror(errno)); return -1; } dahdip->fmts.srcfmt = ast_format_to_old_bitfield(src_format); dahdip->fmts.dstfmt = ast_format_to_old_bitfield(dst_format); ast_debug(1, "Opening transcoder channel from %s to %s.\n", ast_getformatname(src_format), ast_getformatname(dst_format)); retry: if (ioctl(fd, DAHDI_TC_ALLOCATE, &dahdip->fmts)) { if ((ENODEV == errno) && !tried_once) { /* We requested to translate to/from an unsupported * format. Most likely this is because signed linear * was not supported by any hardware devices even * though this module always registers signed linear * support. In this case we'll retry, requesting * support for ULAW instead of signed linear and then * we'll just convert from ulaw to signed linear in * software. */ if (AST_FORMAT_SLINEAR == ast_format_id_from_old_bitfield(dahdip->fmts.srcfmt)) { ast_debug(1, "Using soft_slin support on source\n"); dahdip->softslin = 1; dahdip->fmts.srcfmt = ast_format_id_to_old_bitfield(AST_FORMAT_ULAW); } else if (AST_FORMAT_SLINEAR == ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) { ast_debug(1, "Using soft_slin support on destination\n"); dahdip->softslin = 1; dahdip->fmts.dstfmt = ast_format_id_to_old_bitfield(AST_FORMAT_ULAW); } tried_once = 1; goto retry; } ast_log(LOG_ERROR, "Unable to attach to transcoder: %s\n", strerror(errno)); close(fd); return -1; } flags = fcntl(fd, F_GETFL); if (flags > - 1) { if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) ast_log(LOG_WARNING, "Could not set non-block mode!\n"); } dahdip->fd = fd; dahdip->required_samples = ((dahdip->fmts.dstfmt|dahdip->fmts.srcfmt) & (ast_format_id_to_old_bitfield(AST_FORMAT_G723_1))) ? G723_SAMPLES : G729_SAMPLES; switch (ast_format_id_from_old_bitfield(dahdip->fmts.dstfmt)) { case AST_FORMAT_G729A: ast_atomic_fetchadd_int(&channels.encoders, +1); break; case AST_FORMAT_G723_1: ast_atomic_fetchadd_int(&channels.encoders, +1); break; default: ast_atomic_fetchadd_int(&channels.decoders, +1); break; } return 0; } static int dahdi_new(struct ast_trans_pvt *pvt) { return dahdi_translate(pvt, &pvt->t->dst_format, &pvt->t->src_format); } static struct ast_frame *fakesrc_sample(void) { /* Don't bother really trying to test hardware ones. */ static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .samples = 160, .src = __PRETTY_FUNCTION__ }; return &f; } static int is_encoder(struct translator *zt) { if ((zt->t.src_format.id == AST_FORMAT_ULAW) || (zt->t.src_format.id == AST_FORMAT_ALAW) || (zt->t.src_format.id == AST_FORMAT_SLINEAR)) { return 1; } else { return 0; } } static int register_translator(int dst, int src) { struct translator *zt; int res; struct ast_format dst_format; struct ast_format src_format; ast_format_from_old_bitfield(&dst_format, (1 << dst)); ast_format_from_old_bitfield(&src_format, (1 << src)); if (!(zt = ast_calloc(1, sizeof(*zt)))) { return -1; } snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s", ast_getformatname(&src_format), ast_getformatname(&dst_format)); ast_format_copy(&zt->t.src_format, &src_format); ast_format_copy(&zt->t.dst_format, &dst_format); zt->t.buf_size = BUFFER_SIZE; if (is_encoder(zt)) { zt->t.framein = dahdi_encoder_framein; zt->t.frameout = dahdi_encoder_frameout; } else { zt->t.framein = dahdi_decoder_framein; zt->t.frameout = dahdi_decoder_frameout; } zt->t.destroy = dahdi_destroy; zt->t.buffer_samples = 0; zt->t.newpvt = dahdi_new; zt->t.sample = fakesrc_sample; zt->t.native_plc = 0; zt->t.desc_size = sizeof(struct codec_dahdi_pvt); if ((res = ast_register_translator(&zt->t))) { ast_free(zt); return -1; } AST_LIST_LOCK(&translators); AST_LIST_INSERT_HEAD(&translators, zt, entry); AST_LIST_UNLOCK(&translators); global_format_map.map[dst][src] = 1; return res; } static void drop_translator(int dst, int src) { struct translator *cur; AST_LIST_LOCK(&translators); AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) { if (cur->t.src_format.id != ast_format_id_from_old_bitfield((1 << src))) continue; if (cur->t.dst_format.id != ast_format_id_from_old_bitfield((1 << dst))) continue; AST_LIST_REMOVE_CURRENT(entry); ast_unregister_translator(&cur->t); ast_free(cur); global_format_map.map[dst][src] = 0; break; } AST_LIST_TRAVERSE_SAFE_END; AST_LIST_UNLOCK(&translators); } static void unregister_translators(void) { struct translator *cur; AST_LIST_LOCK(&translators); while ((cur = AST_LIST_REMOVE_HEAD(&translators, entry))) { ast_unregister_translator(&cur->t); ast_free(cur); } AST_LIST_UNLOCK(&translators); } static void build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts) { unsigned int src, dst; for (src = 0; src < 32; src++) { for (dst = 0; dst < 32; dst++) { if (!(srcfmts & (1 << src))) continue; if (!(dstfmts & (1 << dst))) continue; if (global_format_map.map[dst][src]) continue; if (!register_translator(dst, src)) map->map[dst][src] = 1; } } } static int find_transcoders(void) { struct dahdi_transcoder_info info = { 0, }; struct format_map map = { { { 0 } } }; int fd; unsigned int x, y; if ((fd = open("/dev/dahdi/transcode", O_RDWR)) < 0) { ast_log(LOG_ERROR, "Failed to open /dev/dahdi/transcode: %s\n", strerror(errno)); return 0; } for (info.tcnum = 0; !ioctl(fd, DAHDI_TC_GETINFO, &info); info.tcnum++) { ast_verb(2, "Found transcoder '%s'.\n", info.name); /* Complex codecs need to support signed linear. If the * hardware transcoder does not natively support signed linear * format, we will emulate it in software directly in this * module. Also, do not allow direct ulaw/alaw to complex * codec translation, since that will prevent the generic PLC * functions from working. */ if (info.dstfmts & (DAHDI_FORMAT_ULAW | DAHDI_FORMAT_ALAW)) { info.dstfmts |= DAHDI_FORMAT_SLINEAR; info.dstfmts &= ~(DAHDI_FORMAT_ULAW | DAHDI_FORMAT_ALAW); } if (info.srcfmts & (DAHDI_FORMAT_ULAW | DAHDI_FORMAT_ALAW)) { info.srcfmts |= DAHDI_FORMAT_SLINEAR; info.srcfmts &= ~(DAHDI_FORMAT_ULAW | DAHDI_FORMAT_ALAW); } build_translators(&map, info.dstfmts, info.srcfmts); ast_atomic_fetchadd_int(&channels.total, info.numchannels / 2); } close(fd); if (!info.tcnum) { ast_verb(2, "No hardware transcoders found.\n"); } for (x = 0; x < 32; x++) { for (y = 0; y < 32; y++) { if (!map.map[x][y] && global_format_map.map[x][y]) drop_translator(x, y); } } return 0; } static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { ast_cli_unregister_multiple(cli, ARRAY_LEN(cli)); unregister_translators(); return 0; } static int load_module(void) { ast_ulaw_init(); find_transcoders(); ast_cli_register_multiple(cli, ARRAY_LEN(cli)); return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generic DAHDI Transcoder Codec Translator", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/codec_a_mu.c0000644000175000007640000000607411607650606017045 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 codec_a_mu.c - translate between alaw and ulaw directly * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/alaw.h" #include "asterisk/ulaw.h" #include "asterisk/utils.h" #define BUFFER_SAMPLES 8000 /* size for the translation buffers */ static unsigned char mu2a[256]; static unsigned char a2mu[256]; /* Sample frame data */ #include "ex_ulaw.h" #include "ex_alaw.h" /*! \brief convert frame data and store into the buffer */ static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int x = f->samples; unsigned char *src = f->data.ptr; unsigned char *dst = pvt->outbuf.uc + pvt->samples; pvt->samples += x; pvt->datalen += x; while (x--) *dst++ = a2mu[*src++]; return 0; } /*! \brief convert frame data and store into the buffer */ static int ulawtoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int x = f->samples; unsigned char *src = f->data.ptr; unsigned char *dst = pvt->outbuf.uc + pvt->samples; pvt->samples += x; pvt->datalen += x; while (x--) *dst++ = mu2a[*src++]; return 0; } static struct ast_translator alawtoulaw = { .name = "alawtoulaw", .framein = alawtoulaw_framein, .sample = alaw_sample, .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES, }; static struct ast_translator ulawtoalaw = { .name = "ulawtoalaw", .framein = ulawtoalaw_framein, .sample = ulaw_sample, .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES, }; /*! \brief standard module glue */ static int unload_module(void) { int res; res = ast_unregister_translator(&ulawtoalaw); res |= ast_unregister_translator(&alawtoulaw); return res; } static int load_module(void) { int res; int x; ast_format_set(&alawtoulaw.src_format, AST_FORMAT_ALAW, 0); ast_format_set(&alawtoulaw.dst_format, AST_FORMAT_ULAW, 0); ast_format_set(&ulawtoalaw.src_format, AST_FORMAT_ULAW, 0); ast_format_set(&ulawtoalaw.dst_format, AST_FORMAT_ALAW, 0); for (x=0;x<256;x++) { mu2a[x] = AST_LIN2A(AST_MULAW(x)); a2mu[x] = AST_LIN2MU(AST_ALAW(x)); } res = ast_register_translator(&alawtoulaw); if (!res) res = ast_register_translator(&ulawtoalaw); else ast_unregister_translator(&alawtoulaw); if (res) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "A-law and Mulaw direct Coder/Decoder"); asterisk-11.7.0/codecs/codec_ulaw.c0000644000175000007640000000777411607650606017104 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 codec_ulaw.c - translate between signed linear and ulaw * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/translate.h" #include "asterisk/ulaw.h" #include "asterisk/utils.h" #define BUFFER_SAMPLES 8096 /* size for the translation buffers */ /* Sample frame data */ #include "asterisk/slin.h" #include "ex_ulaw.h" /*! \brief convert and store samples in outbuf */ static int ulawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; unsigned char *src = f->data.ptr; int16_t *dst = pvt->outbuf.i16 + pvt->samples; pvt->samples += i; pvt->datalen += i * 2; /* 2 bytes/sample */ /* convert and copy in outbuf */ while (i--) *dst++ = AST_MULAW(*src++); return 0; } /*! \brief convert and store samples in outbuf */ static int lintoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; char *dst = pvt->outbuf.c + pvt->samples; int16_t *src = f->data.ptr; pvt->samples += i; pvt->datalen += i; /* 1 byte/sample */ while (i--) *dst++ = AST_LIN2MU(*src++); return 0; } /*! * \brief The complete translator for ulawToLin. */ static struct ast_translator ulawtolin = { .name = "ulawtolin", .framein = ulawtolin_framein, .sample = ulaw_sample, .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, }; static struct ast_translator testlawtolin = { .name = "testlawtolin", .framein = ulawtolin_framein, .sample = ulaw_sample, .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, }; /*! * \brief The complete translator for LinToulaw. */ static struct ast_translator lintoulaw = { .name = "lintoulaw", .framein = lintoulaw_framein, .sample = slin8_sample, .buf_size = BUFFER_SAMPLES, .buffer_samples = BUFFER_SAMPLES, }; static struct ast_translator lintotestlaw = { .name = "lintotestlaw", .framein = lintoulaw_framein, .sample = slin8_sample, .buf_size = BUFFER_SAMPLES, .buffer_samples = BUFFER_SAMPLES, }; static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res; res = ast_unregister_translator(&lintoulaw); res |= ast_unregister_translator(&ulawtolin); res |= ast_unregister_translator(&testlawtolin); res |= ast_unregister_translator(&lintotestlaw); return res; } static int load_module(void) { int res; ast_format_set(&lintoulaw.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintoulaw.dst_format, AST_FORMAT_ULAW, 0); ast_format_set(&lintotestlaw.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintotestlaw.dst_format, AST_FORMAT_TESTLAW, 0); ast_format_set(&ulawtolin.src_format, AST_FORMAT_ULAW, 0); ast_format_set(&ulawtolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&testlawtolin.src_format, AST_FORMAT_TESTLAW, 0); ast_format_set(&testlawtolin.dst_format, AST_FORMAT_SLINEAR, 0); res = ast_register_translator(&ulawtolin); if (!res) { res = ast_register_translator(&lintoulaw); res |= ast_register_translator(&lintotestlaw); res |= ast_register_translator(&testlawtolin); } else ast_unregister_translator(&ulawtolin); if (res) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "mu-Law Coder/Decoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/codec_ilbc.c0000644000175000007640000001400312077304750017022 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * The iLBC code is from The IETF code base and is copyright The Internet Society (2004) * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Translate between signed linear and Internet Low Bitrate Codec * * \ingroup codecs */ /*** MODULEINFO ilbc core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 379719 $") #include "asterisk/translate.h" #include "asterisk/module.h" #include "asterisk/utils.h" #ifdef ILBC_WEBRTC #include typedef WebRtc_UWord16 ilbc_bytes; typedef WebRtc_Word16 ilbc_block; #define BUF_TYPE i16 #else #include "ilbc/iLBC_encode.h" #include "ilbc/iLBC_decode.h" typedef unsigned char ilbc_bytes; typedef float ilbc_block; #define BUF_TYPE uc #endif #define USE_ILBC_ENHANCER 0 #define ILBC_MS 30 /* #define ILBC_MS 20 */ #define ILBC_FRAME_LEN 50 /* apparently... */ #define ILBC_SAMPLES 240 /* 30ms at 8000 hz */ #define BUFFER_SAMPLES 8000 /* Sample frame data */ #include "asterisk/slin.h" #include "ex_ilbc.h" struct ilbc_coder_pvt { iLBC_Enc_Inst_t enc; iLBC_Dec_Inst_t dec; /* Enough to store a full second */ int16_t buf[BUFFER_SAMPLES]; }; static int lintoilbc_new(struct ast_trans_pvt *pvt) { struct ilbc_coder_pvt *tmp = pvt->pvt; initEncode(&tmp->enc, ILBC_MS); return 0; } static int ilbctolin_new(struct ast_trans_pvt *pvt) { struct ilbc_coder_pvt *tmp = pvt->pvt; initDecode(&tmp->dec, ILBC_MS, USE_ILBC_ENHANCER); return 0; } /*! \brief decode a frame and store in outbuf */ static int ilbctolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct ilbc_coder_pvt *tmp = pvt->pvt; int plc_mode = 1; /* 1 = normal data, 0 = plc */ /* Assuming there's space left, decode into the current buffer at the tail location. Read in as many frames as there are */ int x,i; int datalen = f->datalen; int16_t *dst = pvt->outbuf.i16; ilbc_block tmpf[ILBC_SAMPLES]; if (!f->data.ptr && datalen) { ast_debug(1, "issue 16070, ILIB ERROR. data = NULL datalen = %d src = %s\n", datalen, f->src ? f->src : "no src set"); f->datalen = 0; datalen = 0; } if (datalen == 0) { /* native PLC, set fake datalen and clear plc_mode */ datalen = ILBC_FRAME_LEN; f->samples = ILBC_SAMPLES; plc_mode = 0; /* do native plc */ pvt->samples += ILBC_SAMPLES; } if (datalen % ILBC_FRAME_LEN) { ast_log(LOG_WARNING, "Huh? An ilbc frame that isn't a multiple of 50 bytes long from %s (%d)?\n", f->src, datalen); return -1; } for (x=0; x < datalen ; x += ILBC_FRAME_LEN) { if (pvt->samples + ILBC_SAMPLES > BUFFER_SAMPLES) { ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } iLBC_decode(tmpf, plc_mode ? f->data.ptr + x : NULL, &tmp->dec, plc_mode); for ( i=0; i < ILBC_SAMPLES; i++) dst[pvt->samples + i] = tmpf[i]; pvt->samples += ILBC_SAMPLES; pvt->datalen += 2*ILBC_SAMPLES; } return 0; } /*! \brief store a frame into a temporary buffer, for later decoding */ static int lintoilbc_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct ilbc_coder_pvt *tmp = pvt->pvt; /* Just add the frames to our stream */ /* XXX We should look at how old the rest of our stream is, and if it is too old, then we should overwrite it entirely, otherwise we can get artifacts of earlier talk that do not belong */ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } /*! \brief encode the temporary buffer and generate a frame */ static struct ast_frame *lintoilbc_frameout(struct ast_trans_pvt *pvt) { struct ilbc_coder_pvt *tmp = pvt->pvt; int datalen = 0; int samples = 0; /* We can't work on anything less than a frame in size */ if (pvt->samples < ILBC_SAMPLES) return NULL; while (pvt->samples >= ILBC_SAMPLES) { ilbc_block tmpf[ILBC_SAMPLES]; int i; /* Encode a frame of data */ for (i = 0 ; i < ILBC_SAMPLES ; i++) tmpf[i] = tmp->buf[samples + i]; iLBC_encode( (ilbc_bytes*)pvt->outbuf.BUF_TYPE + datalen, tmpf, &tmp->enc); datalen += ILBC_FRAME_LEN; samples += ILBC_SAMPLES; pvt->samples -= ILBC_SAMPLES; } /* Move the data at the end of the buffer to the front */ if (pvt->samples) memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); return ast_trans_frameout(pvt, datalen, samples); } static struct ast_translator ilbctolin = { .name = "ilbctolin", .newpvt = ilbctolin_new, .framein = ilbctolin_framein, .sample = ilbc_sample, .desc_size = sizeof(struct ilbc_coder_pvt), .buf_size = BUFFER_SAMPLES * 2, .native_plc = 1, }; static struct ast_translator lintoilbc = { .name = "lintoilbc", .newpvt = lintoilbc_new, .framein = lintoilbc_framein, .frameout = lintoilbc_frameout, .sample = slin8_sample, .desc_size = sizeof(struct ilbc_coder_pvt), .buf_size = (BUFFER_SAMPLES * ILBC_FRAME_LEN + ILBC_SAMPLES - 1) / ILBC_SAMPLES, }; static int unload_module(void) { int res; res = ast_unregister_translator(&lintoilbc); res |= ast_unregister_translator(&ilbctolin); return res; } static int load_module(void) { int res; ast_format_set(&ilbctolin.src_format, AST_FORMAT_ILBC, 0); ast_format_set(&ilbctolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintoilbc.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintoilbc.dst_format, AST_FORMAT_ILBC, 0); res = ast_register_translator(&ilbctolin); if (!res) res=ast_register_translator(&lintoilbc); else ast_unregister_translator(&ilbctolin); if (res) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "iLBC Coder/Decoder"); asterisk-11.7.0/codecs/codec_speex.c0000644000175000007640000004243511607650606017251 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * * 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 Translate between signed linear and Speex (Open Codec) * * \note This work was motivated by Jeremy McNamara * hacked to be configurable by anthm and bkw 9/28/2004 * * \ingroup codecs * * \extref The Speex library - http://www.speex.org * */ /*** MODULEINFO speex speex_preprocess speexdsp core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include /* We require a post 1.1.8 version of Speex to enable preprocessing and better type handling */ #ifdef _SPEEX_TYPES_H #include #endif #include "asterisk/translate.h" #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/utils.h" /* codec variables */ static int quality = 3; static int complexity = 2; static int enhancement = 0; static int vad = 0; static int vbr = 0; static float vbr_quality = 4; static int abr = 0; static int dtx = 0; /* set to 1 to enable silence detection */ static int preproc = 0; static int pp_vad = 0; static int pp_agc = 0; static float pp_agc_level = 8000; /* XXX what is this 8000 ? */ static int pp_denoise = 0; static int pp_dereverb = 0; static float pp_dereverb_decay = 0.4; static float pp_dereverb_level = 0.3; #define TYPE_SILENCE 0x2 #define TYPE_HIGH 0x0 #define TYPE_LOW 0x1 #define TYPE_MASK 0x3 #define BUFFER_SAMPLES 8000 #define SPEEX_SAMPLES 160 /* Sample frame data */ #include "asterisk/slin.h" #include "ex_speex.h" struct speex_coder_pvt { void *speex; SpeexBits bits; int framesize; int silent_state; #ifdef _SPEEX_TYPES_H SpeexPreprocessState *pp; spx_int16_t buf[BUFFER_SAMPLES]; #else int16_t buf[BUFFER_SAMPLES]; /* input, waiting to be compressed */ #endif }; static int speex_encoder_construct(struct ast_trans_pvt *pvt, const SpeexMode *profile, int sampling_rate) { struct speex_coder_pvt *tmp = pvt->pvt; if (!(tmp->speex = speex_encoder_init(profile))) return -1; speex_bits_init(&tmp->bits); speex_bits_reset(&tmp->bits); speex_encoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize); speex_encoder_ctl(tmp->speex, SPEEX_SET_COMPLEXITY, &complexity); #ifdef _SPEEX_TYPES_H if (preproc) { tmp->pp = speex_preprocess_state_init(tmp->framesize, sampling_rate); speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_VAD, &pp_vad); speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_AGC, &pp_agc); speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_AGC_LEVEL, &pp_agc_level); speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DENOISE, &pp_denoise); speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB, &pp_dereverb); speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &pp_dereverb_decay); speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &pp_dereverb_level); } #endif if (!abr && !vbr) { speex_encoder_ctl(tmp->speex, SPEEX_SET_QUALITY, &quality); if (vad) speex_encoder_ctl(tmp->speex, SPEEX_SET_VAD, &vad); } if (vbr) { speex_encoder_ctl(tmp->speex, SPEEX_SET_VBR, &vbr); speex_encoder_ctl(tmp->speex, SPEEX_SET_VBR_QUALITY, &vbr_quality); } if (abr) speex_encoder_ctl(tmp->speex, SPEEX_SET_ABR, &abr); if (dtx) speex_encoder_ctl(tmp->speex, SPEEX_SET_DTX, &dtx); tmp->silent_state = 0; return 0; } static int lintospeex_new(struct ast_trans_pvt *pvt) { return speex_encoder_construct(pvt, &speex_nb_mode, 8000); } static int lin16tospeexwb_new(struct ast_trans_pvt *pvt) { return speex_encoder_construct(pvt, &speex_wb_mode, 16000); } static int lin32tospeexuwb_new(struct ast_trans_pvt *pvt) { return speex_encoder_construct(pvt, &speex_uwb_mode, 32000); } static int speex_decoder_construct(struct ast_trans_pvt *pvt, const SpeexMode *profile) { struct speex_coder_pvt *tmp = pvt->pvt; if (!(tmp->speex = speex_decoder_init(profile))) return -1; speex_bits_init(&tmp->bits); speex_decoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize); if (enhancement) speex_decoder_ctl(tmp->speex, SPEEX_SET_ENH, &enhancement); return 0; } static int speextolin_new(struct ast_trans_pvt *pvt) { return speex_decoder_construct(pvt, &speex_nb_mode); } static int speexwbtolin16_new(struct ast_trans_pvt *pvt) { return speex_decoder_construct(pvt, &speex_wb_mode); } static int speexuwbtolin32_new(struct ast_trans_pvt *pvt) { return speex_decoder_construct(pvt, &speex_uwb_mode); } /*! \brief convert and store into outbuf */ static int speextolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct speex_coder_pvt *tmp = pvt->pvt; /* Assuming there's space left, decode into the current buffer at the tail location. Read in as many frames as there are */ int x; int res; int16_t *dst = pvt->outbuf.i16; /* XXX fout is a temporary buffer, may have different types */ #ifdef _SPEEX_TYPES_H spx_int16_t fout[1024]; #else float fout[1024]; #endif if (f->datalen == 0) { /* Native PLC interpolation */ if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) { ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } #ifdef _SPEEX_TYPES_H speex_decode_int(tmp->speex, NULL, dst + pvt->samples); #else speex_decode(tmp->speex, NULL, fout); for (x=0;xframesize;x++) { dst[pvt->samples + x] = (int16_t)fout[x]; } #endif pvt->samples += tmp->framesize; pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */ return 0; } /* Read in bits */ speex_bits_read_from(&tmp->bits, f->data.ptr, f->datalen); for (;;) { #ifdef _SPEEX_TYPES_H res = speex_decode_int(tmp->speex, &tmp->bits, fout); #else res = speex_decode(tmp->speex, &tmp->bits, fout); #endif if (res < 0) break; if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) { ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } for (x = 0 ; x < tmp->framesize; x++) dst[pvt->samples + x] = (int16_t)fout[x]; pvt->samples += tmp->framesize; pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */ } return 0; } /*! \brief store input frame in work buffer */ static int lintospeex_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct speex_coder_pvt *tmp = pvt->pvt; /* XXX We should look at how old the rest of our stream is, and if it is too old, then we should overwrite it entirely, otherwise we can get artifacts of earlier talk that do not belong */ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } /*! \brief convert work buffer and produce output frame */ static struct ast_frame *lintospeex_frameout(struct ast_trans_pvt *pvt) { struct speex_coder_pvt *tmp = pvt->pvt; int is_speech=1; int datalen = 0; /* output bytes */ int samples = 0; /* output samples */ /* We can't work on anything less than a frame in size */ if (pvt->samples < tmp->framesize) return NULL; speex_bits_reset(&tmp->bits); while (pvt->samples >= tmp->framesize) { #ifdef _SPEEX_TYPES_H /* Preprocess audio */ if (preproc) is_speech = speex_preprocess(tmp->pp, tmp->buf + samples, NULL); /* Encode a frame of data */ if (is_speech) { /* If DTX enabled speex_encode returns 0 during silence */ is_speech = speex_encode_int(tmp->speex, tmp->buf + samples, &tmp->bits) || !dtx; } else { /* 5 zeros interpreted by Speex as silence (submode 0) */ speex_bits_pack(&tmp->bits, 0, 5); } #else { float fbuf[1024]; int x; /* Convert to floating point */ for (x = 0; x < tmp->framesize; x++) fbuf[x] = tmp->buf[samples + x]; /* Encode a frame of data */ is_speech = speex_encode(tmp->speex, fbuf, &tmp->bits) || !dtx; } #endif samples += tmp->framesize; pvt->samples -= tmp->framesize; } /* Move the data at the end of the buffer to the front */ if (pvt->samples) memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); /* Use AST_FRAME_CNG to signify the start of any silence period */ if (is_speech) { tmp->silent_state = 0; } else { if (tmp->silent_state) { return NULL; } else { tmp->silent_state = 1; speex_bits_reset(&tmp->bits); memset(&pvt->f, 0, sizeof(pvt->f)); pvt->f.frametype = AST_FRAME_CNG; pvt->f.samples = samples; /* XXX what now ? format etc... */ } } /* Terminate bit stream */ speex_bits_pack(&tmp->bits, 15, 5); datalen = speex_bits_write(&tmp->bits, pvt->outbuf.c, pvt->t->buf_size); return ast_trans_frameout(pvt, datalen, samples); } static void speextolin_destroy(struct ast_trans_pvt *arg) { struct speex_coder_pvt *pvt = arg->pvt; speex_decoder_destroy(pvt->speex); speex_bits_destroy(&pvt->bits); } static void lintospeex_destroy(struct ast_trans_pvt *arg) { struct speex_coder_pvt *pvt = arg->pvt; #ifdef _SPEEX_TYPES_H if (preproc) speex_preprocess_state_destroy(pvt->pp); #endif speex_encoder_destroy(pvt->speex); speex_bits_destroy(&pvt->bits); } static struct ast_translator speextolin = { .name = "speextolin", .newpvt = speextolin_new, .framein = speextolin_framein, .destroy = speextolin_destroy, .sample = speex_sample, .desc_size = sizeof(struct speex_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, .native_plc = 1, }; static struct ast_translator lintospeex = { .name = "lintospeex", .newpvt = lintospeex_new, .framein = lintospeex_framein, .frameout = lintospeex_frameout, .destroy = lintospeex_destroy, .sample = slin8_sample, .desc_size = sizeof(struct speex_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */ }; static struct ast_translator speexwbtolin16 = { .name = "speexwbtolin16", .newpvt = speexwbtolin16_new, .framein = speextolin_framein, .destroy = speextolin_destroy, .sample = speex16_sample, .desc_size = sizeof(struct speex_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, .native_plc = 1, }; static struct ast_translator lin16tospeexwb = { .name = "lin16tospeexwb", .newpvt = lin16tospeexwb_new, .framein = lintospeex_framein, .frameout = lintospeex_frameout, .destroy = lintospeex_destroy, .sample = slin16_sample, .desc_size = sizeof(struct speex_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */ }; static struct ast_translator speexuwbtolin32 = { .name = "speexuwbtolin32", .newpvt = speexuwbtolin32_new, .framein = speextolin_framein, .destroy = speextolin_destroy, .desc_size = sizeof(struct speex_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, .native_plc = 1, }; static struct ast_translator lin32tospeexuwb = { .name = "lin32tospeexuwb", .newpvt = lin32tospeexuwb_new, .framein = lintospeex_framein, .frameout = lintospeex_frameout, .destroy = lintospeex_destroy, .desc_size = sizeof(struct speex_coder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */ }; static int parse_config(int reload) { struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); struct ast_variable *var; int res; float res_f; if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; for (var = ast_variable_browse(cfg, "speex"); var; var = var->next) { if (!strcasecmp(var->name, "quality")) { res = abs(atoi(var->value)); if (res > -1 && res < 11) { ast_verb(3, "CODEC SPEEX: Setting Quality to %d\n",res); quality = res; } else ast_log(LOG_ERROR,"Error Quality must be 0-10\n"); } else if (!strcasecmp(var->name, "complexity")) { res = abs(atoi(var->value)); if (res > -1 && res < 11) { ast_verb(3, "CODEC SPEEX: Setting Complexity to %d\n",res); complexity = res; } else ast_log(LOG_ERROR,"Error! Complexity must be 0-10\n"); } else if (!strcasecmp(var->name, "vbr_quality")) { if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0 && res_f <= 10) { ast_verb(3, "CODEC SPEEX: Setting VBR Quality to %f\n",res_f); vbr_quality = res_f; } else ast_log(LOG_ERROR,"Error! VBR Quality must be 0-10\n"); } else if (!strcasecmp(var->name, "abr_quality")) { ast_log(LOG_ERROR,"Error! ABR Quality setting obsolete, set ABR to desired bitrate\n"); } else if (!strcasecmp(var->name, "enhancement")) { enhancement = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: Perceptual Enhancement Mode. [%s]\n",enhancement ? "on" : "off"); } else if (!strcasecmp(var->name, "vbr")) { vbr = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: VBR Mode. [%s]\n",vbr ? "on" : "off"); } else if (!strcasecmp(var->name, "abr")) { res = abs(atoi(var->value)); if (res >= 0) { if (res > 0) ast_verb(3, "CODEC SPEEX: Setting ABR target bitrate to %d\n",res); else ast_verb(3, "CODEC SPEEX: Disabling ABR\n"); abr = res; } else ast_log(LOG_ERROR,"Error! ABR target bitrate must be >= 0\n"); } else if (!strcasecmp(var->name, "vad")) { vad = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: VAD Mode. [%s]\n",vad ? "on" : "off"); } else if (!strcasecmp(var->name, "dtx")) { dtx = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: DTX Mode. [%s]\n",dtx ? "on" : "off"); } else if (!strcasecmp(var->name, "preprocess")) { preproc = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: Preprocessing. [%s]\n",preproc ? "on" : "off"); } else if (!strcasecmp(var->name, "pp_vad")) { pp_vad = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: Preprocessor VAD. [%s]\n",pp_vad ? "on" : "off"); } else if (!strcasecmp(var->name, "pp_agc")) { pp_agc = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: Preprocessor AGC. [%s]\n",pp_agc ? "on" : "off"); } else if (!strcasecmp(var->name, "pp_agc_level")) { if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) { ast_verb(3, "CODEC SPEEX: Setting preprocessor AGC Level to %f\n",res_f); pp_agc_level = res_f; } else ast_log(LOG_ERROR,"Error! Preprocessor AGC Level must be >= 0\n"); } else if (!strcasecmp(var->name, "pp_denoise")) { pp_denoise = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: Preprocessor Denoise. [%s]\n",pp_denoise ? "on" : "off"); } else if (!strcasecmp(var->name, "pp_dereverb")) { pp_dereverb = ast_true(var->value) ? 1 : 0; ast_verb(3, "CODEC SPEEX: Preprocessor Dereverb. [%s]\n",pp_dereverb ? "on" : "off"); } else if (!strcasecmp(var->name, "pp_dereverb_decay")) { if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) { ast_verb(3, "CODEC SPEEX: Setting preprocessor Dereverb Decay to %f\n",res_f); pp_dereverb_decay = res_f; } else ast_log(LOG_ERROR,"Error! Preprocessor Dereverb Decay must be >= 0\n"); } else if (!strcasecmp(var->name, "pp_dereverb_level")) { if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) { ast_verb(3, "CODEC SPEEX: Setting preprocessor Dereverb Level to %f\n",res_f); pp_dereverb_level = res_f; } else ast_log(LOG_ERROR,"Error! Preprocessor Dereverb Level must be >= 0\n"); } } ast_config_destroy(cfg); return 0; } static int reload(void) { if (parse_config(1)) return AST_MODULE_LOAD_DECLINE; return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res = 0; res |= ast_unregister_translator(&speextolin); res |= ast_unregister_translator(&lintospeex); res |= ast_unregister_translator(&speexwbtolin16); res |= ast_unregister_translator(&lin16tospeexwb); res |= ast_unregister_translator(&speexuwbtolin32); res |= ast_unregister_translator(&lin32tospeexuwb); return res; } static int load_module(void) { int res = 0; if (parse_config(0)) return AST_MODULE_LOAD_DECLINE; ast_format_set(&speextolin.src_format, AST_FORMAT_SPEEX, 0); ast_format_set(&speextolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintospeex.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintospeex.dst_format, AST_FORMAT_SPEEX, 0); ast_format_set(&speexwbtolin16.src_format, AST_FORMAT_SPEEX16, 0); ast_format_set(&speexwbtolin16.dst_format, AST_FORMAT_SLINEAR16, 0); ast_format_set(&lin16tospeexwb.src_format, AST_FORMAT_SLINEAR16, 0); ast_format_set(&lin16tospeexwb.dst_format, AST_FORMAT_SPEEX16, 0); ast_format_set(&speexuwbtolin32.src_format, AST_FORMAT_SPEEX32, 0); ast_format_set(&speexuwbtolin32.dst_format, AST_FORMAT_SLINEAR32, 0); ast_format_set(&lin32tospeexuwb.src_format, AST_FORMAT_SLINEAR32, 0); ast_format_set(&lin32tospeexuwb.dst_format, AST_FORMAT_SPEEX32, 0); res |= ast_register_translator(&speextolin); res |= ast_register_translator(&lintospeex); res |= ast_register_translator(&speexwbtolin16); res |= ast_register_translator(&lin16tospeexwb); res |= ast_register_translator(&speexuwbtolin32); res |= ast_register_translator(&lin32tospeexuwb); return res; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Speex Coder/Decoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/codec_alaw.c0000644000175000007640000000607411607650606017050 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 codec_alaw.c - translate between signed linear and alaw * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/translate.h" #include "asterisk/alaw.h" #include "asterisk/utils.h" #define BUFFER_SAMPLES 8096 /* size for the translation buffers */ /* Sample frame data */ #include "asterisk/slin.h" #include "ex_alaw.h" /*! \brief decode frame into lin and fill output buffer. */ static int alawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; unsigned char *src = f->data.ptr; int16_t *dst = pvt->outbuf.i16 + pvt->samples; pvt->samples += i; pvt->datalen += i * 2; /* 2 bytes/sample */ while (i--) *dst++ = AST_ALAW(*src++); return 0; } /*! \brief convert and store input samples in output buffer */ static int lintoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; char *dst = pvt->outbuf.c + pvt->samples; int16_t *src = f->data.ptr; pvt->samples += i; pvt->datalen += i; /* 1 byte/sample */ while (i--) *dst++ = AST_LIN2A(*src++); return 0; } static struct ast_translator alawtolin = { .name = "alawtolin", .framein = alawtolin_framein, .sample = alaw_sample, .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, }; static struct ast_translator lintoalaw = { "lintoalaw", .framein = lintoalaw_framein, .sample = slin8_sample, .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES, }; /*! \brief standard module stuff */ static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res; res = ast_unregister_translator(&lintoalaw); res |= ast_unregister_translator(&alawtolin); return res; } static int load_module(void) { int res; ast_format_set(&lintoalaw.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintoalaw.dst_format, AST_FORMAT_ALAW, 0); ast_format_set(&alawtolin.src_format, AST_FORMAT_ALAW, 0); ast_format_set(&alawtolin.dst_format, AST_FORMAT_SLINEAR, 0); res = ast_register_translator(&alawtolin); if (!res) res = ast_register_translator(&lintoalaw); else ast_unregister_translator(&alawtolin); if (res) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "A-law Coder/Decoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/codec_adpcm.c0000644000175000007640000001726411607650606017213 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Based on frompcm.c and topcm.c from the Emiliano MIPL browser/ * interpreter. See http://www.bsdtelephony.com.mx * * Copyright (c) 2001 - 2005 Digium, Inc. * All rights reserved. * * Karl Sackett , 2001-03-21 * * 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 codec_adpcm.c - translate between signed linear and Dialogic ADPCM * * \ingroup codecs */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/lock.h" #include "asterisk/linkedlists.h" #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/translate.h" #include "asterisk/utils.h" /* define NOT_BLI to use a faster but not bit-level identical version */ /* #define NOT_BLI */ #define BUFFER_SAMPLES 8096 /* size for the translation buffers */ /* Sample frame data */ #include "asterisk/slin.h" #include "ex_adpcm.h" /* * Step size index shift table */ static int indsft[8] = { -1, -1, -1, -1, 2, 4, 6, 8 }; /* * Step size table, where stpsz[i]=floor[16*(11/10)^i] */ static int stpsz[49] = { 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552 }; /* * Decoder/Encoder state * States for both encoder and decoder are synchronized */ struct adpcm_state { int ssindex; int signal; int zero_count; int next_flag; }; /* * Decode(encoded) * Decodes the encoded nibble from the adpcm file. * * Results: * Returns the encoded difference. * * Side effects: * Sets the index to the step size table for the next encode. */ static inline short decode(int encoded, struct adpcm_state *state) { int diff; int step; int sign; step = stpsz[state->ssindex]; sign = encoded & 0x08; encoded &= 0x07; #ifdef NOT_BLI diff = (((encoded << 1) + 1) * step) >> 3; #else /* BLI code */ diff = step >> 3; if (encoded & 4) diff += step; if (encoded & 2) diff += step >> 1; if (encoded & 1) diff += step >> 2; if ((encoded >> 1) & step & 0x1) diff++; #endif if (sign) diff = -diff; if (state->next_flag & 0x1) state->signal -= 8; else if (state->next_flag & 0x2) state->signal += 8; state->signal += diff; if (state->signal > 2047) state->signal = 2047; else if (state->signal < -2047) state->signal = -2047; state->next_flag = 0; #ifdef AUTO_RETURN if (encoded) state->zero_count = 0; else if (++(state->zero_count) == 24) { state->zero_count = 0; if (state->signal > 0) state->next_flag = 0x1; else if (state->signal < 0) state->next_flag = 0x2; } #endif state->ssindex += indsft[encoded]; if (state->ssindex < 0) state->ssindex = 0; else if (state->ssindex > 48) state->ssindex = 48; return state->signal << 4; } /* * Adpcm * Takes a signed linear signal and encodes it as ADPCM * For more information see http://support.dialogic.com/appnotes/adpcm.pdf * * Results: * Foo. * * Side effects: * signal gets updated with each pass. */ static inline int adpcm(short csig, struct adpcm_state *state) { int diff; int step; int encoded; /* * Clip csig if too large or too small */ csig >>= 4; step = stpsz[state->ssindex]; diff = csig - state->signal; #ifdef NOT_BLI if (diff < 0) { encoded = (-diff << 2) / step; if (encoded > 7) encoded = 7; encoded |= 0x08; } else { encoded = (diff << 2) / step; if (encoded > 7) encoded = 7; } #else /* BLI code */ if (diff < 0) { encoded = 8; diff = -diff; } else encoded = 0; if (diff >= step) { encoded |= 4; diff -= step; } step >>= 1; if (diff >= step) { encoded |= 2; diff -= step; } step >>= 1; if (diff >= step) encoded |= 1; #endif /* NOT_BLI */ /* feedback to state */ decode(encoded, state); return encoded; } /*----------------- Asterisk-codec glue ------------*/ /*! \brief Workspace for translating signed linear signals to ADPCM. */ struct adpcm_encoder_pvt { struct adpcm_state state; int16_t inbuf[BUFFER_SAMPLES]; /* Unencoded signed linear values */ }; /*! \brief Workspace for translating ADPCM signals to signed linear. */ struct adpcm_decoder_pvt { struct adpcm_state state; }; /*! \brief decode 4-bit adpcm frame data and store in output buffer */ static int adpcmtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct adpcm_decoder_pvt *tmp = pvt->pvt; int x = f->datalen; unsigned char *src = f->data.ptr; int16_t *dst = pvt->outbuf.i16 + pvt->samples; while (x--) { *dst++ = decode((*src >> 4) & 0xf, &tmp->state); *dst++ = decode(*src++ & 0x0f, &tmp->state); } pvt->samples += f->samples; pvt->datalen += 2*f->samples; return 0; } /*! \brief fill input buffer with 16-bit signed linear PCM values. */ static int lintoadpcm_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct adpcm_encoder_pvt *tmp = pvt->pvt; memcpy(&tmp->inbuf[pvt->samples], f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } /*! \brief convert inbuf and store into frame */ static struct ast_frame *lintoadpcm_frameout(struct ast_trans_pvt *pvt) { struct adpcm_encoder_pvt *tmp = pvt->pvt; struct ast_frame *f; int i; int samples = pvt->samples; /* save original number */ if (samples < 2) return NULL; pvt->samples &= ~1; /* atomic size is 2 samples */ for (i = 0; i < pvt->samples; i += 2) { pvt->outbuf.c[i/2] = (adpcm(tmp->inbuf[i ], &tmp->state) << 4) | (adpcm(tmp->inbuf[i+1], &tmp->state) ); }; f = ast_trans_frameout(pvt, pvt->samples/2, 0); /* * If there is a left over sample, move it to the beginning * of the input buffer. */ if (samples & 1) { /* move the leftover sample at beginning */ tmp->inbuf[0] = tmp->inbuf[samples - 1]; pvt->samples = 1; } return f; } static struct ast_translator adpcmtolin = { .name = "adpcmtolin", .framein = adpcmtolin_framein, .sample = adpcm_sample, .desc_size = sizeof(struct adpcm_decoder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, }; static struct ast_translator lintoadpcm = { .name = "lintoadpcm", .framein = lintoadpcm_framein, .frameout = lintoadpcm_frameout, .sample = slin8_sample, .desc_size = sizeof (struct adpcm_encoder_pvt), .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES/ 2, /* 2 samples per byte */ }; /*! \brief standard module glue */ static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res; res = ast_unregister_translator(&lintoadpcm); res |= ast_unregister_translator(&adpcmtolin); return res; } static int load_module(void) { int res; ast_format_set(&adpcmtolin.src_format, AST_FORMAT_ADPCM, 0); ast_format_set(&adpcmtolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintoadpcm.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintoadpcm.dst_format, AST_FORMAT_ADPCM, 0); res = ast_register_translator(&adpcmtolin); if (!res) res = ast_register_translator(&lintoadpcm); else ast_unregister_translator(&adpcmtolin); if (res) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Adaptive Differential PCM Coder/Decoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/ex_g722.h0000644000175000007640000000272311522553062016140 0ustar sharkyjerryweb/*! \file * \brief 8-bit data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_g722[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static struct ast_frame *g722_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_g722), .samples = ARRAY_LEN(ex_g722), .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_g722, }; ast_format_set(&f.subclass.format, AST_FORMAT_G722, 0); return &f; } asterisk-11.7.0/codecs/ex_ilbc.h0000644000175000007640000000152311523026147016365 0ustar sharkyjerryweb/*! \file * \brief Raw 8-bit data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_ilbc[] = { 0xff, 0xa0, 0xff, 0xfa, 0x0f, 0x60, 0x12, 0x11, 0xa2, 0x47, 0x22, 0x8c, 0x00, 0x00, 0x01, 0x02, 0x80, 0x43, 0xa0, 0x40, 0x33, 0xff, 0xcf, 0xc0, 0xf3, 0xf3, 0x3f, 0x8f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf9, 0xe5, 0x55, 0x78, 0x0b, 0xca, 0xe1, 0x27, 0x94, 0x7b, 0xa8, 0x91, 0x2c, 0x36, 0x08, 0x56, }; static struct ast_frame *ilbc_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_ilbc), /* All frames are 30 ms long */ .samples = ILBC_SAMPLES, .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_ilbc, }; ast_format_set(&f.subclass.format, AST_FORMAT_ILBC, 0); return &f; } asterisk-11.7.0/codecs/ex_alaw.h0000644000175000007640000000174711522553062016410 0ustar sharkyjerryweb/*! \file * \brief 8-bit data * * Copyright (C) 2008, Digium, Inc. * * Distributed under the terms of the GNU General Public License * */ static uint8_t ex_alaw[] = { 0x00, 0x03, 0x06, 0x09, 0x0c, 0x0f, 0x12, 0x15, 0x10, 0x18, 0x1b, 0x1e, 0x21, 0x24, 0x27, 0x2a, 0x20, 0x2d, 0x30, 0x33, 0x36, 0x39, 0x3c, 0x3f, 0x30, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x51, 0x54, 0x40, 0x57, 0x5a, 0x5d, 0x60, 0x63, 0x66, 0x69, 0x50, 0x6c, 0x6f, 0x72, 0x75, 0x78, 0x7b, 0x7e, 0x60, 0x81, 0x84, 0x87, 0x8a, 0x8d, 0x90, 0x93, 0x70, 0x96, 0x99, 0x9c, 0x9f, 0xa2, 0xa5, 0xa8, 0x80, 0xab, 0xae, 0xb1, 0xb4, 0xb7, 0xba, 0xbd, 0x90, 0xc0, 0xc3, 0xc6, 0xc9, 0xcc, 0xcf, 0xd2, }; static struct ast_frame *alaw_sample(void) { static struct ast_frame f = { .frametype = AST_FRAME_VOICE, .datalen = sizeof(ex_alaw), .samples = ARRAY_LEN(ex_alaw), .mallocd = 0, .offset = 0, .src = __PRETTY_FUNCTION__, .data.ptr = ex_alaw, }; ast_format_set(&f.subclass.format, AST_FORMAT_ALAW, 0); return &f; } asterisk-11.7.0/codecs/Makefile0000644000175000007640000000424012122105451016236 0ustar sharkyjerryweb# # Asterisk -- A telephony toolkit for Linux. # # Makefile for codec modules # # Copyright (C) 1999-2006, Digium, Inc. # # Mark Spencer # # This program is free software, distributed under the terms of # the GNU General Public License # -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps MODULE_PREFIX=codec MENUSELECT_CATEGORY=CODECS MENUSELECT_DESCRIPTION=Codec Translators SUB_GSM := gsm SUB_ILBC := ilbc LIBILBC := $(SUB_ILBC)/libilbc.a SUB_LPC10 := lpc10 LIBLPC10 := $(SUB_LPC10)/liblpc10.a SUB_DIRS := \ $(SUB_GSM) \ $(SUB_ILBC) \ $(SUB_LPC10) \ all: _all include $(ASTTOPDIR)/Makefile.moddir_rules ifneq ($(GSM_INTERNAL),no) GSM_INCLUDE := -I$(SUB_GSM)/inc $(if $(filter codec_gsm,$(EMBEDDED_MODS)),modules.link,codec_gsm.so): $(SUB_GSM)/lib/libgsm.a endif # Don't run the implicit rules for this target. $(SUB_GSM)/lib/libgsm.a: $(SUB_GSM) ; $(SUB_GSM): @mkdir -p $(SUB_GSM)/lib @$(MAKE) -C $(SUB_GSM) lib/libgsm.a clean:: for dir in $(SUB_DIRS); do \ $(MAKE) -C $$dir clean; \ done rm -f g722/*.[oai] rm -f speex/*.[oai] .PHONY: $(SUB_DIRS) $(if $(filter codec_lpc10,$(EMBEDDED_MODS)),modules.link,codec_lpc10.so): $(LIBLPC10) # Don't run the implicit rules for this target. $(LIBLPC10): $(SUB_LPC10) ; $(SUB_LPC10): @$(MAKE) -C $(SUB_LPC10) all ifneq ($(ILBC_INTERNAL),no) $(if $(filter codec_ilbc,$(EMBEDDED_MODS)),modules.link,codec_ilbc.so): $(LIBILBC) else ILBC_INCLUDE += -DILBC_WEBRTC endif # Don't run the implicit rules for this target. $(LIBILBC): $(SUB_ILBC) ; $(SUB_ILBC): @$(MAKE) -C $(SUB_ILBC) all _ASTCFLAGS="$(filter-out -Wmissing-prototypes -Wmissing-declarations -Wshadow,$(_ASTCFLAGS)) $(AST_NO_STRICT_OVERFLOW)" $(if $(filter codec_g722,$(EMBEDDED_MODS)),modules.link,codec_g722.so): g722/g722_encode.o g722/g722_decode.o g722/g722_encode.o g722/g722_decode.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,codec_g722) ifeq ($(BUILD_CPU),x86_64) SPEEX_RESAMPLE_CFLAGS:=-fPIC else SPEEX_RESAMPLE_CFLAGS:= endif $(if $(filter codec_resample,$(EMBEDDED_MODS)),modules.link,codec_resample.so): speex/resample.o speex/resample.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,codec_resample) $(SPEEX_RESAMPLE_CFLAGS) asterisk-11.7.0/codecs/codec_gsm.c0000644000175000007640000001376011607650606016712 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * The GSM code is from TOAST. Copyright information for that package is available * in the GSM directory. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Translate between signed linear and Global System for Mobile Communications (GSM) * * \ingroup codecs */ /*** MODULEINFO gsm core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/translate.h" #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/utils.h" #ifdef HAVE_GSM_HEADER #include "gsm.h" #elif defined(HAVE_GSM_GSM_HEADER) #include #endif #include "../formats/msgsm.h" #define BUFFER_SAMPLES 8000 #define GSM_SAMPLES 160 #define GSM_FRAME_LEN 33 #define MSGSM_FRAME_LEN 65 /* Sample frame data */ #include "asterisk/slin.h" #include "ex_gsm.h" struct gsm_translator_pvt { /* both gsm2lin and lin2gsm */ gsm gsm; int16_t buf[BUFFER_SAMPLES]; /* lin2gsm, temporary storage */ }; static int gsm_new(struct ast_trans_pvt *pvt) { struct gsm_translator_pvt *tmp = pvt->pvt; return (tmp->gsm = gsm_create()) ? 0 : -1; } /*! \brief decode and store in outbuf. */ static int gsmtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct gsm_translator_pvt *tmp = pvt->pvt; int x; int16_t *dst = pvt->outbuf.i16; /* guess format from frame len. 65 for MSGSM, 33 for regular GSM */ int flen = (f->datalen % MSGSM_FRAME_LEN == 0) ? MSGSM_FRAME_LEN : GSM_FRAME_LEN; for (x=0; x < f->datalen; x += flen) { unsigned char data[2 * GSM_FRAME_LEN]; unsigned char *src; int len; if (flen == MSGSM_FRAME_LEN) { len = 2*GSM_SAMPLES; src = data; /* Translate MSGSM format to Real GSM format before feeding in */ /* XXX what's the point here! we should just work * on the full format. */ conv65(f->data.ptr + x, data); } else { len = GSM_SAMPLES; src = f->data.ptr + x; } /* XXX maybe we don't need to check */ if (pvt->samples + len > BUFFER_SAMPLES) { ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } if (gsm_decode(tmp->gsm, src, dst + pvt->samples)) { ast_log(LOG_WARNING, "Invalid GSM data (1)\n"); return -1; } pvt->samples += GSM_SAMPLES; pvt->datalen += 2 * GSM_SAMPLES; if (flen == MSGSM_FRAME_LEN) { if (gsm_decode(tmp->gsm, data + GSM_FRAME_LEN, dst + pvt->samples)) { ast_log(LOG_WARNING, "Invalid GSM data (2)\n"); return -1; } pvt->samples += GSM_SAMPLES; pvt->datalen += 2 * GSM_SAMPLES; } } return 0; } /*! \brief store samples into working buffer for later decode */ static int lintogsm_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct gsm_translator_pvt *tmp = pvt->pvt; /* XXX We should look at how old the rest of our stream is, and if it is too old, then we should overwrite it entirely, otherwise we can get artifacts of earlier talk that do not belong */ if (pvt->samples + f->samples > BUFFER_SAMPLES) { ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } /*! \brief encode and produce a frame */ static struct ast_frame *lintogsm_frameout(struct ast_trans_pvt *pvt) { struct gsm_translator_pvt *tmp = pvt->pvt; int datalen = 0; int samples = 0; /* We can't work on anything less than a frame in size */ if (pvt->samples < GSM_SAMPLES) return NULL; while (pvt->samples >= GSM_SAMPLES) { /* Encode a frame of data */ gsm_encode(tmp->gsm, tmp->buf + samples, (gsm_byte *) pvt->outbuf.c + datalen); datalen += GSM_FRAME_LEN; samples += GSM_SAMPLES; pvt->samples -= GSM_SAMPLES; } /* Move the data at the end of the buffer to the front */ if (pvt->samples) memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); return ast_trans_frameout(pvt, datalen, samples); } static void gsm_destroy_stuff(struct ast_trans_pvt *pvt) { struct gsm_translator_pvt *tmp = pvt->pvt; if (tmp->gsm) gsm_destroy(tmp->gsm); } static struct ast_translator gsmtolin = { .name = "gsmtolin", .newpvt = gsm_new, .framein = gsmtolin_framein, .destroy = gsm_destroy_stuff, .sample = gsm_sample, .buffer_samples = BUFFER_SAMPLES, .buf_size = BUFFER_SAMPLES * 2, .desc_size = sizeof (struct gsm_translator_pvt ), }; static struct ast_translator lintogsm = { .name = "lintogsm", .newpvt = gsm_new, .framein = lintogsm_framein, .frameout = lintogsm_frameout, .destroy = gsm_destroy_stuff, .sample = slin8_sample, .desc_size = sizeof (struct gsm_translator_pvt ), .buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES, }; /*! \brief standard module glue */ static int reload(void) { return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { int res; res = ast_unregister_translator(&lintogsm); if (!res) res = ast_unregister_translator(&gsmtolin); return res; } static int load_module(void) { int res; ast_format_set(&gsmtolin.src_format, AST_FORMAT_GSM, 0); ast_format_set(&gsmtolin.dst_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintogsm.src_format, AST_FORMAT_SLINEAR, 0); ast_format_set(&lintogsm.dst_format, AST_FORMAT_GSM, 0); res = ast_register_translator(&gsmtolin); if (!res) res=ast_register_translator(&lintogsm); else ast_unregister_translator(&gsmtolin); if (res) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "GSM Coder/Decoder", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/codecs/lpc10/0000755000175000007640000000000012254071136015525 5ustar sharkyjerrywebasterisk-11.7.0/codecs/lpc10/lpcini.c0000644000175000007640000003075311075416522017161 0ustar sharkyjerryweb/* $Log$ Revision 1.18 2003/10/21 18:08:11 markster Fix include order Revision 1.5 2003/10/21 18:08:11 markster Fix include order Revision 1.4 2003/10/21 02:57:29 markster FreeBSD patch, take 2 Revision 1.3 2003/10/16 21:11:30 martinp Revert the previous patch since it's braking compilation Revision 1.1 2003/02/12 13:59:15 matteo Initial revision Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:35:41 jaf * Added functions for allocating and initializing lpc10_encoder_state * and lpc10_decoder_state structures. * * Revision 1.1 1996/08/19 22:31:40 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "asterisk.h" #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int lpcini_(void); /* comlen contrl_ 12 */ /*:ref: initlpcenc_ 14 0 */ /*:ref: initlpcdec_ 14 0 */ #endif /* Common Block Declarations */ struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* ***************************************************************** */ /* $Log$ * Revision 1.18 2003/10/21 18:08:11 markster * Fix include order * * Revision 1.5 2003/10/21 18:08:11 markster * Fix include order * * Revision 1.4 2003/10/21 02:57:29 markster * FreeBSD patch, take 2 * * Revision 1.3 2003/10/16 21:11:30 martinp * Revert the previous patch since it's braking compilation * * Revision 1.1 2003/02/12 13:59:15 matteo * Initial revision * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:35:41 jaf * Added functions for allocating and initializing lpc10_encoder_state * and lpc10_decoder_state structures. * * Revision 1.1 1996/08/19 22:31:40 jaf * Initial revision * */ /* Revision 1.1 1996/03/28 00:04:05 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Initialize COMMON block variables used by LPC-10 encoder and decoder, */ /* and call initialization routines for both of them. */ /* Subroutine */ int lpcini_(void) { /* $Log$ * Revision 1.18 2003/10/21 18:08:11 markster * Fix include order * * Revision 1.5 2003/10/21 18:08:11 markster * Fix include order * * Revision 1.4 2003/10/21 02:57:29 markster * FreeBSD patch, take 2 * * Revision 1.3 2003/10/16 21:11:30 martinp * Revert the previous patch since it's braking compilation * * Revision 1.1 2003/02/12 13:59:15 matteo * Initial revision * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:35:41 jaf * Added functions for allocating and initializing lpc10_encoder_state * and lpc10_decoder_state structures. * * Revision 1.1 1996/08/19 22:31:40 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* $Log$ * Revision 1.18 2003/10/21 18:08:11 markster * Fix include order * * Revision 1.5 2003/10/21 18:08:11 markster * Fix include order * * Revision 1.4 2003/10/21 02:57:29 markster * FreeBSD patch, take 2 * * Revision 1.3 2003/10/16 21:11:30 martinp * Revert the previous patch since it's braking compilation * * Revision 1.1 2003/02/12 13:59:15 matteo * Initial revision * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:35:41 jaf * Added functions for allocating and initializing lpc10_encoder_state * and lpc10_decoder_state structures. * * Revision 1.1 1996/08/19 22:31:40 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ contrl_1.order = 10; contrl_1.lframe = 180; contrl_1.corrp = TRUE_; return 0; } /* lpcini_ */ /* Allocate memory for, and initialize, the state that needs to be kept from encoding one frame to the next for a single LPC-10-compressed audio stream. Return 0 if malloc fails, otherwise return pointer to new structure. */ struct lpc10_encoder_state * create_lpc10_encoder_state() { struct lpc10_encoder_state *st; st = (struct lpc10_encoder_state *) malloc((unsigned) sizeof (struct lpc10_encoder_state)); if (st != 0) { init_lpc10_encoder_state(st); } return (st); } void init_lpc10_encoder_state(struct lpc10_encoder_state *st) { int i; lpcini_(); /* State used only by function hp100 */ st->z11 = 0.0f; st->z21 = 0.0f; st->z12 = 0.0f; st->z22 = 0.0f; /* State used by function analys */ for (i = 0; i < 540; i++) { st->inbuf[i] = 0.0f; st->pebuf[i] = 0.0f; } for (i = 0; i < 696; i++) { st->lpbuf[i] = 0.0f; } for (i = 0; i < 312; i++) { st->ivbuf[i] = 0.0f; } st->bias = 0.0f; /* integer osbuf[10]; */ /* no initial value necessary */ st->osptr = 1; for (i = 0; i < 3; i++) { st->obound[i] = 0; } st->vwin[4] = 307; st->vwin[5] = 462; st->awin[4] = 307; st->awin[5] = 462; for (i = 0; i < 8; i++) { st->voibuf[i] = 0; } for (i = 0; i < 3; i++) { st->rmsbuf[i] = 0.0f; } for (i = 0; i < 30; i++) { st->rcbuf[i] = 0.0f; } st->zpre = 0.0f; /* State used by function onset */ st->n = 0.0f; st->d__ = 1.0f; /* real fpc; */ /* no initial value necessary */ for (i = 0; i < 16; i++) { st->l2buf[i] = 0.0f; } st->l2sum1 = 0.0f; st->l2ptr1 = 1; st->l2ptr2 = 9; /* integer lasti; */ /* no initial value necessary */ st->hyst = FALSE_; /* State used by function voicin */ st->dither = 20.0f; st->maxmin = 0.0f; for (i = 0; i < 6; i++) { st->voice[i] = 0.0f; } st->lbve = 3000; st->fbve = 3000; st->fbue = 187; st->ofbue = 187; st->sfbue = 187; st->lbue = 93; st->olbue = 93; st->slbue = 93; st->snr = (real) (st->fbve / st->fbue << 6); /* State used by function dyptrk */ for (i = 0; i < 60; i++) { st->s[i] = 0.0f; } for (i = 0; i < 120; i++) { st->p[i] = 0; } st->ipoint = 0; st->alphax = 0.0f; /* State used by function chanwr */ st->isync = 0; } /* Allocate memory for, and initialize, the state that needs to be kept from decoding one frame to the next for a single LPC-10-compressed audio stream. Return 0 if malloc fails, otherwise return pointer to new structure. */ struct lpc10_decoder_state * create_lpc10_decoder_state() { struct lpc10_decoder_state *st; st = (struct lpc10_decoder_state *) malloc((unsigned) sizeof (struct lpc10_decoder_state)); if (st != 0) { init_lpc10_decoder_state(st); } return (st); } void init_lpc10_decoder_state(struct lpc10_decoder_state *st) { int i; lpcini_(); /* State used by function decode */ st->iptold = 60; st->first = TRUE_; st->ivp2h = 0; st->iovoic = 0; st->iavgp = 60; st->erate = 0; for (i = 0; i < 30; i++) { st->drc[i] = 0; } for (i = 0; i < 3; i++) { st->dpit[i] = 0; st->drms[i] = 0; } /* State used by function synths */ for (i = 0; i < 360; i++) { st->buf[i] = 0.0f; } st->buflen = 180; /* State used by function pitsyn */ /* ivoico; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ /* ipito; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ st->rmso = 1.0f; /* rco[10]; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ /* integer jsamp; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ st->first_pitsyn = TRUE_; /* State used by function bsynz */ st->ipo = 0; for (i = 0; i < 166; i++) { st->exc[i] = 0.0f; st->exc2[i] = 0.0f; } st->lpi1 = 0.0f; st->lpi2 = 0.0f; st->lpi3 = 0.0f; st->hpi1 = 0.0f; st->hpi2 = 0.0f; st->hpi3 = 0.0f; st->rmso_bsynz = 0.0f; /* State used by function random */ st->j = 2; st->k = 5; st->y[0] = (shortint) -21161; st->y[1] = (shortint) -8478; st->y[2] = (shortint) 30892; st->y[3] = (shortint) -10216; st->y[4] = (shortint) 16950; /* State used by function deemp */ st->dei1 = 0.0f; st->dei2 = 0.0f; st->deo1 = 0.0f; st->deo2 = 0.0f; st->deo3 = 0.0f; } asterisk-11.7.0/codecs/lpc10/synths.c0000644000175000007640000003531610513757330017234 0ustar sharkyjerryweb/* $Log$ Revision 1.16 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.15 2003/09/27 02:45:37 markster Fix various compiler warnings (bug #322) Revision 1.2 2003/09/27 02:45:37 markster Fix various compiler warnings (bug #322) Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:42:59 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:30:33 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int synths_(integer *voice, integer *pitch, real *rms, real *rc, real *speech, integer *k, struct lpc10_decoder_state *st); /* comlen contrl_ 12 */ /*:ref: pitsyn_ 14 12 4 4 4 6 6 4 4 4 6 6 4 6 */ /*:ref: irc2pc_ 14 5 6 6 4 6 6 */ /*:ref: bsynz_ 14 7 6 4 4 6 6 6 6 */ /*:ref: deemp_ 14 2 6 4 */ /*:ref: initpitsyn_ 14 0 */ /*:ref: initbsynz_ 14 0 */ /*:ref: initdeemp_ 14 0 */ #endif /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* Table of constant values */ static real c_b2 = .7f; /* ***************************************************************** */ /* SYNTHS Version 54 */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/27 02:45:37 markster * Fix various compiler warnings (bug #322) * * Revision 1.2 2003/09/27 02:45:37 markster * Fix various compiler warnings (bug #322) * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:42:59 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:30:33 jaf * Initial revision * */ /* Revision 1.5 1996/03/26 19:31:58 jaf */ /* Commented out trace statements. */ /* Revision 1.4 1996/03/25 19:41:01 jaf */ /* Changed so that MAXFRM samples are always returned in the output array */ /* SPEECH. */ /* This required delaying the returned samples by MAXFRM sample times, */ /* and remembering any "left over" samples returned by PITSYN from one */ /* call of SYNTHS to the next. */ /* Changed size of SPEECH from 2*MAXFRM to MAXFRM. Removed local */ /* variable SOUT. Added local state variables BUF and BUFLEN. */ /* Revision 1.3 1996/03/25 19:20:10 jaf */ /* Added comments about the range of possible return values for argument */ /* K, and increased the size of the arrays filled in by PITSYN from 11 to */ /* 16, as has been already done inside of PITSYN. */ /* Revision 1.2 1996/03/22 00:18:18 jaf */ /* Added comments explaining meanings of input and output parameters, and */ /* indicating which array indices can be read or written. */ /* Added entry INITSYNTHS, which does nothing except call the */ /* corresponding initialization entries for subroutines PITSYN, BSYNZ, */ /* and DEEMP. */ /* Revision 1.1 1996/02/07 14:49:44 jaf */ /* Initial revision */ /* ***************************************************************** */ /* The note below is from the distributed version of the LPC10 coder. */ /* The version of the code below has been modified so that SYNTHS always */ /* has a constant frame length output of MAXFRM. */ /* Also, BSYNZ and DEEMP need not be modified to work on variable */ /* positions within an array. It is only necessary to pass the first */ /* index desired as the array argument. What actually gets passed is the */ /* address of that array position, which the subroutine treats as the */ /* first index of the array. */ /* This technique is used in subroutine ANALYS when calling PREEMP, so it */ /* appears that multiple people wrote different parts of this LPC10 code, */ /* and that they didn't necessarily have equivalent knowledge of Fortran */ /* (not surprising). */ /* NOTE: There is excessive buffering here, BSYNZ and DEEMP should be */ /* changed to operate on variable positions within SOUT. Also, */ /* the output length parameter is bogus, and PITSYN should be */ /* rewritten to allow a constant frame length output. */ /* Input: */ /* VOICE - Half frame voicing decisions */ /* Indices 1 through 2 read. */ /* Input/Output: */ /* PITCH - Pitch */ /* PITCH is restricted to range 20 to 156, inclusive, */ /* before calling subroutine PITSYN, and then PITSYN */ /* can modify it further under some conditions. */ /* RMS - Energy */ /* Only use is for debugging, and passed to PITSYN. */ /* See comments there for how it can be modified. */ /* RC - Reflection coefficients */ /* Indices 1 through ORDER restricted to range -.99 to .99, */ /* before calling subroutine PITSYN, and then PITSYN */ /* can modify it further under some conditions. */ /* Output: */ /* SPEECH - Synthesized speech samples. */ /* Indices 1 through the final value of K are written. */ /* K - Number of samples placed into array SPEECH. */ /* This is always MAXFRM. */ /* Subroutine */ int synths_(integer *voice, integer *pitch, real * rms, real *rc, real *speech, integer *k, struct lpc10_decoder_state *st) { /* Initialized data */ real *buf; integer *buflen; /* System generated locals */ integer i__1; real r__1, r__2; /* Local variables */ real rmsi[16]; integer nout, ivuv[16], i__, j; extern /* Subroutine */ int deemp_(real *, integer *, struct lpc10_decoder_state *); real ratio; integer ipiti[16]; real g2pass; real pc[10]; extern /* Subroutine */ int pitsyn_(integer *, integer *, integer *, real *, real *, integer *, integer *, integer *, real *, real *, integer *, real *, struct lpc10_decoder_state *); real rci[160] /* was [10][16] */; /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/27 02:45:37 markster * Fix various compiler warnings (bug #322) * * Revision 1.2 2003/09/27 02:45:37 markster * Fix various compiler warnings (bug #322) * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:42:59 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:30:33 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Arguments */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/27 02:45:37 markster * Fix various compiler warnings (bug #322) * * Revision 1.2 2003/09/27 02:45:37 markster * Fix various compiler warnings (bug #322) * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:42:59 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:30:33 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Parameters/constants */ /* Local variables that need not be saved */ /* Local state */ /* BUF is a buffer of speech samples that would have been returned */ /* by the older version of SYNTHS, but the newer version doesn't, */ /* so that the newer version can always return MAXFRM samples on */ /* every call. This has the effect of delaying the return of */ /* samples for one additional frame time. */ /* Indices 1 through BUFLEN contain samples that are left over from */ /* the last call to SYNTHS. Given the way that PITSYN works, */ /* BUFLEN should always be in the range MAXFRM-MAXPIT+1 through */ /* MAXFRM, inclusive, after a call to SYNTHS is complete. */ /* On the first call to SYNTHS (or the first call after */ /* reinitializing with the entry INITSYNTHS), BUFLEN is MAXFRM, and */ /* a frame of silence is always returned. */ /* Parameter adjustments */ if (voice) { --voice; } if (rc) { --rc; } if (speech) { --speech; } /* Function Body */ buf = &(st->buf[0]); buflen = &(st->buflen); /* Computing MAX */ i__1 = min(*pitch,156); *pitch = max(i__1,20); i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { /* Computing MAX */ /* Computing MIN */ r__2 = rc[i__]; r__1 = min(r__2,.99f); rc[i__] = max(r__1,-.99f); } pitsyn_(&contrl_1.order, &voice[1], pitch, rms, &rc[1], &contrl_1.lframe, ivuv, ipiti, rmsi, rci, &nout, &ratio, st); if (nout > 0) { i__1 = nout; for (j = 1; j <= i__1; ++j) { /* Add synthesized speech for pitch period J to the en d of */ /* BUF. */ irc2pc_(&rci[j * 10 - 10], pc, &contrl_1.order, &c_b2, &g2pass); bsynz_(pc, &ipiti[j - 1], &ivuv[j - 1], &buf[*buflen], &rmsi[j - 1] , &ratio, &g2pass, st); deemp_(&buf[*buflen], &ipiti[j - 1], st); *buflen += ipiti[j - 1]; } /* Copy first MAXFRM samples from BUF to output array SPEECH */ /* (scaling them), and then remove them from the beginning of */ /* BUF. */ for (i__ = 1; i__ <= 180; ++i__) { speech[i__] = buf[i__ - 1] / 4096.f; } *k = 180; *buflen += -180; i__1 = *buflen; for (i__ = 1; i__ <= i__1; ++i__) { buf[i__ - 1] = buf[i__ + 179]; } } return 0; } /* synths_ */ asterisk-11.7.0/codecs/lpc10/prepro.c0000644000175000007640000000633510513757330017212 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:40:51 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:30:54 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int prepro_(real *speech, integer *length, struct lpc10_encoder_state *st); /*:ref: hp100_ 14 3 6 4 4 */ /*:ref: inithp100_ 14 0 */ #endif /* Table of constant values */ static integer c__1 = 1; /* ********************************************************************* */ /* PREPRO Version 48 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:40:51 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:30:54 jaf * Initial revision * */ /* Revision 1.3 1996/03/14 23:22:56 jaf */ /* Added comments about when INITPREPRO should be used. */ /* Revision 1.2 1996/03/14 23:09:27 jaf */ /* Added an entry named INITPREPRO that initializes the local state of */ /* this subroutine, and those it calls (if any). */ /* Revision 1.1 1996/02/07 14:48:54 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Pre-process input speech: */ /* Inputs: */ /* LENGTH - Number of SPEECH samples */ /* Input/Output: */ /* SPEECH(LENGTH) - Speech data. */ /* Indices 1 through LENGTH are read and modified. */ /* This subroutine has no local state maintained from one call to the */ /* next, but HP100 does. If you want to switch to using a new audio */ /* stream for this filter, or reinitialize its state for any other */ /* reason, call the ENTRY INITPREPRO. */ /* Subroutine */ int prepro_(real *speech, integer *length, struct lpc10_encoder_state *st) { extern /* Subroutine */ int hp100_(real *, integer *, integer *, struct lpc10_encoder_state *); /* Arguments */ /* High Pass Filter at 100 Hz */ /* Parameter adjustments */ if (speech) { --speech; } /* Function Body */ hp100_(&speech[1], &c__1, length, st); return 0; } /* prepro_ */ asterisk-11.7.0/codecs/lpc10/encode.c0000644000175000007640000003005210513757330017131 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:32:21 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int encode_(integer *voice, integer *pitch, real *rms, real *rc, integer *ipitch, integer *irms, integer *irc); /* comlen contrl_ 12 */ #endif /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* Table of constant values */ static integer c__2 = 2; /* ***************************************************************** */ /* ENCODE Version 54 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:21 jaf * Initial revision * */ /* Revision 1.5 1996/03/26 19:35:50 jaf */ /* Commented out trace statements. */ /* Revision 1.4 1996/03/21 00:26:29 jaf */ /* Added the comment that this subroutine has no local state. */ /* In the last check-in, I forgot to mention that I had added comments */ /* explaining which indices of array arguments are read or written. */ /* Revision 1.3 1996/03/21 00:22:39 jaf */ /* Added comments explaining that all local arrays are effectively */ /* constants. */ /* Revision 1.2 1996/03/13 18:48:33 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:45:29 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Quantize LPC parameters for transmission */ /* INPUTS: */ /* VOICE - Half frame voicing decisions */ /* Indices 1 through 2 read. */ /* PITCH - Pitch */ /* RMS - Energy */ /* RC - Reflection coefficients */ /* Indices 1 through ORDER read. */ /* CORRP - Error Correction: TRUE = yes, FALSE = none */ /* (this is defined in file control.fh) */ /* OUTPUTS: */ /* IPITCH - Coded pitch and voicing */ /* IRMS - Quantized energy */ /* IRC - Quantized reflection coefficients */ /* Indices 1 through MAX(ORDER,2) written. */ /* If CORRP is .TRUE., then indices 1 through 10 written */ /* for unvoiced frames. */ /* This subroutine has no local state. */ /* Subroutine */ int encode_(integer *voice, integer *pitch, real *rms, real * rc, integer *ipitch, integer *irms, integer *irc) { /* Initialized data */ static integer enctab[16] = { 0,7,11,12,13,10,6,1,14,9,5,2,3,4,8,15 }; static integer entau[60] = { 19,11,27,25,29,21,23,22,30,14,15,7,39,38,46, 42,43,41,45,37,53,49,51,50,54,52,60,56,58,26,90,88,92,84,86,82,83, 81,85,69,77,73,75,74,78,70,71,67,99,97,113,112,114,98,106,104,108, 100,101,76 }; static integer enadd[8] = { 1920,-768,2432,1280,3584,1536,2816,-1152 }; static real enscl[8] = { .0204f,.0167f,.0145f,.0147f,.0143f,.0135f,.0125f, .0112f }; static integer enbits[8] = { 6,5,4,4,4,4,3,3 }; static integer entab6[64] = { 0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3, 3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,9,9, 9,10,10,11,11,12,13,14,15 }; static integer rmst[64] = { 1024,936,856,784,718,656,600,550,502,460,420, 384,352,328,294,270,246,226,206,188,172,158,144,132,120,110,102, 92,84,78,70,64,60,54,50,46,42,38,34,32,30,26,24,22,20,18,17,16,15, 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 }; /* System generated locals */ integer i__1, i__2; /* Builtin functions */ integer pow_ii(integer *, integer *); /* Local variables */ integer idel, nbit, i__, j, i2, i3, mrk; /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:21 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:21 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Parameters/constants */ /* These arrays are not Fortran PARAMETER's, but they are defined */ /* by DATA statements below, and their contents are never altered. */ /* Local variables that need not be saved */ /* Parameter adjustments */ --irc; --rc; --voice; /* Function Body */ /* Scale RMS and RC's to integers */ *irms = (integer)*rms; i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { irc[i__] = (integer)(rc[i__] * 32768.f); } /* IF(LISTL.GE.3)WRITE(FDEBUG,800)VOICE,PITCH,IRMS,(IRC(I),I=1,ORDER) */ /* 800 FORMAT(1X,/,' <>',T32,2I3,I6,I5,T50,10I8) */ /* Encode pitch and voicing */ if (voice[1] != 0 && voice[2] != 0) { *ipitch = entau[*pitch - 1]; } else { if (contrl_1.corrp) { *ipitch = 0; if (voice[1] != voice[2]) { *ipitch = 127; } } else { *ipitch = (voice[1] << 1) + voice[2]; } } /* Encode RMS by binary table search */ j = 32; idel = 16; *irms = min(*irms,1023); while(idel > 0) { if (*irms > rmst[j - 1]) { j -= idel; } if (*irms < rmst[j - 1]) { j += idel; } idel /= 2; } if (*irms > rmst[j - 1]) { --j; } *irms = 31 - j / 2; /* Encode RC(1) and (2) as log-area-ratios */ for (i__ = 1; i__ <= 2; ++i__) { i2 = irc[i__]; mrk = 0; if (i2 < 0) { i2 = -i2; mrk = 1; } i2 /= 512; i2 = min(i2,63); i2 = entab6[i2]; if (mrk != 0) { i2 = -i2; } irc[i__] = i2; } /* Encode RC(3) - (10) linearly, remove bias then scale */ i__1 = contrl_1.order; for (i__ = 3; i__ <= i__1; ++i__) { i2 = irc[i__] / 2; i2 = (integer)((i2 + enadd[contrl_1.order + 1 - i__ - 1]) * enscl[ contrl_1.order + 1 - i__ - 1]); /* Computing MIN */ i__2 = max(i2,-127); i2 = min(i__2,127); nbit = enbits[contrl_1.order + 1 - i__ - 1]; i3 = 0; if (i2 < 0) { i3 = -1; } i2 /= pow_ii(&c__2, &nbit); if (i3 == -1) { --i2; } irc[i__] = i2; } /* Protect the most significant bits of the most */ /* important parameters during non-voiced frames. */ /* RC(1) - RC(4) are protected using 20 parity bits */ /* replacing RC(5) - RC(10). */ if (contrl_1.corrp) { if (*ipitch == 0 || *ipitch == 127) { irc[5] = enctab[(irc[1] & 30) / 2]; irc[6] = enctab[(irc[2] & 30) / 2]; irc[7] = enctab[(irc[3] & 30) / 2]; irc[8] = enctab[(*irms & 30) / 2]; irc[9] = enctab[(irc[4] & 30) / 2] / 2; irc[10] = enctab[(irc[4] & 30) / 2] & 1; } } /* IF(LISTL.GE.3)WRITE(FDEBUG,801)VOICE,IPITCH,IRMS,(IRC(J),J=1,ORDER) */ /* 801 FORMAT(1X,'<>',T32,2I3,I6,I5,T50,10I8) */ return 0; } /* encode_ */ asterisk-11.7.0/codecs/lpc10/liblpc10.vcproj0000644000175000007640000001170610407616736020376 0ustar sharkyjerryweb asterisk-11.7.0/codecs/lpc10/mload.c0000644000175000007640000001211410513757330016767 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:31:25 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int mload_(integer *order, integer *awins, integer *awinf, real *speech, real *phi, real *psi); #endif /* ***************************************************************** */ /* MLOAD Version 48 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:25 jaf * Initial revision * */ /* Revision 1.5 1996/03/27 23:59:51 jaf */ /* Added some more accurate comments about which indices of the argument */ /* array SPEECH are read. I thought that this might be the cause of a */ /* problem I've been having, but it isn't. */ /* Revision 1.4 1996/03/26 19:16:53 jaf */ /* Commented out the code at the end that copied the lower triangular */ /* half of PHI into the upper triangular half (making the resulting */ /* matrix symmetric). The upper triangular half was never used by later */ /* code in subroutine ANALYS. */ /* Revision 1.3 1996/03/18 21:16:00 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 16:47:41 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:48:01 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Load a covariance matrix. */ /* Input: */ /* ORDER - Analysis order */ /* AWINS - Analysis window start */ /* AWINF - Analysis window finish */ /* SPEECH(AWINF) - Speech buffer */ /* Indices MIN(AWINS, AWINF-(ORDER-1)) through */ /* MAX(AWINF, AWINS+(ORDER-1)) read. */ /* As long as (AWINF-AWINS) .GE. (ORDER-1), */ /* this is just indices AWINS through AWINF. */ /* Output: */ /* PHI(ORDER,ORDER) - Covariance matrix */ /* Lower triangular half and diagonal written, and read.*/ /* Upper triangular half untouched. */ /* PSI(ORDER) - Prediction vector */ /* Indices 1 through ORDER written, */ /* and most are read after that. */ /* This subroutine has no local state. */ /* Subroutine */ int mload_(integer *order, integer *awins, integer *awinf, real *speech, real *phi, real *psi) { /* System generated locals */ integer phi_dim1, phi_offset, i__1, i__2; /* Local variables */ integer c__, i__, r__, start; /* Arguments */ /* Local variables that need not be saved */ /* Load first column of triangular covariance matrix PHI */ /* Parameter adjustments */ --psi; phi_dim1 = *order; phi_offset = phi_dim1 + 1; phi -= phi_offset; --speech; /* Function Body */ start = *awins + *order; i__1 = *order; for (r__ = 1; r__ <= i__1; ++r__) { phi[r__ + phi_dim1] = 0.f; i__2 = *awinf; for (i__ = start; i__ <= i__2; ++i__) { phi[r__ + phi_dim1] += speech[i__ - 1] * speech[i__ - r__]; } } /* Load last element of vector PSI */ psi[*order] = 0.f; i__1 = *awinf; for (i__ = start; i__ <= i__1; ++i__) { psi[*order] += speech[i__] * speech[i__ - *order]; } /* End correct to get additional columns of PHI */ i__1 = *order; for (r__ = 2; r__ <= i__1; ++r__) { i__2 = r__; for (c__ = 2; c__ <= i__2; ++c__) { phi[r__ + c__ * phi_dim1] = phi[r__ - 1 + (c__ - 1) * phi_dim1] - speech[*awinf + 1 - r__] * speech[*awinf + 1 - c__] + speech[start - r__] * speech[start - c__]; } } /* End correct to get additional elements of PSI */ i__1 = *order - 1; for (c__ = 1; c__ <= i__1; ++c__) { psi[c__] = phi[c__ + 1 + phi_dim1] - speech[start - 1] * speech[start - 1 - c__] + speech[*awinf] * speech[*awinf - c__]; } /* Copy lower triangular section into upper (why bother?) */ /* I'm commenting this out, since the upper triangular half of PHI */ /* is never used by later code, unless a sufficiently high level of */ /* tracing is turned on. */ /* DO R = 1,ORDER */ /* DO C = 1,R-1 */ /* PHI(C,R) = PHI(R,C) */ /* END DO */ /* END DO */ return 0; } /* mload_ */ asterisk-11.7.0/codecs/lpc10/difmag.c0000644000175000007640000000712410513757330017127 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:32:31 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr); #endif /* ********************************************************************** */ /* DIFMAG Version 49 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:31 jaf * Initial revision * */ /* Revision 1.3 1996/03/15 23:09:39 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 14:41:31 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:45:04 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Compute Average Magnitude Difference Function */ /* Inputs: */ /* SPEECH - Low pass filtered speech */ /* Indices MIN_N1 through MAX_N1+LPITA-1 are read, where */ /* MIN_N1 = (MAXLAG - MAX_TAU)/2+1 MAX_TAU = max of TAU(I) for I=1,LTAU */ /* MAX_N1 = (MAXLAG - MIN_TAU)/2+1 MIN_TAU = min of TAU(I) for I=1,LTAU */ /* LPITA - Length of speech buffer */ /* TAU - Table of lags */ /* Indices 1 through LTAU read. */ /* LTAU - Number of lag values to compute */ /* MAXLAG - Maximum possible lag value */ /* Outputs: */ /* (All of these outputs are also read, but only after being written.) */ /* AMDF - Average Magnitude Difference for each lag in TAU */ /* Indices 1 through LTAU written */ /* MINPTR - Index of minimum AMDF value */ /* MAXPTR - Index of maximum AMDF value */ /* This subroutine has no local state. */ /* Subroutine */ int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer * maxptr) { /* System generated locals */ integer i__1, i__2; real r__1; /* Local variables */ integer i__, j, n1, n2; real sum; /* Arguments */ /* Local variables that need not be saved */ /* Local state */ /* None */ /* Parameter adjustments */ --amdf; --tau; --speech; /* Function Body */ *minptr = 1; *maxptr = 1; i__1 = *ltau; for (i__ = 1; i__ <= i__1; ++i__) { n1 = (*maxlag - tau[i__]) / 2 + 1; n2 = n1 + *lpita - 1; sum = 0.f; i__2 = n2; for (j = n1; j <= i__2; j += 4) { sum += (r__1 = speech[j] - speech[j + tau[i__]], abs(r__1)); } amdf[i__] = sum; if (amdf[i__] < amdf[*minptr]) { *minptr = i__; } if (amdf[i__] > amdf[*maxptr]) { *maxptr = i__; } } return 0; } /* difmag_ */ asterisk-11.7.0/codecs/lpc10/tbdm.c0000644000175000007640000001320710513757330016625 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:40 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:30:26 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int tbdm_(real *speech, integer *lpita, integer *tau, integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer *mintau); /*:ref: difmag_ 14 8 6 4 4 4 4 6 4 4 */ #endif /* ********************************************************************** */ /* TBDM Version 49 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:40 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:30:26 jaf * Initial revision * */ /* Revision 1.3 1996/03/18 22:14:00 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 14:48:37 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:49:54 jaf */ /* Initial revision */ /* ********************************************************************* */ /*TURBO DIFMAG: Compute High Resolution Average Magnitude Difference Function */ /* Note: There are several constants in here that appear to depend on a */ /* particular TAU table. That's not a problem for the LPC10 coder, but */ /* watch out if you change the contents of TAU in the subroutine ANALYS. */ /* Input: */ /* SPEECH - Low pass filtered speech */ /* Indices 1 through MAX+LPITA-1 are read, where: */ /* MAX = (TAU(LTAU)-TAU(1))/2+1 */ /* (If TAU(1) .LT. 39, then larger indices could be read */ /* by the last call to DIFMAG below.) */ /* LPITA - Length of speech buffer */ /* TAU - Table of lags, sorted in increasing order. */ /* Indices 1 through LTAU read. */ /* LTAU - Number of lag values to compute */ /* Output: */ /* AMDF - Average Magnitude Difference for each lag in TAU */ /* Indices 1 through LTAU written, and several might then be read.*/ /* MINPTR - Index of minimum AMDF value */ /* MAXPTR - Index of maximum AMDF value within +/- 1/2 octave of min */ /* MINTAU - Lag corresponding to minimum AMDF value */ /* This subroutine has no local state. */ /* Subroutine */ int tbdm_(real *speech, integer *lpita, integer *tau, integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer * mintau) { /* System generated locals */ integer i__1, i__2, i__3, i__4; /* Local variables */ real amdf2[6]; integer minp2, ltau2, maxp2, i__; extern /* Subroutine */ int difmag_(real *, integer *, integer *, integer *, integer *, real *, integer *, integer *); integer minamd, ptr, tau2[6]; /* Arguments */ /* REAL SPEECH(LPITA+TAU(LTAU)), AMDF(LTAU) */ /* Stupid TOAST doesn't understand expressions */ /* Local variables that need not be saved */ /* Local state */ /* None */ /* Compute full AMDF using log spaced lags, find coarse minimum */ /* Parameter adjustments */ --speech; --amdf; --tau; /* Function Body */ difmag_(&speech[1], lpita, &tau[1], ltau, &tau[*ltau], &amdf[1], minptr, maxptr); *mintau = tau[*minptr]; minamd = (integer)amdf[*minptr]; /* Build table containing all lags within +/- 3 of the AMDF minimum */ /* excluding all that have already been computed */ ltau2 = 0; ptr = *minptr - 2; /* Computing MAX */ i__1 = *mintau - 3; /* Computing MIN */ i__3 = *mintau + 3, i__4 = tau[*ltau] - 1; i__2 = min(i__3,i__4); for (i__ = max(i__1,41); i__ <= i__2; ++i__) { while(tau[ptr] < i__) { ++ptr; } if (tau[ptr] != i__) { ++ltau2; tau2[ltau2 - 1] = i__; } } /* Compute AMDF of the new lags, if there are any, and choose one */ /* if it is better than the coarse minimum */ if (ltau2 > 0) { difmag_(&speech[1], lpita, tau2, <au2, &tau[*ltau], amdf2, &minp2, & maxp2); if (amdf2[minp2 - 1] < (real) minamd) { *mintau = tau2[minp2 - 1]; minamd = (integer)amdf2[minp2 - 1]; } } /* Check one octave up, if there are any lags not yet computed */ if (*mintau >= 80) { i__ = *mintau / 2; if ((i__ & 1) == 0) { ltau2 = 2; tau2[0] = i__ - 1; tau2[1] = i__ + 1; } else { ltau2 = 1; tau2[0] = i__; } difmag_(&speech[1], lpita, tau2, <au2, &tau[*ltau], amdf2, &minp2, & maxp2); if (amdf2[minp2 - 1] < (real) minamd) { *mintau = tau2[minp2 - 1]; minamd = (integer)amdf2[minp2 - 1]; *minptr += -20; } } /* Force minimum of the AMDF array to the high resolution minimum */ amdf[*minptr] = (real) minamd; /* Find maximum of AMDF within 1/2 octave of minimum */ /* Computing MAX */ i__2 = *minptr - 5; *maxptr = max(i__2,1); /* Computing MIN */ i__1 = *minptr + 5; i__2 = min(i__1,*ltau); for (i__ = *maxptr + 1; i__ <= i__2; ++i__) { if (amdf[i__] > amdf[*maxptr]) { *maxptr = i__; } } return 0; } /* tbdm_ */ asterisk-11.7.0/codecs/lpc10/median.c0000644000175000007640000000373010513757330017134 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:31:31 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern integer median_(integer *d1, integer *d2, integer *d3); #endif /* ********************************************************************* */ /* MEDIAN Version 45G */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:31 jaf * Initial revision * */ /* Revision 1.2 1996/03/14 22:30:22 jaf */ /* Just rearranged the comments and local variable declarations a bit. */ /* Revision 1.1 1996/02/07 14:47:53 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Find median of three values */ /* Input: */ /* D1,D2,D3 - Three input values */ /* Output: */ /* MEDIAN - Median value */ integer median_(integer *d1, integer *d2, integer *d3) { /* System generated locals */ integer ret_val; /* Arguments */ ret_val = *d2; if (*d2 > *d1 && *d2 > *d3) { ret_val = *d1; if (*d3 > *d1) { ret_val = *d3; } } else if (*d2 < *d1 && *d2 < *d3) { ret_val = *d1; if (*d3 < *d1) { ret_val = *d3; } } return ret_val; } /* median_ */ asterisk-11.7.0/codecs/lpc10/placev.c0000644000175000007640000002212610513757330017151 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.3 2001/04/12 21:27:53 markh app_record now supports wildcards of sort so your output file is not overwritten every time it's run. File.h got a documentation update on the ast_fileexists to include the return call. Watch out for the placea.c placev.c code, it's updates have not been tested yet. Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set. Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:31:02 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int placev_(integer *osbuf, integer *osptr, integer *oslen, integer *obound, integer *vwin, integer *af, integer *lframe, integer *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh); #endif /* ****************************************************************** */ /* PLACEV Version 48 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.3 2001/04/12 21:27:53 markh * app_record now supports wildcards of sort so your output file is not overwritten every time it's run. File.h got a documentation update on the ast_fileexists to include the return call. Watch out for the placea.c placev.c code, it's updates have not been tested yet. Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set. * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:02 jaf * Initial revision * */ /* Revision 1.6 1996/03/19 20:42:19 jaf */ /* Added some conditions satisfied by the output values in VWIN. */ /* Revision 1.5 1996/03/19 18:37:56 jaf */ /* Strengthened the specification of which indices of VWIN are read and */ /* written. */ /* Revision 1.4 1996/03/15 16:38:33 jaf */ /* One tiny comment added. */ /* Revision 1.3 1996/03/15 16:36:13 jaf */ /* Added comments giving In/Out status of arguments. */ /* Revision 1.2 1996/03/12 23:56:01 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:48:39 jaf */ /* Initial revision */ /* ****************************************************************** */ /* Input: */ /* OSBUF Buffer which holds sorted indexes of onsets */ /* I believe that only indices 1 through OSPTR-1 can be read. */ /* OSLEN */ /* OSPTR Free pointer into OSBUF */ /* AF */ /* LFRAME */ /* MINWIN */ /* MAXWIN */ /* DVWINL */ /* DVWINH (This argument is never used. Should it be?) */ /* Input/Output: */ /* VWIN Buffer of Voicing Window Positions (Modified) */ /* Index (2,AF-1) is read. */ /* Indices (1,AF) and (2,AF) are written, */ /* and then possibly read. */ /* All other indices are unused. */ /* In all cases, the final values will satsify the condition:*/ /* VWIN(2,AF)-VWIN(1,AF)+1 .LE. MAXWIN */ /* I'm not certain yet, but they may also satisfy: */ /* MINWIN .LE. VWIN(2,AF)-VWIN(1,AF)+1 */ /* Output: */ /* OBOUND This variable is set by this procedure and used */ /* in placing analysis windows (PLACEA). Bit 1 */ /* indicates whether an onset bounds the left side */ /* of the voicing window, and bit 2 indicates whether */ /* an onset bounds the right side of the voicing window. */ /* This subroutine has no local state. */ /* Subroutine */ int placev_(integer *osbuf, integer *osptr, integer *oslen, integer *obound, integer *vwin, integer *af, integer *lframe, integer *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh) { /* System generated locals */ integer i__1, i__2; /* Local variables */ logical crit; integer i__, q, osptr1, hrange, lrange; /* Arguments */ /* Local variables that need not be saved */ /* Variables */ /* LRANGE, HRANGE Range in which window is placed */ /* OSPTR1 OSPTR excluding samples in 3F */ /* Local state */ /* None */ /* Voicing Window Placement */ /* __________________ __________________ ______________ */ /* | | | */ /* | 1F | 2F | 3F ... */ /* |__________________|__________________|______________ */ /* Previous | */ /* Window | */ /* ...________| */ /* | | */ /* ------>| This window's placement range |<------ */ /* | | */ /* There are three cases. Note that these are different from those */ /* given in the LPC-10e phase 1 report. */ /* 1. If there are no onsets in this range, then the voicing window */ /* is centered in the pitch window. If such a placement is not within */ /* the window's placement range, then the window is placed in the left- */ /* most portion of the placement range. Its length is always MAXWIN. */ /* 2. If the first onset is in 2F and there is sufficient room to place */ /* the window immediately before this onset, then the window is placed */ /* there, and its length is set to the maximum possible under these */ /* constraints. */ /* "Critical Region Exception": If there is another onset in 2F */ /* such that a window can be placed between the two onsets, the */ /* window is placed there (ie, as in case 3). */ /* 3. Otherwise, the window is placed immediately after the onset. The */ /* window's length */ /* is the longest length that can fit in the range under these constraint s,*/ /* except that the window may be shortened even further to avoid overlapp ing*/ /* other onsets in the placement range. In any case, the window's length */ /* is at least MINWIN. */ /* Note that the values of MINWIN and LFRAME must be chosen such */ /* that case 2 = false implies case 3 = true. This means that */ /* MINWIN <= LFRAME/2. If this were not the case, then a fourth case */ /* would have to be added for when the window cannot fit either before */ /* or after the onset. */ /* Note also that onsets which weren't in 2F last time may be in 1F this */ /* time, due to the filter delays in computing onsets. The result is tha t*/ /* occasionally a voicing window will overlap that onset. The only way */ /* to circumvent this problem is to add more delay in processing input */ /* speech. In the trade-off between delay and window-placement, window */ /* placement lost. */ /* Compute the placement range */ /* Parameter adjustments */ --osbuf; vwin -= 3; /* Function Body */ /* Computing MAX */ i__1 = vwin[((*af - 1) << 1) + 2] + 1, i__2 = (*af - 2) * *lframe + 1; lrange = max(i__1,i__2); hrange = *af * *lframe; /* Compute OSPTR1, so the following code only looks at relevant onsets. */ for (osptr1 = *osptr - 1; osptr1 >= 1; --osptr1) { if (osbuf[osptr1] <= hrange) { goto L90; } } L90: ++osptr1; /* Check for case 1 first (fast case): */ if (osptr1 <= 1 || osbuf[osptr1 - 1] < lrange) { /* Computing MAX */ i__1 = vwin[((*af - 1) << 1) + 2] + 1; vwin[(*af << 1) + 1] = max(i__1,*dvwinl); vwin[(*af << 1) + 2] = vwin[(*af << 1) + 1] + *maxwin - 1; *obound = 0; } else { /* Search backward in OSBUF for first onset in range. */ /* This code relies on the above check being performed first. */ for (q = osptr1 - 1; q >= 1; --q) { if (osbuf[q] < lrange) { goto L100; } } L100: ++q; /* Check for case 2 (placement before onset): */ /* Check for critical region exception: */ i__1 = osptr1 - 1; for (i__ = q + 1; i__ <= i__1; ++i__) { if (osbuf[i__] - osbuf[q] >= *minwin) { crit = TRUE_; goto L105; } } crit = FALSE_; L105: /* Computing MAX */ i__1 = (*af - 1) * *lframe, i__2 = lrange + *minwin - 1; if (! crit && osbuf[q] > max(i__1,i__2)) { vwin[(*af << 1) + 2] = osbuf[q] - 1; /* Computing MAX */ i__1 = lrange, i__2 = vwin[(*af << 1) + 2] - *maxwin + 1; vwin[(*af << 1) + 1] = max(i__1,i__2); *obound = 2; /* Case 3 (placement after onset) */ } else { vwin[(*af << 1) + 1] = osbuf[q]; L110: ++q; if (q >= osptr1) { goto L120; } if (osbuf[q] > vwin[(*af << 1) + 1] + *maxwin) { goto L120; } if (osbuf[q] < vwin[(*af << 1) + 1] + *minwin) { goto L110; } vwin[(*af << 1) + 2] = osbuf[q] - 1; *obound = 3; return 0; L120: /* Computing MIN */ i__1 = vwin[(*af << 1) + 1] + *maxwin - 1; vwin[(*af << 1) + 2] = min(i__1,hrange); *obound = 1; } } return 0; } /* placev_ */ asterisk-11.7.0/codecs/lpc10/lpcdec.c0000644000175000007640000002426410513757330017136 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:30:11 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Changed name of function from lpcenc_ to lpc10_encode, simply to make * all lpc10 functions have more consistent naming with each other. * * Revision 1.1 1996/08/19 22:31:48 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int lpcdec_(integer *bits, real *speech); extern int initlpcdec_(void); /* comlen contrl_ 12 */ /*:ref: chanrd_ 14 5 4 4 4 4 4 */ /*:ref: decode_ 14 7 4 4 4 4 4 6 6 */ /*:ref: synths_ 14 6 4 4 6 6 6 4 */ /*:ref: initdecode_ 14 0 */ /*:ref: initsynths_ 14 0 */ #endif /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* Table of constant values */ static integer c__10 = 10; /* ***************************************************************** */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:30:11 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Changed name of function from lpcenc_ to lpc10_encode, simply to make * all lpc10 functions have more consistent naming with each other. * * Revision 1.1 1996/08/19 22:31:48 jaf * Initial revision * */ /* Revision 1.1 1996/03/28 00:03:00 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Decode 54 bits to one frame of 180 speech samples. */ /* Input: */ /* BITS - 54 encoded bits, stored 1 per array element. */ /* Indices 1 through 53 read (SYNC bit ignored). */ /* Output: */ /* SPEECH - Speech encoded as real values in the range [-1,+1]. */ /* Indices 1 through 180 written. */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITLPCDEC. */ /* Subroutine */ int lpc10_decode(integer *bits, real *speech, struct lpc10_decoder_state *st) { integer irms, voice[2], pitch, ipitv; extern /* Subroutine */ int decode_(integer *, integer *, integer *, integer *, integer *, real *, real *, struct lpc10_decoder_state *); real rc[10]; extern /* Subroutine */ int chanrd_(integer *, integer *, integer *, integer *, integer *), synths_(integer *, integer *, real *, real *, real *, integer *, struct lpc10_decoder_state *); integer irc[10], len; real rms; /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:30:11 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Changed name of function from lpcenc_ to lpc10_encode, simply to make * all lpc10 functions have more consistent naming with each other. * * Revision 1.1 1996/08/19 22:31:48 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:30:11 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Changed name of function from lpcenc_ to lpc10_encode, simply to make * all lpc10 functions have more consistent naming with each other. * * Revision 1.1 1996/08/19 22:31:48 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Local variables that need not be saved */ /* Uncoded speech parameters */ /* Coded speech parameters */ /* Others */ /* Local state */ /* None */ /* Parameter adjustments */ if (bits) { --bits; } if (speech) { --speech; } /* Function Body */ chanrd_(&c__10, &ipitv, &irms, irc, &bits[1]); decode_(&ipitv, &irms, irc, voice, &pitch, &rms, rc, st); synths_(voice, &pitch, &rms, rc, &speech[1], &len, st); return 0; } /* lpcdec_ */ asterisk-11.7.0/codecs/lpc10/onset.c0000644000175000007640000002466710513757330017043 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:37:55 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:31:18 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int onset_(real *pebuf, integer *osbuf, integer *osptr, integer *oslen, integer *sbufl, integer *sbufh, integer *lframe, struct lpc10_encoder_state *st); #endif /* Table of constant values */ static real c_b2 = 1.f; /* ****************************************************************** */ /* ONSET Version 49 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:37:55 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:31:18 jaf * Initial revision * */ /* Revision 1.5 1996/03/15 16:41:01 jaf */ /* Just rearranged INITONSET assignment orders to be consistent with */ /* order of DATA statements in ONSET. */ /* Revision 1.4 1996/03/15 15:48:27 jaf */ /* Changed some comments, and only reordered the DATA statements (their */ /* meaning wasn't changed). */ /* Revision 1.3 1996/03/14 23:53:06 jaf */ /* Added an entry INITONSET that reinitializes the local state variables */ /* of subroutine ONSET. */ /* Rearranged quite a few comments, adding more explaining which */ /* arguments were inputs, and how the modified ones can be changed. */ /* Revision 1.2 1996/03/12 23:53:00 jaf */ /* Lots of comments added about the local state of this subroutine that */ /* must be saved from one invocation to the next. */ /* One constant 180 replaced with LFRAME, which should be "more general", */ /* even though it would probably require many more changes than this to */ /* get this coder to work for other frame sizes. */ /* Revision 1.1 1996/02/07 14:48:09 jaf */ /* Initial revision */ /* ****************************************************************** */ /* Floating point version */ /* Detection of onsets in (or slightly preceding) the futuremost frame */ /* of speech. */ /* Input: */ /* PEBUF(SBUFL:SBUFH) - Preemphasized speech */ /* Indices SBUFH-LFRAME through SBUFH are read. */ /* OSLEN - Maximum number of onsets that can be stored in OSBUF. */ /* SBUFL, SBUFH - Range of PEBUF */ /* LFRAME - length of a frame, in samples */ /* Input/Output: */ /* OSBUF(OSLEN) - Buffer which holds sorted indexes of onsets */ /* Indices A through B are modified, where A */ /* is the original value of OSPTR, and B is the final */ /* value of OSPTR-1. B is at most OSLEN. */ /* OSPTR - Free pointer into OSBUF */ /* Initial value should be .LE. OSLEN+1. */ /* If so, final value grows by one for each new onset */ /* found, and final value will be .LE. OSLEN+1. */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this subroutine, or */ /* reinitialize its state for any other reason, call the ENTRY INITONSET. */ /* Subroutine */ int onset_(real *pebuf, integer *osbuf, integer * osptr, integer *oslen, integer *sbufl, integer *sbufh, integer * lframe, struct lpc10_encoder_state *st) { /* Initialized data */ real *n; real *d__; real *l2buf; real *l2sum1; integer *l2ptr1; integer *l2ptr2; logical *hyst; /* System generated locals */ integer pebuf_offset, i__1; real r__1; /* Builtin functions */ double r_sign(real *, real *); /* Local variables */ integer i__; integer *lasti; real l2sum2; real *fpc; /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:37:55 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:31:18 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Parameters/constants */ /* Parameters for onset detection algorithm: */ /* L2 Threshold for filtered slope of FPC (function of L2WID!) */ /* L2LAG Lag due to both filters which compute filtered slope of FPC */ /* L2WID Width of the filter which computes the slope of FPC */ /* OSHYST The number of samples of slope(FPC) which must be below */ /* the threshold before a new onset may be declared. */ /* Local variables that need not be saved */ /* Local state */ /* Variables */ /* N, D Numerator and denominator of prediction filters */ /* FPC Current prediction coefs */ /* L2BUF, L2SUM1, L2SUM2 State of slope filter */ /* The only "significant" change I've made is to change L2SUM2 out */ /* of the list of local variables that need to be saved, since it */ /* didn't need to be. */ /* L2SUM1 need not be, but avoiding saving it would require a small */ /* change to the body of the code. See comments below for an */ /* example of how the code could be changed to avoid saving L2SUM1. */ /* FPC and LASTI are saved from one invocation to the next, but */ /* they are not given initial values. This is acceptable, because */ /* FPC will be assigned a value the first time that this function */ /* is called after D is initialized to 1, since the formula to */ /* change D will not change it to 0 in one step, and the IF (D */ /* .NE. 0) statement will execute its THEN part, initializing FPC. */ /* LASTI's value will not be used until HYST is .TRUE., and */ /* whenever HYST is changed from its initial value of .FALSE., */ /* LASTI is assigned a value. */ /* In a C version of this coder, it would be nice if all of these */ /* saved things, in this and all other subroutines, could be stored */ /* in a single struct lpc10_coder_state_t, initialized with a call */ /* to a function like lpc10_init(&lpc10_coder_state). In this way, */ /* a program that used these functions could conveniently alternate */ /* coding more than one distinct audio stream. */ n = &(st->n); d__ = &(st->d__); fpc = &(st->fpc); l2buf = &(st->l2buf[0]); l2sum1 = &(st->l2sum1); l2ptr1 = &(st->l2ptr1); l2ptr2 = &(st->l2ptr2); lasti = &(st->lasti); hyst = &(st->hyst); /* Parameter adjustments */ if (osbuf) { --osbuf; } if (pebuf) { pebuf_offset = *sbufl; pebuf -= pebuf_offset; } /* Function Body */ /* The following line subtracted a hard-coded "180" from LASTI, */ /* instead of using a variable like LFRAME or a constant like */ /* MAXFRM. I changed it to LFRAME, for "generality". */ if (*hyst) { *lasti -= *lframe; } i__1 = *sbufh; for (i__ = *sbufh - *lframe + 1; i__ <= i__1; ++i__) { /* Compute FPC; Use old FPC on divide by zero; Clamp FPC to +/- 1. */ *n = (pebuf[i__] * pebuf[i__ - 1] + (*n) * 63.f) / 64.f; /* Computing 2nd power */ r__1 = pebuf[i__ - 1]; *d__ = (r__1 * r__1 + (*d__) * 63.f) / 64.f; if ((*d__) != 0.f) { if (abs(*n) > (*d__)) { *fpc = (real)r_sign(&c_b2, n); } else { *fpc = (*n) / (*d__); } } /* Filter FPC */ /* In order to allow L2SUM1 not to be saved from one invocation of */ /* this subroutine to the next, one could change the sequence of */ /* assignments below, up to the IF statement, to the following. In */ /* addition, the initial value of L2PTR2 should be changed to */ /* L2WID/2 instead of L2WID/2+1. */ /* L2SUM1 = L2BUF(L2PTR2) */ /* L2PTR2 = MOD(L2PTR2,L2WID)+1 */ /* L2SUM1 = L2SUM1 - L2BUF(L2PTR2) + FPC */ /* L2BUF(L2PTR2) = L2SUM1 */ /* * The following lines didn't change from the original: */ /* L2SUM2 = L2BUF(L2PTR1) */ /* L2BUF(L2PTR1) = FPC */ /* L2PTR1 = MOD(L2PTR1,L2WID)+1 */ l2sum2 = l2buf[*l2ptr1 - 1]; *l2sum1 = *l2sum1 - l2buf[*l2ptr2 - 1] + *fpc; l2buf[*l2ptr2 - 1] = *l2sum1; l2buf[*l2ptr1 - 1] = *fpc; *l2ptr1 = *l2ptr1 % 16 + 1; *l2ptr2 = *l2ptr2 % 16 + 1; if ((r__1 = *l2sum1 - l2sum2, abs(r__1)) > 1.7f) { if (! (*hyst)) { /* Ignore if buffer full */ if (*osptr <= *oslen) { osbuf[*osptr] = i__ - 9; ++(*osptr); } *hyst = TRUE_; } *lasti = i__; /* After one onset detection, at least OSHYST sample times m ust go */ /* by before another is allowed to occur. */ } else if ((*hyst) && i__ - *lasti >= 10) { *hyst = FALSE_; } } return 0; } /* onset_ */ asterisk-11.7.0/codecs/lpc10/rcchk.c0000644000175000007640000000572310513757330016775 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:30:41 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int rcchk_(integer *order, real *rc1f, real *rc2f); #endif /* ********************************************************************* */ /* RCCHK Version 45G */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:30:41 jaf * Initial revision * */ /* Revision 1.4 1996/03/27 18:13:47 jaf */ /* Commented out a call to subroutine ERROR. */ /* Revision 1.3 1996/03/18 15:48:53 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 16:55:22 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:49:08 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Check RC's, repeat previous frame's RC's if unstable */ /* Input: */ /* ORDER - Number of RC's */ /* RC1F - Previous frame's RC's */ /* Indices 1 through ORDER may be read. */ /* Input/Output: */ /* RC2F - Present frame's RC's */ /* Indices 1 through ORDER may be read, and written. */ /* This subroutine has no local state. */ /* Subroutine */ int rcchk_(integer *order, real *rc1f, real *rc2f) { /* System generated locals */ integer i__1; real r__1; /* Local variables */ integer i__; /* Arguments */ /* Local variables that need not be saved */ /* Parameter adjustments */ --rc2f; --rc1f; /* Function Body */ i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { if ((r__1 = rc2f[i__], abs(r__1)) > .99f) { goto L10; } } return 0; /* Note: In version embedded in other software, all calls to ERROR */ /* should probably be removed. */ L10: /* This call to ERROR is only needed for debugging purposes. */ /* CALL ERROR('RCCHK',2,I) */ i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { rc2f[i__] = rc1f[i__]; } return 0; } /* rcchk_ */ asterisk-11.7.0/codecs/lpc10/vparms.c0000644000175000007640000002114010513757330017202 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:40 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:30:04 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int vparms_(integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *dither, integer *mintau, integer *zc, integer *lbe, integer *fbe, real *qs, real *rc1, real *ar_b__, real *ar_f__); #endif /* Table of constant values */ static real c_b2 = 1.f; /* ********************************************************************* */ /* VPARMS Version 50 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:40 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:30:04 jaf * Initial revision * */ /* Revision 1.6 1996/03/29 18:01:16 jaf */ /* Added some more comments about the range of INBUF and LPBUF that can */ /* be read. Note that it is possible for index VWIN(2)+1 to be read from */ /* INBUF, which might be outside of its defined range, although that will */ /* require more careful checking. */ /* Revision 1.5 1996/03/19 00:02:02 jaf */ /* I just noticed that the argument DITHER is modified inside of this */ /* subroutine. Comments were added explaining the possible final values. */ /* Revision 1.4 1996/03/18 22:22:59 jaf */ /* Finishing the job I said I did with the last check-in comments. */ /* Revision 1.3 1996/03/18 22:22:17 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 15:02:58 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:50:42 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Calculate voicing parameters: */ /* Input: */ /* VWIN - Voicing window limits */ /* Indices 1 through 2 read. */ /* INBUF - Input speech buffer */ /* Indices START-1 through STOP read, */ /* where START and STOP are defined in the code (only written once). */ /* Note that STOP can be as large as VWIN(2)+1 ! */ /* LPBUF - Low pass filtered speech */ /* Indices START-MINTAU through STOP+MINTAU read, */ /* where START and STOP are defined in the code (only written once). */ /* BUFLIM - Array bounds for INBUF and LPBUF */ /* Indices 1 through 4 read. */ /* HALF - Half frame (1 or 2) */ /* MINTAU - Lag corresponding to minimum AMDF value (pitch estimate) */ /* Input/Output: */ /* DITHER - Zero crossing threshold */ /* The resulting value might be the negation of the input */ /* value. It might always be the same as the input value, */ /* if the DO loop below always executes an even number of times. */ /* Output: (all of them are written on every call) */ /* ZC - Zero crossing rate */ /* LBE - Low band energy (sum of magnitudes - SM) */ /* FBE - Full band energy (SM) */ /* QS - Ratio of 6 dB/oct preemphasized energy to full band energy */ /* RC1 - First reflection coefficient */ /* AR_B - Product of the causal forward and reverse pitch */ /* prediction gains */ /* AR_F - Product of the noncausal forward and reverse pitch */ /* prediction gains */ /* Internal: */ /* OLDSGN - Previous sign of dithered signal */ /* VLEN - Length of voicing window */ /* START - Lower address of current half of voicing window */ /* STOP - Upper address of current half of voicing window */ /* E_0 - Energy of LPF speech (sum of squares - SS) */ /* E_B - Energy of LPF speech backward one pitch period (SS) */ /* E_F - Energy of LPF speech forward one pitch period (SS) */ /* R_B - Autocovariance of LPF speech backward one pitch period */ /* R_F - Autocovariance of LPF speech forward one pitch period */ /* LP_RMS - Energy of LPF speech (sum of magnitudes - SM) */ /* AP_RMS - Energy of all-pass speech (SM) */ /* E_PRE - Energy of 6dB preemphasized speech (SM) */ /* E0AP - Energy of all-pass speech (SS) */ /* This subroutine has no local state. */ /* Subroutine */ int vparms_(integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *dither, integer *mintau, integer *zc, integer *lbe, integer *fbe, real *qs, real *rc1, real *ar_b__, real * ar_f__) { /* System generated locals */ integer inbuf_offset, lpbuf_offset, i__1; real r__1, r__2; /* Builtin functions */ double r_sign(real *, real *); integer i_nint(real *); /* Local variables */ integer vlen, stop, i__; real e_pre__; integer start; real ap_rms__, e_0__, oldsgn, lp_rms__, e_b__, e_f__, r_b__, r_f__, e0ap; /* Arguments */ /* Local variables that need not be saved */ /* Calculate zero crossings (ZC) and several energy and correlation */ /* measures on low band and full band speech. Each measure is taken */ /* over either the first or the second half of the voicing window, */ /* depending on the variable HALF. */ /* Parameter adjustments */ --vwin; --buflim; lpbuf_offset = buflim[3]; lpbuf -= lpbuf_offset; inbuf_offset = buflim[1]; inbuf -= inbuf_offset; /* Function Body */ lp_rms__ = 0.f; ap_rms__ = 0.f; e_pre__ = 0.f; e0ap = 0.f; *rc1 = 0.f; e_0__ = 0.f; e_b__ = 0.f; e_f__ = 0.f; r_f__ = 0.f; r_b__ = 0.f; *zc = 0; vlen = vwin[2] - vwin[1] + 1; start = vwin[1] + (*half - 1) * vlen / 2 + 1; stop = start + vlen / 2 - 1; /* I'll use the symbol HVL in the table below to represent the value */ /* VLEN/2. Note that if VLEN is odd, then HVL should be rounded down, */ /* i.e., HVL = (VLEN-1)/2. */ /* HALF START STOP */ /* 1 VWIN(1)+1 VWIN(1)+HVL */ /* 2 VWIN(1)+HVL+1 VWIN(1)+2*HVL */ /* Note that if VLEN is even and HALF is 2, then STOP will be */ /* VWIN(1)+VLEN = VWIN(2)+1. That could be bad, if that index of INBUF */ /* is undefined. */ r__1 = inbuf[start - 1] - *dither; oldsgn = (real)r_sign(&c_b2, &r__1); i__1 = stop; for (i__ = start; i__ <= i__1; ++i__) { lp_rms__ += (r__1 = lpbuf[i__], abs(r__1)); ap_rms__ += (r__1 = inbuf[i__], abs(r__1)); e_pre__ += (r__1 = inbuf[i__] - inbuf[i__ - 1], abs(r__1)); /* Computing 2nd power */ r__1 = inbuf[i__]; e0ap += r__1 * r__1; *rc1 += inbuf[i__] * inbuf[i__ - 1]; /* Computing 2nd power */ r__1 = lpbuf[i__]; e_0__ += r__1 * r__1; /* Computing 2nd power */ r__1 = lpbuf[i__ - *mintau]; e_b__ += r__1 * r__1; /* Computing 2nd power */ r__1 = lpbuf[i__ + *mintau]; e_f__ += r__1 * r__1; r_f__ += lpbuf[i__] * lpbuf[i__ + *mintau]; r_b__ += lpbuf[i__] * lpbuf[i__ - *mintau]; r__1 = inbuf[i__] + *dither; if (r_sign(&c_b2, &r__1) != oldsgn) { ++(*zc); oldsgn = -oldsgn; } *dither = -(*dither); } /* Normalized short-term autocovariance coefficient at unit sample delay */ *rc1 /= max(e0ap,1.f); /* Ratio of the energy of the first difference signal (6 dB/oct preemphas is)*/ /* to the energy of the full band signal */ /* Computing MAX */ r__1 = ap_rms__ * 2.f; *qs = e_pre__ / max(r__1,1.f); /* aR_b is the product of the forward and reverse prediction gains, */ /* looking backward in time (the causal case). */ *ar_b__ = r_b__ / max(e_b__,1.f) * (r_b__ / max(e_0__,1.f)); /* aR_f is the same as aR_b, but looking forward in time (non causal case ).*/ *ar_f__ = r_f__ / max(e_f__,1.f) * (r_f__ / max(e_0__,1.f)); /* Normalize ZC, LBE, and FBE to old fixed window length of 180. */ /* (The fraction 90/VLEN has a range of .58 to 1) */ r__2 = (real) (*zc << 1); r__1 = r__2 * (90.f / vlen); *zc = i_nint(&r__1); /* Computing MIN */ r__1 = lp_rms__ / 4 * (90.f / vlen); i__1 = i_nint(&r__1); *lbe = min(i__1,32767); /* Computing MIN */ r__1 = ap_rms__ / 4 * (90.f / vlen); i__1 = i_nint(&r__1); *fbe = min(i__1,32767); return 0; } /* vparms_ */ asterisk-11.7.0/codecs/lpc10/preemp.c0000644000175000007640000001015210513757330017163 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:30:58 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z__); #endif /* ******************************************************************* */ /* PREEMP Version 55 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:30:58 jaf * Initial revision * */ /* Revision 1.3 1996/03/14 23:16:29 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/11 23:23:34 jaf */ /* Added a bunch of comments to an otherwise simple subroutine. */ /* Revision 1.1 1996/02/07 14:48:48 jaf */ /* Initial revision */ /* ******************************************************************* */ /* Preemphasize speech with a single-zero filter. */ /* (When coef = .9375, preemphasis is as in LPC43.) */ /* Inputs: */ /* NSAMP - Number of samples to filter */ /* INBUF - Input speech buffer */ /* Indices 1 through NSAMP are read. */ /* COEF - Preemphasis coefficient */ /* Input/Output: */ /* Z - Filter state */ /* Output: */ /* PEBUF - Preemphasized speech buffer (can be equal to INBUF) */ /* Indices 1 through NSAMP are modified. */ /* This subroutine has no local state. */ /* Subroutine */ int preemp_(real *inbuf, real *pebuf, integer *nsamp, real * coef, real *z__) { /* System generated locals */ integer i__1; /* Local variables */ real temp; integer i__; /* Arguments */ /* Local variables */ /* None of these need to have their values saved from one */ /* invocation to the next. */ /* Logically, this subroutine computes the output sequence */ /* pebuf(1:nsamp) defined by: */ /* pebuf(i) = inbuf(i) - coef * inbuf(i-1) */ /* where inbuf(0) is defined by the value of z given as input to */ /* this subroutine. */ /* What is this filter's frequency response and phase response? */ /* Why is this filter applied to the speech? */ /* Could it be more efficient to apply multiple filters */ /* simultaneously, by combining them into one equivalent filter? */ /* Are there ever cases when "factoring" one high-order filter into */ /* multiple smaller-order filter actually reduces the number of */ /* arithmetic operations needed to perform them? */ /* When I first read this subroutine, I didn't understand why the */ /* variable temp was used. It seemed that the statements in the do */ /* loop could be replaced with the following: */ /* pebuf(i) = inbuf(i) - coef * z */ /* z = inbuf(i) */ /* The reason for temp is so that even if pebuf and inbuf are the */ /* same arrays in memory (i.e., they are aliased), then this */ /* subroutine will still work correctly. I didn't realize this */ /* until seeing the comment after PEBUF above that says "(can be */ /* equal to INBUF)". */ /* Parameter adjustments */ --pebuf; --inbuf; /* Function Body */ i__1 = *nsamp; for (i__ = 1; i__ <= i__1; ++i__) { temp = inbuf[i__] - *coef * *z__; *z__ = inbuf[i__]; pebuf[i__] = temp; /* L10: */ } return 0; } /* preemp_ */ asterisk-11.7.0/codecs/lpc10/random.c0000644000175000007640000000643310513757330017162 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:41:32 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:30:49 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern integer random_(struct lpc10_decoder_state *st); #endif /* ********************************************************************** */ /* RANDOM Version 49 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:41:32 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:30:49 jaf * Initial revision * */ /* Revision 1.3 1996/03/20 16:13:54 jaf */ /* Rearranged comments a little bit, and added comments explaining that */ /* even though there is local state here, there is no need to create an */ /* ENTRY for reinitializing it. */ /* Revision 1.2 1996/03/14 22:25:29 jaf */ /* Just rearranged the comments and local variable declarations a bit. */ /* Revision 1.1 1996/02/07 14:49:01 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Pseudo random number generator based on Knuth, Vol 2, p. 27. */ /* Function Return: */ /* RANDOM - Integer variable, uniformly distributed over -32768 to 32767 */ /* This subroutine maintains local state from one call to the next. */ /* In the context of the LPC10 coder, there is no reason to reinitialize */ /* this local state when switching between audio streams, because its */ /* results are only used to generate noise for unvoiced frames. */ integer random_(struct lpc10_decoder_state *st) { /* Initialized data */ integer *j; integer *k; shortint *y; /* System generated locals */ integer ret_val; /* Parameters/constants */ /* Local state */ /* The following is a 16 bit 2's complement addition, */ /* with overflow checking disabled */ j = &(st->j); k = &(st->k); y = &(st->y[0]); y[*k - 1] += y[*j - 1]; ret_val = y[*k - 1]; --(*k); if (*k <= 0) { *k = 5; } --(*j); if (*j <= 0) { *j = 5; } return ret_val; } /* random_ */ asterisk-11.7.0/codecs/lpc10/decode.c0000644000175000007640000005017010513757330017122 0ustar sharkyjerryweb/* $Log$ Revision 1.16 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.15 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.2 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.1.1.1 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:22:39 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:38 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int decode_(integer *ipitv, integer *irms, integer *irc, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_decoder_state *st); /* comlen contrl_ 12 */ /*:ref: ham84_ 14 3 4 4 4 */ /*:ref: median_ 4 3 4 4 4 */ #endif /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* Table of constant values */ static integer c__2 = 2; /* ***************************************************************** */ /* DECODE Version 54 */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:22:39 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:38 jaf * Initial revision * */ /* Revision 1.5 1996/05/23 20:06:03 jaf */ /* Assigned PITCH a "default" value on the first call, since otherwise it */ /* would be left uninitialized. */ /* Revision 1.4 1996/03/26 19:35:18 jaf */ /* Commented out trace statements. */ /* Revision 1.3 1996/03/21 21:10:50 jaf */ /* Added entry INITDECODE to reinitialize the local state of subroutine */ /* DECODE. */ /* Revision 1.2 1996/03/21 21:04:50 jaf */ /* Determined which local variables should be saved from one invocation */ /* to the next, and guessed initial values for some that should have been */ /* saved, but weren't given initial values. Many of the arrays are */ /* "constants", and many local variables are only used if the "global" */ /* variable CORRP is .TRUE. */ /* Added comments explaining which indices of array arguments are read or */ /* written. */ /* Revision 1.1 1996/02/12 03:21:10 jaf */ /* Initial revision */ /* ***************************************************************** */ /* This subroutine provides error correction and decoding */ /* for all LPC parameters */ /* Input: */ /* IPITV - Index value of pitch */ /* IRMS - Coded Energy */ /* CORRP - Error correction: */ /* If FALSE, parameters are decoded directly with no delay. If TRUE, */ /* most important parameter bits are protected by Hamming code and */ /* median smoothed. This requires an additional frame of delay. */ /* Input/Output: */ /* IRC - Coded Reflection Coefficients */ /* Indices 1 through ORDER always read, then written. */ /* Output: */ /* VOICE - Half frame voicing decisions */ /* Indices 1 through 2 written. */ /* PITCH - Decoded pitch */ /* RMS - Energy */ /* RC - Reflection coefficients */ /* Indices 1 through ORDER written. */ /* NOTE: Zero RC's should be done more directly, but this would affect */ /* coded parameter printout. */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITDECODE. */ /* Subroutine */ int decode_(integer *ipitv, integer *irms, integer *irc, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_decoder_state *st) { /* Initialized data */ logical *first; static integer ethrs = 2048; static integer ethrs1 = 128; static integer ethrs2 = 1024; static integer ethrs3 = 2048; static integer ivtab[32] = { 24960,24960,24960,24960,25480,25480,25483, 25480,16640,1560,1560,1560,16640,1816,1563,1560,24960,24960,24859, 24856,26001,25881,25915,25913,1560,1560,7800,3640,1561,1561,3643, 3641 }; static real corth[32] /* was [4][8] */ = { 32767.f,10.f,5.f,0.f, 32767.f,8.f,4.f,0.f,32.f,6.4f,3.2f,0.f,32.f,6.4f,3.2f,0.f,32.f, 11.2f,6.4f,0.f,32.f,11.2f,6.4f,0.f,16.f,5.6f,3.2f,0.f,16.f,5.6f, 3.2f,0.f }; static integer detau[128] = { 0,0,0,3,0,3,3,31,0,3,3,21,3,3,29,30,0,3,3, 20,3,25,27,26,3,23,58,22,3,24,28,3,0,3,3,3,3,39,33,32,3,37,35,36, 3,38,34,3,3,42,46,44,50,40,48,3,54,3,56,3,52,3,3,1,0,3,3,108,3,78, 100,104,3,84,92,88,156,80,96,3,3,74,70,72,66,76,68,3,62,3,60,3,64, 3,3,1,3,116,132,112,148,152,3,3,140,3,136,3,144,3,3,1,124,120,128, 3,3,3,3,1,3,3,3,1,3,1,1,1 }; static integer rmst[64] = { 1024,936,856,784,718,656,600,550,502,460,420, 384,352,328,294,270,246,226,206,188,172,158,144,132,120,110,102, 92,84,78,70,64,60,54,50,46,42,38,34,32,30,26,24,22,20,18,17,16,15, 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 }; static integer detab7[32] = { 4,11,18,25,32,39,46,53,60,66,72,77,82,87,92, 96,101,104,108,111,114,115,117,119,121,122,123,124,125,126,127, 127 }; static real descl[8] = { .6953f,.625f,.5781f,.5469f,.5312f,.5391f,.4688f, .3828f }; integer *ivp2h; static integer deadd[8] = { 1152,-2816,-1536,-3584,-1280,-2432,768,-1920 } ; static integer qb[8] = { 511,511,1023,1023,1023,1023,2047,4095 }; static integer nbit[10] = { 8,8,5,5,4,4,4,4,3,2 }; static integer zrc[10] = { 0,0,0,0,0,3,0,2,0,0 }; static integer bit[5] = { 2,4,8,16,32 }; integer *iovoic; integer *iavgp; integer *iptold; integer *erate; integer *drc; integer *dpit; integer *drms; /* System generated locals */ integer i__1, i__2; /* Builtin functions */ integer pow_ii(integer *, integer *); /* Local variables */ extern /* Subroutine */ int ham84_(integer *, integer *, integer *); integer ipit, iout, i__, icorf, index, ivoic, ixcor, i1, i2, i4; extern integer median_(integer *, integer *, integer *); integer ishift, errcnt, lsb; /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:22:39 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:38 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Arguments */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:22:39 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:38 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Function return value definitions */ /* Parameters/constants */ /* The variables below that are not Fortran PARAMETER's are */ /* initialized with DATA statements, and then never modified. */ /* The following are used regardless of CORRP's value. */ /* DETAU, NBIT, QB, DEADD, DETAB7, RMST, DESCL */ /* The following are used only if CORRP is .TRUE. */ /* ETHRS, ETHRS1, ETHRS2, ETHRS3, IVTAB, BIT, CORTH, ZRC */ /* Local variables that need not be saved */ /* The following are used regardless of CORRP's value */ /* The following are used only if CORRP is .TRUE. */ /* Local state */ /* The following are used regardless of CORRP's value */ /* The following are used only if CORRP is .TRUE. */ /* I am guessing the initial values for IVP2H, IOVOIC, DRC, DPIT, */ /* and DRMS. They should be checked to see if they are reasonable. */ /* I'm also guessing for ERATE, but I think 0 is the right initial */ /* value. */ /* Parameter adjustments */ if (irc) { --irc; } if (voice) { --voice; } if (rc) { --rc; } /* Function Body */ iptold = &(st->iptold); first = &(st->first); ivp2h = &(st->ivp2h); iovoic = &(st->iovoic); iavgp = &(st->iavgp); erate = &(st->erate); drc = &(st->drc[0]); dpit = &(st->dpit[0]); drms = &(st->drms[0]); /* DATA statements for "constants" defined above. */ /* IF (LISTL.GE.3) WRITE(FDEBUG,800) IPITV,IRMS,(IRC(J),J=1,ORDER) */ /* 800 FORMAT(1X,' <>',T32,6X,I6,I5,T50,10I8) */ /* If no error correction, do pitch and voicing then jump to decode */ i4 = detau[*ipitv]; if (! contrl_1.corrp) { voice[1] = 1; voice[2] = 1; if (*ipitv <= 1) { voice[1] = 0; } if (*ipitv == 0 || *ipitv == 2) { voice[2] = 0; } *pitch = i4; if (*pitch <= 4) { *pitch = *iptold; } if (voice[1] == 1 && voice[2] == 1) { *iptold = *pitch; } if (voice[1] != voice[2]) { *pitch = *iptold; } goto L900; } /* Do error correction pitch and voicing */ if (i4 > 4) { dpit[0] = i4; ivoic = 2; *iavgp = (*iavgp * 15 + i4 + 8) / 16; } else { ivoic = i4; dpit[0] = *iavgp; } drms[0] = *irms; i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { drc[i__ * 3 - 3] = irc[i__]; } /* Determine index to IVTAB from V/UV decision */ /* If error rate is high then use alternate table */ index = (*ivp2h << 4) + (*iovoic << 2) + ivoic + 1; i1 = ivtab[index - 1]; ipit = i1 & 3; icorf = i1 / 8; if (*erate < ethrs) { icorf /= 64; } /* Determine error rate: 4=high 1=low */ ixcor = 4; if (*erate < ethrs3) { ixcor = 3; } if (*erate < ethrs2) { ixcor = 2; } if (*erate < ethrs1) { ixcor = 1; } /* Voice/unvoice decision determined from bits 0 and 1 of IVTAB */ voice[1] = icorf / 2 & 1; voice[2] = icorf & 1; /* Skip decoding on first frame because present data not yet available */ if (*first) { *first = FALSE_; /* Assign PITCH a "default" value on the first call, since */ /* otherwise it would be left uninitialized. The two lines */ /* below were copied from above, since it seemed like a */ /* reasonable thing to do for the first call. */ *pitch = i4; if (*pitch <= 4) { *pitch = *iptold; } goto L500; } /* If bit 4 of ICORF is set then correct RMS and RC(1) - RC(4). */ /* Determine error rate and correct errors using a Hamming 8,4 code */ /* during transition or unvoiced frame. If IOUT is negative, */ /* more than 1 error occurred, use previous frame's parameters. */ if ((icorf & bit[3]) != 0) { errcnt = 0; lsb = drms[1] & 1; index = (drc[22] << 4) + drms[1] / 2; ham84_(&index, &iout, &errcnt); drms[1] = drms[2]; if (iout >= 0) { drms[1] = (iout << 1) + lsb; } for (i__ = 1; i__ <= 4; ++i__) { if (i__ == 1) { i1 = ((drc[25] & 7) << 1) + (drc[28] & 1); } else { i1 = drc[(9 - i__) * 3 - 2] & 15; } i2 = drc[(5 - i__) * 3 - 2] & 31; lsb = i2 & 1; index = (i1 << 4) + i2 / 2; ham84_(&index, &iout, &errcnt); if (iout >= 0) { iout = (iout << 1) + lsb; if ((iout & 16) == 16) { iout += -32; } } else { iout = drc[(5 - i__) * 3 - 1]; } drc[(5 - i__) * 3 - 2] = iout; } /* Determine error rate */ *erate = (integer)(*erate * .96875f + errcnt * 102); } /* Get unsmoothed RMS, RC's, and PITCH */ *irms = drms[1]; i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { irc[i__] = drc[i__ * 3 - 2]; } if (ipit == 1) { dpit[1] = dpit[2]; } if (ipit == 3) { dpit[1] = dpit[0]; } *pitch = dpit[1]; /* If bit 2 of ICORF is set then smooth RMS and RC's, */ if ((icorf & bit[1]) != 0) { if ((i__1 = drms[1] - drms[0], (real) abs(i__1)) >= corth[ixcor + 3] && (i__2 = drms[1] - drms[2], (real) abs(i__2)) >= corth[ ixcor + 3]) { *irms = median_(&drms[2], &drms[1], drms); } for (i__ = 1; i__ <= 6; ++i__) { if ((i__1 = drc[i__ * 3 - 2] - drc[i__ * 3 - 3], (real) abs(i__1)) >= corth[ixcor + ((i__ + 2) << 2) - 5] && (i__2 = drc[i__ * 3 - 2] - drc[i__ * 3 - 1], (real) abs(i__2)) >= corth[ ixcor + ((i__ + 2) << 2) - 5]) { irc[i__] = median_(&drc[i__ * 3 - 1], &drc[i__ * 3 - 2], &drc[ i__ * 3 - 3]); } } } /* If bit 3 of ICORF is set then smooth pitch */ if ((icorf & bit[2]) != 0) { if ((i__1 = dpit[1] - dpit[0], (real) abs(i__1)) >= corth[ixcor - 1] && (i__2 = dpit[1] - dpit[2], (real) abs(i__2)) >= corth[ ixcor - 1]) { *pitch = median_(&dpit[2], &dpit[1], dpit); } } /* If bit 5 of ICORF is set then RC(5) - RC(10) are loaded with */ /* values so that after quantization bias is removed in decode */ /* the values will be zero. */ L500: if ((icorf & bit[4]) != 0) { i__1 = contrl_1.order; for (i__ = 5; i__ <= i__1; ++i__) { irc[i__] = zrc[i__ - 1]; } } /* House keeping - one frame delay */ *iovoic = ivoic; *ivp2h = voice[2]; dpit[2] = dpit[1]; dpit[1] = dpit[0]; drms[2] = drms[1]; drms[1] = drms[0]; i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { drc[i__ * 3 - 1] = drc[i__ * 3 - 2]; drc[i__ * 3 - 2] = drc[i__ * 3 - 3]; } L900: /* IF (LISTL.GE.3)WRITE(FDEBUG,801)VOICE,PITCH,IRMS,(IRC(J),J=1,ORDER) */ /* 801 FORMAT(1X,'<>',T32,2I3,I6,I5,T50,10I8) */ /* Decode RMS */ *irms = rmst[(31 - *irms) * 2]; /* Decode RC(1) and RC(2) from log-area-ratios */ /* Protect from illegal coded value (-16) caused by bit errors */ for (i__ = 1; i__ <= 2; ++i__) { i2 = irc[i__]; i1 = 0; if (i2 < 0) { i1 = 1; i2 = -i2; if (i2 > 15) { i2 = 0; } } i2 = detab7[i2 * 2]; if (i1 == 1) { i2 = -i2; } ishift = 15 - nbit[i__ - 1]; irc[i__] = i2 * pow_ii(&c__2, &ishift); } /* Decode RC(3)-RC(10) to sign plus 14 bits */ i__1 = contrl_1.order; for (i__ = 3; i__ <= i__1; ++i__) { i2 = irc[i__]; ishift = 15 - nbit[i__ - 1]; i2 *= pow_ii(&c__2, &ishift); i2 += qb[i__ - 3]; irc[i__] = (integer)(i2 * descl[i__ - 3] + deadd[i__ - 3]); } /* IF (LISTL.GE.3) WRITE(FDEBUG,811) IRMS, (IRC(I),I=1,ORDER) */ /* 811 FORMAT(1X,'<>',T45,I4,1X,10I8) */ /* Scale RMS and RC's to reals */ *rms = (real) (*irms); i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { rc[i__] = irc[i__] / 16384.f; } return 0; } /* decode_ */ asterisk-11.7.0/codecs/lpc10/bsynz.c0000644000175000007640000003502210513757330017043 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:18:55 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:58 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int bsynz_(real *coef, integer *ip, integer *iv, real *sout, real *rms, real *ratio, real *g2pass, struct lpc10_decoder_state *st); /* comlen contrl_ 12 */ /*:ref: random_ 4 0 */ #endif /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* ***************************************************************** */ /* BSYNZ Version 54 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:18:55 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:58 jaf * Initial revision * */ /* Revision 1.4 1996/03/27 18:11:22 jaf */ /* Changed the range of NOISE printed out in the debugging statements, */ /* even though they are commented out. I didn't discover this until I */ /* tried comparing two different versions of the LPC-10 coder, each with */ /* full tracing enabled. */ /* Revision 1.3 1996/03/26 19:33:23 jaf */ /* Commented out trace statements. */ /* Revision 1.2 1996/03/20 17:12:54 jaf */ /* Added comments about which indices of array arguments are read or */ /* written. */ /* Rearranged local variable declarations to indicate which need to be */ /* saved from one invocation to the next. Added entry INITBSYNZ to */ /* reinitialize the local state variables, if desired. */ /* Revision 1.1 1996/02/07 14:43:15 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Synthesize One Pitch Epoch */ /* Input: */ /* COEF - Predictor coefficients */ /* Indices 1 through ORDER read. */ /* IP - Pitch period (number of samples to synthesize) */ /* IV - Voicing for the current epoch */ /* RMS - Energy for the current epoch */ /* RATIO - Energy slope for plosives */ /* G2PASS- Sharpening factor for 2 pass synthesis */ /* Output: */ /* SOUT - Synthesized speech */ /* Indices 1 through IP written. */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITBSYNZ. */ /* Subroutine */ int bsynz_(real *coef, integer *ip, integer *iv, real *sout, real *rms, real *ratio, real *g2pass, struct lpc10_decoder_state *st) { /* Initialized data */ integer *ipo; real *rmso; static integer kexc[25] = { 8,-16,26,-48,86,-162,294,-502,718,-728,184, 672,-610,-672,184,728,718,502,294,162,86,48,26,16,8 }; real *exc; real *exc2; real *lpi1; real *lpi2; real *lpi3; real *hpi1; real *hpi2; real *hpi3; /* System generated locals */ integer i__1, i__2; real r__1, r__2; /* Builtin functions */ double sqrt(doublereal); /* Local variables */ real gain, xssq; integer i__, j, k; real noise[166], pulse; integer px; real sscale; extern integer random_(struct lpc10_decoder_state *); real xy, sum, ssq; real lpi0, hpi0; /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:18:55 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:58 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:18:55 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:58 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Function return value definitions */ /* Parameters/constants */ /* KEXC is not a Fortran PARAMETER, but it is an array initialized */ /* with a DATA statement that is never modified. */ /* Local variables that need not be saved */ /* NOISE is declared with range (1:MAXPIT+MAXORD), but only indices */ /* ORDER+1 through ORDER+IP are ever used, and I think that IP */ /* .LE. MAXPIT. Why not declare it to be in the range (1:MAXPIT) */ /* and use that range? */ /* Local state */ /* I believe that only indices 1 through ORDER of EXC need to be */ /* saved from one invocation to the next, but we may as well save */ /* the whole array. */ /* None of these local variables were given initial values in the */ /* original code. I'm guessing that 0 is a reasonable initial */ /* value for all of them. */ /* Parameter adjustments */ if (coef) { --coef; } if (sout) { --sout; } /* Function Body */ ipo = &(st->ipo); exc = &(st->exc[0]); exc2 = &(st->exc2[0]); lpi1 = &(st->lpi1); lpi2 = &(st->lpi2); lpi3 = &(st->lpi3); hpi1 = &(st->hpi1); hpi2 = &(st->hpi2); hpi3 = &(st->hpi3); rmso = &(st->rmso_bsynz); /* MAXPIT+MAXORD=166 */ /* Calculate history scale factor XY and scale filter state */ /* Computing MIN */ r__1 = *rmso / (*rms + 1e-6f); xy = min(r__1,8.f); *rmso = *rms; i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { exc2[i__ - 1] = exc2[*ipo + i__ - 1] * xy; } *ipo = *ip; if (*iv == 0) { /* Generate white noise for unvoiced */ i__1 = *ip; for (i__ = 1; i__ <= i__1; ++i__) { exc[contrl_1.order + i__ - 1] = (real) (random_(st) / 64); } /* Impulse doublet excitation for plosives */ /* (RANDOM()+32768) is in the range 0 to 2**16-1. Therefore the */ /* following expression should be evaluated using integers with at */ /* least 32 bits (16 isn't enough), and PX should be in the rang e */ /* ORDER+1+0 through ORDER+1+(IP-2) .EQ. ORDER+IP-1. */ px = (random_(st) + 32768) * (*ip - 1) / 65536 + contrl_1.order + 1; r__1 = *ratio / 4 * 1.f; pulse = r__1 * 342; if (pulse > 2e3f) { pulse = 2e3f; } exc[px - 1] += pulse; exc[px] -= pulse; /* Load voiced excitation */ } else { sscale = (real)sqrt((real) (*ip)) / 6.928f; i__1 = *ip; for (i__ = 1; i__ <= i__1; ++i__) { exc[contrl_1.order + i__ - 1] = 0.f; if (i__ <= 25) { exc[contrl_1.order + i__ - 1] = sscale * kexc[i__ - 1]; } lpi0 = exc[contrl_1.order + i__ - 1]; r__2 = exc[contrl_1.order + i__ - 1] * .125f + *lpi1 * .75f; r__1 = r__2 + *lpi2 * .125f; exc[contrl_1.order + i__ - 1] = r__1 + *lpi3 * 0.f; *lpi3 = *lpi2; *lpi2 = *lpi1; *lpi1 = lpi0; } i__1 = *ip; for (i__ = 1; i__ <= i__1; ++i__) { noise[contrl_1.order + i__ - 1] = random_(st) * 1.f / 64; hpi0 = noise[contrl_1.order + i__ - 1]; r__2 = noise[contrl_1.order + i__ - 1] * -.125f + *hpi1 * .25f; r__1 = r__2 + *hpi2 * -.125f; noise[contrl_1.order + i__ - 1] = r__1 + *hpi3 * 0.f; *hpi3 = *hpi2; *hpi2 = *hpi1; *hpi1 = hpi0; } i__1 = *ip; for (i__ = 1; i__ <= i__1; ++i__) { exc[contrl_1.order + i__ - 1] += noise[contrl_1.order + i__ - 1]; } } /* Synthesis filters: */ /* Modify the excitation with all-zero filter 1 + G*SUM */ xssq = 0.f; i__1 = *ip; for (i__ = 1; i__ <= i__1; ++i__) { k = contrl_1.order + i__; sum = 0.f; i__2 = contrl_1.order; for (j = 1; j <= i__2; ++j) { sum += coef[j] * exc[k - j - 1]; } sum *= *g2pass; exc2[k - 1] = sum + exc[k - 1]; } /* Synthesize using the all pole filter 1 / (1 - SUM) */ i__1 = *ip; for (i__ = 1; i__ <= i__1; ++i__) { k = contrl_1.order + i__; sum = 0.f; i__2 = contrl_1.order; for (j = 1; j <= i__2; ++j) { sum += coef[j] * exc2[k - j - 1]; } exc2[k - 1] = sum + exc2[k - 1]; xssq += exc2[k - 1] * exc2[k - 1]; } /* Save filter history for next epoch */ i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { exc[i__ - 1] = exc[*ip + i__ - 1]; exc2[i__ - 1] = exc2[*ip + i__ - 1]; } /* Apply gain to match RMS */ r__1 = *rms * *rms; ssq = r__1 * *ip; gain = (real)sqrt(ssq / xssq); i__1 = *ip; for (i__ = 1; i__ <= i__1; ++i__) { sout[i__] = gain * exc2[contrl_1.order + i__ - 1]; } return 0; } /* bsynz_ */ asterisk-11.7.0/codecs/lpc10/ivfilt.c0000644000175000007640000000713310513757330017175 0ustar sharkyjerryweb/* $Log$ Revision 1.16 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.15 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.2 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:31:53 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *nsamp, real *ivrc); #endif /* ********************************************************************* */ /* IVFILT Version 48 */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:53 jaf * Initial revision * */ /* Revision 1.3 1996/03/15 21:36:29 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 00:01:00 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:47:34 jaf */ /* Initial revision */ /* ********************************************************************* */ /* 2nd order inverse filter, speech is decimated 4:1 */ /* Input: */ /* LEN - Length of speech buffers */ /* NSAMP - Number of samples to filter */ /* LPBUF - Low pass filtered speech buffer */ /* Indices LEN-NSAMP-7 through LEN read. */ /* Output: */ /* IVBUF - Inverse filtered speech buffer */ /* Indices LEN-NSAMP+1 through LEN written. */ /* IVRC - Inverse filter reflection coefficients (for voicing) */ /* Indices 1 and 2 both written (also read, but only after writing). */ /* This subroutine has no local state. */ /* Subroutine */ int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer * nsamp, real *ivrc) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, j, k; real r__[3], pc1, pc2; /* Arguments */ /* Local variables that need not be saved */ /* Local state */ /* None */ /* Calculate Autocorrelations */ /* Parameter adjustments */ --ivbuf; --lpbuf; --ivrc; /* Function Body */ for (i__ = 1; i__ <= 3; ++i__) { r__[i__ - 1] = 0.f; k = (i__ - 1) << 2; i__1 = *len; for (j = (i__ << 2) + *len - *nsamp; j <= i__1; j += 2) { r__[i__ - 1] += lpbuf[j] * lpbuf[j - k]; } } /* Calculate predictor coefficients */ pc1 = 0.f; pc2 = 0.f; ivrc[1] = 0.f; ivrc[2] = 0.f; if (r__[0] > 1e-10f) { ivrc[1] = r__[1] / r__[0]; ivrc[2] = (r__[2] - ivrc[1] * r__[1]) / (r__[0] - ivrc[1] * r__[1]); pc1 = ivrc[1] - ivrc[1] * ivrc[2]; pc2 = ivrc[2]; } /* Inverse filter LPBUF into IVBUF */ i__1 = *len; for (i__ = *len + 1 - *nsamp; i__ <= i__1; ++i__) { ivbuf[i__] = lpbuf[i__] - pc1 * lpbuf[i__ - 4] - pc2 * lpbuf[i__ - 8]; } return 0; } /* ivfilt_ */ asterisk-11.7.0/codecs/lpc10/invert.c0000644000175000007640000001316510513757330017211 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:32:00 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int invert_(integer *order, real *phi, real *psi, real *rc); #endif /* **************************************************************** */ /* INVERT Version 45G */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:00 jaf * Initial revision * */ /* Revision 1.3 1996/03/18 20:52:47 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 16:51:32 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Eliminated a comment from the original, describing a local array X */ /* that appeared nowhere in the code. */ /* Revision 1.1 1996/02/07 14:47:20 jaf */ /* Initial revision */ /* **************************************************************** */ /* Invert a covariance matrix using Choleski decomposition method. */ /* Input: */ /* ORDER - Analysis order */ /* PHI(ORDER,ORDER) - Covariance matrix */ /* Indices (I,J) read, where ORDER .GE. I .GE. J .GE. 1.*/ /* All other indices untouched. */ /* PSI(ORDER) - Column vector to be predicted */ /* Indices 1 through ORDER read. */ /* Output: */ /* RC(ORDER) - Pseudo reflection coefficients */ /* Indices 1 through ORDER written, and then possibly read. */ /* Internal: */ /* V(ORDER,ORDER) - Temporary matrix */ /* Same indices written as read from PHI. */ /* Many indices may be read and written again after */ /* initially being copied from PHI, but all indices */ /* are written before being read. */ /* NOTE: Temporary matrix V is not needed and may be replaced */ /* by PHI if the original PHI values do not need to be preserved. */ /* Subroutine */ int invert_(integer *order, real *phi, real *psi, real *rc) { /* System generated locals */ integer phi_dim1, phi_offset, i__1, i__2, i__3; real r__1, r__2; /* Local variables */ real save; integer i__, j, k; real v[100] /* was [10][10] */; /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:00 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Parameters/constants */ /* Local variables that need not be saved */ /* Decompose PHI into V * D * V' where V is a triangular matrix whose */ /* main diagonal elements are all 1, V' is the transpose of V, and */ /* D is a vector. Here D(n) is stored in location V(n,n). */ /* Parameter adjustments */ --rc; --psi; phi_dim1 = *order; phi_offset = phi_dim1 + 1; phi -= phi_offset; /* Function Body */ i__1 = *order; for (j = 1; j <= i__1; ++j) { i__2 = *order; for (i__ = j; i__ <= i__2; ++i__) { v[i__ + j * 10 - 11] = phi[i__ + j * phi_dim1]; } i__2 = j - 1; for (k = 1; k <= i__2; ++k) { save = v[j + k * 10 - 11] * v[k + k * 10 - 11]; i__3 = *order; for (i__ = j; i__ <= i__3; ++i__) { v[i__ + j * 10 - 11] -= v[i__ + k * 10 - 11] * save; } } /* Compute intermediate results, which are similar to RC's */ if ((r__1 = v[j + j * 10 - 11], abs(r__1)) < 1e-10f) { goto L100; } rc[j] = psi[j]; i__2 = j - 1; for (k = 1; k <= i__2; ++k) { rc[j] -= rc[k] * v[j + k * 10 - 11]; } v[j + j * 10 - 11] = 1.f / v[j + j * 10 - 11]; rc[j] *= v[j + j * 10 - 11]; /* Computing MAX */ /* Computing MIN */ r__2 = rc[j]; r__1 = min(r__2,.999f); rc[j] = max(r__1,-.999f); } return 0; /* Zero out higher order RC's if algorithm terminated early */ L100: i__1 = *order; for (i__ = j; i__ <= i__1; ++i__) { rc[i__] = 0.f; } /* Back substitute for PC's (if needed) */ /* 110 DO J = ORDER,1,-1 */ /* PC(J) = RC(J) */ /* DO I = 1,J-1 */ /* PC(J) = PC(J) - PC(I)*V(J,I) */ /* END DO */ /* END DO */ return 0; } /* invert_ */ asterisk-11.7.0/codecs/lpc10/lpfilt.c0000644000175000007640000000705410513757330017174 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:31:35 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer *nsamp); #endif /* *********************************************************************** */ /* LPFILT Version 55 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:35 jaf * Initial revision * */ /* Revision 1.3 1996/03/15 16:53:49 jaf */ /* Just put comment header in standard form. */ /* Revision 1.2 1996/03/12 23:58:06 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:47:44 jaf */ /* Initial revision */ /* *********************************************************************** */ /* 31 Point Equiripple FIR Low-Pass Filter */ /* Linear phase, delay = 15 samples */ /* Passband: ripple = 0.25 dB, cutoff = 800 Hz */ /* Stopband: atten. = 40. dB, cutoff = 1240 Hz */ /* Inputs: */ /* LEN - Length of speech buffers */ /* NSAMP - Number of samples to filter */ /* INBUF - Input speech buffer */ /* Indices len-nsamp-29 through len are read. */ /* Output: */ /* LPBUF - Low passed speech buffer (must be different array than INBUF) */ /* Indices len+1-nsamp through len are written. */ /* This subroutine has no local state. */ /* Subroutine */ int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer * nsamp) { /* System generated locals */ integer i__1; /* Local variables */ integer j; real t; /* Arguments */ /* Parameters/constants */ /* Local variables that need not be saved */ /* Local state */ /* None */ /* Parameter adjustments */ --lpbuf; --inbuf; /* Function Body */ i__1 = *len; for (j = *len + 1 - *nsamp; j <= i__1; ++j) { t = (inbuf[j] + inbuf[j - 30]) * -.0097201988f; t += (inbuf[j - 1] + inbuf[j - 29]) * -.0105179986f; t += (inbuf[j - 2] + inbuf[j - 28]) * -.0083479648f; t += (inbuf[j - 3] + inbuf[j - 27]) * 5.860774e-4f; t += (inbuf[j - 4] + inbuf[j - 26]) * .0130892089f; t += (inbuf[j - 5] + inbuf[j - 25]) * .0217052232f; t += (inbuf[j - 6] + inbuf[j - 24]) * .0184161253f; t += (inbuf[j - 7] + inbuf[j - 23]) * 3.39723e-4f; t += (inbuf[j - 8] + inbuf[j - 22]) * -.0260797087f; t += (inbuf[j - 9] + inbuf[j - 21]) * -.0455563702f; t += (inbuf[j - 10] + inbuf[j - 20]) * -.040306855f; t += (inbuf[j - 11] + inbuf[j - 19]) * 5.029835e-4f; t += (inbuf[j - 12] + inbuf[j - 18]) * .0729262903f; t += (inbuf[j - 13] + inbuf[j - 17]) * .1572008878f; t += (inbuf[j - 14] + inbuf[j - 16]) * .2247288674f; t += inbuf[j - 15] * .250535965f; lpbuf[j] = t; } return 0; } /* lpfilt_ */ asterisk-11.7.0/codecs/lpc10/analys.c0000644000175000007640000005676310513757330017204 0ustar sharkyjerryweb/* $Log$ Revision 1.16 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.15 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.2 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.1.1.1 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:16:01 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:29:08 jaf * Initial revision * */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int analys_(real *speech, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_encoder_state *st); /* comlen contrl_ 12 */ /*:ref: preemp_ 14 5 6 6 4 6 6 */ /*:ref: onset_ 14 7 6 4 4 4 4 4 4 */ /*:ref: placev_ 14 11 4 4 4 4 4 4 4 4 4 4 4 */ /*:ref: lpfilt_ 14 4 6 6 4 4 */ /*:ref: ivfilt_ 14 5 6 6 4 4 6 */ /*:ref: tbdm_ 14 8 6 4 4 4 6 4 4 4 */ /*:ref: voicin_ 14 12 4 6 6 4 4 6 6 4 6 4 4 4 */ /*:ref: dyptrk_ 14 6 6 4 4 4 4 4 */ /*:ref: placea_ 14 9 4 4 4 4 4 4 4 4 4 */ /*:ref: dcbias_ 14 3 4 6 6 */ /*:ref: energy_ 14 3 4 6 6 */ /*:ref: mload_ 14 6 4 4 4 6 6 6 */ /*:ref: invert_ 14 4 4 6 6 6 */ /*:ref: rcchk_ 14 3 4 6 6 */ /*:ref: initonset_ 14 0 */ /*:ref: initvoicin_ 14 0 */ /*:ref: initdyptrk_ 14 0 */ /* Rerunning f2c -P may change prototypes or declarations. */ #endif /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* Table of constant values */ static integer c__10 = 10; static integer c__181 = 181; static integer c__720 = 720; static integer c__3 = 3; static integer c__90 = 90; static integer c__156 = 156; static integer c__307 = 307; static integer c__462 = 462; static integer c__312 = 312; static integer c__60 = 60; static integer c__1 = 1; /* ****************************************************************** */ /* ANALYS Version 55 */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:16:01 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:29:08 jaf * Initial revision * */ /* Revision 1.9 1996/05/23 19:41:07 jaf */ /* Commented out some unnecessary lines that were reading uninitialized */ /* values. */ /* Revision 1.8 1996/03/27 23:57:55 jaf */ /* Added some comments about which indices of the local buffers INBUF, */ /* LPBUF, etc., get read or modified by some of the subroutine calls. I */ /* just did this while trying to figure out the discrepancy between the */ /* embedded code compiled with all local variables implicitly saved, and */ /* without. */ /* I added some debugging write statements in hopes of finding a problem. */ /* None of them ever printed anything while running with the long input */ /* speech file dam9.spd provided in the distribution. */ /* Revision 1.7 1996/03/27 18:06:20 jaf */ /* Commented out access to MAXOSP, which is just a debugging variable */ /* that was defined in the COMMON block CONTRL in contrl.fh. */ /* Revision 1.6 1996/03/26 19:31:33 jaf */ /* Commented out trace statements. */ /* Revision 1.5 1996/03/21 15:19:35 jaf */ /* Added comments for ENTRY PITDEC. */ /* Revision 1.4 1996/03/19 20:54:27 jaf */ /* Added a line to INITANALYS. See comments there. */ /* Revision 1.3 1996/03/19 20:52:49 jaf */ /* Rearranged the order of the local variables quite a bit, to separate */ /* them into groups of "constants", "locals that don't need to be saved */ /* from one call to the next", and "local that do need to be saved from */ /* one call to the next". */ /* Several locals in the last set should have been given initial values, */ /* but weren't. I gave them all initial values of 0. */ /* Added a separate ENTRY INITANALYS that initializes all local state */ /* that should be, and also calls the corresponding entries of the */ /* subroutines called by ANALYS that also have local state. */ /* There used to be DATA statements in ANALYS. I got rid of most of */ /* them, and added a local logical variable FIRST that calls the entry */ /* INITANALYS on the first call to ANALYS. This is just so that one need */ /* not remember to call INITANALYS first in order for the state to be */ /* initialized. */ /* Revision 1.2 1996/03/11 23:29:32 jaf */ /* Added several comments with my own personal questions about the */ /* Fortran 77 meaning of the parameters passed to the subroutine PREEMP. */ /* Revision 1.1 1996/02/07 14:42:29 jaf */ /* Initial revision */ /* ****************************************************************** */ /* SUBROUTINE ANALYS */ /* Input: */ /* SPEECH */ /* Indices 1 through LFRAME read. */ /* Output: */ /* VOICE */ /* Indices 1 through 2 written. */ /* PITCH */ /* Written in subroutine DYPTRK, and then perhaps read and written */ /* some more. */ /* RMS */ /* Written. */ /* RC */ /* Indices 1 through ORDER written (ORDER defined in contrl.fh). */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITANALYS. */ /* ENTRY PITDEC */ /* Input: */ /* PITCH - Encoded pitch index */ /* Output: */ /* PTAU - Decoded pitch period */ /* This entry has no local state. It accesses a "constant" array */ /* declared in ANALYS. */ /* Subroutine */ int analys_(real *speech, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_encoder_state *st) { /* Initialized data */ static integer tau[60] = { 20,21,22,23,24,25,26,27,28,29,30,31,32,33,34, 35,36,37,38,39,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72, 74,76,78,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136, 140,144,148,152,156 }; static integer buflim[4] = { 181,720,25,720 }; static real precoef = .9375f; /* System generated locals */ integer i__1; /* Local variables */ real amdf[60]; integer half; real abuf[156]; real *bias; extern /* Subroutine */ int tbdm_(real *, integer *, integer *, integer *, real *, integer *, integer *, integer *); integer *awin; integer midx, ewin[6] /* was [2][3] */; real ivrc[2], temp; real *zpre; integer *vwin; integer i__, j, lanal; extern /* Subroutine */ int rcchk_(integer *, real *, real *), mload_( integer *, integer *, integer *, real *, real *, real *); real *inbuf, *pebuf; real *lpbuf, *ivbuf; real *rcbuf; integer *osbuf; extern /* Subroutine */ int onset_(real *, integer *, integer *, integer * , integer *, integer *, integer *, struct lpc10_encoder_state *); integer *osptr; extern int dcbias_(integer *, real *, real *); integer ipitch; integer *obound; extern /* Subroutine */ int preemp_(real *, real *, integer *, real *, real *), voicin_(integer *, real *, real *, integer *, integer *, real *, real *, integer *, real *, integer *, integer *, integer *, struct lpc10_encoder_state *); integer *voibuf; integer mintau; real *rmsbuf; extern /* Subroutine */ int lpfilt_(real *, real *, integer *, integer *), ivfilt_(real *, real *, integer *, integer *, real *), energy_( integer *, real *, real *), invert_(integer *, real *, real *, real *); integer minptr, maxptr; extern /* Subroutine */ int dyptrk_(real *, integer *, integer *, integer *, integer *, integer *, struct lpc10_encoder_state *); real phi[100] /* was [10][10] */, psi[10]; /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:16:01 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:29:08 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Arguments to ANALYS */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:16:01 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:29:08 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Arguments to entry PITDEC (below) */ /* Parameters/constants */ /* Constants */ /* NF = Number of frames */ /* AF = Frame in which analysis is done */ /* OSLEN = Length of the onset buffer */ /* LTAU = Number of pitch lags */ /* SBUFL, SBUFH = Start and end index of speech buffers */ /* LBUFL, LBUFH = Start and end index of LPF speech buffer */ /* MINWIN, MAXWIN = Min and Max length of voicing (and analysis) windows */ /* PWLEN, PWINH, PWINL = Length, upper and lower limits of pitch window */ /* DVWINL, DVWINH = Default lower and upper limits of voicing window */ /* The tables TAU and BUFLIM, and the variable PRECOEF, are not */ /* Fortran PARAMETER's, but they are initialized with DATA */ /* statements, and never modified. Thus, they need not have SAVE */ /* statements for them to keep their values from one invocation to */ /* the next. */ /* Local variables that need not be saved */ /* Local state */ /* Data Buffers */ /* INBUF Raw speech (with DC bias removed each frame) */ /* PEBUF Preemphasized speech */ /* LPBUF Low pass speech buffer */ /* IVBUF Inverse filtered speech */ /* OSBUF Indexes of onsets in speech buffers */ /* VWIN Voicing window indices */ /* AWIN Analysis window indices */ /* EWIN Energy window indices */ /* VOIBUF Voicing decisions on windows in VWIN */ /* RMSBUF RMS energy */ /* RCBUF Reflection Coefficients */ /* Pitch is handled separately from the above parameters. */ /* The following variables deal with pitch: */ /* MIDX Encoded initial pitch estimate for analysis frame */ /* IPITCH Initial pitch computed for frame AF (decoded from MIDX) */ /* PITCH The encoded pitch value (index into TAU) for the present */ /* frame (delayed and smoothed by Dyptrack) */ /* Parameter adjustments */ if (speech) { --speech; } if (voice) { --voice; } if (rc) { --rc; } /* Function Body */ /* Calculations are done on future frame due to requirements */ /* of the pitch tracker. Delay RMS and RC's 2 frames to give */ /* current frame parameters on return. */ /* Update all buffers */ inbuf = &(st->inbuf[0]); pebuf = &(st->pebuf[0]); lpbuf = &(st->lpbuf[0]); ivbuf = &(st->ivbuf[0]); bias = &(st->bias); osbuf = &(st->osbuf[0]); osptr = &(st->osptr); obound = &(st->obound[0]); vwin = &(st->vwin[0]); awin = &(st->awin[0]); voibuf = &(st->voibuf[0]); rmsbuf = &(st->rmsbuf[0]); rcbuf = &(st->rcbuf[0]); zpre = &(st->zpre); i__1 = 720 - contrl_1.lframe; for (i__ = 181; i__ <= i__1; ++i__) { inbuf[i__ - 181] = inbuf[contrl_1.lframe + i__ - 181]; pebuf[i__ - 181] = pebuf[contrl_1.lframe + i__ - 181]; } i__1 = 540 - contrl_1.lframe; for (i__ = 229; i__ <= i__1; ++i__) { ivbuf[i__ - 229] = ivbuf[contrl_1.lframe + i__ - 229]; } i__1 = 720 - contrl_1.lframe; for (i__ = 25; i__ <= i__1; ++i__) { lpbuf[i__ - 25] = lpbuf[contrl_1.lframe + i__ - 25]; } j = 1; i__1 = (*osptr) - 1; for (i__ = 1; i__ <= i__1; ++i__) { if (osbuf[i__ - 1] > contrl_1.lframe) { osbuf[j - 1] = osbuf[i__ - 1] - contrl_1.lframe; ++j; } } *osptr = j; voibuf[0] = voibuf[2]; voibuf[1] = voibuf[3]; for (i__ = 1; i__ <= 2; ++i__) { vwin[(i__ << 1) - 2] = vwin[((i__ + 1) << 1) - 2] - contrl_1.lframe; vwin[(i__ << 1) - 1] = vwin[((i__ + 1) << 1) - 1] - contrl_1.lframe; awin[(i__ << 1) - 2] = awin[((i__ + 1) << 1) - 2] - contrl_1.lframe; awin[(i__ << 1) - 1] = awin[((i__ + 1) << 1) - 1] - contrl_1.lframe; /* EWIN(*,J) is unused for J .NE. AF, so the following shift is */ /* unnecessary. It also causes error messages when the C versio n */ /* of the code created from this by f2c is run with Purify. It */ /* correctly complains that uninitialized memory is being read. */ /* EWIN(1,I) = EWIN(1,I+1) - LFRAME */ /* EWIN(2,I) = EWIN(2,I+1) - LFRAME */ obound[i__ - 1] = obound[i__]; voibuf[i__ * 2] = voibuf[(i__ + 1) * 2]; voibuf[(i__ << 1) + 1] = voibuf[((i__ + 1) << 1) + 1]; rmsbuf[i__ - 1] = rmsbuf[i__]; i__1 = contrl_1.order; for (j = 1; j <= i__1; ++j) { rcbuf[j + i__ * 10 - 11] = rcbuf[j + (i__ + 1) * 10 - 11]; } } /* Copy input speech, scale to sign+12 bit integers */ /* Remove long term DC bias. */ /* If the average value in the frame was over 1/4096 (after current */ /* BIAS correction), then subtract that much more from samples in */ /* next frame. If the average value in the frame was under */ /* -1/4096, add 1/4096 more to samples in next frame. In all other */ /* cases, keep BIAS the same. */ temp = 0.f; i__1 = contrl_1.lframe; for (i__ = 1; i__ <= i__1; ++i__) { inbuf[720 - contrl_1.lframe + i__ - 181] = speech[i__] * 4096.f - (*bias); temp += inbuf[720 - contrl_1.lframe + i__ - 181]; } if (temp > (real) contrl_1.lframe) { *bias += 1; } if (temp < (real) (-contrl_1.lframe)) { *bias += -1; } /* Place Voicing Window */ i__ = 721 - contrl_1.lframe; preemp_(&inbuf[i__ - 181], &pebuf[i__ - 181], &contrl_1.lframe, &precoef, zpre); onset_(pebuf, osbuf, osptr, &c__10, &c__181, &c__720, &contrl_1.lframe, st); /* MAXOSP is just a debugging variable. */ /* MAXOSP = MAX( MAXOSP, OSPTR ) */ placev_(osbuf, osptr, &c__10, &obound[2], vwin, &c__3, &contrl_1.lframe, &c__90, &c__156, &c__307, &c__462); /* The Pitch Extraction algorithm estimates the pitch for a frame */ /* of speech by locating the minimum of the average magnitude difference */ /* function (AMDF). The AMDF operates on low-pass, inverse filtered */ /* speech. (The low-pass filter is an 800 Hz, 19 tap, equiripple, FIR */ /* filter and the inverse filter is a 2nd-order LPC filter.) The pitch */ /* estimate is later refined by dynamic programming (DYPTRK). However, */ /* since some of DYPTRK's parameters are a function of the voicing */ /* decisions, a voicing decision must precede the final pitch estimation. */ /* See subroutines LPFILT, IVFILT, and TBDM. */ /* LPFILT reads indices LBUFH-LFRAME-29 = 511 through LBUFH = 720 */ /* of INBUF, and writes indices LBUFH+1-LFRAME = 541 through LBUFH */ /* = 720 of LPBUF. */ lpfilt_(&inbuf[228], &lpbuf[384], &c__312, &contrl_1.lframe); /* IVFILT reads indices (PWINH-LFRAME-7) = 353 through PWINH = 540 */ /* of LPBUF, and writes indices (PWINH-LFRAME+1) = 361 through */ /* PWINH = 540 of IVBUF. */ ivfilt_(&lpbuf[204], ivbuf, &c__312, &contrl_1.lframe, ivrc); /* TBDM reads indices PWINL = 229 through */ /* (PWINL-1)+MAXWIN+(TAU(LTAU)-TAU(1))/2 = 452 of IVBUF, and writes */ /* indices 1 through LTAU = 60 of AMDF. */ tbdm_(ivbuf, &c__156, tau, &c__60, amdf, &minptr, &maxptr, &mintau); /* Voicing decisions are made for each half frame of input speech. */ /* An initial voicing classification is made for each half of the */ /* analysis frame, and the voicing decisions for the present frame */ /* are finalized. See subroutine VOICIN. */ /* The voicing detector (VOICIN) classifies the input signal as */ /* unvoiced (including silence) or voiced using the AMDF windowed */ /* maximum-to-minimum ratio, the zero crossing rate, energy measures, */ /* reflection coefficients, and prediction gains. */ /* The pitch and voicing rules apply smoothing and isolated */ /* corrections to the pitch and voicing estimates and, in the process, */ /* introduce two frames of delay into the corrected pitch estimates and */ /* voicing decisions. */ for (half = 1; half <= 2; ++half) { voicin_(&vwin[4], inbuf, lpbuf, buflim, &half, &amdf[minptr - 1], & amdf[maxptr - 1], &mintau, ivrc, obound, voibuf, &c__3, st); } /* Find the minimum cost pitch decision over several frames */ /* given the current voicing decision and the AMDF array */ dyptrk_(amdf, &c__60, &minptr, &voibuf[7], pitch, &midx, st); ipitch = tau[midx - 1]; /* Place spectrum analysis and energy windows */ placea_(&ipitch, voibuf, &obound[2], &c__3, vwin, awin, ewin, & contrl_1.lframe, &c__156); /* Remove short term DC bias over the analysis window, Put result in ABUF */ lanal = awin[5] + 1 - awin[4]; dcbias_(&lanal, &pebuf[awin[4] - 181], abuf); /* ABUF(1:LANAL) is now defined. It is equal to */ /* PEBUF(AWIN(1,AF):AWIN(2,AF)) corrected for short term DC bias. */ /* Compute RMS over integer number of pitch periods within the */ /* analysis window. */ /* Note that in a hardware implementation this computation may be */ /* simplified by using diagonal elements of PHI computed by MLOAD. */ i__1 = ewin[5] - ewin[4] + 1; energy_(&i__1, &abuf[ewin[4] - awin[4]], &rmsbuf[2]); /* Matrix load and invert, check RC's for stability */ mload_(&contrl_1.order, &c__1, &lanal, abuf, phi, psi); invert_(&contrl_1.order, phi, psi, &rcbuf[20]); rcchk_(&contrl_1.order, &rcbuf[10], &rcbuf[20]); /* Set return parameters */ voice[1] = voibuf[2]; voice[2] = voibuf[3]; *rms = rmsbuf[0]; i__1 = contrl_1.order; for (i__ = 1; i__ <= i__1; ++i__) { rc[i__] = rcbuf[i__ - 1]; } return 0; } /* analys_ */ asterisk-11.7.0/codecs/lpc10/hp100.c0000644000175000007640000001112110513757330016520 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:28:05 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:32:04 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int hp100_(real *speech, integer *start, integer *end, struct lpc10_encoder_state *st); extern int inithp100_(void); #endif /* ********************************************************************* */ /* HP100 Version 55 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:28:05 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:32:04 jaf * Initial revision * */ /* Revision 1.6 1996/03/15 16:45:25 jaf */ /* Rearranged a few comments. */ /* Revision 1.5 1996/03/14 23:20:54 jaf */ /* Added comments about when INITHP100 should be used. */ /* Revision 1.4 1996/03/14 23:08:08 jaf */ /* Added an entry named INITHP100 that initializes the local state of */ /* subroutine HP100. */ /* Revision 1.3 1996/03/14 22:09:20 jaf */ /* Comments added explaining which of the local variables of this */ /* subroutine need to be saved from one invocation to the next, and which */ /* do not. */ /* Revision 1.2 1996/02/12 15:05:54 jaf */ /* Added lots of comments explaining why I changed one line, which was a */ /* declaration with initializations. */ /* Revision 1.1 1996/02/07 14:47:12 jaf */ /* Initial revision */ /* ********************************************************************* */ /* 100 Hz High Pass Filter */ /* Jan 92 - corrected typo (1.937148 to 1.935715), */ /* rounded coefficients to 7 places, */ /* corrected and merged gain (.97466**4), */ /* merged numerator into first two sections. */ /* Input: */ /* start, end - Range of samples to filter */ /* Input/Output: */ /* speech(end) - Speech data. */ /* Indices start through end are read and modified. */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITHP100. */ /* Subroutine */ int hp100_(real *speech, integer *start, integer *end, struct lpc10_encoder_state *st) { /* Temporary local copies of variables in lpc10_encoder_state. I've only created these because it might cause the loop below to execute a bit faster to access local variables, rather than variables in the lpc10_encoder_state structure. It is just a guess that it will be faster. */ real z11; real z21; real z12; real z22; /* System generated locals */ integer i__1; /* Local variables */ integer i__; real si, err; /* Arguments */ /* Local variables that need not be saved */ /* Local state */ /* Parameter adjustments */ if (speech) { --speech; } /* Function Body */ z11 = st->z11; z21 = st->z21; z12 = st->z12; z22 = st->z22; i__1 = *end; for (i__ = *start; i__ <= i__1; ++i__) { si = speech[i__]; err = si + z11 * 1.859076f - z21 * .8648249f; si = err - z11 * 2.f + z21; z21 = z11; z11 = err; err = si + z12 * 1.935715f - z22 * .9417004f; si = err - z12 * 2.f + z22; z22 = z12; z12 = err; speech[i__] = si * .902428f; } st->z11 = z11; st->z21 = z21; st->z12 = z12; st->z22 = z22; return 0; } /* hp100_ */ asterisk-11.7.0/codecs/lpc10/ham84.c0000644000175000007640000000673310513757330016626 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:32:07 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int ham84_(integer *input, integer *output, integer *errcnt); #endif /* ***************************************************************** */ /* HAM84 Version 45G */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:07 jaf * Initial revision * */ /* Revision 1.3 1996/03/21 15:26:00 jaf */ /* Put comment header in standard form. */ /* Revision 1.2 1996/03/13 22:00:13 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:47:04 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Hamming 8,4 Decoder - can correct 1 out of seven bits */ /* and can detect up to two errors. */ /* Input: */ /* INPUT - Seven bit data word, 4 bits parameter and */ /* 4 bits parity information */ /* Input/Output: */ /* ERRCNT - Sums errors detected by Hamming code */ /* Output: */ /* OUTPUT - 4 corrected parameter bits */ /* This subroutine is entered with an eight bit word in INPUT. The 8th */ /* bit is parity and is stripped off. The remaining 7 bits address the */ /* hamming 8,4 table and the output OUTPUT from the table gives the 4 */ /* bits of corrected data. If bit 4 is set, no error was detected. */ /* ERRCNT is the number of errors counted. */ /* This subroutine has no local state. */ /* Subroutine */ int ham84_(integer *input, integer *output, integer *errcnt) { /* Initialized data */ static integer dactab[128] = { 16,0,0,3,0,5,14,7,0,9,14,11,14,13,30,14,0, 9,2,7,4,7,7,23,9,25,10,9,12,9,14,7,0,5,2,11,5,21,6,5,8,11,11,27, 12,5,14,11,2,1,18,2,12,5,2,7,12,9,2,11,28,12,12,15,0,3,3,19,4,13, 6,3,8,13,10,3,13,29,14,13,4,1,10,3,20,4,4,7,10,9,26,10,4,13,10,15, 8,1,6,3,6,5,22,6,24,8,8,11,8,13,6,15,1,17,2,1,4,1,6,15,8,1,10,15, 12,15,15,31 }; integer i__, j, parity; /* Arguments */ /* Parameters/constants */ /* Local variables that need not be saved */ /* Determine parity of input word */ parity = *input & 255; parity ^= parity / 16; parity ^= parity / 4; parity ^= parity / 2; parity &= 1; i__ = dactab[*input & 127]; *output = i__ & 15; j = i__ & 16; if (j != 0) { /* No errors detected in seven bits */ if (parity != 0) { ++(*errcnt); } } else { /* One or two errors detected */ ++(*errcnt); if (parity == 0) { /* Two errors detected */ ++(*errcnt); *output = -1; } } return 0; } /* ham84_ */ asterisk-11.7.0/codecs/lpc10/energy.c0000644000175000007640000000476610513757330017202 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:32:17 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int energy_(integer *len, real *speech, real *rms); #endif /* ********************************************************************* */ /* ENERGY Version 50 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:32:17 jaf * Initial revision * */ /* Revision 1.3 1996/03/18 21:17:41 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 16:46:02 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:45:40 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Compute RMS energy. */ /* Input: */ /* LEN - Length of speech buffer */ /* SPEECH - Speech buffer */ /* Indices 1 through LEN read. */ /* Output: */ /* RMS - Root Mean Square energy */ /* This subroutine has no local state. */ /* Subroutine */ int energy_(integer *len, real *speech, real *rms) { /* System generated locals */ integer i__1; /* Builtin functions */ double sqrt(doublereal); /* Local variables */ integer i__; /* Arguments */ /* Local variables that need not be saved */ /* Parameter adjustments */ --speech; /* Function Body */ *rms = 0.f; i__1 = *len; for (i__ = 1; i__ <= i__1; ++i__) { *rms += speech[i__] * speech[i__]; } *rms = (real)sqrt(*rms / *len); return 0; } /* energy_ */ asterisk-11.7.0/codecs/lpc10/voicin.c0000644000175000007640000007051710513757330017175 0ustar sharkyjerryweb/* $Log$ Revision 1.16 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.15 2003/11/23 22:14:32 markster Various warning cleanups Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:40 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:45:00 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:30:14 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int voicin_(integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *minamd, real *maxamd, integer *mintau, real *ivrc, integer *obound, integer *voibuf, integer *af, struct lpc10_encoder_state *st); /* comlen contrl_ 12 */ /*:ref: vparms_ 14 14 4 6 6 4 4 6 4 4 4 4 6 6 6 6 */ #endif /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /****************************************************************************/ /* VOICIN Version 52 */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/11/23 22:14:32 markster * Various warning cleanups * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:40 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:45:00 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:30:14 jaf * Initial revision * */ /* Revision 1.10 1996/03/29 17:59:14 jaf */ /* Avoided using VALUE(9), although it shouldn't affect the function of */ /* the code at all, because it was always multiplied by VDC(9,SNRL), */ /* which is 0 for all values of SNRL. Still, if VALUE(9) had an initial */ /* value of IEEE NaN, it might cause trouble (I don't know how IEEE */ /* defines Nan * 0. It should either be NaN or 0.) */ /* Revision 1.9 1996/03/29 17:54:46 jaf */ /* Added a few comments about the accesses made to argument array VOIBUF */ /* and the local saved array VOICE. */ /* Revision 1.8 1996/03/27 18:19:54 jaf */ /* Added an assignment to VSTATE that does not affect the function of the */ /* program at all. The only reason I put it in was so that the tracing */ /* statements at the end, when enabled, will print a consistent value for */ /* VSTATE when HALF .EQ. 1, rather than a garbage value that could change */ /* from one call to the next. */ /* Revision 1.7 1996/03/26 20:00:06 jaf */ /* Removed the inclusion of the file "vcomm.fh", and put its contents */ /* into this file. It was included nowhere else but here. */ /* Revision 1.6 1996/03/26 19:38:09 jaf */ /* Commented out trace statements. */ /* Revision 1.5 1996/03/19 20:43:45 jaf */ /* Added comments about which indices of OBOUND and VOIBUF can be */ /* accessed, and whether they are read or written. VOIBUF is fairly */ /* messy. */ /* Revision 1.4 1996/03/19 15:00:58 jaf */ /* Moved the DATA statements for the *VDC* variables later, as it is */ /* apparently illegal to have DATA statements before local variable */ /* declarations. */ /* Revision 1.3 1996/03/19 00:10:49 jaf */ /* Heavily commented the local variables that are saved from one */ /* invocation to the next, and how the local variable FIRST is used to */ /* avoid the need to assign most of them initial values with DATA */ /* statements. */ /* A few should be initialized, but aren't. I've guessed initial values */ /* for two of these, SFBUE and SLBUE, and I've convinced myself that for */ /* VOICE, the effects of uninitialized values will die out after 2 or 3 */ /* frame times. It would still be good to choose initial values for */ /* these, but I don't know what reasonable values would be (0 comes to */ /* mind). */ /* Revision 1.2 1996/03/13 16:09:28 jaf */ /* Comments added explaining which of the local variables of this */ /* subroutine need to be saved from one invocation to the next, and which */ /* do not. */ /* WARNING! Some of them that should are never given initial values in */ /* this code. Hopefully, Fortran 77 defines initial values for them, but */ /* even so, giving them explicit initial values is preferable. */ /* WARNING! VALUE(9) is used, but never assigned a value. It should */ /* probably be eliminated from the code. */ /* Revision 1.1 1996/02/07 14:50:28 jaf */ /* Initial revision */ /****************************************************************************/ /* Voicing Detection (VOICIN) makes voicing decisions for each half */ /* frame of input speech. Tentative voicing decisions are made two frames*/ /* in the future (2F) for each half frame. These decisions are carried */ /* through one frame in the future (1F) to the present (P) frame where */ /* they are examined and smoothed, resulting in the final voicing */ /* decisions for each half frame. */ /* The voicing parameter (signal measurement) column vector (VALUE) */ /* is based on a rectangular window of speech samples determined by the */ /* window placement algorithm. The voicing parameter vector contains the*/ /* AMDF windowed maximum-to-minimum ratio, the zero crossing rate, energy*/ /* measures, reflection coefficients, and prediction gains. The voicing */ /* window is placed to avoid contamination of the voicing parameter vector*/ /* with speech onsets. */ /* The input signal is then classified as unvoiced (including */ /* silence) or voiced. This decision is made by a linear discriminant */ /* function consisting of a dot product of the voicing decision */ /* coefficient (VDC) row vector with the measurement column vector */ /* (VALUE). The VDC vector is 2-dimensional, each row vector is optimized*/ /* for a particular signal-to-noise ratio (SNR). So, before the dot */ /* product is performed, the SNR is estimated to select the appropriate */ /* VDC vector. */ /* The smoothing algorithm is a modified median smoother. The */ /* voicing discriminant function is used by the smoother to determine how*/ /* strongly voiced or unvoiced a signal is. The smoothing is further */ /* modified if a speech onset and a voicing decision transition occur */ /* within one half frame. In this case, the voicing decision transition */ /* is extended to the speech onset. For transmission purposes, there are*/ /* constraints on the duration and transition of voicing decisions. The */ /* smoother takes these constraints into account. */ /* Finally, the energy estimates are updated along with the dither */ /* threshold used to calculate the zero crossing rate (ZC). */ /* Inputs: */ /* VWIN - Voicing window limits */ /* The indices read of arrays VWIN, INBUF, LPBUF, and BUFLIM */ /* are the same as those read by subroutine VPARMS. */ /* INBUF - Input speech buffer */ /* LPBUF - Low-pass filtered speech buffer */ /* BUFLIM - INBUF and LPBUF limits */ /* HALF - Present analysis half frame number */ /* MINAMD - Minimum value of the AMDF */ /* MAXAMD - Maximum value of the AMDF */ /* MINTAU - Pointer to the lag of the minimum AMDF value */ /* IVRC(2) - Inverse filter's RC's */ /* Only index 2 of array IVRC read under normal operation. */ /* (Index 1 is also read when debugging is turned on.) */ /* OBOUND - Onset boundary descriptions */ /* Indices 1 through 3 read if (HALF .NE. 1), otherwise untouched. */ /* AF - The analysis frame number */ /* Output: */ /* VOIBUF(2,0:AF) - Buffer of voicing decisions */ /* Index (HALF,3) written. */ /* If (HALF .EQ. 1), skip down to "Read (HALF,3)" below. */ /* Indices (1,2), (2,1), (1,2), and (2,2) read. */ /* One of the following is then done: */ /* read (1,3) and possibly write (1,2) */ /* read (1,3) and write (1,2) or (2,2) */ /* write (2,1) */ /* write (2,1) or (1,2) */ /* read (1,0) and (1,3) and then write (2,2) or (1,1) */ /* no reads or writes on VOIBUF */ /* Finally, read (HALF,3) */ /* Internal: */ /* QS - Ratio of preemphasized to full-band energies */ /* RC1 - First reflection coefficient */ /* AR_B - Product of the causal forward and reverse pitch prediction gain s*/ /* AR_F - Product of the noncausal forward and rev. pitch prediction gain s*/ /* ZC - Zero crossing rate */ /* DITHER - Zero crossing threshold level */ /* MAXMIN - AMDF's 1 octave windowed maximum-to-minimum ratio */ /* MINPTR - Location of minimum AMDF value */ /* NVDC - Number of elements in each VDC vector */ /* NVDCL - Number of VDC vectors */ /* VDCL - SNR values corresponding to the set of VDC's */ /* VDC - 2-D voicing decision coefficient vector */ /* VALUE(9) - Voicing Parameters */ /* VOICE(2,3)- History of LDA results */ /* On every call when (HALF .EQ. 1), VOICE(*,I+1) is */ /* shifted back to VOICE(*,I), for I=1,2. */ /* VOICE(HALF,3) is written on every call. */ /* Depending on several conditions, one or more of */ /* (1,1), (1,2), (2,1), and (2,2) might then be read. */ /* LBE - Ratio of low-band instantaneous to average energies */ /* FBE - Ratio of full-band instantaneous to average energies */ /* LBVE - Low band voiced energy */ /* LBUE - Low band unvoiced energy */ /* FBVE - Full band voiced energy */ /* FBUE - Full band unvoiced energy */ /* OFBUE - Previous full-band unvoiced energy */ /* OLBUE - Previous low-band unvoiced energy */ /* REF - Reference energy for initialization and DITHER threshold */ /* SNR - Estimate of signal-to-noise ratio */ /* SNR2 - Estimate of low-band signal-to-noise ratio */ /* SNRL - SNR level number */ /* OT - Onset transition present */ /* VSTATE - Decimal interpretation of binary voicing classifications */ /* FIRST - First call flag */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITVOICIN. */ /* Subroutine */ int voicin_(integer *vwin, real *inbuf, real * lpbuf, integer *buflim, integer *half, real *minamd, real *maxamd, integer *mintau, real *ivrc, integer *obound, integer *voibuf, integer *af, struct lpc10_encoder_state *st) { /* Initialized data */ real *dither; static real vdc[100] /* was [10][10] */ = { 0.f,1714.f,-110.f, 334.f,-4096.f,-654.f,3752.f,3769.f,0.f,1181.f,0.f,874.f,-97.f, 300.f,-4096.f,-1021.f,2451.f,2527.f,0.f,-500.f,0.f,510.f,-70.f, 250.f,-4096.f,-1270.f,2194.f,2491.f,0.f,-1500.f,0.f,500.f,-10.f, 200.f,-4096.f,-1300.f,2e3f,2e3f,0.f,-2e3f,0.f,500.f,0.f,0.f, -4096.f,-1300.f,2e3f,2e3f,0.f,-2500.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f, 0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f, 0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f, 0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f }; static integer nvdcl = 5; static real vdcl[10] = { 600.f,450.f,300.f,200.f,0.f,0.f,0.f,0.f,0.f,0.f } ; /* System generated locals */ integer inbuf_offset = 0, lpbuf_offset = 0, i__1, i__2; real r__1, r__2; /* Builtin functions */ integer i_nint(real *); double sqrt(doublereal); /* Local variables */ real ar_b__, ar_f__; integer *lbve, *lbue, *fbve, *fbue; integer snrl, i__; integer *ofbue, *sfbue; real *voice; integer *olbue, *slbue; real value[9]; integer zc; logical ot; real qs; real *maxmin; integer vstate; real rc1; extern /* Subroutine */ int vparms_(integer *, real *, real *, integer *, integer *, real *, integer *, integer *, integer *, integer *, real *, real *, real *, real *); integer fbe, lbe; real *snr; real snr2; /* Global Variables: */ /* Arguments */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/11/23 22:14:32 markster * Various warning cleanups * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:40 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:45:00 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:30:14 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Parameters/constants */ /* Voicing coefficient and Linear Discriminant Analysis variables: */ /* Max number of VDC's and VDC levels */ /* The following are not Fortran PARAMETER's, but they are */ /* initialized with DATA statements, and never modified. */ /* Actual number of VDC's and levels */ /* Local variables that need not be saved */ /* Note: */ /* VALUE(1) through VALUE(8) are assigned values, but VALUE(9) */ /* never is. Yet VALUE(9) is read in the loop that begins "DO I = */ /* 1, 9" below. I believe that this doesn't cause any problems in */ /* this subroutine, because all VDC(9,*) array elements are 0, and */ /* this is what is multiplied by VALUE(9) in all cases. Still, it */ /* would save a multiplication to change the loop to "DO I = 1, 8". */ /* Local state */ /* WARNING! */ /* VOICE, SFBUE, and SLBUE should be saved from one invocation to */ /* the next, but they are never given an initial value. */ /* Does Fortran 77 specify some default initial value, like 0, or */ /* is it undefined? If it is undefined, then this code should be */ /* corrected to specify an initial value. */ /* For VOICE, note that it is "shifted" in the statement that */ /* begins "IF (HALF .EQ. 1) THEN" below. Also, uninitialized */ /* values in the VOICE array can only affect entries in the VOIBUF */ /* array that are for the same frame, or for an older frame. Thus */ /* the effects of uninitialized values in VOICE cannot linger on */ /* for more than 2 or 3 frame times. */ /* For SFBUE and SLBUE, the effects of uninitialized values can */ /* linger on for many frame times, because their previous values */ /* are exponentially decayed. Thus it is more important to choose */ /* initial values for these variables. I would guess that a */ /* reasonable initial value for SFBUE is REF/16, the same as used */ /* for FBUE and OFBUE. Similarly, SLBUE can be initialized to */ /* REF/32, the same as for LBUE and OLBUE. */ /* These guessed initial values should be validated by re-running */ /* the modified program on some audio samples. */ /* Declare and initialize filters: */ dither = (&st->dither); snr = (&st->snr); maxmin = (&st->maxmin); voice = (&st->voice[0]); lbve = (&st->lbve); lbue = (&st->lbue); fbve = (&st->fbve); fbue = (&st->fbue); ofbue = (&st->ofbue); olbue = (&st->olbue); sfbue = (&st->sfbue); slbue = (&st->slbue); /* Parameter adjustments */ if (vwin) { --vwin; } if (buflim) { --buflim; } if (inbuf) { inbuf_offset = buflim[1]; inbuf -= inbuf_offset; } if (lpbuf) { lpbuf_offset = buflim[3]; lpbuf -= lpbuf_offset; } if (ivrc) { --ivrc; } if (obound) { --obound; } if (voibuf) { --voibuf; } /* Function Body */ /* The following variables are saved from one invocation to the */ /* next, but are not initialized with DATA statements. This is */ /* acceptable, because FIRST is initialized ot .TRUE., and the */ /* first time that this subroutine is then called, they are all */ /* given initial values. */ /* SNR */ /* LBVE, LBUE, FBVE, FBUE, OFBUE, OLBUE */ /* MAXMIN is initialized on the first call, assuming that HALF */ /* .EQ. 1 on first call. This is how ANALYS calls this subroutine. */ /* Voicing Decision Parameter vector (* denotes zero coefficient): */ /* * MAXMIN */ /* LBE/LBVE */ /* ZC */ /* RC1 */ /* QS */ /* IVRC2 */ /* aR_B */ /* aR_F */ /* * LOG(LBE/LBVE) */ /* Define 2-D voicing decision coefficient vector according to the voicin g*/ /* parameter order above. Each row (VDC vector) is optimized for a speci fic*/ /* SNR. The last element of the vector is the constant. */ /* E ZC RC1 Qs IVRC2 aRb aRf c */ /* The VOICE array contains the result of the linear discriminant functio n*/ /* (analog values). The VOIBUF array contains the hard-limited binary */ /* voicing decisions. The VOICE and VOIBUF arrays, according to FORTRAN */ /* memory allocation, are addressed as: */ /* (half-frame number, future-frame number) */ /* | Past | Present | Future1 | Future2 | */ /* | 1,0 | 2,0 | 1,1 | 2,1 | 1,2 | 2,2 | 1,3 | 2,3 | ---> time */ /* Update linear discriminant function history each frame: */ if (*half == 1) { voice[0] = voice[2]; voice[1] = voice[3]; voice[2] = voice[4]; voice[3] = voice[5]; *maxmin = *maxamd / max(*minamd,1.f); } /* Calculate voicing parameters twice per frame: */ vparms_(&vwin[1], &inbuf[inbuf_offset], &lpbuf[lpbuf_offset], &buflim[1], half, dither, mintau, &zc, &lbe, &fbe, &qs, &rc1, &ar_b__, & ar_f__); /* Estimate signal-to-noise ratio to select the appropriate VDC vector. */ /* The SNR is estimated as the running average of the ratio of the */ /* running average full-band voiced energy to the running average */ /* full-band unvoiced energy. SNR filter has gain of 63. */ r__1 = (*snr + *fbve / (real) max(*fbue,1)) * 63 / 64.f; *snr = (real) i_nint(&r__1); snr2 = *snr * *fbue / max(*lbue,1); /* Quantize SNR to SNRL according to VDCL thresholds. */ snrl = 1; i__1 = nvdcl - 1; for (snrl = 1; snrl <= i__1; ++snrl) { if (snr2 > vdcl[snrl - 1]) { goto L69; } } /* (Note: SNRL = NVDCL here) */ L69: /* Linear discriminant voicing parameters: */ value[0] = *maxmin; value[1] = (real) lbe / max(*lbve,1); value[2] = (real) zc; value[3] = rc1; value[4] = qs; value[5] = ivrc[2]; value[6] = ar_b__; value[7] = ar_f__; /* Evaluation of linear discriminant function: */ voice[*half + 3] = vdc[snrl * 10 - 1]; for (i__ = 1; i__ <= 8; ++i__) { voice[*half + 3] += vdc[i__ + snrl * 10 - 11] * value[i__ - 1]; } /* Classify as voiced if discriminant > 0, otherwise unvoiced */ /* Voicing decision for current half-frame: 1 = Voiced; 0 = Unvoiced */ if (voice[*half + 3] > 0.f) { voibuf[*half + 6] = 1; } else { voibuf[*half + 6] = 0; } /* Skip voicing decision smoothing in first half-frame: */ /* Give a value to VSTATE, so that trace statements below will print */ /* a consistent value from one call to the next when HALF .EQ. 1. */ /* The value of VSTATE is not used for any other purpose when this is */ /* true. */ vstate = -1; if (*half == 1) { goto L99; } /* Voicing decision smoothing rules (override of linear combination): */ /* Unvoiced half-frames: At least two in a row. */ /* -------------------- */ /* Voiced half-frames: At least two in a row in one frame. */ /* ------------------- Otherwise at least three in a row. */ /* (Due to the way transition frames are encoded) */ /* In many cases, the discriminant function determines how to smooth. */ /* In the following chart, the decisions marked with a * may be overridden .*/ /* Voicing override of transitions at onsets: */ /* If a V/UV or UV/V voicing decision transition occurs within one-half */ /* frame of an onset bounding a voicing window, then the transition is */ /* moved to occur at the onset. */ /* P 1F */ /* ----- ----- */ /* 0 0 0 0 */ /* 0 0 0* 1 (If there is an onset there) */ /* 0 0 1* 0* (Based on 2F and discriminant distance) */ /* 0 0 1 1 */ /* 0 1* 0 0 (Always) */ /* 0 1* 0* 1 (Based on discriminant distance) */ /* 0* 1 1 0* (Based on past, 2F, and discriminant distance) */ /* 0 1* 1 1 (If there is an onset there) */ /* 1 0* 0 0 (If there is an onset there) */ /* 1 0 0 1 */ /* 1 0* 1* 0 (Based on discriminant distance) */ /* 1 0* 1 1 (Always) */ /* 1 1 0 0 */ /* 1 1 0* 1* (Based on 2F and discriminant distance) */ /* 1 1 1* 0 (If there is an onset there) */ /* 1 1 1 1 */ /* Determine if there is an onset transition between P and 1F. */ /* OT (Onset Transition) is true if there is an onset between */ /* P and 1F but not after 1F. */ ot = ((obound[1] & 2) != 0 || obound[2] == 1) && (obound[3] & 1) == 0; /* Multi-way dispatch on voicing decision history: */ vstate = (voibuf[3] << 3) + (voibuf[4] << 2) + (voibuf[5] << 1) + voibuf[ 6]; switch (vstate + 1) { case 1: goto L99; case 2: goto L1; case 3: goto L2; case 4: goto L99; case 5: goto L4; case 6: goto L5; case 7: goto L6; case 8: goto L7; case 9: goto L8; case 10: goto L99; case 11: goto L10; case 12: goto L11; case 13: goto L99; case 14: goto L13; case 15: goto L14; case 16: goto L99; } L1: if (ot && voibuf[7] == 1) { voibuf[5] = 1; } goto L99; L2: if (voibuf[7] == 0 || voice[2] < -voice[3]) { voibuf[5] = 0; } else { voibuf[6] = 1; } goto L99; L4: voibuf[4] = 0; goto L99; L5: if (voice[1] < -voice[2]) { voibuf[4] = 0; } else { voibuf[5] = 1; } goto L99; /* VOIBUF(2,0) must be 0 */ L6: if (voibuf[1] == 1 || voibuf[7] == 1 || voice[3] > voice[0]) { voibuf[6] = 1; } else { voibuf[3] = 1; } goto L99; L7: if (ot) { voibuf[4] = 0; } goto L99; L8: if (ot) { voibuf[4] = 1; } goto L99; L10: if (voice[2] < -voice[1]) { voibuf[5] = 0; } else { voibuf[4] = 1; } goto L99; L11: voibuf[4] = 1; goto L99; L13: if (voibuf[7] == 0 && voice[3] < -voice[2]) { voibuf[6] = 0; } else { voibuf[5] = 1; } goto L99; L14: if (ot && voibuf[7] == 0) { voibuf[5] = 0; } /* GOTO 99 */ L99: /* Now update parameters: */ /* ---------------------- */ /* During unvoiced half-frames, update the low band and full band unvoice d*/ /* energy estimates (LBUE and FBUE) and also the zero crossing */ /* threshold (DITHER). (The input to the unvoiced energy filters is */ /* restricted to be less than 10dB above the previous inputs of the */ /* filters.) */ /* During voiced half-frames, update the low-pass (LBVE) and all-pass */ /* (FBVE) voiced energy estimates. */ if (voibuf[*half + 6] == 0) { /* Computing MIN */ i__1 = fbe, i__2 = *ofbue * 3; r__1 = (*sfbue * 63 + (min(i__1,i__2) << 3)) / 64.f; *sfbue = i_nint(&r__1); *fbue = *sfbue / 8; *ofbue = fbe; /* Computing MIN */ i__1 = lbe, i__2 = *olbue * 3; r__1 = (*slbue * 63 + (min(i__1,i__2) << 3)) / 64.f; *slbue = i_nint(&r__1); *lbue = *slbue / 8; *olbue = lbe; } else { r__1 = (*lbve * 63 + lbe) / 64.f; *lbve = i_nint(&r__1); r__1 = (*fbve * 63 + fbe) / 64.f; *fbve = i_nint(&r__1); } /* Set dither threshold to yield proper zero crossing rates in the */ /* presence of low frequency noise and low level signal input. */ /* NOTE: The divisor is a function of REF, the expected energies. */ /* Computing MIN */ /* Computing MAX */ r__2 = (real)(sqrt((real) (*lbue * *lbve)) * 64 / 3000); r__1 = max(r__2,1.f); *dither = min(r__1,20.f); /* Voicing decisions are returned in VOIBUF. */ return 0; } /* voicin_ */ asterisk-11.7.0/codecs/lpc10/chanwr.c0000644000175000007640000001610511102362576017160 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:20:24 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Revision 1.1 1996/08/19 22:40:31 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include #include "f2c.h" /* *********************************************************************** */ /* CHANL Version 49 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:20:24 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Revision 1.1 1996/08/19 22:40:31 jaf * Initial revision * */ /* Revision 1.3 1996/03/21 15:14:57 jaf */ /* Added comments about which indices of argument arrays are read or */ /* written, and about the one bit of local state in CHANWR. CHANRD */ /* has no local state. */ /* Revision 1.2 1996/03/13 18:55:10 jaf */ /* Comments added explaining which of the local variables of this */ /* subroutine need to be saved from one invocation to the next, and which */ /* do not. */ /* Revision 1.1 1996/02/07 14:43:31 jaf */ /* Initial revision */ /* *********************************************************************** */ /* CHANWR: */ /* Place quantized parameters into bitstream */ /* Input: */ /* ORDER - Number of reflection coefficients (not really variable) */ /* IPITV - Quantized pitch/voicing parameter */ /* IRMS - Quantized energy parameter */ /* IRC - Quantized reflection coefficients */ /* Indices 1 through ORDER read. */ /* Output: */ /* IBITS - Serial bitstream */ /* Indices 1 through 54 written. */ /* Bit 54, the SYNC bit, alternates from one call to the next. */ /* Subroutine CHANWR maintains one bit of local state from one call to */ /* the next, in the variable ISYNC. I believe that this one bit is only */ /* intended to allow a receiver to resynchronize its interpretation of */ /* the bit stream, by looking for which of the 54 bits alternates every */ /* frame time. This is just a simple framing mechanism that is not */ /* useful when other, higher overhead framing mechanisms are used to */ /* transmit the coded frames. */ /* I'm not going to make an entry to reinitialize this bit, since it */ /* doesn't help a receiver much to know whether the first sync bit is a 0 */ /* or a 1. It needs to examine several frames in sequence to have */ /* reasonably good assurance that its framing is correct. */ /* CHANRD: */ /* Reconstruct parameters from bitstream */ /* Input: */ /* ORDER - Number of reflection coefficients (not really variable) */ /* IBITS - Serial bitstream */ /* Indices 1 through 53 read (SYNC bit is ignored). */ /* Output: */ /* IPITV - Quantized pitch/voicing parameter */ /* IRMS - Quantized energy parameter */ /* IRC - Quantized reflection coefficients */ /* Indices 1 through ORDER written */ /* Entry CHANRD has no local state. */ /* IBITS is 54 bits of LPC data ordered as follows: */ /* R1-0, R2-0, R3-0, P-0, A-0, */ /* R1-1, R2-1, R3-1, P-1, A-1, */ /* R1-2, R4-0, R3-2, A-2, P-2, R4-1, */ /* R1-3, R2-2, R3-3, R4-2, A-3, */ /* R1-4, R2-3, R3-4, R4-3, A-4, */ /* P-3, R2-4, R7-0, R8-0, P-4, R4-4, */ /* R5-0, R6-0, R7-1,R10-0, R8-1, */ /* R5-1, R6-1, R7-2, R9-0, P-5, */ /* R5-2, R6-2,R10-1, R8-2, P-6, R9-1, */ /* R5-3, R6-3, R7-3, R9-2, R8-3, SYNC */ /* Subroutine */ int chanwr_0_(int n__, integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits, struct lpc10_encoder_state *st) { /* Initialized data */ integer *isync; static integer bit[10] = { 2,4,8,8,8,8,16,16,16,16 }; static integer iblist[53] = { 13,12,11,1,2,13,12,11,1,2,13,10,11,2,1,10, 13,12,11,10,2,13,12,11,10,2,1,12,7,6,1,10,9,8,7,4,6,9,8,7,5,1,9,8, 4,6,1,5,9,8,7,5,6 }; /* System generated locals */ integer i__1; /* Local variables */ integer itab[13], i__; /* Arguments */ /* Parameters/constants */ /* These arrays are not Fortran PARAMETER's, but they are defined */ /* by DATA statements below, and their contents are never altered. */ /* Local variables that need not be saved */ /* Local state */ /* ISYNC is only used by CHANWR, not by ENTRY CHANRD. */ /* Parameter adjustments */ --irc; --ibits; /* Function Body */ switch(n__) { case 1: goto L_chanrd; } isync = &(st->isync); /* *********************************************************************** */ /* Place quantized parameters into bitstream */ /* *********************************************************************** */ /* Place parameters into ITAB */ itab[0] = *ipitv; itab[1] = *irms; itab[2] = 0; i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { itab[i__ + 2] = irc[*order + 1 - i__] & 32767; } /* Put 54 bits into IBITS array */ for (i__ = 1; i__ <= 53; ++i__) { ibits[i__] = itab[iblist[i__ - 1] - 1] & 1; itab[iblist[i__ - 1] - 1] /= 2; } ibits[54] = *isync & 1; *isync = 1 - *isync; return 0; /* *********************************************************************** */ /* Reconstruct parameters from bitstream */ /* *********************************************************************** */ L_chanrd: /* Reconstruct ITAB */ for (i__ = 1; i__ <= 13; ++i__) { itab[i__ - 1] = 0; } for (i__ = 1; i__ <= 53; ++i__) { itab[iblist[54 - i__ - 1] - 1] = (itab[iblist[54 - i__ - 1] - 1] << 1) + ibits[54 - i__]; } /* Sign extend RC's */ i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { if ((itab[i__ + 2] & bit[i__ - 1]) != 0) { itab[i__ + 2] -= bit[i__ - 1] << 1; } } /* Restore variables */ *ipitv = itab[0]; *irms = itab[1]; i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { irc[i__] = itab[*order + 4 - i__ - 1]; } return 0; } /* chanwr_ */ /* Subroutine */ int chanwr_(integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits, struct lpc10_encoder_state *st) { return chanwr_0_(0, order, ipitv, irms, irc, ibits, st); } /* Subroutine */ int chanrd_(integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits) { return chanwr_0_(1, order, ipitv, irms, irc, ibits, NULL); } asterisk-11.7.0/codecs/lpc10/pitsyn.c0000644000175000007640000004355411234342451017230 0ustar sharkyjerryweb/* $Log$ Revision 1.16 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.15 2003/11/23 22:14:32 markster Various warning cleanups Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:40:12 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:31:12 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio, struct lpc10_decoder_state *st); #endif /* ***************************************************************** */ /* PITSYN Version 53 */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/11/23 22:14:32 markster * Various warning cleanups * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:40:12 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:31:12 jaf * Initial revision * */ /* Revision 1.2 1996/03/25 18:49:07 jaf */ /* Added comments about which indices of array arguments are read or */ /* written. */ /* Rearranged local variable declarations to indicate which need to be */ /* saved from one invocation to the next. Added entry INITPITSYN to */ /* reinitialize local state variables, if desired. */ /* Added lots of comments about proving that the maximum number of pitch */ /* periods (NOUT) that can be returned is 16. The call to STOP that */ /* could happen if NOUT got too large was removed as a result. */ /* Also proved that the total number of samples returned from N calls, */ /* each with identical values of LFRAME, will always be in the range */ /* N*LFRAME-MAXPIT+1 to N*LFRAME. */ /* Revision 1.1 1996/02/07 14:48:18 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Synthesize a single pitch epoch */ /* Input: */ /* ORDER - Synthesis order (number of RC's) */ /* VOICE - Half frame voicing decisions */ /* Indices 1 through 2 read. */ /* LFRAME - Length of speech buffer */ /* Input/Output: */ /* PITCH - Pitch */ /* This value should be in the range MINPIT (20) to MAXPIT */ /* (156), inclusive. */ /* PITCH can be modified under some conditions. */ /* RMS - Energy (can be modified) */ /* RMS is changed to 1 if the value passed in is less than 1. */ /* RC - Reflection coefficients */ /* Indices 1 through ORDER can be temporarily overwritten with */ /* RCO, and then replaced with original values, under some */ /* conditions. */ /* Output: */ /* IVUV - Pitch epoch voicing decisions */ /* Indices (I) of IVUV, IPITI, and RMSI are written, */ /* and indices (J,I) of RCI are written, */ /* where I ranges from 1 to NOUT, and J ranges from 1 to ORDER. */ /* IPITI - Pitch epoch length */ /* RMSI - Pitch epoch energy */ /* RCI - Pitch epoch RC's */ /* NOUT - Number of pitch periods in this frame */ /* This is at least 0, at least 1 if MAXPIT .LT. LFRAME (this */ /* is currently true on every call), and can never be more than */ /* (LFRAME+MAXPIT-1)/PITCH, which is currently 16 with */ /* LFRAME=180, MAXPIT=156, and PITCH .GE. 20, as SYNTHS */ /* guarantees when it calls this subroutine. */ /* RATIO - Previous to present energy ratio */ /* Always assigned a value. */ /* Subroutine */ int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio, struct lpc10_decoder_state *st) { /* Initialized data */ real *rmso; logical *first; /* System generated locals */ integer rci_dim1 = 0, rci_offset, i__1, i__2; real r__1; /* Builtin functions */ double log(doublereal), exp(doublereal); /* Local variables */ real alrn, alro, yarc[10], prop; integer i__, j, vflag, jused, lsamp; integer *jsamp; real slope; integer *ipito; real uvpit; integer ip, nl, ivoice; integer *ivoico; integer istart; real *rco; real xxy; /* Arguments */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/11/23 22:14:32 markster * Various warning cleanups * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:40:12 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:31:12 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Local variables that need not be saved */ /* LSAMP is initialized in the IF (FIRST) THEN clause, but it is */ /* not used the first time through, and it is given a value before */ /* use whenever FIRST is .FALSE., so it appears unnecessary to */ /* assign it a value when FIRST is .TRUE. */ /* Local state */ /* FIRST - .TRUE. only on first call to PITSYN. */ /* IVOICO - Previous VOICE(2) value. */ /* IPITO - Previous PITCH value. */ /* RMSO - Previous RMS value. */ /* RCO - Previous RC values. */ /* JSAMP - If this routine is called N times with identical values of */ /* LFRAME, then the total length of all pitch periods returned */ /* is always N*LFRAME-JSAMP, and JSAMP is always in the range 0 */ /* to MAXPIT-1 (see below for why this is so). Thus JSAMP is */ /* the number of samples "left over" from the previous call to */ /* PITSYN, that haven't been "used" in a pitch period returned */ /* from this subroutine. Every time this subroutine is called, */ /* it returns pitch periods with a total length of at most */ /* LFRAME+JSAMP. */ /* IVOICO, IPITO, RCO, and JSAMP need not be assigned an initial value */ /* with a DATA statement, because they are always initialized on the */ /* first call to PITSYN. */ /* FIRST and RMSO should be initialized with DATA statements, because */ /* even on the first call, they are used before being initialized. */ /* Parameter adjustments */ if (rc) { --rc; } if (rci) { rci_dim1 = *order; rci_offset = rci_dim1 + 1; rci -= rci_offset; } if (voice) { --voice; } if (ivuv) { --ivuv; } if (ipiti) { --ipiti; } if (rmsi) { --rmsi; } /* Function Body */ ivoico = &(st->ivoico); ipito = &(st->ipito); rmso = &(st->rmso); rco = &(st->rco[0]); jsamp = &(st->jsamp); first = &(st->first_pitsyn); if (*rms < 1.f) { *rms = 1.f; } if (*rmso < 1.f) { *rmso = 1.f; } uvpit = 0.f; *ratio = *rms / (*rmso + 8.f); if (*first) { lsamp = 0; ivoice = voice[2]; if (ivoice == 0) { *pitch = *lframe / 4; } *nout = *lframe / *pitch; *jsamp = *lframe - *nout * *pitch; /* SYNTHS only calls this subroutine with PITCH in the range 20 */ /* to 156. LFRAME = MAXFRM = 180, so NOUT is somewhere in th e */ /* range 1 to 9. */ /* JSAMP is "LFRAME mod PITCH", so it is in the range 0 to */ /* (PITCH-1), or 0 to MAXPIT-1=155, after the first call. */ i__1 = *nout; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *order; for (j = 1; j <= i__2; ++j) { rci[j + i__ * rci_dim1] = rc[j]; } ivuv[i__] = ivoice; ipiti[i__] = *pitch; rmsi[i__] = *rms; } *first = FALSE_; } else { vflag = 0; lsamp = *lframe + *jsamp; slope = (*pitch - *ipito) / (real) lsamp; *nout = 0; jused = 0; istart = 1; if (voice[1] == *ivoico && voice[2] == voice[1]) { if (voice[2] == 0) { /* SSUV - - 0 , 0 , 0 */ *pitch = *lframe / 4; *ipito = *pitch; if (*ratio > 8.f) { *rmso = *rms; } } /* SSVC - - 1 , 1 , 1 */ slope = (*pitch - *ipito) / (real) lsamp; ivoice = voice[2]; } else { if (*ivoico != 1) { if (*ivoico == voice[1]) { /* UV2VC2 - - 0 , 0 , 1 */ nl = lsamp - *lframe / 4; } else { /* UV2VC1 - - 0 , 1 , 1 */ nl = lsamp - *lframe * 3 / 4; } ipiti[1] = nl / 2; ipiti[2] = nl - ipiti[1]; ivuv[1] = 0; ivuv[2] = 0; rmsi[1] = *rmso; rmsi[2] = *rmso; i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { rci[i__ + rci_dim1] = rco[i__ - 1]; rci[i__ + (rci_dim1 << 1)] = rco[i__ - 1]; rco[i__ - 1] = rc[i__]; } slope = 0.f; *nout = 2; *ipito = *pitch; jused = nl; istart = nl + 1; ivoice = 1; } else { if (*ivoico != voice[1]) { /* VC2UV1 - - 1 , 0 , 0 */ lsamp = *lframe / 4 + *jsamp; } else { /* VC2UV2 - - 1 , 1 , 0 */ lsamp = *lframe * 3 / 4 + *jsamp; } i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { yarc[i__ - 1] = rc[i__]; rc[i__] = rco[i__ - 1]; } ivoice = 1; slope = 0.f; vflag = 1; } } /* Here is the value of most variables that are used below, depending on */ /* the values of IVOICO, VOICE(1), and VOICE(2). VOICE(1) and VOICE(2 ) */ /* are input arguments, and IVOICO is the value of VOICE(2) on the */ /* previous call (see notes for the IF (NOUT .NE. 0) statement near th e */ /* end). Each of these three values is either 0 or 1. These three */ /* values below are given as 3-bit long strings, in the order IVOICO, */ /* VOICE(1), and VOICE(2). It appears that the code above assumes tha t */ /* the bit sequences 010 and 101 never occur, but I wonder whether a */ /* large enough number of bit errors in the channel could cause such a */ /* thing to happen, and if so, could that cause NOUT to ever go over 1 1? */ /* Note that all of the 180 values in the table are really LFRAME, but */ /* 180 has fewer characters, and it makes the table a little more */ /* concrete. If LFRAME is ever changed, keep this in mind. Similarly , */ /* 135's are 3*LFRAME/4, and 45's are LFRAME/4. If LFRAME is not a */ /* multiple of 4, then the 135 for NL-JSAMP is actually LFRAME-LFRAME/ 4, */ /* and the 45 for NL-JSAMP is actually LFRAME-3*LFRAME/4. */ /* Note that LSAMP-JSAMP is given as the variable. This was just for */ /* brevity, to avoid adding "+JSAMP" to all of the column entries. */ /* Similarly for NL-JSAMP. */ /* Variable | 000 001 011,010 111 110 100,101 */ /* ------------+-------------------------------------------------- */ /* ISTART | 1 NL+1 NL+1 1 1 1 */ /* LSAMP-JSAMP | 180 180 180 180 135 45 */ /* IPITO | 45 PITCH PITCH oldPITCH oldPITCH oldPITCH */ /* SLOPE | 0 0 0 seebelow 0 0 */ /* JUSED | 0 NL NL 0 0 0 */ /* PITCH | 45 PITCH PITCH PITCH PITCH PITCH */ /* NL-JSAMP | -- 135 45 -- -- -- */ /* VFLAG | 0 0 0 0 1 1 */ /* NOUT | 0 2 2 0 0 0 */ /* IVOICE | 0 1 1 1 1 1 */ /* while_loop | once once once once twice twice */ /* ISTART | -- -- -- -- JUSED+1 JUSED+1 */ /* LSAMP-JSAMP | -- -- -- -- 180 180 */ /* IPITO | -- -- -- -- oldPITCH oldPITCH */ /* SLOPE | -- -- -- -- 0 0 */ /* JUSED | -- -- -- -- ?? ?? */ /* PITCH | -- -- -- -- PITCH PITCH */ /* NL-JSAMP | -- -- -- -- -- -- */ /* VFLAG | -- -- -- -- 0 0 */ /* NOUT | -- -- -- -- ?? ?? */ /* IVOICE | -- -- -- -- 0 0 */ /* UVPIT is always 0.0 on the first pass through the DO WHILE (.TRUE.) */ /* loop below. */ /* The only possible non-0 value of SLOPE (in column 111) is */ /* (PITCH-IPITO)/FLOAT(LSAMP) */ /* Column 101 is identical to 100. Any good properties we can prove */ /* for 100 will also hold for 101. Similarly for 010 and 011. */ /* SYNTHS calls this subroutine with PITCH restricted to the range 20 to */ /* 156. IPITO is similarly restricted to this range, after the first */ /* call. IP below is also restricted to this range, given the */ /* definitions of IPITO, SLOPE, UVPIT, and that I is in the range ISTA RT */ /* to LSAMP. */ while(TRUE_) { /* JUSED is the total length of all pitch periods curr ently */ /* in the output arrays, in samples. */ /* An invariant of the DO I = ISTART,LSAMP loop below, under */ /* the condition that IP is always in the range 1 thro ugh */ /* MAXPIT, is: */ /* (I - MAXPIT) .LE. JUSED .LE. (I-1) */ /* Note that the final value of I is LSAMP+1, so that after */ /* the DO loop is complete, we know: */ /* (LSAMP - MAXPIT + 1) .LE. JUSED .LE. LSAMP */ i__1 = lsamp; for (i__ = istart; i__ <= i__1; ++i__) { r__1 = *ipito + slope * i__; ip = (integer)(r__1 + .5f); if (uvpit != 0.f) { ip = (integer)uvpit; } if (ip <= i__ - jused) { ++(*nout); /* The following check is no longer nece ssary, now that */ /* we can prove that NOUT will never go over 16. */ /* IF (NOUT .GT. 16) STOP 'PITSYN: too many epochs' */ ipiti[*nout] = ip; *pitch = ip; ivuv[*nout] = ivoice; jused += ip; prop = (jused - ip / 2) / (real) lsamp; i__2 = *order; for (j = 1; j <= i__2; ++j) { alro = (real)log((rco[j - 1] + 1) / (1 - rco[j - 1])); alrn = (real)log((rc[j] + 1) / (1 - rc[j])); xxy = alro + prop * (alrn - alro); xxy = (real)exp(xxy); rci[j + *nout * rci_dim1] = (xxy - 1) / (xxy + 1); } rmsi[*nout] = (real)(log(*rmso) + prop * (log(*rms) - log(*rmso))); rmsi[*nout] = (real)exp(rmsi[*nout]); } } if (vflag != 1) { goto L100; } /* I want to prove what range UVPIT must lie in after the */ /* assignments to it below. To do this, I must determ ine */ /* what range (LSAMP-ISTART) must lie in, after the */ /* assignments to ISTART and LSAMP below. */ /* Let oldLSAMP be the value of LSAMP at this point in the */ /* execution. This is 135+JSAMP in state 110, or 45+J SAMP in */ /* states 100 or 101. */ /* Given the loop invariant on JUSED above, we know th at: */ /* (oldLSAMP - MAXPIT + 1) .LE. JUSED .LE. oldLSAMP */ /* ISTART is one more than this. */ /* Let newLSAMP be the value assigned to LSAMP below. This */ /* is 180+JSAMP. Thus (newLSAMP-oldLSAMP) is either 4 5 or */ /* 135, depending on the state. */ /* Thus, the range of newLSAMP-ISTART is: */ /* (newLSAMP-(oldLSAMP+1)) .LE. newLSAMP-ISTART */ /* .LE. (newLSAMP-(oldLSAMP - MAXPIT + 2)) */ /* or: */ /* 46 .LE. newLSAMP-ISTART .LE. 133+MAXPIT .EQ. 289 */ /* Therefore, UVPIT is in the range 23 to 144 after th e first */ /* assignment to UVPIT below, and after the conditiona l */ /* assignment, it is in the range 23 to 90. */ /* The important thing is that it is in the range 20 t o 156, */ /* so that in the loop above, IP is always in this ran ge. */ vflag = 0; istart = jused + 1; lsamp = *lframe + *jsamp; slope = 0.f; ivoice = 0; uvpit = (real) ((lsamp - istart) / 2); if (uvpit > 90.f) { uvpit /= 2; } *rmso = *rms; i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { rc[i__] = yarc[i__ - 1]; rco[i__ - 1] = yarc[i__ - 1]; } } L100: *jsamp = lsamp - jused; } /* Given that the maximum pitch period MAXPIT .LT. LFRAME (this is */ /* currently true on every call, since SYNTHS always sets */ /* LFRAME=180), NOUT will always be .GE. 1 at this point. */ if (*nout != 0) { *ivoico = voice[2]; *ipito = *pitch; *rmso = *rms; i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { rco[i__ - 1] = rc[i__]; } } return 0; } /* pitsyn_ */ asterisk-11.7.0/codecs/lpc10/lpcenc.c0000644000175000007640000001300410513757330017136 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:31:21 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Changed name of function from lpcenc_ to lpc10_encode, simply to make * all lpc10 functions have more consistent naming with each other. * * Revision 1.1 1996/08/19 22:31:44 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int lpcenc_(real *speech, integer *bits); extern int initlpcenc_(void); /*:ref: prepro_ 14 2 6 4 */ /*:ref: analys_ 14 5 6 4 4 6 6 */ /*:ref: encode_ 14 7 4 4 6 6 4 4 4 */ /*:ref: chanwr_ 14 5 4 4 4 4 4 */ /*:ref: initprepro_ 14 0 */ /*:ref: initanalys_ 14 0 */ #endif /* Table of constant values */ static integer c__180 = 180; static integer c__10 = 10; /* ***************************************************************** */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:31:21 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Changed name of function from lpcenc_ to lpc10_encode, simply to make * all lpc10 functions have more consistent naming with each other. * * Revision 1.1 1996/08/19 22:31:44 jaf * Initial revision * */ /* Revision 1.2 1996/03/28 00:01:22 jaf */ /* Commented out some trace statements. */ /* Revision 1.1 1996/03/28 00:00:27 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Encode one frame of 180 speech samples to 54 bits. */ /* Input: */ /* SPEECH - Speech encoded as real values in the range [-1,+1]. */ /* Indices 1 through 180 read, and modified (by PREPRO). */ /* Output: */ /* BITS - 54 encoded bits, stored 1 per array element. */ /* Indices 1 through 54 written. */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITLPCENC. */ /* Subroutine */ int lpc10_encode(real *speech, integer *bits, struct lpc10_encoder_state *st) { integer irms, voice[2], pitch, ipitv; real rc[10]; extern /* Subroutine */ int encode_(integer *, integer *, real *, real *, integer *, integer *, integer *), chanwr_(integer *, integer *, integer *, integer *, integer *, struct lpc10_encoder_state *), analys_(real *, integer *, integer *, real *, real *, struct lpc10_encoder_state *), prepro_(real *, integer *, struct lpc10_encoder_state *); integer irc[10]; real rms; /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:31:21 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Changed name of function from lpcenc_ to lpc10_encode, simply to make * all lpc10 functions have more consistent naming with each other. * * Revision 1.1 1996/08/19 22:31:44 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Local variables that need not be saved */ /* Uncoded speech parameters */ /* Coded speech parameters */ /* Local state */ /* None */ /* Parameter adjustments */ if (speech) { --speech; } if (bits) { --bits; } /* Function Body */ prepro_(&speech[1], &c__180, st); analys_(&speech[1], voice, &pitch, &rms, rc, st); encode_(voice, &pitch, &rms, rc, &ipitv, &irms, irc); chanwr_(&c__10, &ipitv, &irms, irc, &bits[1], st); return 0; } /* lpcenc_ */ asterisk-11.7.0/codecs/lpc10/f2c.h0000644000175000007640000002353010374426007016355 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:26:28 jaf * Any typedef defining a type that was used in lpc10_encoder_state or * lpc10_decoder_state struct's was commented out here and added to * lpc10.h. * * Revision 1.1 1996/08/19 22:32:13 jaf * Initial revision * */ /* * f2c.h * * SCCS ID: @(#)f2c.h 1.2 96/05/19 */ /* f2c.h -- Standard Fortran to C header file */ /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ #ifndef F2C_INCLUDE #define F2C_INCLUDE #include "lpc10.h" /*typedef long int integer;*/ /*typedef INT32 integer;*/ /*typedef short int shortint;*/ /*typedef INT16 shortint;*/ /*typedef float real;*/ /* doublereal only used for function arguments to sqrt, exp, etc. */ typedef double doublereal; /* 32 bits seems wasteful, but there really aren't that many logical * variables around, and making them 32 bits could avoid word * alignment problems, perhaps. */ /*typedef long int logical;*/ /*typedef INT32 logical;*/ /* The following types are not used in the translated C code for the * LPC-10 coder, but they might be needed by the definitions down * below, so they don't cause compilation errors. */ typedef char *address; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; typedef short int shortlogical; typedef char logical1; typedef char integer1; /* typedef long long longint; */ /* system-dependent */ #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ #ifdef f2c_i2 /* for -i2 */ typedef short flag; typedef short ftnlen; typedef short ftnint; #else typedef long int flag; typedef long int ftnlen; typedef long int ftnint; #endif /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; /*typedef long int Long;*/ /* No longer used; formerly in Namelist */ struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (doublereal)abs(x) #define min(a,b) ((a) <= (b) ? (a) : (b)) #define max(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (doublereal)min(a,b) #define dmax(a,b) (doublereal)max(a,b) /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef int /* Unknown procedure type */ (*U_fp)(...); typedef shortint (*J_fp)(...); typedef integer (*I_fp)(...); typedef real (*R_fp)(...); typedef doublereal (*D_fp)(...), (*E_fp)(...); typedef /* Complex */ VOID (*C_fp)(...); typedef /* Double Complex */ VOID (*Z_fp)(...); typedef logical (*L_fp)(...); typedef shortlogical (*K_fp)(...); typedef /* Character */ VOID (*H_fp)(...); typedef /* Subroutine */ int (*S_fp)(...); #else typedef int /* Unknown procedure type */ (*U_fp)(VOID); typedef shortint (*J_fp)(VOID); typedef integer (*I_fp)(VOID); typedef real (*R_fp)(VOID); typedef doublereal (*D_fp)(VOID), (*E_fp)(VOID); typedef /* Complex */ VOID (*C_fp)(VOID); typedef /* Double Complex */ VOID (*Z_fp)(VOID); typedef logical (*L_fp)(VOID); typedef shortlogical (*K_fp)(VOID); typedef /* Character */ VOID (*H_fp)(VOID); typedef /* Subroutine */ int (*S_fp)(VOID); #endif /* E_fp is for real functions when -R is not specified */ typedef VOID C_f; /* complex function */ typedef VOID H_f; /* character function */ typedef VOID Z_f; /* double complex function */ typedef doublereal E_f; /* real function with -R not specified */ /* undef any lower-case symbols that your C compiler predefines, e.g.: */ #ifndef Skip_f2c_Undefs #undef cray #undef gcos #undef mc68010 #undef mc68020 #undef mips #undef pdp11 #undef sgi #undef sparc #undef sun #undef sun2 #undef sun3 #undef sun4 #undef u370 #undef u3b #undef u3b2 #undef u3b5 #undef unix #undef vax #endif #ifdef KR_headers extern integer pow_ii(ap, bp); extern double r_sign(a,b); extern integer i_nint(x); #else extern integer pow_ii(integer *ap, integer *bp); extern double r_sign(real *a, real *b); extern integer i_nint(real *x); #endif #ifdef P_R_O_T_O_T_Y_P_E_S extern int bsynz_(real *coef, integer *ip, integer *iv, real *sout, real *rms, real *ratio, real *g2pass, struct lpc10_decoder_state *st); extern int chanwr_(integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits, struct lpc10_encoder_state *st); extern int chanrd_(integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits); extern int chanwr_0_(int n__, integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits, struct lpc10_encoder_state *st); extern int dcbias_(integer *len, real *speech, real *sigout); extern int decode_(integer *ipitv, integer *irms, integer *irc, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_decoder_state *st); extern int deemp_(real *x, integer *n, struct lpc10_decoder_state *st); extern int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr); extern int dyptrk_(real *amdf, integer *ltau, integer * minptr, integer *voice, integer *pitch, integer *midx, struct lpc10_encoder_state *st); extern int encode_(integer *voice, integer *pitch, real *rms, real *rc, integer *ipitch, integer *irms, integer *irc); extern int energy_(integer *len, real *speech, real *rms); extern int ham84_(integer *input, integer *output, integer *errcnt); extern int hp100_(real *speech, integer *start, integer *end, struct lpc10_encoder_state *st); extern int inithp100_(void); extern int invert_(integer *order, real *phi, real *psi, real *rc); extern int irc2pc_(real *rc, real *pc, integer *order, real *gprime, real *g2pass); extern int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *nsamp, real *ivrc); extern int lpcdec_(integer *bits, real *speech); extern int initlpcdec_(void); extern int lpcenc_(real *speech, integer *bits); extern int initlpcenc_(void); extern int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer *nsamp); extern integer median_(integer *d1, integer *d2, integer *d3); extern int mload_(integer *order, integer *awins, integer *awinf, real *speech, real *phi, real *psi); extern int onset_(real *pebuf, integer *osbuf, integer *osptr, integer *oslen, integer *sbufl, integer *sbufh, integer *lframe, struct lpc10_encoder_state *st); extern int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio, struct lpc10_decoder_state *st); extern int placea_(integer *ipitch, integer *voibuf, integer *obound, integer *af, integer *vwin, integer *awin, integer *ewin, integer *lframe, integer *maxwin); extern int placev_(integer *osbuf, integer *osptr, integer *oslen, integer *obound, integer *vwin, integer *af, integer *lframe, integer *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh); extern int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z__); extern int prepro_(real *speech, integer *length, struct lpc10_encoder_state *st); extern int decode_(integer *ipitv, integer *irms, integer *irc, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_decoder_state *st); extern integer random_(struct lpc10_decoder_state *st); extern int rcchk_(integer *order, real *rc1f, real *rc2f); extern int synths_(integer *voice, integer *pitch, real *rms, real *rc, real *speech, integer *k, struct lpc10_decoder_state *st); extern int tbdm_(real *speech, integer *lpita, integer *tau, integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer *mintau); extern int voicin_(integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *minamd, real *maxamd, integer *mintau, real *ivrc, integer *obound, integer *voibuf, integer *af, struct lpc10_encoder_state *st); extern int vparms_(integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *dither, integer *mintau, integer *zc, integer *lbe, integer *fbe, real *qs, real *rc1, real *ar_b__, real *ar_f__); #endif #endif /* ! defined F2C_INCLUDE */ asterisk-11.7.0/codecs/lpc10/Makefile0000644000175000007640000000253011741571773017201 0ustar sharkyjerryweb# # Makefile for LPC-10 speech coder library (unix) # # default C compiler CC?= gcc # # These definitions for CFLAGS and LIB_TARGET_DIR are used when one # runs make in the lpc10 directory, without environment variables that # override them. When make is run in this directory from a makefile # for an application that uses the LPC10 coder, there are environment # variables set for CFLAGS and LIB_TARGET_DIR that override these # definitions. # LIB_TARGET_DIR = . # # -I$(LIB_TARGET_DIR) option needed so that #include "machine.h" # directives can find the machine.h file. # CFLAGS+= -fPIC -Wno-comment # The code here generates lots of warnings, so compiling with -Werror # fails miserably. Remove it for the time being. _ASTCFLAGS:=$(_ASTCFLAGS:-Werror=) LIB = $(LIB_TARGET_DIR)/liblpc10.a .PHONY: all clean include $(ASTTOPDIR)/Makefile.rules all: $(LIB) OBJ=f2clib.o analys.o bsynz.o chanwr.o dcbias.o decode.o \ deemp.o difmag.o dyptrk.o encode.o energy.o ham84.o \ hp100.o invert.o irc2pc.o ivfilt.o lpcdec.o lpcenc.o \ lpcini.o lpfilt.o median.o mload.o onset.o pitsyn.o \ placea.o placev.o preemp.o prepro.o random.o rcchk.o \ synths.o tbdm.o voicin.o vparms.o $(LIB): $(OBJ) $(ECHO_PREFIX) echo " [AR] $^ -> $@" $(CMD_PREFIX) $(AR) cr $@ $^ $(CMD_PREFIX) $(RANLIB) $@ clean: rm -f *.o $(LIB) .*.d rm -f *.s *.i asterisk-11.7.0/codecs/lpc10/irc2pc.c0000644000175000007640000000765110513757330017067 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:31:56 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int irc2pc_(real *rc, real *pc, integer *order, real *gprime, real *g2pass); #endif /* ***************************************************************** */ /* IRC2PC Version 48 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:56 jaf * Initial revision * */ /* Revision 1.3 1996/03/20 15:47:19 jaf */ /* Added comments about which indices of array arguments are read or */ /* written. */ /* Revision 1.2 1996/03/14 16:59:04 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:47:27 jaf */ /* Initial revision */ /* ***************************************************************** */ /* Convert Reflection Coefficients to Predictor Coeficients */ /* Inputs: */ /* RC - Reflection coefficients */ /* Indices 1 through ORDER read. */ /* ORDER - Number of RC's */ /* GPRIME - Excitation modification gain */ /* Outputs: */ /* PC - Predictor coefficients */ /* Indices 1 through ORDER written. */ /* Indices 1 through ORDER-1 are read after being written. */ /* G2PASS - Excitation modification sharpening factor */ /* This subroutine has no local state. */ /* Subroutine */ int irc2pc_(real *rc, real *pc, integer *order, real *gprime, real *g2pass) { /* System generated locals */ integer i__1, i__2; /* Builtin functions */ double sqrt(doublereal); /* Local variables */ real temp[10]; integer i__, j; /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:56 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:03:47 jaf */ /* Removed definitions for any constants that were no longer used. */ /* Revision 1.2 1996/03/26 19:34:33 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:43:51 jaf */ /* Initial revision */ /* LPC Configuration parameters: */ /* Frame size, Prediction order, Pitch period */ /* Local variables that need not be saved */ /* Parameter adjustments */ --pc; --rc; /* Function Body */ *g2pass = 1.f; i__1 = *order; for (i__ = 1; i__ <= i__1; ++i__) { *g2pass *= 1.f - rc[i__] * rc[i__]; } *g2pass = *gprime * (real)sqrt(*g2pass); pc[1] = rc[1]; i__1 = *order; for (i__ = 2; i__ <= i__1; ++i__) { i__2 = i__ - 1; for (j = 1; j <= i__2; ++j) { temp[j - 1] = pc[j] - rc[i__] * pc[i__ - j]; } i__2 = i__ - 1; for (j = 1; j <= i__2; ++j) { pc[j] = temp[j - 1]; } pc[i__] = rc[i__]; } return 0; } /* irc2pc_ */ asterisk-11.7.0/codecs/lpc10/deemp.c0000644000175000007640000001015510513757330016770 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:23:46 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:34 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int deemp_(real *x, integer *n, struct lpc10_decoder_state *st); #endif /* ***************************************************************** */ /* DEEMP Version 48 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:23:46 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_decoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_decoder_state(). * * Revision 1.1 1996/08/19 22:32:34 jaf * Initial revision * */ /* Revision 1.3 1996/03/20 15:54:37 jaf */ /* Added comments about which indices of array arguments are read or */ /* written. */ /* Added entry INITDEEMP to reinitialize the local state variables, if */ /* desired. */ /* Revision 1.2 1996/03/14 22:11:13 jaf */ /* Comments added explaining which of the local variables of this */ /* subroutine need to be saved from one invocation to the next, and which */ /* do not. */ /* Revision 1.1 1996/02/07 14:44:53 jaf */ /* Initial revision */ /* ***************************************************************** */ /* De-Emphasize output speech with 1 / ( 1 - .75z**-1 ) */ /* cascaded with 200 Hz high pass filter */ /* ( 1 - 1.9998z**-1 + z**-2 ) / ( 1 - 1.75z**-1 + .78z**-2 ) */ /* WARNING! The coefficients above may be out of date with the code */ /* below. Either that, or some kind of transformation was performed */ /* on the coefficients above to create the code below. */ /* Input: */ /* N - Number of samples */ /* Input/Output: */ /* X - Speech */ /* Indices 1 through N are read before being written. */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITDEEMP. */ /* Subroutine */ int deemp_(real *x, integer *n, struct lpc10_decoder_state *st) { /* Initialized data */ real *dei1; real *dei2; real *deo1; real *deo2; real *deo3; /* System generated locals */ integer i__1; real r__1; /* Local variables */ integer k; real dei0; /* Arguments */ /* Local variables that need not be saved */ /* Local state */ /* All of the locals saved below were not given explicit initial */ /* values in the original code. I think 0 is a safe choice. */ /* Parameter adjustments */ if (x) { --x; } /* Function Body */ dei1 = &(st->dei1); dei2 = &(st->dei2); deo1 = &(st->deo1); deo2 = &(st->deo2); deo3 = &(st->deo3); i__1 = *n; for (k = 1; k <= i__1; ++k) { dei0 = x[k]; r__1 = x[k] - *dei1 * 1.9998f + *dei2; x[k] = r__1 + *deo1 * 2.5f - *deo2 * 2.0925f + *deo3 * .585f; *dei2 = *dei1; *dei1 = dei0; *deo3 = *deo2; *deo2 = *deo1; *deo1 = x[k]; } return 0; } /* deemp_ */ asterisk-11.7.0/codecs/lpc10/lpc10.h0000644000175000007640000001632310442400260016611 0ustar sharkyjerryweb/* $Log$ Revision 1.18 2004/08/31 13:32:11 markster Merge NetBSD and Courtesty tone with modifications (bug #2329) Revision 1.17 2003/10/26 18:50:49 markster Make it build and run on MacOS X Revision 1.3 2003/10/26 18:50:49 markster Make it build and run on MacOS X Revision 1.2 2003/04/23 19:13:35 markster More OpenBSD patches Revision 1.1.1.2 2003/03/16 22:37:30 matteo dom mar 16 23:37:23 CET 2003 Revision 1.2 2003/03/16 16:09:48 markster Mere James's cleanups for fewer build warnings Revision 1.1 2000/01/05 00:20:06 markster Add broken lpc10 code... It's not too far from working I don't think... * Revision 1.1 1996/08/19 22:47:31 jaf * Initial revision * */ #ifndef __LPC10_H__ #define __LPC10_H__ #define P_R_O_T_O_T_Y_P_E_S #define LPC10_SAMPLES_PER_FRAME 180 #define LPC10_BITS_IN_COMPRESSED_FRAME 54 /* The "#if defined"'s in this file are by no means intended to be complete. They are what Nautilus uses, which has been successfully compiled under DOS with the Microsoft C compiler, and under a few versions of Unix with the GNU C compiler. */ #if defined(unix) || defined(__unix__) || defined(__NetBSD__) typedef short INT16; typedef int INT32; #endif #if defined(__MSDOS__) || defined(MSDOS) typedef int INT16; typedef long INT32; #endif #if defined(__APPLE__) typedef short INT16; typedef int INT32; #endif #if defined(WIN32) && defined(_MSC_VER) typedef __int16 INT16; typedef __int32 INT32; #pragma warning(disable: 4005) #endif /* The initial values for every member of this structure is 0, except where noted in comments. */ /* These two lines are copied from f2c.h. There should be a more elegant way of doing this than having the same declarations in two files. */ typedef float real; typedef INT32 integer; typedef INT32 logical; typedef INT16 shortint; struct lpc10_encoder_state { /* State used only by function hp100 */ real z11; real z21; real z12; real z22; /* State used by function analys */ real inbuf[540], pebuf[540]; real lpbuf[696], ivbuf[312]; real bias; integer osbuf[10]; /* no initial value necessary */ integer osptr; /* initial value 1 */ integer obound[3]; integer vwin[6] /* was [2][3] */; /* initial value vwin[4] = 307; vwin[5] = 462; */ integer awin[6] /* was [2][3] */; /* initial value awin[4] = 307; awin[5] = 462; */ integer voibuf[8] /* was [2][4] */; real rmsbuf[3]; real rcbuf[30] /* was [10][3] */; real zpre; /* State used by function onset */ real n; real d__; /* initial value 1.f */ real fpc; /* no initial value necessary */ real l2buf[16]; real l2sum1; integer l2ptr1; /* initial value 1 */ integer l2ptr2; /* initial value 9 */ integer lasti; /* no initial value necessary */ logical hyst; /* initial value FALSE_ */ /* State used by function voicin */ real dither; /* initial value 20.f */ real snr; real maxmin; real voice[6] /* was [2][3] */; /* initial value is probably unnecessary */ integer lbve, lbue, fbve, fbue; integer ofbue, sfbue; integer olbue, slbue; /* Initial values: lbve = 3000; fbve = 3000; fbue = 187; ofbue = 187; sfbue = 187; lbue = 93; olbue = 93; slbue = 93; snr = (real) (fbve / fbue << 6); */ /* State used by function dyptrk */ real s[60]; integer p[120] /* was [60][2] */; integer ipoint; real alphax; /* State used by function chanwr */ integer isync; }; struct lpc10_decoder_state { /* State used by function decode */ integer iptold; /* initial value 60 */ logical first; /* initial value TRUE_ */ integer ivp2h; integer iovoic; integer iavgp; /* initial value 60 */ integer erate; integer drc[30] /* was [3][10] */; integer dpit[3]; integer drms[3]; /* State used by function synths */ real buf[360]; integer buflen; /* initial value 180 */ /* State used by function pitsyn */ integer ivoico; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ integer ipito; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ real rmso; /* initial value 1.f */ real rco[10]; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ integer jsamp; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ logical first_pitsyn; /* initial value TRUE_ */ /* State used by function bsynz */ integer ipo; real exc[166]; real exc2[166]; real lpi1; real lpi2; real lpi3; real hpi1; real hpi2; real hpi3; real rmso_bsynz; /* State used by function random */ integer j; /* initial value 2 */ integer k; /* initial value 5 */ shortint y[5]; /* initial value { -21161,-8478,30892,-10216,16950 } */ /* State used by function deemp */ real dei1; real dei2; real deo1; real deo2; real deo3; }; /* Calling sequence: Call create_lpc10_encoder_state(), which returns a pointer to an already initialized lpc10_encoder_state structure. lpc10_encode reads indices 0 through (LPC10_SAMPLES_PER_FRAME-1) of array speech[], and writes indices 0 through (LPC10_BITS_IN_COMPRESSED_FRAME-1) of array bits[], and both reads and writes the lpc10_encoder_state structure contents. The lpc10_encoder_state structure should *not* be initialized for every frame of encoded speech. Once at the beginning of execution, done automatically for you by create_lpc10_encoder_state(), is enough. init_lpc10_encoder_state() reinitializes the lpc10_encoder_state structure. This might be useful if you are finished processing one sound sample, and want to reuse the same lpc10_encoder_state structure to process another sound sample. There might be other uses as well. Note that the comments in the lpc10/lpcenc.c file imply that indices 1 through 180 of array speech[] are read. These comments were written for the Fortran version of the code, before it was automatically converted to C by the conversion program f2c. f2c seems to use the convention that the pointers to arrays passed as function arguments point to the first index used in the Fortran code, whatever index that might be (usually 1), and then it modifies the pointer inside of the function, like so: if (speech) { --speech; } So that the code can access the first value at index 1 and the last at index 180. This makes the translated C code "closer" to the original Fortran code. The calling sequence for the decoder is similar to the encoder. The only significant difference is that the array bits[] is read (indices 0 through (LPC10_BITS_IN_COMPRESSED_FRAME-1)), and the array speech[] is written (indices 0 through (LPC10_SAMPLES_PER_FRAME-1)). */ struct lpc10_encoder_state * create_lpc10_encoder_state (void); void init_lpc10_encoder_state (struct lpc10_encoder_state *st); int lpc10_encode (real *speech, INT32 *bits, struct lpc10_encoder_state *st); struct lpc10_decoder_state * create_lpc10_decoder_state (void); void init_lpc10_decoder_state (struct lpc10_decoder_state *st); int lpc10_decode (INT32 *bits, real *speech, struct lpc10_decoder_state *st); #endif /* __LPC10_H__ */ asterisk-11.7.0/codecs/lpc10/f2clib.c0000644000175000007640000000224210374426007017034 0ustar sharkyjerryweb/* $Log$ Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:32:10 jaf * Initial revision * */ /* * f2clib.c * * SCCS ID: @(#)f2clib.c 1.2 96/05/19 */ #include "f2c.h" #ifdef KR_headers integer pow_ii(ap, bp) integer *ap, *bp; #else integer pow_ii(integer *ap, integer *bp) #endif { integer pow, x, n; unsigned long u; x = *ap; n = *bp; if (n <= 0) { if (n == 0 || x == 1) return 1; if (x != -1) return x == 0 ? 0 : 1/x; n = -n; } u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } return(pow); } #ifdef KR_headers double r_sign(a,b) real *a, *b; #else double r_sign(real *a, real *b) #endif { double x; x = (*a >= 0 ? *a : - *a); return( *b >= 0 ? x : -x); } #ifdef KR_headers double floor(); integer i_nint(x) real *x; #else #undef abs #include "math.h" integer i_nint(real *x) #endif { return( (integer)((*x)>=0 ? floor(*x + .5) : -floor(.5 - *x)) ); } asterisk-11.7.0/codecs/lpc10/README0000644000175000007640000000777210374426007016424 0ustar sharkyjerrywebTue Aug 20 16:19:51 CDT 1996 Andy Fingerhut (jaf@arl.wustl.edu) In release 1.4, there are quite a few hand modifications to the C code that was automatically created from the Fortran code with f2c. They are all summarized in change log comments at the beginning of the changed files. All of the original files from f2c were checked in to RCS before modification, so it is possible to see exactly what changes were made, for the extremely curious. That precaution was also for my benefit, in case I ever recompile the Fortran sources, and want to make similar changes to that new C source code. Below is the README file for this directory included with the 1.3 release of the LPC-10 package. A few parts of it are a little out of date, but it is correct for the most part. Sun Jul 7 15:30:31 CDT 1996 Andy Fingerhut (jaf@arl.wustl.edu) To create the LPC-10 library, copy the appropriate makefile to the proper name for easy use, e.g., for Unix, copy makefile.unx to the file "Makefile". The file makefile.dos has been used with some version of the 'nmake' utility that comes with the Microsoft C compiler (the same one used for Nautilus v1.5a, which I believe specifies Microsoft C version 7.0 or later). Then edit the file lpc10.h in the directory above. It should already be set up to work properly on any Unix compiler for which "int" is 32 bits and "short" is 16 bits, and under the Microsoft C compiler configured so that "long" is 32 bits and "int" is 16 bits. There must be a typedef for the two types INT32 and INT16 in that file. You should choose types that compile to those sizes using your compiler, because there are places in the LPC-10 code that expect INT16's to have exactly 16 bits (at least, I *think* they must be no larger), and INT32's to have exactly 32 bits. A few notes on how these files were created ------------------------------------------- (This section is mostly for my benefit, so I can remember what I did. You don't need to read it if you just want to use this package. It might be useful to read it if you change the Fortran sources and want to recreate a usable library of C sources. -- Andy) These C sources were created automatically from the Fortran sources using f2c, for the most part. Listed below are the extra modifications that were made after this automatic conversion. Many of them were made so that it was not necessary to install f2c in order to use this LPC-10 coder. 1. Put all of those files that were necessary for only the coder, rather than an application that uses the coder, into this subdirectory called lpc10. 2. Copied f2c.h from the f2c distribution into this subdirectory. Some modifications were made to the "typedef" statements in this file, to explicitly indicate the sizes (in bits) that different integer types should be. The types INT32 and INT16 must be defined in a file called lpc10.h in the directory above. Created the file f2clib.c, containing only the functions pow_ii(), r_sign(), and i_nint() from the f2c library. 3. The f2c output originally had a file called contrl_com.c, that defined a small structure containing a few variables that were used in many different functions of the LPC10 code. Every file containing functions that used it defined it as "extern", while contrl_com.c actually allocated storage for the structure. Bill Dorsey, one of the lead developers of Nautilus, said that the Microsoft C compiler had problems either compiling this file, or linking it with all of the other compiled files, so he just eliminated that file and removed the "extern" keyword from the one of the files that declared it that way. The file chosen (arbitrarily) was analys.c. 4. Copied the makefiles for Unix and Microsoft C from the Nautilus v1.5a distribution into the lpc10 directory. Modified them to take out references to Nautilus. These makefiles don't create an executable, but a library of compiled functions called liblpc10.a (Unix) or LPC10.LIB (DOS). This library can be used when linking an executable that calls the functions lpcini_(), lpcenc_(), and lpcdec_(). asterisk-11.7.0/codecs/lpc10/dcbias.c0000644000175000007640000000514410513757330017125 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:14 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:40:23 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int dcbias_(integer *len, real *speech, real *sigout); #endif /* ********************************************************************* */ /* DCBIAS Version 50 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:14 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:40:23 jaf * Initial revision * */ /* Revision 1.3 1996/03/18 21:19:22 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 16:44:53 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:44:21 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Calculate and remove DC bias from buffer. */ /* Input: */ /* LEN - Length of speech buffers */ /* SPEECH - Input speech buffer */ /* Indices 1 through LEN read. */ /* Output: */ /* SIGOUT - Output speech buffer */ /* Indices 1 through LEN written */ /* This subroutine has no local state. */ /* Subroutine */ int dcbias_(integer *len, real *speech, real *sigout) { /* System generated locals */ integer i__1; /* Local variables */ real bias; integer i__; /* Arguments */ /* Local variables that need not be saved */ /* Parameter adjustments */ --sigout; --speech; /* Function Body */ bias = 0.f; i__1 = *len; for (i__ = 1; i__ <= i__1; ++i__) { bias += speech[i__]; } bias /= *len; i__1 = *len; for (i__ = 1; i__ <= i__1; ++i__) { sigout[i__] = speech[i__] - bias; } return 0; } /* dcbias_ */ asterisk-11.7.0/codecs/lpc10/placea.c0000644000175000007640000002125110513757330017122 0ustar sharkyjerryweb/* $Log$ Revision 1.16 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.15 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.2 2003/09/19 01:20:22 markster Code cleanups (bug #66) Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.3 2001/04/12 21:27:53 markh app_record now supports wildcards of sort so your output file is not overwritten every time it's run. File.h got a documentation update on the ast_fileexists to include the return call. Watch out for the placea.c placev.c code, it's updates have not been tested yet. Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set. Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.1 1996/08/19 22:31:07 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int placea_(integer *ipitch, integer *voibuf, integer *obound, integer *af, integer *vwin, integer *awin, integer *ewin, integer *lframe, integer *maxwin); #endif /* *********************************************************************** */ /* PLACEA Version 48 */ /* $Log$ * Revision 1.16 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.15 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.2 2003/09/19 01:20:22 markster * Code cleanups (bug #66) * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.3 2001/04/12 21:27:53 markh * app_record now supports wildcards of sort so your output file is not overwritten every time it's run. File.h got a documentation update on the ast_fileexists to include the return call. Watch out for the placea.c placev.c code, it's updates have not been tested yet. Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set. * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.1 1996/08/19 22:31:07 jaf * Initial revision * */ /* Revision 1.5 1996/03/19 20:41:55 jaf */ /* Added some conditions satisfied by the output values in EWIN. */ /* Revision 1.4 1996/03/19 20:24:17 jaf */ /* Added some conditions satisfied by the output values in AWIN. */ /* Revision 1.3 1996/03/18 21:40:04 jaf */ /* Just added a few comments about which array indices of the arguments */ /* are used, and mentioning that this subroutine has no local state. */ /* Revision 1.2 1996/03/13 16:43:09 jaf */ /* Comments added explaining that none of the local variables of this */ /* subroutine need to be saved from one invocation to the next. */ /* Revision 1.1 1996/02/07 14:48:31 jaf */ /* Initial revision */ /* *********************************************************************** */ /* Input: */ /* IPITCH */ /* VOIBUF */ /* Indices (2,AF-2), (1,AF-1), (2,AF-1), (1,AF), and (2,AF) read.*/ /* All other indices untouched. */ /* OBOUND */ /* AF */ /* VWIN */ /* Indices (1,AF) and (2,AF) read. */ /* All other indices untouched. */ /* LFRAME */ /* MAXWIN */ /* Input/Output: */ /* AWIN */ /* Index (1,AF-1) read. */ /* Indices (1,AF) and (2,AF) written, and then read. */ /* All other indices untouched. */ /* In all cases (except possibly one), the final values will */ /* satisfy the condition: AWIN(2,AF)-AWIN(1,AF)+1 = MAXWIN. */ /* In that other case, */ /* AWIN(1,AF)=VWIN(1,AF) and AWIN(2,AF)=VWIN(2,AF). */ /* Output: */ /* EWIN */ /* Indices (1,AF) and (2,AF) written. */ /* All other indices untouched. */ /* In all cases, the final values will satisfy the condition: */ /* AWIN(1,AF) .LE. EWIN(1,AF) .LE. EWIN(2,AF) .LE. AWIN(2,AF) */ /* In other words, the energy window is a sub-window of */ /* the analysis window. */ /* This subroutine has no local state. */ /* Subroutine */ int placea_(integer *ipitch, integer *voibuf, integer * obound, integer *af, integer *vwin, integer *awin, integer *ewin, integer *lframe, integer *maxwin) { /* System generated locals */ real r__1; /* Builtin functions */ integer i_nint(real *); /* Local variables */ logical allv, winv; integer i__, j, k, l, hrange; logical ephase; integer lrange; /* Arguments */ /* Local variables that need not be saved */ /* Parameter adjustments */ ewin -= 3; awin -= 3; vwin -= 3; --voibuf; /* Function Body */ lrange = (*af - 2) * *lframe + 1; hrange = *af * *lframe; /* Place the Analysis window based on the voicing window */ /* placement, onsets, tentative voicing decision, and pitch. */ /* Case 1: Sustained Voiced Speech */ /* If the five most recent voicing decisions are */ /* voiced, then the window is placed phase-synchronously with the */ /* previous window, as close to the present voicing window if possible. */ /* If onsets bound the voicing window, then preference is given to */ /* a phase-synchronous placement which does not overlap these onsets. */ /* Case 2: Voiced Transition */ /* If at least one voicing decision in AF is voicied, and there are no */ /* onsets, then the window is placed as in case 1. */ /* Case 3: Unvoiced Speech or Onsets */ /* If both voicing decisions in AF are unvoiced, or there are onsets, */ /* then the window is placed coincident with the voicing window. */ /* Note: During phase-synchronous placement of windows, the length */ /* is not altered from MAXWIN, since this would defeat the purpose */ /* of phase-synchronous placement. */ /* Check for case 1 and case 2 */ allv = voibuf[((*af - 2) << 1) + 2] == 1; allv = allv && voibuf[((*af - 1) << 1) + 1] == 1; allv = allv && voibuf[((*af - 1) << 1) + 2] == 1; allv = allv && voibuf[(*af << 1) + 1] == 1; allv = allv && voibuf[(*af << 1) + 2] == 1; winv = voibuf[(*af << 1) + 1] == 1 || voibuf[(*af << 1) + 2] == 1; if (allv || (winv && *obound == 0)) { /* APHASE: Phase synchronous window placement. */ /* Get minimum lower index of the window. */ i__ = (lrange + *ipitch - 1 - awin[((*af - 1) << 1) + 1]) / *ipitch; i__ *= *ipitch; i__ += awin[((*af - 1) << 1) + 1]; /* L = the actual length of this frame's analysis window. */ l = *maxwin; /* Calculate the location where a perfectly centered window would star t. */ k = (vwin[(*af << 1) + 1] + vwin[(*af << 1) + 2] + 1 - l) / 2; /* Choose the actual location to be the pitch multiple closest to this . */ r__1 = (real) (k - i__) / *ipitch; awin[(*af << 1) + 1] = i__ + i_nint(&r__1) * *ipitch; awin[(*af << 1) + 2] = awin[(*af << 1) + 1] + l - 1; /* If there is an onset bounding the right of the voicing window and t he */ /* analysis window overlaps that, then move the analysis window backwa rd */ /* to avoid this onset. */ if (*obound >= 2 && awin[(*af << 1) + 2] > vwin[(*af << 1) + 2]) { awin[(*af << 1) + 1] -= *ipitch; awin[(*af << 1) + 2] -= *ipitch; } /* Similarly for the left of the voicing window. */ if ((*obound == 1 || *obound == 3) && awin[(*af << 1) + 1] < vwin[(* af << 1) + 1]) { awin[(*af << 1) + 1] += *ipitch; awin[(*af << 1) + 2] += *ipitch; } /* If this placement puts the analysis window above HRANGE, then */ /* move it backward an integer number of pitch periods. */ while(awin[(*af << 1) + 2] > hrange) { awin[(*af << 1) + 1] -= *ipitch; awin[(*af << 1) + 2] -= *ipitch; } /* Similarly if the placement puts the analysis window below LRANGE. */ while(awin[(*af << 1) + 1] < lrange) { awin[(*af << 1) + 1] += *ipitch; awin[(*af << 1) + 2] += *ipitch; } /* Make Energy window be phase-synchronous. */ ephase = TRUE_; /* Case 3 */ } else { awin[(*af << 1) + 1] = vwin[(*af << 1) + 1]; awin[(*af << 1) + 2] = vwin[(*af << 1) + 2]; ephase = FALSE_; } /* RMS is computed over an integer number of pitch periods in the analysis */ /*window. When it is not placed phase-synchronously, it is placed as clos e*/ /* as possible to onsets. */ j = (awin[(*af << 1) + 2] - awin[(*af << 1) + 1] + 1) / *ipitch * *ipitch; if (j == 0 || ! winv) { ewin[(*af << 1) + 1] = vwin[(*af << 1) + 1]; ewin[(*af << 1) + 2] = vwin[(*af << 1) + 2]; } else if (! ephase && *obound == 2) { ewin[(*af << 1) + 1] = awin[(*af << 1) + 2] - j + 1; ewin[(*af << 1) + 2] = awin[(*af << 1) + 2]; } else { ewin[(*af << 1) + 1] = awin[(*af << 1) + 1]; ewin[(*af << 1) + 2] = awin[(*af << 1) + 1] + j - 1; } return 0; } /* placea_ */ asterisk-11.7.0/codecs/lpc10/dyptrk.c0000644000175000007640000003200411560064554017212 0ustar sharkyjerryweb/* $Log$ Revision 1.15 2004/06/26 03:50:14 markster Merge source cleanups (bug #1911) Revision 1.14 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.1.1.1 2003/02/12 13:59:15 matteo mer feb 12 14:56:57 CET 2003 Revision 1.2 2000/01/05 08:20:39 markster Some OSS fixes and a few lpc changes to make it actually work * Revision 1.2 1996/08/20 20:25:29 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:32:26 jaf * Initial revision * */ /* -- translated by f2c (version 19951025). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ #include "f2c.h" #ifdef P_R_O_T_O_T_Y_P_E_S extern int dyptrk_(real *amdf, integer *ltau, integer *minptr, integer *voice, integer *pitch, integer *midx, struct lpc10_encoder_state *st); /* comlen contrl_ 12 */ #endif /* Common Block Declarations */ extern struct { integer order, lframe; logical corrp; } contrl_; #define contrl_1 contrl_ /* ********************************************************************* */ /* DYPTRK Version 52 */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:25:29 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:32:26 jaf * Initial revision * */ /* Revision 1.5 1996/03/26 19:35:35 jaf */ /* Commented out trace statements. */ /* Revision 1.4 1996/03/19 18:03:22 jaf */ /* Replaced the initialization "DATA P/60*DEPTH*0/" with "DATA P/120*0/", */ /* because apparently Fortran (or at least f2c) can't handle expressions */ /* like that. */ /* Revision 1.3 1996/03/19 17:38:32 jaf */ /* Added comments about the local variables that should be saved from one */ /* invocation to the next. None of them were given initial values in the */ /* original code, but from my testing, it appears that initializing them */ /* all to 0 works. */ /* Added entry INITDYPTRK to reinitialize these local variables. */ /* Revision 1.2 1996/03/13 16:32:17 jaf */ /* Comments added explaining which of the local variables of this */ /* subroutine need to be saved from one invocation to the next, and which */ /* do not. */ /* WARNING! Some of them that should are never given initial values in */ /* this code. Hopefully, Fortran 77 defines initial values for them, but */ /* even so, giving them explicit initial values is preferable. */ /* Revision 1.1 1996/02/07 14:45:14 jaf */ /* Initial revision */ /* ********************************************************************* */ /* Dynamic Pitch Tracker */ /* Input: */ /* AMDF - Average Magnitude Difference Function array */ /* Indices 1 through LTAU read, and MINPTR */ /* LTAU - Number of lags in AMDF */ /* MINPTR - Location of minimum AMDF value */ /* VOICE - Voicing decision */ /* Output: */ /* PITCH - Smoothed pitch value, 2 frames delayed */ /* MIDX - Initial estimate of current frame pitch */ /* Compile time constant: */ /* DEPTH - Number of frames to trace back */ /* This subroutine maintains local state from one call to the next. If */ /* you want to switch to using a new audio stream for this filter, or */ /* reinitialize its state for any other reason, call the ENTRY */ /* INITDYPTRK. */ /* Subroutine */ int dyptrk_(real *amdf, integer *ltau, integer * minptr, integer *voice, integer *pitch, integer *midx, struct lpc10_encoder_state *st) { /* Initialized data */ real *s; integer *p; integer *ipoint; real *alphax; /* System generated locals */ integer i__1; /* Local variables */ integer pbar; real sbar; integer iptr, i__, j; real alpha, minsc, maxsc; /* Arguments */ /* $Log$ * Revision 1.15 2004/06/26 03:50:14 markster * Merge source cleanups (bug #1911) * * Revision 1.14 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.1.1.1 2003/02/12 13:59:15 matteo * mer feb 12 14:56:57 CET 2003 * * Revision 1.2 2000/01/05 08:20:39 markster * Some OSS fixes and a few lpc changes to make it actually work * * Revision 1.2 1996/08/20 20:25:29 jaf * Removed all static local variables that were SAVE'd in the Fortran * code, and put them in struct lpc10_encoder_state that is passed as an * argument. * * Removed init function, since all initialization is now done in * init_lpc10_encoder_state(). * * Revision 1.1 1996/08/19 22:32:26 jaf * Initial revision * */ /* Revision 1.3 1996/03/29 22:05:55 jaf */ /* Commented out the common block variables that are not needed by the */ /* embedded version. */ /* Revision 1.2 1996/03/26 19:34:50 jaf */ /* Added comments indicating which constants are not needed in an */ /* application that uses the LPC-10 coder. */ /* Revision 1.1 1996/02/07 14:44:09 jaf */ /* Initial revision */ /* LPC Processing control variables: */ /* *** Read-only: initialized in setup */ /* Files for Speech, Parameter, and Bitstream Input & Output, */ /* and message and debug outputs. */ /* Here are the only files which use these variables: */ /* lpcsim.f setup.f trans.f error.f vqsetup.f */ /* Many files which use fdebug are not listed, since it is only used in */ /* those other files conditionally, to print trace statements. */ /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* LPC order, Frame size, Quantization rate, Bits per frame, */ /* Error correction */ /* Subroutine SETUP is the only place where order is assigned a value, */ /* and that value is 10. It could increase efficiency 1% or so to */ /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as */ /* a variable in a COMMON block, since it is used in many places in the */ /* core of the coding and decoding routines. Actually, I take that back. */ /* At least when compiling with f2c, the upper bound of DO loops is */ /* stored in a local variable before the DO loop begins, and then that is */ /* compared against on each iteration. */ /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ /* Similarly for quant, which is given a value of 2400 in SETUP. quant */ /* is used in only a few places, and never in the core coding and */ /* decoding routines, so it could be eliminated entirely. */ /* nbits is similar to quant, and is given a value of 54 in SETUP. */ /* corrp is given a value of .TRUE. in SETUP, and is only used in the */ /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ /* coder significantly whether it is .TRUE. or .FALSE., or whether it is */ /* a constant or a variable, since it is only examined once per frame. */ /* Leaving it as a variable that is set to .TRUE. seems like a good */ /* idea, since it does enable some error-correction capability for */ /* unvoiced frames, with no change in the coding rate, and no noticeable */ /* quality difference in the decoded speech. */ /* integer quant, nbits */ /* *** Read/write: variables for debugging, not needed for LPC algorithm */ /* Current frame, Unstable frames, Output clip count, Max onset buffer, */ /* Debug listing detail level, Line count on listing page */ /* nframe is not needed for an embedded LPC10 at all. */ /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ /* an application, I would recommend removing the call to ERROR in RCCHK, */ /* and remove ERROR and nunsfm completely. */ /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in */ /* sread.f. When LPC10 is embedded into an application, one might want */ /* to cause it to be incremented in a routine that takes the output of */ /* SYNTHS and sends it to an audio device. It could be optionally */ /* displayed, for those that might want to know what it is. */ /* maxosp is never initialized to 0 in SETUP, although it probably should */ /* be, and it is updated in subroutine ANALYS. I doubt that its value */ /* would be of much interest to an application in which LPC10 is */ /* embedded. */ /* listl and lincnt are not needed for an embedded LPC10 at all. */ /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ /* common /contrl/ quant, nbits */ /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ /* Parameters/constants */ /* Local variables that need not be saved */ /* Note that PATH is only used for debugging purposes, and can be */ /* removed. */ /* Local state */ /* It would be a bit more "general" to define S(LTAU), if Fortran */ /* allows the argument of a function to be used as the dimension of */ /* a local array variable. */ /* IPOINT is always in the range 0 to DEPTH-1. */ /* WARNING! */ /* In the original version of this subroutine, IPOINT, ALPHAX, */ /* every element of S, and potentially any element of P with the */ /* second index value .NE. IPTR were read without being given */ /* initial values (all indices of P with second index equal to */ /* IPTR are all written before being read in this subroutine). */ /* From examining the code carefully, it appears that all of these */ /* should be saved from one invocation to the next. */ /* I've run lpcsim with the "-l 6" option to see all of the */ /* debugging information that is printed out by this subroutine */ /* below, and it appears that S, P, IPOINT, and ALPHAX are all */ /* initialized to 0 (these initial values would likely be different */ /* on different platforms, compilers, etc.). Given that the output */ /* of the coder sounds reasonable, I'm going to initialize these */ /* variables to 0 explicitly. */ s = &(st->s[0]); p = &(st->p[0]); ipoint = &(st->ipoint); alphax = &(st->alphax); /* Parameter adjustments */ if (amdf) { --amdf; } /* Function Body */ /* Calculate the confidence factor ALPHA, used as a threshold slope in */ /* SEESAW. If unvoiced, set high slope so that every point in P array */ /* is marked as a potential pitch frequency. A scaled up version (ALPHAX )*/ /* is used to maintain arithmetic precision. */ if (*voice == 1) { *alphax = *alphax * .75f + amdf[*minptr] / 2.f; } else { *alphax *= .984375f; } alpha = *alphax / 16; if (*voice == 0 && *alphax < 128.f) { alpha = 8.f; } /* SEESAW: Construct a pitch pointer array and intermediate winner functio n*/ /* Left to right pass: */ iptr = *ipoint + 1; p[iptr * 60 - 60] = 1; i__ = 1; pbar = 1; sbar = s[0]; i__1 = *ltau; for (i__ = 1; i__ <= i__1; ++i__) { sbar += alpha; if (sbar < s[i__ - 1]) { s[i__ - 1] = sbar; p[i__ + iptr * 60 - 61] = pbar; } else { sbar = s[i__ - 1]; p[i__ + iptr * 60 - 61] = i__; pbar = i__; } } /* Right to left pass: */ i__ = pbar - 1; sbar = s[i__]; while(i__ >= 1) { sbar += alpha; if (sbar < s[i__ - 1]) { s[i__ - 1] = sbar; p[i__ + iptr * 60 - 61] = pbar; } else { pbar = p[i__ + iptr * 60 - 61]; i__ = pbar; sbar = s[i__ - 1]; } --i__; } /* Update S using AMDF */ /* Find maximum, minimum, and location of minimum */ s[0] += amdf[1] / 2; minsc = s[0]; maxsc = minsc; *midx = 1; i__1 = *ltau; for (i__ = 2; i__ <= i__1; ++i__) { s[i__ - 1] += amdf[i__] / 2; if (s[i__ - 1] > maxsc) { maxsc = s[i__ - 1]; } if (s[i__ - 1] < minsc) { *midx = i__; minsc = s[i__ - 1]; } } /* Subtract MINSC from S to prevent overflow */ i__1 = *ltau; for (i__ = 1; i__ <= i__1; ++i__) { s[i__ - 1] -= minsc; } maxsc -= minsc; /* Use higher octave pitch if significant null there */ j = 0; for (i__ = 20; i__ <= 40; i__ += 10) { if (*midx > i__) { if (s[*midx - i__ - 1] < maxsc / 4) { j = i__; } } } *midx -= j; /* TRACE: look back two frames to find minimum cost pitch estimate */ j = *ipoint; *pitch = *midx; for (i__ = 1; i__ <= 2; ++i__) { j = j % 2 + 1; *pitch = p[*pitch + j * 60 - 61]; } /* The following statement subtracts one from IPOINT, mod DEPTH. I */ /* think the author chose to add DEPTH-1, instead of subtracting 1, */ /* because then it will work even if MOD doesn't work as desired on */ /* negative arguments. */ *ipoint = (*ipoint + 1) % 2; return 0; } /* dyptrk_ */ asterisk-11.7.0/LICENSE0000644000175000007640000000565011333070336014357 0ustar sharkyjerrywebAsterisk is distributed under the GNU General Public License version 2 and is also available under alternative licenses negotiated directly with Digium, Inc. If you obtained Asterisk under the GPL, then the GPL applies to all loadable Asterisk modules used on your system as well, except as defined below. The GPL (version 2) is included in this source tree in the file COPYING. This package also includes various components that are not part of Asterisk itself; these components are in the 'contrib' directory and its subdirectories. These components are also distributed under the GPL version 2 as well. Digium, Inc. (formerly Linux Support Services) holds copyright and/or sufficient licenses to all components of the Asterisk package, and therefore can grant, at its sole discretion, the ability for companies, individuals, or organizations to create proprietary or Open Source (even if not GPL) modules which may be dynamically linked at runtime with the portions of Asterisk which fall under our copyright/license umbrella, or are distributed under more flexible licenses than GPL. If you wish to use our code in other GPL programs, don't worry -- there is no requirement that you provide the same exception in your GPL'd products (although if you've written a module for Asterisk we would strongly encourage you to make the same exception that we do). Specific permission is also granted to link Asterisk with OpenSSL, OpenH323 and/or the UW IMAP Toolkit and distribute the resulting binary files. In addition, Asterisk implements two management/control protocols: the Asterisk Manager Interface (AMI) and the Asterisk Gateway Interface (AGI). It is our belief that applications using these protocols to manage or control an Asterisk instance do not have to be licensed under the GPL or a compatible license, as we believe these protocols do not create a 'derivative work' as referred to in the GPL. However, should any court or other judiciary body find that these protocols do fall under the terms of the GPL, then we hereby grant you a license to use these protocols in combination with Asterisk in external applications licensed under any license you wish. The 'Asterisk' name and logos are trademarks owned by Digium, Inc., and use of them is subject to our trademark licensing policies. If you wish to use these trademarks for purposes other than simple redistribution of Asterisk source code obtained from Digium, you should contact our licensing department to determine the necessary steps you must take. For more information on this policy, please read: http://www.digium.com/en/company/profile/trademarkpolicy.php If you have any questions regarding our licensing policy, please contact us: +1.877.344.4861 (via telephone in the USA) +1.256.428.6000 (via telephone outside the USA) +1.256.864.0464 (via FAX inside or outside the USA) IAX2/pbx.digium.com (via IAX2) licensing@digium.com (via email) Digium, Inc. 445 Jan Davis Drive Huntsville, AL 35806 USA asterisk-11.7.0/sample.call0000644000175000007640000000524111503716745015476 0ustar sharkyjerryweb# # This is a sample file that can be dumped in /var/spool/asterisk/outgoing # to generate a call. For Asterisk to read call files, you must have the # pbx_spool.so module loaded. # # Comments are indicated by a '#' character that begins a line, or follows # a space or tab character. To be consistent with the configuration files # in Asterisk, comments can also be indicated by a semicolon. However, the # multiline comments (;-- --;) used in Asterisk configuration files are not # supported. Semicolons can be escaped by a backslash. # # Obviously, you MUST specify at least a channel in the same format as you # would for the "Dial" application. Only one channel name is permitted. # Channel: DAHDI/1 # # You can specify codecs for the call Codecs: alaw, speex, h264 # # You may also specify a wait time (default is 45 seconds) for how long to # wait for the channel to be answered, a retry time (default is 5 mins) # for how soon to retry this call, and a maximum number of retries (default # is 0) for how many times to retry this call. # MaxRetries: 2 RetryTime: 60 WaitTime: 30 # # Once the call is answered, you must provide either an application/data # combination, or a context/extension/priority in which to start the PBX. # Context: default Extension: s Priority: 1 # # Alternatively you can specify just an application # and its arguments to be run, instead of a context # extension and priority # #Application: VoiceMailMain #Data: 1234 # # You can set the callerid that will be used for the outgoing call # #Callerid: Wakeup Call Service <(555) 555-5555> # # An account code can be specified the following way: # #Account: mysuperfunaccountcode # # Normally, a call file is always deleted after the call is successful # or the maximum number of tries is reached even if the modification # time of the call file was changed during the call to be in the # future. By Setting AlwaysDelete to No the modification time of the # call file will be checked after the call is completed or the maximum # number of retries is reached. If the modification time is in the # future, the call file will not be deleted. # #AlwaysDelete: Yes # # You can set channel variables that will be passed to the channel. # This includes writable dialplan functions. To set a writable dialplan # function, the module containing this function *must* be loaded. # #Set: file1=/tmp/to #Set: file2=/tmp/msg #Set: timestamp=20021023104500 #Set: CDR(userfield,r)=42 # # Setting Archive to yes the call file is never deleted, but is moved # in the subdir "outgoing_done" of the spool directory. In this case # will be appended a line with "Status: value", where value can be # Completed, Expired or Failed. # #Archive: yes asterisk-11.7.0/configure.ac0000644000175000007640000023460212225103357015642 0ustar sharkyjerryweb# Process this file with autoconf to produce a configure script. # # Make sure we use autoconf 2.60 to generate the "configure" script, # in case we want to commit it. Other than that, version 2.59 is # perfectly fine for our purposes, so people who want to modify # this file just have to remember to set the AC_PREREQ argument # to something that suits their needs. AC_PREREQ(2.60) AC_INIT([asterisk], [trunk], [https://issues.asterisk.org]) # cross-compile macros AC_CANONICAL_BUILD AC_CANONICAL_HOST # check existence of the package AC_CONFIG_SRCDIR([main/asterisk.c]) AC_CONFIG_AUX_DIR(`pwd`) AC_COPYRIGHT("Asterisk") AC_REVISION($Revision: 400768 $) # preserve any CFLAGS or LDFLAGS that may be set # NOTE: This must be done before calling any macros that end up # calling AC_PROG_CC or the like, since they will set a default # set of CFLAGS ("-g -O2") if the user did not supply any, and # we don't want those default flags to be carried over into the # rest of the build system since we have other means of controlling # debugging symbol generation and optimization. CONFIG_CFLAGS="${CFLAGS}" CONFIG_LDFLAGS="${LDFLAGS}" AC_SUBST(CONFIG_CFLAGS) AC_SUBST(CONFIG_LDFLAGS) # specify output header file AC_CONFIG_HEADER(include/asterisk/autoconfig.h) # Note: AC_PROG_CC *must* be specified before AC_USE_SYSTEM_EXTENSIONS or any # other macro that uses the C compiler, or the default order will be used. AC_PROG_CC([gcc cc]) AC_USE_SYSTEM_EXTENSIONS dnl note- does not work on FreeBSD # System default paths AC_SUBST([astsbindir], ['${sbindir}'])dnl AC_SUBST([astetcdir], ['${sysconfdir}/asterisk'])dnl AC_SUBST([astheaderdir], ['${includedir}/asterisk'])dnl AC_SUBST([astlibdir], ['${libdir}'])dnl AC_SUBST([astmoddir], ['${libdir}/asterisk/modules'])dnl AC_SUBST([astmandir], ['${mandir}'])dnl AC_SUBST([astvarlibdir], ['${localstatedir}/lib/asterisk'])dnl AC_SUBST([astdatadir], ['${astvarlibdir}'])dnl AC_SUBST([astdbdir], ['${astvarlibdir}'])dnl AC_SUBST([astkeydir], ['${astvarlibdir}'])dnl AC_SUBST([astspooldir], ['${localstatedir}/spool/asterisk'])dnl AC_SUBST([astlogdir], ['${localstatedir}/log/asterisk'])dnl AC_SUBST([astvarrundir], ['${localstatedir}/run/asterisk'])dnl case "${host_os}" in *bsd*) if test ${prefix} = 'NONE'; then astvarlibdir='${prefix}/share/asterisk' astdbdir='${localstatedir}/db/asterisk' fi ;; darwin*) if test ${prefix} = 'NONE'; then astvarrundir='/Library/Application Support/Asterisk/Run' fi ;; esac case "${host_os}" in freebsd*) ac_default_prefix=/usr/local CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ;; openbsd*) ac_default_prefix=/usr/local if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then if test ${sysconfdir} = '${prefix}/etc'; then astetcdir=/etc/asterisk fi if test ${mandir} = '${prefix}/man'; then astmandir=/usr/share/man fi fi CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ;; darwin*) ac_default_prefix=/usr/local if test ${prefix} = 'NONE'; then astmoddir='/Library/Application Support/Asterisk/Modules' astvarlibdir='/Library/Application Support/Asterisk' astlogdir=/Library/Logs/Asterisk astvarrundir='/Library/Application Support/Asterisk/Run' fi AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.]) AC_DEFINE([_DARWIN_UNLIMITED_SELECT], 1, [Define to 1 if running on Darwin.]) ;; solaris*) if test ${prefix} = 'NONE'; then astetcdir=/var/etc/asterisk astsbindir=/opt/asterisk/sbin astlibdir=/opt/asterisk/lib astmoddir=/opt/asterisk/lib/modules astheaderdir=/opt/asterisk/include astmandir=/opt/asterisk/man astvarlibdir=/var/opt/asterisk astspooldir=/var/spool/asterisk astlogdir=/var/log/asterisk astvarrundir=/var/run/asterisk fi ;; *) ac_default_prefix=/usr if test ${prefix} = '/usr' || test ${prefix} = 'NONE'; then if test ${sysconfdir} = '${prefix}/etc'; then sysconfdir=/etc fi if test ${mandir} = '${prefix}/man'; then mandir=/usr/share/man fi fi ;; esac if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then if test ${localstatedir} = '${prefix}/var'; then localstatedir=/var fi fi BUILD_PLATFORM=${build} BUILD_CPU=${build_cpu} BUILD_VENDOR=${build_vendor} BUILD_OS=${build_os} AC_SUBST(BUILD_PLATFORM) AC_SUBST(BUILD_CPU) AC_SUBST(BUILD_VENDOR) AC_SUBST(BUILD_OS) HOST_PLATFORM=${host} HOST_CPU=${host_cpu} HOST_VENDOR=${host_vendor} HOST_OS=${host_os} AC_SUBST(HOST_PLATFORM) AC_SUBST(HOST_CPU) AC_SUBST(HOST_VENDOR) AC_SUBST(HOST_OS) PBX_WINARCH=0 case "${host_os}" in freebsd*) OSARCH=FreeBSD ;; netbsd*) OSARCH=NetBSD ;; openbsd*) OSARCH=OpenBSD ;; solaris*) OSARCH=SunOS ;; mingw32) OSARCH=mingw32 PBX_WINARCH=1 ;; cygwin) OSARCH=cygwin PBX_WINARCH=1 ;; linux-gnueabi* | linux-gnuspe) OSARCH=linux-gnu ;; kfreebsd*-gnu) OSARCH=kfreebsd-gnu ;; *) OSARCH=${host_os} ;; esac AC_SUBST(OSARCH) AC_SUBST(PBX_WINARCH) # check for uname AC_PATH_TOOL([UNAME], [uname], No) if test ! x"${UNAME}" = xNo; then PBX_OSREV=$(${UNAME} -r) fi AC_SUBST(PBX_OSREV) AH_TOP( #ifndef ASTERISK_AUTOCONFIG_H #define ASTERISK_AUTOCONFIG_H #include "asterisk/buildopts.h" ) AH_BOTTOM( #endif ) # cross-compile checks if test "${cross_compiling}" = "yes"; then AC_CHECK_TOOL(CC, gcc, :) AC_CHECK_TOOL(CXX, g++, :) AC_CHECK_TOOL(LD, ld, :) AC_CHECK_TOOL(RANLIB, ranlib, :) fi # Checks for programs. AC_PROG_CXX AC_PROG_CPP AC_PROG_CXXCPP # This macro is just copied into our local acinclude.m4 from libtool.m4 so that # the developers regenerating the configure script don't have to install libtool. AST_PROG_LD # note, does not work on FreeBSD AC_PROG_AWK AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_RANLIB AST_CHECK_GNU_MAKE AC_PROG_EGREP AC_CHECK_TOOLS([STRIP], [strip gstrip], :) AC_CHECK_TOOLS([AR], [ar gar], :) GNU_LD=0 if test "x$with_gnu_ld" = "xyes" ; then GNU_LD=1 fi AC_SUBST(GNU_LD) AC_PATH_PROG([BISON], [bison], :) AC_PATH_PROG([CMP], [cmp], :) AC_PATH_PROG([FLEX], [flex], :) AC_PATH_PROG([GREP], [grep], :) AC_PATH_PROG([PYTHON], [python], :) AC_PATH_PROG([FIND], [find], :) AC_PATH_PROG([COMPRESS], [compress], :) AC_PATH_PROG([BASENAME], [basename], :) AC_PATH_PROG([DIRNAME], [dirname], :) AC_PATH_PROG([SHELL], [sh], :) AC_PATH_PROG([LN], [ln], :) AC_PATH_PROG([DOT], [dot], :) AC_PATH_PROG([WGET], [wget], :) AC_PATH_PROG([CURL], [curl], :) AC_PATH_PROG([RUBBER], [rubber], :) AC_PATH_PROG([CATDVI], [catdvi], :) AC_PATH_PROG([KPATHSEA], [kpsewhich], :) AC_PATH_PROG([XMLLINT], [xmllint], :) AC_PATH_PROG([XMLSTARLET], [xmlstarlet], :) AC_PATH_PROG([GIT], [git], :) if test "${WGET}" != ":" ; then DOWNLOAD=${WGET} else if test "${CURL}" != ":" ; then DOWNLOAD="${CURL} -O --progress-bar -w \"%{url_effective}\n\"" else AC_PATH_PROG([FETCH], [fetch], [:]) DOWNLOAD=${FETCH} fi fi AC_SUBST(DOWNLOAD) AC_PATH_PROG([LDCONFIG], [ldconfig], :) AC_PATH_PROG([SHA1SUM], [sha1sum], $ac_aux_dir/build_tools/sha1sum-sh) AC_PATH_PROG([OPENSSL], [openssl], :) AC_CACHE_CHECK([for bison that supports parse-param], [ac_cv_path_BISON2], [ if test "x$BISON" != "x:" ; then # Create a temporary directory $tmp in $TMPDIR (default /tmp). # Use mktemp if possible; otherwise fall back on mkdir, # with $RANDOM to make collisions less likely. : ${TMPDIR=/tmp} { tmp=` (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null ` && test -n "$tmp" && test -d "$tmp" } || { tmp=$TMPDIR/foo$$-$RANDOM (umask 077 && mkdir "$tmp") } || exit $? cat >$tmp/test.y <<__EOL__ %parse-param {struct parse_io *parseio} %% file : { \$\$ = parseio->pval = 1; } ; %% __EOL__ ${BISON} -o ${tmp}/test.tab.c ${tmp}/test.y >/dev/null 2>&1 if test -e "${tmp}/test.tab.c"; then ac_cv_path_BISON2=${BISON} fi rm -rf ${tmp} fi ]) if test "x${ac_cv_path_BISON2}" = "x" ; then BISON=: PBX_BISON=0 else PBX_BISON=1 fi AC_SUBST(PBX_BISON) if test "x${FLEX}" = "x:" ; then PBX_FLEX=0 else PBX_FLEX=1 fi AC_SUBST(PBX_FLEX) AC_CHECK_TOOL([SOXMIX], [soxmix], [:]) if test "${SOXMIX}" != ":" ; then AC_DEFINE([HAVE_SOXMIX], 1, [Define to 1 if your system has soxmix application.]) fi AC_CHECK_PROGS([MD5], [md5 md5sum gmd5sum digest]) if test "${MD5}" = "digest" ; then MD5="${MD5} -a md5" fi ACX_PTHREAD AC_LANG(C) AC_ARG_ENABLE([dev-mode], [AS_HELP_STRING([--enable-dev-mode], [Turn on developer mode])], [case "${enableval}" in y|ye|yes) AST_DEVMODE=yes ;; n|no) AST_DEVMODE=no ;; noisy) AST_DEVMODE=yes NOISY_BUILD=yes ;; strict) AST_DEVMODE=yes AST_DEVMODE_STRICT=yes ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode) ;; esac]) AC_SUBST(NOISY_BUILD) AC_SUBST(AST_DEVMODE) AC_SUBST(AST_DEVMODE_STRICT) AST_CODE_COVERAGE=no AC_ARG_ENABLE([coverage], [AS_HELP_STRING([--enable-coverage], [Turn on code coverage tracking (for gcov)])], [case "${enableval}" in y|ye|yes) AST_CODE_COVERAGE=yes ;; n|no) AST_CODE_COVERAGE=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-coverage) ;; esac]) AC_SUBST(AST_CODE_COVERAGE) # AST_EXT_LIB_SETUP is used to tell configure to handle variables for # various packages. # $1 is the prefix for the variables in makeopts and autoconfig.h # $2 is the short comment, $4 is the long comment # $3 is the name used in --with- or --without- flags for configure. # # Package option names should be in alphabetical order # by the --with option name (the third field), # to make things easier for the users. AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound]) AST_EXT_LIB_SETUP([BFD], [Debug symbol decoding], [bfd]) # BKTR is used for backtrace support on platforms that do not # have it natively. AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo]) AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth]) AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap]) AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg]) AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg]) AST_EXT_LIB_SETUP([CURSES], [curses], [curses]) AST_EXT_LIB_SETUP([CRYPTO], [OpenSSL Cryptography], [crypto]) AST_EXT_LIB_SETUP_OPTIONAL([OPENSSL_SRTP], [OpenSSL SRTP Extension Support], [CRYPTO], [crypto]) AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi]) AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec], [avcodec]) AST_EXT_LIB_SETUP([GSM], [External GSM], [gsm], [, use 'internal' GSM otherwise]) AST_EXT_LIB_SETUP([ILBC], [System iLBC], [ilbc], [, use 'internal' iLBC otherwise]) AST_EXT_LIB_SETUP([GTK2], [gtk2], [gtk2]) AST_EXT_LIB_SETUP([GMIME], [GMime], [gmime]) AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323]) AST_EXT_LIB_SETUP([HOARD], [Hoard Memory Allocator], [hoard]) AST_EXT_LIB_SETUP([ICAL], [iCal], [ical]) AST_EXT_LIB_SETUP([ICONV], [Iconv], [iconv]) AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber], [iksemel]) AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap]) AST_EXT_LIB_SETUP([INOTIFY], [inotify support], [inotify]) AST_EXT_LIB_SETUP([IODBC], [iODBC], [iodbc]) AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux], [isdnnet]) AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack]) AST_EXT_LIB_SETUP([KQUEUE], [kqueue support], [kqueue]) AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap]) AST_LIBCURL_CHECK_CONFIG([], [7.10.1]) AST_EXT_LIB_SETUP([LIBEDIT], [NetBSD Editline library], [libedit], [, use 'internal' Editline otherwise]) AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2]) AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl]) AST_EXT_LIB_SETUP([LUA], [Lua], [lua]) AST_EXT_LIB_SETUP([MISDN], [mISDN user], [misdn]) AST_EXT_LIB_SETUP([MYSQLCLIENT], [MySQL client], [mysqlclient]) AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs]) AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses]) AST_EXT_LIB_SETUP([NEON], [neon], [neon]) AST_EXT_LIB_SETUP([NEON29], [neon29], [neon29]) AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp]) AST_EXT_LIB_SETUP([NEWT], [newt], [newt]) AST_EXT_LIB_SETUP([OGG], [OGG], [ogg]) AST_EXT_LIB_SETUP([OPENR2], [MFR2], [openr2]) AST_EXT_LIB_SETUP([OSPTK], [OSP Toolkit], [osptk]) AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss]) AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres]) AST_EXT_LIB_SETUP([POPT], [popt], [popt]) AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio]) AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_L2_PERSISTENCE], [ISDN Layer 2 persistence option], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_DATETIME_SEND], [ISDN PRI Date/time ie send policy], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_MWI_V2], [ISDN PRI Message Waiting Indication (Fixed)], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_DISPLAY_TEXT], [ISDN PRI user display text IE contents during call], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_MWI], [ISDN PRI Message Waiting Indication], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_MCID], [ISDN PRI Malicious Call ID], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_WAITING], [ISDN PRI call waiting supplementary service], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_AOC_EVENTS], [ISDN PRI advice of charge supplementary service events], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_TRANSFER], [ISDN PRI call transfer supplementary service], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_CCSS], [ISDN PRI call completion supplementary service], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_HANGUP_FIX], [ISDN PRI hangup fix], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_SUBADDR], [ISDN PRI subaddressing], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_HOLD], [ISDN PRI call hold], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_CALL_REROUTING], [ISDN PRI call rerouting and call deflection], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_SETUP_KEYPAD], [ISDN PRI keypad facility in SETUP], [PRI], [pri]) # ------------------------------------v # TODO: The code can be changed to always include these features now. # These features will always be present if pri_connected_line_update is available. AST_EXT_LIB_SETUP_OPTIONAL([PRI_INBANDDISCONNECT], [ISDN PRI set_inbanddisconnect], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_PROG_W_CAUSE], [ISDN progress with cause], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_SERVICE_MESSAGES], [ISDN service messages], [PRI], [pri]) AST_EXT_LIB_SETUP_OPTIONAL([PRI_REVERSE_CHARGE], [ISDN reverse charge], [PRI], [pri]) # ------------------------------------^ AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib]) AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius]) AST_EXT_LIB_SETUP([RESAMPLE], [LIBRESAMPLE], [resample]) AST_EXT_LIB_SETUP([SDL], [Sdl], [sdl]) AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image], [SDL_image]) AST_OPTION_ONLY([sounds-cache], [SOUNDS_CACHE_DIR], [cached sound tarfiles], []) AST_EXT_LIB_SETUP([SPANDSP], [SPANDSP], [spandsp]) AST_EXT_LIB_SETUP([SS7], [ISDN SS7], [ss7]) AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex]) AST_EXT_LIB_SETUP([SPEEX_PREPROCESS], [Speex preprocess routines], [speex]) AST_EXT_LIB_SETUP([SPEEXDSP], [SpeexDSP], [speexdsp]) AST_EXT_LIB_SETUP_DEPENDENT([SPEEX_PREPROCESS], [speex_preprocess_ctl], [], [speex]) AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite]) AST_EXT_LIB_SETUP([SQLITE3], [SQLite], [sqlite3]) AST_EXT_LIB_SETUP([SRTP], [Secure RTP], [srtp]) AST_EXT_LIB_SETUP_OPTIONAL([SRTP_SHUTDOWN], [SRTP Library Shutdown Function], [SRTP], [srtp]) AST_EXT_LIB_SETUP([OPENSSL], [OpenSSL Secure Sockets Layer], [ssl]) AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv]) AST_EXT_LIB_SETUP([FREETDS], [FreeTDS], [tds]) AST_EXT_LIB_SETUP([TERMCAP], [Termcap], [termcap]) AST_EXT_LIB_SETUP([TIMERFD], [timerfd], [timerfd]) AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo]) AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone]) AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [unixodbc]) AST_EXT_LIB_SETUP([UUID], [UUID], [uuid]) AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis]) AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb]) AST_EXT_LIB_SETUP([X11], [X11], [x11]) AST_EXT_LIB_SETUP([ZLIB], [zlib compression], [z]) # check for basic system features and functionality before # checking for package libraries AC_FUNC_ALLOCA AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/event.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h utime.h arpa/nameser.h sys/io.h]) # Any one of these 4 packages support a mandatory requirement, so we want to check on them as early as possible. AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], []) AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], []) AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h]) AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h]) EDITLINE_LIB="" if test "x$TERMCAP_LIB" != "x" ; then EDITLINE_LIB="$TERMCAP_LIB" elif test "x$TINFO_LIB" != "x" ; then EDITLINE_LIB="$TINFO_LIB" elif test "x$CURSES_LIB" != "x" ; then EDITLINE_LIB="$CURSES_LIB" elif test "x$NCURSES_LIB" != "x" ; then EDITLINE_LIB="$NCURSES_LIB" else AC_MSG_ERROR([*** termcap support not found (on modern systems, this typically means the ncurses development package is missing)]) fi AC_SUBST(EDITLINE_LIB) # Another mandatory item (unless it's explicitly disabled) AC_ARG_ENABLE([xmldoc], [AS_HELP_STRING([--disable-xmldoc], [Explicitly disable XML documentation])], [case "${enableval}" in y|ye|yes) disable_xmldoc=no ;; n|no) disable_xmldoc=yes ;; *) AC_MSG_ERROR(bad value ${enableval} for --disable-xmldoc) ;; esac], [disable_xmldoc=no]) if test "${disable_xmldoc}" != "yes"; then AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , , [#include #include ], [LIBXML_TEST_VERSION]) if test "${PBX_LIBXML2}" != 1; then AC_MSG_NOTICE(*** XML documentation will not be available because the 'libxml2' development package is missing.) AC_MSG_NOTICE(*** Please run the 'configure' script with the '--disable-xmldoc' parameter option) AC_MSG_NOTICE(*** or install the 'libxml2' development package.) exit 1 fi fi # some embedded systems omit internationalization (locale) support AC_CHECK_HEADERS([xlocale.h]) AC_CHECK_HEADERS([winsock.h winsock2.h]) AC_CHECK_HEADER([sys/poll.h], [], AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.])) AC_SYS_LARGEFILE # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_TYPE_UID_T AC_C_INLINE AC_TYPE_LONG_DOUBLE_WIDER AC_TYPE_MODE_T AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_CHECK_MEMBERS([struct stat.st_blksize]) AC_CHECK_MEMBERS([struct ucred.uid, struct ucred.cr_uid, struct sockpeercred.uid], [], [], [#include #include ]) AC_CHECK_MEMBERS([struct ifreq.ifr_ifru.ifru_hwaddr], [], [], [#include ]) AC_HEADER_TIME AC_STRUCT_TM AC_C_VOLATILE AC_CHECK_TYPES([ptrdiff_t]) # Checks for library functions. AC_FUNC_CHOWN AC_FUNC_CLOSEDIR_VOID AC_FUNC_ERROR_AT_LINE AST_FUNC_FORK AC_FUNC_FSEEKO AC_PROG_GCC_TRADITIONAL # XXX: these are commented out until we determine whether it matters if our malloc() # acts exactly like glibc's or not # AC_FUNC_MALLOC # AC_FUNC_REALLOC AC_FUNC_MEMCMP AC_FUNC_MMAP AC_FUNC_SELECT_ARGTYPES AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL AC_FUNC_STAT AC_FUNC_STRCOLL AC_FUNC_STRFTIME AC_FUNC_STRNLEN AC_FUNC_STRTOD AC_FUNC_UTIME_NULL AC_FUNC_VPRINTF AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap ntohll newlocale ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl]) # NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks, # so that AC_CHECK_FUNCS can detect functions in that library. AC_CHECK_LIB([m], [sqrt]) # BSD might not have exp2, and/or log2 AC_CHECK_FUNCS([exp2 log2 exp10 log10 sin cos tan asin acos atan atan2 pow rint exp log remainder fmod round roundf trunc floor ceil]) # Certain architectures don't really have long double, even though # AC_CHECK_FUNCS would otherwise find the following functions. if test "x${ac_cv_type_long_double_wider}" = "xyes" ; then AC_CHECK_FUNCS([exp2l log2l exp10l log10l sinl cosl tanl asinl acosl atanl atan2l powl sqrtl rintl expl logl remainderl fmodl roundl truncl floorl ceill]) fi AC_MSG_CHECKING(for LLONG_MAX in limits.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [long long foo = LLONG_MAX])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_LLONG_MAX], 1, [Define to 1 if limits.h includes a LLONG_MAX definition.]), AC_MSG_RESULT(no) ) AC_MSG_CHECKING(for timersub in time.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [struct timeval *a; timersub(a, a, a);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_TIMERSUB], 1, [Define to 1 if your system defines timersub.]), AC_MSG_RESULT(no) ) AC_MSG_CHECKING(for a version of GNU ld that supports the --dynamic-list flag) old_LDFLAGS=${LDFLAGS} cat >conftest.dynamics <<_ACEOF { *ast_*; }; _ACEOF LDFLAGS="${LDFLAGS} -Wl,--dynamic-list,conftest.dynamics" PBX_DYNAMIC_LIST=0 AC_LINK_IFELSE( [AC_LANG_PROGRAM([], [])], PBX_DYNAMIC_LIST=1 AC_MSG_RESULT(yes), AC_MSG_RESULT(no) ) AC_SUBST(PBX_DYNAMIC_LIST) LDFLAGS=${old_LDFLAGS} rm -f conftest.dynamics AC_CHECK_HEADER([sys/poll.h], [HAS_POLL=1] AC_DEFINE([HAVE_SYS_POLL_H], 1, [Define to 1 if your system has working sys/poll.h]), ) AC_ARG_ENABLE([internal-poll], [AS_HELP_STRING([--enable-internal-poll], [Use Asterisk's poll implementation])], [case "${enableval}" in y|ye|yes) HAS_POLL="";; n|no) HAS_POLL="${HAS_POLL}" ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-internal-poll) ;; esac]) AC_SUBST(HAS_POLL) AC_ARG_ENABLE([asteriskssl], [AS_HELP_STRING([--disable-asteriskssl], [Disable Asterisk's SSL wrapper library])], [case "${enableval}" in y|ye|yes) AST_ASTERISKSSL=yes ;; n|no) AST_ASTERISKSSL=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --disable-asteriskssl) ;; esac], [AST_ASTERISKSSL=yes]) AC_SUBST(AST_ASTERISKSSL) # https support (in main/http.c) uses funopen on BSD systems, # fopencookie on linux AC_CHECK_FUNCS([funopen fopencookie]) AC_CHECK_FUNCS([inet_aton]) # check if we have IP_PKTINFO constant defined AC_MSG_CHECKING(for IP_PKTINFO) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [int pi = IP_PKTINFO;])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_PKTINFO], 1, [Define to 1 if your system defines IP_PKTINFO.]), AC_MSG_RESULT(no) ) # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c AC_SEARCH_LIBS(gethostbyname_r, [socket nsl]) AC_MSG_CHECKING(for gethostbyname_r with 6 arguments) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include #include ], [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]), AC_MSG_RESULT(no) ) AC_MSG_CHECKING(for gethostbyname_r with 5 arguments) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include #include ], [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]), AC_MSG_RESULT(no) ) AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])]) AC_MSG_CHECKING(for __swap16 variant of byteswapping macros) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [int a = 1; int b = __swap16(a);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_SYS_ENDIAN_SWAP16], 1, [Define to 1 if your sys/endian.h header file provides the __swap16 macro.]), AC_MSG_RESULT(no) ) AC_MSG_CHECKING(for bswap16 variant of byteswapping macros) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [int a = 1; int b = bswap16(a);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_SYS_ENDIAN_BSWAP16], 1, [Define to 1 if your sys/endian.h header file provides the bswap16 macro.]), AC_MSG_RESULT(no) ) if test "${cross_compiling}" = "no"; then AC_CHECK_FILE(/dev/urandom, AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define to 1 if your system has /dev/urandom.])) fi AC_MSG_CHECKING(for locale_t in locale.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [locale_t lt = NULL])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_LOCALE_T_IN_LOCALE_H], 1, [Define to 1 if your system defines the locale_t type in locale.h]), AC_MSG_RESULT(no) AC_MSG_CHECKING(for locale_t in xlocale.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [locale_t lt = NULL])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_LOCALE_T_IN_XLOCALE_H], 1, [Define to 1 if your system defines the locale_t type in xlocale.h]), AC_MSG_RESULT(no) ) ) AC_MSG_CHECKING(for O_EVTONLY in fcntl.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [int a = O_EVTONLY;])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_O_EVTONLY], 1, [Define to 1 if your system defines the file flag O_EVTONLY in fcntl.h]), AC_MSG_RESULT(no) ) AC_MSG_CHECKING(for O_SYMLINK in fcntl.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [int a = O_SYMLINK;])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_O_SYMLINK], 1, [Define to 1 if your system defines the file flag O_SYMLINK in fcntl.h]), AC_MSG_RESULT(no) ) AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_INITIALIZER], [PTHREAD_RWLOCK_INITIALIZER], [pthread.h]) AC_MSG_CHECKING(for PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [int a = PTHREAD_RWLOCK_PREFER_WRITER_NP;])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP], 1, [Define to 1 if your system defines PTHREAD_RWLOCK_PREFER_WRITER_NP in pthread.h]), AC_MSG_RESULT(no) ) AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE_NP in pthread.h) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [int a = PTHREAD_MUTEX_RECURSIVE_NP;])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1, [Define to 1 if your system defines PTHREAD_MUTEX_RECURSIVE_NP in pthread.h]), AC_MSG_RESULT(no) ) AC_MSG_CHECKING(for pthread_rwlock_timedwrlock() in pthread.h) save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include #include ], [pthread_rwlock_t foo; struct timespec bar; pthread_rwlock_timedwrlock(&foo, &bar)]) ],[ AC_MSG_RESULT(yes) ac_cv_pthread_rwlock_timedwrlock="yes" ],[ AC_MSG_RESULT(no) ac_cv_pthread_rwlock_timedwrlock="no" ] ) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" if test "${ac_cv_pthread_rwlock_timedwrlock}" = "yes"; then AC_DEFINE([HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK], 1, [Define if your system has pthread_rwlock_timedwrlock()]) fi AC_MSG_CHECKING(if PTHREAD_ONCE_INIT needs braces) saved_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} -Werror -Wmissing-braces" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [#include void empty(){}], [pthread_once_t once = PTHREAD_ONCE_INIT; pthread_once(&once, empty);]) ],[ AC_MSG_RESULT(no) ac_cv_pthread_once_needsbraces="no" ],[ AC_MSG_RESULT(yes) ac_cv_pthread_once_needsbraces="yes" ] ) CFLAGS="${saved_CFLAGS}" if test "${ac_cv_pthread_once_needsbraces}" = "yes"; then AC_DEFINE([PTHREAD_ONCE_INIT_NEEDS_BRACES], 1, [Define if your system needs braces around PTHREAD_ONCE_INIT]) fi AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h]) # Can we compare a mutex to its initial value? # Generally yes on OpenBSD/FreeBSD and no on Mac OS X. AC_MSG_CHECKING(whether we can compare a mutex to its initial value) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [pthread_mutex_t lock; if ((lock) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { return 0; } return 0])], AC_MSG_RESULT(yes) AC_DEFINE([CAN_COMPARE_MUTEX_TO_INIT_VALUE], 1, [Define to 1 if your system's implementation of mutexes supports comparison of a mutex to its initializer.]), AC_MSG_RESULT(no) ) #if test "${cross_compiling}" = "no"; #then #AC_MSG_CHECKING(for working epoll support) #AC_LINK_IFELSE( #AC_LANG_PROGRAM([#include ], [int res = epoll_create(10); # if (res < 0) # return 1; # close (res); # return 0;]), #AC_MSG_RESULT(yes) #AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]), #AC_MSG_RESULT(no) #) #fi # for FreeBSD thr_self AC_CHECK_HEADERS([sys/thr.h]) AC_MSG_CHECKING(for compiler atomic operations) AC_LINK_IFELSE( [AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_GCC_ATOMICS], 1, [Define to 1 if your GCC C compiler provides atomic operations.]), AC_MSG_RESULT(no) ) # glibc, AFAIK, is the only C library that makes printing a NULL to a string safe. AC_MSG_CHECKING([if your system printf is NULL-safe.]) AC_RUN_IFELSE( [AC_LANG_PROGRAM([#include ], [printf("%s", NULL)])], AC_DEFINE([HAVE_NULLSAFE_PRINTF], 1, [Define to 1 if your C library can safely print NULL to string formats.]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no), # It's unlikely an embedded system will have this. AC_MSG_RESULT(unknown) ) AC_MSG_CHECKING(if we can increase the maximum select-able file descriptor) AC_RUN_IFELSE( [AC_LANG_PROGRAM([ #include #include #include #include #include #include #include #include #include #include #include ], [[ struct rlimit rlim = { FD_SETSIZE * 2, FD_SETSIZE * 2 }; int fd0, fd1; struct timeval tv = { 0, }; struct ast_fdset { long fds_bits[[1024]]; } fds = { { 0, } }; if (setrlimit(RLIMIT_NOFILE, &rlim)) { exit(1); } if ((fd0 = open("/dev/null", O_RDONLY)) < 0) { exit(1); } if (dup2(fd0, (fd1 = FD_SETSIZE + 1)) < 0) { exit(1); } FD_SET(fd0, (fd_set *) &fds); FD_SET(fd1, (fd_set *) &fds); if (select(FD_SETSIZE + 2, (fd_set *) &fds, NULL, NULL, &tv) < 0) { exit(1); } exit(0)]])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_VARIABLE_FDSET], 1, [Define to 1 if your system can support larger than default select bitmasks.]), AC_MSG_RESULT(no), AC_MSG_RESULT(cross-compile) ) if test "${ac_cv_have_variable_fdset}x" = "0x"; then AC_RUN_IFELSE( [AC_LANG_PROGRAM([ #include #include #include ], [if (getuid() != 0) { exit(1); }])], AC_DEFINE([CONFIGURE_RAN_AS_ROOT], 1, [Some configure tests will unexpectedly fail if configure is run by a non-root user. These may be able to be tested at runtime.])) fi AST_GCC_ATTRIBUTE(pure) AST_GCC_ATTRIBUTE(malloc) AST_GCC_ATTRIBUTE(const) AST_GCC_ATTRIBUTE(unused) AST_GCC_ATTRIBUTE(always_inline) AST_GCC_ATTRIBUTE(deprecated) AST_GCC_ATTRIBUTE(sentinel) AST_GCC_ATTRIBUTE(warn_unused_result) # Support weak symbols on a platform specific basis. The Mac OS X # (Darwin) support must be isolated from the other platforms because # it has caused other platforms to fail. # case "${OSARCH}" in darwin*) # Allow weak symbol support on Darwin platforms only because there # is active community support for it. # However, Darwin seems to break weak symbols for each new version. # AST_GCC_ATTRIBUTE(weak_import, [], [], PBX_WEAKREF) # Several other platforms including Linux have GCC versions that # define the weak attribute. However, this attribute is only # setup for use in the code by Darwin. AST_GCC_ATTRIBUTE(weak, [], [], PBX_WEAKREF) ;; linux-gnu) # Primarily support weak symbols on Linux platforms. # AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static, PBX_WEAKREF) ;; *) # Allow weak symbols on other platforms. However, any problems # with this feature on other platforms must be fixed by the # community. # AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static, PBX_WEAKREF) ;; esac AC_MSG_CHECKING(for -ffunction-sections support) saved_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} -ffunction-sections" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [int x = 1;])], AC_MSG_RESULT(yes) [saved_LDFLAGS="${LDFLAGS}"] [LDFLAGS="${LDFLAGS} -Wl,--gc-sections"] AC_MSG_CHECKING(for --gc-sections support) AC_LINK_IFELSE( [AC_LANG_PROGRAM([], [int x = 1;])], AC_MSG_RESULT(yes) [GC_CFLAGS="-ffunction-sections"] [[GC_LDFLAGS="-Wl,--gc-sections"]], AC_MSG_RESULT(no) ) [LDFLAGS="${saved_LDFLAGS}"], AC_MSG_RESULT(no) ) CFLAGS="${saved_CFLAGS}" AC_SUBST(GC_CFLAGS) AC_SUBST(GC_LDFLAGS) AC_MSG_CHECKING(for -Wdeclaration-after-statement support) if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then AC_MSG_RESULT(yes) AST_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement else AC_MSG_RESULT(no) AST_DECLARATION_AFTER_STATEMENT= fi AC_SUBST(AST_DECLARATION_AFTER_STATEMENT) AC_MSG_CHECKING(for -Wtrampolines support) if $(${CC} -Wtrampolines -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then AC_MSG_RESULT(yes) AST_TRAMPOLINES=-Wtrampolines else AC_MSG_RESULT(no) AST_TRAMPOLINES= fi AC_SUBST(AST_TRAMPOLINES) AC_MSG_CHECKING(for _FORTIFY_SOURCE support) if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then AC_MSG_RESULT(yes) AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2 else AC_MSG_RESULT(no) AST_FORTIFY_SOURCE= fi AC_SUBST(AST_FORTIFY_SOURCE) AC_MSG_CHECKING(for -fno-strict-overflow) if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then AC_MSG_RESULT(yes) AST_NO_STRICT_OVERFLOW=-fno-strict-overflow else AC_MSG_RESULT(no) AST_NO_STRICT_OVERFLOW= fi AC_SUBST(AST_NO_STRICT_OVERFLOW) AC_MSG_CHECKING(for -Wshadow) if $(${CC} -Wshadow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then AC_MSG_RESULT(yes) AST_SHADOW_WARNINGS=-Wshadow else AC_MSG_RESULT(no) AST_SHADOW_WARNINGS= fi AC_SUBST(AST_SHADOW_WARNINGS) AC_MSG_CHECKING(for -march=native support) if $(${CC} -march=native -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then if test "${CONFIG_CFLAGS}" = ""; then AC_MSG_RESULT(yes) AST_NATIVE_ARCH=1 else AC_MSG_RESULT(user CFLAGS present) AST_NATIVE_ARCH= fi else AC_MSG_RESULT(no) AST_NATIVE_ARCH= fi AC_SUBST(AST_NATIVE_ARCH) dnl Nested functions required for RAII implementation AC_MSG_CHECKING(for -fnested-functions) AC_COMPILE_IFELSE( dnl Prototype needed due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36774 [AC_LANG_PROGRAM([], [auto void foo(void); void foo(void) {}])], AC_MSG_RESULT(no) [AST_NESTED_FUNCTIONS=], AC_MSG_RESULT(required) [AST_NESTED_FUNCTIONS=-fnested-functions] ) AC_SUBST(AST_NESTED_FUNCTIONS) dnl Check to see if rpath should be set in LDFLAGS AC_ARG_ENABLE(rpath, [AC_HELP_STRING([--disable-rpath], [Disables rpath linker option checking])], [case "${enableval}" in y|ye|yes) check_rpath=yes ;; n|no) check_rpath=no ;; *) AC_MSG_ERROR(bad value ${enableval} for --disable-rpath) ;; esac], [check_rpath=yes]) AC_MSG_CHECKING(whether to use rpath) AST_RPATH= if test "${check_rpath}" != yes; then AC_MSG_RESULT(skipped) elif test "${prefix}" = /usr || test "${prefix}" = NONE; then AC_MSG_RESULT(not needed) else case "${host_os}" in darwin*) AC_MSG_RESULT(not supported) # We set macosx_version_min to 10.4, which doesn't # support rpath. However, we set install_name on our # dylibs, so it's not strictly necessary. ;; *) AC_MSG_RESULT(required) AST_RPATH="-Wl,-rpath,${libdir}" ;; esac fi AC_SUBST(AST_RPATH) AC_MSG_CHECKING(for sysinfo) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [struct sysinfo sys_info; int uptime = sys_info.uptime])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_SYSINFO], 1, [Define to 1 if your system has sysinfo support]), AC_MSG_RESULT(no) ) AC_SEARCH_LIBS(res_9_ninit, resolv) AC_MSG_CHECKING(for res_ninit) AC_LINK_IFELSE( [AC_LANG_PROGRAM([ #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_NAMESER_H #include #endif #include ], [int foo = res_ninit(NULL);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_RES_NINIT], 1, [Define to 1 if your system has the re-entrant resolver functions.]) AC_SEARCH_LIBS(res_9_ndestroy, resolv) AC_MSG_CHECKING(for res_ndestroy) AC_LINK_IFELSE( [AC_LANG_PROGRAM([ #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_NAMESER_H #include #endif #include ], [res_ndestroy(NULL);])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_RES_NDESTROY], 1, [Define to 1 if your system has the ndestroy resolver function.]), AC_MSG_RESULT(no) ) AC_SEARCH_LIBS(res_9_close, resolv) AC_MSG_CHECKING(for res_close) AC_LINK_IFELSE( [AC_LANG_PROGRAM([ #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_NAMESER_H #include #endif #include ], [res_close();])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_RES_CLOSE], 1, [Define to 1 if your system has the close resolver function.]), AC_MSG_RESULT(no) ), AC_MSG_RESULT(no) ) AST_C_DEFINE_CHECK([GLOB_NOMAGIC], [GLOB_NOMAGIC], [glob.h]) AST_C_DEFINE_CHECK([GLOB_BRACE], [GLOB_BRACE], [glob.h]) AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h]) AC_CHECK_HEADER([libkern/OSAtomic.h], [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])]) AC_CHECK_SIZEOF([int]) AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([long long]) AC_CHECK_SIZEOF([char *]) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_COMPUTE_INT([ac_cv_sizeof_fd_set_fds_bits], [sizeof(foo.fds_bits[[0]])], [$ac_includes_default fd_set foo;]) # This doesn't actually work; what it does is to use the variable set in the # previous test as a cached value to set the right output variables. AC_CHECK_SIZEOF(fd_set.fds_bits) # Set a type compatible with the previous. We cannot just use a generic type # for these bits, because on big-endian systems, the bits won't match up # correctly if the size is wrong. if test $ac_cv_sizeof_int = $ac_cv_sizeof_fd_set_fds_bits; then AC_DEFINE([TYPEOF_FD_SET_FDS_BITS], [int], [Define to a type of the same size as fd_set.fds_bits[[0]]]) else if test $ac_cv_sizeof_long = $ac_cv_sizeof_fd_set_fds_bits; then AC_DEFINE([TYPEOF_FD_SET_FDS_BITS], [long], [Define to a type of the same size as fd_set.fds_bits[[0]]]) else if test $ac_cv_sizeof_long_long = $ac_cv_sizeof_fd_set_fds_bits; then AC_DEFINE([TYPEOF_FD_SET_FDS_BITS], [long long], [Define to a type of the same size as fd_set.fds_bits[[0]]]) fi ; fi ; fi AC_MSG_CHECKING(for dladdr in dlfcn.h) PBX_DLADDR=0 old_LIBS=${LIBS} LIBS="${LIBS} -ldl" AC_LINK_IFELSE( [AC_LANG_PROGRAM([#define _GNU_SOURCE 1 #include ], [dladdr((void *)0, (void *)0)] )], AC_MSG_RESULT(yes) PBX_DLADDR=1 AC_SUBST([PBX_DLADDR]) AC_DEFINE([HAVE_DLADDR], 1, [Define to 1 if your system has the dladdr() GNU extension]), AC_MSG_RESULT(no) ) LIBS=${old_LIBS} # PKGCONFIG is used in later tests PKG_PROG_PKG_CONFIG() # do the package library checks now AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -ldl]) AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_openr], [bfd.h]) if test "${PBX_BFD}" = "0"; then # Fedora/RedHat/CentOS require extra libraries AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_check_format], [bfd.h], [-ldl -liberty]) fi if test "${PBX_BFD}" = "0"; then # openSUSE requires -lz AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_check_format], [bfd.h], [-ldl -liberty -lz]) fi if test "x${OSARCH}" = "xlinux-gnu" ; then AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h]) fi AST_C_DEFINE_CHECK([DAHDI], [DAHDI_RESET_COUNTERS], [dahdi/user.h], [230]) AST_C_DEFINE_CHECK([DAHDI], [DAHDI_DEFAULT_MTU_MRU], [dahdi/user.h], [220]) AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h], [200]) AST_C_DEFINE_CHECK([DAHDI_HALF_FULL], [DAHDI_POLICY_HALF_FULL], [dahdi/user.h]) AST_C_COMPILE_CHECK([DAHDI_LINEREVERSE_VMWI], [struct dahdi_vmwi_info booger], [dahdi/user.h], , [enhanced dahdi vmwi support]) AST_C_COMPILE_CHECK([DAHDI_ECHOCANCEL_FAX_MODE], [int foo = DAHDI_ECHOCANCEL_FAX_MODE], [dahdi/user.h]) AST_C_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h], , [getifaddrs() support]) AST_C_COMPILE_CHECK([TIMERFD], [timerfd_create(0,0); timerfd_settime(0,0,NULL,NULL);], [sys/timerfd.h], , [timerfd support]) GSM_INTERNAL="yes" AC_SUBST(GSM_INTERNAL) GSM_SYSTEM="yes" if test "${USE_GSM}" != "no"; then if test "${GSM_DIR}" = "internal"; then GSM_SYSTEM="no" elif test "${GSM_DIR}" != ""; then GSM_INTERNAL="no" fi if test "${GSM_SYSTEM}" = "yes"; then gsmlibdir="" if test "x${GSM_DIR}" != "x"; then if test -d ${GSM_DIR}/lib; then gsmlibdir="-L${GSM_DIR}/lib" else gsmlibdir="-L${GSM_DIR}" fi fi AC_CHECK_LIB([gsm], [gsm_create], AC_DEFINE_UNQUOTED([HAVE_GSM], 1, [Define to indicate the GSM library]), [], ${gsmlibdir}) if test "${ac_cv_lib_gsm_gsm_create}" = "yes"; then if test "x${GSM_DIR}" != "x" ; then AC_CHECK_HEADER([${GSM_DIR}/include/gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0]) AC_CHECK_HEADER([${GSM_DIR}/include/gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0]) else AC_CHECK_HEADER([gsm.h], [GSM_HEADER_FOUND=1], [GSM_HEADER_FOUND=0]) AC_CHECK_HEADER([gsm/gsm.h], [GSM_GSM_HEADER_FOUND=1], [GSM_GSM_HEADER_FOUND=0]) fi if test "${GSM_HEADER_FOUND}" = "0" ; then if test "{GSM_GSM_HEADER_FOUND}" = "0" ; then if test "x${GSM_MANDATORY}" = "xyes" ; then AC_MSG_NOTICE([***]) AC_MSG_NOTICE([*** It appears that you do not have the gsm development package installed.]) AC_MSG_NOTICE([*** Please install it to include ${GSM_DESCRIP} support, or re-run configure]) AC_MSG_NOTICE([*** without explicitly specifying --with-${GSM_OPTION}]) exit 1 fi fi fi GSM_OK=0 if test "${GSM_HEADER_FOUND}" = "1" ; then AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location]) GSM_OK=1 else if test "${GSM_GSM_HEADER_FOUND}" = "1" ; then AC_DEFINE_UNQUOTED([HAVE_GSM_GSM_HEADER], 1, [Define to indicate that gsm.h is in gsm/gsm.h]) GSM_OK=1 fi fi if test "${GSM_OK}" = "1" ; then GSM_LIB="-lgsm" if test "x${GSM_DIR}" != "x"; then GSM_LIB="${gsmlibdir} ${GSM_LIB}" GSM_INCLUDE="-I${GSM_DIR}/include" fi PBX_GSM=1 GSM_INTERNAL="no" fi fi fi if test "${GSM_INTERNAL}" = "yes"; then PBX_GSM=1 AC_DEFINE_UNQUOTED([HAVE_GSM_HEADER], 1, [Define to indicate that gsm.h has no prefix for its location]) fi fi ILBC_INTERNAL="yes" AC_SUBST(ILBC_INTERNAL) ILBC_SYSTEM="yes" if test "${USE_ILBC}" != "no"; then if test "${ILBC_DIR}" = "internal"; then ILBC_SYSTEM="no" elif test "${ILBC_DIR}" != ""; then ILBC_INTERNAL="no" fi if test "${ILBC_SYSTEM}" = "yes"; then AST_PKG_CONFIG_CHECK(ILBC, libilbc) if test "$PBX_ILBC" = "1"; then ILBC_INTERNAL="no" fi fi if test "${ILBC_INTERNAL}" = "yes"; then PBX_ILBC=1 fi fi LIBEDIT_INTERNAL="yes" AC_SUBST(LIBEDIT_INTERNAL) LIBEDIT_SYSTEM="yes" if test "${USE_LIBEDIT}" != "no"; then if test "${LIBEDIT_DIR}" = "internal"; then LIBEDIT_SYSTEM="no" elif test "${LIBEDIT_DIR}" != ""; then LIBEDIT_INTERNAL="no" fi if test "${LIBEDIT_SYSTEM}" = "yes"; then AST_PKG_CONFIG_CHECK(LIBEDIT, libedit) if test "$PBX_LIBEDIT" = "1"; then LIBEDIT_INTERNAL="no" fi fi if test "${LIBEDIT_INTERNAL}" = "yes"; then PBX_LIBEDIT=1 fi fi AST_EXT_LIB_CHECK([ICONV], [iconv], [iconv_open], [iconv.h]) # GNU libiconv #define's iconv_open to libiconv_open, so we need to search for that symbol AST_EXT_LIB_CHECK([ICONV], [iconv], [libiconv_open], [iconv.h]) # Some versions of Linux package iconv in glibc AST_EXT_LIB_CHECK([ICONV], [c], [iconv_close], [iconv.h]) # If ical.h is NOT in the libical directory, then it is of a version insufficient for us. AST_EXT_LIB_CHECK([ICAL], [ical], [icaltimezone_get_utc_timezone], [libical/ical.h], [${PTHREAD_LIBS}], [${PTHREAD_CFLAGS}]) AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h]) if test "${USE_IMAP_TK}" != "no"; then saved_cppflags="${CPPFLAGS}" saved_libs="${LIBS}" switch_to_system_on_failure="no" if test "${IMAP_TK_DIR}" = ""; then IMAP_TK_DIR=`pwd`"/../imap-2004g" switch_to_system_on_failure="yes" fi if test "${IMAP_TK_DIR}" != "system"; then AC_MSG_CHECKING(for UW IMAP Toolkit c-client library) if test -f "${IMAP_TK_DIR}/c-client/LDFLAGS"; then imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS` fi imap_libs="${IMAP_TK_DIR}/c-client/c-client.a" imap_include="-I${IMAP_TK_DIR}/c-client" CPPFLAGS="${CPPFLAGS} ${imap_include}" LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}` AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include "c-client.h" void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ MAILSTREAM *foo = mail_open(NULL, "", 0); ] )], [ac_cv_imap_tk="yes"], [ac_cv_imap_tk="no"] ) if test "${ac_cv_imap_tk}" = "yes"; then AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include "c-client.h" void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ long check = mail_expunge_full(NULL, "", 0); ] )], [ac_cv_imap_tk2006="yes"], [ac_cv_imap_tk2006="no"] ) fi CPPFLAGS="${saved_cppflags}" LIBS="${saved_libs}" if test "${ac_cv_imap_tk}" = "no"; then AC_MSG_RESULT(no) if test "${switch_to_system_on_failure}" = "yes"; then IMAP_TK_DIR="system" else #This means they specified a directory. Search for a package installation there too AC_MSG_CHECKING([for system c-client library...]) CPPFLAGS="${saved_cppflags}" LIBS="${saved_libs}" imap_include="-I${IMAP_TK_DIR}/include" imap_ldflags="-L${IMAP_TK_DIR}/lib" imap_libs="-lc-client" CPPFLAGS="${CPPFLAGS} ${imap_include}" LIBS="${LIBS} ${imap_libs} ${imap_ldflags}" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include "c-client.h" void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ MAILSTREAM *foo = mail_open(NULL, "", 0); ] )], [ac_cv_imap_tk="yes"], [ac_cv_imap_tk="no"] ) if test "${ac_cv_imap_tk}" = "yes"; then AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include "c-client.h" void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ long check = mail_expunge_full(NULL, "", 0); ] )], [ac_cv_imap_tk2006="yes"], [ac_cv_imap_tk2006="no"] ) fi fi fi fi if test "${IMAP_TK_DIR}" = "system"; then #We will enter here if user specified "system" or if any of above checks failed AC_MSG_CHECKING([for system c-client library...]) CPPFLAGS="${saved_cppflags}" LIBS="${saved_libs}" imap_ldflags="" imap_libs="-lc-client" imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first CPPFLAGS="${CPPFLAGS} ${imap_include}" LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}` AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include #include void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ MAILSTREAM *foo = mail_open(NULL, "", 0); ] )], [ac_cv_imap_tk="yes"], [ac_cv_imap_tk="no"] ) if test "${ac_cv_imap_tk}" = "yes"; then AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include #include void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ long check = mail_expunge_full(NULL, "", 0); ] )], [ac_cv_imap_tk2006="yes"], [ac_cv_imap_tk2006="no"] ) else #looking in imap directory didn't work, try c-client imap_ldflags="" imap_libs="-lc-client" imap_include="-DUSE_SYSTEM_CCLIENT" CPPFLAGS="${saved_cppflags}" LIBS="${saved_libs}" CPPFLAGS="${CPPFLAGS} ${imap_include}" LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}` AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include #include void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ MAILSTREAM *foo = mail_open(NULL, "", 0); ] )], [ac_cv_imap_tk="yes"], [ac_cv_imap_tk="no"] ) if test "${ac_cv_imap_tk}" = "yes"; then AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include #include void mm_searched (MAILSTREAM *stream,unsigned long number) { } void mm_exists (MAILSTREAM *stream,unsigned long number) { } void mm_expunged (MAILSTREAM *stream,unsigned long number) { } void mm_flags (MAILSTREAM *stream,unsigned long number) { } void mm_notify (MAILSTREAM *stream,char *string,long errflg) { } void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) { } void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) { } void mm_log (char *string,long errflg) { } void mm_dlog (char *string) { } void mm_login (NETMBX *mb,char *user,char *pwd,long trial) { } void mm_critical (MAILSTREAM *stream) { } void mm_nocritical (MAILSTREAM *stream) { } long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) { } void mm_fatal (char *string) { }], [ long check = mail_expunge_full(NULL, "", 0); ] )], [ac_cv_imap_tk2006="yes"], [ac_cv_imap_tk2006="no"] ) fi fi fi if test "${ac_cv_imap_tk}" = "yes"; then AC_MSG_RESULT(yes) IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}` IMAP_TK_INCLUDE="${imap_include}" PBX_IMAP_TK=1 AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.]) if test "${ac_cv_imap_tk2006}" = "yes"; then AC_DEFINE([HAVE_IMAP_TK2006], 1, [Define if your system has the UW IMAP Toolkit c-client library version 2006 or greater.]) fi else AC_MSG_RESULT(no) fi CPPFLAGS="${saved_cppflags}" LIBS="${saved_libs}" fi AST_EXT_LIB_CHECK([IODBC], [iodbc], [SQLConnect], [sql.h], [${PTHREAD_LIBS}], [${PTHREAD_CFLAGS}]) AST_EXT_LIB_CHECK([INOTIFY], [c], [inotify_init], [sys/inotify.h]) AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h]) # BSD (and OS X) equivalent of inotify AST_EXT_LIB_CHECK([KQUEUE], [c], [kqueue], [sys/event.h]) # 64-bit version of kevent (from kqueue) on OS X AC_CHECK_FUNCS([kevent64]) # Needed by unixodbc AST_EXT_LIB_CHECK([LTDL], [ltdl], [lt_dlinit], [ltdl.h], []) AST_EXT_LIB_CHECK([LDAP], [ldap], [ldap_initialize], [ldap.h]) AST_EXT_LIB_CHECK([MISDN], [mISDN], [mISDN_open], [mISDNuser/mISDNlib.h]) if test "${PBX_MISDN}" = 1; then AST_EXT_LIB_CHECK([ISDNNET], [isdnnet], [init_manager], [mISDNuser/isdn_net.h], [-lmISDN -lpthread]) AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h]) AST_C_DEFINE_CHECK([MISDN_FAC_RESULT], [Fac_RESULT], [mISDNuser/suppserv.h]) AST_C_DEFINE_CHECK([MISDN_FAC_ERROR], [Fac_ERROR], [mISDNuser/suppserv.h]) AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])]) AC_CHECK_MEMBER([Q931_info_t.redirect_dn], [], [PBX_MISDN=0], [#include ]) fi AST_EXT_TOOL_CHECK([MYSQLCLIENT], [mysql_config]) AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h]) AST_EXT_TOOL_CHECK([NEON], [neon-config]) AST_EXT_TOOL_CHECK([NEON29], [neon-config], , [--libs], [#include ], [#ifndef NE_AUTH_NTLM #error Need libneon >= 0.29.0 #endif]) AST_EXT_TOOL_CHECK([NETSNMP], [net-snmp-config], , [--agent-libs], [#include #include #include ], [int callback = snmp_register_callback(0, 0, NULL, NULL)]) AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h]) AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], []) AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], []) # Non-glibc platforms require libexecinfo for backtrace support AST_EXT_LIB_CHECK([BKTR], [execinfo], [backtrace], [execinfo.h]) # Linux, however, has backtrace directly in glibc AST_EXT_LIB_CHECK([BKTR], [c], [backtrace], [execinfo.h]) AST_EXT_LIB_CHECK([BLUETOOTH], [bluetooth], [ba2str], [bluetooth/bluetooth.h]) # possible places for oss definitions AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [linux/soundcard.h]) AST_EXT_LIB_CHECK([OSS], [ossaudio], [], [sys/soundcard.h]) AST_EXT_LIB_CHECK([OSS], [ossaudio], [oss_ioctl_mixer], [soundcard.h]) PG_CONFIG=No if test "${USE_PGSQL}" != "no"; then if test "x${PGSQL_DIR}" != "x"; then AC_PATH_TOOL([PG_CONFIG], [pg_config], No, [${PGSQL_DIR}/bin]) if test x"${PG_CONFIG}" = xNo; then AC_MSG_NOTICE([***]) AC_MSG_NOTICE([*** pg_config was not found in the path you specified:]) AC_MSG_NOTICE([*** ${PGSQL_DIR}/bin]) AC_MSG_NOTICE([*** Either correct the installation, or run configure]) AC_MSG_NOTICE([*** including --without-postgres]) exit 1 fi else AC_PATH_TOOL([PG_CONFIG], [pg_config], No) fi fi if test "${PG_CONFIG}" != No; then PGSQL_libdir=`${PG_CONFIG} --libdir` PGSQL_includedir=`${PG_CONFIG} --includedir` if test "x$?" != "x0" ; then if test -n "${PGSQL_MANDATORY}" ; then AC_MSG_NOTICE([***]) AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.]) AC_MSG_NOTICE([*** Either correct the installation, or run configure]) AC_MSG_NOTICE([*** including --without-postgres]) exit 1 fi else AC_CHECK_LIB([pq], [PQescapeStringConn], AC_DEFINE_UNQUOTED([HAVE_PGSQL], 1, [Define to indicate the PostgreSQL library]), [], -L${PGSQL_libdir} -lz) AC_MSG_CHECKING(for pg_encoding_to_char within Postgres headers) old_CFLAGS=${CFLAGS} CFLAGS="${CFLAGS} -I${PGSQL_includedir} -Werror" old_LDFLAGS=${LDFLAGS} LDFLAGS="${LDFLAGS} -L${PGSQL_libdir} -lpq -lz" AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [const char *foo = pg_encoding_to_char(1)])], [AC_MSG_RESULT(yes) AC_DEFINE_UNQUOTED([HAVE_PGSQL_pg_encoding_to_char], 1, [Define to indicate presence of the pg_encoding_to_char API.])], [AC_MSG_RESULT(no)]) CFLAGS=${old_CFLAGS} LDFLAGS=${old_LDFLAGS} if test "${ac_cv_lib_pq_PQescapeStringConn}" = "yes"; then PGSQL_LIB="-L${PGSQL_libdir} -lpq -lz" PGSQL_INCLUDE="-I${PGSQL_includedir}" PBX_PGSQL=1 elif test -n "${PGSQL_MANDATORY}"; then AC_MSG_NOTICE([***]) AC_MSG_NOTICE([*** The PostgreSQL installation on this system appears to be broken.]) AC_MSG_NOTICE([*** Either correct the installation, or run configure]) AC_MSG_NOTICE([*** including --without-postgres]) exit 1 fi fi fi AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h]) AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h]) AST_EXT_LIB_CHECK([PRI], [pri], [pri_connected_line_update], [libpri.h]) AST_EXT_LIB_CHECK([PRI_L2_PERSISTENCE], [pri], [pri_persistent_layer2_option], [libpri.h]) AST_EXT_LIB_CHECK([PRI_DATETIME_SEND], [pri], [pri_date_time_send_option], [libpri.h]) AST_EXT_LIB_CHECK([PRI_MWI_V2], [pri], [pri_mwi_indicate_v2], [libpri.h]) AST_EXT_LIB_CHECK([PRI_DISPLAY_TEXT], [pri], [pri_display_text], [libpri.h]) AST_EXT_LIB_CHECK([PRI_MWI], [pri], [pri_mwi_indicate], [libpri.h]) AST_EXT_LIB_CHECK([PRI_MCID], [pri], [pri_mcid_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_CALL_WAITING], [pri], [pri_connect_ack_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_AOC_EVENTS], [pri], [pri_aoc_events_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_TRANSFER], [pri], [pri_transfer_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_CCSS], [pri], [pri_cc_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_HANGUP_FIX], [pri], [pri_hangup_fix_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_SUBADDR], [pri], [pri_sr_set_called_subaddress], [libpri.h]) AST_EXT_LIB_CHECK([PRI_CALL_HOLD], [pri], [pri_hold_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_CALL_REROUTING], [pri], [pri_reroute_enable], [libpri.h]) AST_EXT_LIB_CHECK([PRI_SETUP_KEYPAD], [pri], [pri_sr_set_keypad_digits], [libpri.h]) # ------------------------------------v # TODO: The code can be changed to always include these features now. # These features will always be present if pri_connected_line_update is available. AST_EXT_LIB_CHECK([PRI_PROG_W_CAUSE], [pri], [pri_progress_with_cause], [libpri.h]) AST_EXT_LIB_CHECK([PRI_INBANDDISCONNECT], [pri], [pri_set_inbanddisconnect], [libpri.h]) AST_EXT_LIB_CHECK([PRI_SERVICE_MESSAGES], [pri], [pri_maintenance_service], [libpri.h]) AST_EXT_LIB_CHECK([PRI_REVERSE_CHARGE], [pri], [pri_sr_set_reversecharge], [libpri.h]) # ------------------------------------^ AST_EXT_LIB_CHECK([RESAMPLE], [resample], [resample_open], [libresample.h], [-lm]) AST_C_COMPILE_CHECK([SPANDSP], [ #if SPANDSP_RELEASE_DATE < 20080516 #error "spandsp 0.0.5 or greater is required" #endif ], [spandsp/version.h], , [minimum version of SpanDSP]) if test "x${PBX_SPANDSP}" = "x1" ; then # We found the correct version in the header, now let's make sure it links # properly, and that libtiff is available PBX_SPANDSP=0 AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [span_set_message_handler], [spandsp.h], [-ltiff]) fi if test "x${PBX_SPANDSP}" = "x1" ; then # We also need t38_terminal_init() PBX_SPANDSP=0 AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [t38_terminal_init], [spandsp.h], [-ltiff]) fi # Check for libss7 v1.0 branch compatible version. AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_set_adjpc], [libss7.h]) AST_EXT_LIB_CHECK([OPENR2], [openr2], [openr2_chan_new], [openr2.h]) if test "${USE_PWLIB}" != "no"; then if test -n "${PWLIB_DIR}"; then PWLIBDIR="${PWLIB_DIR}" fi AST_CHECK_PWLIB() AST_CHECK_PWLIB_VERSION([PWLib], [PWLIB], [ptbuildopts.h], [1], [9], [2], [P[[WT]]LIB_VERSION]) if test "${HAS_PWLIB:-unset}" != "unset"; then AST_CHECK_PWLIB_PLATFORM() PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r" AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB], [Define if your system has the PWLib libraries.], [#include "ptlib.h"], [int q = (int) PTime::IsDaylightSavings();]) fi fi if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then if test -n "${OPENH323_DIR}"; then OPENH323DIR="${OPENH323_DIR}" fi AST_CHECK_OPENH323() AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3], [], [1], [19], [0]) AST_CHECK_OPENH323_BUILD() PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}" AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323], [Define if your system has the OpenH323 libraries.], [#include "ptlib.h" #include "h323.h" #include "h323ep.h"], [H323EndPoint ep = H323EndPoint();], [${PWLIB_INCLUDE}], [${PWLIB_LIB}]) fi AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h], [-lm]) if test "x${PBX_LUA}" = "x1" ; then if test x"${LUA_DIR}" = x; then LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua5.1" else LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua5.1" fi fi # Some distributions (like SuSE) remove the 5.1 suffix. AST_EXT_LIB_CHECK([LUA], [lua], [luaL_register], [lua.h], [-lm]) AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm]) # See if the main speex library contains the preprocess functions AST_EXT_LIB_CHECK([SPEEX_PREPROCESS], [speex], [speex_preprocess_ctl], [speex/speex.h], [-lm]) if test "${PBX_SPEEX_PREPROCESS}" = 1; then PBX_SPEEX_PREPROCESS=1 fi AST_EXT_LIB_CHECK([SPEEXDSP], [speexdsp], [speex_preprocess_ctl], [speex/speex.h], [-lm]) if test "${PBX_SPEEXDSP}" = 1; then PBX_SPEEX_PREPROCESS=1 fi AC_SUBST(PBX_SPEEX_PREPROCESS) AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h]) AST_EXT_LIB_CHECK([SQLITE3], [sqlite3], [sqlite3_open], [sqlite3.h], [${PTHREAD_LIBS}], [${PTHREAD_CFLAGS}]) if test "${PBX_SQLITE3}" != 1; then AC_MSG_WARN(*** Asterisk now uses SQLite3 for the internal Asterisk database.) AC_MSG_WARN(*** Please install the SQLite3 development package.) exit 1 fi AST_EXT_LIB_CHECK([CRYPTO], [crypto], [AES_encrypt], [openssl/aes.h]) if test "$PBX_CRYPTO" = "1"; then AST_EXT_LIB_CHECK([OPENSSL], [ssl], [SSL_connect], [openssl/ssl.h], [-lcrypto]) fi if test "$PBX_OPENSSL" = "1"; then AST_CHECK_OSPTK([4], [0], [0]) AST_EXT_LIB_CHECK([OPENSSL_SRTP], [ssl], [SSL_CTX_set_tlsext_use_srtp], [openssl/ssl.h], [-lcrypto]) fi AST_EXT_LIB_CHECK([SRTP], [srtp], [srtp_init], [srtp/srtp.h]) if test "$PBX_SRTP" = "1"; then saved_libs="${LIBS}" saved_ldflags="${LDFLAGS}" saved_cflags="${CFLAGS}" LIBS="${LIBS} ${SRTP_LIB}" LDFLAGS="${LDFLAGS} -shared -fPIC" CFLAGS="${CFLAGS} ${SRTP_INCLUDE}" AC_MSG_CHECKING(for the ability of -lsrtp to be linked in a shared object) AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [#include ], [srtp_init();] ) ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) AC_MSG_WARN(***) AC_MSG_WARN(*** libsrtp could not be linked as a shared object.) AC_MSG_WARN(*** Try compiling libsrtp manually. Configure libsrtp) AC_MSG_WARN(*** with ./configure CFLAGS=-fPIC --prefix=/usr) AC_MSG_WARN(*** replacing /usr with the prefix of your choice.) AC_MSG_WARN(*** After re-installing libsrtp, re-run the Asterisk) AC_MSG_WARN(*** configure script.) AC_MSG_WARN(***) AC_MSG_WARN(*** If you do not need SRTP support re-run configure) AC_MSG_WARN(*** with the --without-srtp option.) exit 1 ] ) LIBS="${saved_libs}" LDFLAGS="${saved_ldflags}" CFLAGS="${saved_cflags}" fi AST_EXT_LIB_CHECK([SRTP_SHUTDOWN], [srtp], [srtp_shutdown], [srtp/srtp.h]) for ver in 2.0 2.2 2.4 2.6; do AST_PKG_CONFIG_CHECK([GMIME], gmime-$ver) if test "$PBX_GMIME" = 1; then break; fi done AST_EXT_LIB_CHECK([HOARD], [hoard], [malloc], []) AST_EXT_LIB_CHECK([FREETDS], [sybdb], [dbinit], [sybdb.h]) AC_CHECK_LIB([tonezone], [tone_zone_find_by_num], tonezone_does_not_need_lm=yes, tonezone_does_not_need_lm=no) if test "${tonezone_does_not_need_lm}" = "no" ; then tonezone_extra="-lm" fi AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [dahdi/tonezone.h], [${tonezone_extra} ${DAHDI_INCLUDE}]) AST_EXT_LIB_CHECK([UUID], [uuid], [uuid_generate_random], [uuid/uuid.h]) if test "${OSARCH}" = "OpenBSD"; then AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile -logg]) else AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile]) fi AST_C_DECLARE_CHECK([VORBIS_OPEN_CALLBACKS], [OV_CALLBACKS_NOCLOSE], [vorbis/vorbisfile.h]) AC_LANG_PUSH(C++) if test "${USE_VPB}" != "no"; then AC_MSG_CHECKING(for vpb_open in -lvpb) saved_libs="${LIBS}" saved_cppflags="${CPPFLAGS}" if test "x${VPB_DIR}" != "x"; then if test -d ${VPB_DIR}/lib; then vpblibdir=${VPB_DIR}/lib else vpblibdir=${VPB_DIR} fi LIBS="${LIBS} -L${vpblibdir}" CPPFLAGS="${CPPFLAGS} -I${VPB_DIR}/include" fi LIBS="${PTHREAD_LIBS} ${LIBS} -lvpb" CPPFLAGS="${CPPFLAGS} ${PTHREAD_CFLAGS}" AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [#include ], [int q = vpb_open(0,0);]) ], [ AC_MSG_RESULT(yes) ac_cv_lib_vpb_vpb_open="yes" ], [ AC_MSG_RESULT(no) ac_cv_lib_vpb_vpb_open="no" ] ) LIBS="${saved_libs}" CPPFLAGS="${saved_cppflags}" if test "${ac_cv_lib_vpb_vpb_open}" = "yes"; then VPB_LIB="-lvpb" if test "${VPB_DIR}" != ""; then VPB_LIB="-L${vpblibdir} ${VPB_LIB}" VPB_INCLUDE="-I${VPB_DIR}/include" fi PBX_VPB=1 AC_DEFINE([HAVE_VPB], 1, [Define if your system has the VoiceTronix API libraries.]) fi fi AC_LANG_POP AST_EXT_LIB_CHECK([ZLIB], [z], [compress], [zlib.h]) if test "x${PBX_UNIXODBC}" = "x1" -o "x${PBX_IODBC}" = "x1"; then # Does ODBC support wide characters? AC_MSG_CHECKING(whether ODBC has support for Unicode types) AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include #include ], [int foo = SQL_WCHAR])], AC_MSG_RESULT(yes) AC_DEFINE([HAVE_ODBC_WCHAR], [1], [Define to 1 if your ODBC library has wide (Unicode) types.]), AC_MSG_RESULT(no) ) fi AC_CHECK_HEADER([h323.h], [PBX_H323=1], [PBX_H323=0]) AC_SUBST(PBX_H323) AC_CHECK_HEADER([linux/compiler.h], [AC_DEFINE_UNQUOTED([HAVE_LINUX_COMPILER_H], 1, [Define to 1 if your system has linux/compiler.h.])]) AC_CHECK_HEADER([linux/ixjuser.h], [PBX_IXJUSER=1], [PBX_IXJUSER=0], [ #include #ifdef HAVE_LINUX_COMPILER_H #include #endif ]) AC_SUBST(PBX_IXJUSER) # Used in res/res_pktccops AST_C_DEFINE_CHECK([MSG_NOSIGNAL], [MSG_NOSIGNAL], [sys/socket.h]) AST_C_DEFINE_CHECK([SO_NOSIGPIPE], [SO_NOSIGPIPE], [sys/socket.h]) AST_EXT_TOOL_CHECK([SDL], [sdl-config]) AST_EXT_LIB_CHECK([SDL_IMAGE], [SDL_image], [IMG_Load], [SDL_image.h], [${SDL_LIB}], [${SDL_INCLUDE}]) AST_EXT_LIB_CHECK([FFMPEG], [avcodec], [sws_getContext], [ffmpeg/avcodec.h], [${PTHREAD_LIBS} -lz -lm], [${PTHREAD_CFLAGS}]) # possible places for video4linux version 1 AC_CHECK_HEADER([linux/videodev.h], [AC_DEFINE_UNQUOTED([HAVE_VIDEODEV_H], 1, [Define to 1 if your system has linux/videodev.h.])]) # possible places for X11 AST_EXT_LIB_CHECK([X11], [X11], [XOpenDisplay], [X11/Xlib.h],,, [standard_path]) AST_EXT_LIB_CHECK([X11], [X11], [XOpenDisplay], [X11/Xlib.h],, [-I/usr/X11R6/include], [X11R6]) PBX_LAUNCHD=0 if test "${cross_compiling}" = "no"; then AC_CHECK_FILE(/sbin/launchd, AC_DEFINE([HAVE_SBIN_LAUNCHD], 1, [Define to 1 if your system has /sbin/launchd.])) if test "${HAVE_SBIN_LAUNCHD}" = 1; then PBX_LAUNCHD=1 fi fi AC_SUBST(PBX_LAUNCHD) AST_PKG_CONFIG_CHECK([GTK2], [gtk+-2.0]) # build a GENERIC_ODBC result based on the presence of either UnixODBC (preferred) # or iODBC PBX_GENERIC_ODBC=0 if test "${PBX_UNIXODBC}" = 1; then PBX_GENERIC_ODBC=1 GENERIC_ODBC_LIB="${UNIXODBC_LIB}" GENERIC_ODBC_INCLUDE="${UNIXODBC_INCLUDE}" elif test "${PBX_IODBC}" = 1; then PBX_GENERIC_ODBC=1 GENERIC_ODBC_LIB="${IODBC_LIB}" GENERIC_ODBC_INCLUDE="${IODBC_INCLUDE}" fi AC_SUBST([GENERIC_ODBC_LIB]) AC_SUBST([GENERIC_ODBC_INCLUDE]) AC_SUBST([PBX_GENERIC_ODBC]) PBX_SYSLOG=0 if test "${ac_cv_header_syslog_h}" = "yes"; then # syslog facilities AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_AUTH], [LOG_AUTH], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_AUTHPRIV], [LOG_AUTHPRIV], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_CRON], [LOG_CRON], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_DAEMON], [LOG_DAEMON], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_FTP], [LOG_FTP], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_KERN], [LOG_KERN], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_LPR], [LOG_LPR], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_MAIL], [LOG_MAIL], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_NEWS], [LOG_NEWS], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_SYSLOG], [LOG_SYSLOG], [syslog.h]) AST_C_DEFINE_CHECK([SYSLOG_FACILITY_LOG_UUCP], [LOG_UUCP], [syslog.h]) PBX_SYSLOG=1 fi AC_SUBST([PBX_SYSLOG]) if test -f makeopts; then ${ac_cv_path_EGREP} 'CURSES|GTK2|OSARCH|NEWT' makeopts > makeopts.acbak else touch makeopts.acbak fi AC_CONFIG_FILES([build_tools/menuselect-deps makeopts channels/h323/Makefile]) AST_CHECK_MANDATORY if test -f build_tools/menuselect-deps; then # extract old values of all PBX_ variables from menuselect-deps # and preserve them so that menuselect can determine whether # any previously-met dependencies are no longer met and warn # the user appropriately while IFS="=:" read var val old_val; do eval "PBX_${var}=\${PBX_${var}}:${val}" done < build_tools/menuselect-deps fi AC_OUTPUT ${ac_cv_path_EGREP} 'CURSES|GTK2|OSARCH|NEWT' makeopts > makeopts.acbak2 if test "x${ac_cv_path_CMP}" = "x:"; then ( cd `pwd`/menuselect && ./configure ) else if ${ac_cv_path_CMP} -s makeopts.acbak makeopts.acbak2; then : ; else ( cd `pwd`/menuselect && ./configure ) fi ; fi rm makeopts.acbak makeopts.acbak2 if test "x${silent}" != "xyes" ; then echo echo " .\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$=.. " echo " .\$7\$7.. .7\$\$7:. " echo " .\$\$:. ,\$7.7 " echo " .\$7. 7\$\$\$\$ .\$\$77 " echo " ..\$\$. \$\$\$\$\$ .\$\$\$7 " echo " ..7\$ .?. \$\$\$\$\$ .?. 7\$\$\$." echo " \$.\$. .\$\$\$7. \$\$\$\$7 .7\$\$\$. .\$\$\$." echo " .777. .\$\$\$\$\$\$77\$\$\$77\$\$\$\$\$7. \$\$\$," echo " \$\$\$~ .7\$\$\$\$\$\$\$\$\$\$\$\$\$7. .\$\$\$." echo ".\$\$7 .7\$\$\$\$\$\$\$7: ?\$\$\$." echo "\$\$\$ ?7\$\$\$\$\$\$\$\$\$\$I .\$\$\$7 " echo "\$\$\$ .7\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$ :\$\$\$. " echo "\$\$\$ \$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$\$\$\$ .\$\$\$. " echo "\$\$\$ \$\$\$ 7\$\$\$7 .\$\$\$ .\$\$\$. " echo "\$\$\$\$ \$\$\$\$7 .\$\$\$. " echo "7\$\$\$7 7\$\$\$\$ 7\$\$\$ " echo " \$\$\$\$\$ \$\$\$ " echo " \$\$\$\$7. \$\$ (TM) " echo " \$\$\$\$\$\$\$. .7\$\$\$\$\$\$ \$\$ " echo " \$\$\$\$\$\$\$\$\$\$\$\$7\$\$\$\$\$\$\$\$\$.\$\$\$\$\$\$ " echo " \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$. " echo fi if test "x${AST_IODBC_FOUND}" = "xyes"; then echo "WARNING: iodbc libs/headers found!" echo echo " If you plan to use ODBC functionality, you should consider" echo " switching to unixodbc instead." echo " See: https://issues.asterisk.org/jira/browse/ASTERISK-22459" echo fi AC_MSG_NOTICE(Package configured for: ) AC_MSG_NOTICE( OS type : $host_os) AC_MSG_NOTICE( Host CPU : $host_cpu) AC_MSG_NOTICE( build-cpu:vendor:os: $build_cpu : $build_vendor : $build_os :) AC_MSG_NOTICE( host-cpu:vendor:os: $host_cpu : $host_vendor : $host_os :) if test "${cross_compiling}" = "yes"; then AC_MSG_NOTICE( Cross Compilation = YES) fi asterisk-11.7.0/UPGRADE-1.2.txt0000644000175000007640000002214611111616475015503 0ustar sharkyjerryweb========================================================= === === Information for upgrading from Asterisk 1.0 to 1.2 === === This file documents all the changes that MUST be taken === into account when upgrading between the Asterisk === versions listed below. These changes may require that === you modify your configuration files, dialplan or (in === some cases) source code if you have your own Asterisk === modules or patches. These files also includes advance === notice of any functionality that has been marked as === 'deprecated' and may be removed in a future release, === along with the suggested replacement functionality. === ========================================================= Compiling: * The Asterisk 1.2 source code now uses C language features supported only by 'modern' C compilers. Generally, this means GCC version 3.0 or higher, although some GCC 2.96 releases will also work. Some non-GCC compilers that support C99 and the common GCC extensions (including anonymous structures and unions) will also work. All releases of GCC 2.95 do _not_ have the requisite feature support; systems using that compiler will need to be upgraded to a more recent compiler release. Dialplan Expressions: * The dialplan expression parser (which handles $[ ... ] constructs) has gone through a major upgrade, but has one incompatible change: spaces are no longer required around expression operators, including string comparisons. However, you can now use quoting to keep strings together for comparison. For more details, please read the doc/README.variables file, and check over your dialplan for possible problems. Agents: * The default for ackcall has been changed to "no" instead of "yes" because of a bug which caused the "yes" behavior to generally act like "no". You may need to adjust the value if your agents behave differently than you expect with respect to acknowledgement. * The AgentCallBackLogin application now requires a second '|' before specifying an extension@context. This is to distinguish the options string from the extension, so that they do not conflict. See 'show application AgentCallbackLogin' for more details. Parking: * Parking behavior has changed slightly; when a parked call times out, Asterisk will attempt to deliver the call back to the extension that parked it, rather than the 's' extension. If that extension is busy or unavailable, the parked call will be lost. Dialing: * The Caller*ID of the outbound leg is now the extension that was called, rather than the Caller*ID of the inbound leg of the call. The "o" flag for Dial can be used to restore the original behavior if desired. Note that if you are looking for the originating callerid from the manager event, there is a new manager event "Dial" which provides the source and destination channels and callerid. IAX: * The naming convention for IAX channels has changed in two ways: 1. The call number follows a "-" rather than a "/" character. 2. The name of the channel has been simplified to IAX2/peer-callno, rather than IAX2/peer@peer-callno or even IAX2/peer@peer/callno. SIP: * The global option "port" in 1.0.X that is used to set which port to bind to has been changed to "bindport" to be more consistent with the other channel drivers and to avoid confusion with the "port" option for users/peers. * The "Registry" event now uses "Username" rather than "User" for consistency with IAX. Applications: * With the addition of dialplan functions (which operate similarly to variables), the SetVar application has been renamed to Set. * The CallerPres application has been removed. Use SetCallerPres instead. It accepts both numeric and symbolic names. * The applications GetGroupCount, GetGroupMatchCount, SetGroup, and CheckGroup have been deprecated in favor of functions. Here is a table of their replacements: GetGroupCount([groupname][@category] GROUP_COUNT([groupname][@category]) Set(GROUPCOUNT=${GROUP_COUNT()}) GroupMatchCount(groupmatch[@category]) GROUP_MATCH_COUNT(groupmatch[@category]) Set(GROUPCOUNT=${GROUP_MATCH_COUNT(SIP/.*)}) SetGroup(groupname[@category]) GROUP([category])=groupname Set(GROUP()=test) CheckGroup(max[@category]) N/A GotoIf($[ ${GROUP_COUNT()} > 5 ]?103) Note that CheckGroup does not have a direct replacement. There is also a new function called GROUP_LIST() which will return a space separated list of all of the groups set on a channel. The GROUP() function can also return the name of the group set on a channel when used in a read environment. * The applications DBGet and DBPut have been deprecated in favor of functions. Here is a table of their replacements: DBGet(foo=family/key) Set(foo=${DB(family/key)}) DBPut(family/key=${foo}) Set(DB(family/key)=${foo}) * The application SetLanguage has been deprecated in favor of the function LANGUAGE(). SetLanguage(fr) Set(LANGUAGE()=fr) The LANGUAGE function can also return the currently set language: Set(MYLANG=${LANGUAGE()}) * The applications AbsoluteTimeout, DigitTimeout, and ResponseTimeout have been deprecated in favor of the function TIMEOUT(timeouttype): AbsoluteTimeout(300) Set(TIMEOUT(absolute)=300) DigitTimeout(15) Set(TIMEOUT(digit)=15) ResponseTimeout(15) Set(TIMEOUT(response)=15) The TIMEOUT() function can also return the currently set timeouts: Set(DTIMEOUT=${TIMEOUT(digit)}) * The applications SetCIDName, SetCIDNum, and SetRDNIS have been deprecated in favor of the CALLERID(datatype) function: SetCIDName(Joe Cool) Set(CALLERID(name)=Joe Cool) SetCIDNum(2025551212) Set(CALLERID(number)=2025551212) SetRDNIS(2024561414) Set(CALLERID(RDNIS)=2024561414) * The application Record now uses the period to separate the filename from the format, rather than the colon. * The application VoiceMail now supports a 'temporary' greeting for each mailbox. This greeting can be recorded by using option 4 in the 'mailbox options' menu, and 'change your password' option has been moved to option 5. * The application VoiceMailMain now only matches the 'default' context if none is specified in the arguments. (This was the previously documented behavior, however, we didn't follow that behavior.) The old behavior can be restored by setting searchcontexts=yes in voicemail.conf. Queues: * A queue is now considered empty not only if there are no members but if none of the members are available (e.g. agents not logged on). To restore the original behavior, use "leavewhenempty=strict" or "joinwhenempty=strict" instead of "=yes" for those options. * It is now possible to use multi-digit extensions in the exit context for a queue (although you should not have overlapping extensions, as there is no digit timeout). This means that the EXITWITHKEY event in queue_log can now contain a key field with more than a single character in it. Extensions: * By default, there is a new option called "autofallthrough" in extensions.conf that is set to yes. Asterisk 1.0 (and earlier) behavior was to wait for an extension to be dialed after there were no more extensions to execute. "autofallthrough" changes this behavior so that the call will immediately be terminated with BUSY, CONGESTION, or HANGUP based on Asterisk's best guess. If you are writing an extension for IVR, you must use the WaitExten application if "autofallthrough" is set to yes. AGI: * AGI scripts did not always get SIGHUP at the end, previously. That behavior has been fixed. If you do not want your script to terminate at the end of AGI being called (e.g. on a hangup) then set SIGHUP to be ignored within your application. * CallerID is reported with agi_callerid and agi_calleridname instead of a single parameter holding both. Music On Hold: * The preferred format for musiconhold.conf has changed; please see the sample configuration file for the new format. The existing format is still supported but will generate warnings when the module is loaded. chan_modem: * All the chan_modem channel drivers (aopen, bestdata and i4l) are deprecated in this release, and will be removed in the next major Asterisk release. Please migrate to chan_misdn for ISDN interfaces; there is no upgrade path for aopen and bestdata modem users. MeetMe: * The conference application now allows users to increase/decrease their speaking volume and listening volume (independently of each other and other users); the 'admin' and 'user' menus have changed, and new sound files are included with this release. However, if a user calling in over a Zaptel channel that does NOT have hardware DTMF detection increases their speaking volume, it is likely they will no longer be able to enter/exit the menu or make any further adjustments, as the software DTMF detector will not be able to recognize the DTMF coming from their device. GetVar Manager Action: * Previously, the behavior of the GetVar manager action reported the value of a variable in the following manner: > name: value This has been changed to a manner similar to the SetVar action and is now > Variable: name > Value: value asterisk-11.7.0/images/0000755000175000007640000000000012254071122014606 5ustar sharkyjerrywebasterisk-11.7.0/images/animlogo.gif0000644000175000007640000017474010343116347017125 0ustar sharkyjerrywebGIF89a]då= $!2*+2B99,F*8M!9c8BS)Bi2Dd)Jt4TzIIIRJJRRJJRZUUURYiWevdeghkvsksks{xxx4V‡9c™9k¥BZ„Plkw‹Gs®J{Æt„–W„¹r°R…Ël“Ës¥Þ‰‰‰””Œœœœ˜¬–§¸§§§¥­¹¸¹¹„œÆŽ¬Ñª¼Ó”µç¥½ç¸ÉܲÉéÊÊÊÎÎ×ÊÖÚÖÖÖÑÛéÞçïèèéþþþ!ÿ NETSCAPE2.0!ù ?,]dÿÀžpH,ȤrÉl:ŸÐ¨t*äY¯Ø¬vËíz¿à«Òv*›ÏhsjÍ^³R¬¸|.wÅíxÞÅïûù6.6ƒ„……`iù’g¬ Br¸ À )"Í’sgÌ“>u`À•©€`t`UshN˜Bdªñ™c@W°0Ȱ!ÃRiš-zµgM|M `Aˆ?lèÐѧ˜³<#Õt!¸€ hØ@‚D #0@pQö1I«ieMª9؆5ˆ(1bÄ .¼r<Žhɾ’XÔŒ À@‚{€¡A„"DèPhU£pj"€y‡#@|øÐaÃèDðNù*´ 0ѹ3}ôUL0·¦ŽDìñ•ÂÑ4|Šá·Áb ž°_ PWohõ S5y@t ÿã‰ÐA@@€f*8ÖC€:™ôFv4± ‡P[<‡@P Â ŽIÕ^Z”øçÚ#x£€ Î嶃Š,Vè. ÕÏT¥Ä…€A|`ŸÐ5<¨ÅY?­H¡‹Ò á‚[]q…jH¬P@ pß‚lÇå—ZÀ_y €¾ñyåGœÀW¯!ðUŠIðÐ@hÂfÐU—Th„ 0 ×0œDüW%:ÒÄa\¹U€r}0ÁÝÑJÄ § (FŸ ` „ ˜‚ÕlPàœªCX' …¹"JÙ¥4À€a"vÿA´I´•ÀÌnÖÙ  @)¸Z@‡P0ÁÌF(ÔC‚[G@— ÐL§G ›Á\€P‚ @A1¼…åÕ'˜PDP¶S%z ÃT¼>·€¨%@@ÅÁ¾ÓC4À'6 *ÀqÿrfŸxêJH„¨Œù[ZsÜ+DD7f.) ª0Öì1•€ÍzÆcp»¢[OÿÛA}âi@W‡ðɃ¨Ø³¤wTC` —{‚¶@\‚P/-Ä ûÒ7Âs»!A`tð@õ™§Ay6>¾f¨³•»xÍÿƒ[dÐȘÀ}XDðîÝå5‹à(ð:΀höø¡çX>ÂՇ܀Á)9„ wÔ\ÅW²Ð,p×"D€#P@—ƶ¯Át¶ FÈ£Žˆ‰' ꌒ˜´0 9˜:6a>!(@>ºk@näs ”àŽƒÀaVg?!‡3â1‚ Þ’€Ï™©.ëÌçöÖ™<ð 8 ÓîÀ"x@…‘ÔW˜÷Fƒ@À0' õ@€À³¼,d¯‰PÌD3& ÀϨl8„‰¢`äÛpPœEBwÉ€™^1?Ã,ÿF ô *ñ¯¢ ó¹]O† @᲌gÆ~‹|~(‚ À @çbÀÞBƒG»h’KÔÀ”Ƨ Ih\Áä8$ Ào^$€˜R‘q:‡Ö*dƒjlbU°MTy˜Ð@`‰žL~VG–`uÁßøPÅ!¿Ñe¯” bJ@ .V,B#·Ckx­V)@°5" ”©u™À"p¿ÀÄ @\°ÕÞÀ-ˆÐ>$eÖ…#€À$VEÄ‘[ë$ûÐ)¼B7–3`©–‡ÂÅLl4@é0p¢QÏ5Õb”çJ‰™1ÿŸóÀ‰ QH0&hȧˆÀo$B)‚Žù-Bc‚@g>Ë0G1àÑdÈ35ÂN²ËrRT :ÀLJP‚Qa‹>â©K)F‚|¨Cˆyr¨Ô ÆR‚ §ÃñaãœÙÁ \ '™ÒC˜â771‹Ñg+àCVKBÜTÀ†OT7©­lcrL0Ù)NvükMnG©‰qY÷Û"[!»D”5‰Xd#¾!<ݼ¥Jb‡Z™¥Åœ€ý&Ä”£·ˆò $=Ò$ÀÐVDëˆè@&0€S éÀgd}ÿܘ^”V Ü5œmyYîB!ýhÕ¥0àSÎTN°#ù‰YM•Nà‚äµ ñÍÑvý 9#Ü€9ÄÓ~¿‚€OEŽ ž%Ý€±Tî“ÀÂze€,XV!0È9> 'áÐp`¸ô•×0G ò# 0€ù=àq.ÆVr: £°• OèÕΑ„øvµÆŸ¨° $à4¸€Has #1ã@€@iÐÄ•#Ó\:À.9‡@Àv. <ØÊ´qBeËF“ýjÀ]î‚ ðmÊèÁf¶7ß+¼ èXo?PçÄR`˜tÿå¤%W¢Ùï³\„ÑeðÀ’š6–M/eßÜ@ÛÆ7€#SàEè4Z— pyýˆK½œƒ'˸æ“'A„­Ìè;éÔQÇLÉ/‚³ù*lþ8tˆØä©tî2ù…Œ+ÒZ5$ÌK` æv½Š@ ¥½ ”<(CkzŒ0jÀ‰<°\0?ƒuÊE“^Ž  (ñaÖ, ÷ª Ñ-P_&x@ð¤3‚v²3"(­VÈ•ö†V8ÀL.ðÚ„€K°Øˆ\9 x +x &¾zƒ5.fJÅP¹¥rh–Ô:Ó­pÇçt¶øbPÿªr1C[cg> þöAK#¢}CŽ'…+ ð5à04 K´Ï20ƒ#è×Ε{ÞT |Ê•£<ð¥jàm–i fq! ‡£[Š*×~ª®¸ØbŠ)OÂY„0ªÇ_á’Ý\ò 0B:‹o’ÿ`{p\¹EgZ7ˆÀå(F§¬‹©sF—ý!ÁÚ˜ÜØ\àÄ!”è ãñ%€Ö¶ÂÒxWZà *Ï˃ˆ‚,rôß|FŸŽ{U“ (>ŸY h~î΀æDŽK42¬ÿ$O$7ʸ¥£Pw§!g9 ¥*C³:òfÒAd9‚¥õC|KBf[Uvòñ0Œ…Ñ1øQ´r!kÀ}º7 FšB4" .=rjU )fÓ+C*Ð/cº¥It£> µM3u%f@„ed GÎñÌÒæ’-ˆRM!>H/ÐhÍÒwI Íb™Æ1$ uîq(PyÒF ø—± c±Â!KD%ð8ÔGKpÒbJ´1`]­pd˜fˆßu#@m!ñ;SWHM2* iB¦ó0àQZjQ¡€FHÿùR:# *€ýBCËÂ|Oð}K`Qc¨jãvã`Cà dËÄ,W&ÖŒx‚H€Ñ_.¶f2*ŒE16̈Ù¶]§S€o—âÖZ¯»¦&Æ Îñ»§<Àg€D¢bxÈeÐϱ]£˜·Ã%¯€îã>rô,ˆܸ;ýàŒ˜‘(q;#÷L™$vÐ…VՑ̰‹'¸ŽQp;¿2çÂ!²‡ž1£ÄAˆL3 0°/ã>sáZ A å0†äÇ03GgS IPèíø‘ð•>ápƒ!0k”ãÐÁÿ<Ù.IQé+À€«sfæQ°”Q`Q-i[…(HA#  â±M …[¹–CB@2 ˜1`—TÀŒº’u ˜–™…©—4E@q™ž ~=ù”‡ù™Ÿ™™Û•¤Iš[ù|âbàV ¶²¹ƒóÿ‘„SS Ñ›Á Ñ ¯ð¼´Ç€›‰0›8@\a¾ð/ªÁ»S³Ö‰ýâ»ã“ã³rÒ-+‚5õМ´E[ωqÑÙgÀ tÄ ™Õ %’É™@18㩹œ÷àœéië)fŸïŸt$œÔÙõÙ–b‡`7pžÄà›è¹ ÐI:ñ î™ €™æô‘ ÑÀÎ0Ÿ Ø/Š7ЧxÃ'£þ£0š#tgŸBÿð22!¤B:¤DZ¤Fz¤Hš¤V9 f,;Õê¥R*ˆSZ¥V: îõ{ež\ÚŸqæ¹¥]Ú¥[Ê Rr²¦r RÁ ž/Ó¦rЦsj§ÝcA!ù ?,Y`ÿÀÜox ¨cr¸<:S¬_têü¹ª×c¶ú³q¹ÂaØûµQ¸'¢:Í…þR_©+:¤Çï×ð½{¿91lpmo'‚uGpp,.)YWp[[G6.”dU—{q™UF†š_ŸRZ‹CŸ’e?z 96=G~?l_•C±“ {Büèà2C‡ H€(QoØÉ#…Âi“o@  ý±Då Lß{†ÓH"Lа)Ò£< ÚÆ qâw$HTĈ·=\ˆ°š[×(y¸{€!‚‚*0L=a‚: &aF` XСȃÑkÛÙӣŹ\R‡ 8XŠp/n`°RË4r¹ àü´4݇ìñPHH €e?xdÔtGðCH (0@uq³‡TF ÿV'<`À„àS…‘ÁÔÒQ™åt„\ÈA@áÀ…€,0AòH â0ñtG4—T-‘ÂM{d·Ð^­U“’N@˜^, ÁÅ= › A‡qARÐäWŒ\d1wfPÙlY¦ Ux3ÑxjäR €ÛµDB;„:AàZqn0X 8hâK a™dxdM—ªè „Y\Œç˜!e0Al4RKtÐ@1q Ù¨ESœ±i¼êÙà[¥åçÄ*ÔɘQn`@°å¯„FP”VÙ`<€F?j´ÿ‘K”yðA`V¤dá² „FTÚ` ä9“¥*DðôäLI‘0Bô¦ñNòµTÚºu5Qp9Ä.œª Ç¥8Á_d%˜Ã (ðQ–%`*~1A¬ÕrÑ}!±G6 @…gßRwx-Q|ÂC^|pÌh“ž-7×)H_¨ÓR@ý5íY@0Ó#PP³?(¥R/Ø]àäh) 'ÿL b"\סUšd_ÜpËÆNÊÂ…ü¸ÀHÊA Á`t 5jšgÔ)ÑU¦têÒÒ+ÕÑQ³{@å9ÜRîøîñ€ÜEÙ¯¬=TqmÅÑiRÝ$”˜hÀX‹ôd©|«ÉÞæ6üãG*òˆ¾²¨’¬¥S<ÑZÄä@Õü@# @šc™ l$`K¯Ôö³|¡"õÒÐ|e)p™2ðà %#ÒwN0›NA ¸ØêÒ´d.™ îÀ‹`Ù€ôÂõ¨ô¥zZSMµ¨´`qÐü‚¾ÿ+†A œŒ* J¾HSRÃ’€WC‰@&É'. lZ N 2ã:ÁÉA L ‚O•¦ Šù´Á `+Љ”Q‘0rƒˆ´[Š(>KÕ"Áê8hp€4°¡:VR0!fØðÌá:®¨À]GÐ@š‚·|lá Cø¢òу٠@‘àëÈÆ(:„M(A×;üq¿À¨€LÄ n€Cm`Ó ®…´2€þü@B?ØN"Ð!#L F’À1"<5@câˆ5d¡#€þH)kÉ¡âµE=D.SήGþioGX%0ä6†\ Lÿq,ÀBtÕÒh`‹À"ד @@qÉaˆ€b¤'@Ñ2(Ìmêð€„F@ |•)LGpÚìL§·‚ TÀ¯p”¡ùv,x' Ê ƒ ‚5DÕ':Yh¾£Ä+ <ÀH€ø‘‚0¤ˑͭ¶‚€tàÃ|ÒóiU ðÞdúðÕ(hJñk0°ŠH 8+ìO‚ò 5Àe ™@誒Äq2Kn™Žž|$$B@vå—¾>ðáÄÄ¢¬åxÃÖz:0ØÈJ& 0€¿`$L bDj=Êcbƒ°ûÔñ€5òÿÀI@±¬¹Í]–²®s‘QªÉîÐ!ºAë@”òvHàbç3J¼~å`BeØHG º@HŸÁÓ7=à«ó u]#2 `ë)è×ÅzÕ´x5OIû@ ðñ€ªÌüq$|¦º¯íKa¶È…ä4:àád#àâÌf%ùÁ$}úõÅaM#øÕVP³G½C>À›lßaº(…ÈOXòÑÜæ„…ttcÈwð«"H͸ØìY @ &òh‡d€àµöUT–­\…k"ðx\e 8F¬>`Î#¬j³@•ïŒÿ{à <€p˜k%€×NÀ«ÁXÐݺàUV0N¢PEîaij•Qú…Î*@ÀL%Š¥Ðj‚^ »æºøôó“ðnuî¨Ê@¤8u`í m†R}`wQO¾)RÎd]6°“šp„«@ ñrÜݽ! ¥€Æô Z…á<àln‰IЕPÈb(b ‚¤Ø'äsî¸}†{pÁÎfœ°:ÂÄB½Q‡š³YOhÄV_iNXsÑ©)‡Oå€.ëpèø*0ÕËæîp—;¨À½9*×PÏ‹ÖÍiÊ™@h_[tUÌFj¡T2j­ÿ )~Ô^SÔá“àxqˆ‚ž#ƒba͉ñPÛå`ŠÏzÀÐÛgÁuÿrƒyjdõhÅ (ç£Øß@I´дÓ5 Ÿ€%ÅqŒT‹A®ùHbQŠBû¼e;ŸäfÄ'd¹ÕÚ_ȇgn! €·ßµÆª¸ö‘r> ¸|€n:š=7Â)µu²“~9A§>¬ø¸¿BÇ’¥ÚþRH )üƉð§¡#ÚçR#PA¤îµÄäÓJXN§—å­7GPE·O#˜ûUÑ5¿Œ)Ö9c¡ÃS=þ =–Q*Eyˆw?€%€ ù‘ññWEðMå€< 6°*àûwˆ×tx‚ºµ}'è€áö·‚(‘L&ƒ¾ç6/É B ƒ¾à (Q‚ôУÂ×€vÛp~q€Mps€MˆMUw­A„BÈ>7Dƒ½% ä0 ¯€íã· ‚?À|Ê” E² È<òkVøF( ”µ#2t_Wp/+xd5Ë-ز(žEPØR²qˆÕ¡(¥7\×fXXÀP!&X‘èh•‰Ñ"7‘è€M€QˆQ0ƒõ †Ê`„™ Š<ò\ôªH…«t B¸…ã0*ªØ†¶8„š!ù ?,YbÿÀŸð·ȤrÉl:‡Å§tJ­Z˜ÓP+äþ¼ËÔO,6²ŽçaérÚ†o+JXž—¯øknïbºI`JkI,„?‡R{yJZ‚T‰thOmB9}O<ˆø¡fƯÊ5‰§‡©~sæ °Àç#(|Ðø çÑáïH½¨~ÑD‡lÂÒêÁÚÈ/ÅEPûQw‰å08@‚2‰Ól.Ùá"„ÕÂ~ð@Ž(áÙCDp¢ÂÀ X{oЃq™D¡6Ѻøˆ‡(bÍÚÔ>Òt£;xÐvÁW)Äg€t°DêL‚„BP@AÙÐÄÜðÐÝ|@ÿÂYFÔ`€t—]6;˜"Öv!@J aW Òć’ðC14¡£Œ  L€€ô1%\ŒG@5EE- L¾7ãÓ cþ°P&‰::Á( AO?€D JrD ðd5YhS[°OÕ°Ác|€f*,‘£:€@T¦6eX)o¬Hðe´)E% @—°–óO4~p–„u*9@À‰tT”Q[¤Ð,Ë!PPA£nÀÁ“YxPÁ I õ€d ˜%$„Yÿ@W¨ÐQEÂöÞžLÔáº{•0Z¦Æw“Ô”„  ?|(C·?PÑPðï'ŒÐAhŽðC&aÒ‡„d£ã›’ùA'0Øš+AcB˜Œ(@КjZÔ¤s“3á*TÑ€*QP© œ|@*Ãw-I©f@OÛm—„8 4 ^Òt¿ ©Â® :L`P#”P dnÐQ6^Òm@¤G àßvµQ„Ê?¨<ÂWa|"|¸é¼¥Áí „P¨À *ŒàèÜ9¾%ñü’š"ˆ–9þ A5u…TRY¤¹}aÿƒè@ñ¸u­A!tð5—­s¹z,7à6Å£H\VÓ×_·.AŠš€6mL$°€–IáötW @œ>ý Äå!€BÔz¿*:µÔœã–han‚Û¼%ŽZÞù¾Ç@ÿô$(Ü2@hE&4dY<<`hüó\\åè* —HB¬èÓÐL¦Q'k ¾Â©”Pªf”É>`•H ßa ðG ñ!G@¢ž¦ ƒÀÀmÁúž8$‹éLYÀúP@P@9 ÖÀ p%l€ . 6¬p 9¸ Tp‚Õµÿ[”Å¥Ë8 `=2Ê÷Xâ‚B*ñ {Øž.lÀ‚ŒP%ÐÜY`Ä­u”ùÁ `pƒÿ—ÔñáBÌд4 ÉÁRì 0á:” !ÃS³Tš2TÀaU37l˜0á! PEP‰Åª‡B4øðÁÄ2Ð0åJÚŽeò娢¼îTÓ#®‘ƒp‘àkBæ%,Øð„Ž€¡aC‰'ƒ~¬˜l¤ršdr0@ðÈŠ^IŒh€á. ­?Ôh‘3g0Ðæa{È\'î( ã :x@Öà¯Mñ#œeæíÇLtî@ßjaþdP`G`0A¼µ„ C¼cŸZ‘IДfG óÙÙPPÚUd°ÿ@PÀDY@ž hpË-ÀÀÔa#°iIDÑœI\(D<4^eãC 0@OFT0ÚmpÜUK¸àŒTu°šœ@Â110Ž¡@PãŠL%€6>Ê&€YET‚.rs Z6"@gþ0€RÙظâ 4£<(PÀp`Ótp  ¼ø øQzÖQƒI"ÖNH€Øx 0¼pjd:3Àu”àCd%AzKLê•M`Àg  €€ öxÄ.\Õ<ÔÀ 'Ô1~ì×Ì®IØ5Ѩ ü ÿ`¹! 4à 8€O”†F¼wJ@€t4Bt`;4`‹E?"èÀÔ:¤ùG <ò‚.0À™ !70ú6ð€  ›VÐ.ð« „Gß(€àcÕ⎆dB9`MlÀ¨=“¢’6\bî¢@ OIÒ%„Èxh;/2’‘ ÀŠ,#7Þ€J’Ÿ`X€ràÎ]`­@KTÔœ *º |ÃP 0ñ%âšÿÀ9'WC”È4‹HÚ:P€ œa'À D5*ŠÊ&èÃÜàÆ¼´à ƒ²¢Ð”CÇ!¸˜1lÇYÄBT¬dé÷ºTº \yà™IPIK•€ò$ŒO“XMçž !Z @À fAu$e(V‡Æ¿‰<$taMÄŒà‚I'i"ÎI:ïƒbž>ÃtÕOjÞWÐõƒfà–G`K‘ mlG‰Ò&>Nð‚î¬&·¼Ü¡LÀyÖ_D –’hÕF[Z&3Ð%#À¡£}8‚6à”¤ ÜÈÒ ^“®òîäQ^ÿÁ쨺ŸL 5ÈûJV…SÔhΘN ¯@•˜tàeÍ(˜©šH‚VvÕk€m L¾+êG$P UlFøs|°Ö`M„Bð·T€ÇdChDŽ’€ŒàDl5%@_Gµ–L@•CÆS"€?ª%(X2@fr¯ dÄõ1 "„ ë*#ð«“ç ™/Á%?˜ƒTh/" SóP?zHµ2m¬Qdhˆû”*@Æl„ŸÂ‡6@Éex…bHYtxA&‘ | /H›sš:‚nÑË| ÌC8  ÇV TùÀ<ô71?„½G@3ÿPT½åIŒN1«C7M4µ<„6K˲—à¯(aÍš¥ß9ê!C‹KÀ`í`Çã6P])èÒ#8VÔ{å0¡KFÊG8²I|,ÈRƒãŒ Ü»N³“! ˆà*&€õµu¨ $pF/ëP@ Â@Ò–€‹u#a‰PA `K[z²$ð9bPkæò±*Y`ˆ™m™Ë¥Hã1€ 0€&eE±"ÛÈ›_/Í1-´ñ«Œ. ^(•‡Øl ; iýÉ<ž…í l oC·–€ã4쇣)î„Í‘Q} Ù‰à8FÔ½ÿ ]€43Y@ØÑã¬ÚETc±Ý‡€-8ÁG¬–ßaééFLK#X¹gÔIËEˆ€-å‘À]&b£³¾®‚Oi80wƒnè”ÿÄ”/JÓrCénÃK׋Ó`@#XØÐÒ ‚ƒÂ;´Èxbj6„>1¼ žEÅ|àÜIϼNn°ÄØ øÂO>- ®|Sð¢éÍ·Dî£_T§¡:@¾$t°—gÿÚw„¼˜ ˆIL"PB(ô™€D&L–{‰ÿ ­êÔÖrþôÉ_¡ÊÊ6¢ÁÇ|¥€wNð|µñEò´e]P¼Ò~M`€”0=`ãCOU.•‹ÔQ“…e±f" $h}é§€ H}F@z µzÆ*f  ë§‚jp8<~Hƒ™@=p~<øƒÔx~¢€G`C ®°„EPøEW?!ù ?,YaÿÀŸpH,È£K¸lþ–ɨtJ­¦œ.–Pûãn«`$4LöŽÉè´ú—b¶]Pï—è²­¼»xºSµ.WOƒ~R9czñŒÎ¾#Œí*d Þ}ÿL½-[D®?ÀÅi8pÉ«`@ó€@v§—¥úË^/Ô@K÷d²y›Ê»Á<#ØÐÇQ x·žX9'"Ê…W-¶`ðA à'"„h6ÑCÛEî}Õ”|Õã$€S€sÓ]žV€ïü@eK~¶ + vØOjP°¡,.éó€y®÷àh,{ çÀ¢©Mm#¨›‚F0§ÙAfG°ÁòÀ ƒÌÈ MéšG‘´¡n›ª<ÈÁ¹ž¨ †‹Ø‘r C ]ËÈTæAlðz­‘A <•†Á)9ŒNpVŽ ±éˆ!Ô¿E¸#ÑJËÛð‚üÿ1¤Àã ŸEa cBPàð´4aQ?Pb!z€˜£tC€‚H‡ 8Gk°è‘gÐT£-'¨Áù"ŽaÀ3GÙ rJi RáÛÂ3|³€h$  À[¼92¨-Ê# š‚2°­,à›¦¹ÈQD’>2|q †‰Oº27û½KHp=02–ġ޸Ä%|À1ZÐÁÈ¥ª€È[Ôa ÑúÐB„ù&ºfœÐ@C,UÚv˜®mÅPÿ†2p|cµ#ÜSu,Âò¢ŒL_#  çЀÐàšèJµŠ°ÉÉ2Q€xšò”Lg†`‚ƒ õŒiE=ÿ*(B“ã›lð€T3pŠ¿Ì2æ ‡ÜÕ(àhïJÉŠ F"¼b€‰ <ê&)  fb'˜h-i€2Eø `œ"/ænÝ”"­aQ#ð7IG‹\ݱŒ'89…`€5 Æ…L“ìÏPˆBËÂ2 °À‡p \Q‰Ð.˜qˆè""AîPÕl£‡A”Ô°‰dK©’ÖQ„*7ÀÓCÀvM9òÿÍ_FVšæ‚+ÀÇ1“±Œv €{¹@ $£HPÁää1Xå²|Ö®gvqq#€‡ˆXS6ƒôÁ_Øãû~K  <Áx(]Óì'ÅŒ\) $üÅKçÁ¯<: ¢Á‚àÁv@"M¡pIH'(Á€'G èl˜V$ E.%¡Ñ(îÝä1«@æ°Â^‰`ƒmÈ ² È2E YÓ1“ ÕqÔ1rx“GóæD y‰XP‚Tøg5B:μ €/Ë1ÀÀ°ƒ!Ö®8Ò€úî&ØA‘8³AtÈ& zÀ»FHÿ;@’5 ïˆB "§Âßrod8eÎ p7”u€màÀ—°“Å„ ±k;ozŸ°)~͘nv.†j)”°?(Ž‹Žx$-?€T¼¿¤è‘6µ, I'uŠË.Ð1ÉÚÑJ‹t©Àh ÚdÒÿ‰à.="ò_G‚iÈ©‹ùŽS!€t±l—øÞ–¥;®w ËbY` ðpé¾ÄÎxfgTŒÀ\ë<@xÁ&ÞÁŒb;û¦…  *žïd`ñ‘ôÄ ÔòBè@ð@¡¬€´ïñ‘WáTÀ0#ÇÆÓíNûÚÛþöšÇ½L¶Sø5‚6;HTvâwþ? Ct€ˆà!p¸ƒ†€ ¥ãúPKFéŽ?„ä=ûC‹Ëµ¿lò—Bz°eÝF…!5B@èÈm:„ÞÓvhv:‹„ñ!æóW~aÒkÆ[F00 ‘W}5è eî±û€8N‡q<ÁÙ ^£{B@Uà[G€ @Ǩ¢0§ÉC¨~ݵˆÐ< ƒ4ˆeG– vA 1h¡†1Ñ1èƒ<˜ƒ>¨ƒG!ù ?,YbÿÀŸð·ȤrÉl:‡Å§tJ­Z¯Ø¬6iK¢¶à0²;½²:!fKÌ}x¢<¾aQÖˆ_?üjà$°–N$X!1 5š<c5ù6Ê€-h+˜ô`'à„UÁÒšYI¥ L€j¤í#‘ 2uÀ@ùPOÐ;°¦Y,{Œ¯ït"ô6ÙÁ€?IˆWü‘ÛH)¿;xx0ñDP&Þ$ưBÃ{ ´)Áôú·†êN”È0/‰¦fDwF@ðC$0¤HÁNJ|B”„{$4Qÿ cDhF šÑ$© Ò‹Ü1ÀH¡†ªiz¨Ðᜠ”ÓAf¶Ðÿæ Ì'D–@þv@c¡62P8„«H\I` U"V¶®yÂ"¤ÿD%&99ŠÁ°Dˆ‹iTÓÐ IHÈ ëZ‡`-8¸h Àô2 ÓüÀ"H†ÈÊ=Ð!iЙe~0€VTâ `AcG‹ÀY#'0ÌÖ©!,üQD )Da 7s H†!? £•LbD&TiPR8C)¼*çÕâ—h’³€U† 20FÎYn$‚iE`@‘f"U Œ?ºb€|¥²¨g&;÷ƒ,IÈq^“`st}‹‘N?Šò¤jî ž`žà¢6;FÕØ¤¼cµ{Ó Š–”ÀLxÂTÆ2H<âÅJ&ÿV• øÂ „y˜Í€$ ÷U‘Ä Š5©$ )PÇ dCñÀ¥1l2C„4E}L ÚòW4Ͻ† æ8€,!@gI@Æ. /6æ¨IbF°諦–c("Ð'Ë´Ð@%ñ ¤ _q€R6Ô~ abƘÀÜ" Æœ`©-Ác6‹%ÔÑ)ŠŠå:ch€hº™˜ÛˆâAài,€œÉñ2˜M…`-QA»˜“‰"Dâ"V”Ÿ¢Íö€!xMfE€Çþ` ÒXÑj¡¥ æ‡jÿ#ãÒ¦@A­íÚÿ*s~ ®í*áþˆÆÁ6p×!„`F˜Æ8÷ÝÚµ©ŒÛ¡ÀM—°ƒQlHHÁàÞ¨!Ô‰$; `%“ˆIŒ8!8€FÀacuÕ ,‡ù=$H@ ø@&—ð±ø\FMS'€Œ‰°®<×|d(aé3Ë%‚!¯î:ë6‹ã H`AU­ z`«N€€Ö$L@N&¤â¼v¸`‘œ¬á:æà ÚqÁ4çÁ¸ªd <ؤ1= Œm5Ëø€·à‚£kØëUM8TXªHúM¢”@Ï¥w¨Ø$ D„&(ömLAŸÿp+²¹4ˆ¦Pø ªZHâõ8ˆ+¸Ø=‚9M,ÌF.1Fj»{M A@õÈ`’EÀÕ ðS–°#aï P1¬ŠaOÁÆâQÒ:@ââdë€$÷ô/¡Ò»ºG›7h%@R Á²NßàXÀÂùJÐYÇa àŸ€ut{ ˜p ¨&æàGУ•pÙ!xrg@P &` àð í8¢N< †ÚøÇÐ#™\6D‡8ùvÐËÎMDM¤Ü«ª¬ª-ô… 6(à²$€$"˜%Ðs0âXØ‚b¹I`H@€!ÿr4¸Dæ3ßV§$Œ àHµÆ»³Ðu>줨É$,€âÙlëÁVƒUšu-¨è¡¡ÄN›oD`–û¸Â Jñ€dS\ÅBƈ"l-¸ä³{ðÀªP€ €ÔsJÀª1ÎŒXð]=ùÀ÷AÜ \JtíBØ3$¾1ˆL»÷`{´€=ñ|è;ðÕ@˜ßÿøÈ×BÓ¯Ñ;äÀo³è ØïA.L¦cA,j!_”U•¨0*a9‚ñ¥ðç ak_BÃr~` ÝçÁ]bûÁdv0K”JÀ/Ö•î—Ëw‰!Qäwd`&¹ñ`(¡ x‹sUOÑvï$hA´ÕoŸ–|–ƒyY`Í—|N°|h”|§3ˆÀ¦})ò=P=(>ø¹`;(cqƒbÑi>¸„<ˆƒ?ØiMˆ„I!ù ?,YbÿÀŸðÇȤrÉl:‡Å§tzd ­ØŸ•ÊEž0CTxÜ̲Ì.aú·V+mÎÜPÞ= í?;^¹E¶û]SpOx)I‡M‡[gZ[mnF6o]b”F`‰~ŽfRƒ?6tR¤?t{L7œL¦SQK=§DE‹¬¸¹R<99²ºÀÁK9E°^Âȹ¿ˆÉIÆÍÎÐMrB›Ð®³ÒP?â?ܺËJb©ÁÖ ÷ëÀ¦¡ìha¶ x`_ˆÍžyC²Á½ ,(€a‰ 03æ/Xs÷xè!C‚Ž?H|L¢xÁ |0âCKÿ< !ñáÃD!¡l`À„ 70È&S„L5…Ø20Ó6€dЀ V?¶ÌzI>h`ÀàΊ¹ Ûv¢ŒtÅ…!€ Á€!‚Š«.“ñ˜¼õJ²” @Øñ#+kk„΃ "xTEQ‹JêA™‰R#Eÿ'e ~| ÑB .ènÒ£…e&Ehspmõ&-,˜{A B´ç„r}I1V@ÿ(RŒ{ >€ï@b÷‰ €læXÇOjþð!á   DxÁAe'jˆ…ÿ' ‰ pWìæÀ=îM–ÄmB@ pÐÒxÐRø¥Ä d €Žc)€Á=0 q RðÀ  °ÏDœæiqDŠ0P Âa•MJL°xÀ@ (í!Ã2`  ˜Â=Ï/¦#“MO'¨P—%¨¥ÂfPAFppA’à)œ(0€}"°í¸8ËrLÌøÃ—¼ŠSœàQLùH Q luŽ,A± ,Àt%ËâÜ„’„n(ÚR]êáBZ?,° !@æh¤lš?Ðÿ@ ×R»Èý:_O¤áÂmêeÀp2p çü€Ai‘ Áºvàæ±“‚Û j‘Ê$1Q$k¬”ÀÑ$üÐKÉÐØO–ð·úJ´nQdä-‰€FÁO0Áôd”HÐR0d p¿ 4p8) U•LF#¡BJ £QH÷ÃЙOŸ Ø<ÁÌ 4€F|ûmŠ9ˆ$„ü¶+œÇæ!f¤iYµÁô¡€pxœu€_³¦&fQîî¸@ÃGHËÆ7PÀž)‹<61dˆäSŽïaœ vá!¬$\™èÄ·Hi ÿ£ N©•,àŸ ‚Ób ¹€+ÖHpÁ IèÙ€š7VP‚ÞÕF pÎ 8W¯IN°Å lÏë ‘–OÆÀj" T ‚1½aÏ…AQÃ¥zÙY.Á‚Û§èÜmD‘ÄNö€X ì°`åè5øÁ ®³(Xj8"ø@槺«wªÄøw„Ô@6Ú€Àã«ü€/ÂG´F²»` -A›z˜‡Û“É.Á¢˜Œ ’§” ‡¨à¶úˆÇˆ†ü!„CÑÏzÒß(*V1ÉÀÈ$¬€²ã•,³Ä&ð@5@><`€<`ÿ )ü^€µ°H`aQ¡pBPè 2MHb3r°‚$àPÎ5Ðáa8¨d ^Â\L‚@ÈŠn0Ð2ˆ¯( ’!’{M®(ÛЀ )&ð³¤7€i°`FPÚ…ø¬W¤‘&Ð*¥ À•LܲŠÉбÂñfN#8˜ ;€¸Ô Ð`U.B@§öÀô¹bc³·í}àA¹xR°bäè@Ç9Æatɘ "T0hhKêøN=ýà$BX–CB# -è Gáæ!"éáãM"c ˆàòÕoÿ‹\£¨PF3úY2QÒxjQ@Šò¿Œ8ÖÀEïÄD ŸUã!é‰Gû0æR4„I(!L’92Óz †IøÎ4P”oí 7üc TA!€¡Ø^B™ª–m O ˆÛF#‡@ 3¨BSB ¤@ *[ë:°X°oF@HK?0„Pàà†´#‘!r:ÁR0Á@OÀrhˆ$ |!E7ô Ž` èÕ-MÁÀT t«–ȤMdÚ–à¤J‹ ˜Q”e´kÕ¢Œ©Z˜²2`8è H "<=Å'˜ÿdý™Ú )ƒ³¼ÊD>²Ôç1dBÂ*Ô¢<ãñQZ!îÁÅ!ݳ¥‹KVP…!4wnK úc¿ÎF DÙˆaÖÌÔ²Ch}@”ÝŠ‰#3¬ÛžÀú¹HHZG°G:0©DtI )g†ë2¢NC?€<$Œ@]KÃÀŠNÕ§Ÿ ‡¡29¢¸ ú ¨™9ù,‚¢(¥# px§º„ÃÖ%À…”@Np—²Ààh!ˆ‘ Ù „›RÀ*`{Ì©ÜTçœ29»^ÀÜB0`3Œ³UЙ„5vÕ,@ÑøU8‹ÀÿÖ¤P'5œ‘¨°ƒ²5æ_ðpHÚ'P)9Hb‚´£‰Þ#.sïz$ ^`{ëäp°h Ú!téÀK‚"‚Dëb•l uÅ"ŸdS` zU:€€–.àš‘ÛsYcMÝPàqÛº¡ 4€~Fù@ÞH0gÜœºFõ#¹\·d/'€¶±~HW*|{1÷þÜU(퇽©ƒÛ³ +@B\9G[Ô*ððÚŸUeQQÆ«LtloªD=`äô[ŒI¦©ïчbÎéÐë“‘xN”•s‘r¨'°-¶"r§¸È4â"&ï@óË@×…4AK#D(:ÔfÁùa-ù;ŠŒlå±ý€œ’G†Øwê>Cå]ýé¨0,ÌÀ‘ÁéG¾þ÷?þó?E}çÉ`}˜L½WX¨F\Õ Îð”A U mDðe%Uâ"Ç—€O@%ë *² ¨L€Z¡ -â è` ëW'ð…i°?l‚]°~‹Q8xQ€QT0'B%¼ ÖTæ@ɤN`„Np. ßf?…œ ¤a !ØX nôÒQ ]H]è…Åà" †PpH_¨ ÑÒÑ…_¨F!ù ?,YaÿÀß%,¢ŽÃ£RYl:ŸM—PJýI¡Ø¬V{*v…ÝcЏ­^¬­z=7Ép!ó™Â¦§ì¼ž[¬“‡uZ.u.Tm6{luŠX]]_IKCPˆBifV˜‹‹ŽFVM Š6Ž99?©ž?<¬‹ 𝳴z<®ODµ¼½Z»¾Áž¸PÀÂEÄÇy)'ƽ7? *Êzδ9?Ô?ÊÉPaÂ<ßÕ ïÙê¡Û¯Ô hAB$´—­aå €!B„Ö:t(°Â¡]Ê 0°`‚Ò"üè!Ã9ý±zðÀ pÐaÄÿzDÓÈa¾! ˆ6ÐCp­DQ9?RÜéA@¬€Ú’ƒk$@S—*N0 &Ð3€Aņ t¢„U_=°¸I«Æ"hðc"{0`ÀT„¢“/ˆ0`|wÑÚƒJиJdk0p½u@zu%ø5daù‰ otÙPø1¡½ `è@âÃkÉy<̪ŒF‹!¢ x¾……R5|Á; <ŒÞ÷‡tÊYÑÖâõë’¸Ò@† Ä?Hè°]BÝ[8 Ä Œ3R¯Ô¦œW D°@,Œ©! HàA hÐÿ@mNPÍÜáú"À-IP^šQƒ9 Á…ˆ±Ä’ `1 DÜ(vØØ"óý@î—|)L3ˆ?Ü“Á$Ð]K 0ÐÆ€›mF— |–$+$ Ø•´À'Lùx€v |@Ao…8Dp@Mœ@Óc\ã‰i@ôÈ\ITÝc |<z%ZbÀÁÐ@ñ….>¨‰‚öaE=®1ælÀÅ=ù 9’À§:@qÏ€ú¨`áM9{êº@‰ÅI\3n¡ RlÅC, Áud½Èhc q_°NÔxÿ– ôæ§]¤I•O£–”€E‰VÀ$Zœ)D599BžO^éŸ ÿçG6q„w€ÁxM`cNK¯åêæbMm¦ÇnHIQ ðdßaà§Z ?ÁÂdª%¿E¼s¦þKºÈÔ*©aˆÉyrp¡*'üÂ`ãD p¨¥i­ ˆ@héTZ&ÛªA²B\·F¬Mà€á \œ¹F µZ ?ý„fŸv°J þà¢;cPW "dJ÷¨ ,ÀþðÉi±¤Aq…B^÷PjÍ dJ3t&Q@öˆíÀ~” ñ»Öfr¦ x`¬Z(üÿÝ :çI:^Õàâ Йbаy<§Mnzc LiUy¸€µ’ L0ÄTNð#©„Aè@Á\³iÏu‹2¢>˜›¨Õl~v:¼@ÖW‡;—°†€´jX„"éá^cŠ Éeà>ù@ƒMmaAËÊx-¨µ¤!… Δ¶§jÁÙÿÉN2#p 4Ój.„À®uàh‹9Óò`‰}@iKºæ|©GáhIÁpB ÕK'8AΔ¾ý€jéqB ì¡D¨HTÎ+Ù†ú…4ˆ³Íu‡êKþl'i ^ÑçÄ- ܇¬òÃE ©Ã~ÇÅ,mI …ר/ÎØ~3*=D“x"00“Ïã’ãÀ䨫+ò¶ 9®Ã A¥ä’W"ÂéªtË dJXà\¦ñœ°?šá¨8P#Ë— xÀvÀF°‰„)ÇÎ-G9"P¯) ©¨Æ (ŸÙn ÀÐ l‰=XG9ôdIÿ·B5@;à2H· i¸D$YMÆü€&kÐLú›Æ¯"ðWÙ¦¸ïÄSW|ÖBSNÐ|œ€Õ$ÙfPŒ£x‚O €=.€é":p3å<ÀŸ ™>rÑ F •%ñaÆk`^êTCØ¢\‹ðBkâç‚ÞhÉò„àî^è )P N€ïc@q÷RÄR-‚  0àON`ºjѾPÁÅ g";Gà´JÊÉ&Pµ^Ò-±•ãsçu&0Tv­é»NVË•‘Š˜µ8Qùn6ÔðETë 6¢0¼¢4Äüõ'/^º >ÿ‹ÌèÄÙø$‡>` ­ôó€T>Lx‡}Ÿ¶5Û5#Fn®×‚0¾‰šÈJ’©“¬Êñr-R ¸=Rr™õ•¦S~R,x Ãǘ‘1³#^Iñ#À–ôd·›“W ÷…HÒµîf^;Z2;Ë.‰–« ÜÜQÙJò$sÃ퉽ÂÓÁ £Z`Ÿ J@ƒÕׂ_9ú1 ¯ü–ã¾ùW >ô=’ÐÞNß!»˜üõÑ€„J¼âé(Þ~þÐzI€ÿNþà Úl ó­îùu~åç µùŒáu/@Áöx€-®ókðÝ×i?o™± X á€B I_4J¸z`  }QH”zð¸“ð|j@‚½`€PzW‘ Éç -Ø= <ƒëá ƒ=@ƒ%5ƒ3X4Pl0X1­[AHø!!Â&j«v0J !ô"FhØ B€Â'‡›6*TÐCˆ"„àpqã³ÿ…Êüpw"‚»:lðàä­)ÌÖcâÀDjÁC†«84 º¥‰¦iXÀ¤ð£dŠ(:Hè0`d6~…ÀQ§m‚€"Yˆ4CôM»'ÚJfˆ8 €VšX#`°µÌXÞXC°V`A4 )$B…°%EÓñÙÓhelÐ`Zƒj "À¦éKZm;¡È–M…4døñáÃX?6pà€ 5Š£ÿaãÄ”Ûî~h… •‹Š O§ˆaÄù1ÀØW¯5@ÆOŒ‡HrE`Ma´ L‡Ú?p@Ál°>¡Ñ<pÿ ül‘ü Z‚`álñdðÀy°Á Àà¢zÿt¸Þeœ™"`% Á`@KnP@{YÄxߌ` ÔŒ!j@‡\6`€ZkA‘—BAñØ–ÈH*à& -Ð]ÐàŒ?¬‰c ZäÇc‰P@VÁ¥0Áœæ$ãGiÕQB L6™Án:FišD0‚Œ•F¸ÆÖjœPÁ §x‰ 4Å#!”Á’´ Â$|`Ø… ÈFкQ§“dùDzkI€ÁL4™ªÂ­ øùÇJP Ð8Â’nê*c„'Dü A®Xpÿa õ×*D”˜ ¶f°k¸0Å#å&À±$ppB o~ð HþâLšét E(RY©,ˆ4‚Š÷"‡lóL ~ ¤Kz{£ öØ€8 @Akh–˜Zu¥pܰ tüƒ´fF‘@ T8ëx-u»‚P%¢N¨©'(E‰ê pB­ @M)ÌÔ@›ºE$‹8Q8T'ÄIQ·Á¬\ë ÄzlI¥v€µY%‰ –$Ï'°ÁáQ<òHð Õ„?$%MÛ¹v‚EQT pü`sê!°ÚØ)tÀ[M`@ÿ˜HW§òXŒ,nžARº&¨%Õú¯TE'3å[F بÀÕ‰95=è –¢Fr,{€I  (\M'Ó€ ¨Ïº=Àú*ìðD‡xà^(ð¼YÀE(Ѐðp¾ Bp˜ Àsñ@~`¤¬¦$];Àbp„Mfà“àñ`¯k3êÀ„âÓ¸l¯š–p!Fq‘ƒ”E0™ˆ801¨‰¬ò]H¥’ 40!]IÀmOg´…H¨`ËÉâpE´8©¦Z[“™p$ðœ˜k(™I&E‚Ð!5ÈШ¨‹±5ÿ èÀL”2'#Ñ̦8`! ÞCĘAÇ`œ‚±ºÈkH‘¬@WÁ)i4Î.( …ò¸È€åxß+:24fm"dR…¢Ò*½„[“€Np:D­“pÕAŒ!ÔRIëÒÛ© UâÃ0 €\(ˆ G PJ j`³N ÃTøÔCB EIÓ¡RFLHHµFQ>ÕqRp2`$ ¤|€Ô!Á"`£l‰ÅŒ?(×U~ÀÉ?Œ%H[ÇÖ‘¥ÓF(U 8P7ÃÌ8›ËVD6Ÿ (-À§\ƒ40âÿ¢'=ü±pPf$*0˜%JX [ pá .DýåîFjÏa â¡8“ ³Hà èñ`Q0Uý\È D®|*t.Ð@*ØÀ:Pµµs×Ìã@7™Û¡9èØJÓÆŒ4©ÖÊ͵7ˆ@|ℼ@ï«"?0¤.`°*‚ŠÙž BÈ!I‡(³šº`1ˆpMðf@€ÀPcåBêÄ‘€ Oê’[¤l@2œuB<‹àWp¤C T Û œ$Ó«æ× Â)(Ì%[Jüm¨˜„2ºjÜ ´`—cD±Dpÿ€rGr:hJ„àÉt ˆ jeÌ &å4‘Z@€!•ÌÈC¬QQ64€IL—­ ¥Á[)  ÐR0 52ï\@²‘]ˆÛ]€k0`éÁÆ€­g:„³Ñ6¥¥Lju©¥ ˆ½¢ ‚ ðF­™:OPx I‘ëÞ5òô¶Æ"Æ´‰©ZE×°SJv&Æ4ÝüÁlh¡š„à‹WÑc’`ð 7 â‚BP‚äÎ"‡ÙZpX@BuiÚÀ„rNÖI7HnZ @F᤾8lÊk^)€±ÙbáP¬™ æ'Oÿð¨QiBKD ohòb]ô®±“´#@3PPrüA‡Jƒ72òD#Y0Í4S‚訵`›~!anÁFÑP#À˜iÆÍN@i80ÐfÀ…€ˆN*´.¹PMuÊIFCj±… ú4©1©`²…¸ƒ¯¦±©•‚È…VVˆ‹À]¾ÍLO„'ÎN`à¥Ì¶0¬YjŒRÀ Eð¨,½2©ùDáà~xÎÀ@€Bòáw¼ìzƒÊÞJG¤«+1ˆ#°@Ò[=Œ1}ö‘€'€¨b0‚¹<ÅÏ £¶ <À>×ú9Úþ@ƒ0{“ ®,±&ÿM I:;È–ܸ6j$ƒL¡ã¥ÞTéfdˆaئÒL "¸Î6 {0ÜÁ_Üù˜7¥:Ý ¨ /a,QÑö¹:p‚£ÞhÎ"[p•1ˆ(F%Úð@tÖZ>]E §YΊ»aøtnS3È †êÝMƒæ¼z °ì&W½ßV•†/8û âHÝtnU¥% Væt{4B)<71Wš„Ðä©{'\Šh°“¼ ÷«Ö`…Ò˱zoê€1íÙýú§ÛþøBùŸÿÆWºÿW7ü€œçÂdü€Æ¢aÓˆcÐ~¼rC-²y•=à˜Ø& wÐy5‡u·Ð—@<`uÙ,p‰ Q~Dà¬àxõV Òåpɱ_àxt0ƒQ0z | /N@Q‰àå'\œ%=¬#L Q…ZÕ<ÂÁdB"”æT®â*%…´\Ëå÷ Ð9PkWç èsÈ<\` <Ð!b‚|?y(yø‡ÔP ¨$ˆÕà‚H ~h‚bRo A!ù ?,YaÿÀŸpH,Èd’¥l:‹'Ì5­6™Ì#V˜-Ú†6×—˜3–…ç'ñ$dÿØnd׈u±\¿­÷gû|NcG8yBn)GŠMŒFx†,zz|bbGƒN;¬:¼Wy€d´?Ò2j à€¶$> Î@’)XÒÐz¤…]€â$RgX An„{iŸÿ\„Ü j(œöð!÷ƒêU8Ñ×ÈcMH\¤PD»ž¢ò~_q0AuîÕª%´­á„¼s>% Îâ3cyxg=Ù¢ ‡Í9·€ ÁbN4ÏÐT“iÅ’È`Àl0$<×ÿÁuPü a‡ƒiÚР„"ø¤†Ôt@-HðÜC @’0ºéuD-6÷Fø„ h`žjÿÀG !VJ e@h „‚º)Q–yd`dŒe'ÄE¨‚jôVSueÈgÃg6ijt &  — Ц*àåGøÁ§1€/ªÆÀA»ÑTÀOEœQNèóÀ—m°¤Œðƒ€Ä€†Íñ(iØq)B4ØéŸ Ä áK*‰(rþP¤ ô†GdðÜ (uÄIø °@ °aU@L¤ñÿiäwÐst0ç0ð"M ŠM¤æ¦Ï9T@@9@ÁI ¤-¨KD*`qpmTP§ð¸ÀQj€ ,pU¸2*DI kZTPÁ)™ÔÀ9TJ„F @¼»eðéT@ÁnW€Tv¡ˆE è$Ù{èôÕ_FW€RÝ…¬`D¼T,Cð\„ Ò`)Ö€Ñx0Áż(€…ALhOQQSd—ÖD ŽA `71»Ìüñ40 "¬íàXýÐïüàB p$EQ¨]°ñÕ° Á0$è@ˆÄBØQÿ) h0ÆPG ˜ÐÞ*=`DÔ)ìdH!ñýW Óa`€èœ€GI*îqˆxW"‘»jMô€=à‹^Ô¡ BBòÀ¢@\÷Uý¾­ÓÞ¤ð¸Ü!P3; Û’(Õ¤IA˜3)5 „=~R=ýD 8€38p@hoÃS" 30øbÝá `БD mKØ–¢ó•àZÙÀ˜¢£µà#ÈP ‘1 ÄÉ !©tO 9ˆc´Æ4™…@P˜^jr:E9GiÀŽêD xñ€‰FpV€h‹CKa`‚(ÿ nD¸ã_‡œB¨ÀÀÔ¿P Ü‹D56±¹(ààÌ~ ¤ NB AZ8däê‰â ÉÖòÉõq ((Á6ƒ¼ñ,i & t(mq „@Cu¨hTÝëÎ1\p©P€h•sxi"¡8‘ B %2xPÀ!§! S‡R3ù‚Ò~”t@þàKƒ jq#[´‚ÏŒ¦4Ÿ@sµ‹ŠéÀB°* ¼JÌ2ê¡SQÃ4À€ñ¸0O#Òæ :,f€Vi •ûA3óè(€ô(GAOÀ„W:a¼„¾°ºš£.ÿhÀ¦³ &[ûAH làKÎ:Òà¿  ‘Ã@ M@̳3¦1€Tq(¨Œ,u=ØA&€¨ |éP*S£1iê9½)ßÎñ)cd" FÀÀ MC¬qà‘m¡†) hÀŸÑñÀJ Ñ ¨æœ:ÀOp’µIŽh$SOZò@*t…Oe ´Œ¥þ@&r°Át¨%x€ä”›˜‰}þÔÀü9ƒ"¥­`‰ê"30E¦q€ˆ&€¦yó;pÒ:‹€'ù³Cjü’0£š ĉ5ñ nI»!ðÀô (b"¶Lt€ùÿRZ"À«ܰÏHà©“>€ÑUIužÛxЮhÈNr±VFðe1ÇýNQ2tL#Ènçü@$ ; ¬¶KXÖ¢uavw- yšà8wqË[ÆÛ7F‰å‚™È„ZÀ›æ°Si;ÏAy]ùÞ JÈ~T2{ä*8Ô`²W‰KM ä£zªøOœîµÜ­ÜSipñÞµýg7Ÿ²ËRPç´Ò¡çÀà€ä‚³tL‡^f X”FÕpà(Ê‚¶Vá‹ Ð#$× íRg3…ç?4ù_4€ `Ú)¡€ÿ0 6ƒp`KUïBÅr½¡'^Ð%Xhn—sJ&Pz™Ìh:YFò-{ Ái`Åš €0Ú5<ÂG,”̸,àmmD‚ h…))MÁ˜ÝcX ,Pೈ¶ p˲C‚> Ö€Ðä&  lªt„9 Ø[ ¶&3(áè`ÊM†.•x>ÌþÔ\Xƒº|R³]½ÐI:€ÊOh¨'À2¸¼:ìIBŸrt`³Já[±6·) ´f’¶9.cŪñNäÑ MÇ){‹šÂ¥SZ­:ÓàA`ƒ '¡ ÑsË1Ðÿ;ç ÕEØêDƒv\(R-ú•¦:€@}ÍV‚6„rz8ÈdÇ´‹Õn¢ŽOÄAçÏpÀ¥h²›œf"tÊ *pñ©TC úàìbÓ œ†Z‹û4¤ðö}`JPØÊ¨•…¼HvvH9°Ê lðuI_|YŒìΫã½Ï ¸°AŒºÛxã…R'¹ÞU ¨@”ßÖ€|O½Pþ*36øºäXoü9üéê<Àͬۛ…|"ž Aéòë,ætH#Ø¥:Ø }‡°aUãSjØ'ÿ} ¢ûCp„å,/B š€Bq6Ï×}§€Žxç¸èWÈê t8 9°» ‚À°*§Ï”Ø€ ,-ˆÉÖPˆ 6xFHF`#.bãµðV“MöwÈŽÁ²c@-­€b3¨ô‡Nt<èJ¡á]. 8…Š#…|w ³À#ãw`bÆPÕ!3BpMBPaêU‡s8IÇ´@Ú¢kH¨^Gx„ÎÔDCðLHKaˆ…ˆfDÈû@sM[ȈØPS8!ˆ Ý JØ‚k&K‰ ˆ„›Ÿè‚ž¸‰¥H%§Ho!ù ?,YaÿÀŸpH,ÈdÒ¥l:‹˜ÓP*¤þ¬ÉÔO{d2ßbØe mFô¹i£¹\ÔVÉí‚Y.x/½L9N‚JfUGXHzG‹€|^Cd’G„O9l˜Á€¦ÿgY‰ð­¢Í hØÐ‚ VDT²0Øp4)¢œð@!BÐfgéX—a'ƒ?Rf¼0BD}ÈîZ `\¤ <` @›¬ÅfÊÕdúÞ¼¹ Á‰Ââ¡øGZª¡ÎÅ À«Í2S8ñáÃÊuŸ‡Ôy¦£€? >@8A¡7 #H8÷¹Òã¡Hxå‘¿U¨áAx‰U¯bOÑ3»‰€ œ¨è ‚At%H€Pâ€øÔ>䳪Ç7ÅA‚ïtgÄ7­6B έ§ÞuM_aÁóƒ^EPIüpPèôÿÑSx€ ã…5B‚à  Np4Ð@4`Ï0gÍ‚Daã4às8õ]=J à@uΩ˜à<0gä£|––È–Dòà`ÃmAJ`YøÒ{?,Øâ´õ#TЀ`ΘPQF~ð„”@ð ,`€@À"#C(¨¤ ÞÅh€J•´E°ŒøÂ$@A0£z(`À xÀÀ1ß,°A’í9gážz©4€YY é Êv ÄÀæÑØÞW8A0ôƒÿq0çr"A”<!pPŒ ÿe ì©) á"n D !iðÃW!`À·zó¯¤îyD å†É@Ô.° Gãd ÓM Pà*¼Å€/eAlpé õš^Ç9y€,‡0Œ@YXh;ÄÅ¢tÊAn(êAR ›Ü?ȘÑâ8øÃHÀ“mpèõDBz ªð¨70áÍÃK}m­Á 8`@º‹Á \ª @":ÈØ— áOÇ9—Aü€{ì]È(¡ Q?¬Â4€«²Ê*`•øg!š8´íV @ðC«Á §d{GØpÿk(¥˜ƒ›ìøÖ ›×ÓšÎ4pö*€€ï% Ð8ϲ´–ÛõÎ9>a°šC¹ŠAo`f³­e0cP=¨ÐÏøPø•Ð$²“š°¤jÿƒ >ƒ\ÚR¹¸L  ÷Bu*’ñÑd%L ‡(°¹/x \˜Æ´€«a@PUà€f³Ë“N´·ƒàæ˜Ó€*F€.| XÂEa!F8ȽFlRAˆÊ ÖÊ#œÍF­)Ág¼Á”Ä j7B¥€²»°ðÆ"²Â;ìçŽö%"a~”·’B@5瘶0ÈMÖ³ pfF>šþCVz·%òr†¼õD¹(Y=`BeA¨³¢œ·žmå'ˆÀJ ¦­€"Lp ¨Àm±²NDÒY%VîXœƒß$0à™5i]ø € éÊÍŠêN%RQ„4 %9”y‚“›¶ˆyG;Öh@ÿ&Òå!¤"òÇ-nIBz`íNÑÅÍ']¬¡»•i'B¡"P-R`'4é 2¤„X+*PPŒŒ*ýø¾µÌj2\{78Œ}ñËlÐä‹Êë ðÑH Áéhi“\à7Õ|p§Y —Q«¢d@òƒ'0x ³õÐnÚà À™^€ÿˆÊe@@ÔÈ °Õ!ÅO@¥Ç0û: •O=¦Ä(ÁpMÆÔŸ;ÁÉrÖgžàÿ 3Ï Ðo7€Â"t@ ˜ˆ :™W¬C›‹ÀƒTæQËÍü=¸Û“ …’sà Á+Ó¢¬ØÍœBá’¹–œ àG÷KƒáwŽdyå# \—ÉR'C °”3¥³¡`Þ`@5ªQ«´¶»>£SYZù—¨Í­~N+âFèAÃuPà–ª_yðÿa$üÂmGåúxVP”y  µ9гHñ‹B_fôÁ<8ðè^D@T#µ !¡ «,Üš£È· `¾À(`cE1 qh“ŽÏ ÎZ´ÀI$`oÆ€N¥ È‚ DSà€510AA;u`€ o\fo$d@P„g”ÐèµÔ~jV@òQP, ðÌ¡$”BD€Ëm l©2·?@«ÖtNzBž*0ÁH„ª T®5”ç óƒ>“B?”y‚6Šÿ ®JÚe JLäTp´faø"_ý2%4Œÿ!kM3Ítè ±rG‘ÐpPÎSoZ ߾Π ð€, 0Àc%1o´ p¾™êßÈÞÀ/™c<ÒY“X‡P Ñ§ÇÆL­/ÂBeÆ ,HÈÈ¥‰ªNÏ…@Ò—|x`ЉS\ƒH%FÇiF\p-y4kð€à'ql"÷øRBb¡ „`1XÏ ,ÑŠØ@×°†¿B2ª  AØ@Ž~¤ EzadäC¶D Ì ò' ¢P‘c«ÀµÆ‹( 6)sE㎉4L!€€DPä{Ð »1½üÿã?HÈGD0ï±0Ê0 PTÍDC¨ dh+ÞÌa’ˆÓP@X@Q2 !h (]iœd62FÂ!Àf„·)$èÈ€‰>Ÿh /?Ø@ˆ³Î5.N¸`¾‘A)ì†0ÊL € r„t€lä¸ÊU:Ï# ©L¦x¦†.äÁXå3@£l8­càPÕÆ C1€ !ÐÀ¢ðÉ\’'ØZ< 0Jˆéa5ª\çÜC g‘@PÍÁFLÓ$*Aô2p’~Š 1y¡ÆÁ:ƳÐt €ÂL:º"iâ1ÿ‰@›òx(Õ0¡Á>‡Àƒ:x'‡ÅÑxà™Š“ÅI…€bna ÃØ à€mñRd ‚$-!Ïð¸!Œæ4µZÞtY·/¤ …Û‚)­Õ ¢61Ç8:àµü DKЄ8¾”ž„tæØ¨‰²Ò€­5[ð× P| ;‚VZò Œ ‡"ÐúNw(nT¨ ©Š*2ÍFnäÈÀOµ Áª<@Áh‚Œˆ W‰@_±aS•-%¨.Vð t,@×Â@ ª¡‚:רé¶TL°ì# hP^³rK( MÝ’ÿBIÎr“ „À«Q`‹Ji’d4Ki*•4ß(ˆ =àV­V>nöF£ÁâÊ„*ÜêK¨'¥ðY«mñå` —YÔÏ #$>óJÍ›ü‡Úõ¯/ Ð7“`ý]Ât&‚÷9`"ÐJ м(¸¸Q˜RT²@±å¬a=+‚Ì@)aJ‹a¥@ïYmJ¡ ¥SÄR§El²ÈFâ5„ߤ˜ .…¿j£‚helKà2I$ô±sÍ“0€ªI¸`Q¹,Fþó”yR1Ö,òj/Á˜oxË‘·@‰äÜÂd…‚ãªOcøpœÿã °óà6ɱ³¶+†àsd11Q¨@“°½N€#NFñðF4baùZ ,°í&Pµ0EéÔx(æ¤4¡ ƒ:ªV´’ǽ¡× Kv)—NÄÁYÁ¡¥Àƒ^(Ë{jÙ –"m!¸ÀÒKúœ†Msb ‹S–¹¾—Æñ»x˜Q? ôØ¥jÐâ”ÿ8ŠÈB>£²ê:`I-–€þ¦x!Ä¢(àžNÓâÍnÔ‰‰ dÚD!æh¶"ç„rVÆ•nÊ:ΜóI hPÁoUr¨%è è˜E`Ūg©oãXw*B>ÿ‰ Jµy=ðL L —qÇË9QøÁÏ #@†ˆÞ‰1„÷ë†CRn‘¼VAÇ…:)ÞªG±äGŽH«º¬+ÓÁ¹àOAƒsÃÀ£fÅR'O …s>›ÿ|ç‡ÀuÑçañ„)чÖcI(9À&fÏÓK$âTïP2í˜ÀÖzd³WÏÖÎ ÏG!ô àA%è"Ì9^!bº×E&#TøVÀ¾"lPz.xŸ”†èò£¹àAáà…#ZÊ-{±ãýB 9çª^·8ßN¿O´þ…°ÃB8 ÿ3€x7!Æ$j°.x€|¬àŽAÛgzý†Q¡| ÉÇ|Ç |Ú€CP HÈ!ÈS `$ˆ$8A!ù ?,YaÿÀß/%,Ã$±Èl:ŸÐ¨tú 1§æ—v¹ÃÓÒ‰¤š.ª­¸>¨'1N>ÛïÌ\WdW`И@×àƒDña…%¤Æ«B€&8üð‰°Ppð§V±„L$| ™aÃ!0¤ðâÌÿ`åFõÀ‚6I$ 1bD “&w½„bê:Ü$±àÄS“£nÔk<逡¨PKHÕ3 µ0ð`Æ F¼59ø ©?¦êIQuÕÞë*h K‚äß½xL-r¨1¢ ÀàA­ßÊ~ûe6“ç! „Lhafe„øe@­:Ã3<\øœÒCU"x£ìe& "Œ¨€ ß‚ ×k’¨A3&63QÌÙÞ’`-B[Ê«)4h0 A’&w˜ð#€ÐdPWÆ!’E6éTA6Ù%Å à\'D€Te¨°‰ÌDGÿÍ,0BM3Ïê  y _«ýÐØ\·€Ü·ÈDX À£UXßLULfLð|„°`t80€, ÅEX÷^HÐÀC$Fð7À?˜=¡I>6Q€–?”`äp€@høÄ!ÑefN:Ñ…¨¦Ï áÙJm† QñÑ}[àx¦9ãD~x‚œ L6€×1 @Gä àwP`Û‰N$ B@ „ŽØX@z•zQ!,pÓNàܸnTàÁ£ øI ‚÷ô—i’h’¨ÿÇšFN[:ǶC­sE¥ Yd À³MtâDrM`éê¤y&µD Ï8A” BšÇBÒPKÒôf XH'!8ðD'=psÎu?°³€•EÀ¤ Þ§Mˆö#Hù6éØwŸRÜ5À  Y83ÌøáÀZˆöQ.' šÑTkô`Ei¥Aí1ÁM\W’RÏ\DdlQ@PN¬¡‘¿6œ Àœ €Qz QÐu§é.x±a·8XÙw“‚¦d3Øh€€“œxü-ÒãØ­@1ŽÁ2nÜÝŠØOòÑæ¨d&PÔ¯éªK’F ŠrÞ`±…“°]ô7*à„t £$ £"ÀÍØZ] ©Á¯Eþƒ ó+H=LlÂ~À>˜€À‡Qöû@1PA ”®üîóâêÞ‡8)þ]|aì寅 @þZä`zx¿t€ ¸ñNЃqŒSœ òœɱ¯QÏ€nö÷TëNÐªà€›! ?€ ÆÈÐ~‰àYÀPwÐ@Ô€š =À4ç>ŠPFQx!À÷ÀPYPÕ—ºÐC(T8°7ƒf ¼ÂðfoPv-(€ô,Ð uö€K ‚e@S’ ˆUX¨C+&¶I†D: ȵW¤ó󡀉ÐQ`2•"`l¸IZ¸I¼6SŽ`à—~uð>bž°sùç~f  š¡ /‚„¨BPˆ5x „è Š•†‚Šˆ‹xˆQð!ù ?,YbÿÀŸð·ȤrÉl:‡Eäé8­þ¬Ó§6ÉÚzÙaXyJ·ÝîO}´ m.·1÷}¢¦)!êgæÓ.,.k„m?6rnˆ‡uHlIX|gJƒ„,iB™BpIrZyBgM–„ƒ§š”FŠot¡ dÐAÀü$0ôÕÿÀDTývD =XÀDDà^¿Ñ²,°ÁLW bðƒ~,´À`@"eN xdE0ï sÑEŸÔŸh1}ÐØ£ãÌA d¦m ð¦D=õ ‚0Õ‡J´Ã–š,ABÀÑLMЀ4@'80@pø@v&šü€¼É¡€F„³%"Üpà=a>D–Kúý)OJ`[tB¥Î”äó~HôCƒ.ÁS—Þ 0Yo&¤- ƒ@JÞ¦c @iD?¨„Á °Ä_ΖÀ1!"pH0NÅÿ@÷Ìe$&áús‚’½²3„|0‚4±ÛÀ '<0€á:áF2ú ß¤»N–îæ/600–†á·nº}ÀÀ§p»dz¬ÑRQ};ª¤äl€2ÿ   êzÕ°V$¬Ì)P«1Z"è Da©`ŠÄ Bw zOh`A ÜîAPÖ¾µqÐ~P´}‘}02 {AmÜ‘I$'®ÇÈ[ÁÓ¨œ¥ A ¨ÔRãùz›ÜV Q>b Âp4•K DÁ ¬°D¯A­*¤À‚Sp # ÿ|0Á”Hs4‰~HTq¤_Êw6.­WBܰpêF8€Ô#ìŽ+”°ù—·SÐA¨¨úRMÀÄ?8Ä‘hHeЀÍÈy a?£ÀC¸…#×à#?Zˆ¼=!%+èR–TÕÊ)D‹ØtàÌÈ%+  &C5@ãBp…u !`À)êñŽÅm›#Üm`‡  Ax•ŽjjиÄD+œcÀm~‡–±ïø(îf= q;Bðã4¨uñw*ðÀP³#@)6ÀD!œ°ƒðÿ†&p@áBP HàK €àD „/m‘sIrîaÜæ+€A ¤…„qÕB‰MÐÁ Xɨj<âIÎx¦£ä@ C´h#ºh^¸"äˆÉ/Ø# T D\afB˜ mX°e ÑçØÁõø ÒZ”ÒlK]Ô'§ ¦6Ü ¡åäÒ4$\ÌòÅ”Z~¡@ZäÆ>ˆ`)ˆºÖ9\!Ë8ªÁˆÊ¨U¨'¤H !‚BI­Ä±KèF ৤6Ð4I}é66ÐA5ë@I:t¡˜^ÈA²$€EDL7+@?Ób¨`³ ´tÔÆP J›ÿ[hÁ?î‘|È'·Š[R wú`ã#¤ðñZµÀ R-@ÏVüƒZ;2 °Å0 Br«Mº•—™l`$ìãlø Áa$rAR›% T?TuÓ€³Vz€,¢á×v0ÆÂÀ_ý`6 •¦,84Àwð"Li²U©‡hi>ˆÁ@Je>SÕbþk° [rAz–B7÷2‡¼Í~2 8 HV²ö%ø2‹aº*Y:Ö€’*môÌc#”€¨@xFÂE/¨ìL@”„–.ºˆ‹Ây±¯nöª­Â@DÅ®^¥ @ZIÿ¥:‚˜!î:(~D£•§e€—s‘!ŒÀÅjì#œ{ÈUµ8°¬ µ]ZÏ~$!Ó&„Úòe3à …âŽ)8Yj¿?¸o§‚Ø-VàAJ€ks'Cç6íÅXûðH‚).K"MÓžæA#´¸¶åÊß‚D ˆ‡`´šM*p…ü†3è×Ó4ÐãÀYÎ ¥x¼£ªŒ,+& /zƒýx"Hó7'ð•Œ9Üj#Ä0´,á^â•¡ÓÜÐ ‚3zÚÞ˜‡$„°¨qj_x­8“hc™ Ôºs zrHZ{…Pê'TX€pÿ—ÀTi‰lÓ@ሠ_Æ’HB‘ÛŠ×øµUÉò¡r»3!a spÑ @ó;pî’l­ÇDÔÿÂÏiǬ*‘~€Ôaµ ÝÈòŸ#`ãǯ8 `€éª0?‰#›’šZ"I%ERCÉܬRèXsù3~©‘^0à…p&<§ Vwè­•Z›#Û8U°3‡½áKÂÔºx 6$& çßÒÝøÐ¢$È àçÚTHy(»… ‚ yI8Œ„1@|ôuš™°Ôc  Ù28 ‰)ìÁâOH2Àb- e¸ ÿ>ª¸M7­Ý·RV3 ælÄ;FÀvdÝãøà ±äÖŸ° ¼ú] j°V$´™€›®êÖà(;ÞûþƒWäY¨ìX'3å§1™)”ÌFô¡EÛð(+ô2Ï•¦@!ÄÆqÖ:Ôé¹a@¾ž†ŽÆ0sfàƒ^-œhDó–ôXö.!ÑMN4•ÐyþÖ›º¶¢xÓ‹#BáS·~'‚Û… Ôv>@8‚— øéœKFµQ3£ _:<à…|ÚlñKV…HÏQJí€sVv®úo–4ø#óB>PBÂ[y±pÚàx(Ae$ t;ÿð›¡}\Snk Y²€qKüSX‚&Øx'˜‚¤ ‚)È€,-–yOP:0zâRƒ;à5Ⱦ¡ µ7*ñ7•¤EP„=àÆÐ 3'r4Gï!}൒âT8Ý!|½,Â_ëá ®`f¬†[Pz¥÷[²%àÆ…;À";ÀExDbÈ_Ø2À }0tÒ+Y Bp-òôµ ppEj…¶LèM…`Ð(xxx†@ "a +xSˆL–j>¦#¶aÓWâ:ð5ï°3‡…¦G"ÀÐLXH"$’†Ùðtº ‹ÑE8p:ðƒGðvº@ŒahŒÆ¸YçÉhhk(=ðŒÒ¨k( Ñ('ÏP[¨QÀ»p–CÙˆªñïШH!ù ?,YbÿÀŸðÇȤrÉl:‡E$ꈪþªØìsév¿?ðvlÔ O˜g55E²~ï°\ìMv½6dþ˜öÉTF'Xd,`.otC_wŒ?L{\?hR?)WW™J™œ.™¡b‡6.¦¦€ªJiBYVmG™qva).wµ«~e¹?’y6{9}[9<ÆÌÇGQK=DBI±»ÚÛKËÕB9¿ÙÜääÊMãåêëCSéìB<Ñðd'ôG!?œ÷¨1±B/B€(4 0à{ìúР„   0‡INdz·MB€~lØð#C†$Hh Þ$ˆ0ÄS‘þQÚ5¨‚ >dš`Bƒ *,`À.ŠWM× X@®S (|¡AÂ]“äiv! *hp"Ä…$àÂĬÎð%!‰Éa@˜D‡Š!t Ì €š]åÍë‹Öº6t@¨€z `\Ý´×ôp@@Õƒ_Î¥ZùŒ[áFöTOÂ#ÅÌÖ'™P A‚ ?0a0)@ä !‹-ÿ°•½¨ì;À“ÕTÇÃtB¤Y$°°÷t¥pTl.!cÆá€RТMB§} »7 2ÅpÈ XÍÚA£ö$¬€BŸs}„­„3+€Ç&´º]΄ÛÐ$yÆ ¡å$¡øA§p* 8`A 0‚&ÀOˆúÁ C4YM`ø[~°é@`ªjŒÐƒ¨d‚áÊ™$ŸT‚ ·\TpÂR/ÊéÀè¾ä¥>‰LBÀ o `»ùò X½xÀ~z˜hƒÛ}à"ØÀªì$‚p™†q"H“B&T€ìÿÍèœõƒ ©|ÐÙÏ<å)À`a€@D•@Æx a-q Ånç©8b`€Q€.©£ M(šÛ ^©3!4lŠÄ` ±pIp2b£Š…s1ÅI`xÑ“­|âà ‚¸ÈUè€+èôéE!P^Ÿ(p‚Mö(+À0› ÌbnƒØJGà48 —XQPà‚m’#að¦*hpž”ÐQ°›L$ w–][‡ öò–ý +8Á%zTäÂD#ºBK´”ð)?0”pâ*!rà B™ À¬Àr{ è@솂Pªÿþúˆäé«>6èO°Ú Zh?¾Èp‰ -]Z \c¦…AMä.g €Lè@ @€;áAªÙ€oNéGS À”.(i wèÓไttEú“½øQU¸l(v{Úd°¢‚¡D€'}s‰``€¶)`Š?…à¤%¥rØ“½zT‘@ &úÁ@–#3('a+éKJƒÏíMbÛKÎJ»­lÉJLXä)N-Mä¨È0i·A ŠÉVÃFÀ(4ž‘^zÙj6«4¥)V[IJ;'<À±“¢å~Ò#…¸(½ECnFDzöx13ÿB‹…É <Ò;¸À P™Û4 =î`! - l5BB7¼ÂhÀ=Š’E&°ôAZå;‘H0n±ŒVùüOA¥/=F€×~°G(`+vÃ@€˜×¶9R$^HxÀ~&À%tÀÚÚÖ$«e€îd˜ !uø&t!Xî’hPHH0ô•vgmS?ŠæKLÎ)9žÊ(?08 7›€3«s÷u âûAsC°¨   q¦„š¡M@¤Þ µ©^^ßÁ‹ÈV‘ )ÈÄ dš 4•éVÀ€MqÊS‚Âgÿh„—% B{sâ|£4¨M}Àðá ³ {]`„ M^~V>)¨ÄÊÀ鎰e¼ðÙ-KûÓ „„ ‹¦¯Ë€&MO qÊÉE3¤ÊZDg=.Z؄Ҿ Û0ÀIº•A¥böL~©À)`A#.Uèmª\ <€Ìr<£Ý—%pºìee.XÁvë²Ùî†TäwÉL9¥!˜ïÍL䂃T(œ 'B-à?ídÏ'€@Ñ ëv¨ÂÁÁçpšF…KÞ< c U9‚) ƒK`ž¦YÈ´­ú5]ÔJé$¼ì-ÑŠ€pÖÿ· ."Â×ñ^RRaNG›* J€:ÆÔà{óׇ0‡S¹&(­Al·<™è&@拳X@¦Á4ª!Àµ]!„ÕÈH€Å@ ‚o•`ÞJ°™0¹ÉÞZ5á™ß1÷òôd¢% æ~„B½:¿ ‡Ró7± #°„æQ7„Z³^˜ 7ÀŸåú v‚v™'™³m˜ËôM y0ÜcˆL©/jñ00 Ág `h ¡¨C̞ƣÐÀ€Ï:Ñ „4uEl”$F€ ø”0 ‚‡ $À(:iD¨q±áC…<HøPc+@¯ÂrÐÀÁ€;`Ø ù‡†~4Q¥(õdlj0´pƒ³„˜fHÐ@Á‡7!MYF-„† aV–ñH¨š‚º ,ÎåÄ€â  ØÍ¬Ý[² 0`Á¬ÀAœ•@Q@„ | Y4NÌd@0eøÑ=Z¸§ÿA ôÂ*ÀWâ³=Á £…ŒQD–KåBjaÍ'€ƒ@ÀœàÝ* À PEB³) BV QE€@B>°ã=fŽ³Ð *5XةԙO#`SÎèû1èÁl|°Á #h `MdUÍF#Fû­Ä%œd@Âàæ„4 ñh‰Œ¥Y2‚OAEÑCk °% %D0ÁYŒ“FRù´Ñ$¤Ai›2òD4éQB"ŒP§nÄÐìóDfÀ@B½ÖWSרK mä ÉJlLÿ ­€ºKB¸ä B8ä‘+Oä0@»T]+AŠYÜšU ~ËÒÁšE6GBjÑ™¶5é"ø9ðtNˆm4ÜJUñ1Uå_Ÿ£™›E•¤QÄX¼ZqGìÑ›ªm  ýÀщ}ÀS ãMŠò ¨L¥. o=ºÀÛä:û ÀÔÙ¼xÙá8ðª“9A«8 D@LôOô·2sñ¨ÔBɶÙ PÜÐs Á ÕX—ŠS ô‰Ã™¸*A*¨Â\—+g A§ _ÁÛp}z0TBèšx°çž¼÷ÿD>Dõ{?°âôŠŠD0< Ü·9LÍ—§ž^íß!T0BõŽA9Šål¦B»TÐÖ¼‡ÑB M¯ ÓÁoDí†#[Ü0±²[07#€†‚„ )0À@|ç( B°í0Ò:z M'x€ÑŒNAáoQˆA%–#§õ©!Aj‡–ÈF€Oï"P¢=K_(pµð ³Ð +zøÄ`¢‚‰m&E¯ÃQkÄS€‚$„À;ùÆt¥0LÍNQ°šÌhƒÈ ôÒÀ$0D @€Ü~@”¹!ÿ`, `Ñ…NHŒ0‘7p ½ÄoBˆ[Ý `‘B¨@Z¦ÆJ4€½'ÑQAb’ ¾¨ 1Jà °ŠG®5:Vc?Ж6† ß &Ïñ‚Æ VŽ=@ u2‡XЧœI$‡á,¾‡dÉC\6<@Ž6È*‘Ñ©JÌ$F;å „A%Þlðƒd‚Õ¬D˜L!§wDpGS@(©tâ9À\ Aà”Œ«.û‚ç¯Â7ØR qB5\C„MðÊ‘ ˜«Àï™ éH€  L™DHá@¾#›`’[Ê¢«Üàÿ°´ÊÒ‚h#_`ܸè Bæ`ñ·LÀÀ\S»ðÈj!Qxž3‚}üf4^ûÚLaÙpÀã–}+%p   [ï(É ð@8‰C…9Á¦Xå"ކ9: n%âBHW1 :ÀG%€BRŸ, ŒzB=B¯·Á ÀhL¶³xD/ÍÀ’Ö$„ó9ÁÞéÁî Ϭd6àâ¢_žPR}À~?ØAdbg·ÈDf?‰!h> €<†®E Àîô„~€æ3 ÒN(PtDt_û ,˦¶›Yˆ\7ãW<çu‚âÿ'™`€åÉŒY9퀀 dÅË¢—®k ·]BÃRÊ•aJNyJ=³R•À>á›òî dÞ†„‹ÈBL …,§AÙ+% Ýjêváðí"£€ hÁÇÛ©À40üOA~‚±q$Õ&àÄ$¨ޤò½j.)r¸ÿ1pÐÈ o'k1è4à¾+Wª¬…àñfá´˜ªv¨w¢SYÓÂÆ;(Ü r{*ž«°ëj Òv ÎÆbÙ¡AÀÊÂ1摦±¤åÂïüi¼ìôÈL¬ïª„9£Ä¸¦àsü„†ø ÅÈ£SšIªZ÷i+€oØB€ üÍ&“vƒ `\¿NFξeWˆÀ†K³Õ :°”É›€Åw»A) A b€ÜæD`s^ü—V à E! 0 ¾U“ZÁ¹0Rä»@­ÅÌZÖ öá"üð —FÖ GºD§9‚i{‘ÿ ›Z9" oxÕ€^fÈhy/êIǨ3ƒVPÑJJðµª$oehz F*àˆð@}29•üCø¦ „ïÃi«i²ƒ]§1Y >ZÃíÏ ˆ³…p´øTQóÓ{%~S”€&ØL2@ÜŒ7¼×¬ ìü¤ýŒÐ|– ž«Å³‘i^¾(-hW$ ¨¹I—¢ ²4Ö)‡ò­’Ç Ù'ßóÒA|@€2Ô¥!`–Q„NŒÐp¬ã$‚xÓôÀ)hƒ  -õ¶e˜øwöó/¶óÿÿB°ø !Å|¼ô×A?´€$ [è.PPÀo¨ °vX#Vo -µpøB~ç‚(„0…àíWc<Ð+øgÕ{p°BRþg»p‚wÐAY(5"(_(YtpƒD@ƒ(i÷39ˆx`x`[Vsð?Z17#‚5sT<ÅsIE`hÙ`rø@!i3L®¦qC!®–HBh7ÐT'„OÀø„cÀÓ'édK?¨v_ƒQЂ,ˆPÐ+X,¨¾ç ƒØ\‰øÓ¤Ð!ù ?,YaÿÀŸpH,È£K¸lþ–ɨtJ­>¯ÐËÊ­º0Bp—˜Bn™ã4sRËϲ« OºlîhoD±mjuB[Ntyc|ˆy<‹U …Ž’“T”—˜™š]o›Ÿy–˜7?B* ¬G?³?¯“¹G'ƒ’9C À­­B$ ΟPÑ C æÝ›ÜàÖ$?#ê™?àÄ~|" 0è–—£þ-È0QC‡  @mߥ`X@’¤ Tˆ @¦]¬BÆJ0qÁ ThP@Þ¤ÿÅ@“• ÁƒþVèè1S»Œ) (Ea‚¦š<8q¢j;Žø@Ž•¢)¯ LÈ¥j '0D™r@` #äÿ´àŠ€6„€€,<€dÜBF:Â;‡HækB IZ±+,ìY9NVå®1öj0½ É–ÞžH>@ÁË‚p‚†*ðº’Kú~;ôÑ«žFw¸@Ú dÇž½é^ÚÔæyåe*Bx ªR Ô`དA jà*ð!lVXÁ”ɧÆÀN( — üàbºIÀ`Ö¦+ÝÀ~X1tƒˆà7öÁär¡´-/‡ËD'±¼#!i§ŠÚt„€¼I‚=ú 0¸ˆhà† B‚x”‚£œ ‚ŽˆÓ†(‰Xd t¸ŽcŠ(f‚I àÁÐSÈÿCK?€AWÀÃE<ꄹQL‚ä! VcZ‡$tÆŽ@ËØÍ¼P,…“CÞl $DÈ%ùÎ#¥±Œ«¤)_ÇHŽ5°Ô.&MNG|4ÆR°‚éQ)šI‡¼c¢ìL„‡È‹~`¤+‘ 0ßžæ¢XѦ ¥4"0­)P ,ùAn@“Y$`âPQ²‚3C ƒ˜]›Và0ùhºqMMh2›t¥q™MÞa$5ï@ñðÀfJ¢>ÝA%¸Žæ€ ‹ ³Žô͘IMR× ¢Í_~€Iá<ÆòDð¡ ÐOÀX^!ÕXª]®ÿÌKšoDƒ €Q €rPH¼¥/ÉÅË2æ0 AÃÓvÑeÝŽ*,@\QÁ :k‹°ØÂƒ©¸áÖÚ‡ DWJ‚)°JÒ ¡Ê¡†K/¢ñ°ÐPrü@go¥=¨Ä!*IKW¸ÒÞ•`’’¾¨“BÀÁ?uµLj,èF‚Õ*€ fa•¢b0)¹èH¢¿"j¯ \ nF†ÀðtÒ!¬ FO\R”«@là~€ÑÀð-±×i3€ \"DÕ~w1 ``"HPA8ût2ÇDCí0ß‚u„óM¡Ýóÿ24P•=½Ã5+=5„„¦øg ó`×Ú‹ƒddr¸¦h…(X% Kí©cB¤ ¸µ`•æá;ò2ñëÌᘸäè|ØÒ wX°-Ceäaúï0-m=%¨&«Üƒt¤ %#Í-àÈÁ¼›±êP±,ã l‡*A‘yÀøHT!ûä`xƒî-ëó@ T™RaeÂ(Š”0 —…ë¨*0"èML§M 8Å÷ºbXÀÚ“ˆKrÇæ àªtù‹˜ÌzÂj:< ”CIv¬°`Ç„R§omGfÄ'k‡öº nl°„-a }À²J‰`•à#Ø—èyp µ†õ{}±0Ô÷á +¾èY+pßwÁî$^/RA@€›ÒÝ 8AóŽ1.œý]1XâŸÞ†Süþ`ãŽKþò˜ij3?‰¹€]ãRpãpéø€Q¥gEõððÀõ>Ž^SØ@{•o~Àj¨w8ž{¶á™ D Žm†1‚¾ vÞØÃ„ðä-Æù‚<Ÿô‰Ë˜S”—øB8ñq<æc³1û7ξ°¬€@ "ù­à½:RŸ)Ù!òH€ýë/ñúú¥òÏÿ.üc#!ù ?,Y`ÿÀŸð‡9 BäO9l S?(´ÉrV‡WçÏ¥ÕÚ†ßnW9¢¢â´zÍVçÒ¸#19fg»¬ûOßþ½ûN\Z'L€VbSXm‚~a} !]ûe@ÖŽ¹É#å1€,ÇŸ8–€< ì·À04TÄLCF0:N ÀŽ8©£P ܆dÊ%@" #P ÕT T›ÐÐl®tÜ…t„@Åa€Aq:“ ÍÀ”  P€À*\+ÄÔ8°OL7B>§\O|$lìkíí!ĵoP…`TTÄ2ÁwXW €!@´ :wdE¸ÙÁ;è3rD£ªdã´*4›Î)|³„STBLpùÀ™Ä`À `´v¤¨}N`€ Xmc^{¡I{iÆÿÕ,‘ÀE4P@Tóîè=Ä^Õè4HŽž“'4àéFCpÂa88^B–C $àkó ð²U“ågU?¨ÐLˆúAB9öÃÞTAUŽ á$h²K \pŠORB(íRùAn¦R€pHj:îZÀ.˜‡4€X% E†ÔºýlĪÃlð$eSÏ(Ð:€`-<»Yav¨ƒÒÓ,F¥V¸€¹ Pà1<ü£±Tð³oœ)´@Å»v˜\`8BÈàÏ@$æ —}PÅ.%€á¸‰T 蟱Êဠà€@áø™qÓr¤±üŽDÊ—±¦Ø¿¤MhòóÇ5¯)5-ß4G\ÀäœÌQxr™@õ ü2ˆHA@À$¡¨fM€ Û.¦&¡Ãõ(Ñþzå¿|} ƒCšÞ7À§€*û‘!ƒ~p€BùD4ÿbèW6yz‚©,{›àCü@*„€0yôFË âФP1AÉ{Š Õ€I1ô ÓxÎŒ„‘eh ‘áêÂ!ȰD_ãIJ" ©Õ &¸â2UØøAéLU~T-?ØOÀšQ¤•9 \©&"µ8õic 4Œ°™ÍÌ7á'ÁÐ9J–µIaƒ¢ ´€ÕÍ£aBà¨Æ@ºDǪΞ:`´© õ„#¡“…°€Ð‘[l5'=:’YiŽÒI×r7 o‹# + dI0Åœ5(iÍ„;”³n ˆí¨ÿ r®ä´Zpÿ;,ÓZ¹D zÐþJ.Ø¡ª]X ™`‚Æ À#ð•XI€H-˜NÏû‘“ÎŽ¸w?­ë%³@T_'àW ¨€*æïP cõ•dÐhu_eq“¸7‘€¸Šeq”Þ¢°’ YÜÑ<Àì 9A>£²ûI°ÂCx´ÈBõßù\6 6¤ $LûÆGЉ(G˜‰"Kw‚¿2· ÃÜ;†V…$5–¬@€IÞ¥'!L(Tì_žáÊT¬j@m ¡2ÆžÌ"nî«Ün²Áð‡@Ô:båt‚nÂÃrEÈ W´CÁÿàXW2]Ä Ñj† h8 Ýš¢> G!Xæs¨X;N ç|ÒÎ@Å~ñ¯dº5­Œ7œê’5Ѐ1½èô4õ»1Q6ÅVÛí9ÞðgÛŠÇKDZw„S<9Mn?D.B1|E676}?9ˆˆ…EzœwyzuBbƒ›§¨—N¦©­¨¬®±]–F²N¶\°±¹NŠŒ²B? :ÁR»„B ÆÑ‘Br±Ù"' âÑÌ ? $Ý$,  eK“ W ØàAŸˆ 61B…Qâ´*P`Á†öAì¶ïD8Á,L…Y†#"| AbC¶™*œµÒ…ÆÿM:þ˜¢A$>üÈà!E¼V¸ViÕ¡Z‰$.4H°ïƒ†? ØeÐOB\º#Qƒ ¾2@oL©\ÈЯk Œ÷ãìÐzþÀÛJGn:ÐÜGBʼn P¨»Øp”j[.ÐÀkÒ}+NüêfKÔ.èàe%Ücø¨¨@‘ï”iªHáˆÊ Û œèaÇómº~,ˆp-„@ô œð̧ŒýÁl[‚­¡$N³Œô‚?.@à,<”àí÷rV0×C}OO¼V34‘qy`ÁDP9 Ѐƒ3‰àÿÕ: Ô 1Œ¶AwûÄ‚¸œ0´1ü€ $àÁ P¸Z ÐA!y7XT<¶Ž"}@`LÎMQÜ#B,àë,`%(8àŒÀ8¡B~ 1ðLÐ@˜NÐõÃ^°i¬ƒ‚M8ãbM`à¦'AÐA ™uÀcì%ÂbPASBQb‘uÀ ä˜MdJIQžT@ @\"`Arq…PÁ¡<€TD d0 8P›2Þö¦Žôâ:¤ª,(²`GŒP…ËX÷k< $jh€é4°ã¢¤ÜÖ‹›Q0ÿ'PЛ>¶hYB.yKE;#„ –¬Ó0@'÷„§à6‚N€cLa °€*„+Ø91¥ª[h@BÌ„Ôå#ð³¢°**`£AêÜ08Þôf_'’ÓWÀ ‡«”€W˜… !ÒMRì"ár€|^Í £tŒ=øôƒŽÓˆ´€òdÝhHX` ªŠ:Õˆpú¤@È¢4e¦À8…Ã[ºûŠ7¨¹U:MDEÐ7x*!ôÀñ ‹u˜TM,ÂY…Ð…>6¡5K¾$òO ˜INJí€V8Ö ´º(½3™¢’ pÒÀ¦¨Jñ Ú:¨tàDI‘¦H“c:b °€L`ð„ x¸HI Ðd²„-Íìaè ÜžÃLëpGo°Hà| ÿ–“¦™Lð¢ÕT§wÊèÙ$ W«ãK BPÁ¬Ú]?.‡G ©*wRx BòÀ6¡e«m¬w^ð+o1à=Yõ˜+…ôùÁ÷• 2mkâ  €€„,@øÎ}bÛ&‘ ¦'™‡–À ŒvOànm4nŒM7«P¹a(Ü úìT~c\(, «¬Œ†N-u•¶‚e«Ä¯‡&l̼Y-’ù‡Ÿ +ûG“ Ç ðžB1ÌO\üžá*±£8éâ2 c¥)k/ ;˜@V‰˜°Ü¬€%– ^D…DyÇÒì~ÿ +…khÉ:!Á˜¡áìj£< ç' ¢B[\rh8Ÿûžz p€sµT¨ p°Rp•o80˜©¨TŒÀh[M‚cPNБ¼Ô =Èí";ʽRp;€¼]½$S€¶ ,Æ\„i…ŪqW¾í8là3_2@¤K‰¦ýx U 7k ,‹º(0)T»Á§QY#{ 7H\ò±ãðû9Ðã Nƒ‹«âß‹°?: U[ဋ® É üÄåwp¦À¢½Öi[èAv# l–r#Uz›d®Ô v£ô.„ÃlÿU U Ð ‘u­'‡l$@ú†¨ƒ1±È5 ÷Ò„ r0v/t„ÇioëzEÛ·§¢î^8—™hò°?øV¢t À£¡qéj Xb4Ã#Ä4Zî˜i&óÝd“Ì3=  e´WÇÝ¡ asJè±—™ì£(ðÒ@L4äx?AÐÁ¨ ps4 ³¯úéÍäPoH ú$O_ˆŠj“@¶H!‹Ã1H ¦/‹²Sÿüèß»ÒÏôä³?ð~.¡úÿÀþïÂzN1$, €HÀi÷‡¢æÇ2<$B°~ë÷•î|E°€RpqÌ4F0Pà~Qàx‡à7p‚VP)z†ñpDM îÇ-B` ~7WÐI°y¨u3>(›Ñ@a¡_”TFò·]’ Àðp]…eQĽ§¶¢ ØQ5vlV=ÀaøIÌ!†:††UÞÄІz€†bøqÈf÷G‡A!ù ?,YaÿÀßï$,žŽÃ£ò˜*:ŸP'K8­þ¦Ñ¬vûpþÀ€Á‚ d8`ÀÞ"õÀIøÀ@„6üð€ABÊÞ)ô¥E€$4PÙáÇÿH|°Hƒ&kç0ø±€B6|(á)ˆ J¨› ÅŒ: %Pø@âG†".t bÃY£]Y„ÄÆC‚@  ÊvØ@ƒ²ÞžãÁµH“‡ØFð0DÛ ~„h@vƒ† p…ÔqônBÄ"þð£d?œŒ¡"ÄàB(¢±Ï½$HŒÀ€Œ­?fÊ9Qè (‘êX7… ‚ñëÁU•Ì:`X5oÞ7óNŠâQTŒlpÅÐÈ :ˆÆL:7‰†z´@ª…°·)s=!€A³ÄE 0BD†Uƒ?äUÃ! °ÔÐÓ†ÿ^7ý S00~[p€vðBtP_aNtd`ÀôÇŇÜt@ŒdTÑ@ÐÉ’EÐâcgý6T@Ax ‡vL‰°„À€ 0àA°aW€ì¶Œcfm±•4@AY^´åJJñ„¡‚ $bЀ¨€ÑvP¦#T@«%‚!ù\IÆ^u|q‹.PÉ)_†~ƒ@ j;?8Êd˜8&ƒ`8ÀwâÉéYy*†F¡‰r Â<õÁ •Z4p@E`’pš7lQe ȳ"sÍy ÿÉ>Q¨ÈÀO8ö¡ä^K¥x|Áeg…Ð.ËÐ*@pdyå–Wæô G Á¬áÂoìp“¼Lšv œùƒ4+'¼¥Á ž\„$µ Xñe[8PÅì[„Aòvà[aN  ,À—N°ºöC@ö!Pà³Yô c”ªÆŠY|ÊL”¹×R‰P/T2’0¬ìÃÂ4¦ËNÈA¹e2)t4[DóRâòC¸B,Ó‰O(åh8¼A¹‚pÙÃubP4Ð[•Ö¹`0€@`PÁs‰…?!‹&šØ ÿbBqoPu_¹† 4 3}©<7bZäÞVªÁ0P”á"®™—@±§N¨V•P—‘UžHÁ´ ÀH±Ag«%JPäêY*ÀÀ'8¹ØE€Å >Õ†‹Eap‰O~0‚ô ep¹ ÁZä–=ñ@hŠJžp#NÑŒ,#PðT&H`A ÉxÁO<ÁX" •êù®/ÈMÇNà‚€Ea@^´g°¨†X÷!‚NÈeBRÀ…¸ ³ƒÈHsJæU¬Æ­ÈÕ±³hdzÑÈ@B5 Y 8@¦¢ƒ-Èÿbuø6z˜š­é&WlSÀ.S‘@‹eìÑ )u Ì' @F°‚냀z,Æ `°‚äå ¢²Àe `â·t ø@ xîÑĪ`®T0öP€f¼Q ~á4aôÉ(Só€$³EÉü€N Á ,)Ž5Ø`V„x °’ 8 ,ƒæ&€7uÌêjápAÙàÓŸÜ둬@9³‹=… è@®ØÕ€LžÙèÆiN÷nF…y¡‡µ* ^óˇ,þ!€”>|a#¸·@˜@ZŒAc”;Ý?„ G‰È@ÿhË cìòÓY jB(@Dèd§+¸ ˜†ˆ¨0ê`€•RtŒ"B@>… lmmdd$#x­‡4aÅSšˆ]#Ï]Õ"G3Y²@ƒ ‰(”ø0Fð–²ì¦•‘OnøÌb ʹ]#ð€m]õ,‡6A*@’NJ0-ÿ<à;ÞÂ*F—&‹Ÿ¢$GÑ]jž"y'KÓ¬ªZ(jBjãÆ"†{™J ^•²Kˇr‘iµâì 8 S) «ýxsU¦x M$)Ûp¡&tö„Ò¶4gA £EáöOì7À/8 t%ªHH:›œ`ÀfSË$ ’ƒ'ÈöÒ7葸Ã}$S©Ìe€<@I« ÈãÍHA‡­TàU9Û¶r !µ\Ð8 fj’kùs ò°ï+CYJ€ÎJ-é›Ð>°+>h)P«h´‚›sóm%|xWJŸ+"vRß'Ð 2ÁJPƒåÞÄ$¹ê´ÿcâ,1b5½á uŸ£H_[#5ß‘Ô :ØÁ!J‘™"\ Gˆ¥€ÂK]ûÈÁÛ¥1&ä]B»@b/jÍã^аf<â/X!`o–2ènNþpÂìÒP9߈'öxn® Àþ.Ðc#ŒH¹È•À ¤ÀP0ñX_÷'”mÂ%€úÀ&jD´»Ç¶ÅÁƒŽÜ˯åšëL.€¼Cx„ë³ÑW•è2|i H†x&g#ò½ŸE>èØ) ظ˜Óÿ¥\d±ó´”IFôÓ߇ g}µbx‚@Ëgyµ1G pþ@ü®Ö{6ÐB50vFá ƒGö`~˜~ ‚$X‚ô÷h‚$Ø PÀ Áɰ ´Ôbàð’€ Â+:ø*B *)èþAÇ$» zt _àG6Q@Ç@ÔÁá²}[pàMÆó4_À…qþM¨E(‚‡åð!!ß „Y(g ×c#‡Œ`}0 JPåô*ª£#±%tUpMæ$ËPˆ0%6Ág*˜7="TBÅ+ÆgQéÅ ‹a |Eš$yϰ¥=Ú3$¥P…< ŠÓp ìÀaˆ.¸Š­…†Ð3a‹P!ù ?,YbÿÀŸð·ȤrÉl:‡Å§tJ­Z˜ÓP+äþ¼ËÔO|Mºœ¶ašyF¢„ä7Y9/Û9é ÓM‚•,wSyR9<_?k~ˆ‚Bm?9ŠN‡Fk|N„Ž‚QK‡<𛤤†?=¥ª¥ Mu«°‚°;±·S7??¸?•ÂH9Á??°ÄI)Z¯<ÌÐB  8Å‹¥Ê? ?"? ª©çFgËî?@Äbƒ†b샳ª :Lø@‚D„ $ ~!D)}šŠEø‘@Ã10 ¸¡Ã H,“¯A€ 0(ø¡"Nÿ8ãUü(Ä’@¤`0‚ÂJ ¶ü¢LRFÏQ€àD„9̰aÄ‚%ˆYxâá… PD»ç‰ VõÈÑCß¾(DˆpBo8/PüPc•Ž™? LXÁ‚ÃFT "ë}ýV[²Ãkä)Ž “Á±#"äMëdG›ž‡¤â‘[J²ÀG6a`0U®KÆþ·Ié† À¤¤ˆh#,°IV`Ù($m BÖ^‹¡U“Ð}IŽ¿¤5)Hv½ C—,0ÁuF 0€ œÐD ¬› LÌ¢_t¿ÆWÉt#A´ÿÁ T°„ èÕ®¶ ñ 0Vøš×õUuï=c@-áEÂ@~ÐÀK`0@``À~¤ÄxBÀ¨L7âh`”E qŸüT¤QÁÈC_˜G7 @¨„’•8@á¼¶Á} ‚h{ aCÂ1!"4ÀÓÁyáOÌeÐ"`€oYP×Õ©s`˜ìØ b6fÄ–!!ß8àxsP '8Ш3I`Íe'PðÁ(Œ PÐ@ `@¯Í3fÑÊ£\"0Ø Õ4$²l‰4 ,ðÁ 5›Ä2™±ÿpê„gZn1É$HP@f¹"PÁ‚,8 à¤A½"a@ˆå˜%1¥#xµîdHàÁxåŽV¤R€)T°&¶<€ÁxE– hà.\–ÁÂWáKt“JðÀ’¨RfÞ‘ lÉðå­<ôeD`$Àa{´üAæ ‘Cýµ N¨€P€»Q0ÀAeæTÈ\õxG4I"5‚0:Wš®  ™<àÙêD¥È23 äÔ +™ô‹Wï™,e‘Îv6$ýö|¸W]r¢€¼°LV }Ô `€ªÃÞDN cªÎKð…¯QÛßzˆ §t JpbÁœä™8•6+4³ŒWW‚!¶´„YÄb+ßiÙJÐ_™` ªÀÄxW¡”MÉ.ØÙ\“Ñž¦ÒEÐPÓ¹ÿ ä4è ¨.u„KŠH+“¡ªã"37o¨{³ŽE¤…7ììlŸ[—ÀrõMÜmñ@ +ÖàÙI}„ؤå€(­|ÖúdÈ~‡,xòŽXWðÀÓ®ñ’qf>ÝŸÃ‚àš™Ó€¤ É¤€5«0½0$S’kŠ‚ªv3ÙKí û[,\Éà’üÉóMàˆôIg@¸È‚Ú¼½F ``¦ìÞ|€OâÏýí'Ýûé>ø“Òˆëƒ?ʉ๊Àþè’ÿä.NgAû ÞA*ö¿&èÂÈW +Ös}PYÂ~J€93ÁYЀ{ð€ %e}Q|ž¨ 6  €l€}FpœµIÀ GÐ., o·pq{&}5TED“5D4ƒ¶3Ì@UyРφ ¢àýÚ÷=øÏÖ/B9@¸4Aøl(àæ· ØðJÀKçR¸tˆ†“…ÐVŠ šsS D dhg¨ÖñaY²o¸fˆ gH‡sh†x(‡k˜A!ù ?,YbÿÀŸðÇȤrÉl:‡Å§tzt ­ØŸ•ÊívSYK8þ•ÉÞ®-™J'Ï[·ü‡3bNsa[ÛvmÏhF.kyP9?}CC…Hc.`Z“ŽJ9QB:Bx•T˜žR<9=? €¨yŸCœ©®\¤J­¯´L«F{µ<·µ±H³®??šµ‡K(©:Å?ÒBÅ!ɵ²¨;F ? Ë©èl¨ ? ?   ÙýBî h˜ða^~ @x@àÐ` dè ¡ ~è0®„+^¯$(p`b„$FP@©RêR˜ CˆJœx€C‚ÿù>2ÉUA :`ˆÀ@…vfñ¡`%^_Ì€ai„„À°@à PÈÑ $ø¸®½žÁHŽGTü&\sLά :€gIM²0ƒ!µP$¬Àå³v0!¯¼òØ`$Hð“³4|U•R5eÀ@$9ô:ôé¢Ù° Á"_ EyÇŠe@BBQ#Qš Yæ°JðõÉ'd°92ß­Á¯n€<á`3DÆ€—Ó$|HA.PÉ’MÂZkÄø;Aôõ0Jt˜=U…>ÿfU‡‡@¿†ÀTÐÚ™¿Ã˜P Gðªˆ<8"É#ÝÎh ‚(‘ðƒÎwWÕ!&*`@U|" ¬[À¨Ži pVàAÈ'Ó!Ï[‚_8]U"¸Û:À| „  Œr³ ˆ`"ÍÒĦ Ðá!e ËN­ „Óeâ#^`±¾h °ûæ^¢l`Ã0>S=¿ø$E ¨G*"0@)}20 /!äÀè0ŽŸà‚Œ@øx AHP=t -_bŸpD@æ(0@>0¤på)X¢@bƒq¹4ˆæñ  ÿ˜A^ôü¤‡éÀÀ2Põ&òÀ_`~ƒ#Ü$-~a€¹, i,`Á%ü ò]`$[Ð(0¸'ts„0 (nÁƒs 6p–‰ÌãKû2Æ *P9„è ´h7„P6òÙ…KÛAE0¥‡T€$|‚ö´Gç$àlœ,D2&0Œë|4/ù¢ð—È«çÔ:­ B( dJÖ¿À 1,Xʇ†€~€°—R0Žø ÌÄ3z?ðœÃTð,c”â=Ç8€Û 0¼æ~(ú“N',";C(@ Ð"\Nà$CÁRŒq (ÿC˜€—fÃ"‹ '°å(P—.¸Ó˜I9ŒATåƒ+Ÿ]^S¤´c'Á7¾t`hzpÀ1Fba@£UX"¬“œ&ÈðËXâóL ùHÆ‚Ÿ‰èXªÚw¦1™Ç@ò™iôf$èôØÉ ¢`"‰H%1‹vpRø¡ßr‰ g¥¨N!ŠE«ºâV-,±À ³%R¤ )pͨ¦z„Õ+ Áåb5@L~íZU~p&Pkm<Â0î1d0uC‚Ôs’‚׌éà)ª¾âÁÕÄ=)êà¬VBc ÿ v2¦¯tåÙÍ^B·†z¹@/«prò8L¥½“€’;#èK„G¹‘{îÒ^Ç&Æ@xY*¡NÅà1eïà± ÈoR´2£Ý0%u  â;)X„3E` ƒcúAÒƒ†ˆÉŸ•G´ÊÔ瘇K»C9üEâh@ÈHˆÃèh$`/$#™ýEKOàÉú¥Ôhè ¥ F†« Â\XÔ…Špàlà¤ÙÅnÕÛ—ÝêSµÐiЈ ‚4@»Í>xv_˜›²Œ!˜€â´Üú9ÂÐ|ÚÝ@Ç„F ŠR÷»A`ï$À`p?X]B4P"ÚO *@×f5s ¡¸°Î È};!~JHv8Zì`%€ j`q!ì€ÆGõŒ—kd8/Ø ÉF`nXª±`%P`4°‘RXãUd,˜€Q#YtÌOPs ÒC²¹ÿÅ åEÏ\©~ž­ûƒB¬°½³ó÷ Ä^HÖ[ñmG¬G[B@Ip×`Ý xè@k!¾Þ]×5{AËÆô÷4t…ëG9Œ¨s¦š X'¯h|* %¿o=Èkc)pXÇ#¡îŽTJÕuÞ%HHJiÓ@öTŽéNŒOA©B`;ÂÅB0ê Á ÏF¬ŒåˆËÒÏu, zõk&`éN\¹þÐÁ f΀óD`çº+z ƒÔ4h¹ø×Ïþögsøî·>öãß<´ÆÛoD†ú3¡ƒþó@ܰ… c–ð6· hCµ— /Ö€JÖ$J„»@ªÝ¡„°€†ÕÇ¥ýÑ8h¢1E@ I²ðÇ|q*H$,èËGf ¤1˜uv À 4f`ZÐb0pçX'(J–LD8 Ip jÆ;Šò®ð[N0xâ|C`ÆÑJƒ‡*¿@CPzŽš·ue':É3ƒý€DÞá!BÃG »!±‡Dð†$˜¾°qH‡£1#8s؇?ð†\˜A!ù ?, VWÿÀŸpH,ÈdP(ü$ª¤tJ­Z‘€ y8 ƒïJ.›‹¹ðv‘Ñü:¡Èâ·¸ïx)äøµ7?#€y‰ŠB}"!ƒ$s‹še|Ž$'''?˜Q›¬T J` oˆ­¾I ¦?! º ´¿ÐDŸ$–& Ëp»ÑßÔ†qLƒ½ßÐ!Ô¸å*’''îî ÔE0ðàGA})"4°ãï× f1ø0âYˆ–LÓðÊSU0ü@°Áš0€ð _G).†À2€ ±¡Ã‚ÿ™‚6 ƒJ|ü(ÐiSS!0Ð$¦m2´!7L½V”þHФ@;M4 œÐ`ÁÏ’@À@ƒ¥K0PÀÀBŠŠ>#Ýjýà¡Áš0\—Ä›BιÑD'ˆì%eõXÅ‚5€ñƒbŠ ØÂ Âé #$hÀ¥*‰„vA0€"‰ I\h1à–AI"XÎÐùŽê êvÓ Bª—šQ„Šaty¤Úè¬JÏõ A`°@ƒÙ&t¸´¡z ˆ\Ô€vDÐD—q;UTd@ wì±tuÐ#!ˆöÿH¸qÄQqD0J ìq?Ðä‡hÖ„@€5 lµ Î=z0ÁLÀ ä|€ØdH ¤ D@GtÆÊô§Þ£¡óÁN8æ@tÁA#@0Ž<ýЃˆd`Í! € #Ü¢% ;]€@š%• ‚ w óC Az@°B%ùHv T`„ lBOLYÄLsí±Á¡xb¶ç%éUÄâ )(Œ%„ <Ð \àæ)0Ðå<ÐEŽˆT^Hp©ìD‚HNHÀÝFzµÕ[ÜAn]W„¸ÁAQD@¹EúYƒÿ‹5Ëž’ 0¨€ w€Ar‰B œ‡TÒ¹Bàp@KDM03]ü±‹Â€(o}åáB6 WÒD '. >èÞÄeÁkÊ´Å-q0€g’ Bª%7½‰Ø€QÄ1¬ ø]:ÀṜ€°ùŽFaòI¨N¶" ‰57·øeÆšŒ‚„–†@uôÉRO@JÁM P¨]€+@Nö]M¬§wÙ &NV4:Ð @èÖ€à8uØ-Á¸¶•nH³šÍ93ÖÐÀóKB æÂ Å–N1 @@P”ÂÇ™œ -F @|žcâ ‘É"BªXø¥ JTšÍlq)e.?0À.)Ä ñA @sZY‚5<2±$EÀ Š"t`eg›ÀBP‚Ž€EÚ`ƒ!4à4É”J KòÈ %ìŒôIXIv%„å^à0­0 VúÀÈ,(š½IL‘Â0ùÔÅHgú‘ 1à>ð2¿¨i€UðŠ%(AÖ2…¢'ŽìyS²‡_ò ¨²ðä½@i[**'3¥lhÅ|?µ< RP+SuB‘¥D°@$aœF8×Ú¬QHÂ5ÿ•øÀ;%À¾#%dzR !ôk‘ 0€T~`)™F(ÈÔq6+Mø‡ŠتGR¾” ”6s†±E5]0Q“–‰§p(…U†`ùŒ´à€è€R]ö²8 !£…6t5ÆAiÉV“@ ‚Iã¦?¸× TEx p[ ¤ ”ì=ÂmP´]d@@ZŽa)IB_(¶a"ŽÙPM)˜S_p‘0Úlh²?Ø ¡“¸Vž´Ð©z€"ýŒp6 ª!`‚P¨ÏJ!ôƒÅ!!ÿE48þË ˜ßâr„ÙF@?³BM8$¡Ô„Ijš„ Ö_šL,ì± `4©?Xj”~Œx@CÒ€ ßr¶íƒêN쉄܆×>eBü«(Ià Ъ¥`àX$¨ÅR?Xèe0 ß°€… Kv½·[{† ÕZŒeSð\¹ ÄxñDñ$Ø  ‹ äÕã;¨ ,ptÉɇ7ìÃŽóÓzª°‚ L®*`A'èe]¿¡…Z«pïR¡•à`.D ‚¸àHNIzÒ ·"¼ý‘„’#Šd¡‚Gj$¿±€ô%ÃC…5ÿY¬ è£!o’j˜(ÊÐ2©YÑBcÃAG||“/aç{U„(üA“Óà–´È}t©Ø æ!d—M^z]Ñ4ÛcV„a:µ£Ù,{„éÙ¬?欉50;ºÐÀâEMœ:²ß°‹tù¨ߨµ;Rp‹M`[ ìì3øŒ‰úÙÒÍ …u„6À jàçhôãä.ø& £q_`„ÙîxÈ“q‘ßA$¶y+¼›ipÜäU0¨ ó+8< /¯9ÈóNâAXý¸ùNEœ?ž%.´èÅ,àíÀ!†Eˆ¡o4r^ªÁêJ }Un+„M“¡U/»³yÆõ’ÿ‚=@{Ô.‚«éíkŠûtÙ÷1¬Iíiw{!þ‰This animated GIF file was constructed using Ulead GIF Animator Trial Version, visit us at http://www.ulead.com to find out more.USSPCMT;asterisk-11.7.0/images/play.gif0000644000175000007640000000052510343116347016252 0ustar sharkyjerrywebGIF89a9„Bf®Ýén­ÆŽÊÜ©ÙåƒÁÔ¡Òày·Í“ÆÖo®Ç}´Èd¤¿j¥¾Y™¸Zš¸Z—µO±LŒ­E†ªA§;}£4vŸ0sœ&i•_Žÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ!þCreated with The GIMP!ù ,9¹à'Ždižhú€ê–lüº@´³ï- ü¸Ü©6¸ }¿ä(D…‚q†Œ1«#žv%Ëà)íJàXIe9¸B$’âTm^1íf:›U,þqCi@=w{@k$ lƒy]|ˆfŠYœ’&|‹‡…U™:©©Ÿ wYsxt˜”®+¸¬­u¢J\jy„½:Ç» ]¯;:ZZµÓÉMGKÄ+ÕÖ9HJ’,Þä0[M!;asterisk-11.7.0/images/kpad2.jpg0000644000175000007640000007076011032455473016333 0ustar sharkyjerrywebÿØÿàJFIFHHÿáExifMM*ÿÛCÿÛCÿþÁ# region for console video keypad region = 1 circle 34 80 30 region = 2 circle 83 80 30 region = 3 circle 132 80 30 region = 4 circle 34 121 30 region = 5 circle 83 121 30 region = 6 circle 132 121 30 region = 7 circle 34 162 30 region = 8 circle 83 162 30 region = 9 circle 132 162 30 region = * circle 34 203 30 region = 0 circle 83 203 30 region = # circle 132 203 30 region = pip rect 147 2 163 2 16 region = sendvideo rect 115 2 144 2 16 region = mute rect 83 2 112 2 16 region = freeze rect 139 20 163 20 16 region = pickup circle 31 57 70 31 30 region = hangup circle 87 50 140 50 25 region = messageboard rect 8 220 158 220 70 region = message 8 220 150 70 region = dialed 8 0 80 21 ÿÀ'¦"ÿÄ   ÿÄr!1 Aa"Qq¡ $‘±áð%&2ÁÑ#4BFT¢ñ'5ERXbr()3689CDGUcegtux’•˜§µ×è7SVdhiv…†‡™¥¨³·ÆÒâÿÄ ÿÄJ !1AQaq‘"2’ðBSb¡±#%RÁÑ$35CDWcr“§²ÒñÖáâÿÚ ?¿Æ 0„0`Â`ÁƒAƒ ! 0„SCát’t¦ecbêl ÷¼*ñqpûÙ)oí qÞáM7Âô}Ö|ì/Ëá fÒÀäçr‚ÓXhde–Û5Ö®UjíüV9o¬Œ…ù­åZVEb[’gM½5+šéľṹ7\ë{%—UØðü¼?‰n ì-³q]k“B‹a=œî©¶Ý©Í¾mX¾SwV‰ø–\ìE[M&Õ# ÌÂèªÁ_KÒ]1â®U®éD‹tÌ™ÞÉAĵ›‹*ßk¼½ô+y îÈ+L–’’Vg å5&R¥É–’´(´|øt¨ôͶÈr ÉÍʺÉ5Ûè¥Ê–k/$nÕå®Ö݇׋pkJQ\K¢âОÍKœ£l®.EŒ R‘•;$•b¦ô­mmŠš¥‹éÁøAÇö(¬"÷Þ)Œ¢Q$™CãQÈ®RlŒ…úE.·,ÍÒ;ƒcfhËúÇy<îÔû2d@™Cœa™Ñ¹Ñí2+SW«¼³¿~ 6·)îSh¬B~ã9ø90›{žÒ¹…ŠÌ'm¹®´—B’7G O*‚JšM‰Û™lé¹UI¬i•S´Q +¥wšNÁ\Vs6öh’ÛåyÚà’Ó4›tºM/[ZØlݹ²x›4y(‹B¬dFûmÏ–w c|Þ®¬iLRxÎçm“I¤²1z§|§*Qç‡àÙ5[6¼]e|ièîXʆÉ{¯Á¸Ü®7 UúùA(”‘:ªÝô…5-‡½©dÓN—Mm¥™[WW5Ì­ÆyMl´ÕU2”ŠeÌ–*w„.d‰J9†J·7§3¨¨,„¥ ®äû>YýÍüÇ=|ûÜD¢Wa—´Qè¤ÒÔ@­4–é4=ëïjvH„ì+\©Å#G¨–N™]fò¡!Ûé¢íË…Yˆ­ðQoL†ÿ]þ’û§,iŽGœÝ£yŽ"CÓ¼§Gcê{m¼.<ÌW÷©4†º6(tI¤«¤27çç##3‹ÓÓš¥K+ùÕÚ‡ÊûqÆ–‰XfÓƒ*0ÚêpÍ‚J)ìöjê¬)c«¸QÐJ–„¡2Q[>¡N’¥©JPÞ$ÄšÏ=3-Ôë3¦Ô?{»:`Þ\ĉËJT¥îÐ6Yº!Gh5þèÁÿÂ_Ñ8ô§ù£ýýOþá±ï=ÆvQ4ÔPà<>ú=\ñíÈÇ)KÄJ"ÄDCPãȼ ³ÃMÀ† OøGXf@äIøéøtðŽ.¤5P(ê Rˆ5ÐyéÄtÐ@|5ðyô‹´&9K̦Р”L:ðÚãÄCjb:^»óml´v¼–{/hˆ7Q§P)©yTDX´P½:¥ž‘„Æy:fÇeDbSU"¯M5CÒ¡T @«^Ù×Lÿv–½¨·q3d·ÑÔÓ‡gY¨5juŽi¸qˆñh)Ê HÔÍê‚‘ûà„Ã'.¬ÆÛ[˜ ËEζXš@*BV’O²îKÛ@zñKh›wÁ[8Z)ï7 >­e!iRÒÛº€\9-žz¿(´¸»&(ˆu”õׇ¦Ñ 5å˘éÇL{Ê‘ùU¢}zðõ§ÏNZéìÅ9:Ls™%sªê†è5Bi4 Š5 Œ*ŽLOÛªÕ ”~M"¬ 8S•’™=!¤R PÉbý+y¸‰!¢‰Åî qk‚º‚.²˜‰;ÕÛ)KM°êaÑV.°†%%ZqrUëi…ST%ud¾ÕÛ?Tã(.qeQHÝgK6¹¾E߃F•‘ÛofsjM9P»¿ºÖõswuâÇž¶üíaT¦-#ÒëD¦ØÛ1ÚÀ˜Jc ³´%Ô6´0?4•– V!«”ã´d¤¬ZOQÓ®¨s‰„QÔC.¡¨VrÊôÁ\4Ó–t9€ŒÆhAä.-©‹)!“µ 8†<Œç¤ðØîõ)­8ë„#¤ª1ÂÆŒZI¤S•*"xÅ+²®¢è‡¶PJÓL"çô6Ͷµ…v•K:¢ÃXŠƒ!·H Ω›ŒÃƒãC7Ýùô¹l׋5¶÷Jâ°B-ÓDˆ—VôÁÁ,5¡öI%ngÝ6êâÄXÔ w¹|‰nñTÙYÖ®ðÊTH‘ tÑP> ŸBðùêˆhi˜|Ó‡ˆëÎöñðûé«ÉàQÔ@Ð :êcl€qCÀ4ú4Çè&(h"<µ~Z>|½zxëÔ°íÇmXbÕIbÃ;^Ú†²[å™t{=Åv›U ¥¬ÍTº;}ÖE%25J˜¤É”„™‹Rˆ*R‰Øs-ÖéëïgPQM›1Š—2–LÉŠ %·”©eJ` f„gý ŸBèꓪº‡?ðCæœyÿï´=_XcÏô6] ¿Úu[þQ§ÿ®Ü<Á1@5yãÐÕé]j9€˜N ¢xý~¬eOhþÐįod)#t…m; @pA½³bEºÀY­GKUð¢§:7û¾‚%ëè?èÀÌPZA¼9i©.ø‹²P,ºZ±-æ¿ñîëÙ»c½{ëÝ6Mø,›íÏòŠG½åN}§ñ»ã‡RŸ©ÒÐÙt/iÕoy‡Í?¯‡ú7éúµy"zf95Úüà xòÔ@}a§†ž:~£ ðgc­yÛu‚ß"ÓaÛ&Ô춺nñTÖÛNÐq]º‚œÏœª‰ÆMÚM<žþ|Ù“¦÷rÓÞM˜¹‹u­J<¦ZíóW6ÝE2agTÊI R€` R¥’XÏ  š—ô6] ¿Úu[þPù§ÿ®ÜW¥úÛt.ôRæV—Ø…­~»åccWŸ½ÿ²š{]»{Å>¹~íw¯¸½³±ü]oMñ¾ÒöñØ·] ßÚ×}¶ƒQå§=u?7?æÅ*:g¥å·½=Ö.|U“¤èpÎ4¿·ÛÀÛ–‹»9oé;yívöäŒ~X6ör›±uÑ)ÀÅd½Ó#{ÿwÞ{îSìŽÅÛPÚVѶµzµm#h»dÚ²l·hØÄa3· §a_¦.˜^Ä«¥ºéË'¢®¡çIÆz¦M¦—ßwµµ(—ݘî!££¤¡–ª:Ku,éµ´rÿ£¨çîK52Ô®êl…!lîäKd ï †÷ôºtaf,֔ס1D¤lm“eÖ×u]$÷僻6rØ•Ðhy»·jZ7ر•éÌ;Ã!ÞÒ§0SøáñÀh'Z?ðçèbãþ"ïþ(ùœáÿ7ÁïÄ«°Ùäi¸60÷uû:]&]dÊôlÚ§kÅ4ÌlòÞeíʼntšJV@%t貓]‡-«S«©%wˆÒ„^s4ËØk¼…¼Ÿ÷³wź‹é)f½¹Ù»öV%ž»s–Èiî4½VQò6Ì!áwòÜ¥„˜Àí\qF]ŽÞÔKaJÜT‚»M/£sc}*–1!,5ÊœŽ{kÖú›K³M‹`äbË^˱.8DÛ ›egk ¿Y-·;Åò‹ \gZ¨./ˆ°Õ\¦×ã:EO²×^¨é§®U^,­Âòî–óS UmʤÓÍMlš®û×EŠ×1h—)SR¤wFh@M9SMDµ(™ º¶°ßÁ½Ù-½GÎÍ\£dB¶JªE‰—wê3Gs³(7,ƾæ‹BãÇØ‹ îh²H„w()ïzƒxõ;‰Zc_ü©Fgfù˜é|˜ç)šäG³))}É{ýÌb»1i"rÑ]Ùƒ1«bíë¢R´MÏ‘æd°šÑºPæÅ(è'M ,|­€f®ÅPæ>"öÞö|)ÚohV[EµK·lâã&Bqÿh2Q~Ùn ¿ÜM5ÅÜIA2çs«›oºW®Q¨¢\ƒOICJ$QSì\71ujI³H+*«A&ž])Ý•[Q)Ôò7eIXB„ÊyKS­V÷(l†ŸÝáMúqç<êð¾¾|y>3ñèc@åýî‚ÌÜ9éÈv‹ üüµÆ†¼·J+i¡r ¤ÉÍ  *#¸ºº:ª) £H6OR­Cm S….À˜j@ ^[[ êHŒaÔ»%KN>¯ðÐ ¯ 8¬ßL•ìxt˜Á¬(ƒ"AoºªŸeb/R櫾ֶ2Sšˆ”KMÏCÒ!ö”¾±×QbFi’W¬ö§ŒQƒpuÌ/va”¤ËsªØnätÍËçâáãLí¿hv}‚n7ô¦«¸™.”¸Êr’ÍØ±.ÞèZ™ˆÌÈÌÝÊ[pg!Eº‰RÂá©”‘Æ5‹´“§¦M¢»ÏSgkò†FJµ*Ÿd´éž  t\¯ÛËg´°&{U ”AU¢”qÝ d.”ßwq+'~;«e24/Q -JoužˆbQ|Xá]fÏZ¤jçÞÏðtý¹ßî•—›²„‘1EŒÂUºK€£«`6òãe›=¸v”Å7K®"¾(JDõ-TæjŒÂ•+!-\\b©õ²}™:‡K„¢ÏHbPævY{Û»œª£Tu{{|9êÇÊÕ"F-)ñˆÿU‘@Dû&®jެT J¼P¥•Œg¦ ‚—´*0‚4ÙÔv€=zxsçäÅ4(Ò=C J½U"T=@9„ûS³>Í1F›Z«Ä‰”ɘeLp‚Ä2†®ýx³îžÇ[#Å»>U}F!‘6™5 „˼ú„䬸jÙpà#gV(jCua(j:ˆ€º@4ÙÐxŽ·{26ZÂ4S~¼w kØ\éµ%y›Jc1F5ÏÀÜæçº)9¼¼Ó¥Qì´ZÝõD¯Öš›"ƒP¦zt*˜ÚÓ;Y dÿ-WfüÊhÓr$,U-¹ݮœ¦Vò¦›4*-Ué…‚H¡˜²™Ó³lÏ´ã*hEÈñVT¦¤"ƒãç!šÝßÜäÌÓ\œÃO1qB2$ðØûs]\1¥íæ£ýFhk0¥M=­QÒÈK&”Ê"ŒñòM%rª±ð1=)‹±µ’eï%Ud„‚HV™¸äy yGÚÎͽ˜ïûv»Íîi,´e"¦¸ ªÈ”î ™‰vh"Òù‡øJ¶b%)KË¥™_¶&²”Ïå’§›FÊ5÷s%fŽéÚ/ž¾›GWfY]Yj"dUjФII$:…å<øI™Ì|“¹(·6¾ÄAáê)3™­¢TÛ;Ÿ¿ «Qš‰ßk8KÚ§¶Ñ…Þ˜HÈëM=ìEÍE!ZÕ•W-U+ØÚˆW/FÝB“JuFHÜ™KÃËTe•÷g@h¤²Çg˜ã#[8 *[¯¯ãŽ…C§Ø5ZåÑë[oƒÍž¹Ò({´’Ad L/å)”¢q‘ÈÞ屦—Q¤wfàgcUb{yŽR®UA¥sëÆ%RZ5:ÉmJYCŒ1®$\ÕZ‘») bB$’2+VyŽeôñ 8“³ßeý…SPSí£¾ºÍ”’SS9eU»¡JL‡"ÎR(ÎmÿÂKÎkT¡›…nldÎ.œŽb狲ϠO®U ×TìU[¥î“Ë–ÄÐSÈj4QT@IÍU%JÅ£Y2¢ “ŠÛü(J£»ñåºâD‚‰–>Úc¸ôÝ@hºƒ½WRÉéÙÑeª”h7žÁ¤)ÎE%ª³pTLs©\·àîçº$’dóXÉë+È•EP6HäŒÒÙ;cO[ºZ·KìŒl:TŒ¤c•®•ÄNOVˆÒ—U1jJ“#‰¼m|"S)€JÛÑ,ƒI¤P¹:®Ø¼ˆä÷@hzi;»E cz /m …1 b˜@ècÒáŠq¾ UÍ;ÒÔjHZIõN Æ ;ÿ;¼°ŽÊ[s™SGƒ—&MÊžXQE<õÊ™-.–Qœ‹ êÙqú6dW¥#,ñNäÕk%o¬÷%©²‹óí²Ÿ ¦Á1laÊÍÓ–I n@Ôz4šÔ.$NC%·xãT&å‹M$d¢x'ÒãÐ=*ÙŽƒfÙµ%ˆ<2ÇFìÈD b~4бéýÌœŒ›¼¶ï±  ¸ÀØ,Âȧ³îqZ•ÁdEJ[_qg6š{¹ÖÞXí›B¨?E¥‘úÇ#£s©j’µ1%B…*ïLÒ#±ù„jBJ±ydUÛº2ðšU‰x^…ΔWÜëDÞlõì®ƒðŠ´¬±çEOÉW²´¦¼§JàÛñ€ÕN)ê¶H£Šš3xè°FéÄc²§Æ³EÖG»áFôOgÔ8ïf²Ÿlêþ0¦8¦¡­¶J¹›MŽòÆ\¹u’SCˆm·[q3¥ '}tj›,“2Z‰ö¯ìYqÙj*nôR•sÂ3&K˜W1©æ ÝåJ\¥lAöµ9¥!J‡ÀÅÔd‹ŸþG¿ö¤ÇŸè1ó‘ô{ÿjL^8ºl†œ„5úxùzñíxÿ¤³¶Çûjÿ§;%ÿàqóè`ì:ÁíÙ°íuúñÿZçß¡‹¡‹ö"? ðHþŸ„Ä÷ú|S÷GâŸãKý”®^ÿßÿë.êÜ¿×-åò#<¡´½¥ãm°ckÖÑv‹zý"ÆX‹èߦ/FÚm™ôE¦‚Åoýßb ¶Z©ýÕl¡¥þËC#½î;ùýíLÙÓ¦ghèé­ôÒé)%÷4òwû¹{ó&n÷“5~¼Õ-eÖµ+ÖQg`À x7!öÕ8ðnCì«HºŒ9â!D°Õ ¶9J"?æ!´^ "%ñÔƒ²:j!Šcç’æ½Ý|ÍÝ·GZ&LXT•ÒÛ±µš«UaE„<=0èÌÁV¥`“È)½HÆ¥J•MPË ­R¥x°Ô5ÓΔ+Ô¶¶Š$9hAÔG^aĈñ9è)#;}‹¯´â­Ú³ïí‘yóµIeLòz_”IÚÞAÚ•u¢ÆdìlÄ Ô“P˜î8Õ¥‡U4ŠL¯ÍûÁøƒáEQÙ»És}ifT3Ϩò}cÊ©¶q‰qî —E‡Jæ®TîõTãÚœ’ ‹’O\ÎO¤ÕP”S†Ø”ˆlŽ€!Lj쎃ß1 CŽ,пqå —nÖ-R¡\b¾-!jÇ#´³¢Ih»³% §‘”ê"a#Òš¤®G/ €b’žÄ[OÑšòS2 2;3M=A6¯s†Ö£Ä-àˆírJ"<9é®VM2oÊ復ÑÇé›Ü&“5¨Ì×!’:'1B€OaŠ–ºŠøÚEHåW5e eJärY€ì÷²,u…ñ1¯¹Ê›GE$úÈ$;1̇Ï.9;“ÇÌ}•¶´LŒWq½Hl·Ë.©j+JgUÜ02úqÌ"zÓÙêÀxjv 8ùpÓ¨Q© ˜…Ó˜€hÐçõ}?±C@õaÄ9ó Hcèb@(NðºólƒëáŸ6Î>¤n%)X `¬ѸåŸÊ?¦ AÚ@5òá`a§Ï®r`â¡)O²”§ÀùE‰imÄ¥aÇ„§ØHOTy9b9f9çS-$¡)O‚@<8žC—D\0èÔ•²_ʘ«‹‹D¥¡¦JʤÉÌŒW4=µo¶ZœuQ©LüÄH&ôÀDM˜ãœsŒ*e1‹ÛسÄÂ`ô–;bH+ÝV@ˆ‰‡dúq)„D±ÔA Þ”+œü­áªÏ²2@cúŠ$R  ‘MÃñØì½è;Q˜ù‚6!¬\шڜ³`=zOï§ûœÃh[]Ç»öñ¥µòFЗ}¶ fïÂcSâ„>›»"Åܲ vŠi »BB³ý"3 ÏU¼Øü° º1?{Œh½Þ¾öúi·ÄŲÁ|Á,p<$ ÈËR3lÊ6ûdfâüB,ÁÒ!šÖWª.Îs–yb ²?!ƒÃÛšÖp…bŽDäeÐt -Ð|@7 *YÑŠæEXBåI¡— *n(Zk,%fÙÕJ ôÅáâsZ=Yé½×,n Õ­Ý!¡ZX4¦ Vdk_^‹™¢½‘üÔÞ«û–‰…ÆŒÀ.Õ´Ì$”—ZrNÓ7|¨õkŸŸ¨E*2"ÄØ¢j’’pÃ4Üfpsš„Yô6¹.g^ÞêÔ¹KkÃZƵ¬îÍ+7kšOôé˜ëêõzµ @ԌΧž–o!JPôK³óûtý

8ÐÖ"ã'»V†q)VL­T¦>Öàîf´.míH¥:žfØÎaN SO&¦øšœJsuA¶5f¶7àˆÂ(Ã,´f÷i«£šå®Ë·7µ£q\èææ´Í¨R)Žw7cTê˦”‡‰¶D6ªDœÈ˜o7I´Ž“ÓÔrÄ´3ÒP;Êd·\‰ÙÅÅÄÕ¶ÆòÄÂRc”锉L’—˜ÁݺµáQJõjDM—ô¡ÝZÌŒð0ÔæT…5I´Ý"nôÜÁ©¦ ³Â@)K~Õ’‹ÕEЦ1ê)ÇO²BìíWo7”¯r¼µÝö¼·µ‹Õî} f²"Ç]™ñá‰éá‘ìÒXcò¬}ñîO •Œ¼Ûɶ*làÜ9p†´ÝҚċP,¯rÒ½'H©±ZÆ—8,8Ë@à fW“Fã…•Ò0€ˆíHp `€ƒÊÎ~îì¥<æ1³ÂçN¦Q§ö§:ôâÒ·»4Œ4ÄI  h;!¶ð`Â[N‘ØêÖ<ÕJœÖ×L¢„æ;’´ ñol@‚†üÐD „¼œ¡¨èSD <2ç#96¯&©Tþà8¢_'|#²[qm‹dšæÊ@d…”ÆaÅŒ$ÒP! mÔ|ÚW‡Ëî›,³6æJ"Ú†UlÓèÅ7•py£(;}0v1j<°½Ò¨C±KHÐÒSœ¦í1Q§B¡ Z)¨N{z7Zï„îÔ&¾î·ÖÊO¬KÄ™ê ¦Þ¼3Â\ŽæööÀnø²¾?Ç%¦S$j'ˆ˜LRóÈC€g*wï69€·ùÑÏ"q€Æ`Fl™å*MOûÆÚ9 Ⱦ1½]B‰"Fƒ¦l=g|æ3AŒôè$@,Þæ‡ìi‡öýô—ÿÊ êã:ÊH$7~BÝ5ºm/që@Ø-kR#R™Õ±ÒäúT_X”¦1L6ð¹ Þ’”}!Ú=”EmÙ(+ˆårÌ59)H¥Z¸ÕY53%¢dÝñòpÊ # ‘‰ð¥9GCÊ`Ó^8–ø0aC}+1å‰.µ°—WTŒZ_`.qĈÈ:º„%ò£ëÁĆÉÂhÌ:ècÚ鄽}.ë…µ{¿"‹Ìælñœ^]ãöÙ¤$20m¡·ƒ2Œ’"RGbó&›Ô8’™aŒRqªrrÛË1V>3˜ l¶ßÈkWd ­¨ì… T­QšSNr²»1ÍH„†wuaPc’®¦¢%!êÒ¨ZÔ_l¿KíÚ‰»»Ð¤«#¯É]¢ËÕ›yÁnTdŒæ#ùYBAù1 –>ôb¦1NúbÏÀ S!ðÎ=¾È…ÇË4§¤‘µÁÆÙÞ)Ô?6²·‘‚ëË™ç?¬l EµÐ†Vf),®.k‡~ƒ%6¡ˆˆÄ’Q2¥4ˆž1ß„üèõ¸7.édÃ/Sk±IÎŒÙÎ d —Ï ;<¤ä–EwUE‘"ލµö&4ÒÔ€®­1Þî7TŒ°™¡v ¡¬n¡ËM‚¤sb™O†”†Ð£²0É’Ùz3ãËcylÞËT¥UBs>”Iš ” c!l-80‘ØÅ0VøSИtc§;,tj4ÙŽGâ¬T¹¢,ÐÓeLeX(Z·#->:‰hÓ¦N@'úb"Ìp„0`Â`ÁƒA*Cçh¶ÌbQÉ«2e­3D®:Ñ$o# ŽGp¢øZ„1ÊjAÚˆ††Ç.e1‹ÛسÄÂ`ô–;bH+ÝV@ˆ‰‡dúq)„D±ÔA;\^•wqª¥¯·hÓÐ2ÖÓ%OU îÞØ,ã¾µ…GŒ'`5'à%0LeÛ{5b„¦„6x¤µEõÞ!6Ò uRˆ«S‡±GW‹X­‚,4iˆ˜Þ¶¢ÙÑÍ }¹C³²ÔÍ­M‰W:¹º.¦ÞÚ‰¾™Dçsw5^¬ƒèÓ6‚mŽg0šžƒ°£®ïJ Sj·f»3,“²ˆÓÍfªÌÜÒzä{…P‚²¬’A#RÔl=GXûLjC„¤Ø!š0YK7qO#ŠÚKa‘Pìì(‹K².aå–­TjoJ‰t’!-=åRS˜7£%rÒ|Q #c'¦JUN4h‰¢"ÊbƬ„LÜ0a1Šº6!7(ivD™É©Í#ŠVÇD4ÜV·Ô(íŽå«Ö=†Ð ·ÈåÔÔvò¬)+×ÒS ‰¼;G­„X÷!Á¢¢ôÔ¥ žŠ‚ MȤ¦ o,‚AÛž°÷ŒkÒ9Ц*A–§r*VNrÊé¡ñ¾ÁYõ-ÎMVrÔ5;¶)­o VæÚæÚæ ]™j‘ƒnm´JoÞê6€#¼p€t¤Þã86)u[5í$Vß½’35ÍÜ\+…™Ø²YmS}"uôª ©€6Œa3Ëfvíî`Þ §X ÄÀ¬Ñgw¸¶=S¦Zªx[éL”ïå ,„à1Èš¦¦,«MŸØ0`Â`ÁƒAƒ !Ù齓ËÔákÛЛ_»‘©­Ú›‹rÉÁ™‹¿ž$ðFܱÎ&†‚L"Â[0¥Mzãf•…Ú5˜«ÜÒýK¨rSqåd©»P8›g[õŒvCP.±ÇÆ3~ôGd=xPÝ%³œÂBò·"A•øuÇ–Ý‹‰!n€¡u¶­.Ò ¼.ô üÏs1Gå@îË ãåÝÄ*ÏI3$Ðóê€Bfb3»t®¾r²ŠÈܹ+fT(æj b;ÛùÉZà×¶nÇ7´/—ÄÎ̬ŠŒ†:V;Ÿ ‹œòrJá3:tëÌ`Š ßI‘ j;;u¥bâ0\8½u5­)š’ª+xÊ£D1Nóz-Bœ›rŠ…-Jbb›`ä$ïA4§VenÌ>19è°‡[ü¬æÆÝòÃq[LÓºÖ–9ºÕ 5±otaM r2–}qe¯ì­4 &‰–¤Ö{Dº…iX…+MÂäC4‡Äeã‘ÄÆKŒIMšµ=7aÆmú,Ófb ˆÅ ‰éùm ‰Rˆ€p„\­­Í ¹;³JÔÎMNi—59µ®¦àÚµ¾¡@äsh5.°èÔ.¢]¾D0¦¡·•cLY&HœµY* K"Œ[ˆ+#ÊAUÛ»«AÜ»zG«²”¡¶5Âq N[ŸB7é9¼…•5Y(ëåDÌ"ÎÓ%£mz ¹Ñáèä³¼³ž TŒ½èÙ1Ã]ÿ¨4éV‹ÄÆ¥Dúm®uÄ´¹X·Ò+kq&Öåùfa"ìKd6ö^÷ vZÖ{ew žcÕhõŒ$F1%1>Á„==I´!f‘76œÔN]œ‘ÙƒTGWÚ¶Ase8{tÅýä•…ôš†›[;A .sƒ&óo‰»œ!#—Ç Å²±#šï¶oûœÇP–ÿB<Ú1ÑûW\¦Ê%džƯ¡KHÕ „h a,’ä°­µ=(Ù©¾ÐWv™úë|“<»”ØúÖÄù9Bo bï¶ôD¬‘‰À”å1Šþ$׫ԸpqyL¦ "h”EÞÔG_˜Õö¶‡T T˜¢Cµ@CA @ÁǾéZ·Vc&ÊòÚl·E¡¢ÿÃï sKTRfXöÍ®º ôà%6³B”é*½îq„f×űÎtgµ323¹”ŽÃe,@ËYÁR°±Ê_élµ‚’‚0É¡¢CÓ<¨iTû?¹½˜e–=h!Öb1žf0ªßÚœ·|6ÆœJqñ<¼í <†©¿ß!1’ó8XÓ¾û”Dñ9McŽ•&ho%º”VBPb¶äµ)*À\æÇ2zz)DÚfÅL£Ä^̲²Óélš9_î–Ënü×¹®wzx†ÜH]¡›Ø§u&¶ ”ñØ„Jìt¤UÔS%X´®‰Â‰‹TNC™­7xé;ÊwÅ͘]!ΜFS$‹C¯M›¶Yfš@ZžÈÉ!ÌmX@)Å*H†¤yŽk¡(—T‡BÉÞÈV…ÔïY uM®K™×·ºµ.RÚðÖ±­k;³JÍÚæÓý:cæ:ú½^­Gþ¾æÌWE™ì5äü+n¾c,„’u¶™Ž·÷¹an4¡ÉÔ¤ù¥’<”À0(ù£dy)"eš¥šÇã=ö™^hMa$Eøá´6Vn½KÕd`ówgª%gDfix%qhq“0˜Œf;Õ6!5CÉŒBJ '¦þR…Ч•X[]lNìùppusH L®D–MP*ÊnÜÔ-ö#›^î€<= âd¸B 0a0`Á„!Ig·).÷PÃyíª%N³vFƒ$–B’³% F¨axb!iQß“ú% TD• *%ñÍ(Iª FœJn1s F¹öZ¬}שQlþÚÇ^Ý–-«d ÔÉ—Ôjib‹ãü|щ3á ´rÓ§× "ÔéSêè–ˆ Kk÷”{c˜û“—»¥9xš eŠt–*ôÒØÚòìÖþAÖMAö=,)˜°fjB‚ĉÕÕ¨%¦:º„w ʽ߳]9ªl´§‘T‰2Ä¿ã%ÕÞ¦Ë02È)V·‚p!fÂr@MÜLã0¥lÑl”ez ¡S¢+3R¥R##¨YJ×ɺ¦p0HÉ<‘Jã¥Ú-B”µKÏIJÿAƒ ! Ï:YTQ˜¸Ãt²&Os Íî;¥ªMM…·ÕðÇ·³£HJbÔî+b wù)j#K 2ŠU76y<²ù¦šÜf¡K¼=d C°ƒÄræ[YAY‰ðX_dÁ¦Ø•i ï“h³ÈFÌLå5ï± î½…µ7~‚ª3˜nR¤R¶¡#ºÔ%C!DÞÌìW²4´ÌØÆŒ¥€…¬;f¦‘E!ªa &¨cD;uÑ«d!W¢1%—üßû‹ccoƒ)ÌMÇh¹M±Wj.‚òÊúÉV¬z+\$qÓš@¢#H•JšZDŠtiM¨¦—Pw¹Tʬ§1²‚×RU‘Ë\Ƽ¥˜ËH]®Ø(Caµ¿ÀÚÆ(¹]e@%"Ä!ò÷kÈþTãniQÙ¦õ èE*iÄÆlÓL@4ÐÌ’I,¦:5טéÏq­± }¹;KJ$Í­M‰µ65¡¦ÞÚ‰¾™@„lh-.¬ƒèÓ. ]Žd(ž°„ mˆcíÉÚZQ&mjlHÜ…©±­ 6öÔMôÊ#cAiudF™uìs!@´ô Œ« !Ã5sE˜û~ª4.©§1µõ_!ò%Hª‰ÜÄ‘ØJZ’>îJ H´ëŒ\ôÌ5Ùc•LYPÅèP¯Q|øä}£2æ]–ûÞžI—F$›ê8æ˜NW(,ñÿq»ˆ¦$n,yéø ]Jy”1ôB –4 ÛãQÜ;Sm.Z"žÁ#sDÝ•á"a~j*÷Tx‘àž„*HXºúe g4j¥… ¦ Š}JóØônÏœo=»¦ÍÜÓ3 ²ä•Ùè›Ä•ºm`“3¼GžØ¦oïì7\y»ˆ%3A ”ÀñøÅI¼Ö[‰žg£—|»Íó7M‹'3s;X‚É„áR²"Öq v@wü€?QÐ¥/f“L=”¹Ê«rô©¬ú5 T V”®²›£uJ„(NîÊû'«{›ËRsjb ÖJ˜Ìr7g¢ÅcfŒ46{+y™±µ­ºuLìE%2˜tä@}! @GF-l¡1ûiŒAc©•¶.ÐØÇDÅÁmjfµáÜZ(%-WÉ0”²IMr´ë¥JãLv«T³ƒƒ B 0aÅ]ÐÇÛ”;;-LÚÔØ‘Ås«›¢êmí¨›é”Nw7sUêÈ>3h&Øæs ©è; nât YøÝJèí¤ZMq”&TÞ=¡`ZÛU§¬üJgý©(œž‰t$?ckhDj”B2ô“f RïpÖXVµª[b1tñµ’ä†F-æ•IŸ›Ó †µb¿Æ£÷V*ÂJ}QFjbõÔŠ "':I¿KÑpaÍÌ–&ý—/rô’V§µ“SZÈ…Ú¸3?ÂwôäF rcJ@Ãè±J%0ÅB,Aé_ˆ9­®žoh$q¶ŽÌ™dRFÓ5u3†¦¬¬Œã@*Ç(ˆ1àÆ­…Ԅݨµ5³‘'–0ö§^”®Í€‰Ù§Ñ3SÃ<‚˜?²˜‡&ÈÓ5¥SU¦>eYÏ—t†åN­Å:@x¯`.'p ¶ÉfV, º#…]Â/¡6~Lh”ÊúýŒ²¡ŠÔÕìÇ-8‘‚“òA|/Yþ)Ýg²ª"P&ŒÆ÷y!Mž:0³0íÝ™”iÄŠiI¿I!† pÑÐÆ50¥ Œ4ˆEº°`Á„ Âͼ$öbßÕ’ …îìHšˆ+ZÈ ðjŽÔÞE‰Ýž¬Ö ¦ÁN&ªYΩé'̪ f›!pVÎY„t^gN´Î[{|©ggb}9¸S>æ}ï˜2h^ì3ÔNyiiÖ‹;Y°ŽäÆÇ8Þ‡¸ç{\H£Pø”$#}ë’=Lfa|4vXñîÛä ¥Ú(œì%¦]L`B,²ÃÒÀÌ©å=M—zf`h©Ö?=g¹¢6ƒþ(Èûˆ o X @D@8b}Ù»ÿoo«%Y ¿o"·nÂÉãõ‘ÖG%‰¹;´ôßYꈦ1LéÓQ­YšAÔW%«T¿>ضt3Yfo…€²ùäµ¶28ƒ3ÂÒŠÜM윎dQ‚ÎŽN6ÆlÂÿß‘S’½Zظʢ•§!)‹4˜jŒ1ÜZ›­.³ö™¤)Ð[›@­F¨Æ#só^º½³¼²JwÖ˜ä¨CôÎr§)LEºðc_Â%H§è„ÁéÙ¦QÈÔ:½AÈϬ¤{¢W’œD #N ”D¼ pÔÆ.6ƒ êóçÚÉY÷—ˆ¸ï¹ìÕ{¡^ÉB ÜÉ)c¨ ÒööùT´JNzãWº‰¥µ¢`Ë!A $«ô‚fUf­óK4Az¶9•Ã\î… "S”X⬅¤§iz)‚›,“ñÃiU8ĤY ‰Sº@j…ô‹æáó%ùsSu"ÌmoSwÉäZßÁÈšJáÞoÆ~|}ï°1IbsG»¹›ˆHI˜Æ aØ)ŒT"ÐÍ}+©*®n ídÔ·5[x¼,j¸ÆupBÜ~;LŒU-ÜV«ùKÈ)’± %Ú »3’ÉfªÓf•Tðµ´$Méª-xо ;t½¸ÌÈGƒlœÑ—²d &‹U•'± ©XƒZ:¿8«›q:TrkhmŽk¯MÝ„^¨»³a3—ÎãÛhPC›i°ÇšX®¤6PIDÏ,½¢WR†Ljƺšz Y€•üY»É_²Û›éh%*S&ugŒO ²¤È·fðj~d3ë#ÉØd%ãÞÈãæÈÅe :†œ¹† GL¼Ý ¼Önrk#+žÙÉEéÓ™hIX]Åð€ç©PÌc!ixyëF­§PD `(H¼! 0„0`ÂSÜÌ·.nÌ%÷¤èŠ»uqºSµà‘JQo(µ¿<¿¿±=ô  îàêÐ6ƒŽœq¤pà:Cò¹$t{{Ì\% 9¶ƒSQ.#ZZOt\ÛÁ„¤§ß‰Î=kØA¢54=:tË ¢ÅNtR£/¯I72,÷:¶ÓèDv^ã˜Ádñ–yûX`®ŒÏìLS&Q$š~ðÅt 8ì̈!ûÓ´BLègŸ¤ÿgyzw%Ë/ÍMÖ+,êLÊðØÞ±­ì_Š÷4d|q‹»Ïoò~ëK"s…šþF@ÔˆøQê½;“ÝeÙ$}ípS"’Ì%³agx÷®HôP)^wdRÀvؘâæ6È ÎÂj†ÔæÃwÊVäY›7º:Ò"[Uwn{ªÑwÝÅ.È ÈR˜™úO´SUÐÀ0¢ ïšÿ, ehleŸjs£]½á¢ÕÛ$.íJ„9·;P†1Ó¨ÐìRmV§PÝUBìí€ÄÙ xàÁ„"´ Í«ÒfÎã¨p@¥*wTpEÍ U£ÔW5Œ-…„øˆj&7À6‚ &êÀB¶ý0îVºIcíýƒÅ¤SKá}®CS6Y"Ì=Û\ö3:3wÇÉMéFv€‹IÈj³Ÿu„h“¾°Ë¬ç÷+r[ÈЊåÁi‹´â ÖêÐéDGs;JbjƒÝ3…!4†*c?(ÐS!fT_µŒz”b1:µ-Ï>O_3>Íj¥VÎZÕnïþ]§¹V‚lòËÞFº˜7ùaÏ,¡¤j› ¦LÖTX„À!ßu Õ(̪Ҩ„,LÂ"¿–røä§0Ý'ËímDzVŽF¸ä§.jßTŠÞM–i 5êº,oÑh”Š|I9 ¡'©µf,8;€i Q© »ö'†¹™=ÎÆp$ê-œÙÖW™¬»6ܧxM‰b¼..—)ÉLÀ0×׫‚x¬–<À§¹´bœª)0R« ë)BfhÓ©~ùw˼ß1ÓtÑh²s73µˆ,˜N!1›"-g×dÈø Rñ0€i4Â÷2"•{fU-wTJ+‚)2îÈ­ 7í³Ië°€€@#•) ´"a1Š; &šØÃ£Q¦È„r?b -Íf†˜Ó*c(2ÁBÐÈÕ¹iñÐDKF2r8—Ó.c„!t©·.§{¡Õ›Ôƒ:«XÔ‰¯dn^èÇ1‹ã)ÃGÆ06 üµ ð®ïH¾Qß3¡—56®,øÖË7cžE®T‰Ø­ñ­æÂgæ7Þû j_',{»“y¸Ä„5™„`¦ ƒ¦¹t²Øó˜+xÞš3M0܈·W˜ÍJêŒÞWÖw¢½ÂV¡†8ÃRW¸˜Žy!Ê'%Fq¥Lñ@“¨¬Zžæÿ(ï6VéÆÈ^ôSv4ìS§¤ŠãË;µ9‰ÎØúÆ!!úEóÓÜgº²Øxñ~ÿ ¡·;òΓ©ÎGÄócá¦!h«¿W\gvÚFåyÜBåÀX lp›~yH[é $OŒ²É¶Ñ‰JcÝÀ@Ã)íÂf/#%¿ä6Ê?ûØì7ÿŒ£ø‚‹º-'÷æ!C9Y×¼9˜¶0F˜ÒF‹NŠ1Nѵ8:BCñ#Ìáä²a_¤!|{‹ÌäÄÙ¼’ýýûUí)„N/"ÔÚ™uç—´ÂáMbâìä¹jÅE1Û˜ZõÑíáåè€c±0˜Â%2Ǩq¦9ŠQBgEûcŠ<½?Ö\Þ¥:g[©&ZʵJApm8;ž@J!Ô ‰…è… ƒ¶È"(§Ã?Æ–³áŽÍ[=³lªZÈaì¥L¡hJwsÏO¯& ‰Ž“Hñ%9ö´Uè_Í Ó„ Áƒƒ B @K—Ñý— ùT®OYnÞ©@µS¥µ^Hè‡VÎf*lôÙ JQcå!‹«'¦s¥cϼ@K—Ò—T¡O0Yq)@‰S]µ@IXÎgÚoÞÍV/|”…9‹”œ¬' C¥!Ì{£K-ѵ׺ÁŸQ=˜e’â·7£àm\ˆx ~üõ¬rk´a SôÂxÆc‘¸‹=(³4a¡°£ÙX#ÌÍ­h5Ъgb))”ç"Ãéj8Ñî’Ü·IW@è7Döz–DJâÞ³µm! 2 ƒð×Ô@@‰ ®ÑDãOÐã‘ÆåÌô_bÏŒÒv‡2e<¶95¯ÓA©áˆÇ¦c¼È"b¢#¨ˆaÌ0`Á„ Ä*»0±™KëÜÄY•/ Os‘ÊZék‹CwÈjÓ|##Ó5Gbu$Qª‡¬zѹL±-P-1¦‰©!µ‹£.Ít]\œn|½é^<ý$gmlX`.‚&«ŒÅ¤šè$1¥@PÙ>&”ÝÂ-“"xô >ÝhEùÉ™PƒmU†+M&‘u}1 ýôäd¤CHåÏV±P=c˜¥BÖ.“¼»;¹Ñjrn¹ñË­y ômɱ„ºˆ”zM)’h ¦Š‰DDGh˜šP[‰¹¬‰ä0)t­¡oç)e\UQ˜Í4…©ô¤(îÒî‘Í”T%Z$9DôHc „m\0a1î¦V,¥ë®¥Öo JªF­šNû°©«•j4‘ŒŒ % ÈjFHÌÎ0ÂË\TƒÔÓ-!DjKLD»©š{)e+©j›Í’¥‘¤F毹 )ªÈåFm$|S Ž1ê’b<³„0ÒÀˆ•Xõ5 Xa hDsmèÇËêG *ë=]—ªÕ \±©ÞGÇ ›;Öá‹Ò‘ÔÚô€*”¡À sq1fµ²³6ÆÕ2n;}l‰¦®ŠŸmìaQ{ƒ‰ÌwºÄßo/ây$„ä;Ó°Ó©)©XJa9K²" 0¥·¤ã/ªÜ(¤¬ËvYh,V ÇWxäL[öôo[†QVGLgÒ¤b) ĦšÖÊó[ªÉ¿-ôá²Xš‚*}·±D Ç)Þè“}³?$‘ãœì®ÁNœ¦1€æ.Ѐˆ!« B 0a0`ÁŠ8æ<Ä!'ô‡æŽHÖö÷—HJ°lm¦£ÜGDµ^ë9¸ñIS¹Ç:¦0‹D–hJu*eEöœ§)B_BVŸñ»³2â¹Ç0—Þ«¢Úî5ÂéNе*…À ÖÂòþÀÄÊÔvC» QÙðÂÝÎÖ_^³+baЮî&»±™^àYYl®[qáÐ; Á²Æ4¯¶ò˜’8¬yéì°“”f0Иš5ÀäS9Ç1çóÌyÂ7-Ÿ»öêþÛ¨ýÚ´²>öÛùFô܈Þ#€¼Xž¤ /¢,ñÈŒ›A‘±>!<°Ä²‡šI_¦ÍínµHªÕLÛ‚^Ô´÷c M²&—²Ó¨%~Œl”µt(ŒÔ¡âbÂû˜†2_ÑþÑ”{™u^Ð-ïdE$v3Ëô²C9—I.[°Ï.µ²›2°ûiç(I¡b°óL©™öSRrmkT!&9?žcÎs ÑÖJµÖ2Ϻ¹Ö®àðïjí’çwU@ \Ü]«ÃêTwv16DkT¨^¶¡¶¶„Âc펡¼pqÌyüóp…kŸÜÒIlÛB+i¨-3‰Ó[«»¤‰ÝÊíˆRª ”Î4€²QŠþ¤¡På†ÑcV)*VˆË)S;¤+4²ßLlX2¦ãI˜ ÄÈ@K)ZŒÒGKqc}Là¥KÄc²Ò‹ñ,—D¥e„B-ýÐÒj½Tº'bg%êógqÓ¸/R©;R8"„ÊÖh(ZÂÂü ì|5ãà›@H4@W Ê”‘®šÜ‹Í$Š‚;±R¨C4¢@5#o3Ðd¿ ag|5>¨ÏÕäS˜Q §Xjç³U) .¤Î9?žcÎ*Ç‘òùæ<ã!‚_lÙå; ±fºòF¯•ªÌbÕ]çhBÉ™é–EP!ûqè᢯ò)Dˆ"gŠša,ËëY;¥6‰Œ½L:[a|»æ"o—ºiLYAœYÝÌ ê—­’æ²k²!¸$ü “Ž¥1x 4…â¸ý% Y.zú*¡ÌY¹‚ú¼Í]âlQÆHÇ-ȰïÔæOl´ÉPA€cð‰±K'03 & §§N"j…wX8æ<þy81ä|¾y8·üjJÙ/ŽGåLUÅÅ¢RÐÓ%eRdæF+šÚ·Û-N:ˆ ¨Ô¦~b$z`"&Ìq r"©{žU-‡UªëŠ)2Ö­X8˜ŒSIHˆˆ€c”é ²Q)Œ;@ šØ8æ<þy8¤@<éfMç/¶ñ½Lf¢`¹Ån¬ÑšuÒ™À¬LìÛF{šž•B„qú¤S~±ñ³˜zV™%aQDÕÛrr\ð½ÁÕÕr—'‡EŽ‹^–o'5îŸéÓç!×û/_«PÃ%éSq]R÷Bk8)t¶±©j&®ÖÜÑòc;Ç£!>Œlb" ]„g@â—3.³[sž³»vÙq®åÜu’bà~Aîa4BJP•ØÆ x¨J©Œ88æ>ö<á ï1ø¼v§öG ‰[Cå ð;niLÁ̯äÌyX ;ïÉ{Æ]öÁ俆ž-VRÓ¨bËÊQ1ݽ©ºÒë1/išB¹Ù´ ÔjŒb7?5ë«Û;Ë)§}a)€J„1OLà!Šr”ÁBïð¹ÿ¹ÿ,Óý¿ÊçÿúÿžÜ\{.Q1±ÖÅ—.¨wmW兩GÚæ.‰×åæùÏÀ$¥ P=„œ¤•  ŠÅXò>_<Çœ\ÖÌ\v;Ël ÷1²‘h¡˜2•J„B%1ÛÝÊs2¾³â8ž3 #ÄhäÙÐ HM©¿8wNEû›ŠÌ½?Ñ\à¥Bf«©&DʉJ±om8;á™ÚDLÔ‰ùèåc¶ö 0œ¤Ã?Ås<ÇœR 0`ã˜óŽ0‰t9@t×N#¯`‡¬5ððÇ‘)uÓ^"mLé…§.é.³¹L¦á¹êÝb¯Q×%-¬‘s6VqetÜÊ)¶UQ7§^©F©‹Õ‰“'9‰´j´hF‰qÐéU²@  »a¦¢?‰bC ðÎ^a¨‡æè!È£¤’Ÿâ”¦z-sæËS¹rVBœ'0[=Ip[O›´\5N{•\yié odž§=#gI._å- eúkF¡Ê#'¡G-V+EÀÑI3Ref0Ñ¢VÔ•©Šˆž—Z@š”¡Z°©4D„Wxî'9~n\Òío.k‹{’é7¸F¢ 8#)NE †§ßsQ9ªÚ™õ.Èkèl”J¸n:Ü—¾ÕSVÜ£¿Ö꺅 €T Yb3ˆâFðg&ç¦ÿ:¥"!OK«‡£1–¨œ¤¡Õ nåà¬H¢lõ Í÷•"c7d–]]›ŒpIƒڸ ÄþÑ$ýFƒ˜Ï0N@ž&"¶$f[²ÿ'ÌËnŽ6¢RöÕÍjî4±o3gdM²G’€˜Ò)Y@Ç„@vHSt)f¢^Š0L¯"q®3i5÷’¶0dqhE¼ƒ¯"ý4•ùþìËÍPà JE!ÚK¦¢È-¾2­hc‰â¶ÞÕ\裮Xº³jVøºó.qx>ÝGwEò …VFôcˆ(:ªõŒ u bÓ£ÕÕX'ÏR r)æq É”; x‡‡ë+ j.)|˜o†q¹žyqˇÂç£ê¤ß«£ê¤ß« ¸:U,–œakëø’%õ ßÛ¨xiä:²©d¸~DÝ­<ĵ_ðߎœC]–˜éýÄo•š§ƒáYû<Çù3äýfá|¿y#‡ùƒîÿ^=>óá$Ù}•KÌÓ{¡Íë Ž‹4骃Äè㌕_ÙÞXê‰ ¾_;ä=aõ FB:i‰,=J¾çc$ѼàÇ`5èͤ¶žïYçú’;Auâfwqs‰:á„ ,fÅH;"ÆÂ~2Ø|Ú5EÍHÔ«_—ZÓöUl—þݯø–#áËOË~!ôiËà ²îJrM;¬òë Œ__#s¥^¡[ãÈ"ްQzß%us4?¿”Ä”J"rÔ`ŠÊ"Q ݜ皧j0V%,‘g©¨T…0öA]ÿ'œ¾S¹w}!­¦ÕZ™uç—5Bámbâìä¹jµE1›X[5Ñíáåä€c±°œÂ§H…1ê@”Êc˜¥‰‘]=Ò­&š^ç¨æÈ‚†Ö]ocn«Ž@STv»2íJÐÂBÅõ@bmjöÎg3)v1„ñëkî»qœˆ€òWú袋d2ÇfFŠMÁùï¿u[«º¨4”é"TTº¾ötd¢­e0ì8+3 5AË_GX%Ãë“ñЦaC˜¸¡Ë}týÒùõaÈ{áÅAâ¨`ø|=ZêYá±ÈÔa¡J£\NÚÄÍM–‰ž rDÁNžÑ€¡¡jí cc=ô}Aô›õaWJ­’# »\?ÖHˆÐ3p×Çݦ¢8õ•[&~C]Ý]SoȳÑh‹å6–Ri½I?±*U LOLÒSTb{úÃÙý•k !¨BîÈ›£¹"aÿîÞÏÞð tåÆ Þ‹³’K¸ôí/Uò„Kª¼-ZùG¤Þù#} =CÃÌ}ölb˜¢c(1‚/^%R`G©R³¨©U?d¼‰˜½ž¥ L…’ħ"œµ™NÓp¨g¹K.@ °5ÜsÕÜ7':Ðeß!’ÔþÇ!¤Òë`æ|¢~e¹:ÌþLÇøAnîÂ<³"J)CŠZB4Ê2ò w3‹Êg2ˆ¼]‘D‰õñ_dikJ R­(Œ&9„@¥è"&àˆˆc3gO`i-@¡ögwWµö†ÑwDÇibŒ.(} lç¿’cG:¡iÔÃh:“éÆmY ×äÆÁ²˜-¯½'‘¸¡ªâ^üš(å!ro;¥g²2š¸Í©FØ)Ã@Àž5B1DâÌÀ5)U:T†gbMÐSg©Q %»…¢]LR3}4p8Ç/Ön9‹ŠA-˜Z@Ïq¸fï×™ÌæÛòók‹flä ÛÖXUËÙÉ]íuE&TÚ27çmþþ,Æ9)Õ@»;„BR”hÐ-:f ¢†Dz> úMú°©ÒÁc)éùwCNˆb<=Z~Ô:ú¾~?ˆô³X ü‡»à"hô@  ‡÷çÀv¼t(¯PŸÀø˜š¯NŸ³žoÏNf(6›…$\¥ÍûÄà’Kfã><Ü9k£§‡ŸˆÖ÷çƒ ŸöX,V¼!—oN?Ö(Ÿ=ôßôùx qýħ?¡j¿ä¬rä–çåÖ:Õ´Ì.ÿâ’¸}tgì¶ êãRuäâå÷£ý>Îßޱê<ýÿf7eñ¢&½7^?Ó2á˜G@ïSÖ×@5Ð=~\±¬ú?Ùhà±)8zÔ¢„—•+yÀ/û9g7Ruñë¾ ¾Ÿ;ö“ŒîC º È1õ~ÿ³Qçïû1u~ÿ³còþV%+ì‘ðzÀ´ÿ´_Æxn·Öû£ä˜Çû—ò±ÈêjûéËÛ¯/v¸î(ÑþÓúÇæ ¨ýÇô}` °ñÁå}’>Ó¯AÝŸö“8}c÷[ëtO¼¾?ÔyûþÌGŸ¿ìÆAÔyûþÌËùX<¯²GÀ:uè"›“¾Ñÿ˧˘Çú?Ùƒ©ë~o?¿-|¹ýQçïû1Çê¨ú½Ãú°y_d€tëÐE7&ý¢ýëWCü]ÿÜtýGŸ¿ìÁÔyûþÌd‹ýGßÿúǪ£ê÷êÅËÉûü)éÓ †äï´™ñ«ÿ>ŸŸ3?Qçïû1Çê<ýÿf2Žª«Ü?«~¦‡U÷õ{tóû8á½ eÜ£áGé ÝéçŸ/EŸ¯{3_ã?u²}Yqm\¨ó÷ý˜:?ÙŒ‡±§õÑö`ìiýcô}˜¶y_d€tëÐGîw¯£©]ëtOÉŒZµ¾Ì#õòõù ~£Ïßöc(ê¨ú½Ãú±Çê<ýÿf.B¤€J1}Äh¦C!ÓÅË×rwÚLøÕÓïô$Æ?YßêãõÍåŽ?còþV2Ž£ÏßöcÔþÕ÷Ó—·^^>íqsý™¿º— ú‰l›ŽïÝIóæI¶ÝŸöÓ~/¿t|’øÿcòþV dGŸ¿ìÁ‹W‘öøSÁºtQÄÊšK÷³~3Á¾÷Aå:öQÖðݱÖçÜ/>rÇ¡áêà®:qãcØúî½ÿ7ÏíòñÆÞ¼”§Ûà?÷M¸FÔe{ziÃQz€iÏ )øŽ¼¹øxù駆£ã¦®¹Â aëj7€"L·2áH:ŽOüøDâò•ú’%‹–/þ^eœŒÁþQ‹öN}xýøó =¼Ã×ÇÃ?ÏúXüÁŒ£±ù+~§©ÿù6œ¹òúuá§·ÝŒé¬B}¢”ø’#е{»’Ös`É,CêÍàG|ã§ì~_ÊǨó÷ý˜ä,’FÑŽ•ßóìš9råçÃù¸éŒeÎŽQ«­ T€xÿS4åà:kâ:óùñÐot ’éÈ#–àÌéĹcÀ˜ÌÓáË´Ö2é RêI|ÊC5'6 Þ3žÇ[þò@þ¼qº?ÙOZóþÛòânû­ZÎ>!È<|øÿb<uÁܯ3ånÑÔ>nÑþ(‘£ãdzËÇÃÿ¥”c"3uãz| pž^`$¸%‰>®ðÐ囇,Ü D˜¢ýCÙÃ߯¸uùÇc§srcgÆ®­­¾®Ö³_¯æýX†ë'²E•hurÕ_Ýœµóþo Ƴ·,í]wi ?v{yóçîòæ6ߥ£§˜þ±—FÏ·7fTHrN_Uþz’3‰ÁF{ÿ0•2|ë>~<|>g†;”k–~Þ…rU:YÈ}~¯_ÄGû—³è›Ä~~cÇŸPh§0×\e îUÛUuèW)mÿjqÓ@çåÃèåÈqQ‹RáÈÈ??ŸeN¥¨– )en‡!ÙÀNAùåÐa£±ù+Qçïû1¥Ûoz4“öä œuãÛ¬£ž£§€¼ý\² 7²*?»¨=¶ð×匹sÓêýq˜§Ä”•)sªYßC£îÚ’9èÂ!•86íN§–IfNA9d? y쎣Ïßö`­Gö¯›ÙÀ4÷{Çž5{•튣£ò.NJ=»·N~À 4×^<<ñÓ¶Þ¾ÙUGnŽvdÉ9vGÆ~<üCÚ?8b¿¤t<ü?¯â=ý²0é (¡ô/º “¸y>¿>©ÑØü¿•Ž=d«Ö?7–1¨=½zçUI¿ñEŒï^οO¬yãÇÆ¥¹ì½}yn_ÄÞw§¨tÓ˜x‡Ñ‹‘z¢,2rÜ›òÓ8¶¨°ÜÊ‚Me“¼%žiåÅõëËXÈ:?ÙŽEjWßë×^:iãõcøÈƒ‡gëß&íAò?‘€yð>}¾ÌšŸ©~*umr×—dYßßôkϧº †ºeѸð'–` ¹XÏÃuô¡*ÝPv%-ì¿‘-¦oÑÇOÔyûþÌÈ:?ك鞠rtéŸ6ãÞ†¯á? £afíÂ#W’ï!VµÆºÔJâ7.D(œrK^ÈbmŽÐ€‡çqÔ8ëÀDt(æ+[´u o~]¬Y¾úòãKšêÕ©fS1ƒ[Ša¿Wp@57%ð@ÈÁêÔxxi#ûEj]E ÊC×›žžï/h¬?x&×@´”ŒºîË,ts“Æ7ÅÇÚM\åîo)ƹ’=Wã¡ÈD˜x¿ «RêÚ›Tx«VËÔ>!÷æ!À5ÖÎsgWêº:®R§À~Y»töŽœ>®páqFŠ é“sE¢¿§Ï‡ß\y­[±ëÔiçóùkÇË_£•7Zº•TÙçë1,AÐdï¯=41ßMGGG- P¶èÞ)À#7lÁv÷¾¯BÅ•ëUQÔfÏnƒÃïìA厛©¯F¯íë…O‡kæ?`rñÓ†¼xqè¬ë¿sü§×ÚÑùé÷_@c‘×Òê€ê¨éðÓõ‡à´ô¥ó=>÷‡áÒ3ô“e‘º„'t€¾ƒ·¿Bü´Ã¶~Õ­Þ_¸øëÄ|5â<¼¼µ xìhkRù2Ÿ0Xüüuñâ>ÞŽE$T+uô:L£]?¾z/¸ˆû{ˆL=Öa#ocdjí*,ìB?úóNC¨ú½a 8ª¬¥*Qp3ÿëÁøôÊ;¥Ò©K!N¥6@ñ)võ[—ËÆÐ³66½ÚtpjBùdÝh÷ÒÍìñ»w‡}|ý^ÝNþÂøÌ©Âƒª)»*ÎÅÚÇúš¿OXúõÓÌ}€8t“-ñËnÃòŠ œä ‘†øYýlÿqXôõøbæŠÀW¥S#ŽW{r‹ªV+V$V³yƒysåä kÃ]"ò1ô°— D6¡ÝÈ©#Ÿd#?p³…[ÖÙ½—ÝlÙùtü"VF=o> |<¸yúýzý8íÇåŸ'¡CEˆ}üxyê:ùfí¨÷’U@U%pH“¶ŠE|AÁ¯ÀG·ÃC”UÕž’ŠëvŸ‘‚ÝRs@?XþŸf%bäˆ ÈË6âÚfþ¥·Tè:d<GßÏ—XÅëU×äýGg×êÓŽ£üßF£ŽEn½b_âÚðñçâÖ¿O×ÇìUèRëúŽÍþÛáçÃûà?^šj8㬢¹$ý}pþ8?Oëòxbé5JÕ!Y¶€>d6ƒ›{ऊbË«Žør tÐ>_€ŽGíê§ëÃå5¿Ð:‡ˆ:úÕ«ÑT¢…äºþ~~?ÓØR£¼ª§ÓNÑâëÏAý>±ñÓǰrGB…£À|ÀtãÄCQ9éÏ–œ9\–Ô·Ž_šc¸N”tÌ»åÁ›ɆPQYAb”QJ§èöüþ±×Ùá¦;ÆxóÝXrÎJ?Š«xÝ­ž¾_O?XÇÛ|{?É~ß«Ë×ÃË G(½}h”áp®Òø'ñÿW ¯]}zŽ#X“ÔÛ)="AÀÑD \°!øiÈ ýŽÕIu©D­Ä–#2Ìî—SÈó<ãCVÉÍ÷¢×ׄ¹J„¨ûvG†o—‡8-GùôtÞØÜ{mW¯˜Å^ãz|‹åŒ¼4ñösÓ׈=™Œ©òÞµÁëРÉDòaeX“»O.{‡ñ.£çdž"¿H¢=ÚÍmÓõíª{RÉBÕ‰jåØ80øëý|áÃN¡ÄmçWrE5LÕn¨†€]%ÁgÅÇ„KïxÙODjU-ÔbwXÉör.däÙÂ+Õ™Gè $ Õ×¢@ÊyðÓ–šqúpcCTiVP…70Ôuë¨ÿe¯4<ðcný?=L{Öp rÉ=u'?=ú^m’Ð&)å —Ì²sÓ¨oŽlc{fŸ¨ü'³ Ô~éøï»»^ߌ—Ýtòõëú±ƒ³Û‹—wû qÉíL¥ngH“ÇÕàÿPŸ8ÿsÏž6b©(¯™üÃ'¡ªÄ]ÍH;^†—-øv| aâmuÃÇ´°øã6†9Ù›YûíŽÝŒ7žëàüú?üñóþ?à>½GY6‹e A–—p@ _\߇£aÙ°ònÕ5 Pa“¾LS¸ß–ƒ«h!w­ÉÅÍ£`÷H±2*œ*’wŸ±¤þ© kP£_¾¼1 ÖY›¸xP]|L­®ZŒ>@×ÇÔpÔCŸ³ž,QÝF­èÞ¹ ë’n˽;jÁáÛÝi¨‡ˆî?ÔÃ<Å^@×®Ú¥BTaØÕö=O_†¿«Ž"Ò1µYQrJw¼Ù²ðá™÷D®·SN£¤¥iHÈ 3$uü¢¸ë r6z]zæ§$ÊrùŸÑ§?XÇëÑu£I= Ò§´ñÄb<~ü5áÃ]0ò+J õµ¡\?rëüx=xÆþm?¹ã® Õ­šÚ +¨Fý_+GÄ8s1ýzú±)¥Å´¬7¬É~`°Ë«·ˆ|ºE)ðU), f8î€úê‘gÊ¿S_µˆ†ÕÇﯻ‡>8f?´¨chÏß[¨~F yøéÇLjŽÈœuÐq${Ÿež)(Qº¡ SŽ¢‘c0.>›žºðà!ŒÞ7ƒ·%Nj–ö¤}…D‹=\>}CÏ_qk{ĵ5T›´„»«€¢Ì i›7>2+5“Ѫ^­!YÄò$éïË<Û8ØÖP­I:z Ó|”XÞ¶;ºn´~R™…#xe™-dX{£KÜíµ6ʵz0*A#2äj•8Ôf{´Ò:‡š—°×B›ä«Ù¯‡—«ôc[VY^·È?Îý°G]8x?VžÀúGƒÍôo¯¯h×Og? >¾ãÑG@i| 8þ¾~ÇŽŸÌL$)4ù’’àAÙ?æäs¸M™QRAËRÞ© ,Ù8ëœ~ëW£T(ys xð?P–œG½z=E ®¸EO‚?WÓO=@yøkÇ”húšJu'×ÛáË}?V˜ã-YB·g ~N<¸ðñâQÐ4ÔGÖ#®ºz°ŸR*˜§ –w˜lò9;—Ÿ*ÓÓ1c‘vÏ\ØÁ‹iË ºµQì4ÙÇùµ ~o^…¥auŠÇ!ÈXš»0þ+Œ|­fƒ½uEóÈ8üüÀûj:ïʛСùMKÑ,û~o¿,> dÏ*£ÙÚš¨%ìí{­j=í§õTY7ááÏ^\¹Ž˜Õî©^ŒR Iv ñ œ€ÌjtñwxÚ8*”… +Sªxæèrc®s0q•FÞbìt˜ÞÔJ7§c{çTÂÊþý¾øÿ¸l|¹û8b;f¢6Æåo¤ß”·n¦îßò\Õ¸ä‹"èžj;±xn]ýãÄuÐ~ åsd•;Ói ÉÔ’…‰AÍËñqhÙŒ¡†M’G€mûýoîtÞÎÇ÷ûŽ pœÜ UH)Ôàö¡ çË@! ð ô%<ÜJu%÷«ï1çIÔã½^ž×ÏóÊ&mâÜÍ›|ŬV`1\/•Ü*2•0Å)î[ð<€Ž£ ›@Ø1„ãÄ Á ²¼ŠÃ¤5tŠÝ$HíÐt×—Ò80b€ü¢iÀxŸÉ1â«{uFizt’B%ÎéEJ00nåDvv½!ãÀDD4Ÿ¯­`¬ê¢…vf±N•Ÿ¶ðH‡åÇQáá qÁƒ53‚ÅÁqÍÿúŽ®é¿ý#¦E×Bmff¡¢æ"<¸ýx[ÕØÖUW@´h¥ê–ö1€=5ñá qÐ<<ð`ÆVËq«P;ÓJ™D‡ÏŠ>±ˆ»[hйARÒw'ö5çóÖ6”  f0ê5«eW$j‰xo¡ÓCè:é§ñðð„Å'U4Ø÷#"Vµ®íé«ÕÍÄiðe7æ‹ûðæ_ßiƒ!8â¦rª ²¹6EÊ]ÇLM0,„S(¥œÉ%ô)aá!ÊÍboq^Y;D ³vx0Ž‚!ÀÚkÇ Ã9’šïPVäuP& °g®ˆU3—C_Ø‹£Ðj"ó„@t× b,$ªá@„%Ǫ"E|ÿ>'ó±ê¶…]‡¯˜~¯æ÷ƒ7Ì¿îåÿÀŸûDh•j|OçÿÙasterisk-11.7.0/images/font.png0000644000175000007640000000301510741001435016260 0ustar sharkyjerryweb‰PNG  IHDR@@Áîf•bKGDÿ‡Ì¿ pHYs  šœtIMEØ!8p…éžIDATxÚí]írã D¿ÿ+ïýè%1èAÀñõv;ÓIScƒX„%(… ‚¸P >¿ týߟ¿–ù¹NŒÏïr0žë}'nm®Ũ$ŸÒ”°eü, ³'êûÀì/¨;£ÛŸ%ÝÓ½ÿ Áž h²®ªOÐX°ßáWÓÏêp1IeµØj+:äìýO?cFFbAÔ²)<6t™#·_N–ÔÛ¨xnÜnÕžZH’A’×Àüfýfò—\g%G¨ò"¢¸si{uO,mGb«mhóó¬.F{gùOÐMzx÷Èc `X«´”µzhvõÛáš~½ñ=òü}JyþέIÒ§Ÿ¨.†IÒÌ©ÖÀ€ê‰è=1Ô?ñ,¸HúÇR‡¦?2qrN0Ý=\Š#mÿ®"î“*öp‘Jrx͸çR‘Cö¾F^„DÓ¢úG&ü²‹~cæg gºâzqrkMz6B7`X|ÿ{Ì/Öî›/yíœyÆþ\>¡ÑV‡pµ ö}C8¥³¦/Ü;_1‹Íø‹Ú.–—%i 6ÓÙø ÑQÁ¶=¾L{K&äÑqñ9mr¶dnu¬OŠ=Z´Šï.J=ëo,Åm)uKÍ÷V*[å/“ºè+*¸G,[@g!ô}¸Ï¢‘¤_éÒÅ[ï´ça)™…èh…1®Of!º¿vÙ—-†hy`á>{—-õ[_ôAùÖAAAAAqCl]Âör ìFõ5~Ę•ÏིŠ_ày÷nk­KÅ1½è“¨¹kú¯ë2õ™ÿƯsôIyŽbÅ—Õq{µX¡ÞR¶¯³Ï÷‡ò-àFúñt£’0Â?mšZ­Ð¡Þ5Pß,Ì£HN+¥D1bÈ[«¥Kñp#k%|ÍÞFèö‰áâ|ŸÕ±|9…³¼ßŠÑŒµAì:<,¤?OæmƒæatL$`¤fµïY+½ºÈ­êÛ'—U¤Ÿ“GføÈî>>ÛÁž'd˜ã66ÑÏq_½d2aëkDeU¬X¹pûÌpܦZG ˜wWÆ*œŸ-aÌP¸ÑÌ4zešt}'ß:fO«`íIÚé‚ûòD×eÊZdsm‚ò5WÈÆS¦Ö`ÅúÉ·‡ù£ 4ÉÀh»~|¯§,¢û¾, =kdöû2MÆ?Âhw?ÀW𥙵n€ƒ÷*&ŸeßU¦}ð›ãh 澑-•[L›MÌ÷ÌÓ-ÿ®G•’Éÿ‡ªtŒ÷ç'é´*ÓöÞö=1ë8Á¤7ŒõÑÛ™×qEr?AAAAA¿\H$"Ä{ú/ÀÑ<Ưƺ \ãoc[‚Åûðƒ¬#‘x×Ùg”(®ˆˆ¾RrÑ›G¹]÷ãëô“ðwã³EšÇé¸õ\!4!¾&óR>œ®ôô¢HûÄ#» V² Ü;ÙÊtl£òw¶Z½®×®öl'«>h~×åÚ9Ä7Ö¦ez‰¬7Ä#œªkÁ‰!H1réÆC'Em—-mn½osI™™vEõi[*ªÜ»]íÙIŸæÈe—t@qN^–õl«³í´L;DÓ:T ¡-$æ³V9?‘š‰½Š®ÑwšßSÞ#Œù4»{þÍ”#ôSWy]—˜³7³ž°öTIu÷qúåüÙ‹ûçèTaE’M¶£dQ·ËM(xž¿d˜¸™¤$¹‘ö,ÃØ'éœëIJL¶ ÊhÔ^ ÆV‚ÑN3 .žÄbºy–µ”þ9pÿØâF{šGì-j/¥¸YÞñ)–Šö|:Ë“ô>Yþ¬ nNÔó‚½ã¬¼•„HbÑ™Pž|ìúX}<¶ýêÖ±Rû—v3sÙ·ex¯ú,µÑ®ŸL”’ ê·ö<©»È ‚ ‚ ‚ ‚ ‚ ~?þ>…ò\§këIEND®B`‚asterisk-11.7.0/images/asterisk-intro.jpg0000644000175000007640000001377710343116347020313 0ustar sharkyjerrywebÿØÿàJFIFHHÿþCreated with The GIMPÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀx "ÿÄÿÄE !1"AQaq23B‘¡±#$²Ñá%&Rbr„”¢4CSces‚ƒ“ÿÄÿÄ0!1AQ"2‘4aq$¡ÁðBÂÑÿÚ ?ÉðÇ ËÄnñÂá\vηT|š©zrg” =5åɸÕî½@ï§¶»¸ütÑJX³ÇH²‘Ròj©#fY>ƒQŸ”7ÙæîzãOíÈ8¦#ºŸ)©¼™©e'ÆŽÃ\ÉÉŠ½Ë¶aƒßO=.æâ¾ ¨»ÕSÐĬ±ÈÊ©;Ûh8Σâ˜Õ>SV>^LÕ¤a–pO¨×ÊnQÔË™;[Ó:Û ×“¢˜ÂîÔ„ºñO­,ÃþÿvÄVérš—oÉ»‚‘‰Aë¯Ê£KЃM%¹q!jyåÿÃ]‹‡ÿàKÿ/þâØ„rZ—prf¢H·¼ÛO¶¼_“u¢7a(È=™ë[~ÇX¥ÿðÿ {ÇSyoƲþŸðÒñLGtrš”Ðòz¸y¤pF;k´å\¤ÛGΛf¢èiIÿÚݨõ7Ùíb«Ë$“,%v€A=´x¬ýÑÊjYÃÉŠßÒN1 rrw…ñ.vùÓ¼€}õ÷KÄñÓå5# äý\<ŒzI‹“o#;´»Gì:´hif vÊ¡¶ òfOëò®ÓÛ¾žšGòbQDàŽ§O dâŸ0Tâô£Fç+¬ ôθüKý±­þ°ü0›xª°û‰?´4ŠãF³UÌàöŽ+¥S™FRšß!øìÜJá¾/³ñ];Il¨bè’T¤‰žÄƒéò25*;¢Õo0xá8*ѱӊšê§1ÓÂN@Éfø?xÒòÑÌî5–o©¬ŽÚÔùÉ„ÄÉ‘ðÛ²>ç:ÑóŠÜÏOe»<:IÞ)  ®Ïï@?=,«¥_¥r #1† çwϯÛZa……ÇR¨‘îh¿FÙ®°Þ­4÷U•z¡î¬:~ÄOÖk€mâÛÁ6ØC³Æ»á¼Ã¾=×þapß V *úìÕô&c22ƒþ¶;~}uš¬ÐW^š­F±\j¸§¦?ú„_ÌëOh¼Ûï´ [m©YàcŒ€A؃Ôƒ¬ßàQÒûšø¿™Ò!5°õköë\Çúµû u¡Ñ£F„#IÎsV‚‘Ó²{îÓIÞrʨ‘ $÷lkwù†ªåôªþNщ*d”¿oLéå¤o%åQ]2ätÓËSâ—ñzQ£Fs•ˆÖ;‡SoU7©Y?´5±ÖO‡Çùþ ÿ²ÿÚHHK¶ë·].µäý[TËåÎJªåUHìòûžŸž¬­7:‹UMÊúcoÆF9zƒÐi¿Äü³´ñíSCPò $x0ú’b}ÁÍVòžä)¼ZÊYb^Š®Y ¸ŒŸá­q½€j‡µÄ‚¶ UEÌ «§M©$Ñl’&90ËÝOÈÈ](,yn— S+!’£ebŽ…9eϧcŸ^=ð ÉT¦*oLJÅÕÒSU==5Gh½Ý¬×–»´‰-d²;¸x€³w `wÉ?Ç72" ÔSž Û„ÎæGÇÁ¶d£·„kµJ즌‘/mä{Aê='-Ô> if/S]3’Wl³6z’{÷ί©xC‰xª¶¢û[LÕRÕ¾á&àªvTÜGAÛòÖªÛË «-eU-9dªeÈ=ϰî}õDqê󪔥ïÑ¡EåL”ÜNÐDWª‰„@ JõÜŸLühxΡ嚚`¥¥4h×9ZeìJêsêU¿˜Ö£YûÌ~zÔç‹&• S¸ƒ„,ÜK±®4ìeA…–7(À{w|êM“‡m|=Åm¥o9w$³9ù'Óã¶½!¾Z§¡–º;)¥ˆâY|P3ìÇÐõ¾©,QùN>«’»…­ÓLÅåð‚;ìWÊOçŒê¾÷Ëûò¬ÕJ“SÌÇ253…ñû@‚ßÕÍ:Pðõšf©Ž h)–w3êI=NuäxšÊ( h¹Sµ8“ÁÞ­»/Œíu'8{k3¤Äía ªælü%hH”¥-* ±%ñcöÒ¦ó]G=4¢X^¼aí“û´Ãâ:‹5êÍK7éÚ:@“ø´óHÊÊΩRA=†8ûi[$QC|‡Â«JµjðÆt]ªç8È81ŒžÞú£™#¥¢<µwzßÛùVehgÖöO¨ÿV¿aªÛ¯[¬Ì‰W+™œnX¢‰¤b=ð à|œFaÃéµ?J@ø-]Ý”üu_Æ m¸pȺ@”µ.%§U W!Lè×öêGCï¨Í-Fãle¸lUýªëÞ•§$@ŽQ–@ú;ë©ÚÊp¥]5–¾¢®¢*x¯Í$®FR02ONäÏWPq–ª¡)éîôM!ÂGJ31Æzrz¥†›™ íÜ÷ ËIѰ$)rVSEQ<•¤Ò~ÙÀfûçKr*µ®?>ÚöâtÿHîÌFù|H|#ê¸DÙƒðù#äê9)]©b”>w×Áñ<ì[™U”×ßEL<¸Úë¼ÂÕ'c rv ‚=4ùÒ+“p¯‘ÑM;+î–º)*ëj#‚ÇWv}‡¹øÖî(PUúRÿŽëuåhq+SR*E7„ `e#y~ÒÅ‚?ßÔÕE5Êó4¶¤ž–pïŒE#†Ål»ÓÉ4 ÉÖФ®JÅId_0Üq×úMyHl×+%]ÖZÊKUæ&“ÆHdò;v¥ÀSÓ s€u7¿âÛÑ\9NÇ`~Ä(µ¼‚øÞ X7ú{ª®v¥áZ´ª®’¢`ôòÓÁ9Ò"¡ËÀë“î>uèµtkZÉ_SVƒéãtFí’Käª}‡}]ðìFKG §¤W³2H\œxdïŸ^½ð¥Î×o¬©ý'SMMÔÐe¨uDr¥÷OLù”ãçàêØ%“ âÀÐëÛú„ÊÆÊ3Yl³•×#YC$4RHÔ ©r§Åb¥!ñ’¡ÁúçÜcÆJš=°-4s‡«#OPŒ²!8mþsž„‘Ó¸Çbu{~X–÷-eCSOXð×S Ç9b´`öÏôc?ïj’ýÁÏL%i(c|dÓ¼@N><—êf”Û%1Ò:¡eD`·vÀ/SÙuÍÎy£½T};ÔC·¤Ž#)ÜUsŒ©U œ œ ôL[­æÏr໳S@´…KS¤s*FÎøV@>¡—§p5ëÁsÐq¦žZqTõ›’'eÞËáGÔÔŒƒûެ0FüLMw›ÈuïU©î¢%{aynžomÒÆÝ4âûJí,åçvIwS”V€ê2:õï¨Nj•Iá”Ò­{´Ï°„ â7sÛnpÆsÓMî6jHÒÙ4+Qõ{ü0Fý¾£8ïŒê â*¦úEQVj$†DîÙ—ù€9ý’4ÜÈãÄÈ”rÆÝ7×ð{áaÜæÿЦŽLÖÚŠ:É>’ðÒ3RÕÏ3¤/æÌjª1µJ‘Ôäá³­Úß=¯—ŸIRc3-TLÞ%|ÕJØžþÚ£¸CbýGr´ÕÁ•F5{jJ$C¸€ê©Ô¡@I ` §#Ô{ýR§.>žYÐ]R#¿™£Z”è ÷ä vj4Åš´Xa§£ê:Þs呤ÑvǺ¬«½D8zåe‰ ’IT¦yãÁc+ƒÐ$ d€¿ˆôÆvÖ‚„SÖÜ7OrO8Ĭc„ãUsƒŽ¾b2I' À¶Ç[m®©¦—Ǭ¦˜øô^!s$4Î#ÏB3‘רý®š.âju¦Keƶ0È ÒTK ¢/A“Ý— ùORN#4b`/ ÈÇ߯Ûdñ@ÓÌgüŽo}? »ŠbÏC IMlœš†R䫹Êd[dEG—=N­ø–®ÜœcO<²T¥ð~­’dc,\Ù8VèGmfùË<†8¢9ë½ÁX5ämßê7ýÖS‰‰–:%FäËmi€Q“ë¦ýÆ×Iv¦X+cgX8Û#!g*AìN’¼«jõ·Ü½ªÄiƒö2m;AøÎ4Íšã]F3l§¯© ;}\Ò€6Æ3…òÙo»{uÖî(§p;,ð’V4<1i·V%U4 “;Yêe ŒŒÄv'Rîvª;½:A[:#ø‹²VŒ†ÁÊ{ûõKýõÖiRžžH’ À1NèIñdˆKaºˆØ‘Ðß'¼Þi±SQ ¦¡ZYyfDN›ˆfu$¨é’@dë˜"­È+µh®/q9‰ÕM~áùP¤”“ºêõ³"úò<g2†ñ+¶ÑýKú¿ýZ«ý5Ä*ŠºXšf– lZIФ« §Ê é‡DB¾çõyz©¸ªÀ´LʺK5ÅžI•^:°ë½v1s†¶8èc$×Zªñzš:¹ìR‚`iŸÃ(Z-ÞmÇ•‡ –,øÆŠ7€Ðkè ×¹¦Úi]K`µÍiK\”ŠÔ‘õDÜr‡¯˜6wê|Àç©ëªÅàkH“/%t‘úDj˜ùŒ1üÉÔJ¯­pg‚?¨+cm¦›3`¿OÇ6BûœÉ‚®µ-Ö9fZö"¢AR< ”ËʸöÒ|<‚öƒ]Âm‘íô’ú޲ÔÓÓ@ÔB8©ƒVžG„.ìnüg8õåÙ)ê¡©JiŒ°¸’2õs8 ; ê¾ ÅïÇ”N"30>-$ňj‰ź°}1Í?ßeJgks yãI”ÐL FÑÄYúž¸‘qíײ6C EÙËE÷¤ PM+Šþ´ÜëMeT´ì¡ GS,y8謩ÔqÁv ’¨¥˜6°Ûœ`–ÈüG·|õÔkµ]ÚšéU-5 .bÃ*ºÄÌm‘Y°:Á°:Œë„¿Þ&¹Šhé)a$£•XÆf)¸’FÜ&¨êA¿@Áqqh³ôG1õViz'Ù„¬òµdÊaêö%pHø$êÆ·†m§RÑøP¬¼!§” c Õñ]¾š¤[ã•g§+%,ŠÊÄDx,vä»ÿH|¾^Ú³´×Þ*n ÔT§t˜€´rG‚²PK1Á#Íéœôí!‡…­- zPLË!6\oî¥[¸jÕj­úÊH%Z ¢ÞõI…$0ÌGu_ݨ’pGÊ$I6Ù ,‚®`§=ÆÐø¯nÚ®Šã~§ñ<ifibz˜¦Ø00»”‚I\®6‘ÔãSâ¸ßÞh‹Aƒ-DðÿÙ$ ’y²ýCF¬sæ*}>DT”Pú%Ì}Ý›R.)j¹Ü~¶¢9w¶ßB©6ÞÛǯ ù‘ÓKÞtH‚’Û–Ï}ki/Wáoƒú‰GXáVI©'b7$eœ¶I8bêW«tÉ8+~h\.U+á×S$avíd‰Õ[¾p_õæ;ç§G†1£ª¦q,¢V_ƒøº^”º€Ê}5¼*%óSùq£F½$¸8evgV@÷ ælÑ @(!PŽ^0¨Æ9ÉÄäõù:ŸWÍÛsÑm’eÝø‘€ þGFg<7{)s\¼G9)(Ö*}p6€½¦ç.õXâÎFI:4iž‡ìŽk—ƒó†U&<œúkÕyÍJS&£F Þˆæ¹tüå£*Dw}DŸ§• Ýó£F˜á¸~Èæ¹|^s« ]w/98¿S¹¶<;~”s\»¦ç57‡‰!9Ç}B^nSÉRòÉJ›Šx{öÅsœgÛãF‡ìŽk•æí5‡­‘Írõ‹›ô¢RdA³Ó^2óš—ꂤ'Ãõ:4h7Ù×)GœV÷F„7¦uƒã~7‡‰©V0˜t=ôhÕàaùš5IÒ8Š+ÿÙasterisk-11.7.0/BUGS0000644000175000007640000000112711607404317014034 0ustar sharkyjerrywebAsterisk Bug Tracking Information ================================= To learn about and report Asterisk bugs, please visit the official Asterisk Bug Tracker at: https://issues.asterisk.org/jira For more information on using the bug tracker, or to learn how you can contribute by acting as a bug marshal please see: http://www.asterisk.org/developers/bug-guidelines If you would like to submit a feature request, please resist the temptation to post it to the bug tracker. Feature requests should be posted to the asterisk-dev mailing list, located at: http://lists.digium.com Thank you! asterisk-11.7.0/apps/0000755000175000007640000000000012254071122014304 5ustar sharkyjerrywebasterisk-11.7.0/apps/app_mp3.c0000644000175000007640000001633011721555224016022 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Silly application to play an MP3 file -- uses mpg123 * * \author Mark Spencer * * \note Add feature to play local M3U playlist file * Vincent Li * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356573 $") #include #include #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/frame.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/app.h" #define LOCAL_MPG_123 "/usr/local/bin/mpg123" #define MPG_123 "/usr/bin/mpg123" /*** DOCUMENTATION Play an MP3 file or M3U playlist file or stream. Location of the file to be played. (argument passed to mpg123) Executes mpg123 to play the given location, which typically would be a mp3 filename or m3u playlist filename or a URL. Please read http://en.wikipedia.org/wiki/M3U to see how M3U playlist file format is like, Example usage would be exten => 1234,1,MP3Player(/var/lib/asterisk/playlist.m3u) User can exit by pressing any key on the dialpad, or by hanging up. This application does not automatically answer and should be preceeded by an application such as Answer() or Progress(). ***/ static char *app = "MP3Player"; static int mp3play(const char *filename, int fd) { int res; res = ast_safe_fork(0); if (res < 0) ast_log(LOG_WARNING, "Fork failed\n"); if (res) { return res; } if (ast_opt_high_priority) ast_set_priority(0); dup2(fd, STDOUT_FILENO); ast_close_fds_above_n(STDERR_FILENO); /* Execute mpg123, but buffer if it's a net connection */ if (!strncasecmp(filename, "http://", 7)) { /* Most commonly installed in /usr/local/bin */ execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); /* But many places has it in /usr/bin */ execl(MPG_123, "mpg123", "-q", "-s", "-b", "1024","-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); /* As a last-ditch effort, try to use PATH */ execlp("mpg123", "mpg123", "-q", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); } else if (strstr(filename, ".m3u")) { /* Most commonly installed in /usr/local/bin */ execl(LOCAL_MPG_123, "mpg123", "-q", "-z", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); /* But many places has it in /usr/bin */ execl(MPG_123, "mpg123", "-q", "-z", "-s", "-b", "1024","-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); /* As a last-ditch effort, try to use PATH */ execlp("mpg123", "mpg123", "-q", "-z", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); } else { /* Most commonly installed in /usr/local/bin */ execl(MPG_123, "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); /* But many places has it in /usr/bin */ execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); /* As a last-ditch effort, try to use PATH */ execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); } /* Can't use ast_log since FD's are closed */ fprintf(stderr, "Execute of mpg123 failed\n"); _exit(0); } static int timed_read(int fd, void *data, int datalen, int timeout) { int res; struct pollfd fds[1]; fds[0].fd = fd; fds[0].events = POLLIN; res = ast_poll(fds, 1, timeout); if (res < 1) { ast_log(LOG_NOTICE, "Poll timed out/errored out with %d\n", res); return -1; } return read(fd, data, datalen); } static int mp3_exec(struct ast_channel *chan, const char *data) { int res=0; int fds[2]; int ms = -1; int pid = -1; struct ast_format owriteformat; int timeout = 2000; struct timeval next; struct ast_frame *f; struct myframe { struct ast_frame f; char offset[AST_FRIENDLY_OFFSET]; short frdata[160]; } myf = { .f = { 0, }, }; ast_format_clear(&owriteformat); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n"); return -1; } if (pipe(fds)) { ast_log(LOG_WARNING, "Unable to create pipe\n"); return -1; } ast_stopstream(chan); ast_format_copy(&owriteformat, ast_channel_writeformat(chan)); res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set write format to signed linear\n"); return -1; } res = mp3play(data, fds[1]); if (!strncasecmp(data, "http://", 7)) { timeout = 10000; } /* Wait 1000 ms first */ next = ast_tvnow(); next.tv_sec += 1; if (res >= 0) { pid = res; /* Order is important -- there's almost always going to be mp3... we want to prioritize the user */ for (;;) { ms = ast_tvdiff_ms(next, ast_tvnow()); if (ms <= 0) { res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata), timeout); if (res > 0) { myf.f.frametype = AST_FRAME_VOICE; ast_format_set(&myf.f.subclass.format, AST_FORMAT_SLINEAR, 0); myf.f.datalen = res; myf.f.samples = res / 2; myf.f.mallocd = 0; myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.src = __PRETTY_FUNCTION__; myf.f.delivery.tv_sec = 0; myf.f.delivery.tv_usec = 0; myf.f.data.ptr = myf.frdata; if (ast_write(chan, &myf.f) < 0) { res = -1; break; } } else { ast_debug(1, "No more mp3\n"); res = 0; break; } next = ast_tvadd(next, ast_samp2tv(myf.f.samples, 8000)); } else { ms = ast_waitfor(chan, ms); if (ms < 0) { ast_debug(1, "Hangup detected\n"); res = -1; break; } if (ms) { f = ast_read(chan); if (!f) { ast_debug(1, "Null frame == hangup() detected\n"); res = -1; break; } if (f->frametype == AST_FRAME_DTMF) { ast_debug(1, "User pressed a key\n"); ast_frfree(f); res = 0; break; } ast_frfree(f); } } } } close(fds[0]); close(fds[1]); if (pid > -1) kill(pid, SIGKILL); if (!res && owriteformat.id) ast_set_write_format(chan, &owriteformat); return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, mp3_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Silly MP3 Application"); asterisk-11.7.0/apps/app_readexten.c0000644000175000007640000002022611723453737017311 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007-2008, Trinity College Computing Center * Written by David Chappell * * 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 Trivial application to read an extension into a variable * * \author David Chappell * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 357542 $") #include "asterisk/file.h" #include "asterisk/pbx.h" #include "asterisk/app.h" #include "asterisk/module.h" #include "asterisk/indications.h" #include "asterisk/channel.h" /*** DOCUMENTATION Read an extension into a variable. File to play before reading digits or tone with option i Context in which to match extensions. An integer number of seconds to wait for a digit response. If greater than 0, that value will override the default timeout. Reads a # terminated string of digits from the user into the given variable. Will set READEXTENSTATUS on exit with one of the following statuses: A valid extension exists in ${variable}. No extension was entered in the specified time. Also sets ${variable} to "t". An invalid extension, ${INVALID_EXTEN}, was entered. Also sets ${variable} to "i". Line was not up and the option 's' was specified. Invalid arguments were passed. ***/ enum readexten_option_flags { OPT_SKIP = (1 << 0), OPT_INDICATION = (1 << 1), OPT_NOANSWER = (1 << 2), }; AST_APP_OPTIONS(readexten_app_options, { AST_APP_OPTION('s', OPT_SKIP), AST_APP_OPTION('i', OPT_INDICATION), AST_APP_OPTION('n', OPT_NOANSWER), }); static char *app = "ReadExten"; static int readexten_exec(struct ast_channel *chan, const char *data) { int res = 0; char exten[256] = ""; int maxdigits = sizeof(exten) - 1; int timeout = 0, digit_timeout = 0, x = 0; char *argcopy = NULL, *status = ""; struct ast_tone_zone_sound *ts = NULL; struct ast_flags flags = {0}; AST_DECLARE_APP_ARGS(arglist, AST_APP_ARG(variable); AST_APP_ARG(filename); AST_APP_ARG(context); AST_APP_ARG(options); AST_APP_ARG(timeout); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "ReadExten requires at least one argument\n"); pbx_builtin_setvar_helper(chan, "READEXTENSTATUS", "ERROR"); return 0; } argcopy = ast_strdupa(data); AST_STANDARD_APP_ARGS(arglist, argcopy); if (ast_strlen_zero(arglist.variable)) { ast_log(LOG_WARNING, "Usage: ReadExten(variable[,filename[,context[,options[,timeout]]]])\n"); pbx_builtin_setvar_helper(chan, "READEXTENSTATUS", "ERROR"); return 0; } if (ast_strlen_zero(arglist.filename)) { arglist.filename = NULL; } if (ast_strlen_zero(arglist.context)) { arglist.context = ast_strdupa(ast_channel_context(chan)); } if (!ast_strlen_zero(arglist.options)) { ast_app_parse_options(readexten_app_options, &flags, NULL, arglist.options); } if (!ast_strlen_zero(arglist.timeout)) { timeout = atoi(arglist.timeout); if (timeout > 0) timeout *= 1000; } if (timeout <= 0) timeout = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 10000; if (digit_timeout <= 0) digit_timeout = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->dtimeoutms : 5000; if (ast_test_flag(&flags, OPT_INDICATION) && !ast_strlen_zero(arglist.filename)) { ts = ast_get_indication_tone(ast_channel_zone(chan), arglist.filename); } do { if (ast_channel_state(chan) != AST_STATE_UP) { if (ast_test_flag(&flags, OPT_SKIP)) { /* At the user's option, skip if the line is not up */ pbx_builtin_setvar_helper(chan, arglist.variable, ""); status = "SKIP"; break; } else if (!ast_test_flag(&flags, OPT_NOANSWER)) { /* Otherwise answer unless we're supposed to read while on-hook */ res = ast_answer(chan); } } if (res < 0) { status = "HANGUP"; break; } ast_playtones_stop(chan); ast_stopstream(chan); if (ts && ts->data[0]) { res = ast_playtones_start(chan, 0, ts->data, 0); } else if (arglist.filename) { if (ast_test_flag(&flags, OPT_INDICATION) && ast_fileexists(arglist.filename, NULL, ast_channel_language(chan)) <= 0) { /* * We were asked to play an indication that did not exist in the config. * If no such file exists, play it as a tonelist. With any luck they won't * have a file named "350+440.ulaw" * (but honestly, who would do something so silly?) */ res = ast_playtones_start(chan, 0, arglist.filename, 0); } else { res = ast_streamfile(chan, arglist.filename, ast_channel_language(chan)); } } for (x = 0; x < maxdigits; x++) { ast_debug(3, "extension so far: '%s', timeout: %d\n", exten, timeout); res = ast_waitfordigit(chan, timeout); ast_playtones_stop(chan); ast_stopstream(chan); timeout = digit_timeout; if (res < 1) { /* timeout expired or hangup */ if (ast_check_hangup(chan)) { status = "HANGUP"; } else if (x == 0) { pbx_builtin_setvar_helper(chan, arglist.variable, "t"); status = "TIMEOUT"; } break; } exten[x] = res; if (!ast_matchmore_extension(chan, arglist.context, exten, 1 /* priority */, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { if (!ast_exists_extension(chan, arglist.context, exten, 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)) && res == '#') { exten[x] = '\0'; } break; } } if (!ast_strlen_zero(status)) break; if (ast_exists_extension(chan, arglist.context, exten, 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { ast_debug(3, "User entered valid extension '%s'\n", exten); pbx_builtin_setvar_helper(chan, arglist.variable, exten); status = "OK"; } else { ast_debug(3, "User dialed invalid extension '%s' in context '%s' on %s\n", exten, arglist.context, ast_channel_name(chan)); pbx_builtin_setvar_helper(chan, arglist.variable, "i"); pbx_builtin_setvar_helper(chan, "INVALID_EXTEN", exten); status = "INVALID"; } } while (0); if (ts) { ts = ast_tone_zone_sound_unref(ts); } pbx_builtin_setvar_helper(chan, "READEXTENSTATUS", status); return status[0] == 'H' ? -1 : 0; } static int unload_module(void) { int res = ast_unregister_application(app); return res; } static int load_module(void) { int res = ast_register_application_xml(app, readexten_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Read and evaluate extension validity"); asterisk-11.7.0/apps/app_read.c0000644000175000007640000001741111720555237016242 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Trivial application to read a variable * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356042 $") #include "asterisk/file.h" #include "asterisk/pbx.h" #include "asterisk/channel.h" #include "asterisk/app.h" #include "asterisk/module.h" #include "asterisk/indications.h" /*** DOCUMENTATION Read a variable. The input digits will be stored in the given variable name. file(s) to play before reading digits or tone with option i Maximum acceptable number of digits. Stops reading after maxdigits have been entered (without requiring the user to press the # key). Defaults to 0 - no limit - wait for the user press the # key. Any value below 0 means the same. Max accepted value is 255. If greater than 1, that many attempts will be made in the event no data is entered. The number of seconds to wait for a digit response. If greater than 0, that value will override the default timeout. Can be floating point. Reads a #-terminated string of digits a certain number of times from the user in to the given variable. This application sets the following channel variable upon completion: This is the status of the read operation. SendDTMF ***/ enum read_option_flags { OPT_SKIP = (1 << 0), OPT_INDICATION = (1 << 1), OPT_NOANSWER = (1 << 2), }; AST_APP_OPTIONS(read_app_options, { AST_APP_OPTION('s', OPT_SKIP), AST_APP_OPTION('i', OPT_INDICATION), AST_APP_OPTION('n', OPT_NOANSWER), }); static char *app = "Read"; static int read_exec(struct ast_channel *chan, const char *data) { int res = 0; char tmp[256] = ""; int maxdigits = 255; int tries = 1, to = 0, x = 0; double tosec; char *argcopy = NULL; struct ast_tone_zone_sound *ts = NULL; struct ast_flags flags = {0}; const char *status = "ERROR"; AST_DECLARE_APP_ARGS(arglist, AST_APP_ARG(variable); AST_APP_ARG(filename); AST_APP_ARG(maxdigits); AST_APP_ARG(options); AST_APP_ARG(attempts); AST_APP_ARG(timeout); ); pbx_builtin_setvar_helper(chan, "READSTATUS", status); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "Read requires an argument (variable)\n"); return 0; } argcopy = ast_strdupa(data); AST_STANDARD_APP_ARGS(arglist, argcopy); if (!ast_strlen_zero(arglist.options)) { ast_app_parse_options(read_app_options, &flags, NULL, arglist.options); } if (!ast_strlen_zero(arglist.attempts)) { tries = atoi(arglist.attempts); if (tries <= 0) tries = 1; } if (!ast_strlen_zero(arglist.timeout)) { tosec = atof(arglist.timeout); if (tosec <= 0) to = 0; else to = tosec * 1000.0; } if (ast_strlen_zero(arglist.filename)) { arglist.filename = NULL; } if (!ast_strlen_zero(arglist.maxdigits)) { maxdigits = atoi(arglist.maxdigits); if ((maxdigits < 1) || (maxdigits > 255)) { maxdigits = 255; } else ast_verb(3, "Accepting a maximum of %d digits.\n", maxdigits); } if (ast_strlen_zero(arglist.variable)) { ast_log(LOG_WARNING, "Invalid! Usage: Read(variable[,filename][,maxdigits][,option][,attempts][,timeout])\n\n"); return 0; } if (ast_test_flag(&flags, OPT_INDICATION)) { if (!ast_strlen_zero(arglist.filename)) { ts = ast_get_indication_tone(ast_channel_zone(chan), arglist.filename); } } if (ast_channel_state(chan) != AST_STATE_UP) { if (ast_test_flag(&flags, OPT_SKIP)) { /* At the user's option, skip if the line is not up */ pbx_builtin_setvar_helper(chan, arglist.variable, ""); pbx_builtin_setvar_helper(chan, "READSTATUS", "SKIPPED"); return 0; } else if (!ast_test_flag(&flags, OPT_NOANSWER)) { /* Otherwise answer unless we're supposed to read while on-hook */ res = ast_answer(chan); } } if (!res) { while (tries && !res) { ast_stopstream(chan); if (ts && ts->data[0]) { if (!to) to = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 6000; res = ast_playtones_start(chan, 0, ts->data, 0); for (x = 0; x < maxdigits; ) { res = ast_waitfordigit(chan, to); ast_playtones_stop(chan); if (res < 1) { if (res == 0) status = "TIMEOUT"; tmp[x]='\0'; break; } tmp[x++] = res; if (tmp[x-1] == '#') { tmp[x-1] = '\0'; status = "OK"; break; } if (x >= maxdigits) { status = "OK"; } } } else { res = ast_app_getdata(chan, arglist.filename, tmp, maxdigits, to); if (res == AST_GETDATA_COMPLETE || res == AST_GETDATA_EMPTY_END_TERMINATED) status = "OK"; else if (res == AST_GETDATA_TIMEOUT) status = "TIMEOUT"; else if (res == AST_GETDATA_INTERRUPTED) status = "INTERRUPTED"; } if (res > -1) { pbx_builtin_setvar_helper(chan, arglist.variable, tmp); if (!ast_strlen_zero(tmp)) { ast_verb(3, "User entered '%s'\n", tmp); tries = 0; } else { tries--; if (tries) ast_verb(3, "User entered nothing, %d chance%s left\n", tries, (tries != 1) ? "s" : ""); else ast_verb(3, "User entered nothing.\n"); } res = 0; } else { pbx_builtin_setvar_helper(chan, arglist.variable, tmp); ast_verb(3, "User disconnected\n"); } } } if (ts) { ts = ast_tone_zone_sound_unref(ts); } if (ast_check_hangup(chan)) status = "HANGUP"; pbx_builtin_setvar_helper(chan, "READSTATUS", status); return 0; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, read_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Read Variable Application"); asterisk-11.7.0/apps/app_alarmreceiver.c0000644000175000007640000004462611744060755020162 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2004 - 2005 Steve Rodgers * * Steve Rodgers * * 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 Central Station Alarm receiver for Ademco Contact ID * \author Steve Rodgers * * *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** * * Use at your own risk. Please consult the GNU GPL license document included with Asterisk. * * * *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 362635 $") #include #include #include #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/ulaw.h" #include "asterisk/app.h" #include "asterisk/dsp.h" #include "asterisk/config.h" #include "asterisk/localtime.h" #include "asterisk/callerid.h" #include "asterisk/astdb.h" #include "asterisk/utils.h" #define ALMRCV_CONFIG "alarmreceiver.conf" #define ADEMCO_CONTACT_ID "ADEMCO_CONTACT_ID" struct event_node{ char data[17]; struct event_node *next; }; typedef struct event_node event_node_t; static const char app[] = "AlarmReceiver"; /*** DOCUMENTATION Provide support for receiving alarm reports from a burglar or fire alarm panel. This application should be called whenever there is an alarm panel calling in to dump its events. The application will handshake with the alarm panel, and receive events, validate them, handshake them, and store them until the panel hangs up. Once the panel hangs up, the application will run the system command specified by the eventcmd setting in alarmreceiver.conf and pipe the events to the standard input of the application. The configuration file also contains settings for DTMF timing, and for the loudness of the acknowledgement tones. Only 1 signalling format is supported at this time: Ademco Contact ID. alarmreceiver.conf ***/ /* Config Variables */ static int fdtimeout = 2000; static int sdtimeout = 200; static int toneloudness = 4096; static int log_individual_events = 0; static char event_spool_dir[128] = {'\0'}; static char event_app[128] = {'\0'}; static char db_family[128] = {'\0'}; static char time_stamp_format[128] = {"%a %b %d, %Y @ %H:%M:%S %Z"}; /* Misc variables */ static char event_file[14] = "/event-XXXXXX"; /* * Attempt to access a database variable and increment it, * provided that the user defined db-family in alarmreceiver.conf * The alarmreceiver app will write statistics to a few variables * in this family if it is defined. If the new key doesn't exist in the * family, then create it and set its value to 1. */ static void database_increment( char *key ) { int res = 0; unsigned v; char value[16]; if (ast_strlen_zero(db_family)) return; /* If not defined, don't do anything */ res = ast_db_get(db_family, key, value, sizeof(value) - 1); if (res) { ast_verb(4, "AlarmReceiver: Creating database entry %s and setting to 1\n", key); /* Guess we have to create it */ res = ast_db_put(db_family, key, "1"); return; } sscanf(value, "%30u", &v); v++; ast_verb(4, "AlarmReceiver: New value for %s: %u\n", key, v); snprintf(value, sizeof(value), "%u", v); res = ast_db_put(db_family, key, value); if (res) ast_verb(4, "AlarmReceiver: database_increment write error\n"); return; } /* * Build a MuLaw data block for a single frequency tone */ static void make_tone_burst(unsigned char *data, float freq, float loudness, int len, int *x) { int i; float val; for (i = 0; i < len; i++) { val = loudness * sin((freq * 2.0 * M_PI * (*x)++)/8000.0); data[i] = AST_LIN2MU((int)val); } /* wrap back around from 8000 */ if (*x >= 8000) *x = 0; return; } /* * Send a single tone burst for a specifed duration and frequency. * Returns 0 if successful */ static int send_tone_burst(struct ast_channel *chan, float freq, int duration, int tldn) { int res = 0; int i = 0; int x = 0; struct ast_frame *f, wf; struct { unsigned char offset[AST_FRIENDLY_OFFSET]; unsigned char buf[640]; } tone_block; for (;;) { if (ast_waitfor(chan, -1) < 0) { res = -1; break; } f = ast_read(chan); if (!f) { res = -1; break; } if (f->frametype == AST_FRAME_VOICE) { wf.frametype = AST_FRAME_VOICE; ast_format_set(&wf.subclass.format, AST_FORMAT_ULAW, 0); wf.offset = AST_FRIENDLY_OFFSET; wf.mallocd = 0; wf.data.ptr = tone_block.buf; wf.datalen = f->datalen; wf.samples = wf.datalen; make_tone_burst(tone_block.buf, freq, (float) tldn, wf.datalen, &x); i += wf.datalen / 8; if (i > duration) { ast_frfree(f); break; } if (ast_write(chan, &wf)) { ast_verb(4, "AlarmReceiver: Failed to write frame on %s\n", ast_channel_name(chan)); ast_log(LOG_WARNING, "AlarmReceiver Failed to write frame on %s\n",ast_channel_name(chan)); res = -1; ast_frfree(f); break; } } ast_frfree(f); } return res; } /* * Receive a string of DTMF digits where the length of the digit string is known in advance. Do not give preferential * treatment to any digit value, and allow separate time out values to be specified for the first digit and all subsequent * digits. * * Returns 0 if all digits successfully received. * Returns 1 if a digit time out occurred * Returns -1 if the caller hung up or there was a channel error. * */ static int receive_dtmf_digits(struct ast_channel *chan, char *digit_string, int length, int fdto, int sdto) { int res = 0; int i = 0; int r; struct ast_frame *f; struct timeval lastdigittime; lastdigittime = ast_tvnow(); for (;;) { /* if outa time, leave */ if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > ((i > 0) ? sdto : fdto)) { ast_verb(4, "AlarmReceiver: DTMF Digit Timeout on %s\n", ast_channel_name(chan)); ast_debug(1,"AlarmReceiver: DTMF timeout on chan %s\n",ast_channel_name(chan)); res = 1; break; } if ((r = ast_waitfor(chan, -1)) < 0) { ast_debug(1, "Waitfor returned %d\n", r); continue; } f = ast_read(chan); if (f == NULL) { res = -1; break; } /* If they hung up, leave */ if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) { if (f->data.uint32) { ast_channel_hangupcause_set(chan, f->data.uint32); } ast_frfree(f); res = -1; break; } /* if not DTMF, just do it again */ if (f->frametype != AST_FRAME_DTMF) { ast_frfree(f); continue; } digit_string[i++] = f->subclass.integer; /* save digit */ ast_frfree(f); /* If we have all the digits we expect, leave */ if(i >= length) break; lastdigittime = ast_tvnow(); } digit_string[i] = '\0'; /* Nul terminate the end of the digit string */ return res; } /* * Write the metadata to the log file */ static int write_metadata( FILE *logfile, char *signalling_type, struct ast_channel *chan) { int res = 0; struct timeval t; struct ast_tm now; char *cl; char *cn; char workstring[80]; char timestamp[80]; /* Extract the caller ID location */ ast_copy_string(workstring, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""), sizeof(workstring)); ast_shrink_phone_number(workstring); if (ast_strlen_zero(workstring)) { cl = ""; } else { cl = workstring; } cn = S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, ""); /* Get the current time */ t = ast_tvnow(); ast_localtime(&t, &now, NULL); /* Format the time */ ast_strftime(timestamp, sizeof(timestamp), time_stamp_format, &now); res = fprintf(logfile, "\n\n[metadata]\n\n"); if (res >= 0) { res = fprintf(logfile, "PROTOCOL=%s\n", signalling_type); } if (res >= 0) { res = fprintf(logfile, "CALLINGFROM=%s\n", cl); } if (res >= 0) { res = fprintf(logfile, "CALLERNAME=%s\n", cn); } if (res >= 0) { res = fprintf(logfile, "TIMESTAMP=%s\n\n", timestamp); } if (res >= 0) { res = fprintf(logfile, "[events]\n\n"); } if (res < 0) { ast_verb(3, "AlarmReceiver: can't write metadata\n"); ast_debug(1,"AlarmReceiver: can't write metadata\n"); } else { res = 0; } return res; } /* * Write a single event to the log file */ static int write_event( FILE *logfile, event_node_t *event) { int res = 0; if (fprintf(logfile, "%s\n", event->data) < 0) res = -1; return res; } /* * If we are configured to log events, do so here. * */ static int log_events(struct ast_channel *chan, char *signalling_type, event_node_t *event) { int res = 0; char workstring[sizeof(event_spool_dir)+sizeof(event_file)] = ""; int fd; FILE *logfile; event_node_t *elp = event; if (!ast_strlen_zero(event_spool_dir)) { /* Make a template */ ast_copy_string(workstring, event_spool_dir, sizeof(workstring)); strncat(workstring, event_file, sizeof(workstring) - strlen(workstring) - 1); /* Make the temporary file */ fd = mkstemp(workstring); if (fd == -1) { ast_verb(3, "AlarmReceiver: can't make temporary file\n"); ast_debug(1,"AlarmReceiver: can't make temporary file\n"); res = -1; } if (!res) { logfile = fdopen(fd, "w"); if (logfile) { /* Write the file */ res = write_metadata(logfile, signalling_type, chan); if (!res) while ((!res) && (elp != NULL)) { res = write_event(logfile, elp); elp = elp->next; } if (!res) { if (fflush(logfile) == EOF) res = -1; if (!res) { if (fclose(logfile) == EOF) res = -1; } } } else res = -1; } } return res; } /* * This function implements the logic to receive the Ademco contact ID format. * * The function will return 0 when the caller hangs up, else a -1 if there was a problem. */ static int receive_ademco_contact_id(struct ast_channel *chan, const void *data, int fdto, int sdto, int tldn, event_node_t **ehead) { int i, j; int res = 0; int checksum; char event[17]; event_node_t *enew, *elp; int got_some_digits = 0; int events_received = 0; int ack_retries = 0; static char digit_map[15] = "0123456789*#ABC"; static unsigned char digit_weights[15] = {10,1,2,3,4,5,6,7,8,9,11,12,13,14,15}; database_increment("calls-received"); /* Wait for first event */ ast_verb(4, "AlarmReceiver: Waiting for first event from panel\n"); while (res >= 0) { if (got_some_digits == 0) { /* Send ACK tone sequence */ ast_verb(4, "AlarmReceiver: Sending 1400Hz 100ms burst (ACK)\n"); res = send_tone_burst(chan, 1400.0, 100, tldn); if (!res) res = ast_safe_sleep(chan, 100); if (!res) { ast_verb(4, "AlarmReceiver: Sending 2300Hz 100ms burst (ACK)\n"); res = send_tone_burst(chan, 2300.0, 100, tldn); } } if ( res >= 0) res = receive_dtmf_digits(chan, event, sizeof(event) - 1, fdto, sdto); if (res < 0) { if (events_received == 0) { /* Hangup with no events received should be logged in the DB */ database_increment("no-events-received"); } else { if (ack_retries) { ast_verb(4, "AlarmReceiver: ACK retries during this call: %d\n", ack_retries); database_increment("ack-retries"); } } ast_verb(4, "AlarmReceiver: App exiting...\n"); res = -1; break; } if (res != 0) { /* Didn't get all of the digits */ ast_verb(2, "AlarmReceiver: Incomplete string: %s, trying again...\n", event); if (!got_some_digits) { got_some_digits = (!ast_strlen_zero(event)) ? 1 : 0; ack_retries++; } continue; } got_some_digits = 1; ast_verb(2, "AlarmReceiver: Received Event %s\n", event); ast_debug(1, "AlarmReceiver: Received event: %s\n", event); /* Calculate checksum */ for (j = 0, checksum = 0; j < 16; j++) { for (i = 0; i < sizeof(digit_map); i++) { if (digit_map[i] == event[j]) break; } if (i == 16) break; checksum += digit_weights[i]; } if (i == 16) { ast_verb(2, "AlarmReceiver: Bad DTMF character %c, trying again\n", event[j]); continue; /* Bad character */ } /* Checksum is mod(15) of the total */ checksum = checksum % 15; if (checksum) { database_increment("checksum-errors"); ast_verb(2, "AlarmReceiver: Nonzero checksum\n"); ast_debug(1, "AlarmReceiver: Nonzero checksum\n"); continue; } /* Check the message type for correctness */ if (strncmp(event + 4, "18", 2)) { if (strncmp(event + 4, "98", 2)) { database_increment("format-errors"); ast_verb(2, "AlarmReceiver: Wrong message type\n"); ast_debug(1, "AlarmReceiver: Wrong message type\n"); continue; } } events_received++; /* Queue the Event */ if (!(enew = ast_calloc(1, sizeof(*enew)))) { res = -1; break; } enew->next = NULL; ast_copy_string(enew->data, event, sizeof(enew->data)); /* * Insert event onto end of list */ if (*ehead == NULL) *ehead = enew; else { for(elp = *ehead; elp->next != NULL; elp = elp->next) ; elp->next = enew; } if (res > 0) res = 0; /* Let the user have the option of logging the single event before sending the kissoff tone */ if ((res == 0) && (log_individual_events)) res = log_events(chan, ADEMCO_CONTACT_ID, enew); /* Wait 200 msec before sending kissoff */ if (res == 0) res = ast_safe_sleep(chan, 200); /* Send the kissoff tone */ if (res == 0) res = send_tone_burst(chan, 1400.0, 900, tldn); } return res; } /* * This is the main function called by Asterisk Core whenever the App is invoked in the extension logic. * This function will always return 0. */ static int alarmreceiver_exec(struct ast_channel *chan, const char *data) { int res = 0; event_node_t *elp, *efree; char signalling_type[64] = ""; event_node_t *event_head = NULL; /* Set write and read formats to ULAW */ ast_verb(4, "AlarmReceiver: Setting read and write formats to ULAW\n"); if (ast_set_write_format_by_id(chan,AST_FORMAT_ULAW)) { ast_log(LOG_WARNING, "AlarmReceiver: Unable to set write format to Mu-law on %s\n",ast_channel_name(chan)); return -1; } if (ast_set_read_format_by_id(chan,AST_FORMAT_ULAW)) { ast_log(LOG_WARNING, "AlarmReceiver: Unable to set read format to Mu-law on %s\n",ast_channel_name(chan)); return -1; } /* Set default values for this invocation of the application */ ast_copy_string(signalling_type, ADEMCO_CONTACT_ID, sizeof(signalling_type)); /* Answer the channel if it is not already */ ast_verb(4, "AlarmReceiver: Answering channel\n"); if (ast_channel_state(chan) != AST_STATE_UP) { if ((res = ast_answer(chan))) return -1; } /* Wait for the connection to settle post-answer */ ast_verb(4, "AlarmReceiver: Waiting for connection to stabilize\n"); res = ast_safe_sleep(chan, 1250); /* Attempt to receive the events */ if (!res) { /* Determine the protocol to receive in advance */ /* Note: Ademco contact is the only one supported at this time */ /* Others may be added later */ if(!strcmp(signalling_type, ADEMCO_CONTACT_ID)) receive_ademco_contact_id(chan, data, fdtimeout, sdtimeout, toneloudness, &event_head); else res = -1; } /* Events queued by receiver, write them all out here if so configured */ if ((!res) && (log_individual_events == 0)) res = log_events(chan, signalling_type, event_head); /* * Do we exec a command line at the end? */ if ((!res) && (!ast_strlen_zero(event_app)) && (event_head)) { ast_debug(1,"Alarmreceiver: executing: %s\n", event_app); ast_safe_system(event_app); } /* * Free up the data allocated in our linked list */ for (elp = event_head; (elp != NULL);) { efree = elp; elp = elp->next; ast_free(efree); } return 0; } /* * Load the configuration from the configuration file */ static int load_config(void) { struct ast_config *cfg; const char *p; struct ast_flags config_flags = { 0 }; /* Read in the config file */ cfg = ast_config_load(ALMRCV_CONFIG, config_flags); if (!cfg) { ast_verb(4, "AlarmReceiver: No config file\n"); return 0; } else if (cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", ALMRCV_CONFIG); return 0; } else { p = ast_variable_retrieve(cfg, "general", "eventcmd"); if (p) { ast_copy_string(event_app, p, sizeof(event_app)); } p = ast_variable_retrieve(cfg, "general", "loudness"); if (p) { toneloudness = atoi(p); if(toneloudness < 100) toneloudness = 100; if(toneloudness > 8192) toneloudness = 8192; } p = ast_variable_retrieve(cfg, "general", "fdtimeout"); if (p) { fdtimeout = atoi(p); if(fdtimeout < 1000) fdtimeout = 1000; if(fdtimeout > 10000) fdtimeout = 10000; } p = ast_variable_retrieve(cfg, "general", "sdtimeout"); if (p) { sdtimeout = atoi(p); if(sdtimeout < 110) sdtimeout = 110; if(sdtimeout > 4000) sdtimeout = 4000; } p = ast_variable_retrieve(cfg, "general", "logindividualevents"); if (p) log_individual_events = ast_true(p); p = ast_variable_retrieve(cfg, "general", "eventspooldir"); if (p) { ast_copy_string(event_spool_dir, p, sizeof(event_spool_dir)); } p = ast_variable_retrieve(cfg, "general", "timestampformat"); if (p) { ast_copy_string(time_stamp_format, p, sizeof(time_stamp_format)); } p = ast_variable_retrieve(cfg, "general", "db-family"); if (p) { ast_copy_string(db_family, p, sizeof(db_family)); } ast_config_destroy(cfg); } return 1; } /* * These functions are required to implement an Asterisk App. */ static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { if (load_config()) { if (ast_register_application_xml(app, alarmreceiver_exec)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } else return AST_MODULE_LOAD_DECLINE; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Alarm Receiver for Asterisk"); asterisk-11.7.0/apps/app_externalivr.c0000644000175000007640000006532711770334100017670 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Kevin P. Fleming * * Portions taken from the file-based music-on-hold work * created by Anthony Minessale II in res_musiconhold.c * * 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 External IVR application interface * * \author Kevin P. Fleming * * \note Portions taken from the file-based music-on-hold work * created by Anthony Minessale II in res_musiconhold.c * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 369142 $") #include #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/linkedlists.h" #include "asterisk/app.h" #include "asterisk/utils.h" #include "asterisk/tcptls.h" #include "asterisk/astobj2.h" /*** DOCUMENTATION Interfaces with an external IVR application. Either forks a process to run given command or makes a socket to connect to given host and starts a generator on the channel. The generator's play list is controlled by the external application, which can add and clear entries via simple commands issued over its stdout. The external application will receive all DTMF events received on the channel, and notification if the channel is hung up. The received on the channel, and notification if the channel is hung up. The application will not be forcibly terminated when the channel is hung up. For more information see doc/AST.pdf. ***/ static const char app[] = "ExternalIVR"; /* XXX the parser in gcc 2.95 gets confused if you don't put a space between 'name' and the comma */ #define ast_chan_log(level, channel, format, ...) ast_log(level, "%s: " format, ast_channel_name(channel) , ## __VA_ARGS__) /* Commands */ #define EIVR_CMD_APND 'A' /* append to prompt queue */ #define EIVR_CMD_DTMF 'D' /* send DTMF */ #define EIVR_CMD_EXIT 'E' /* exit */ #define EIVR_CMD_GET 'G' /* get channel varable(s) */ #define EIVR_CMD_HGUP 'H' /* hangup */ #define EIVR_CMD_IRPT 'I' /* interrupt */ #define EIVR_CMD_LOG 'L' /* log message */ #define EIVR_CMD_OPT 'O' /* option */ #define EIVR_CMD_PARM 'P' /* return supplied params */ #define EIVR_CMD_SQUE 'S' /* (re)set prompt queue */ #define EIVR_CMD_ANS 'T' /* answer channel */ #define EIVR_CMD_SVAR 'V' /* set channel varable(s) */ #define EIVR_CMD_XIT 'X' /* exit **depricated** */ #define EXTERNALIVR_PORT 2949 enum options_flags { noanswer = (1 << 0), ignore_hangup = (1 << 1), run_dead = (1 << 2), }; AST_APP_OPTIONS(app_opts, { AST_APP_OPTION('n', noanswer), AST_APP_OPTION('i', ignore_hangup), AST_APP_OPTION('d', run_dead), }); struct playlist_entry { AST_LIST_ENTRY(playlist_entry) list; char filename[1]; }; struct ivr_localuser { struct ast_channel *chan; AST_LIST_HEAD(playlist, playlist_entry) playlist; AST_LIST_HEAD(finishlist, playlist_entry) finishlist; int abort_current_sound; int playing_silence; int option_autoclear; int gen_active; }; struct gen_state { struct ivr_localuser *u; struct ast_filestream *stream; struct playlist_entry *current; int sample_queue; }; static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, int *eivr_events_fd, int *eivr_commands_fd, int *eivr_errors_fd, const struct ast_str *args, const struct ast_flags flags); static void send_eivr_event(FILE *handle, const char event, const char *data, const struct ast_channel *chan) { struct ast_str *tmp = ast_str_create(12); ast_str_append(&tmp, 0, "%c,%10d", event, (int)time(NULL)); if (data) { ast_str_append(&tmp, 0, ",%s", data); } fprintf(handle, "%s\n", ast_str_buffer(tmp)); ast_debug(1, "sent '%s'\n", ast_str_buffer(tmp)); ast_free(tmp); } static void *gen_alloc(struct ast_channel *chan, void *params) { struct ivr_localuser *u = params; struct gen_state *state; if (!(state = ast_calloc(1, sizeof(*state)))) return NULL; state->u = u; return state; } static void gen_closestream(struct gen_state *state) { if (!state->stream) return; ast_closestream(state->stream); ast_channel_stream_set(state->u->chan, NULL); state->stream = NULL; } static void gen_release(struct ast_channel *chan, void *data) { struct gen_state *state = data; gen_closestream(state); ast_free(data); } /* caller has the playlist locked */ static int gen_nextfile(struct gen_state *state) { struct ivr_localuser *u = state->u; char *file_to_stream; u->abort_current_sound = 0; u->playing_silence = 0; gen_closestream(state); while (!state->stream) { state->current = AST_LIST_FIRST(&u->playlist); if (state->current) { file_to_stream = state->current->filename; } else { file_to_stream = "silence/10"; u->playing_silence = 1; } if (!(state->stream = ast_openstream_full(u->chan, file_to_stream, ast_channel_language(u->chan), 1))) { ast_chan_log(LOG_WARNING, u->chan, "File '%s' could not be opened: %s\n", file_to_stream, strerror(errno)); AST_LIST_LOCK(&u->playlist); AST_LIST_REMOVE_HEAD(&u->playlist, list); AST_LIST_UNLOCK(&u->playlist); if (!u->playing_silence) { continue; } else { break; } } } return (!state->stream); } static struct ast_frame *gen_readframe(struct gen_state *state) { struct ast_frame *f = NULL; struct ivr_localuser *u = state->u; if (u->abort_current_sound || (u->playing_silence && AST_LIST_FIRST(&u->playlist))) { gen_closestream(state); AST_LIST_LOCK(&u->playlist); gen_nextfile(state); AST_LIST_UNLOCK(&u->playlist); } if (!(state->stream && (f = ast_readframe(state->stream)))) { if (state->current) { /* remove finished file from playlist */ AST_LIST_LOCK(&u->playlist); AST_LIST_REMOVE_HEAD(&u->playlist, list); AST_LIST_UNLOCK(&u->playlist); /* add finished file to finishlist */ AST_LIST_LOCK(&u->finishlist); AST_LIST_INSERT_TAIL(&u->finishlist, state->current, list); AST_LIST_UNLOCK(&u->finishlist); state->current = NULL; } if (!gen_nextfile(state)) f = ast_readframe(state->stream); } return f; } static int gen_generate(struct ast_channel *chan, void *data, int len, int samples) { struct gen_state *state = data; struct ast_frame *f = NULL; int res = 0; state->sample_queue += samples; while (state->sample_queue > 0) { if (!(f = gen_readframe(state))) return -1; res = ast_write(chan, f); ast_frfree(f); if (res < 0) { ast_chan_log(LOG_WARNING, chan, "Failed to write frame: %s\n", strerror(errno)); return -1; } state->sample_queue -= f->samples; } return res; } static struct ast_generator gen = { .alloc = gen_alloc, .release = gen_release, .generate = gen_generate, }; static void ast_eivr_getvariable(struct ast_channel *chan, char *data, char *outbuf, int outbuflen) { /* original input data: "G,var1,var2," */ /* data passed as "data": "var1,var2" */ char *inbuf, *variable; const char *value; int j; struct ast_str *newstring = ast_str_alloca(outbuflen); outbuf[0] = '\0'; for (j = 1, inbuf = data; ; j++) { variable = strsep(&inbuf, ","); if (variable == NULL) { int outstrlen = strlen(outbuf); if (outstrlen && outbuf[outstrlen - 1] == ',') { outbuf[outstrlen - 1] = 0; } break; } ast_channel_lock(chan); if (!(value = pbx_builtin_getvar_helper(chan, variable))) { value = ""; } ast_str_append(&newstring, 0, "%s=%s,", variable, value); ast_channel_unlock(chan); ast_copy_string(outbuf, ast_str_buffer(newstring), outbuflen); } } static void ast_eivr_setvariable(struct ast_channel *chan, char *data) { char *value; char *inbuf = ast_strdupa(data), *variable; for (variable = strsep(&inbuf, ","); variable; variable = strsep(&inbuf, ",")) { ast_debug(1, "Setting up a variable: %s\n", variable); /* variable contains "varname=value" */ value = strchr(variable, '='); if (!value) { value = ""; } else { *value++ = '\0'; } pbx_builtin_setvar_helper(chan, variable, value); } } static void ast_eivr_senddtmf(struct ast_channel *chan, char *vdata) { char *data; int dinterval = 0, duration = 0; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(digits); AST_APP_ARG(dinterval); AST_APP_ARG(duration); ); data = ast_strdupa(vdata); AST_STANDARD_APP_ARGS(args, data); if (!ast_strlen_zero(args.dinterval)) { ast_app_parse_timelen(args.dinterval, &dinterval, TIMELEN_MILLISECONDS); } if (!ast_strlen_zero(args.duration)) { ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS); } ast_verb(4, "Sending DTMF: %s %d %d\n", args.digits, dinterval <= 0 ? 250 : dinterval, duration); ast_dtmf_stream(chan, NULL, args.digits, dinterval <= 0 ? 250 : dinterval, duration); } static struct playlist_entry *make_entry(const char *filename) { struct playlist_entry *entry; if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(filename) + 10))) /* XXX why 10 ? */ return NULL; strcpy(entry->filename, filename); return entry; } static int app_exec(struct ast_channel *chan, const char *data) { struct ast_flags flags = { 0, }; char *opts[0]; struct playlist_entry *entry; int child_stdin[2] = { -1, -1 }; int child_stdout[2] = { -1, -1 }; int child_stderr[2] = { -1, -1 }; int res = -1; int pid; struct ast_tcptls_session_instance *ser = NULL; struct ivr_localuser foo = { .playlist = AST_LIST_HEAD_INIT_VALUE, .finishlist = AST_LIST_HEAD_INIT_VALUE, .gen_active = 0, .playing_silence = 1, }; struct ivr_localuser *u = &foo; char *buf; int j; char *s, **app_args, *e; struct ast_str *comma_delim_args = ast_str_alloca(100); AST_DECLARE_APP_ARGS(eivr_args, AST_APP_ARG(application); AST_APP_ARG(options); ); AST_DECLARE_APP_ARGS(application_args, AST_APP_ARG(cmd)[32]; ); u->abort_current_sound = 0; u->chan = chan; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "ExternalIVR requires a command to execute\n"); goto exit; } buf = ast_strdupa(data); AST_STANDARD_APP_ARGS(eivr_args, buf); ast_verb(4, "ExternalIVR received application and arguments: %s\n", eivr_args.application); ast_verb(4, "ExternalIVR received options: %s\n", eivr_args.options); /* Parse out any application arguments */ if ((s = strchr(eivr_args.application, '('))) { s[0] = ','; if ((e = strrchr(s, ')'))) { *e = '\0'; } else { ast_log(LOG_ERROR, "Parse error, missing closing parenthesis\n"); goto exit; } } AST_STANDARD_APP_ARGS(application_args, eivr_args.application); app_args = application_args.argv; /* Put the application + the arguments in a , delimited list */ ast_str_reset(comma_delim_args); for (j = 0; application_args.cmd[j] != NULL; j++) { ast_str_append(&comma_delim_args, 0, "%s%s", j == 0 ? "" : ",", application_args.cmd[j]); } /* Get rid of any extraneous arguments */ if (eivr_args.options && (s = strchr(eivr_args.options, ','))) { *s = '\0'; } /* Parse the ExternalIVR() arguments */ ast_verb(4, "Parsing options from: [%s]\n", eivr_args.options); ast_app_parse_options(app_opts, &flags, opts, eivr_args.options); if (ast_test_flag(&flags, noanswer)) { ast_verb(4, "noanswer is set\n"); } if (ast_test_flag(&flags, ignore_hangup)) { ast_verb(4, "ignore_hangup is set\n"); } if (ast_test_flag(&flags, run_dead)) { ast_verb(4, "run_dead is set\n"); } if (!(ast_test_flag(&flags, noanswer))) { ast_verb(3, "Answering channel and starting generator\n"); if (ast_channel_state(chan) != AST_STATE_UP) { if (ast_test_flag(&flags, run_dead)) { ast_chan_log(LOG_ERROR, chan, "Running ExternalIVR with 'd'ead flag on non-hungup channel isn't supported\n"); goto exit; } ast_answer(chan); } if (ast_activate_generator(chan, &gen, u) < 0) { ast_chan_log(LOG_ERROR, chan, "Failed to activate generator\n"); goto exit; } else { u->gen_active = 1; } } if (!strncmp(app_args[0], "ivr://", sizeof("ivr://") - 1)) { struct ast_tcptls_session_args ivr_desc = { .accept_fd = -1, .name = "IVR", }; struct ast_sockaddr *addrs; int num_addrs = 0, i = 0; char *host = app_args[0] + sizeof("ivr://") - 1; /* Communicate through socket to server */ ast_debug(1, "Parsing hostname/port for socket connect from \"%s\"\n", host); if (!(num_addrs = ast_sockaddr_resolve(&addrs, host, 0, AST_AF_UNSPEC))) { ast_chan_log(LOG_ERROR, chan, "Unable to locate host '%s'\n", host); goto exit; } for (i = 0; i < num_addrs; i++) { if (!ast_sockaddr_port(&addrs[i])) { /* Default port if not specified */ ast_sockaddr_set_port(&addrs[i], EXTERNALIVR_PORT); } ast_sockaddr_copy(&ivr_desc.remote_address, &addrs[i]); if (!(ser = ast_tcptls_client_create(&ivr_desc)) || !(ser = ast_tcptls_client_start(ser))) { continue; } break; } if (i == num_addrs) { ast_chan_log(LOG_ERROR, chan, "Could not connect to any host. ExternalIVR failed.\n"); goto exit; } res = eivr_comm(chan, u, &ser->fd, &ser->fd, NULL, comma_delim_args, flags); } else { if (pipe(child_stdin)) { ast_chan_log(LOG_ERROR, chan, "Could not create pipe for child input: %s\n", strerror(errno)); goto exit; } if (pipe(child_stdout)) { ast_chan_log(LOG_ERROR, chan, "Could not create pipe for child output: %s\n", strerror(errno)); goto exit; } if (pipe(child_stderr)) { ast_chan_log(LOG_ERROR, chan, "Could not create pipe for child errors: %s\n", strerror(errno)); goto exit; } pid = ast_safe_fork(0); if (pid < 0) { ast_log(LOG_ERROR, "Failed to fork(): %s\n", strerror(errno)); goto exit; } if (!pid) { /* child process */ if (ast_opt_high_priority) ast_set_priority(0); dup2(child_stdin[0], STDIN_FILENO); dup2(child_stdout[1], STDOUT_FILENO); dup2(child_stderr[1], STDERR_FILENO); ast_close_fds_above_n(STDERR_FILENO); execv(app_args[0], app_args); fprintf(stderr, "Failed to execute '%s': %s\n", app_args[0], strerror(errno)); _exit(1); } else { /* parent process */ close(child_stdin[0]); child_stdin[0] = -1; close(child_stdout[1]); child_stdout[1] = -1; close(child_stderr[1]); child_stderr[1] = -1; res = eivr_comm(chan, u, &child_stdin[1], &child_stdout[0], &child_stderr[0], comma_delim_args, flags); } } exit: if (u->gen_active) { ast_deactivate_generator(chan); } if (child_stdin[0] > -1) { close(child_stdin[0]); } if (child_stdin[1] > -1) { close(child_stdin[1]); } if (child_stdout[0] > -1) { close(child_stdout[0]); } if (child_stdout[1] > -1) { close(child_stdout[1]); } if (child_stderr[0] > -1) { close(child_stderr[0]); } if (child_stderr[1] > -1) { close(child_stderr[1]); } if (ser) { ao2_ref(ser, -1); } while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { ast_free(entry); } return res; } static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, int *eivr_events_fd, int *eivr_commands_fd, int *eivr_errors_fd, const struct ast_str *args, const struct ast_flags flags) { struct playlist_entry *entry; struct ast_frame *f; int ms; int exception; int ready_fd; int waitfds[2] = { *eivr_commands_fd, (eivr_errors_fd) ? *eivr_errors_fd : -1 }; struct ast_channel *rchan; int res = -1; int test_available_fd = -1; int hangup_info_sent = 0; FILE *eivr_commands = NULL; FILE *eivr_errors = NULL; FILE *eivr_events = NULL; if (!(eivr_events = fdopen(*eivr_events_fd, "w"))) { ast_chan_log(LOG_ERROR, chan, "Could not open stream to send events\n"); goto exit; } if (!(eivr_commands = fdopen(*eivr_commands_fd, "r"))) { ast_chan_log(LOG_ERROR, chan, "Could not open stream to receive commands\n"); goto exit; } if (eivr_errors_fd) { /* if opening a socket connection, error stream will not be used */ if (!(eivr_errors = fdopen(*eivr_errors_fd, "r"))) { ast_chan_log(LOG_ERROR, chan, "Could not open stream to receive errors\n"); goto exit; } } test_available_fd = open("/dev/null", O_RDONLY); setvbuf(eivr_events, NULL, _IONBF, 0); setvbuf(eivr_commands, NULL, _IONBF, 0); if (eivr_errors) { setvbuf(eivr_errors, NULL, _IONBF, 0); } while (1) { if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)) { ast_chan_log(LOG_ERROR, chan, "Is a zombie\n"); break; } if (!hangup_info_sent && !(ast_test_flag(&flags, run_dead)) && ast_check_hangup(chan)) { if (ast_test_flag(&flags, ignore_hangup)) { ast_verb(3, "Got check_hangup, but ignore_hangup set so sending 'I' command\n"); send_eivr_event(eivr_events, 'I', "HANGUP", chan); hangup_info_sent = 1; } else { ast_verb(3, "Got check_hangup\n"); send_eivr_event(eivr_events, 'H', NULL, chan); break; } } ready_fd = 0; ms = 100; errno = 0; exception = 0; rchan = ast_waitfor_nandfds(&chan, 1, waitfds, (eivr_errors_fd) ? 2 : 1, &exception, &ready_fd, &ms); if (ast_channel_state(chan) == AST_STATE_UP && !AST_LIST_EMPTY(&u->finishlist)) { AST_LIST_LOCK(&u->finishlist); while ((entry = AST_LIST_REMOVE_HEAD(&u->finishlist, list))) { send_eivr_event(eivr_events, 'F', entry->filename, chan); ast_free(entry); } AST_LIST_UNLOCK(&u->finishlist); } if (ast_channel_state(chan) == AST_STATE_UP && !(ast_check_hangup(chan)) && rchan) { /* the channel has something */ f = ast_read(chan); if (!f) { ast_verb(3, "Returned no frame\n"); send_eivr_event(eivr_events, 'H', NULL, chan); break; } if (f->frametype == AST_FRAME_DTMF) { send_eivr_event(eivr_events, f->subclass.integer, NULL, chan); if (u->option_autoclear) { AST_LIST_LOCK(&u->playlist); if (!u->abort_current_sound && !u->playing_silence) { /* send interrupted file as T data */ if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { send_eivr_event(eivr_events, 'T', entry->filename, chan); ast_free(entry); } } while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { send_eivr_event(eivr_events, 'D', entry->filename, chan); ast_free(entry); } if (!u->playing_silence) u->abort_current_sound = 1; AST_LIST_UNLOCK(&u->playlist); } } else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) { ast_verb(3, "Got AST_CONTROL_HANGUP\n"); send_eivr_event(eivr_events, 'H', NULL, chan); if (f->data.uint32) { ast_channel_hangupcause_set(chan, f->data.uint32); } ast_frfree(f); break; } ast_frfree(f); } else if (ready_fd == *eivr_commands_fd) { char input[1024]; if (exception || (dup2(*eivr_commands_fd, test_available_fd) == -1) || feof(eivr_commands)) { ast_chan_log(LOG_ERROR, chan, "Child process went away\n"); break; } if (!fgets(input, sizeof(input), eivr_commands)) { continue; } ast_strip(input); ast_verb(4, "got command '%s'\n", input); if (strlen(input) < 3) { continue; } if (input[0] == EIVR_CMD_PARM) { struct ast_str *tmp = (struct ast_str *) args; send_eivr_event(eivr_events, 'P', ast_str_buffer(tmp), chan); } else if (input[0] == EIVR_CMD_DTMF) { ast_verb(4, "Sending DTMF: %s\n", &input[2]); ast_eivr_senddtmf(chan, &input[2]); } else if (input[0] == EIVR_CMD_ANS) { ast_verb(3, "Answering channel if needed and starting generator\n"); if (ast_channel_state(chan) != AST_STATE_UP) { if (ast_test_flag(&flags, run_dead)) { ast_chan_log(LOG_WARNING, chan, "Running ExternalIVR with 'd'ead flag on non-hungup channel isn't supported\n"); send_eivr_event(eivr_events, 'Z', "ANSWER_FAILURE", chan); continue; } if (ast_answer(chan)) { ast_chan_log(LOG_WARNING, chan, "Failed to answer channel\n"); send_eivr_event(eivr_events, 'Z', "ANSWER_FAILURE", chan); continue; } } if (!(u->gen_active)) { if (ast_activate_generator(chan, &gen, u) < 0) { ast_chan_log(LOG_WARNING, chan, "Failed to activate generator\n"); send_eivr_event(eivr_events, 'Z', "GENERATOR_FAILURE", chan); } else { u->gen_active = 1; } } } else if (input[0] == EIVR_CMD_IRPT) { if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) { ast_chan_log(LOG_WARNING, chan, "Queue 'I'nterrupt called on unanswered channel\n"); send_eivr_event(eivr_events, 'Z', NULL, chan); continue; } AST_LIST_LOCK(&u->playlist); if (!u->abort_current_sound && !u->playing_silence) { /* send interrupted file as T data */ if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { send_eivr_event(eivr_events, 'T', entry->filename, chan); ast_free(entry); } } while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { send_eivr_event(eivr_events, 'D', entry->filename, chan); ast_free(entry); } if (!u->playing_silence) { u->abort_current_sound = 1; } AST_LIST_UNLOCK(&u->playlist); } else if (input[0] == EIVR_CMD_SQUE) { if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) { ast_chan_log(LOG_WARNING, chan, "Queue re'S'et called on unanswered channel\n"); send_eivr_event(eivr_events, 'Z', NULL, chan); continue; } if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) { ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]); send_eivr_event(eivr_events, 'Z', &input[2], chan); } else { AST_LIST_LOCK(&u->playlist); if (!u->abort_current_sound && !u->playing_silence) { /* send interrupted file as T data */ if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { send_eivr_event(eivr_events, 'T', entry->filename, chan); ast_free(entry); } } while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { send_eivr_event(eivr_events, 'D', entry->filename, chan); ast_free(entry); } if (!u->playing_silence) { u->abort_current_sound = 1; } entry = make_entry(&input[2]); if (entry) { AST_LIST_INSERT_TAIL(&u->playlist, entry, list); } AST_LIST_UNLOCK(&u->playlist); } } else if (input[0] == EIVR_CMD_APND) { if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) { ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n"); send_eivr_event(eivr_events, 'Z', NULL, chan); continue; } if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) { ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]); send_eivr_event(eivr_events, 'Z', &input[2], chan); } else { entry = make_entry(&input[2]); if (entry) { AST_LIST_LOCK(&u->playlist); AST_LIST_INSERT_TAIL(&u->playlist, entry, list); AST_LIST_UNLOCK(&u->playlist); } } } else if (input[0] == EIVR_CMD_GET) { char response[2048]; ast_verb(4, "Retriving Variables from channel: %s\n", &input[2]); ast_eivr_getvariable(chan, &input[2], response, sizeof(response)); send_eivr_event(eivr_events, 'G', response, chan); } else if (input[0] == EIVR_CMD_SVAR) { ast_verb(4, "Setting Variables in channel: %s\n", &input[2]); ast_eivr_setvariable(chan, &input[2]); } else if (input[0] == EIVR_CMD_LOG) { ast_chan_log(LOG_NOTICE, chan, "Log message from EIVR: %s\n", &input[2]); } else if (input[0] == EIVR_CMD_XIT) { ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]); ast_chan_log(LOG_WARNING, chan, "e'X'it command is depricated, use 'E'xit instead\n"); res = 0; break; } else if (input[0] == EIVR_CMD_EXIT) { ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]); send_eivr_event(eivr_events, 'E', NULL, chan); res = 0; break; } else if (input[0] == EIVR_CMD_HGUP) { ast_chan_log(LOG_NOTICE, chan, "Hanging up: %s\n", &input[2]); send_eivr_event(eivr_events, 'H', NULL, chan); break; } else if (input[0] == EIVR_CMD_OPT) { if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) { ast_chan_log(LOG_WARNING, chan, "Option called on unanswered channel\n"); send_eivr_event(eivr_events, 'Z', NULL, chan); continue; } if (!strcasecmp(&input[2], "autoclear")) u->option_autoclear = 1; else if (!strcasecmp(&input[2], "noautoclear")) u->option_autoclear = 0; else ast_chan_log(LOG_WARNING, chan, "Unknown option requested: %s\n", &input[2]); } } else if (eivr_errors_fd && (ready_fd == *eivr_errors_fd)) { char input[1024]; if (exception || feof(eivr_errors)) { ast_chan_log(LOG_ERROR, chan, "Child process went away\n"); break; } if (fgets(input, sizeof(input), eivr_errors)) { ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", ast_strip(input)); } } else if ((ready_fd < 0) && ms) { if (errno == 0 || errno == EINTR) continue; ast_chan_log(LOG_ERROR, chan, "Wait failed (%s)\n", strerror(errno)); break; } } exit: if (test_available_fd > -1) { close(test_available_fd); } if (eivr_events) { fclose(eivr_events); *eivr_events_fd = -1; } if (eivr_commands) { fclose(eivr_commands); *eivr_commands_fd = -1; } if (eivr_errors) { fclose(eivr_errors); *eivr_errors_fd = -1; } return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, app_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "External IVR Interface Application"); asterisk-11.7.0/apps/app_sendtext.c0000644000175000007640000000611411720555237017163 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 App to transmit a text message * * \author Mark Spencer * * \note Requires support of sending text messages from channel driver * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356042 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/app.h" /*** DOCUMENTATION Send a Text Message. Sends text to current channel (callee). Result of transmission will be stored in the SENDTEXTSTATUS Transmission succeeded. Transmission failed. Text transmission not supported by channel. At this moment, text is supposed to be 7 bit ASCII in most channels. SendImage SendURL ***/ static const char * const app = "SendText"; static int sendtext_exec(struct ast_channel *chan, const char *data) { char *status = "UNSUPPORTED"; struct ast_str *str; /* NOT ast_strlen_zero, because some protocols (e.g. SIP) MUST be able to * send a zero-length message. */ if (!data) { ast_log(LOG_WARNING, "SendText requires an argument (text)\n"); return -1; } if (!(str = ast_str_alloca(strlen(data) + 1))) { return -1; } ast_str_get_encoded_str(&str, -1, data); ast_channel_lock(chan); if (!ast_channel_tech(chan)->send_text) { ast_channel_unlock(chan); /* Does not support transport */ pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status); return 0; } status = "FAILURE"; if (!ast_sendtext(chan, ast_str_buffer(str))) { status = "SUCCESS"; } ast_channel_unlock(chan); pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status); return 0; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, sendtext_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send Text Applications"); asterisk-11.7.0/apps/app_sayunixtime.c0000644000175000007640000001172411720555237017707 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (c) 2003, 2006 Tilghman Lesher. All rights reserved. * Copyright (c) 2006 Digium, Inc. * * Tilghman Lesher * * This code is released by the author with no restrictions on usage. * * 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. * */ /*! \file * * \brief SayUnixTime application * * \author Tilghman Lesher * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356042 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/say.h" #include "asterisk/app.h" /*** DOCUMENTATION Says a specified time in a custom format. time, in seconds since Jan 1, 1970. May be negative. Defaults to now. timezone, see /usr/share/zoneinfo for a list. Defaults to machine default. a format the time is to be said in. See voicemail.conf. Defaults to ABdY "digits/at" IMp Uses some of the sound files stored in /var/lib/asterisk/sounds to construct a phrase saying the specified date and/or time in the specified format. STRFTIME STRPTIME IFTIME Says a specified time in a custom format. time, in seconds since Jan 1, 1970. May be negative. Defaults to now. timezone, see /usr/share/zoneinfo for a list. Defaults to machine default. a format the time is to be said in. See voicemail.conf. Defaults to ABdY "digits/at" IMp Say the date and time in a specified format. ***/ enum { OPT_JUMP = (1 << 0), }; enum { OPT_ARG_JUMP = 0, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(sayunixtime_exec_options, BEGIN_OPTIONS AST_APP_OPTION_ARG('j', OPT_JUMP, OPT_ARG_JUMP), END_OPTIONS ); static char *app_sayunixtime = "SayUnixTime"; static char *app_datetime = "DateTime"; static int sayunixtime_exec(struct ast_channel *chan, const char *data) { AST_DECLARE_APP_ARGS(args, AST_APP_ARG(timeval); AST_APP_ARG(timezone); AST_APP_ARG(format); AST_APP_ARG(options); ); char *parse; int res = 0; time_t unixtime; /* New default behavior is do not jump on key pressed */ const char * haltondigits = AST_DIGIT_NONE; struct ast_flags64 opts = { 0, }; char *opt_args[OPT_ARG_ARRAY_SIZE]; if (!data) { return 0; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); /* check if we had the 'j' jump flag in option list */ if (!ast_strlen_zero(args.options)) { ast_app_parse_options64(sayunixtime_exec_options, &opts, opt_args, args.options); if (ast_test_flag64(&opts, OPT_JUMP)){ haltondigits = AST_DIGIT_ANY; } } ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL); if (ast_channel_state(chan) != AST_STATE_UP) { res = ast_answer(chan); } if (!res) { res = ast_say_date_with_format(chan, unixtime, haltondigits, ast_channel_language(chan), ast_strlen_zero(args.format) ? NULL : args.format, ast_strlen_zero(args.timezone) ? NULL : args.timezone); } return res; } static int unload_module(void) { int res; res = ast_unregister_application(app_sayunixtime); res |= ast_unregister_application(app_datetime); return res; } static int load_module(void) { int res; res = ast_register_application_xml(app_sayunixtime, sayunixtime_exec); res |= ast_register_application_xml(app_datetime, sayunixtime_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Say time"); asterisk-11.7.0/apps/app_chanisavail.c0000644000175000007640000001510211730224734017600 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * James Golovich * * 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 Check if Channel is Available * * \author Mark Spencer * \author James Golovich * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 359495 $") #include #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/app.h" #include "asterisk/devicestate.h" static const char app[] = "ChanIsAvail"; /*** DOCUMENTATION Check channel availability Optional extra devices to check If you need more then one enter them as Technology2/Resource2&Technology3/Resourse3&..... Specification of the device(s) to check. These must be in the format of Technology/Resource, where Technology represents a particular channel driver, and Resource represents a resource available to that particular channel driver. This application will check to see if any of the specified channels are available. This application sets the following channel variables: The name of the available channel, if one exists The canonical channel name that was used to create the channel The device state for the device The cause code returned when requesting the channel ***/ static int chanavail_exec(struct ast_channel *chan, const char *data) { int inuse=-1, option_state=0, string_compare=0, option_all_avail=0; int status; char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur; struct ast_str *tmp_availchan = ast_str_alloca(2048); struct ast_str *tmp_availorig = ast_str_alloca(2048); struct ast_str *tmp_availstat = ast_str_alloca(2048); struct ast_str *tmp_availcause = ast_str_alloca(2048); struct ast_channel *tempchan; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(reqchans); AST_APP_ARG(options); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "ChanIsAvail requires an argument (DAHDI/1&DAHDI/2)\n"); return -1; } info = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, info); if (args.options) { if (strchr(args.options, 'a')) { option_all_avail = 1; } if (strchr(args.options, 's')) { option_state = 1; } if (strchr(args.options, 't')) { string_compare = 1; } } peers = args.reqchans; if (peers) { cur = peers; do { /* remember where to start next time */ rest = strchr(cur, '&'); if (rest) { *rest = 0; rest++; } tech = cur; number = strchr(tech, '/'); if (!number) { ast_log(LOG_WARNING, "ChanIsAvail argument takes format ([technology]/[device])\n"); return -1; } *number = '\0'; number++; status = AST_DEVICE_UNKNOWN; if (string_compare) { /* ast_parse_device_state checks for "SIP/1234" as a channel name. ast_device_state will ask the SIP driver for the channel state. */ snprintf(trychan, sizeof(trychan), "%s/%s",cur,number); status = inuse = ast_parse_device_state(trychan); } else if (option_state) { /* If the pbx says in use then don't bother trying further. This is to permit testing if someone's on a call, even if the channel can permit more calls (ie callwaiting, sip calls, etc). */ snprintf(trychan, sizeof(trychan), "%s/%s",cur,number); status = inuse = ast_device_state(trychan); } snprintf(tmp, sizeof(tmp), "%d", status); ast_str_append(&tmp_availstat, 0, "%s%s", ast_str_strlen(tmp_availstat) ? "&" : "", tmp); if ((inuse <= 1) && (tempchan = ast_request(tech, ast_channel_nativeformats(chan), chan, number, &status))) { ast_str_append(&tmp_availchan, 0, "%s%s", ast_str_strlen(tmp_availchan) ? "&" : "", ast_channel_name(tempchan)); snprintf(tmp, sizeof(tmp), "%s/%s", tech, number); ast_str_append(&tmp_availorig, 0, "%s%s", ast_str_strlen(tmp_availorig) ? "&" : "", tmp); snprintf(tmp, sizeof(tmp), "%d", status); ast_str_append(&tmp_availcause, 0, "%s%s", ast_str_strlen(tmp_availcause) ? "&" : "", tmp); ast_hangup(tempchan); tempchan = NULL; if (!option_all_avail) { break; } } cur = rest; } while (cur); } pbx_builtin_setvar_helper(chan, "AVAILCHAN", ast_str_buffer(tmp_availchan)); /* Store the originally used channel too */ pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", ast_str_buffer(tmp_availorig)); pbx_builtin_setvar_helper(chan, "AVAILSTATUS", ast_str_buffer(tmp_availstat)); pbx_builtin_setvar_helper(chan, "AVAILCAUSECODE", ast_str_buffer(tmp_availcause)); return 0; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, chanavail_exec) ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Check channel availability"); asterisk-11.7.0/apps/app_forkcdr.c0000644000175000007640000002451411742050141016747 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Anthony Minessale anthmct@yahoo.com * Development of this app Sponsered/Funded by 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 Fork CDR application * * \author Anthony Minessale anthmct@yahoo.com * * \note Development of this app Sponsored/Funded by TAAN Softworks Corp * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 362085 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/cdr.h" #include "asterisk/app.h" #include "asterisk/module.h" /*** DOCUMENTATION Forks the Call Data Record. Causes the Call Data Record to fork an additional cdr record starting from the time of the fork call. This new cdr record will be linked to end of the list of cdr records attached to the channel. The original CDR has a LOCKED flag set, which forces most cdr operations to skip it, except for the functions that set the answer and end times, which ignore the LOCKED flag. This allows all the cdr records in the channel to be 'ended' together when the channel is closed. The CDR() func (when setting CDR values) normally ignores the LOCKED flag also, but has options to vary its behavior. The 'T' option (described below), can override this behavior, but beware the risks. First, this app finds the last cdr record in the list, and makes a copy of it. This new copy will be the newly forked cdr record. Next, this new record is linked to the end of the cdr record list. Next, The new cdr record is RESET (unless you use an option to prevent this) This means that: 1. All flags are unset on the cdr record 2. the start, end, and answer times are all set to zero. 3. the billsec and duration fields are set to zero. 4. the start time is set to the current time. 5. the disposition is set to NULL. Next, unless you specified the v option, all variables will be removed from the original cdr record. Thus, the v option allows any CDR variables to be replicated to all new forked cdr records. Without the v option, the variables on the original are effectively moved to the new forked cdr record. Next, if the s option is set, the provided variable and value are set on the original cdr record. Next, if the a option is given, and the original cdr record has an answer time set, then the new forked cdr record will have its answer time set to its start time. If the old answer time were carried forward, the answer time would be earlier than the start time, giving strange duration and billsec times. If the d option was specified, the disposition is copied from the original cdr record to the new forked cdr. If the D option was specified, the destination channel field in the new forked CDR is erased. If the e option was specified, the 'end' time for the original cdr record is set to the current time. Future hang-up or ending events will not override this time stamp. If the A option is specified, the original cdr record will have it ANS_LOCKED flag set, which prevent future answer events from updating the original cdr record's disposition. Normally, an ANSWERED event would mark all cdr records in the chain as ANSWERED. If the T option is specified, the original cdr record will have its DONT_TOUCH flag set, which will force the cdr_answer, cdr_end, and cdr_setvar functions to leave that cdr record alone. And, last but not least, the original cdr record has its LOCKED flag set. Almost all internal CDR functions (except for the funcs that set the end, and answer times, and set a variable) will honor this flag and leave a LOCKED cdr record alone. This means that the newly created forked cdr record will be affected by events transpiring within Asterisk, with the previously noted exceptions. CDR NoCDR ResetCDR ***/ static char *app = "ForkCDR"; enum { OPT_SETANS = (1 << 0), OPT_SETDISP = (1 << 1), OPT_RESETDEST = (1 << 2), OPT_ENDCDR = (1 << 3), OPT_NORESET = (1 << 4), OPT_KEEPVARS = (1 << 5), OPT_VARSET = (1 << 6), OPT_ANSLOCK = (1 << 7), OPT_DONTOUCH = (1 << 8), }; enum { OPT_ARG_VARSET = 0, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(forkcdr_exec_options, { AST_APP_OPTION('a', OPT_SETANS), AST_APP_OPTION('A', OPT_ANSLOCK), AST_APP_OPTION('d', OPT_SETDISP), AST_APP_OPTION('D', OPT_RESETDEST), AST_APP_OPTION('e', OPT_ENDCDR), AST_APP_OPTION('R', OPT_NORESET), AST_APP_OPTION_ARG('s', OPT_VARSET, OPT_ARG_VARSET), AST_APP_OPTION('T', OPT_DONTOUCH), AST_APP_OPTION('v', OPT_KEEPVARS), }); static void ast_cdr_fork(struct ast_channel *chan, struct ast_flags optflags, char *set) { struct ast_cdr *cdr; struct ast_cdr *newcdr; struct ast_flags flags = { AST_CDR_FLAG_KEEP_VARS }; cdr = ast_channel_cdr(chan); while (cdr->next) cdr = cdr->next; if (!(newcdr = ast_cdr_dup_unique(cdr))) return; /* * End the original CDR if requested BEFORE appending the new CDR * otherwise we incorrectly end the new CDR also. */ if (ast_test_flag(&optflags, OPT_ENDCDR)) { ast_cdr_end(cdr); } ast_cdr_append(cdr, newcdr); if (!ast_test_flag(&optflags, OPT_NORESET)) ast_cdr_reset(newcdr, &flags); if (!ast_test_flag(cdr, AST_CDR_FLAG_KEEP_VARS)) ast_cdr_free_vars(cdr, 0); if (!ast_strlen_zero(set)) { char *varname = ast_strdupa(set), *varval; varval = strchr(varname,'='); if (varval) { *varval = 0; varval++; ast_cdr_setvar(cdr, varname, varval, 0); } } if (ast_test_flag(&optflags, OPT_SETANS) && !ast_tvzero(cdr->answer)) newcdr->answer = newcdr->start; if (ast_test_flag(&optflags, OPT_SETDISP)) newcdr->disposition = cdr->disposition; if (ast_test_flag(&optflags, OPT_RESETDEST)) newcdr->dstchannel[0] = 0; if (ast_test_flag(&optflags, OPT_ANSLOCK)) ast_set_flag(cdr, AST_CDR_FLAG_ANSLOCKED); if (ast_test_flag(&optflags, OPT_DONTOUCH)) ast_set_flag(cdr, AST_CDR_FLAG_DONT_TOUCH); ast_set_flag(cdr, AST_CDR_FLAG_CHILD | AST_CDR_FLAG_LOCKED); } static int forkcdr_exec(struct ast_channel *chan, const char *data) { int res = 0; char *argcopy = NULL; struct ast_flags flags = {0}; char *opts[OPT_ARG_ARRAY_SIZE]; AST_DECLARE_APP_ARGS(arglist, AST_APP_ARG(options); ); if (!ast_channel_cdr(chan)) { ast_log(LOG_WARNING, "Channel does not have a CDR\n"); return 0; } argcopy = ast_strdupa(data); AST_STANDARD_APP_ARGS(arglist, argcopy); opts[OPT_ARG_VARSET] = 0; if (!ast_strlen_zero(arglist.options)) ast_app_parse_options(forkcdr_exec_options, &flags, opts, arglist.options); if (!ast_strlen_zero(data)) { int keepvars = ast_test_flag(&flags, OPT_KEEPVARS) ? 1 : 0; ast_set2_flag(ast_channel_cdr(chan), keepvars, AST_CDR_FLAG_KEEP_VARS); } ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]); return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, forkcdr_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fork The CDR into 2 separate entities"); asterisk-11.7.0/apps/app_url.c0000644000175000007640000001053211643652375016133 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 App to transmit a URL * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 339778 $") #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/app.h" #include "asterisk/channel.h" /*** DOCUMENTATION Send a URL. Requests client go to URL (IAX2) or sends the URL to the client (other channels). Result is returned in the SENDURLSTATUS channel variable: URL successfully sent to client. Failed to send URL. Client failed to load URL (wait enabled). Channel does not support URL transport. SendURL continues normally if the URL was sent correctly or if the channel does not support HTML transport. Otherwise, the channel is hung up. SendImage SendText ***/ static char *app = "SendURL"; enum option_flags { OPTION_WAIT = (1 << 0), }; AST_APP_OPTIONS(app_opts,{ AST_APP_OPTION('w', OPTION_WAIT), }); static int sendurl_exec(struct ast_channel *chan, const char *data) { int res = 0; char *tmp; struct ast_frame *f; char *status = "FAILURE"; char *opts[0]; struct ast_flags flags = { 0 }; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(url); AST_APP_ARG(options); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n"); pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); return -1; } tmp = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, tmp); if (args.argc == 2) ast_app_parse_options(app_opts, &flags, opts, args.options); if (!ast_channel_supports_html(chan)) { /* Does not support transport */ pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED"); return 0; } res = ast_channel_sendurl(chan, args.url); if (res == -1) { pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE"); return res; } status = "SUCCESS"; if (ast_test_flag(&flags, OPTION_WAIT)) { for(;;) { /* Wait for an event */ res = ast_waitfor(chan, -1); if (res < 0) break; f = ast_read(chan); if (!f) { res = -1; status = "FAILURE"; break; } if (f->frametype == AST_FRAME_HTML) { switch (f->subclass.integer) { case AST_HTML_LDCOMPLETE: res = 0; ast_frfree(f); status = "NOLOAD"; goto out; break; case AST_HTML_NOSUPPORT: /* Does not support transport */ status = "UNSUPPORTED"; res = 0; ast_frfree(f); goto out; break; default: ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass.integer); }; } ast_frfree(f); } } out: pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, sendurl_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send URL Applications"); asterisk-11.7.0/apps/app_nbscat.c0000644000175000007640000001161711721555224016600 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Silly application to play an NBScat file -- uses nbscat8k * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356573 $") #include #include #include #include #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/frame.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/app.h" /*** DOCUMENTATION Play an NBS local stream. Executes nbscat to listen to the local NBS stream. User can exit by pressing any key. ***/ #define LOCAL_NBSCAT "/usr/local/bin/nbscat8k" #define NBSCAT "/usr/bin/nbscat8k" #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX #endif static char *app = "NBScat"; static int NBScatplay(int fd) { int res; res = ast_safe_fork(0); if (res < 0) { ast_log(LOG_WARNING, "Fork failed\n"); } if (res) { return res; } if (ast_opt_high_priority) ast_set_priority(0); dup2(fd, STDOUT_FILENO); ast_close_fds_above_n(STDERR_FILENO); /* Most commonly installed in /usr/local/bin */ execl(NBSCAT, "nbscat8k", "-d", (char *)NULL); execl(LOCAL_NBSCAT, "nbscat8k", "-d", (char *)NULL); fprintf(stderr, "Execute of nbscat8k failed\n"); _exit(0); } static int timed_read(int fd, void *data, int datalen) { int res; struct pollfd fds[1]; fds[0].fd = fd; fds[0].events = POLLIN; res = ast_poll(fds, 1, 2000); if (res < 1) { ast_log(LOG_NOTICE, "Selected timed out/errored out with %d\n", res); return -1; } return read(fd, data, datalen); } static int NBScat_exec(struct ast_channel *chan, const char *data) { int res=0; int fds[2]; int ms = -1; int pid = -1; struct ast_format owriteformat; struct timeval next; struct ast_frame *f; struct myframe { struct ast_frame f; char offset[AST_FRIENDLY_OFFSET]; short frdata[160]; } myf; ast_format_clear(&owriteformat); if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds)) { ast_log(LOG_WARNING, "Unable to create socketpair\n"); return -1; } ast_stopstream(chan); ast_format_copy(&owriteformat, ast_channel_writeformat(chan)); res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set write format to signed linear\n"); return -1; } res = NBScatplay(fds[1]); /* Wait 1000 ms first */ next = ast_tvnow(); next.tv_sec += 1; if (res >= 0) { pid = res; /* Order is important -- there's almost always going to be mp3... we want to prioritize the user */ for (;;) { ms = ast_tvdiff_ms(next, ast_tvnow()); if (ms <= 0) { res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata)); if (res > 0) { myf.f.frametype = AST_FRAME_VOICE; ast_format_set(&myf.f.subclass.format, AST_FORMAT_SLINEAR, 0); myf.f.datalen = res; myf.f.samples = res / 2; myf.f.mallocd = 0; myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.src = __PRETTY_FUNCTION__; myf.f.delivery.tv_sec = 0; myf.f.delivery.tv_usec = 0; myf.f.data.ptr = myf.frdata; if (ast_write(chan, &myf.f) < 0) { res = -1; break; } } else { ast_debug(1, "No more mp3\n"); res = 0; break; } next = ast_tvadd(next, ast_samp2tv(myf.f.samples, 8000)); } else { ms = ast_waitfor(chan, ms); if (ms < 0) { ast_debug(1, "Hangup detected\n"); res = -1; break; } if (ms) { f = ast_read(chan); if (!f) { ast_debug(1, "Null frame == hangup() detected\n"); res = -1; break; } if (f->frametype == AST_FRAME_DTMF) { ast_debug(1, "User pressed a key\n"); ast_frfree(f); res = 0; break; } ast_frfree(f); } } } } close(fds[0]); close(fds[1]); if (pid > -1) kill(pid, SIGKILL); if (!res && owriteformat.id) ast_set_write_format(chan, &owriteformat); return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, NBScat_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Silly NBS Stream Application"); asterisk-11.7.0/apps/app_senddtmf.c0000644000175000007640000001155612031150327017122 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 App to send DTMF digits * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 373954 $") #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/app.h" #include "asterisk/manager.h" #include "asterisk/channel.h" /*** DOCUMENTATION Sends arbitrary DTMF digits List of digits 0-9,*#,a-d,A-D to send also w for a half second pause, and f or F for a flash-hook if the channel supports flash-hook. Amount of time to wait in ms between tones. (defaults to .25s) Duration of each digit Channel where digits will be played It will send all digits or terminate if it encounters an error. Read Play DTMF signal on a specific channel. Channel name to send digit to. The DTMF digit to play. Plays a dtmf digit on the specified channel. ***/ static const char senddtmf_name[] = "SendDTMF"; static int senddtmf_exec(struct ast_channel *chan, const char *vdata) { int res; char *data; int dinterval = 0, duration = 0; struct ast_channel *chan_found = NULL; struct ast_channel *chan_dest = chan; struct ast_channel *chan_autoservice = NULL; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(digits); AST_APP_ARG(dinterval); AST_APP_ARG(duration); AST_APP_ARG(channel); ); if (ast_strlen_zero(vdata)) { ast_log(LOG_WARNING, "SendDTMF requires an argument\n"); return 0; } data = ast_strdupa(vdata); AST_STANDARD_APP_ARGS(args, data); if (ast_strlen_zero(args.digits)) { ast_log(LOG_WARNING, "The digits argument is required (0-9,*#,a-d,A-D,wfF)\n"); return 0; } if (!ast_strlen_zero(args.dinterval)) { ast_app_parse_timelen(args.dinterval, &dinterval, TIMELEN_MILLISECONDS); } if (!ast_strlen_zero(args.duration)) { ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS); } if (!ast_strlen_zero(args.channel)) { chan_found = ast_channel_get_by_name(args.channel); if (!chan_found) { ast_log(LOG_WARNING, "No such channel: %s\n", args.channel); return 0; } chan_dest = chan_found; if (chan_found != chan) { chan_autoservice = chan; } } res = ast_dtmf_stream(chan_dest, chan_autoservice, args.digits, dinterval <= 0 ? 250 : dinterval, duration); if (chan_found) { ast_channel_unref(chan_found); } return chan_autoservice ? 0 : res; } static int manager_play_dtmf(struct mansession *s, const struct message *m) { const char *channel = astman_get_header(m, "Channel"); const char *digit = astman_get_header(m, "Digit"); struct ast_channel *chan; if (!(chan = ast_channel_get_by_name(channel))) { astman_send_error(s, m, "Channel not found"); return 0; } if (ast_strlen_zero(digit)) { astman_send_error(s, m, "No digit specified"); chan = ast_channel_unref(chan); return 0; } ast_senddigit(chan, *digit, 0); chan = ast_channel_unref(chan); astman_send_ack(s, m, "DTMF successfully queued"); return 0; } static int unload_module(void) { int res; res = ast_unregister_application(senddtmf_name); res |= ast_manager_unregister("PlayDTMF"); return res; } static int load_module(void) { int res; res = ast_manager_register_xml("PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf); res |= ast_register_application_xml(senddtmf_name, senddtmf_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send DTMF digits Application"); asterisk-11.7.0/apps/app_macro.c0000644000175000007640000005321712006037127016423 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Dial plan macro Implementation * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO core app_stack (GoSub) ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 370655 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/utils.h" #include "asterisk/lock.h" #include "asterisk/app.h" /*** DOCUMENTATION Macro Implementation. The name of the macro Executes a macro using the context macro-name, jumping to the s extension of that context and executing each step, then returning when the steps end. The calling extension, context, and priority are stored in MACRO_EXTEN, MACRO_CONTEXT and MACRO_PRIORITY respectively. Arguments become ARG1, ARG2, etc in the macro context. If you Goto out of the Macro context, the Macro will terminate and control will be returned at the location of the Goto. If MACRO_OFFSET is set at termination, Macro will attempt to continue at priority MACRO_OFFSET + N + 1 if such a step exists, and N + 1 otherwise. Because of the way Macro is implemented (it executes the priorities contained within it via sub-engine), and a fixed per-thread memory stack allowance, macros are limited to 7 levels of nesting (macro calling macro calling macro, etc.); It may be possible that stack-intensive applications in deeply nested macros could cause asterisk to crash earlier than this limit. It is advised that if you need to deeply nest macro calls, that you use the Gosub application (now allows arguments like a Macro) with explict Return() calls instead. Use of the application WaitExten within a macro will not function as expected. Please use the Read application in order to read DTMF from a channel currently executing a macro. MacroExit Goto Gosub Conditional Macro implementation. Executes macro defined in macroiftrue if expr is true (otherwise macroiffalse if provided) Arguments and return values as in application Macro() GotoIf GosubIf IF Exclusive Macro Implementation. The name of the macro Executes macro defined in the context macro-name. Only one call at a time may run the macro. (we'll wait if another call is busy executing in the Macro) Arguments and return values as in application Macro() Macro Exit from Macro. Causes the currently running macro to exit as if it had ended normally by running out of priorities to execute. If used outside a macro, will likely cause unexpected behavior. Macro ***/ #define MAX_ARGS 80 /* special result value used to force macro exit */ #define MACRO_EXIT_RESULT 1024 static char *app = "Macro"; static char *if_app = "MacroIf"; static char *exclusive_app = "MacroExclusive"; static char *exit_app = "MacroExit"; static void macro_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan); static const struct ast_datastore_info macro_ds_info = { .type = "MACRO", .chan_fixup = macro_fixup, }; static void macro_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan) { int i; char varname[10]; pbx_builtin_setvar_helper(new_chan, "MACRO_DEPTH", "0"); pbx_builtin_setvar_helper(new_chan, "MACRO_CONTEXT", NULL); pbx_builtin_setvar_helper(new_chan, "MACRO_EXTEN", NULL); pbx_builtin_setvar_helper(new_chan, "MACRO_PRIORITY", NULL); pbx_builtin_setvar_helper(new_chan, "MACRO_OFFSET", NULL); for (i = 1; i < 100; i++) { snprintf(varname, sizeof(varname), "ARG%d", i); while (pbx_builtin_getvar_helper(new_chan, varname)) { /* Kill all levels of arguments */ pbx_builtin_setvar_helper(new_chan, varname, NULL); } } } static struct ast_exten *find_matching_priority(struct ast_context *c, const char *exten, int priority, const char *callerid) { struct ast_exten *e; struct ast_include *i; struct ast_context *c2; for (e=ast_walk_context_extensions(c, NULL); e; e=ast_walk_context_extensions(c, e)) { if (ast_extension_match(ast_get_extension_name(e), exten)) { int needmatch = ast_get_extension_matchcid(e); if ((needmatch && ast_extension_match(ast_get_extension_cidmatch(e), callerid)) || (!needmatch)) { /* This is the matching extension we want */ struct ast_exten *p; for (p=ast_walk_extension_priorities(e, NULL); p; p=ast_walk_extension_priorities(e, p)) { if (priority != ast_get_extension_priority(p)) continue; return p; } } } } /* No match; run through includes */ for (i=ast_walk_context_includes(c, NULL); i; i=ast_walk_context_includes(c, i)) { for (c2=ast_walk_contexts(NULL); c2; c2=ast_walk_contexts(c2)) { if (!strcmp(ast_get_context_name(c2), ast_get_include_name(i))) { e = find_matching_priority(c2, exten, priority, callerid); if (e) return e; } } } return NULL; } static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive) { const char *s; char *tmp; char *cur, *rest; char *macro; char fullmacro[80]; char varname[80]; char runningapp[80], runningdata[1024]; char *oldargs[MAX_ARGS + 1] = { NULL, }; int argc, x; int res=0; char oldexten[256]=""; int oldpriority, gosub_level = 0; char pc[80], depthc[12]; char oldcontext[AST_MAX_CONTEXT] = ""; const char *inhangupc; int offset, depth = 0, maxdepth = 7; int setmacrocontext=0; int autoloopflag, inhangup = 0; struct ast_str *tmp_subst = NULL; char *save_macro_exten; char *save_macro_context; char *save_macro_priority; char *save_macro_offset; struct ast_datastore *macro_store = ast_channel_datastore_find(chan, ¯o_ds_info, NULL); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "Macro() requires arguments. See \"core show application macro\" for help.\n"); return -1; } do { if (macro_store) { break; } if (!(macro_store = ast_datastore_alloc(¯o_ds_info, NULL))) { ast_log(LOG_WARNING, "Unable to allocate new datastore.\n"); break; } /* Just the existence of this datastore is enough. */ macro_store->inheritance = DATASTORE_INHERIT_FOREVER; ast_channel_datastore_add(chan, macro_store); } while (0); /* does the user want a deeper rabbit hole? */ ast_channel_lock(chan); if ((s = pbx_builtin_getvar_helper(chan, "MACRO_RECURSION"))) { sscanf(s, "%30d", &maxdepth); } /* Count how many levels deep the rabbit hole goes */ if ((s = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH"))) { sscanf(s, "%30d", &depth); } /* Used for detecting whether to return when a Macro is called from another Macro after hangup */ if (strcmp(ast_channel_exten(chan), "h") == 0) pbx_builtin_setvar_helper(chan, "MACRO_IN_HANGUP", "1"); if ((inhangupc = pbx_builtin_getvar_helper(chan, "MACRO_IN_HANGUP"))) { sscanf(inhangupc, "%30d", &inhangup); } ast_channel_unlock(chan); if (depth >= maxdepth) { ast_log(LOG_ERROR, "Macro(): possible infinite loop detected. Returning early.\n"); return 0; } snprintf(depthc, sizeof(depthc), "%d", depth + 1); tmp = ast_strdupa(data); rest = tmp; macro = strsep(&rest, ","); if (ast_strlen_zero(macro)) { ast_log(LOG_WARNING, "Invalid macro name specified\n"); return 0; } snprintf(fullmacro, sizeof(fullmacro), "macro-%s", macro); if (!ast_exists_extension(chan, fullmacro, "s", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { if (!ast_context_find(fullmacro)) ast_log(LOG_WARNING, "No such context '%s' for macro '%s'. Was called by %s@%s\n", fullmacro, macro, ast_channel_exten(chan), ast_channel_context(chan)); else ast_log(LOG_WARNING, "Context '%s' for macro '%s' lacks 's' extension, priority 1\n", fullmacro, macro); return 0; } /* If we are to run the macro exclusively, take the mutex */ if (exclusive) { ast_debug(1, "Locking macrolock for '%s'\n", fullmacro); ast_autoservice_start(chan); if (ast_context_lockmacro(fullmacro)) { ast_log(LOG_WARNING, "Failed to lock macro '%s' as in-use\n", fullmacro); ast_autoservice_stop(chan); return 0; } ast_autoservice_stop(chan); } if (!(tmp_subst = ast_str_create(16))) { return -1; } /* Save old info */ oldpriority = ast_channel_priority(chan); ast_copy_string(oldexten, ast_channel_exten(chan), sizeof(oldexten)); ast_copy_string(oldcontext, ast_channel_context(chan), sizeof(oldcontext)); if (ast_strlen_zero(ast_channel_macrocontext(chan))) { ast_channel_macrocontext_set(chan, ast_channel_context(chan)); ast_channel_macroexten_set(chan, ast_channel_exten(chan)); ast_channel_macropriority_set(chan, ast_channel_priority(chan)); setmacrocontext=1; } argc = 1; /* Save old macro variables */ save_macro_exten = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_EXTEN")); pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", oldexten); save_macro_context = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT")); pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", oldcontext); save_macro_priority = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY")); snprintf(pc, sizeof(pc), "%d", oldpriority); pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", pc); save_macro_offset = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_OFFSET")); pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", NULL); pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); /* Setup environment for new run */ ast_channel_exten_set(chan, "s"); ast_channel_context_set(chan, fullmacro); ast_channel_priority_set(chan, 1); ast_channel_lock(chan); while((cur = strsep(&rest, ",")) && (argc < MAX_ARGS)) { const char *argp; /* Save copy of old arguments if we're overwriting some, otherwise let them pass through to the other macro */ snprintf(varname, sizeof(varname), "ARG%d", argc); if ((argp = pbx_builtin_getvar_helper(chan, varname))) { oldargs[argc] = ast_strdup(argp); } pbx_builtin_setvar_helper(chan, varname, cur); argc++; } ast_channel_unlock(chan); autoloopflag = ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP); ast_set_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP); while (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { struct ast_context *c; struct ast_exten *e; int foundx; runningapp[0] = '\0'; runningdata[0] = '\0'; /* What application will execute? */ if (ast_rdlock_contexts()) { ast_log(LOG_WARNING, "Failed to lock contexts list\n"); } else { for (c = ast_walk_contexts(NULL), e = NULL; c; c = ast_walk_contexts(c)) { if (!strcmp(ast_get_context_name(c), ast_channel_context(chan))) { if (ast_rdlock_context(c)) { ast_log(LOG_WARNING, "Unable to lock context?\n"); } else { e = find_matching_priority(c, ast_channel_exten(chan), ast_channel_priority(chan), S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)); if (e) { /* This will only be undefined for pbx_realtime, which is majorly broken. */ ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp)); ast_copy_string(runningdata, ast_get_extension_app_data(e), sizeof(runningdata)); } ast_unlock_context(c); } break; } } } ast_unlock_contexts(); /* Reset the macro depth, if it was changed in the last iteration */ pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); res = ast_spawn_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL), &foundx, 1); if (res) { /* Something bad happened, or a hangup has been requested. */ if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) || (res == '*') || (res == '#')) { /* Just return result as to the previous application as if it had been dialed */ ast_debug(1, "Oooh, got something to jump out with ('%c')!\n", res); break; } switch(res) { case MACRO_EXIT_RESULT: res = 0; goto out; default: ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan), macro); ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan), macro); goto out; } } ast_debug(1, "Executed application: %s\n", runningapp); if (!strcasecmp(runningapp, "GOSUB")) { gosub_level++; ast_debug(1, "Incrementing gosub_level\n"); } else if (!strcasecmp(runningapp, "GOSUBIF")) { char *cond, *app_arg; char *app2; ast_str_substitute_variables(&tmp_subst, 0, chan, runningdata); app2 = ast_str_buffer(tmp_subst); cond = strsep(&app2, "?"); app_arg = strsep(&app2, ":"); if (pbx_checkcondition(cond)) { if (!ast_strlen_zero(app_arg)) { gosub_level++; ast_debug(1, "Incrementing gosub_level\n"); } } else { if (!ast_strlen_zero(app2)) { gosub_level++; ast_debug(1, "Incrementing gosub_level\n"); } } } else if (!strcasecmp(runningapp, "RETURN")) { gosub_level--; ast_debug(1, "Decrementing gosub_level\n"); } else if (!strcasecmp(runningapp, "STACKPOP")) { gosub_level--; ast_debug(1, "Decrementing gosub_level\n"); } else if (!strncasecmp(runningapp, "EXEC", 4)) { /* Must evaluate args to find actual app */ char *tmp2, *tmp3 = NULL; ast_str_substitute_variables(&tmp_subst, 0, chan, runningdata); tmp2 = ast_str_buffer(tmp_subst); if (!strcasecmp(runningapp, "EXECIF")) { if ((tmp3 = strchr(tmp2, '|'))) { *tmp3++ = '\0'; } if (!pbx_checkcondition(tmp2)) { tmp3 = NULL; } } else { tmp3 = tmp2; } if (tmp3) { ast_debug(1, "Last app: %s\n", tmp3); } if (tmp3 && !strncasecmp(tmp3, "GOSUB", 5)) { gosub_level++; ast_debug(1, "Incrementing gosub_level\n"); } else if (tmp3 && !strncasecmp(tmp3, "RETURN", 6)) { gosub_level--; ast_debug(1, "Decrementing gosub_level\n"); } else if (tmp3 && !strncasecmp(tmp3, "STACKPOP", 8)) { gosub_level--; ast_debug(1, "Decrementing gosub_level\n"); } } if (gosub_level == 0 && strcasecmp(ast_channel_context(chan), fullmacro)) { ast_verb(2, "Channel '%s' jumping out of macro '%s'\n", ast_channel_name(chan), macro); break; } /* don't stop executing extensions when we're in "h" */ if (ast_check_hangup(chan) && !inhangup) { ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", ast_channel_exten(chan), ast_channel_macroexten(chan), ast_channel_priority(chan)); goto out; } ast_channel_priority_set(chan, ast_channel_priority(chan) + 1); } out: /* Don't let the channel change now. */ ast_channel_lock(chan); /* Reset the depth back to what it was when the routine was entered (like if we called Macro recursively) */ snprintf(depthc, sizeof(depthc), "%d", depth); pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); ast_set2_flag(ast_channel_flags(chan), autoloopflag, AST_FLAG_IN_AUTOLOOP); for (x = 1; x < argc; x++) { /* Restore old arguments and delete ours */ snprintf(varname, sizeof(varname), "ARG%d", x); if (oldargs[x]) { pbx_builtin_setvar_helper(chan, varname, oldargs[x]); ast_free(oldargs[x]); } else { pbx_builtin_setvar_helper(chan, varname, NULL); } } /* Restore macro variables */ pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", save_macro_exten); pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", save_macro_context); pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority); if (save_macro_exten) ast_free(save_macro_exten); if (save_macro_context) ast_free(save_macro_context); if (save_macro_priority) ast_free(save_macro_priority); if (setmacrocontext) { ast_channel_macrocontext_set(chan, ""); ast_channel_macroexten_set(chan, ""); ast_channel_macropriority_set(chan, 0); } if (!strcasecmp(ast_channel_context(chan), fullmacro)) { const char *offsets; /* If we're leaving the macro normally, restore original information */ ast_channel_priority_set(chan, oldpriority); ast_channel_context_set(chan, oldcontext); ast_channel_exten_set(chan, oldexten); if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) { /* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue normally if there is any problem */ if (sscanf(offsets, "%30d", &offset) == 1) { if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + offset + 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { ast_channel_priority_set(chan, ast_channel_priority(chan) + offset); } } } } pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset); if (save_macro_offset) ast_free(save_macro_offset); /* Unlock the macro */ if (exclusive) { ast_debug(1, "Unlocking macrolock for '%s'\n", fullmacro); if (ast_context_unlockmacro(fullmacro)) { ast_log(LOG_ERROR, "Failed to unlock macro '%s' - that isn't good\n", fullmacro); res = 0; } } ast_channel_unlock(chan); ast_free(tmp_subst); return res; } static int macro_exec(struct ast_channel *chan, const char *data) { return _macro_exec(chan, data, 0); } static int macroexclusive_exec(struct ast_channel *chan, const char *data) { return _macro_exec(chan, data, 1); } static int macroif_exec(struct ast_channel *chan, const char *data) { char *expr = NULL, *label_a = NULL, *label_b = NULL; int res = 0; expr = ast_strdupa(data); if ((label_a = strchr(expr, '?'))) { *label_a = '\0'; label_a++; if ((label_b = strchr(label_a, ':'))) { *label_b = '\0'; label_b++; } if (pbx_checkcondition(expr)) res = macro_exec(chan, label_a); else if (label_b) res = macro_exec(chan, label_b); } else ast_log(LOG_WARNING, "Invalid Syntax.\n"); return res; } static int macro_exit_exec(struct ast_channel *chan, const char *data) { return MACRO_EXIT_RESULT; } static int unload_module(void) { int res; res = ast_unregister_application(if_app); res |= ast_unregister_application(exit_app); res |= ast_unregister_application(app); res |= ast_unregister_application(exclusive_app); return res; } static int load_module(void) { int res; res = ast_register_application_xml(exit_app, macro_exit_exec); res |= ast_register_application_xml(if_app, macroif_exec); res |= ast_register_application_xml(exclusive_app, macroexclusive_exec); res |= ast_register_application_xml(app, macro_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Extension Macros"); asterisk-11.7.0/apps/app_celgenuserevent.c0000644000175000007640000000442612055222277020524 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2008, Digium, Inc * * 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 Generate User-Defined CEL event * * \author Steve Murphy * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 376659 $") #include "asterisk/module.h" #include "asterisk/app.h" #include "asterisk/channel.h" #include "asterisk/cel.h" /*** DOCUMENTATION Generates a CEL User Defined Event. Extra text to be included with the event. A CEL event will be immediately generated by this channel, with the supplied name for a type. ***/ static char *app = "CELGenUserEvent"; static int celgenuserevent_exec(struct ast_channel *chan, const char *data) { int res = 0; char *parse; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(event); AST_APP_ARG(extra); ); if (ast_strlen_zero(data)) { return 0; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); ast_cel_report_event(chan, AST_CEL_USER_DEFINED, args.event, args.extra, NULL); return res; } static int unload_module(void) { ast_unregister_application(app); return 0; } static int load_module(void) { int res = ast_register_application_xml(app, celgenuserevent_exec); if (res) { return AST_MODULE_LOAD_DECLINE; } else { return AST_MODULE_LOAD_SUCCESS; } } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined CEL event", .load = load_module, .unload = unload_module, ); asterisk-11.7.0/apps/app_disa.c0000644000175000007640000003157611752762546016267 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * * Made only slightly more sane by Mark Spencer * * 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 DISA -- Direct Inward System Access Application * * \author Jim Dixon * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 366051 $") #include #include #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/app.h" #include "asterisk/indications.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/ulaw.h" #include "asterisk/callerid.h" #include "asterisk/stringfields.h" /*** DOCUMENTATION Direct Inward System Access. If you need to present a DISA dialtone without entering a password, simply set passcode to no-password You may specified a filename instead of a passcode, this filename must contain individual passcodes Specifies the dialplan context in which the user-entered extension will be matched. If no context is specified, the DISA application defaults to the disa context. Presumably a normal system will have a special context set up for DISA use with some or a lot of restrictions. Specifies a new (different) callerid to be used for this call. Will cause a stutter-dialtone (indication dialrecall) to be used, if the specified mailbox contains any new messages. The DISA, Direct Inward System Access, application allows someone from outside the telephone switch (PBX) to obtain an internal system dialtone and to place calls from it as if they were placing a call from within the switch. DISA plays a dialtone. The user enters their numeric passcode, followed by the pound sign #. If the passcode is correct, the user is then given system dialtone within context on which a call may be placed. If the user enters an invalid extension and extension i exists in the specified context, it will be used. Be aware that using this may compromise the security of your PBX. The arguments to this application (in extensions.conf) allow either specification of a single global passcode (that everyone uses), or individual passcodes contained in a file (filename). The file that contains the passcodes (if used) allows a complete specification of all of the same arguments available on the command line, with the sole exception of the options. The file may contain blank lines, or comments starting with # or ;. Authenticate VMAuthenticate ***/ static const char app[] = "DISA"; enum { NOANSWER_FLAG = (1 << 0), POUND_TO_END_FLAG = (1 << 1), }; AST_APP_OPTIONS(app_opts, { AST_APP_OPTION('n', NOANSWER_FLAG), AST_APP_OPTION('p', POUND_TO_END_FLAG), }); static void play_dialtone(struct ast_channel *chan, char *mailbox) { struct ast_tone_zone_sound *ts = NULL; if (ast_app_has_voicemail(mailbox, NULL)) { ts = ast_get_indication_tone(ast_channel_zone(chan), "dialrecall"); } else { ts = ast_get_indication_tone(ast_channel_zone(chan), "dial"); } if (ts) { ast_playtones_start(chan, 0, ts->data, 0); ts = ast_tone_zone_sound_unref(ts); } else { ast_tonepair_start(chan, 350, 440, 0, 0); } } static int disa_exec(struct ast_channel *chan, const char *data) { int i = 0, j, k = 0, did_ignore = 0, special_noanswer = 0; int firstdigittimeout = (ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 20000); int digittimeout = (ast_channel_pbx(chan) ? ast_channel_pbx(chan)->dtimeoutms : 10000); struct ast_flags flags; char *tmp, exten[AST_MAX_EXTENSION] = "", acctcode[20]=""; char pwline[256]; char ourcidname[256],ourcidnum[256]; struct ast_frame *f; struct timeval lastdigittime; int res; FILE *fp; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(passcode); AST_APP_ARG(context); AST_APP_ARG(cid); AST_APP_ARG(mailbox); AST_APP_ARG(options); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "DISA requires an argument (passcode/passcode file)\n"); return -1; } ast_debug(1, "Digittimeout: %d\n", digittimeout); ast_debug(1, "Responsetimeout: %d\n", firstdigittimeout); tmp = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, tmp); if (ast_strlen_zero(args.context)) args.context = "disa"; if (ast_strlen_zero(args.mailbox)) args.mailbox = ""; if (!ast_strlen_zero(args.options)) { ast_app_parse_options(app_opts, &flags, NULL, args.options); } else { /* Coverity - This uninit_use should be ignored since this macro initializes the flags */ ast_clear_flag(&flags, AST_FLAGS_ALL); } ast_debug(1, "Mailbox: %s\n",args.mailbox); if (!ast_test_flag(&flags, NOANSWER_FLAG)) { if (ast_channel_state(chan) != AST_STATE_UP) { /* answer */ ast_answer(chan); } } else special_noanswer = 1; ast_debug(1, "Context: %s\n",args.context); if (!strcasecmp(args.passcode, "no-password")) { k |= 1; /* We have the password */ ast_debug(1, "DISA no-password login success\n"); } lastdigittime = ast_tvnow(); play_dialtone(chan, args.mailbox); ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); for (;;) { /* if outa time, give em reorder */ if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > ((k&2) ? digittimeout : firstdigittimeout)) { ast_debug(1,"DISA %s entry timeout on chan %s\n", ((k&1) ? "extension" : "password"),ast_channel_name(chan)); break; } if ((res = ast_waitfor(chan, -1)) < 0) { ast_debug(1, "Waitfor returned %d\n", res); continue; } if (!(f = ast_read(chan))) { ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); return -1; } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) { if (f->data.uint32) ast_channel_hangupcause_set(chan, f->data.uint32); ast_frfree(f); ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); return -1; } /* If the frame coming in is not DTMF, just drop it and continue */ if (f->frametype != AST_FRAME_DTMF) { ast_frfree(f); continue; } j = f->subclass.integer; /* save digit */ ast_frfree(f); if (!i) { k |= 2; /* We have the first digit */ ast_playtones_stop(chan); } lastdigittime = ast_tvnow(); /* got a DTMF tone */ if (i < AST_MAX_EXTENSION) { /* if still valid number of digits */ if (!(k&1)) { /* if in password state */ if (j == '#') { /* end of password */ /* see if this is an integer */ if (sscanf(args.passcode,"%30d",&j) < 1) { /* nope, it must be a filename */ fp = fopen(args.passcode,"r"); if (!fp) { ast_log(LOG_WARNING,"DISA password file %s not found on chan %s\n",args.passcode,ast_channel_name(chan)); ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); return -1; } pwline[0] = 0; while(fgets(pwline,sizeof(pwline) - 1,fp)) { if (!pwline[0]) continue; if (pwline[strlen(pwline) - 1] == '\n') pwline[strlen(pwline) - 1] = 0; if (!pwline[0]) continue; /* skip comments */ if (pwline[0] == '#') continue; if (pwline[0] == ';') continue; AST_STANDARD_APP_ARGS(args, pwline); ast_debug(1, "Mailbox: %s\n",args.mailbox); /* password must be in valid format (numeric) */ if (sscanf(args.passcode,"%30d", &j) < 1) continue; /* if we got it */ if (!strcmp(exten,args.passcode)) { if (ast_strlen_zero(args.context)) args.context = "disa"; if (ast_strlen_zero(args.mailbox)) args.mailbox = ""; break; } } fclose(fp); } /* compare the two */ if (strcmp(exten,args.passcode)) { ast_log(LOG_WARNING,"DISA on chan %s got bad password %s\n",ast_channel_name(chan),exten); goto reorder; } /* password good, set to dial state */ ast_debug(1,"DISA on chan %s password is good\n",ast_channel_name(chan)); play_dialtone(chan, args.mailbox); k|=1; /* In number mode */ i = 0; /* re-set buffer pointer */ exten[sizeof(acctcode)] = 0; ast_copy_string(acctcode, exten, sizeof(acctcode)); exten[0] = 0; ast_debug(1,"Successful DISA log-in on chan %s\n", ast_channel_name(chan)); continue; } } else { if (j == '#') { /* end of extension .. maybe */ if (i == 0 && (ast_matchmore_extension(chan, args.context, "#", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)) || ast_exists_extension(chan, args.context, "#", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) ) { /* Let the # be the part of, or the entire extension */ } else { break; } } } exten[i++] = j; /* save digit */ exten[i] = 0; if (!(k&1)) continue; /* if getting password, continue doing it */ /* if this exists */ /* user wants end of number, remove # */ if (ast_test_flag(&flags, POUND_TO_END_FLAG) && j == '#') { exten[--i] = 0; break; } if (ast_ignore_pattern(args.context, exten)) { play_dialtone(chan, ""); did_ignore = 1; } else if (did_ignore) { ast_playtones_stop(chan); did_ignore = 0; } /* if can do some more, do it */ if (!ast_matchmore_extension(chan, args.context, exten, 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { break; } } } ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); if (k == 3) { int recheck = 0; struct ast_flags cdr_flags = { AST_CDR_FLAG_POSTED }; if (!ast_exists_extension(chan, args.context, exten, 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { pbx_builtin_setvar_helper(chan, "INVALID_EXTEN", exten); exten[0] = 'i'; exten[1] = '\0'; recheck = 1; } if (!recheck || ast_exists_extension(chan, args.context, exten, 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { ast_playtones_stop(chan); /* We're authenticated and have a target extension */ if (!ast_strlen_zero(args.cid)) { ast_callerid_split(args.cid, ourcidname, sizeof(ourcidname), ourcidnum, sizeof(ourcidnum)); ast_set_callerid(chan, ourcidnum, ourcidname, ourcidnum); } if (!ast_strlen_zero(acctcode)) ast_channel_accountcode_set(chan, acctcode); if (special_noanswer) cdr_flags.flags = 0; ast_cdr_reset(ast_channel_cdr(chan), &cdr_flags); ast_explicit_goto(chan, args.context, exten, 1); return 0; } } /* Received invalid, but no "i" extension exists in the given context */ reorder: /* Play congestion for a bit */ ast_indicate(chan, AST_CONTROL_CONGESTION); ast_safe_sleep(chan, 10*1000); ast_playtones_stop(chan); return -1; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, disa_exec) ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "DISA (Direct Inward System Access) Application"); asterisk-11.7.0/apps/app_talkdetect.c0000644000175000007640000001704611727707762017470 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Playback a file with audio detect * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 358907 $") #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/utils.h" #include "asterisk/dsp.h" #include "asterisk/app.h" /*** DOCUMENTATION Background a file with talk detect. If not specified, defaults to 1000. If not specified, defaults to 100. If not specified, defaults to infinity. If not specified, defaults to infinity. Plays back filename, waiting for interruption from a given digit (the digit must start the beginning of a valid extension, or it will be ignored). During the playback of the file, audio is monitored in the receive direction, and if a period of non-silence which is greater than min ms yet less than max ms is followed by silence for at least sil ms, which occurs during the first analysistime ms, then the audio playback is aborted and processing jumps to the talk extension, if available. ***/ static char *app = "BackgroundDetect"; static int background_detect_exec(struct ast_channel *chan, const char *data) { int res = 0; char *tmp; struct ast_frame *fr; int notsilent = 0; struct timeval start = { 0, 0 }; struct timeval detection_start = { 0, 0 }; int sil = 1000; int min = 100; int max = -1; int analysistime = -1; int continue_analysis = 1; int x; struct ast_format origrformat; struct ast_dsp *dsp = NULL; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(filename); AST_APP_ARG(silence); AST_APP_ARG(min); AST_APP_ARG(max); AST_APP_ARG(analysistime); ); ast_format_clear(&origrformat); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "BackgroundDetect requires an argument (filename)\n"); return -1; } tmp = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, tmp); if (!ast_strlen_zero(args.silence) && (sscanf(args.silence, "%30d", &x) == 1) && (x > 0)) { sil = x; } if (!ast_strlen_zero(args.min) && (sscanf(args.min, "%30d", &x) == 1) && (x > 0)) { min = x; } if (!ast_strlen_zero(args.max) && (sscanf(args.max, "%30d", &x) == 1) && (x > 0)) { max = x; } if (!ast_strlen_zero(args.analysistime) && (sscanf(args.analysistime, "%30d", &x) == 1) && (x > 0)) { analysistime = x; } ast_debug(1, "Preparing detect of '%s', sil=%d, min=%d, max=%d, analysistime=%d\n", args.filename, sil, min, max, analysistime); do { if (ast_channel_state(chan) != AST_STATE_UP) { if ((res = ast_answer(chan))) { break; } } ast_format_copy(&origrformat, ast_channel_readformat(chan)); if ((ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR))) { ast_log(LOG_WARNING, "Unable to set read format to linear!\n"); res = -1; break; } if (!(dsp = ast_dsp_new())) { ast_log(LOG_WARNING, "Unable to allocate DSP!\n"); res = -1; break; } ast_stopstream(chan); if (ast_streamfile(chan, tmp, ast_channel_language(chan))) { ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", ast_channel_name(chan), (char *)data); break; } detection_start = ast_tvnow(); while (ast_channel_stream(chan)) { res = ast_sched_wait(ast_channel_sched(chan)); if ((res < 0) && !ast_channel_timingfunc(chan)) { res = 0; break; } if (res < 0) { res = 1000; } res = ast_waitfor(chan, res); if (res < 0) { ast_log(LOG_WARNING, "Waitfor failed on %s\n", ast_channel_name(chan)); break; } else if (res > 0) { fr = ast_read(chan); if (continue_analysis && analysistime >= 0) { /* If we have a limit for the time to analyze voice * frames and the time has not expired */ if (ast_tvdiff_ms(ast_tvnow(), detection_start) >= analysistime) { continue_analysis = 0; ast_verb(3, "BackgroundDetect: Talk analysis time complete on %s.\n", ast_channel_name(chan)); } } if (!fr) { res = -1; break; } else if (fr->frametype == AST_FRAME_DTMF) { char t[2]; t[0] = fr->subclass.integer; t[1] = '\0'; if (ast_canmatch_extension(chan, ast_channel_context(chan), t, 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { /* They entered a valid extension, or might be anyhow */ res = fr->subclass.integer; ast_frfree(fr); break; } } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.format.id == AST_FORMAT_SLINEAR) && continue_analysis) { int totalsilence; int ms; res = ast_dsp_silence(dsp, fr, &totalsilence); if (res && (totalsilence > sil)) { /* We've been quiet a little while */ if (notsilent) { /* We had heard some talking */ ms = ast_tvdiff_ms(ast_tvnow(), start); ms -= sil; if (ms < 0) ms = 0; if ((ms > min) && ((max < 0) || (ms < max))) { char ms_str[12]; ast_debug(1, "Found qualified token of %d ms\n", ms); /* Save detected talk time (in milliseconds) */ snprintf(ms_str, sizeof(ms_str), "%d", ms); pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ms_str); ast_goto_if_exists(chan, ast_channel_context(chan), "talk", 1); res = 0; ast_frfree(fr); break; } else { ast_debug(1, "Found unqualified token of %d ms\n", ms); } notsilent = 0; } } else { if (!notsilent) { /* Heard some audio, mark the begining of the token */ start = ast_tvnow(); ast_debug(1, "Start of voice token!\n"); notsilent = 1; } } } ast_frfree(fr); } ast_sched_runq(ast_channel_sched(chan)); } ast_stopstream(chan); } while (0); if (res > -1) { if (origrformat.id && ast_set_read_format(chan, &origrformat)) { ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n", ast_channel_name(chan), ast_getformatname(&origrformat)); } } if (dsp) { ast_dsp_free(dsp); } return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, background_detect_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Playback with Talk Detection"); asterisk-11.7.0/apps/app_image.c0000644000175000007640000000515011607650606016406 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 App to transmit an image * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/image.h" static char *app = "SendImage"; /*** DOCUMENTATION Sends an image file. Path of the filename (image) to send. Send an image file on a channel supporting it. Result of transmission will be stored in SENDIMAGESTATUS Transmission succeeded. Transmission failed. Image transmission not supported by channel. SendText SendURL ***/ static int sendimage_exec(struct ast_channel *chan, const char *data) { if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n"); return -1; } if (!ast_supports_images(chan)) { /* Does not support transport */ pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "UNSUPPORTED"); return 0; } if (!ast_send_image(chan, data)) { pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "SUCCESS"); } else { pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "FAILURE"); } return 0; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, sendimage_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Image Transmission Application"); asterisk-11.7.0/apps/app_jack.c0000644000175000007640000006554012046530216016235 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2007 - 2008, Russell Bryant * * Russell Bryant * * 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 Jack Application * * \author Russell Bryant * * This is an application to connect an Asterisk channel to an input * and output jack port so that the audio can be processed through * another application, or to play audio from another application. * * \extref http://www.jackaudio.org/ * * \note To install libresample, check it out of the following repository: * $ svn co http://svn.digium.com/svn/thirdparty/libresample/trunk * * \ingroup applications */ /*** MODULEINFO jack resample extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 376014 $") #include #include #include #include #include "asterisk/module.h" #include "asterisk/channel.h" #include "asterisk/strings.h" #include "asterisk/lock.h" #include "asterisk/app.h" #include "asterisk/pbx.h" #include "asterisk/audiohook.h" #define RESAMPLE_QUALITY 1 #define RINGBUFFER_SIZE 16384 /*! \brief Common options between the Jack() app and JACK_HOOK() function */ #define COMMON_OPTIONS \ " s() - Connect to the specified jack server name.\n" \ " i() - Connect the output port that gets created to the specified\n" \ " jack input port.\n" \ " o() - Connect the input port that gets created to the specified\n" \ " jack output port.\n" \ " n - Do not automatically start the JACK server if it is not already\n" \ " running.\n" \ " c() - By default, Asterisk will use the channel name for the jack client\n" \ " name. Use this option to specify a custom client name.\n" /*** DOCUMENTATION Jack Audio Connection Kit When executing this application, two jack ports will be created; one input and one output. Other applications can be hooked up to these ports to access audio coming from, or being send to the channel. ***/ static const char jack_app[] = "JACK"; struct jack_data { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(server_name); AST_STRING_FIELD(client_name); AST_STRING_FIELD(connect_input_port); AST_STRING_FIELD(connect_output_port); ); jack_client_t *client; jack_port_t *input_port; jack_port_t *output_port; jack_ringbuffer_t *input_rb; jack_ringbuffer_t *output_rb; void *output_resampler; double output_resample_factor; void *input_resampler; double input_resample_factor; unsigned int stop:1; unsigned int has_audiohook:1; unsigned int no_start_server:1; /*! Only used with JACK_HOOK */ struct ast_audiohook audiohook; }; static const struct { jack_status_t status; const char *str; } jack_status_table[] = { { JackFailure, "Failure" }, { JackInvalidOption, "Invalid Option" }, { JackNameNotUnique, "Name Not Unique" }, { JackServerStarted, "Server Started" }, { JackServerFailed, "Server Failed" }, { JackServerError, "Server Error" }, { JackNoSuchClient, "No Such Client" }, { JackLoadFailure, "Load Failure" }, { JackInitFailure, "Init Failure" }, { JackShmFailure, "Shared Memory Access Failure" }, { JackVersionError, "Version Mismatch" }, }; static const char *jack_status_to_str(jack_status_t status) { int i; for (i = 0; i < ARRAY_LEN(jack_status_table); i++) { if (jack_status_table[i].status == status) return jack_status_table[i].str; } return "Unknown Error"; } static void log_jack_status(const char *prefix, jack_status_t status) { struct ast_str *str = ast_str_alloca(512); int i, first = 0; for (i = 0; i < (sizeof(status) * 8); i++) { if (!(status & (1 << i))) continue; if (!first) { ast_str_set(&str, 0, "%s", jack_status_to_str((1 << i))); first = 1; } else ast_str_append(&str, 0, ", %s", jack_status_to_str((1 << i))); } ast_log(LOG_NOTICE, "%s: %s\n", prefix, ast_str_buffer(str)); } static int alloc_resampler(struct jack_data *jack_data, int input) { double from_srate, to_srate, jack_srate; void **resampler; double *resample_factor; if (input && jack_data->input_resampler) return 0; if (!input && jack_data->output_resampler) return 0; jack_srate = jack_get_sample_rate(jack_data->client); /* XXX Hard coded 8 kHz */ to_srate = input ? 8000.0 : jack_srate; from_srate = input ? jack_srate : 8000.0; resample_factor = input ? &jack_data->input_resample_factor : &jack_data->output_resample_factor; if (from_srate == to_srate) { /* Awesome! The jack sample rate is the same as ours. * Resampling isn't needed. */ *resample_factor = 1.0; return 0; } *resample_factor = to_srate / from_srate; resampler = input ? &jack_data->input_resampler : &jack_data->output_resampler; if (!(*resampler = resample_open(RESAMPLE_QUALITY, *resample_factor, *resample_factor))) { ast_log(LOG_ERROR, "Failed to open %s resampler\n", input ? "input" : "output"); return -1; } return 0; } /*! * \brief Handle jack input port * * Read nframes number of samples from the input buffer, resample it * if necessary, and write it into the appropriate ringbuffer. */ static void handle_input(void *buf, jack_nframes_t nframes, struct jack_data *jack_data) { short s_buf[nframes]; float *in_buf = buf; size_t res; int i; size_t write_len = sizeof(s_buf); if (jack_data->input_resampler) { int total_in_buf_used = 0; int total_out_buf_used = 0; float f_buf[nframes + 1]; memset(f_buf, 0, sizeof(f_buf)); while (total_in_buf_used < nframes) { int in_buf_used; int out_buf_used; out_buf_used = resample_process(jack_data->input_resampler, jack_data->input_resample_factor, &in_buf[total_in_buf_used], nframes - total_in_buf_used, 0, &in_buf_used, &f_buf[total_out_buf_used], ARRAY_LEN(f_buf) - total_out_buf_used); if (out_buf_used < 0) break; total_out_buf_used += out_buf_used; total_in_buf_used += in_buf_used; if (total_out_buf_used == ARRAY_LEN(f_buf)) { ast_log(LOG_ERROR, "Output buffer filled ... need to increase its size, " "nframes '%d', total_out_buf_used '%d'\n", nframes, total_out_buf_used); break; } } for (i = 0; i < total_out_buf_used; i++) s_buf[i] = f_buf[i] * (SHRT_MAX / 1.0); write_len = total_out_buf_used * sizeof(int16_t); } else { /* No resampling needed */ for (i = 0; i < nframes; i++) s_buf[i] = in_buf[i] * (SHRT_MAX / 1.0); } res = jack_ringbuffer_write(jack_data->input_rb, (const char *) s_buf, write_len); if (res != write_len) { ast_debug(2, "Tried to write %d bytes to the ringbuffer, but only wrote %d\n", (int) sizeof(s_buf), (int) res); } } /*! * \brief Handle jack output port * * Read nframes number of samples from the ringbuffer and write it out to the * output port buffer. */ static void handle_output(void *buf, jack_nframes_t nframes, struct jack_data *jack_data) { size_t res, len; len = nframes * sizeof(float); res = jack_ringbuffer_read(jack_data->output_rb, buf, len); if (len != res) { ast_debug(2, "Wanted %d bytes to send to the output port, " "but only got %d\n", (int) len, (int) res); } } static int jack_process(jack_nframes_t nframes, void *arg) { struct jack_data *jack_data = arg; void *input_port_buf, *output_port_buf; if (!jack_data->input_resample_factor) alloc_resampler(jack_data, 1); input_port_buf = jack_port_get_buffer(jack_data->input_port, nframes); handle_input(input_port_buf, nframes, jack_data); output_port_buf = jack_port_get_buffer(jack_data->output_port, nframes); handle_output(output_port_buf, nframes, jack_data); return 0; } static void jack_shutdown(void *arg) { struct jack_data *jack_data = arg; jack_data->stop = 1; } static struct jack_data *destroy_jack_data(struct jack_data *jack_data) { if (jack_data->input_port) { jack_port_unregister(jack_data->client, jack_data->input_port); jack_data->input_port = NULL; } if (jack_data->output_port) { jack_port_unregister(jack_data->client, jack_data->output_port); jack_data->output_port = NULL; } if (jack_data->client) { jack_client_close(jack_data->client); jack_data->client = NULL; } if (jack_data->input_rb) { jack_ringbuffer_free(jack_data->input_rb); jack_data->input_rb = NULL; } if (jack_data->output_rb) { jack_ringbuffer_free(jack_data->output_rb); jack_data->output_rb = NULL; } if (jack_data->output_resampler) { resample_close(jack_data->output_resampler); jack_data->output_resampler = NULL; } if (jack_data->input_resampler) { resample_close(jack_data->input_resampler); jack_data->input_resampler = NULL; } if (jack_data->has_audiohook) ast_audiohook_destroy(&jack_data->audiohook); ast_string_field_free_memory(jack_data); ast_free(jack_data); return NULL; } static int init_jack_data(struct ast_channel *chan, struct jack_data *jack_data) { const char *client_name; jack_status_t status = 0; jack_options_t jack_options = JackNullOption; if (!ast_strlen_zero(jack_data->client_name)) { client_name = jack_data->client_name; } else { ast_channel_lock(chan); client_name = ast_strdupa(ast_channel_name(chan)); ast_channel_unlock(chan); } if (!(jack_data->output_rb = jack_ringbuffer_create(RINGBUFFER_SIZE))) return -1; if (!(jack_data->input_rb = jack_ringbuffer_create(RINGBUFFER_SIZE))) return -1; if (jack_data->no_start_server) jack_options |= JackNoStartServer; if (!ast_strlen_zero(jack_data->server_name)) { jack_options |= JackServerName; jack_data->client = jack_client_open(client_name, jack_options, &status, jack_data->server_name); } else { jack_data->client = jack_client_open(client_name, jack_options, &status); } if (status) log_jack_status("Client Open Status", status); if (!jack_data->client) return -1; jack_data->input_port = jack_port_register(jack_data->client, "input", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0); if (!jack_data->input_port) { ast_log(LOG_ERROR, "Failed to create input port for jack port\n"); return -1; } jack_data->output_port = jack_port_register(jack_data->client, "output", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0); if (!jack_data->output_port) { ast_log(LOG_ERROR, "Failed to create output port for jack port\n"); return -1; } if (jack_set_process_callback(jack_data->client, jack_process, jack_data)) { ast_log(LOG_ERROR, "Failed to register process callback with jack client\n"); return -1; } jack_on_shutdown(jack_data->client, jack_shutdown, jack_data); if (jack_activate(jack_data->client)) { ast_log(LOG_ERROR, "Unable to activate jack client\n"); return -1; } while (!ast_strlen_zero(jack_data->connect_input_port)) { const char **ports; int i; ports = jack_get_ports(jack_data->client, jack_data->connect_input_port, NULL, JackPortIsInput); if (!ports) { ast_log(LOG_ERROR, "No input port matching '%s' was found\n", jack_data->connect_input_port); break; } for (i = 0; ports[i]; i++) { ast_debug(1, "Found port '%s' that matched specified input port '%s'\n", ports[i], jack_data->connect_input_port); } if (jack_connect(jack_data->client, jack_port_name(jack_data->output_port), ports[0])) { ast_log(LOG_ERROR, "Failed to connect '%s' to '%s'\n", ports[0], jack_port_name(jack_data->output_port)); } else { ast_debug(1, "Connected '%s' to '%s'\n", ports[0], jack_port_name(jack_data->output_port)); } free((void *) ports); break; } while (!ast_strlen_zero(jack_data->connect_output_port)) { const char **ports; int i; ports = jack_get_ports(jack_data->client, jack_data->connect_output_port, NULL, JackPortIsOutput); if (!ports) { ast_log(LOG_ERROR, "No output port matching '%s' was found\n", jack_data->connect_output_port); break; } for (i = 0; ports[i]; i++) { ast_debug(1, "Found port '%s' that matched specified output port '%s'\n", ports[i], jack_data->connect_output_port); } if (jack_connect(jack_data->client, ports[0], jack_port_name(jack_data->input_port))) { ast_log(LOG_ERROR, "Failed to connect '%s' to '%s'\n", ports[0], jack_port_name(jack_data->input_port)); } else { ast_debug(1, "Connected '%s' to '%s'\n", ports[0], jack_port_name(jack_data->input_port)); } free((void *) ports); break; } return 0; } static int queue_voice_frame(struct jack_data *jack_data, struct ast_frame *f) { float f_buf[f->samples * 8]; size_t f_buf_used = 0; int i; int16_t *s_buf = f->data.ptr; size_t res; memset(f_buf, 0, sizeof(f_buf)); if (!jack_data->output_resample_factor) alloc_resampler(jack_data, 0); if (jack_data->output_resampler) { float in_buf[f->samples]; int total_in_buf_used = 0; int total_out_buf_used = 0; memset(in_buf, 0, sizeof(in_buf)); for (i = 0; i < f->samples; i++) in_buf[i] = s_buf[i] * (1.0 / SHRT_MAX); while (total_in_buf_used < ARRAY_LEN(in_buf)) { int in_buf_used; int out_buf_used; out_buf_used = resample_process(jack_data->output_resampler, jack_data->output_resample_factor, &in_buf[total_in_buf_used], ARRAY_LEN(in_buf) - total_in_buf_used, 0, &in_buf_used, &f_buf[total_out_buf_used], ARRAY_LEN(f_buf) - total_out_buf_used); if (out_buf_used < 0) break; total_out_buf_used += out_buf_used; total_in_buf_used += in_buf_used; if (total_out_buf_used == ARRAY_LEN(f_buf)) { ast_log(LOG_ERROR, "Output buffer filled ... need to increase its size\n"); break; } } f_buf_used = total_out_buf_used; if (f_buf_used > ARRAY_LEN(f_buf)) f_buf_used = ARRAY_LEN(f_buf); } else { /* No resampling needed */ for (i = 0; i < f->samples; i++) f_buf[i] = s_buf[i] * (1.0 / SHRT_MAX); f_buf_used = f->samples; } res = jack_ringbuffer_write(jack_data->output_rb, (const char *) f_buf, f_buf_used * sizeof(float)); if (res != (f_buf_used * sizeof(float))) { ast_debug(2, "Tried to write %d bytes to the ringbuffer, but only wrote %d\n", (int) (f_buf_used * sizeof(float)), (int) res); } return 0; } /*! * \brief handle jack audio * * \param[in] chan The Asterisk channel to write the frames to if no output frame * is provided. * \param[in] jack_data This is the jack_data struct that contains the input * ringbuffer that audio will be read from. * \param[out] out_frame If this argument is non-NULL, then assuming there is * enough data avilable in the ringbuffer, the audio in this frame * will get replaced with audio from the input buffer. If there is * not enough data available to read at this time, then the frame * data gets zeroed out. * * Read data from the input ringbuffer, which is the properly resampled audio * that was read from the jack input port. Write it to the channel in 20 ms frames, * or fill up an output frame instead if one is provided. * * \return Nothing. */ static void handle_jack_audio(struct ast_channel *chan, struct jack_data *jack_data, struct ast_frame *out_frame) { short buf[160]; struct ast_frame f = { .frametype = AST_FRAME_VOICE, .src = "JACK", .data.ptr = buf, .datalen = sizeof(buf), .samples = ARRAY_LEN(buf), }; ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR, 0); for (;;) { size_t res, read_len; char *read_buf; read_len = out_frame ? out_frame->datalen : sizeof(buf); read_buf = out_frame ? out_frame->data.ptr : buf; res = jack_ringbuffer_read_space(jack_data->input_rb); if (res < read_len) { /* Not enough data ready for another frame, move on ... */ if (out_frame) { ast_debug(1, "Sending an empty frame for the JACK_HOOK\n"); memset(out_frame->data.ptr, 0, out_frame->datalen); } break; } res = jack_ringbuffer_read(jack_data->input_rb, (char *) read_buf, read_len); if (res < read_len) { ast_log(LOG_ERROR, "Error reading from ringbuffer, even though it said there was enough data\n"); break; } if (out_frame) { /* If an output frame was provided, then we just want to fill up the * buffer in that frame and return. */ break; } ast_write(chan, &f); } } enum { OPT_SERVER_NAME = (1 << 0), OPT_INPUT_PORT = (1 << 1), OPT_OUTPUT_PORT = (1 << 2), OPT_NOSTART_SERVER = (1 << 3), OPT_CLIENT_NAME = (1 << 4), }; enum { OPT_ARG_SERVER_NAME, OPT_ARG_INPUT_PORT, OPT_ARG_OUTPUT_PORT, OPT_ARG_CLIENT_NAME, /* Must be the last element */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(jack_exec_options, BEGIN_OPTIONS AST_APP_OPTION_ARG('s', OPT_SERVER_NAME, OPT_ARG_SERVER_NAME), AST_APP_OPTION_ARG('i', OPT_INPUT_PORT, OPT_ARG_INPUT_PORT), AST_APP_OPTION_ARG('o', OPT_OUTPUT_PORT, OPT_ARG_OUTPUT_PORT), AST_APP_OPTION('n', OPT_NOSTART_SERVER), AST_APP_OPTION_ARG('c', OPT_CLIENT_NAME, OPT_ARG_CLIENT_NAME), END_OPTIONS ); static struct jack_data *jack_data_alloc(void) { struct jack_data *jack_data; if (!(jack_data = ast_calloc_with_stringfields(1, struct jack_data, 32))) { return NULL; } return jack_data; } /*! * \note This must be done before calling init_jack_data(). */ static int handle_options(struct jack_data *jack_data, const char *__options_str) { struct ast_flags options = { 0, }; char *option_args[OPT_ARG_ARRAY_SIZE]; char *options_str; options_str = ast_strdupa(__options_str); ast_app_parse_options(jack_exec_options, &options, option_args, options_str); if (ast_test_flag(&options, OPT_SERVER_NAME)) { if (!ast_strlen_zero(option_args[OPT_ARG_SERVER_NAME])) ast_string_field_set(jack_data, server_name, option_args[OPT_ARG_SERVER_NAME]); else { ast_log(LOG_ERROR, "A server name must be provided with the s() option\n"); return -1; } } if (ast_test_flag(&options, OPT_CLIENT_NAME)) { if (!ast_strlen_zero(option_args[OPT_ARG_CLIENT_NAME])) ast_string_field_set(jack_data, client_name, option_args[OPT_ARG_CLIENT_NAME]); else { ast_log(LOG_ERROR, "A client name must be provided with the c() option\n"); return -1; } } if (ast_test_flag(&options, OPT_INPUT_PORT)) { if (!ast_strlen_zero(option_args[OPT_ARG_INPUT_PORT])) ast_string_field_set(jack_data, connect_input_port, option_args[OPT_ARG_INPUT_PORT]); else { ast_log(LOG_ERROR, "A name must be provided with the i() option\n"); return -1; } } if (ast_test_flag(&options, OPT_OUTPUT_PORT)) { if (!ast_strlen_zero(option_args[OPT_ARG_OUTPUT_PORT])) ast_string_field_set(jack_data, connect_output_port, option_args[OPT_ARG_OUTPUT_PORT]); else { ast_log(LOG_ERROR, "A name must be provided with the o() option\n"); return -1; } } jack_data->no_start_server = ast_test_flag(&options, OPT_NOSTART_SERVER) ? 1 : 0; return 0; } static int jack_exec(struct ast_channel *chan, const char *data) { struct jack_data *jack_data; if (!(jack_data = jack_data_alloc())) return -1; if (!ast_strlen_zero(data) && handle_options(jack_data, data)) { destroy_jack_data(jack_data); return -1; } if (init_jack_data(chan, jack_data)) { destroy_jack_data(jack_data); return -1; } if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) { destroy_jack_data(jack_data); return -1; } if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) { destroy_jack_data(jack_data); return -1; } while (!jack_data->stop) { struct ast_frame *f; if (ast_waitfor(chan, -1) < 0) { break; } f = ast_read(chan); if (!f) { jack_data->stop = 1; continue; } switch (f->frametype) { case AST_FRAME_CONTROL: if (f->subclass.integer == AST_CONTROL_HANGUP) jack_data->stop = 1; break; case AST_FRAME_VOICE: queue_voice_frame(jack_data, f); default: break; } ast_frfree(f); handle_jack_audio(chan, jack_data, NULL); } jack_data = destroy_jack_data(jack_data); return 0; } static void jack_hook_ds_destroy(void *data) { struct jack_data *jack_data = data; destroy_jack_data(jack_data); } static const struct ast_datastore_info jack_hook_ds_info = { .type = "JACK_HOOK", .destroy = jack_hook_ds_destroy, }; static int jack_hook_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction) { struct ast_datastore *datastore; struct jack_data *jack_data; if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE) return 0; if (direction != AST_AUDIOHOOK_DIRECTION_READ) return 0; if (frame->frametype != AST_FRAME_VOICE) return 0; if (frame->subclass.format.id != AST_FORMAT_SLINEAR) { ast_log(LOG_WARNING, "Expected frame in SLINEAR for the audiohook, but got format %s\n", ast_getformatname(&frame->subclass.format)); return 0; } ast_channel_lock(chan); if (!(datastore = ast_channel_datastore_find(chan, &jack_hook_ds_info, NULL))) { ast_log(LOG_ERROR, "JACK_HOOK datastore not found for '%s'\n", ast_channel_name(chan)); ast_channel_unlock(chan); return -1; } jack_data = datastore->data; queue_voice_frame(jack_data, frame); handle_jack_audio(chan, jack_data, frame); ast_channel_unlock(chan); return 0; } static int enable_jack_hook(struct ast_channel *chan, char *data) { struct ast_datastore *datastore; struct jack_data *jack_data = NULL; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(mode); AST_APP_ARG(options); ); AST_STANDARD_APP_ARGS(args, data); ast_channel_lock(chan); if ((datastore = ast_channel_datastore_find(chan, &jack_hook_ds_info, NULL))) { ast_log(LOG_ERROR, "JACK_HOOK already enabled for '%s'\n", ast_channel_name(chan)); goto return_error; } if (ast_strlen_zero(args.mode) || strcasecmp(args.mode, "manipulate")) { ast_log(LOG_ERROR, "'%s' is not a supported mode. Only manipulate is supported.\n", S_OR(args.mode, "")); goto return_error; } if (!(jack_data = jack_data_alloc())) goto return_error; if (!ast_strlen_zero(args.options) && handle_options(jack_data, args.options)) goto return_error; if (init_jack_data(chan, jack_data)) goto return_error; if (!(datastore = ast_datastore_alloc(&jack_hook_ds_info, NULL))) goto return_error; jack_data->has_audiohook = 1; ast_audiohook_init(&jack_data->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "JACK_HOOK", 0); jack_data->audiohook.manipulate_callback = jack_hook_callback; datastore->data = jack_data; if (ast_audiohook_attach(chan, &jack_data->audiohook)) goto return_error; if (ast_channel_datastore_add(chan, datastore)) goto return_error; ast_channel_unlock(chan); return 0; return_error: ast_channel_unlock(chan); if (jack_data) { destroy_jack_data(jack_data); } if (datastore) { datastore->data = NULL; ast_datastore_free(datastore); } return -1; } static int disable_jack_hook(struct ast_channel *chan) { struct ast_datastore *datastore; struct jack_data *jack_data; ast_channel_lock(chan); if (!(datastore = ast_channel_datastore_find(chan, &jack_hook_ds_info, NULL))) { ast_channel_unlock(chan); ast_log(LOG_WARNING, "No JACK_HOOK found to disable\n"); return -1; } ast_channel_datastore_remove(chan, datastore); jack_data = datastore->data; ast_audiohook_detach(&jack_data->audiohook); /* Keep the channel locked while we destroy the datastore, so that we can * ensure that all of the jack stuff is stopped just in case another frame * tries to come through the audiohook callback. */ ast_datastore_free(datastore); ast_channel_unlock(chan); return 0; } static int jack_hook_write(struct ast_channel *chan, const char *cmd, char *data, const char *value) { int res; if (!strcasecmp(value, "on")) res = enable_jack_hook(chan, data); else if (!strcasecmp(value, "off")) res = disable_jack_hook(chan); else { ast_log(LOG_ERROR, "'%s' is not a valid value for JACK_HOOK()\n", value); res = -1; } return res; } static struct ast_custom_function jack_hook_function = { .name = "JACK_HOOK", .synopsis = "Enable a jack hook on a channel", .syntax = "JACK_HOOK(,[options])", .desc = " The JACK_HOOK allows turning on or off jack connectivity to this channel.\n" "When the JACK_HOOK is turned on, jack ports will get created that allow\n" "access to the audio stream for this channel. The mode specifies which mode\n" "this hook should run in. A mode must be specified when turning the JACK_HOOK.\n" "on. However, all arguments are optional when turning it off.\n" "\n" " Valid modes are:\n" #if 0 /* XXX TODO */ " spy - Create a read-only audio hook. Only an output jack port will\n" " get created.\n" " whisper - Create a write-only audio hook. Only an input jack port will\n" " get created.\n" #endif " manipulate - Create a read/write audio hook. Both an input and an output\n" " jack port will get created. Audio from the channel will be\n" " sent out the output port and will be replaced by the audio\n" " coming in on the input port as it gets passed on.\n" "\n" " Valid options are:\n" COMMON_OPTIONS "\n" " Examples:\n" " To turn on the JACK_HOOK,\n" " Set(JACK_HOOK(manipulate,i(pure_data_0:input0)o(pure_data_0:output0))=on)\n" " To turn off the JACK_HOOK,\n" " Set(JACK_HOOK()=off)\n" "", .write = jack_hook_write, }; static int unload_module(void) { int res; res = ast_unregister_application(jack_app); res |= ast_custom_function_unregister(&jack_hook_function); return res; } static int load_module(void) { if (ast_register_application_xml(jack_app, jack_exec)) { return AST_MODULE_LOAD_DECLINE; } if (ast_custom_function_register(&jack_hook_function)) { ast_unregister_application(jack_app); return AST_MODULE_LOAD_DECLINE; } return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "JACK Interface"); asterisk-11.7.0/apps/app_channelredirect.c0000644000175000007640000000637511727707762020501 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2006, Sergey Basmanov * * 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 ChannelRedirect application * * \author Sergey Basmanov * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 358907 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/app.h" #include "asterisk/features.h" /*** DOCUMENTATION Redirects given channel to a dialplan target Sends the specified channel to the specified extension priority This application sets the following channel variables upon completion Are set to the result of the redirection ***/ static const char app[] = "ChannelRedirect"; static int asyncgoto_exec(struct ast_channel *chan, const char *data) { int res = -1; char *info; struct ast_channel *chan2 = NULL; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(channel); AST_APP_ARG(label); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app); return -1; } info = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, info); if (ast_strlen_zero(args.channel) || ast_strlen_zero(args.label)) { ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app); return -1; } if (!(chan2 = ast_channel_get_by_name(args.channel))) { ast_log(LOG_WARNING, "No such channel: %s\n", args.channel); pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "NOCHANNEL"); return 0; } if (ast_channel_pbx(chan2)) { ast_set_flag(ast_channel_flags(chan2), AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ } res = ast_async_parseable_goto(chan2, args.label); chan2 = ast_channel_unref(chan2); pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "SUCCESS"); return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, asyncgoto_exec) ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Redirects a given channel to a dialplan target"); asterisk-11.7.0/apps/app_test.c0000644000175000007640000003250411721555224016303 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * Russell Bryant * * 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 Applications to test connection and produce report in text file * * \author Mark Spencer * \author Russell Bryant * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356573 $") #include #include "asterisk/paths.h" /* use ast_config_AST_LOG_DIR */ #include "asterisk/channel.h" #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/app.h" #include "asterisk/pbx.h" #include "asterisk/utils.h" /*** DOCUMENTATION Execute Interface Test Server. Perform test server function and write call report. Results stored in /var/log/asterisk/testreports/<testid>-server.txt TestClient Execute Interface Test Client. An ID to identify this test. Executes test client with given testid. Results stored in /var/log/asterisk/testreports/<testid>-client.txt TestServer ***/ static char *tests_app = "TestServer"; static char *testc_app = "TestClient"; static int measurenoise(struct ast_channel *chan, int ms, char *who) { int res=0; int mssofar; int noise=0; int samples=0; int x; short *foo; struct timeval start; struct ast_frame *f; struct ast_format rformat; ast_format_copy(&rformat, ast_channel_readformat(chan)); if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) { ast_log(LOG_NOTICE, "Unable to set to linear mode!\n"); return -1; } start = ast_tvnow(); for(;;) { mssofar = ast_tvdiff_ms(ast_tvnow(), start); if (mssofar > ms) break; res = ast_waitfor(chan, ms - mssofar); if (res < 1) break; f = ast_read(chan); if (!f) { res = -1; break; } if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id == AST_FORMAT_SLINEAR)) { foo = (short *)f->data.ptr; for (x=0;xsamples;x++) { noise += abs(foo[x]); samples++; } } ast_frfree(f); } if (rformat.id) { if (ast_set_read_format(chan, &rformat)) { ast_log(LOG_NOTICE, "Unable to restore original format!\n"); return -1; } } if (res < 0) return res; if (!samples) { ast_log(LOG_NOTICE, "No samples were received from the other side!\n"); return -1; } ast_debug(1, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples); return (noise / samples); } static int sendnoise(struct ast_channel *chan, int ms) { int res; res = ast_tonepair_start(chan, 1537, 2195, ms, 8192); if (!res) { res = ast_waitfordigit(chan, ms); ast_tonepair_stop(chan); } return res; } static int testclient_exec(struct ast_channel *chan, const char *data) { int res = 0; const char *testid=data; char fn[80]; char serverver[80]; FILE *f; /* Check for test id */ if (ast_strlen_zero(testid)) { ast_log(LOG_WARNING, "TestClient requires an argument - the test id\n"); return -1; } if (ast_channel_state(chan) != AST_STATE_UP) res = ast_answer(chan); /* Wait a few just to be sure things get started */ res = ast_safe_sleep(chan, 3000); /* Transmit client version */ if (!res) res = ast_dtmf_stream(chan, NULL, "8378*1#", 0, 0); ast_debug(1, "Transmit client version\n"); /* Read server version */ ast_debug(1, "Read server version\n"); if (!res) res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0); if (res > 0) res = 0; ast_debug(1, "server version: %s\n", serverver); if (res > 0) res = 0; if (!res) res = ast_safe_sleep(chan, 1000); /* Send test id */ if (!res) res = ast_dtmf_stream(chan, NULL, testid, 0, 0); if (!res) res = ast_dtmf_stream(chan, NULL, "#", 0, 0); ast_debug(1, "send test identifier: %s\n", testid); if ((res >=0) && (!ast_strlen_zero(testid))) { /* Make the directory to hold the test results in case it's not there */ snprintf(fn, sizeof(fn), "%s/testresults", ast_config_AST_LOG_DIR); ast_mkdir(fn, 0777); snprintf(fn, sizeof(fn), "%s/testresults/%s-client.txt", ast_config_AST_LOG_DIR, testid); if ((f = fopen(fn, "w+"))) { setlinebuf(f); fprintf(f, "CLIENTCHAN: %s\n", ast_channel_name(chan)); fprintf(f, "CLIENTTEST ID: %s\n", testid); fprintf(f, "ANSWER: PASS\n"); res = 0; if (!res) { /* Step 1: Wait for "1" */ ast_debug(1, "TestClient: 2. Wait DTMF 1\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 1: %s\n", (res != '1') ? "FAIL" : "PASS"); if (res == '1') res = 0; else res = -1; } if (!res) { res = ast_safe_sleep(chan, 1000); } if (!res) { /* Step 2: Send "2" */ ast_debug(1, "TestClient: 2. Send DTMF 2\n"); res = ast_dtmf_stream(chan, NULL, "2", 0, 0); fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 3: Wait one second */ ast_debug(1, "TestClient: 3. Wait one second\n"); res = ast_safe_sleep(chan, 1000); fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 4: Measure noise */ ast_debug(1, "TestClient: 4. Measure noise\n"); res = measurenoise(chan, 5000, "TestClient"); fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) res = 0; } if (!res) { /* Step 5: Wait for "4" */ ast_debug(1, "TestClient: 5. Wait DTMF 4\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 4: %s\n", (res != '4') ? "FAIL" : "PASS"); if (res == '4') res = 0; else res = -1; } if (!res) { /* Step 6: Transmit tone noise */ ast_debug(1, "TestClient: 6. Transmit tone\n"); res = sendnoise(chan, 6000); fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS"); } if (!res || (res == '5')) { /* Step 7: Wait for "5" */ ast_debug(1, "TestClient: 7. Wait DTMF 5\n"); if (!res) res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 5: %s\n", (res != '5') ? "FAIL" : "PASS"); if (res == '5') res = 0; else res = -1; } if (!res) { /* Step 8: Wait one second */ ast_debug(1, "TestClient: 8. Wait one second\n"); res = ast_safe_sleep(chan, 1000); fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 9: Measure noise */ ast_debug(1, "TestClient: 9. Measure tone\n"); res = measurenoise(chan, 4000, "TestClient"); fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) res = 0; } if (!res) { /* Step 10: Send "7" */ ast_debug(1, "TestClient: 10. Send DTMF 7\n"); res = ast_dtmf_stream(chan, NULL, "7", 0, 0); fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res =0; } if (!res) { /* Step 11: Wait for "8" */ ast_debug(1, "TestClient: 11. Wait DTMF 8\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 8: %s\n", (res != '8') ? "FAIL" : "PASS"); if (res == '8') res = 0; else res = -1; } if (!res) { res = ast_safe_sleep(chan, 1000); } if (!res) { /* Step 12: Hangup! */ ast_debug(1, "TestClient: 12. Hangup\n"); } ast_debug(1, "-- TEST COMPLETE--\n"); fprintf(f, "-- END TEST--\n"); fclose(f); res = -1; } else res = -1; } else { ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", ast_channel_name(chan)); res = -1; } return res; } static int testserver_exec(struct ast_channel *chan, const char *data) { int res = 0; char testid[80]=""; char fn[80]; FILE *f; if (ast_channel_state(chan) != AST_STATE_UP) res = ast_answer(chan); /* Read version */ ast_debug(1, "Read client version\n"); if (!res) res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0); if (res > 0) res = 0; ast_debug(1, "client version: %s\n", testid); ast_debug(1, "Transmit server version\n"); res = ast_safe_sleep(chan, 1000); if (!res) res = ast_dtmf_stream(chan, NULL, "8378*1#", 0, 0); if (res > 0) res = 0; if (!res) res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0); ast_debug(1, "read test identifier: %s\n", testid); /* Check for sneakyness */ if (strchr(testid, '/')) res = -1; if ((res >=0) && (!ast_strlen_zero(testid))) { /* Got a Test ID! Whoo hoo! */ /* Make the directory to hold the test results in case it's not there */ snprintf(fn, sizeof(fn), "%s/testresults", ast_config_AST_LOG_DIR); ast_mkdir(fn, 0777); snprintf(fn, sizeof(fn), "%s/testresults/%s-server.txt", ast_config_AST_LOG_DIR, testid); if ((f = fopen(fn, "w+"))) { setlinebuf(f); fprintf(f, "SERVERCHAN: %s\n", ast_channel_name(chan)); fprintf(f, "SERVERTEST ID: %s\n", testid); fprintf(f, "ANSWER: PASS\n"); ast_debug(1, "Processing Test ID '%s'\n", testid); res = ast_safe_sleep(chan, 1000); if (!res) { /* Step 1: Send "1" */ ast_debug(1, "TestServer: 1. Send DTMF 1\n"); res = ast_dtmf_stream(chan, NULL, "1", 0,0 ); fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 2: Wait for "2" */ ast_debug(1, "TestServer: 2. Wait DTMF 2\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 2: %s\n", (res != '2') ? "FAIL" : "PASS"); if (res == '2') res = 0; else res = -1; } if (!res) { /* Step 3: Measure noise */ ast_debug(1, "TestServer: 3. Measure noise\n"); res = measurenoise(chan, 6000, "TestServer"); fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) res = 0; } if (!res) { /* Step 4: Send "4" */ ast_debug(1, "TestServer: 4. Send DTMF 4\n"); res = ast_dtmf_stream(chan, NULL, "4", 0, 0); fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 5: Wait one second */ ast_debug(1, "TestServer: 5. Wait one second\n"); res = ast_safe_sleep(chan, 1000); fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 6: Measure noise */ ast_debug(1, "TestServer: 6. Measure tone\n"); res = measurenoise(chan, 4000, "TestServer"); fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) res = 0; } if (!res) { /* Step 7: Send "5" */ ast_debug(1, "TestServer: 7. Send DTMF 5\n"); res = ast_dtmf_stream(chan, NULL, "5", 0, 0); fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 8: Transmit tone noise */ ast_debug(1, "TestServer: 8. Transmit tone\n"); res = sendnoise(chan, 6000); fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS"); } if (!res || (res == '7')) { /* Step 9: Wait for "7" */ ast_debug(1, "TestServer: 9. Wait DTMF 7\n"); if (!res) res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 7: %s\n", (res != '7') ? "FAIL" : "PASS"); if (res == '7') res = 0; else res = -1; } if (!res) { res = ast_safe_sleep(chan, 1000); } if (!res) { /* Step 10: Send "8" */ ast_debug(1, "TestServer: 10. Send DTMF 8\n"); res = ast_dtmf_stream(chan, NULL, "8", 0, 0); fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) res = 0; } if (!res) { /* Step 11: Wait for hangup to arrive! */ ast_debug(1, "TestServer: 11. Waiting for hangup\n"); res = ast_safe_sleep(chan, 10000); fprintf(f, "WAIT HANGUP: %s\n", (res < 0) ? "PASS" : "FAIL"); } ast_log(LOG_NOTICE, "-- TEST COMPLETE--\n"); fprintf(f, "-- END TEST--\n"); fclose(f); res = -1; } else res = -1; } else { ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", ast_channel_name(chan)); res = -1; } return res; } static int unload_module(void) { int res; res = ast_unregister_application(testc_app); res |= ast_unregister_application(tests_app); return res; } static int load_module(void) { int res; res = ast_register_application_xml(testc_app, testclient_exec); res |= ast_register_application_xml(tests_app, testserver_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Interface Test Application"); asterisk-11.7.0/apps/app_readfile.c0000644000175000007640000000700411607650606017077 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Matt O'Gorman * * 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 ReadFile application -- Reads in a File for you. * * \author Matt O'Gorman * * \ingroup applications */ /*** MODULEINFO no deprecated func_env (FILE()) ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/app.h" #include "asterisk/module.h" /*** DOCUMENTATION Read the contents of a text file into a channel variable. Result stored here. The name of the file to read. Maximum number of characters to capture. If not specified defaults to max. Read the contents of a text file into channel variable varname ReadFile has been deprecated in favor of Set(varname=${FILE(file,0,length)}) System Read ***/ static char *app_readfile = "ReadFile"; static int readfile_exec(struct ast_channel *chan, const char *data) { int res=0; char *s, *varname=NULL, *file=NULL, *length=NULL, *returnvar=NULL; int len=0; static int deprecation_warning = 0; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "ReadFile require an argument!\n"); return -1; } s = ast_strdupa(data); varname = strsep(&s, "="); file = strsep(&s, ","); length = s; if (deprecation_warning++ % 10 == 0) ast_log(LOG_WARNING, "ReadFile has been deprecated in favor of Set(%s=${FILE(%s,0,%s)})\n", varname, file, length); if (!varname || !file) { ast_log(LOG_ERROR, "No file or variable specified!\n"); return -1; } if (length) { if ((sscanf(length, "%30d", &len) != 1) || (len < 0)) { ast_log(LOG_WARNING, "%s is not a positive number, defaulting length to max\n", length); len = 0; } } if ((returnvar = ast_read_textfile(file))) { if (len > 0) { if (len < strlen(returnvar)) returnvar[len]='\0'; else ast_log(LOG_WARNING, "%s is longer than %d, and %d \n", file, len, (int)strlen(returnvar)); } pbx_builtin_setvar_helper(chan, varname, returnvar); ast_free(returnvar); } return res; } static int unload_module(void) { return ast_unregister_application(app_readfile); } static int load_module(void) { return ast_register_application_xml(app_readfile, readfile_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Stores output of file into a variable"); asterisk-11.7.0/apps/app_while.c0000644000175000007640000002407512006037127016432 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright 2004 - 2005, Anthony Minessale * * Anthony Minessale * * 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 While Loop Implementation * * \author Anthony Minessale * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 370655 $") #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/channel.h" /*** DOCUMENTATION Start a while loop. Start a While Loop. Execution will return to this point when EndWhile() is called until expr is no longer true. EndWhile ExitWhile ContinueWhile End a while loop. Return to the previous called While(). While ExitWhile ContinueWhile End a While loop. Exits a While() loop, whether or not the conditional has been satisfied. While EndWhile ContinueWhile Restart a While loop. Returns to the top of the while loop and re-evaluates the conditional. While EndWhile ExitWhile ***/ static char *start_app = "While"; static char *stop_app = "EndWhile"; static char *exit_app = "ExitWhile"; static char *continue_app = "ContinueWhile"; #define VAR_SIZE 64 static const char *get_index(struct ast_channel *chan, const char *prefix, int idx) { char varname[VAR_SIZE]; snprintf(varname, VAR_SIZE, "%s_%d", prefix, idx); return pbx_builtin_getvar_helper(chan, varname); } static struct ast_exten *find_matching_priority(struct ast_context *c, const char *exten, int priority, const char *callerid) { struct ast_exten *e; struct ast_include *i; struct ast_context *c2; for (e=ast_walk_context_extensions(c, NULL); e; e=ast_walk_context_extensions(c, e)) { if (ast_extension_match(ast_get_extension_name(e), exten)) { int needmatch = ast_get_extension_matchcid(e); if ((needmatch && ast_extension_match(ast_get_extension_cidmatch(e), callerid)) || (!needmatch)) { /* This is the matching extension we want */ struct ast_exten *p; for (p=ast_walk_extension_priorities(e, NULL); p; p=ast_walk_extension_priorities(e, p)) { if (priority != ast_get_extension_priority(p)) continue; return p; } } } } /* No match; run through includes */ for (i=ast_walk_context_includes(c, NULL); i; i=ast_walk_context_includes(c, i)) { for (c2=ast_walk_contexts(NULL); c2; c2=ast_walk_contexts(c2)) { if (!strcmp(ast_get_context_name(c2), ast_get_include_name(i))) { e = find_matching_priority(c2, exten, priority, callerid); if (e) return e; } } } return NULL; } static int find_matching_endwhile(struct ast_channel *chan) { struct ast_context *c; int res=-1; if (ast_rdlock_contexts()) { ast_log(LOG_ERROR, "Failed to lock contexts list\n"); return -1; } for (c=ast_walk_contexts(NULL); c; c=ast_walk_contexts(c)) { struct ast_exten *e; if (!ast_rdlock_context(c)) { if (!strcmp(ast_get_context_name(c), ast_channel_context(chan))) { /* This is the matching context we want */ int cur_priority = ast_channel_priority(chan) + 1, level=1; for (e = find_matching_priority(c, ast_channel_exten(chan), cur_priority, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)); e; e = find_matching_priority(c, ast_channel_exten(chan), ++cur_priority, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { if (!strcasecmp(ast_get_extension_app(e), "WHILE")) { level++; } else if (!strcasecmp(ast_get_extension_app(e), "ENDWHILE")) { level--; } if (level == 0) { res = cur_priority; break; } } } ast_unlock_context(c); if (res > 0) { break; } } } ast_unlock_contexts(); return res; } static int _while_exec(struct ast_channel *chan, const char *data, int end) { int res=0; const char *while_pri = NULL; char *my_name = NULL; const char *condition = NULL, *label = NULL; char varname[VAR_SIZE], end_varname[VAR_SIZE]; const char *prefix = "WHILE"; size_t size=0; int used_index_i = -1, x=0; char used_index[VAR_SIZE] = "0", new_index[VAR_SIZE] = "0"; if (!chan) { /* huh ? */ return -1; } #if 0 /* don't want run away loops if the chan isn't even up this is up for debate since it slows things down a tad ...... Debate is over... this prevents While/EndWhile from working within the "h" extension. Not good. */ if (ast_waitfordigit(chan,1) < 0) return -1; #endif for (x=0;;x++) { if (get_index(chan, prefix, x)) { used_index_i = x; } else break; } snprintf(used_index, VAR_SIZE, "%d", used_index_i); snprintf(new_index, VAR_SIZE, "%d", used_index_i + 1); if (!end) condition = ast_strdupa(data); size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32; my_name = ast_alloca(size); memset(my_name, 0, size); snprintf(my_name, size, "%s_%s_%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan)); ast_channel_lock(chan); if (end) { label = used_index; } else if (!(label = pbx_builtin_getvar_helper(chan, my_name))) { label = new_index; pbx_builtin_setvar_helper(chan, my_name, label); } snprintf(varname, VAR_SIZE, "%s_%s", prefix, label); if ((while_pri = pbx_builtin_getvar_helper(chan, varname)) && !end) { while_pri = ast_strdupa(while_pri); snprintf(end_varname,VAR_SIZE,"END_%s",varname); } ast_channel_unlock(chan); if ((!end && !pbx_checkcondition(condition)) || (end == 2)) { /* Condition Met (clean up helper vars) */ const char *goto_str; pbx_builtin_setvar_helper(chan, varname, NULL); pbx_builtin_setvar_helper(chan, my_name, NULL); snprintf(end_varname,VAR_SIZE,"END_%s",varname); ast_channel_lock(chan); if ((goto_str = pbx_builtin_getvar_helper(chan, end_varname))) { ast_parseable_goto(chan, goto_str); pbx_builtin_setvar_helper(chan, end_varname, NULL); } else { int pri = find_matching_endwhile(chan); if (pri > 0) { ast_verb(3, "Jumping to priority %d\n", pri); ast_channel_priority_set(chan, pri); } else { ast_log(LOG_WARNING, "Couldn't find matching EndWhile? (While at %s@%s priority %d)\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan)); } } ast_channel_unlock(chan); return res; } if (!end && !while_pri) { char *goto_str; size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32; goto_str = ast_alloca(size); memset(goto_str, 0, size); snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan)); pbx_builtin_setvar_helper(chan, varname, goto_str); } else if (end && while_pri) { /* END of loop */ snprintf(end_varname, VAR_SIZE, "END_%s", varname); if (! pbx_builtin_getvar_helper(chan, end_varname)) { char *goto_str; size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32; goto_str = ast_alloca(size); memset(goto_str, 0, size); snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan)+1); pbx_builtin_setvar_helper(chan, end_varname, goto_str); } ast_parseable_goto(chan, while_pri); } return res; } static int while_start_exec(struct ast_channel *chan, const char *data) { return _while_exec(chan, data, 0); } static int while_end_exec(struct ast_channel *chan, const char *data) { return _while_exec(chan, data, 1); } static int while_exit_exec(struct ast_channel *chan, const char *data) { return _while_exec(chan, data, 2); } static int while_continue_exec(struct ast_channel *chan, const char *data) { int x; const char *prefix = "WHILE", *while_pri=NULL; for (x = 0; ; x++) { const char *tmp = get_index(chan, prefix, x); if (tmp) while_pri = tmp; else break; } if (while_pri) ast_parseable_goto(chan, while_pri); return 0; } static int unload_module(void) { int res; res = ast_unregister_application(start_app); res |= ast_unregister_application(stop_app); res |= ast_unregister_application(exit_app); res |= ast_unregister_application(continue_app); return res; } static int load_module(void) { int res; res = ast_register_application_xml(start_app, while_start_exec); res |= ast_register_application_xml(stop_app, while_end_exec); res |= ast_register_application_xml(exit_app, while_exit_exec); res |= ast_register_application_xml(continue_app, while_continue_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "While Loops and Conditional Execution"); asterisk-11.7.0/apps/app_directed_pickup.c0000644000175000007640000002735112026647431020467 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2005, Joshua Colp * * Joshua Colp * * Portions merged from app_pickupchan, which was * Copyright (C) 2008, Gary Cook * * 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 Directed Call Pickup Support * * \author Joshua Colp * \author Gary Cook * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 373220 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/app.h" #include "asterisk/features.h" #include "asterisk/manager.h" #include "asterisk/callerid.h" #include "asterisk/cel.h" #define PICKUPMARK "PICKUPMARK" /*** DOCUMENTATION Directed extension call pickup. Specification of the pickup target. Additional specifications of pickup targets. This application can pickup a specified ringing channel. The channel to pickup can be specified in the following ways. 1) If no extension targets are specified, the application will pickup a channel matching the pickup group of the requesting channel. 2) If the extension is specified with a context of the special string PICKUPMARK (for example 10@PICKUPMARK), the application will pickup a channel which has defined the channel variable PICKUPMARK with the same value as extension (in this example, 10). 3) If the extension is specified with or without a context, the channel with a matching extension and context will be picked up. If no context is specified, the current context will be used. The extension is typically set on matching channels by the dial application that created the channel. The context is set on matching channels by the channel driver for the device. Pickup a ringing channel. This will pickup a specified channel if ringing. ***/ static const char app[] = "Pickup"; static const char app2[] = "PickupChan"; struct pickup_by_name_args { const char *name; size_t len; }; static int pickup_by_name_cb(void *obj, void *arg, void *data, int flags) { struct ast_channel *target = obj;/*!< Potential pickup target */ struct pickup_by_name_args *args = data; ast_channel_lock(target); if (!strncasecmp(ast_channel_name(target), args->name, args->len) && ast_can_pickup(target)) { /* Return with the channel still locked on purpose */ return CMP_MATCH | CMP_STOP; } ast_channel_unlock(target); return 0; } /*! \brief Helper Function to walk through ALL channels checking NAME and STATE */ static struct ast_channel *my_ast_get_channel_by_name_locked(const char *channame) { char *chkchan; struct pickup_by_name_args pickup_args; /* Check if channel name contains a '-'. * In this case the channel name will be interpreted as full channel name. */ if (strchr(channame, '-')) { /* check full channel name */ pickup_args.len = strlen(channame); pickup_args.name = channame; } else { /* need to append a '-' for the comparison so we check full channel name, * i.e SIP/hgc- , use a temporary variable so original stays the same for * debugging. */ pickup_args.len = strlen(channame) + 1; chkchan = ast_alloca(pickup_args.len + 1); strcpy(chkchan, channame); strcat(chkchan, "-"); pickup_args.name = chkchan; } return ast_channel_callback(pickup_by_name_cb, NULL, &pickup_args, 0); } /*! \brief Attempt to pick up named channel, does not use context */ static int pickup_by_channel(struct ast_channel *chan, char *pickup) { int res = -1; struct ast_channel *target;/*!< Potential pickup target */ target = my_ast_get_channel_by_name_locked(pickup); if (target) { /* Just check that we are not picking up the SAME as target. (i.e. ourself) */ if (chan != target) { res = ast_do_pickup(chan, target); } ast_channel_unlock(target); target = ast_channel_unref(target); } return res; } /* Attempt to pick up specified extension with context */ static int pickup_by_exten(struct ast_channel *chan, const char *exten, const char *context) { struct ast_channel *target = NULL;/*!< Potential pickup target */ struct ast_channel_iterator *iter; int res = -1; if (!(iter = ast_channel_iterator_by_exten_new(exten, context))) { return -1; } while ((target = ast_channel_iterator_next(iter))) { ast_channel_lock(target); if ((chan != target) && ast_can_pickup(target)) { ast_log(LOG_NOTICE, "%s pickup by %s\n", ast_channel_name(target), ast_channel_name(chan)); break; } ast_channel_unlock(target); target = ast_channel_unref(target); } ast_channel_iterator_destroy(iter); if (target) { res = ast_do_pickup(chan, target); ast_channel_unlock(target); target = ast_channel_unref(target); } return res; } static int find_by_mark(void *obj, void *arg, void *data, int flags) { struct ast_channel *target = obj;/*!< Potential pickup target */ const char *mark = data; const char *tmp; ast_channel_lock(target); tmp = pbx_builtin_getvar_helper(target, PICKUPMARK); if (tmp && !strcasecmp(tmp, mark) && ast_can_pickup(target)) { /* Return with the channel still locked on purpose */ return CMP_MATCH | CMP_STOP; } ast_channel_unlock(target); return 0; } /* Attempt to pick up specified mark */ static int pickup_by_mark(struct ast_channel *chan, const char *mark) { struct ast_channel *target;/*!< Potential pickup target */ int res = -1; /* The found channel is already locked. */ target = ast_channel_callback(find_by_mark, NULL, (char *) mark, 0); if (target) { res = ast_do_pickup(chan, target); ast_channel_unlock(target); target = ast_channel_unref(target); } return res; } static int pickup_by_group(struct ast_channel *chan) { struct ast_channel *target;/*!< Potential pickup target */ int res = -1; /* The found channel is already locked. */ target = ast_pickup_find_by_group(chan); if (target) { ast_log(LOG_NOTICE, "pickup %s attempt by %s\n", ast_channel_name(target), ast_channel_name(chan)); res = ast_do_pickup(chan, target); ast_channel_unlock(target); target = ast_channel_unref(target); } return res; } /* application entry point for Pickup() */ static int pickup_exec(struct ast_channel *chan, const char *data) { char *tmp; char *exten; char *context; if (ast_strlen_zero(data)) { return pickup_by_group(chan) ? 0 : -1; } /* Parse extension (and context if there) */ tmp = ast_strdupa(data); while (!ast_strlen_zero(tmp) && (exten = strsep(&tmp, "&"))) { if ((context = strchr(exten, '@'))) *context++ = '\0'; if (!ast_strlen_zero(context) && !strcasecmp(context, PICKUPMARK)) { if (!pickup_by_mark(chan, exten)) { /* Pickup successful. Stop the dialplan this channel is a zombie. */ return -1; } } else { if (ast_strlen_zero(context)) { context = (char *) ast_channel_context(chan); } if (!pickup_by_exten(chan, exten, context)) { /* Pickup successful. Stop the dialplan this channel is a zombie. */ return -1; } } ast_log(LOG_NOTICE, "No target channel found for %s@%s.\n", exten, context); } /* Pickup failed. Keep going in the dialplan. */ return 0; } /* Find channel for pick up specified by partial channel name */ static int find_by_part(void *obj, void *arg, void *data, int flags) { struct ast_channel *target = obj;/*!< Potential pickup target */ const char *part = data; int len = strlen(part); ast_channel_lock(target); if (len <= strlen(ast_channel_name(target)) && !strncmp(ast_channel_name(target), part, len) && ast_can_pickup(target)) { /* Return with the channel still locked on purpose */ return CMP_MATCH | CMP_STOP; } ast_channel_unlock(target); return 0; } /* Attempt to pick up specified by partial channel name */ static int pickup_by_part(struct ast_channel *chan, const char *part) { struct ast_channel *target;/*!< Potential pickup target */ int res = -1; /* The found channel is already locked. */ target = ast_channel_callback(find_by_part, NULL, (char *) part, 0); if (target) { res = ast_do_pickup(chan, target); ast_channel_unlock(target); target = ast_channel_unref(target); } return res; } /* application entry point for PickupChan() */ static int pickupchan_exec(struct ast_channel *chan, const char *data) { int partial_pickup = 0; char *pickup = NULL; char *parse = ast_strdupa(data); AST_DECLARE_APP_ARGS(args, AST_APP_ARG(channel); AST_APP_ARG(options); ); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.channel)) { ast_log(LOG_WARNING, "PickupChan requires an argument (channel)!\n"); /* Pickup failed. Keep going in the dialplan. */ return 0; } if (!ast_strlen_zero(args.options) && strchr(args.options, 'p')) { partial_pickup = 1; } /* Parse channel */ while (!ast_strlen_zero(args.channel) && (pickup = strsep(&args.channel, "&"))) { if (!strncasecmp(ast_channel_name(chan), pickup, strlen(pickup))) { ast_log(LOG_NOTICE, "Cannot pickup your own channel %s.\n", pickup); } else { if (partial_pickup) { if (!pickup_by_part(chan, pickup)) { /* Pickup successful. Stop the dialplan this channel is a zombie. */ return -1; } } else if (!pickup_by_channel(chan, pickup)) { /* Pickup successful. Stop the dialplan this channel is a zombie. */ return -1; } ast_log(LOG_NOTICE, "No target channel found for %s.\n", pickup); } } /* Pickup failed. Keep going in the dialplan. */ return 0; } static int unload_module(void) { int res; res = ast_unregister_application(app); res |= ast_unregister_application(app2); return res; } static int load_module(void) { int res; res = ast_register_application_xml(app, pickup_exec); res |= ast_register_application_xml(app2, pickupchan_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Directed Call Pickup Application"); asterisk-11.7.0/apps/app_skel.c0000644000175000007640000005320111764207707016266 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) , * * <> * * 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. * * Please follow coding guidelines * https://wiki.asterisk.org/wiki/display/AST/Coding+Guidelines */ /*! \file * * \brief Skeleton application * * \author\verbatim <> \endverbatim * * This is a skeleton for development of an Asterisk application * \ingroup applications */ /*** MODULEINFO no core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 368673 $") #include /* log10 */ #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/app.h" #include "asterisk/config.h" #include "asterisk/config_options.h" #include "asterisk/say.h" #include "asterisk/astobj2.h" #include "asterisk/acl.h" #include "asterisk/netsock2.h" #include "asterisk/strings.h" #include "asterisk/cli.h" /*** DOCUMENTATION An example number guessing game This simple number guessing application is a template to build other applications from. It shows you the basic structure to create your own Asterisk applications. ***/ static char *app = "SkelGuessNumber"; enum option_flags { OPTION_CHEAT = (1 << 0), OPTION_NUMGAMES = (1 << 1), }; enum option_args { OPTION_ARG_NUMGAMES, /* This *must* be the last value in this enum! */ OPTION_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(app_opts,{ AST_APP_OPTION('c', OPTION_CHEAT), AST_APP_OPTION_ARG('n', OPTION_NUMGAMES, OPTION_ARG_NUMGAMES), }); /*! \brief A structure to hold global configuration-related options */ struct skel_global_config { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(prompt); /*!< The comma-separated list of sounds to prompt to enter a number */ AST_STRING_FIELD(wrong); /*!< The comma-separated list of sounds to indicate a wrong guess */ AST_STRING_FIELD(right); /*!< The comma-separated list of sounds to indicate a right guess */ AST_STRING_FIELD(high); /*!< The comma-separated list of sounds to indicate a high guess */ AST_STRING_FIELD(low); /*!< The comma-separated list of sounds to indicate a low guess */ AST_STRING_FIELD(lose); /*!< The comma-separated list of sounds to indicate a lost game */ ); uint32_t num_games; /*!< The number of games to play before hanging up */ unsigned char cheat:1; /*!< Whether the computer can cheat or not */ }; /*! \brief A structure to maintain level state across reloads */ struct skel_level_state { uint32_t wins; /*!< How many wins for this level */ uint32_t losses; /*!< How many losses for this level */ double avg_guesses; /*!< The average number of guesses to win for this level */ }; /*! \brief Object to hold level config information. * \note This object should hold a reference to an an object that holds state across reloads. * The other fields are just examples of the kind of data that might be stored in an level. */ struct skel_level { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(name); /*!< The name of the level */ ); uint32_t max_num; /*!< The upper value on th range of numbers to guess */ uint32_t max_guesses; /*!< The maximum number of guesses before losing */ struct skel_level_state *state; /*!< A pointer to level state that must exist across all reloads */ }; /*! \brief Information about a currently running set of games * \note Because we want to be able to show true running information about the games * regardless of whether or not a reload has modified what the level looks like, it * is important to either copy the information we need from the level to the * current_game struct, or as we do here, store a reference to the level as it is for * the running game. */ struct skel_current_game { uint32_t total_games; /*! The total number of games for this call to to the app */ uint32_t games_left; /*! How many games are left to play in this set */ uint32_t cheat; /*! Whether or not cheating was enabled for the game */ struct skel_level *level_info; /*! The level information for the running game */ }; /* Treat the levels as an array--there won't be many and this will maintain the order */ #define LEVEL_BUCKETS 1 /*! \brief A container that holds all config-related information * \note This object should contain a pointer to structs for global data and containers for * any levels that are configured. Objects of this type will be swapped out on reload. If an * level needs to maintain state across reloads, it needs to allocate a refcounted object to * hold that state and ensure that a reference is passed to that state when creating a new * level for reload. */ struct skel_config { struct skel_global_config *global; struct ao2_container *levels; }; /* Config Options API callbacks */ /*! \brief Allocate a skel_config to hold a snapshot of the complete results of parsing a config * \internal * \returns A void pointer to a newly allocated skel_config */ static void *skel_config_alloc(void); /*! \brief Allocate a skel_level based on a category in a configuration file * \param cat The category to base the level on * \returns A void pointer to a newly allocated skel_level */ static void *skel_level_alloc(const char *cat); /*! \brief Find a skel level in the specified container * \note This function *does not* look for a skel_level in the active container. It is used * internally by the Config Options code to check if an level has already been added to the * container that will be swapped for the live container on a successul reload. * * \param container A non-active container to search for a level * \param category The category associated with the level to check for * \retval non-NULL The level from the container * \retval NULL The level does not exist in the container */ static void *skel_level_find(struct ao2_container *tmp_container, const char *category); /*! \brief An aco_type structure to link the "general" category to the skel_global_config type */ static struct aco_type global_option = { .type = ACO_GLOBAL, .item_offset = offsetof(struct skel_config, global), .category_match = ACO_WHITELIST, .category = "^general$", }; struct aco_type *global_options[] = ACO_TYPES(&global_option); /*! \brief An aco_type structure to link the "sounds" category to the skel_global_config type */ static struct aco_type sound_option = { .type = ACO_GLOBAL, .item_offset = offsetof(struct skel_config, global), .category_match = ACO_WHITELIST, .category = "^sounds$", }; struct aco_type *sound_options[] = ACO_TYPES(&sound_option); /*! \brief An aco_type structure to link the everything but the "general" and "sounds" categories to the skel_level type */ static struct aco_type level_option = { .type = ACO_ITEM, .category_match = ACO_BLACKLIST, .category = "^(general|sounds)$", .item_alloc = skel_level_alloc, .item_find = skel_level_find, .item_offset = offsetof(struct skel_config, levels), }; struct aco_type *level_options[] = ACO_TYPES(&level_option); struct aco_file app_skel_conf = { .filename = "app_skel.conf", .types = ACO_TYPES(&global_option, &sound_option, &level_option), }; /*! \brief A global object container that will contain the skel_config that gets swapped out on reloads */ static AO2_GLOBAL_OBJ_STATIC(globals); /*! \brief The container of active games */ static struct ao2_container *games; /*! \brief Register information about the configs being processed by this module */ CONFIG_INFO_STANDARD(cfg_info, globals, skel_config_alloc, .files = ACO_FILES(&app_skel_conf), ); static void skel_global_config_destructor(void *obj) { struct skel_global_config *global = obj; ast_string_field_free_memory(global); } static void skel_game_destructor(void *obj) { struct skel_current_game *game = obj; ao2_cleanup(game->level_info); } static void skel_state_destructor(void *obj) { return; } static struct skel_current_game *skel_game_alloc(struct skel_level *level) { struct skel_current_game *game; if (!(game = ao2_alloc(sizeof(struct skel_current_game), skel_game_destructor))) { return NULL; } ao2_ref(level, +1); game->level_info = level; return game; } static void skel_level_destructor(void *obj) { struct skel_level *level = obj; ast_string_field_free_memory(level); ao2_cleanup(level->state); } static int skel_level_hash(const void *obj, const int flags) { const struct skel_level *level = obj; const char *name = (flags & OBJ_KEY) ? obj : level->name; return ast_str_case_hash(name); } static int skel_level_cmp(void *obj, void *arg, int flags) { struct skel_level *one = obj, *two = arg; const char *match = (flags & OBJ_KEY) ? arg : two->name; return strcasecmp(one->name, match) ? 0 : (CMP_MATCH | CMP_STOP); } /*! \brief A custom bitfield handler * \internal * \note It is not possible to take the address of a bitfield, therefor all * bitfields in the config struct will have to use a custom handler * \param opt The opaque config option * \param var The ast_variable containing the option name and value * \param obj The object registerd for this option type * \retval 0 Success * \retval non-zero Failure */ static int custom_bitfield_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { struct skel_global_config *global = obj; if (!strcasecmp(var->name, "cheat")) { global->cheat = ast_true(var->value); } else { return -1; } return 0; } static void play_files_helper(struct ast_channel *chan, const char *prompts) { char *prompt, *rest = ast_strdupa(prompts); ast_stopstream(chan); while ((prompt = strsep(&rest, "&")) && !ast_stream_and_wait(chan, prompt, "")) { ast_stopstream(chan); } } static int app_exec(struct ast_channel *chan, const char *data) { int win = 0; uint32_t guesses; RAII_VAR(struct skel_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup); RAII_VAR(struct skel_level *, level, NULL, ao2_cleanup); RAII_VAR(struct skel_current_game *, game, NULL, ao2_cleanup); char *parse, *opts[OPTION_ARG_ARRAY_SIZE]; struct ast_flags flags; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(level); AST_APP_ARG(options); ); if (!cfg) { ast_log(LOG_ERROR, "Couldn't access configuratino data!\n"); return -1; } if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "%s requires an argument (level[,options])\n", app); return -1; } /* We need to make a copy of the input string if we are going to modify it! */ parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (args.argc == 2) { ast_app_parse_options(app_opts, &flags, opts, args.options); } if (ast_strlen_zero(args.level)) { ast_log(LOG_ERROR, "%s requires a level argument\n", app); return -1; } if (!(level = ao2_find(cfg->levels, args.level, OBJ_KEY))) { ast_log(LOG_ERROR, "Unknown level: %s\n", args.level); return -1; } if (!(game = skel_game_alloc(level))) { return -1; } ao2_link(games, game); /* Use app-specified values, or the options specified in [general] if they aren't passed to the app */ if (!ast_test_flag(&flags, OPTION_NUMGAMES) || ast_strlen_zero(opts[OPTION_ARG_NUMGAMES]) || ast_parse_arg(opts[OPTION_ARG_NUMGAMES], PARSE_UINT32, &game->total_games)) { game->total_games = cfg->global->num_games; } game->games_left = game->total_games; game->cheat = ast_test_flag(&flags, OPTION_CHEAT) || cfg->global->cheat; for (game->games_left = game->total_games; game->games_left; game->games_left--) { uint32_t num = ast_random() % level->max_num; /* random number between 0 and level->max_num */ ast_debug(1, "They should totally should guess %u\n", num); /* Play the prompt */ play_files_helper(chan, cfg->global->prompt); ast_say_number(chan, level->max_num, "", ast_channel_language(chan), ""); for (guesses = 0; guesses < level->max_guesses; guesses++) { size_t buflen = log10(level->max_num) + 1; char buf[buflen]; int guess; buf[buflen] = '\0'; /* Read the number pressed */ ast_readstring(chan, buf, buflen - 1, 2000, 10000, ""); if (ast_parse_arg(buf, PARSE_INT32 | PARSE_IN_RANGE, &guess, 0, level->max_num)) { if (guesses < level->max_guesses - 1) { play_files_helper(chan, cfg->global->wrong); } continue; } /* Inform whether the guess was right, low, or high */ if (guess == num && !game->cheat) { /* win */ win = 1; play_files_helper(chan, cfg->global->right); guesses++; break; } else if (guess < num) { play_files_helper(chan, cfg->global->low); } else { play_files_helper(chan, cfg->global->high); } if (guesses < level->max_guesses - 1) { play_files_helper(chan, cfg->global->wrong); } } /* Process game stats */ ao2_lock(level->state); if (win) { ++level->state->wins; level->state->avg_guesses = ((level->state->wins - 1) * level->state->avg_guesses + guesses) / level->state->wins; } else { /* lose */ level->state->losses++; play_files_helper(chan, cfg->global->lose); } ao2_unlock(level->state); } ao2_unlink(games, game); return 0; } static struct skel_level *skel_state_alloc(const char *name) { struct skel_level *level; if (!(level = ao2_alloc(sizeof(*level), skel_state_destructor))) { return NULL; } return level; } static void *skel_level_find(struct ao2_container *tmp_container, const char *category) { return ao2_find(tmp_container, category, OBJ_KEY); } /*! \brief Look up an existing state object, or create a new one * \internal * \note Since the reload code will create a new level from scratch, it * is important for any state that must persist between reloads to be * in a separate refcounted object. This function allows the level alloc * function to get a ref to an existing state object if it exists, * otherwise it will return a reference to a newly allocated state object. */ static void *skel_find_or_create_state(const char *category) { RAII_VAR(struct skel_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup); RAII_VAR(struct skel_level *, level, NULL, ao2_cleanup); if (!cfg || !cfg->levels || !(level = ao2_find(cfg->levels, category, OBJ_KEY))) { return skel_state_alloc(category); } ao2_ref(level->state, +1); return level->state; } static void *skel_level_alloc(const char *cat) { struct skel_level *level; if (!(level = ao2_alloc(sizeof(*level), skel_level_destructor))) { return NULL; } if (ast_string_field_init(level, 128)) { ao2_ref(level, -1); return NULL; } /* Since the level has state information that needs to persist between reloads, * it is important to handle that here in the level's allocation function. * If not separated out into its own object, the data would be destroyed on * reload. */ if (!(level->state = skel_find_or_create_state(cat))) { ao2_ref(level, -1); return NULL; } ast_string_field_set(level, name, cat); return level; } static void skel_config_destructor(void *obj) { struct skel_config *cfg = obj; ao2_cleanup(cfg->global); ao2_cleanup(cfg->levels); } static void *skel_config_alloc(void) { struct skel_config *cfg; if (!(cfg = ao2_alloc(sizeof(*cfg), skel_config_destructor))) { return NULL; } /* Allocate/initialize memory */ if (!(cfg->global = ao2_alloc(sizeof(*cfg->global), skel_global_config_destructor))) { goto error; } if (ast_string_field_init(cfg->global, 128)) { goto error; } if (!(cfg->levels = ao2_container_alloc(LEVEL_BUCKETS, skel_level_hash, skel_level_cmp))) { goto error; } return cfg; error: ao2_ref(cfg, -1); return NULL; } static char *handle_skel_show_config(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { RAII_VAR(struct skel_config *, cfg, NULL, ao2_cleanup); switch(cmd) { case CLI_INIT: e->command = "skel show config"; e->usage = "Usage: skel show config\n" " List app_skel global config\n"; return NULL; case CLI_GENERATE: return NULL; } if (!(cfg = ao2_global_obj_ref(globals)) || !cfg->global) { return NULL; } ast_cli(a->fd, "games per call: %u\n", cfg->global->num_games); ast_cli(a->fd, "computer cheats: %s\n", AST_CLI_YESNO(cfg->global->cheat)); ast_cli(a->fd, "\n"); ast_cli(a->fd, "Sounds\n"); ast_cli(a->fd, " prompt: %s\n", cfg->global->prompt); ast_cli(a->fd, " wrong guess: %s\n", cfg->global->wrong); ast_cli(a->fd, " right guess: %s\n", cfg->global->right); return CLI_SUCCESS; } static char *handle_skel_show_games(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ao2_iterator iter; struct skel_current_game *game; switch(cmd) { case CLI_INIT: e->command = "skel show games"; e->usage = "Usage: skel show games\n" " List app_skel active games\n"; return NULL; case CLI_GENERATE: return NULL; } #define SKEL_FORMAT "%-15.15s %-15.15s %-15.15s\n" #define SKEL_FORMAT1 "%-15.15s %-15u %-15u\n" ast_cli(a->fd, SKEL_FORMAT, "Level", "Total Games", "Games Left"); iter = ao2_iterator_init(games, 0); while ((game = ao2_iterator_next(&iter))) { ast_cli(a->fd, SKEL_FORMAT1, game->level_info->name, game->total_games, game->games_left); ao2_ref(game, -1); } ao2_iterator_destroy(&iter); #undef SKEL_FORMAT #undef SKEL_FORMAT1 return CLI_SUCCESS; } static char *handle_skel_show_levels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { RAII_VAR(struct skel_config *, cfg, NULL, ao2_cleanup); struct ao2_iterator iter; struct skel_level *level; switch(cmd) { case CLI_INIT: e->command = "skel show levels"; e->usage = "Usage: skel show levels\n" " List the app_skel levels\n"; return NULL; case CLI_GENERATE: return NULL; } if (!(cfg = ao2_global_obj_ref(globals)) || !cfg->levels) { return NULL; } #define SKEL_FORMAT "%-15.15s %-11.11s %-12.12s %-8.8s %-8.8s %-12.12s\n" #define SKEL_FORMAT1 "%-15.15s %-11u %-12u %-8u %-8u %-8f\n" ast_cli(a->fd, SKEL_FORMAT, "Name", "Max number", "Max Guesses", "Wins", "Losses", "Avg Guesses"); iter = ao2_iterator_init(cfg->levels, 0); while ((level = ao2_iterator_next(&iter))) { ast_cli(a->fd, SKEL_FORMAT1, level->name, level->max_num, level->max_guesses, level->state->wins, level->state->losses, level->state->avg_guesses); ao2_ref(level, -1); } ao2_iterator_destroy(&iter); #undef SKEL_FORMAT #undef SKEL_FORMAT1 return CLI_SUCCESS; } static struct ast_cli_entry skel_cli[] = { AST_CLI_DEFINE(handle_skel_show_config, "Show app_skel global config options"), AST_CLI_DEFINE(handle_skel_show_levels, "Show app_skel levels"), AST_CLI_DEFINE(handle_skel_show_games, "Show app_skel active games"), }; static int reload_module(void) { if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) { return AST_MODULE_LOAD_DECLINE; } return 0; } static int unload_module(void) { ast_cli_unregister_multiple(skel_cli, ARRAY_LEN(skel_cli)); aco_info_destroy(&cfg_info); ao2_global_obj_release(globals); return ast_unregister_application(app); } static int load_module(void) { if (aco_info_init(&cfg_info)) { goto error; } if (!(games = ao2_container_alloc(1, NULL, NULL))) { goto error; } /* Global options */ aco_option_register(&cfg_info, "games", ACO_EXACT, global_options, "3", OPT_UINT_T, 0, FLDSET(struct skel_global_config, num_games)); aco_option_register_custom(&cfg_info, "cheat", ACO_EXACT, global_options, "no", custom_bitfield_handler, 0); /* Sound options */ aco_option_register(&cfg_info, "prompt", ACO_EXACT, sound_options, "please-enter-your&number&queue-less-than", OPT_STRINGFIELD_T, 0, STRFLDSET(struct skel_global_config, prompt)); aco_option_register(&cfg_info, "wrong_guess", ACO_EXACT, sound_options, "vm-pls-try-again", OPT_STRINGFIELD_T, 0, STRFLDSET(struct skel_global_config, wrong)); aco_option_register(&cfg_info, "right_guess", ACO_EXACT, sound_options, "auth-thankyou", OPT_STRINGFIELD_T, 0, STRFLDSET(struct skel_global_config, right)); aco_option_register(&cfg_info, "too_high", ACO_EXACT, sound_options, "high", OPT_STRINGFIELD_T, 0, STRFLDSET(struct skel_global_config, high)); aco_option_register(&cfg_info, "too_low", ACO_EXACT, sound_options, "low", OPT_STRINGFIELD_T, 0, STRFLDSET(struct skel_global_config, low)); aco_option_register(&cfg_info, "lose", ACO_EXACT, sound_options, "vm-goodbye", OPT_STRINGFIELD_T, 0, STRFLDSET(struct skel_global_config, lose)); /* Level options */ aco_option_register(&cfg_info, "max_number", ACO_EXACT, level_options, NULL, OPT_UINT_T, 0, FLDSET(struct skel_level, max_num)); aco_option_register(&cfg_info, "max_guesses", ACO_EXACT, level_options, NULL, OPT_UINT_T, 1, FLDSET(struct skel_level, max_guesses)); if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) { goto error; } ast_cli_register_multiple(skel_cli, ARRAY_LEN(skel_cli)); if (ast_register_application_xml(app, app_exec)) { goto error; } return AST_MODULE_LOAD_SUCCESS; error: aco_info_destroy(&cfg_info); ao2_cleanup(games); return AST_MODULE_LOAD_DECLINE; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Skeleton (sample) Application", .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_DEFAULT, ); asterisk-11.7.0/apps/app_userevent.c0000644000175000007640000000624611772123406017347 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * 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 UserEvent application -- send manager event * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 369346 $") #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/manager.h" #include "asterisk/app.h" /*** DOCUMENTATION Send an arbitrary event to the manager interface. Sends an arbitrary event to the manager interface, with an optional body representing additional arguments. The body may be specified as a , delimited list of headers. Each additional argument will be placed on a new line in the event. The format of the event will be: Event: UserEvent UserEvent: <specified event name> [body] If no body is specified, only Event and UserEvent headers will be present. ***/ static char *app = "UserEvent"; static int userevent_exec(struct ast_channel *chan, const char *data) { char *parse; int x; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(eventname); AST_APP_ARG(extra)[100]; ); struct ast_str *body = ast_str_create(16); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n"); ast_free(body); return -1; } if (!body) { ast_log(LOG_WARNING, "Unable to allocate buffer\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); for (x = 0; x < args.argc - 1; x++) { ast_str_append(&body, 0, "%s\r\n", args.extra[x]); } /*** DOCUMENTATION A user defined event raised from the dialplan. The event name, as specified in the dialplan. UserEvent ***/ manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n" "Uniqueid: %s\r\n" "%s", args.eventname, ast_channel_uniqueid(chan), ast_str_buffer(body)); ast_free(body); return 0; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, userevent_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Custom User Event Application"); asterisk-11.7.0/apps/app_softhangup.c0000644000175000007640000000711411720555237017504 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 SoftHangup application * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356042 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/app.h" /*** DOCUMENTATION Hangs up the requested channel. Hangs up the requested channel. If there are no channels to hangup, the application will report it. ***/ static char *app = "SoftHangup"; enum { OPTION_ALL = (1 << 0), }; AST_APP_OPTIONS(app_opts,{ AST_APP_OPTION('a', OPTION_ALL), }); static int softhangup_exec(struct ast_channel *chan, const char *data) { struct ast_channel *c = NULL; char *cut, *opts[0]; char name[AST_CHANNEL_NAME] = "", *parse; struct ast_flags flags = {0}; int lenmatch; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(channel); AST_APP_ARG(options); ); struct ast_channel_iterator *iter; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n"); return 0; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (args.argc == 2) ast_app_parse_options(app_opts, &flags, opts, args.options); lenmatch = strlen(args.channel); if (!(iter = ast_channel_iterator_by_name_new(args.channel, lenmatch))) { return -1; } while ((c = ast_channel_iterator_next(iter))) { ast_channel_lock(c); ast_copy_string(name, ast_channel_name(c), sizeof(name)); if (ast_test_flag(&flags, OPTION_ALL)) { /* CAPI is set up like CAPI[foo/bar]/clcnt */ if (!strcmp(ast_channel_tech(c)->type, "CAPI")) { cut = strrchr(name, '/'); /* Basically everything else is Foo/Bar-Z */ } else { /* use strrchr() because Foo/Bar-Z could actually be Foo/B-a-r-Z */ cut = strrchr(name,'-'); } /* Get rid of what we've cut */ if (cut) *cut = 0; } if (!strcasecmp(name, args.channel)) { ast_log(LOG_WARNING, "Soft hanging %s up.\n", ast_channel_name(c)); ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); if (!ast_test_flag(&flags, OPTION_ALL)) { ast_channel_unlock(c); c = ast_channel_unref(c); break; } } ast_channel_unlock(c); c = ast_channel_unref(c); } ast_channel_iterator_destroy(iter); return 0; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, softhangup_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Hangs up the requested channel"); asterisk-11.7.0/apps/app_dial.c0000644000175000007640000035641312111710653016236 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2008, Digium, Inc. * * Mark Spencer * * 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 dial() & retrydial() - Trivial application to dial a channel and send an URL on answer * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO chan_local core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 381880 $") #include #include #include #include #include "asterisk/paths.h" /* use ast_config_AST_DATA_DIR */ #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/say.h" #include "asterisk/config.h" #include "asterisk/features.h" #include "asterisk/musiconhold.h" #include "asterisk/callerid.h" #include "asterisk/utils.h" #include "asterisk/app.h" #include "asterisk/causes.h" #include "asterisk/rtp_engine.h" #include "asterisk/cdr.h" #include "asterisk/manager.h" #include "asterisk/privacy.h" #include "asterisk/stringfields.h" #include "asterisk/global_datastores.h" #include "asterisk/dsp.h" #include "asterisk/cel.h" #include "asterisk/aoc.h" #include "asterisk/ccss.h" #include "asterisk/indications.h" #include "asterisk/framehook.h" /*** DOCUMENTATION Attempt to connect to another device or endpoint and bridge the call. Specification of the device(s) to dial. These must be in the format of Technology/Resource, where Technology represents a particular channel driver, and Resource represents a resource available to that particular channel driver. Optional extra devices to dial in parallel If you need more then one enter them as Technology2/Resource2&Technology3/Resourse3&..... Specifies the number of seconds we attempt to dial the specified devices If not specified, this defaults to 136 years. The optional URL will be sent to the called party if the channel driver supports it. This application will place calls to one or more specified channels. As soon as one of the requested channels answers, the originating channel will be answered, if it has not already been answered. These two channels will then be active in a bridged call. All other channels that were requested will then be hung up. Unless there is a timeout specified, the Dial application will wait indefinitely until one of the called channels answers, the user hangs up, or if all of the called channels are busy or unavailable. Dialplan executing will continue if no requested channels can be called, or if the timeout expires. This application will report normal termination if the originating channel hangs up, or if the call is bridged and either of the parties in the bridge ends the call. If the OUTBOUND_GROUP variable is set, all peer channels created by this application will be put into that group (as in Set(GROUP()=...). If the OUTBOUND_GROUP_ONCE variable is set, all peer channels created by this application will be put into that group (as in Set(GROUP()=...). Unlike OUTBOUND_GROUP, however, the variable will be unset after use. This application sets the following channel variables: This is the time from dialing a channel until when it is disconnected. This is the amount of time for actual call. This is the status of the call For the Privacy and Screening Modes. Will be set if the called party chooses to send the calling party to the 'Go Away' script. For the Privacy and Screening Modes. Will be set if the called party chooses to send the calling party to the 'torture' script. Place a call, retrying on failure allowing an optional exit extension. Filename of sound that will be played when no channel can be reached Number of seconds to wait after a dial attempt failed before a new attempt is made Number of retries When this is reached flow will continue at the next priority in the dialplan Same format as arguments provided to the Dial application This application will attempt to place a call using the normal Dial application. If no channel can be reached, the announce file will be played. Then, it will wait sleep number of seconds before retrying the call. After retries number of attempts, the calling channel will continue at the next priority in the dialplan. If the retries setting is set to 0, this application will retry endlessly. While waiting to retry a call, a 1 digit extension may be dialed. If that extension exists in either the context defined in EXITCONTEXT or the current one, The call will jump to that extension immediately. The dialargs are specified in the same format that arguments are provided to the Dial application. ***/ static const char app[] = "Dial"; static const char rapp[] = "RetryDial"; enum { OPT_ANNOUNCE = (1 << 0), OPT_RESETCDR = (1 << 1), OPT_DTMF_EXIT = (1 << 2), OPT_SENDDTMF = (1 << 3), OPT_FORCECLID = (1 << 4), OPT_GO_ON = (1 << 5), OPT_CALLEE_HANGUP = (1 << 6), OPT_CALLER_HANGUP = (1 << 7), OPT_ORIGINAL_CLID = (1 << 8), OPT_DURATION_LIMIT = (1 << 9), OPT_MUSICBACK = (1 << 10), OPT_CALLEE_MACRO = (1 << 11), OPT_SCREEN_NOINTRO = (1 << 12), OPT_SCREEN_NOCALLERID = (1 << 13), OPT_IGNORE_CONNECTEDLINE = (1 << 14), OPT_SCREENING = (1 << 15), OPT_PRIVACY = (1 << 16), OPT_RINGBACK = (1 << 17), OPT_DURATION_STOP = (1 << 18), OPT_CALLEE_TRANSFER = (1 << 19), OPT_CALLER_TRANSFER = (1 << 20), OPT_CALLEE_MONITOR = (1 << 21), OPT_CALLER_MONITOR = (1 << 22), OPT_GOTO = (1 << 23), OPT_OPERMODE = (1 << 24), OPT_CALLEE_PARK = (1 << 25), OPT_CALLER_PARK = (1 << 26), OPT_IGNORE_FORWARDING = (1 << 27), OPT_CALLEE_GOSUB = (1 << 28), OPT_CALLEE_MIXMONITOR = (1 << 29), OPT_CALLER_MIXMONITOR = (1 << 30), }; /* flags are now 64 bits, so keep it up! */ #define DIAL_STILLGOING (1LLU << 31) #define DIAL_NOFORWARDHTML (1LLU << 32) #define DIAL_CALLERID_ABSENT (1LLU << 33) /* TRUE if caller id is not available for connected line. */ #define OPT_CANCEL_ELSEWHERE (1LLU << 34) #define OPT_PEER_H (1LLU << 35) #define OPT_CALLEE_GO_ON (1LLU << 36) #define OPT_CANCEL_TIMEOUT (1LLU << 37) #define OPT_FORCE_CID_TAG (1LLU << 38) #define OPT_FORCE_CID_PRES (1LLU << 39) #define OPT_CALLER_ANSWER (1LLU << 40) #define OPT_PREDIAL_CALLEE (1LLU << 41) #define OPT_PREDIAL_CALLER (1LLU << 42) enum { OPT_ARG_ANNOUNCE = 0, OPT_ARG_SENDDTMF, OPT_ARG_GOTO, OPT_ARG_DURATION_LIMIT, OPT_ARG_MUSICBACK, OPT_ARG_CALLEE_MACRO, OPT_ARG_RINGBACK, OPT_ARG_CALLEE_GOSUB, OPT_ARG_CALLEE_GO_ON, OPT_ARG_PRIVACY, OPT_ARG_DURATION_STOP, OPT_ARG_OPERMODE, OPT_ARG_SCREEN_NOINTRO, OPT_ARG_ORIGINAL_CLID, OPT_ARG_FORCECLID, OPT_ARG_FORCE_CID_TAG, OPT_ARG_FORCE_CID_PRES, OPT_ARG_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLER, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE, }; AST_APP_OPTIONS(dial_exec_options, BEGIN_OPTIONS AST_APP_OPTION_ARG('A', OPT_ANNOUNCE, OPT_ARG_ANNOUNCE), AST_APP_OPTION('a', OPT_CALLER_ANSWER), AST_APP_OPTION_ARG('b', OPT_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLEE), AST_APP_OPTION_ARG('B', OPT_PREDIAL_CALLER, OPT_ARG_PREDIAL_CALLER), AST_APP_OPTION('C', OPT_RESETCDR), AST_APP_OPTION('c', OPT_CANCEL_ELSEWHERE), AST_APP_OPTION('d', OPT_DTMF_EXIT), AST_APP_OPTION_ARG('D', OPT_SENDDTMF, OPT_ARG_SENDDTMF), AST_APP_OPTION('e', OPT_PEER_H), AST_APP_OPTION_ARG('f', OPT_FORCECLID, OPT_ARG_FORCECLID), AST_APP_OPTION_ARG('F', OPT_CALLEE_GO_ON, OPT_ARG_CALLEE_GO_ON), AST_APP_OPTION('g', OPT_GO_ON), AST_APP_OPTION_ARG('G', OPT_GOTO, OPT_ARG_GOTO), AST_APP_OPTION('h', OPT_CALLEE_HANGUP), AST_APP_OPTION('H', OPT_CALLER_HANGUP), AST_APP_OPTION('i', OPT_IGNORE_FORWARDING), AST_APP_OPTION('I', OPT_IGNORE_CONNECTEDLINE), AST_APP_OPTION('k', OPT_CALLEE_PARK), AST_APP_OPTION('K', OPT_CALLER_PARK), AST_APP_OPTION_ARG('L', OPT_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT), AST_APP_OPTION_ARG('m', OPT_MUSICBACK, OPT_ARG_MUSICBACK), AST_APP_OPTION_ARG('M', OPT_CALLEE_MACRO, OPT_ARG_CALLEE_MACRO), AST_APP_OPTION_ARG('n', OPT_SCREEN_NOINTRO, OPT_ARG_SCREEN_NOINTRO), AST_APP_OPTION('N', OPT_SCREEN_NOCALLERID), AST_APP_OPTION_ARG('o', OPT_ORIGINAL_CLID, OPT_ARG_ORIGINAL_CLID), AST_APP_OPTION_ARG('O', OPT_OPERMODE, OPT_ARG_OPERMODE), AST_APP_OPTION('p', OPT_SCREENING), AST_APP_OPTION_ARG('P', OPT_PRIVACY, OPT_ARG_PRIVACY), AST_APP_OPTION_ARG('r', OPT_RINGBACK, OPT_ARG_RINGBACK), AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP), AST_APP_OPTION_ARG('s', OPT_FORCE_CID_TAG, OPT_ARG_FORCE_CID_TAG), AST_APP_OPTION('t', OPT_CALLEE_TRANSFER), AST_APP_OPTION('T', OPT_CALLER_TRANSFER), AST_APP_OPTION_ARG('u', OPT_FORCE_CID_PRES, OPT_ARG_FORCE_CID_PRES), AST_APP_OPTION_ARG('U', OPT_CALLEE_GOSUB, OPT_ARG_CALLEE_GOSUB), AST_APP_OPTION('w', OPT_CALLEE_MONITOR), AST_APP_OPTION('W', OPT_CALLER_MONITOR), AST_APP_OPTION('x', OPT_CALLEE_MIXMONITOR), AST_APP_OPTION('X', OPT_CALLER_MIXMONITOR), AST_APP_OPTION('z', OPT_CANCEL_TIMEOUT), END_OPTIONS ); #define CAN_EARLY_BRIDGE(flags,chan,peer) (!ast_test_flag64(flags, OPT_CALLEE_HANGUP | \ OPT_CALLER_HANGUP | OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER | \ OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK | \ OPT_CALLER_PARK | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB) && \ !ast_channel_audiohooks(chan) && !ast_channel_audiohooks(peer) && \ ast_framehook_list_is_empty(ast_channel_framehooks(chan)) && ast_framehook_list_is_empty(ast_channel_framehooks(peer))) /* * The list of active channels */ struct chanlist { AST_LIST_ENTRY(chanlist) node; struct ast_channel *chan; /*! Channel interface dialing string (is tech/number). (Stored in stuff[]) */ const char *interface; /*! Channel technology name. (Stored in stuff[]) */ const char *tech; /*! Channel device addressing. (Stored in stuff[]) */ const char *number; uint64_t flags; /*! Saved connected party info from an AST_CONTROL_CONNECTED_LINE. */ struct ast_party_connected_line connected; /*! TRUE if an AST_CONTROL_CONNECTED_LINE update was saved to the connected element. */ unsigned int pending_connected_update:1; struct ast_aoc_decoded *aoc_s_rate_list; /*! The interface, tech, and number strings are stuffed here. */ char stuff[0]; }; AST_LIST_HEAD_NOLOCK(dial_head, chanlist); static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode); static void chanlist_free(struct chanlist *outgoing) { ast_party_connected_line_free(&outgoing->connected); ast_aoc_destroy_decoded(outgoing->aoc_s_rate_list); ast_free(outgoing); } static void hanguptree(struct dial_head *out_chans, struct ast_channel *exception, int answered_elsewhere) { /* Hang up a tree of stuff */ struct chanlist *outgoing; while ((outgoing = AST_LIST_REMOVE_HEAD(out_chans, node))) { /* Hangup any existing lines we have open */ if (outgoing->chan && (outgoing->chan != exception)) { if (answered_elsewhere) { /* This is for the channel drivers */ ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } ast_hangup(outgoing->chan); } chanlist_free(outgoing); } } #define AST_MAX_WATCHERS 256 /* * argument to handle_cause() and other functions. */ struct cause_args { struct ast_channel *chan; int busy; int congestion; int nochan; }; static void handle_cause(int cause, struct cause_args *num) { struct ast_cdr *cdr = ast_channel_cdr(num->chan); switch(cause) { case AST_CAUSE_BUSY: if (cdr) ast_cdr_busy(cdr); num->busy++; break; case AST_CAUSE_CONGESTION: if (cdr) ast_cdr_failed(cdr); num->congestion++; break; case AST_CAUSE_NO_ROUTE_DESTINATION: case AST_CAUSE_UNREGISTERED: if (cdr) ast_cdr_failed(cdr); num->nochan++; break; case AST_CAUSE_NO_ANSWER: if (cdr) { ast_cdr_noanswer(cdr); } break; case AST_CAUSE_NORMAL_CLEARING: break; default: num->nochan++; break; } } static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri) { char rexten[2] = { exten, '\0' }; if (context) { if (!ast_goto_if_exists(chan, context, rexten, pri)) return 1; } else { if (!ast_goto_if_exists(chan, ast_channel_context(chan), rexten, pri)) return 1; else if (!ast_strlen_zero(ast_channel_macrocontext(chan))) { if (!ast_goto_if_exists(chan, ast_channel_macrocontext(chan), rexten, pri)) return 1; } } return 0; } /* do not call with chan lock held */ static const char *get_cid_name(char *name, int namelen, struct ast_channel *chan) { const char *context; const char *exten; ast_channel_lock(chan); context = ast_strdupa(S_OR(ast_channel_macrocontext(chan), ast_channel_context(chan))); exten = ast_strdupa(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))); ast_channel_unlock(chan); return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : ""; } static void senddialevent(struct ast_channel *src, struct ast_channel *dst, const char *dialstring) { struct ast_channel *chans[] = { src, dst }; /*** DOCUMENTATION Raised when a dial action has started. A sub event type, specifying whether the dial action has begun or ended. ***/ ast_manager_event_multichan(EVENT_FLAG_CALL, "Dial", 2, chans, "SubEvent: Begin\r\n" "Channel: %s\r\n" "Destination: %s\r\n" "CallerIDNum: %s\r\n" "CallerIDName: %s\r\n" "ConnectedLineNum: %s\r\n" "ConnectedLineName: %s\r\n" "UniqueID: %s\r\n" "DestUniqueID: %s\r\n" "Dialstring: %s\r\n", ast_channel_name(src), ast_channel_name(dst), S_COR(ast_channel_caller(src)->id.number.valid, ast_channel_caller(src)->id.number.str, ""), S_COR(ast_channel_caller(src)->id.name.valid, ast_channel_caller(src)->id.name.str, ""), S_COR(ast_channel_connected(src)->id.number.valid, ast_channel_connected(src)->id.number.str, ""), S_COR(ast_channel_connected(src)->id.name.valid, ast_channel_connected(src)->id.name.str, ""), ast_channel_uniqueid(src), ast_channel_uniqueid(dst), dialstring ? dialstring : ""); } static void senddialendevent(struct ast_channel *src, const char *dialstatus) { /*** DOCUMENTATION Raised when a dial action has ended. The value of the DIALSTATUS channel variable. ***/ ast_manager_event(src, EVENT_FLAG_CALL, "Dial", "SubEvent: End\r\n" "Channel: %s\r\n" "UniqueID: %s\r\n" "DialStatus: %s\r\n", ast_channel_name(src), ast_channel_uniqueid(src), dialstatus); } /*! * helper function for wait_for_answer() * * \param o Outgoing call channel list. * \param num Incoming call channel cause accumulation * \param peerflags Dial option flags * \param single TRUE if there is only one outgoing call. * \param caller_entertained TRUE if the caller is being entertained by MOH or ringback. * \param to Remaining call timeout time. * \param forced_clid OPT_FORCECLID caller id to send * \param stored_clid Caller id representing the called party if needed * * XXX this code is highly suspicious, as it essentially overwrites * the outgoing channel without properly deleting it. * * \todo eventually this function should be intergrated into and replaced by ast_call_forward() */ static void do_forward(struct chanlist *o, struct cause_args *num, struct ast_flags64 *peerflags, int single, int caller_entertained, int *to, struct ast_party_id *forced_clid, struct ast_party_id *stored_clid) { char tmpchan[256]; struct ast_channel *original = o->chan; struct ast_channel *c = o->chan; /* the winner */ struct ast_channel *in = num->chan; /* the input channel */ char *stuff; char *tech; int cause; struct ast_party_caller caller; ast_copy_string(tmpchan, ast_channel_call_forward(c), sizeof(tmpchan)); if ((stuff = strchr(tmpchan, '/'))) { *stuff++ = '\0'; tech = tmpchan; } else { const char *forward_context; ast_channel_lock(c); forward_context = pbx_builtin_getvar_helper(c, "FORWARD_CONTEXT"); if (ast_strlen_zero(forward_context)) { forward_context = NULL; } snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(c), forward_context ? forward_context : ast_channel_context(c)); ast_channel_unlock(c); stuff = tmpchan; tech = "Local"; } if (!strcasecmp(tech, "Local")) { /* * Drop the connected line update block for local channels since * this is going to run dialplan and the user can change his * mind about what connected line information he wants to send. */ ast_clear_flag64(o, OPT_IGNORE_CONNECTEDLINE); } ast_cel_report_event(in, AST_CEL_FORWARD, NULL, ast_channel_call_forward(c), NULL); /* Before processing channel, go ahead and check for forwarding */ ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", ast_channel_name(in), tech, stuff, ast_channel_name(c)); /* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */ if (ast_test_flag64(peerflags, OPT_IGNORE_FORWARDING)) { ast_verb(3, "Forwarding %s to '%s/%s' prevented.\n", ast_channel_name(in), tech, stuff); c = o->chan = NULL; cause = AST_CAUSE_BUSY; } else { /* Setup parameters */ c = o->chan = ast_request(tech, ast_channel_nativeformats(in), in, stuff, &cause); if (c) { if (single && !caller_entertained) { ast_channel_make_compatible(o->chan, in); } ast_channel_lock_both(in, o->chan); ast_channel_inherit_variables(in, o->chan); ast_channel_datastore_inherit(in, o->chan); ast_channel_unlock(in); ast_channel_unlock(o->chan); /* When a call is forwarded, we don't want to track new interfaces * dialed for CC purposes. Setting the done flag will ensure that * any Dial operations that happen later won't record CC interfaces. */ ast_ignore_cc(o->chan); ast_log(LOG_NOTICE, "Not accepting call completion offers from call-forward recipient %s\n", ast_channel_name(o->chan)); } else ast_log(LOG_NOTICE, "Forwarding failed to create channel to dial '%s/%s' (cause = %d)\n", tech, stuff, cause); } if (!c) { ast_clear_flag64(o, DIAL_STILLGOING); handle_cause(cause, num); ast_hangup(original); } else { ast_channel_lock_both(c, original); ast_party_redirecting_copy(ast_channel_redirecting(c), ast_channel_redirecting(original)); ast_channel_unlock(c); ast_channel_unlock(original); ast_channel_lock_both(c, in); if (single && !caller_entertained && CAN_EARLY_BRIDGE(peerflags, c, in)) { ast_rtp_instance_early_bridge_make_compatible(c, in); } if (!ast_channel_redirecting(c)->from.number.valid || ast_strlen_zero(ast_channel_redirecting(c)->from.number.str)) { /* * The call was not previously redirected so it is * now redirected from this number. */ ast_party_number_free(&ast_channel_redirecting(c)->from.number); ast_party_number_init(&ast_channel_redirecting(c)->from.number); ast_channel_redirecting(c)->from.number.valid = 1; ast_channel_redirecting(c)->from.number.str = ast_strdup(S_OR(ast_channel_macroexten(in), ast_channel_exten(in))); } ast_channel_dialed(c)->transit_network_select = ast_channel_dialed(in)->transit_network_select; /* Determine CallerID to store in outgoing channel. */ ast_party_caller_set_init(&caller, ast_channel_caller(c)); if (ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) { caller.id = *stored_clid; ast_channel_set_caller_event(c, &caller, NULL); ast_set_flag64(o, DIAL_CALLERID_ABSENT); } else if (ast_strlen_zero(S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, NULL))) { /* * The new channel has no preset CallerID number by the channel * driver. Use the dialplan extension and hint name. */ caller.id = *stored_clid; ast_channel_set_caller_event(c, &caller, NULL); ast_set_flag64(o, DIAL_CALLERID_ABSENT); } else { ast_clear_flag64(o, DIAL_CALLERID_ABSENT); } /* Determine CallerID for outgoing channel to send. */ if (ast_test_flag64(o, OPT_FORCECLID)) { struct ast_party_connected_line connected; ast_party_connected_line_init(&connected); connected.id = *forced_clid; ast_party_connected_line_copy(ast_channel_connected(c), &connected); } else { ast_connected_line_copy_from_caller(ast_channel_connected(c), ast_channel_caller(in)); } ast_channel_accountcode_set(c, ast_channel_accountcode(in)); ast_channel_appl_set(c, "AppDial"); ast_channel_data_set(c, "(Outgoing Line)"); ast_channel_unlock(in); if (single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) { struct ast_party_redirecting redirecting; /* * Redirecting updates to the caller make sense only on single * calls. * * We must unlock c before calling * ast_channel_redirecting_macro, because we put c into * autoservice there. That is pretty much a guaranteed * deadlock. This is why the handling of c's lock may seem a * bit unusual here. */ ast_party_redirecting_init(&redirecting); ast_party_redirecting_copy(&redirecting, ast_channel_redirecting(c)); ast_channel_unlock(c); if (ast_channel_redirecting_sub(c, in, &redirecting, 0) && ast_channel_redirecting_macro(c, in, &redirecting, 1, 0)) { ast_channel_update_redirecting(in, &redirecting, NULL); } ast_party_redirecting_free(&redirecting); } else { ast_channel_unlock(c); } if (ast_test_flag64(peerflags, OPT_CANCEL_TIMEOUT)) { *to = -1; } if (ast_call(c, stuff, 0)) { ast_log(LOG_NOTICE, "Forwarding failed to dial '%s/%s'\n", tech, stuff); ast_clear_flag64(o, DIAL_STILLGOING); ast_hangup(original); ast_hangup(c); c = o->chan = NULL; num->nochan++; } else { ast_channel_lock_both(c, in); senddialevent(in, c, stuff); ast_channel_unlock(in); ast_channel_unlock(c); /* Hangup the original channel now, in case we needed it */ ast_hangup(original); } if (single && !caller_entertained) { ast_indicate(in, -1); } } } /* argument used for some functions. */ struct privacy_args { int sentringing; int privdb_val; char privcid[256]; char privintro[1024]; char status[256]; }; static struct ast_channel *wait_for_answer(struct ast_channel *in, struct dial_head *out_chans, int *to, struct ast_flags64 *peerflags, char *opt_args[], struct privacy_args *pa, const struct cause_args *num_in, int *result, char *dtmf_progress, const int ignore_cc, struct ast_party_id *forced_clid, struct ast_party_id *stored_clid) { struct cause_args num = *num_in; int prestart = num.busy + num.congestion + num.nochan; int orig = *to; struct ast_channel *peer = NULL; #ifdef HAVE_EPOLL struct chanlist *epollo; #endif struct chanlist *outgoing = AST_LIST_FIRST(out_chans); /* single is set if only one destination is enabled */ int single = outgoing && !AST_LIST_NEXT(outgoing, node); int caller_entertained = outgoing && ast_test_flag64(outgoing, OPT_MUSICBACK | OPT_RINGBACK); struct ast_party_connected_line connected_caller; struct ast_str *featurecode = ast_str_alloca(FEATURE_MAX_LEN + 1); int cc_recall_core_id; int is_cc_recall; int cc_frame_received = 0; int num_ringing = 0; struct timeval start = ast_tvnow(); ast_party_connected_line_init(&connected_caller); if (single) { /* Turn off hold music, etc */ if (!caller_entertained) { ast_deactivate_generator(in); /* If we are calling a single channel, and not providing ringback or music, */ /* then, make them compatible for in-band tone purpose */ if (ast_channel_make_compatible(outgoing->chan, in) < 0) { /* If these channels can not be made compatible, * there is no point in continuing. The bridge * will just fail if it gets that far. */ *to = -1; strcpy(pa->status, "CONGESTION"); ast_cdr_failed(ast_channel_cdr(in)); return NULL; } } if (!ast_test_flag64(outgoing, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(outgoing, DIAL_CALLERID_ABSENT)) { ast_channel_lock(outgoing->chan); ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(outgoing->chan)); ast_channel_unlock(outgoing->chan); connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; if (ast_channel_connected_line_sub(outgoing->chan, in, &connected_caller, 0) && ast_channel_connected_line_macro(outgoing->chan, in, &connected_caller, 1, 0)) { ast_channel_update_connected_line(in, &connected_caller, NULL); } ast_party_connected_line_free(&connected_caller); } } is_cc_recall = ast_cc_is_recall(in, &cc_recall_core_id, NULL); #ifdef HAVE_EPOLL AST_LIST_TRAVERSE(out_chans, epollo, node) { ast_poll_channel_add(in, epollo->chan); } #endif while ((*to = ast_remaining_ms(start, orig)) && !peer) { struct chanlist *o; int pos = 0; /* how many channels do we handle */ int numlines = prestart; struct ast_channel *winner; struct ast_channel *watchers[AST_MAX_WATCHERS]; watchers[pos++] = in; AST_LIST_TRAVERSE(out_chans, o, node) { /* Keep track of important channels */ if (ast_test_flag64(o, DIAL_STILLGOING) && o->chan) watchers[pos++] = o->chan; numlines++; } if (pos == 1) { /* only the input channel is available */ if (numlines == (num.busy + num.congestion + num.nochan)) { ast_verb(2, "Everyone is busy/congested at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan); if (num.busy) strcpy(pa->status, "BUSY"); else if (num.congestion) strcpy(pa->status, "CONGESTION"); else if (num.nochan) strcpy(pa->status, "CHANUNAVAIL"); } else { ast_verb(3, "No one is available to answer at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan); } *to = 0; if (is_cc_recall) { ast_cc_failed(cc_recall_core_id, "Everyone is busy/congested for the recall. How sad"); } return NULL; } winner = ast_waitfor_n(watchers, pos, to); AST_LIST_TRAVERSE(out_chans, o, node) { struct ast_frame *f; struct ast_channel *c = o->chan; if (c == NULL) continue; if (ast_test_flag64(o, DIAL_STILLGOING) && ast_channel_state(c) == AST_STATE_UP) { if (!peer) { ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in)); if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) { if (o->pending_connected_update) { if (ast_channel_connected_line_sub(c, in, &o->connected, 0) && ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) { ast_channel_update_connected_line(in, &o->connected, NULL); } } else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) { ast_channel_lock(c); ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(c)); ast_channel_unlock(c); connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; if (ast_channel_connected_line_sub(c, in, &connected_caller, 0) && ast_channel_connected_line_macro(c, in, &connected_caller, 1, 0)) { ast_channel_update_connected_line(in, &connected_caller, NULL); } ast_party_connected_line_free(&connected_caller); } } if (o->aoc_s_rate_list) { size_t encoded_size; struct ast_aoc_encoded *encoded; if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) { ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size); ast_aoc_destroy_encoded(encoded); } } peer = c; ast_copy_flags64(peerflags, o, OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER | OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP | OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK | OPT_CALLER_PARK | OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR | DIAL_NOFORWARDHTML); ast_channel_dialcontext_set(c, ""); ast_channel_exten_set(c, ""); } continue; } if (c != winner) continue; /* here, o->chan == c == winner */ if (!ast_strlen_zero(ast_channel_call_forward(c))) { pa->sentringing = 0; if (!ignore_cc && (f = ast_read(c))) { if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_CC) { /* This channel is forwarding the call, and is capable of CC, so * be sure to add the new device interface to the list */ ast_handle_cc_control_frame(in, c, f->data.ptr); } ast_frfree(f); } if (o->pending_connected_update) { /* * Re-seed the chanlist's connected line information with * previously acquired connected line info from the incoming * channel. The previously acquired connected line info could * have been set through the CONNECTED_LINE dialplan function. */ o->pending_connected_update = 0; ast_channel_lock(in); ast_party_connected_line_copy(&o->connected, ast_channel_connected(in)); ast_channel_unlock(in); } do_forward(o, &num, peerflags, single, caller_entertained, to, forced_clid, stored_clid); if (single && o->chan && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(o, DIAL_CALLERID_ABSENT)) { ast_channel_lock(o->chan); ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(o->chan)); ast_channel_unlock(o->chan); connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; if (ast_channel_connected_line_sub(o->chan, in, &connected_caller, 0) && ast_channel_connected_line_macro(o->chan, in, &connected_caller, 1, 0)) { ast_channel_update_connected_line(in, &connected_caller, NULL); } ast_party_connected_line_free(&connected_caller); } continue; } f = ast_read(winner); if (!f) { ast_channel_hangupcause_set(in, ast_channel_hangupcause(c)); #ifdef HAVE_EPOLL ast_poll_channel_del(in, c); #endif ast_hangup(c); c = o->chan = NULL; ast_clear_flag64(o, DIAL_STILLGOING); handle_cause(ast_channel_hangupcause(in), &num); continue; } switch (f->frametype) { case AST_FRAME_CONTROL: switch (f->subclass.integer) { case AST_CONTROL_ANSWER: /* This is our guy if someone answered. */ if (!peer) { ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in)); if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) { if (o->pending_connected_update) { if (ast_channel_connected_line_sub(c, in, &o->connected, 0) && ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) { ast_channel_update_connected_line(in, &o->connected, NULL); } } else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) { ast_channel_lock(c); ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(c)); ast_channel_unlock(c); connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; if (ast_channel_connected_line_sub(c, in, &connected_caller, 0) && ast_channel_connected_line_macro(c, in, &connected_caller, 1, 0)) { ast_channel_update_connected_line(in, &connected_caller, NULL); } ast_party_connected_line_free(&connected_caller); } } if (o->aoc_s_rate_list) { size_t encoded_size; struct ast_aoc_encoded *encoded; if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) { ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size); ast_aoc_destroy_encoded(encoded); } } peer = c; if (ast_channel_cdr(peer)) { ast_channel_cdr(peer)->answer = ast_tvnow(); ast_channel_cdr(peer)->disposition = AST_CDR_ANSWERED; } ast_copy_flags64(peerflags, o, OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER | OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP | OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK | OPT_CALLER_PARK | OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR | DIAL_NOFORWARDHTML); ast_channel_dialcontext_set(c, ""); ast_channel_exten_set(c, ""); if (CAN_EARLY_BRIDGE(peerflags, in, peer)) /* Setup early bridge if appropriate */ ast_channel_early_bridge(in, peer); } /* If call has been answered, then the eventual hangup is likely to be normal hangup */ ast_channel_hangupcause_set(in, AST_CAUSE_NORMAL_CLEARING); ast_channel_hangupcause_set(c, AST_CAUSE_NORMAL_CLEARING); break; case AST_CONTROL_BUSY: ast_verb(3, "%s is busy\n", ast_channel_name(c)); ast_channel_hangupcause_set(in, ast_channel_hangupcause(c)); ast_hangup(c); c = o->chan = NULL; ast_clear_flag64(o, DIAL_STILLGOING); handle_cause(AST_CAUSE_BUSY, &num); break; case AST_CONTROL_CONGESTION: ast_verb(3, "%s is circuit-busy\n", ast_channel_name(c)); ast_channel_hangupcause_set(in, ast_channel_hangupcause(c)); ast_hangup(c); c = o->chan = NULL; ast_clear_flag64(o, DIAL_STILLGOING); handle_cause(AST_CAUSE_CONGESTION, &num); break; case AST_CONTROL_RINGING: /* This is a tricky area to get right when using a native * CC agent. The reason is that we do the best we can to send only a * single ringing notification to the caller. * * Call completion complicates the logic used here. CCNR is typically * offered during a ringing message. Let's say that party A calls * parties B, C, and D. B and C do not support CC requests, but D * does. If we were to receive a ringing notification from B before * the others, then we would end up sending a ringing message to * A with no CCNR offer present. * * The approach that we have taken is that if we receive a ringing * response from a party and no CCNR offer is present, we need to * wait. Specifically, we need to wait until either a) a called party * offers CCNR in its ringing response or b) all called parties have * responded in some way to our call and none offers CCNR. * * The drawback to this is that if one of the parties has a delayed * response or, god forbid, one just plain doesn't respond to our * outgoing call, then this will result in a significant delay between * when the caller places the call and hears ringback. * * Note also that if CC is disabled for this call, then it is perfectly * fine for ringing frames to get sent through. */ ++num_ringing; if (ignore_cc || cc_frame_received || num_ringing == numlines) { ast_verb(3, "%s is ringing\n", ast_channel_name(c)); /* Setup early media if appropriate */ if (single && !caller_entertained && CAN_EARLY_BRIDGE(peerflags, in, c)) { ast_channel_early_bridge(in, c); } if (!(pa->sentringing) && !ast_test_flag64(outgoing, OPT_MUSICBACK) && ast_strlen_zero(opt_args[OPT_ARG_RINGBACK])) { ast_indicate(in, AST_CONTROL_RINGING); pa->sentringing++; } } break; case AST_CONTROL_PROGRESS: ast_verb(3, "%s is making progress passing it to %s\n", ast_channel_name(c), ast_channel_name(in)); /* Setup early media if appropriate */ if (single && !caller_entertained && CAN_EARLY_BRIDGE(peerflags, in, c)) { ast_channel_early_bridge(in, c); } if (!ast_test_flag64(outgoing, OPT_RINGBACK)) { if (single || (!single && !pa->sentringing)) { ast_indicate(in, AST_CONTROL_PROGRESS); } } if (!ast_strlen_zero(dtmf_progress)) { ast_verb(3, "Sending DTMF '%s' to the called party as result of receiving a PROGRESS message.\n", dtmf_progress); ast_dtmf_stream(c, in, dtmf_progress, 250, 0); } break; case AST_CONTROL_VIDUPDATE: case AST_CONTROL_SRCUPDATE: case AST_CONTROL_SRCCHANGE: if (!single || caller_entertained) { break; } ast_verb(3, "%s requested media update control %d, passing it to %s\n", ast_channel_name(c), f->subclass.integer, ast_channel_name(in)); ast_indicate(in, f->subclass.integer); break; case AST_CONTROL_CONNECTED_LINE: if (ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) { ast_verb(3, "Connected line update to %s prevented.\n", ast_channel_name(in)); break; } if (!single) { struct ast_party_connected_line connected; ast_verb(3, "%s connected line has changed. Saving it until answer for %s\n", ast_channel_name(c), ast_channel_name(in)); ast_party_connected_line_set_init(&connected, &o->connected); ast_connected_line_parse_data(f->data.ptr, f->datalen, &connected); ast_party_connected_line_set(&o->connected, &connected, NULL); ast_party_connected_line_free(&connected); o->pending_connected_update = 1; break; } if (ast_channel_connected_line_sub(c, in, f, 1) && ast_channel_connected_line_macro(c, in, f, 1, 1)) { ast_indicate_data(in, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen); } break; case AST_CONTROL_AOC: { struct ast_aoc_decoded *decoded = ast_aoc_decode(f->data.ptr, f->datalen, o->chan); if (decoded && (ast_aoc_get_msg_type(decoded) == AST_AOC_S)) { ast_aoc_destroy_decoded(o->aoc_s_rate_list); o->aoc_s_rate_list = decoded; } else { ast_aoc_destroy_decoded(decoded); } } break; case AST_CONTROL_REDIRECTING: if (!single) { /* * Redirecting updates to the caller make sense only on single * calls. */ break; } if (ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) { ast_verb(3, "Redirecting update to %s prevented.\n", ast_channel_name(in)); break; } ast_verb(3, "%s redirecting info has changed, passing it to %s\n", ast_channel_name(c), ast_channel_name(in)); if (ast_channel_redirecting_sub(c, in, f, 1) && ast_channel_redirecting_macro(c, in, f, 1, 1)) { ast_indicate_data(in, AST_CONTROL_REDIRECTING, f->data.ptr, f->datalen); } pa->sentringing = 0; break; case AST_CONTROL_PROCEEDING: ast_verb(3, "%s is proceeding passing it to %s\n", ast_channel_name(c), ast_channel_name(in)); if (single && !caller_entertained && CAN_EARLY_BRIDGE(peerflags, in, c)) { ast_channel_early_bridge(in, c); } if (!ast_test_flag64(outgoing, OPT_RINGBACK)) ast_indicate(in, AST_CONTROL_PROCEEDING); break; case AST_CONTROL_HOLD: /* XXX this should be saved like AST_CONTROL_CONNECTED_LINE for !single || caller_entertained */ ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(c)); ast_indicate_data(in, AST_CONTROL_HOLD, f->data.ptr, f->datalen); break; case AST_CONTROL_UNHOLD: /* XXX this should be saved like AST_CONTROL_CONNECTED_LINE for !single || caller_entertained */ ast_verb(3, "Call on %s left from hold\n", ast_channel_name(c)); ast_indicate(in, AST_CONTROL_UNHOLD); break; case AST_CONTROL_OFFHOOK: case AST_CONTROL_FLASH: /* Ignore going off hook and flash */ break; case AST_CONTROL_CC: if (!ignore_cc) { ast_handle_cc_control_frame(in, c, f->data.ptr); cc_frame_received = 1; } break; case AST_CONTROL_PVT_CAUSE_CODE: ast_indicate_data(in, AST_CONTROL_PVT_CAUSE_CODE, f->data.ptr, f->datalen); break; case -1: if (single && !caller_entertained) { ast_verb(3, "%s stopped sounds\n", ast_channel_name(c)); ast_indicate(in, -1); pa->sentringing = 0; } break; default: ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer); break; } break; case AST_FRAME_VOICE: case AST_FRAME_IMAGE: if (caller_entertained) { break; } /* Fall through */ case AST_FRAME_TEXT: if (single && ast_write(in, f)) { ast_log(LOG_WARNING, "Unable to write frametype: %d\n", f->frametype); } break; case AST_FRAME_HTML: if (single && !ast_test_flag64(outgoing, DIAL_NOFORWARDHTML) && ast_channel_sendhtml(in, f->subclass.integer, f->data.ptr, f->datalen) == -1) { ast_log(LOG_WARNING, "Unable to send URL\n"); } break; default: break; } ast_frfree(f); } /* end for */ if (winner == in) { struct ast_frame *f = ast_read(in); #if 0 if (f && (f->frametype != AST_FRAME_VOICE)) printf("Frame type: %d, %d\n", f->frametype, f->subclass); else if (!f || (f->frametype != AST_FRAME_VOICE)) printf("Hangup received on %s\n", in->name); #endif if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) { /* Got hung up */ *to = -1; strcpy(pa->status, "CANCEL"); ast_cdr_noanswer(ast_channel_cdr(in)); if (f) { if (f->data.uint32) { ast_channel_hangupcause_set(in, f->data.uint32); } ast_frfree(f); } if (is_cc_recall) { ast_cc_completed(in, "CC completed, although the caller hung up (cancelled)"); } return NULL; } /* now f is guaranteed non-NULL */ if (f->frametype == AST_FRAME_DTMF) { if (ast_test_flag64(peerflags, OPT_DTMF_EXIT)) { const char *context; ast_channel_lock(in); context = pbx_builtin_getvar_helper(in, "EXITCONTEXT"); if (onedigit_goto(in, context, (char) f->subclass.integer, 1)) { ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer); *to = 0; ast_cdr_noanswer(ast_channel_cdr(in)); *result = f->subclass.integer; strcpy(pa->status, "CANCEL"); ast_frfree(f); ast_channel_unlock(in); if (is_cc_recall) { ast_cc_completed(in, "CC completed, but the caller used DTMF to exit"); } return NULL; } ast_channel_unlock(in); } if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) && detect_disconnect(in, f->subclass.integer, &featurecode)) { ast_verb(3, "User requested call disconnect.\n"); *to = 0; strcpy(pa->status, "CANCEL"); ast_cdr_noanswer(ast_channel_cdr(in)); ast_frfree(f); if (is_cc_recall) { ast_cc_completed(in, "CC completed, but the caller hung up with DTMF"); } return NULL; } } /* Send the frame from the in channel to all outgoing channels. */ AST_LIST_TRAVERSE(out_chans, o, node) { if (!o->chan || !ast_test_flag64(o, DIAL_STILLGOING)) { /* This outgoing channel has died so don't send the frame to it. */ continue; } switch (f->frametype) { case AST_FRAME_HTML: /* Forward HTML stuff */ if (!ast_test_flag64(o, DIAL_NOFORWARDHTML) && ast_channel_sendhtml(o->chan, f->subclass.integer, f->data.ptr, f->datalen) == -1) { ast_log(LOG_WARNING, "Unable to send URL\n"); } break; case AST_FRAME_VOICE: case AST_FRAME_IMAGE: if (!single || caller_entertained) { /* * We are calling multiple parties or caller is being * entertained and has thus not been made compatible. * No need to check any other called parties. */ goto skip_frame; } /* Fall through */ case AST_FRAME_TEXT: case AST_FRAME_DTMF_BEGIN: case AST_FRAME_DTMF_END: if (ast_write(o->chan, f)) { ast_log(LOG_WARNING, "Unable to forward frametype: %d\n", f->frametype); } break; case AST_FRAME_CONTROL: switch (f->subclass.integer) { case AST_CONTROL_HOLD: ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(o->chan)); ast_indicate_data(o->chan, AST_CONTROL_HOLD, f->data.ptr, f->datalen); break; case AST_CONTROL_UNHOLD: ast_verb(3, "Call on %s left from hold\n", ast_channel_name(o->chan)); ast_indicate(o->chan, AST_CONTROL_UNHOLD); break; case AST_CONTROL_VIDUPDATE: case AST_CONTROL_SRCUPDATE: case AST_CONTROL_SRCCHANGE: if (!single || caller_entertained) { /* * We are calling multiple parties or caller is being * entertained and has thus not been made compatible. * No need to check any other called parties. */ goto skip_frame; } ast_verb(3, "%s requested media update control %d, passing it to %s\n", ast_channel_name(in), f->subclass.integer, ast_channel_name(o->chan)); ast_indicate(o->chan, f->subclass.integer); break; case AST_CONTROL_CONNECTED_LINE: if (ast_channel_connected_line_sub(in, o->chan, f, 1) && ast_channel_connected_line_macro(in, o->chan, f, 0, 1)) { ast_indicate_data(o->chan, f->subclass.integer, f->data.ptr, f->datalen); } break; case AST_CONTROL_REDIRECTING: if (ast_channel_redirecting_sub(in, o->chan, f, 1) && ast_channel_redirecting_macro(in, o->chan, f, 0, 1)) { ast_indicate_data(o->chan, f->subclass.integer, f->data.ptr, f->datalen); } break; default: /* We are not going to do anything with this frame. */ goto skip_frame; } break; default: /* We are not going to do anything with this frame. */ goto skip_frame; } } skip_frame:; ast_frfree(f); } } if (!*to) { ast_verb(3, "Nobody picked up in %d ms\n", orig); } if (!*to || ast_check_hangup(in)) { ast_cdr_noanswer(ast_channel_cdr(in)); } #ifdef HAVE_EPOLL AST_LIST_TRAVERSE(out_chans, epollo, node) { if (epollo->chan) ast_poll_channel_del(in, epollo->chan); } #endif if (is_cc_recall) { ast_cc_completed(in, "Recall completed!"); } return peer; } static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode) { struct ast_flags features = { AST_FEATURE_DISCONNECT }; /* only concerned with disconnect feature */ struct ast_call_feature feature = { 0, }; int res; ast_str_append(featurecode, 1, "%c", code); res = ast_feature_detect(chan, &features, ast_str_buffer(*featurecode), &feature); if (res != AST_FEATURE_RETURN_STOREDIGITS) { ast_str_reset(*featurecode); } if (feature.feature_mask & AST_FEATURE_DISCONNECT) { return 1; } return 0; } /* returns true if there is a valid privacy reply */ static int valid_priv_reply(struct ast_flags64 *opts, int res) { if (res < '1') return 0; if (ast_test_flag64(opts, OPT_PRIVACY) && res <= '5') return 1; if (ast_test_flag64(opts, OPT_SCREENING) && res <= '4') return 1; return 0; } static int do_privacy(struct ast_channel *chan, struct ast_channel *peer, struct ast_flags64 *opts, char **opt_args, struct privacy_args *pa) { int res2; int loopcount = 0; /* Get the user's intro, store it in priv-callerintros/$CID, unless it is already there-- this should be done before the call is actually dialed */ /* all ring indications and moh for the caller has been halted as soon as the target extension was picked up. We are going to have to kill some time and make the caller believe the peer hasn't picked up yet */ if (ast_test_flag64(opts, OPT_MUSICBACK) && !ast_strlen_zero(opt_args[OPT_ARG_MUSICBACK])) { char *original_moh = ast_strdupa(ast_channel_musicclass(chan)); ast_indicate(chan, -1); ast_channel_musicclass_set(chan, opt_args[OPT_ARG_MUSICBACK]); ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL); ast_channel_musicclass_set(chan, original_moh); } else if (ast_test_flag64(opts, OPT_RINGBACK)) { ast_indicate(chan, AST_CONTROL_RINGING); pa->sentringing++; } /* Start autoservice on the other chan ?? */ res2 = ast_autoservice_start(chan); /* Now Stream the File */ for (loopcount = 0; loopcount < 3; loopcount++) { if (res2 && loopcount == 0) /* error in ast_autoservice_start() */ break; if (!res2) /* on timeout, play the message again */ res2 = ast_play_and_wait(peer, "priv-callpending"); if (!valid_priv_reply(opts, res2)) res2 = 0; /* priv-callpending script: "I have a caller waiting, who introduces themselves as:" */ if (!res2) res2 = ast_play_and_wait(peer, pa->privintro); if (!valid_priv_reply(opts, res2)) res2 = 0; /* now get input from the called party, as to their choice */ if (!res2) { /* XXX can we have both, or they are mutually exclusive ? */ if (ast_test_flag64(opts, OPT_PRIVACY)) res2 = ast_play_and_wait(peer, "priv-callee-options"); if (ast_test_flag64(opts, OPT_SCREENING)) res2 = ast_play_and_wait(peer, "screen-callee-options"); } /*! \page DialPrivacy Dial Privacy scripts \par priv-callee-options script: "Dial 1 if you wish this caller to reach you directly in the future, and immediately connect to their incoming call Dial 2 if you wish to send this caller to voicemail now and forevermore. Dial 3 to send this caller to the torture menus, now and forevermore. Dial 4 to send this caller to a simple "go away" menu, now and forevermore. Dial 5 to allow this caller to come straight thru to you in the future, but right now, just this once, send them to voicemail." \par screen-callee-options script: "Dial 1 if you wish to immediately connect to the incoming call Dial 2 if you wish to send this caller to voicemail. Dial 3 to send this caller to the torture menus. Dial 4 to send this caller to a simple "go away" menu. */ if (valid_priv_reply(opts, res2)) break; /* invalid option */ res2 = ast_play_and_wait(peer, "vm-sorry"); } if (ast_test_flag64(opts, OPT_MUSICBACK)) { ast_moh_stop(chan); } else if (ast_test_flag64(opts, OPT_RINGBACK)) { ast_indicate(chan, -1); pa->sentringing = 0; } ast_autoservice_stop(chan); if (ast_test_flag64(opts, OPT_PRIVACY) && (res2 >= '1' && res2 <= '5')) { /* map keypresses to various things, the index is res2 - '1' */ static const char * const _val[] = { "ALLOW", "DENY", "TORTURE", "KILL", "ALLOW" }; static const int _flag[] = { AST_PRIVACY_ALLOW, AST_PRIVACY_DENY, AST_PRIVACY_TORTURE, AST_PRIVACY_KILL, AST_PRIVACY_ALLOW}; int i = res2 - '1'; ast_verb(3, "--Set privacy database entry %s/%s to %s\n", opt_args[OPT_ARG_PRIVACY], pa->privcid, _val[i]); ast_privacy_set(opt_args[OPT_ARG_PRIVACY], pa->privcid, _flag[i]); } switch (res2) { case '1': break; case '2': ast_copy_string(pa->status, "NOANSWER", sizeof(pa->status)); break; case '3': ast_copy_string(pa->status, "TORTURE", sizeof(pa->status)); break; case '4': ast_copy_string(pa->status, "DONTCALL", sizeof(pa->status)); break; case '5': /* XXX should we set status to DENY ? */ if (ast_test_flag64(opts, OPT_PRIVACY)) break; /* if not privacy, then 5 is the same as "default" case */ default: /* bad input or -1 if failure to start autoservice */ /* well, if the user messes up, ... he had his chance... What Is The Best Thing To Do? */ /* well, there seems basically two choices. Just patch the caller thru immediately, or,... put 'em thru to voicemail. */ /* since the callee may have hung up, let's do the voicemail thing, no database decision */ ast_log(LOG_NOTICE, "privacy: no valid response from the callee. Sending the caller to voicemail, the callee isn't responding\n"); /* XXX should we set status to DENY ? */ /* XXX what about the privacy flags ? */ break; } if (res2 == '1') { /* the only case where we actually connect */ /* if the intro is NOCALLERID, then there's no reason to leave it on disk, it'll just clog things up, and it's not useful information, not being tied to a CID */ if (strncmp(pa->privcid, "NOCALLERID", 10) == 0 || ast_test_flag64(opts, OPT_SCREEN_NOINTRO)) { ast_filedelete(pa->privintro, NULL); if (ast_fileexists(pa->privintro, NULL, NULL) > 0) ast_log(LOG_NOTICE, "privacy: ast_filedelete didn't do its job on %s\n", pa->privintro); else ast_verb(3, "Successfully deleted %s intro file\n", pa->privintro); } return 0; /* the good exit path */ } else { /* hang up on the callee -- he didn't want to talk anyway! */ ast_autoservice_chan_hangup_peer(chan, peer); return -1; } } /*! \brief returns 1 if successful, 0 or <0 if the caller should 'goto out' */ static int setup_privacy_args(struct privacy_args *pa, struct ast_flags64 *opts, char *opt_args[], struct ast_channel *chan) { char callerid[60]; int res; char *l; if (ast_channel_caller(chan)->id.number.valid && !ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) { l = ast_strdupa(ast_channel_caller(chan)->id.number.str); ast_shrink_phone_number(l); if (ast_test_flag64(opts, OPT_PRIVACY) ) { ast_verb(3, "Privacy DB is '%s', clid is '%s'\n", opt_args[OPT_ARG_PRIVACY], l); pa->privdb_val = ast_privacy_check(opt_args[OPT_ARG_PRIVACY], l); } else { ast_verb(3, "Privacy Screening, clid is '%s'\n", l); pa->privdb_val = AST_PRIVACY_UNKNOWN; } } else { char *tnam, *tn2; tnam = ast_strdupa(ast_channel_name(chan)); /* clean the channel name so slashes don't try to end up in disk file name */ for (tn2 = tnam; *tn2; tn2++) { if (*tn2 == '/') /* any other chars to be afraid of? */ *tn2 = '='; } ast_verb(3, "Privacy-- callerid is empty\n"); snprintf(callerid, sizeof(callerid), "NOCALLERID_%s%s", ast_channel_exten(chan), tnam); l = callerid; pa->privdb_val = AST_PRIVACY_UNKNOWN; } ast_copy_string(pa->privcid, l, sizeof(pa->privcid)); if (strncmp(pa->privcid, "NOCALLERID", 10) != 0 && ast_test_flag64(opts, OPT_SCREEN_NOCALLERID)) { /* if callerid is set and OPT_SCREEN_NOCALLERID is set also */ ast_verb(3, "CallerID set (%s); N option set; Screening should be off\n", pa->privcid); pa->privdb_val = AST_PRIVACY_ALLOW; } else if (ast_test_flag64(opts, OPT_SCREEN_NOCALLERID) && strncmp(pa->privcid, "NOCALLERID", 10) == 0) { ast_verb(3, "CallerID blank; N option set; Screening should happen; dbval is %d\n", pa->privdb_val); } if (pa->privdb_val == AST_PRIVACY_DENY) { ast_verb(3, "Privacy DB reports PRIVACY_DENY for this callerid. Dial reports unavailable\n"); ast_copy_string(pa->status, "NOANSWER", sizeof(pa->status)); return 0; } else if (pa->privdb_val == AST_PRIVACY_KILL) { ast_copy_string(pa->status, "DONTCALL", sizeof(pa->status)); return 0; /* Is this right? */ } else if (pa->privdb_val == AST_PRIVACY_TORTURE) { ast_copy_string(pa->status, "TORTURE", sizeof(pa->status)); return 0; /* is this right??? */ } else if (pa->privdb_val == AST_PRIVACY_UNKNOWN) { /* Get the user's intro, store it in priv-callerintros/$CID, unless it is already there-- this should be done before the call is actually dialed */ /* make sure the priv-callerintros dir actually exists */ snprintf(pa->privintro, sizeof(pa->privintro), "%s/sounds/priv-callerintros", ast_config_AST_DATA_DIR); if ((res = ast_mkdir(pa->privintro, 0755))) { ast_log(LOG_WARNING, "privacy: can't create directory priv-callerintros: %s\n", strerror(res)); return -1; } snprintf(pa->privintro, sizeof(pa->privintro), "priv-callerintros/%s", pa->privcid); if (ast_fileexists(pa->privintro, NULL, NULL ) > 0 && strncmp(pa->privcid, "NOCALLERID", 10) != 0) { /* the DELUX version of this code would allow this caller the option to hear and retape their previously recorded intro. */ } else { int duration; /* for feedback from play_and_wait */ /* the file doesn't exist yet. Let the caller submit his vocal intro for posterity */ /* priv-recordintro script: "At the tone, please say your name:" */ int silencethreshold = ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE); ast_answer(chan); res = ast_play_and_record(chan, "priv-recordintro", pa->privintro, 4, "sln", &duration, NULL, silencethreshold, 2000, 0); /* NOTE: I've reduced the total time to 4 sec */ /* don't think we'll need a lock removed, we took care of conflicts by naming the pa.privintro file */ if (res == -1) { /* Delete the file regardless since they hung up during recording */ ast_filedelete(pa->privintro, NULL); if (ast_fileexists(pa->privintro, NULL, NULL) > 0) ast_log(LOG_NOTICE, "privacy: ast_filedelete didn't do its job on %s\n", pa->privintro); else ast_verb(3, "Successfully deleted %s intro file\n", pa->privintro); return -1; } if (!ast_streamfile(chan, "vm-dialout", ast_channel_language(chan)) ) ast_waitstream(chan, ""); } } return 1; /* success */ } static void end_bridge_callback(void *data) { char buf[80]; time_t end; struct ast_channel *chan = data; if (!ast_channel_cdr(chan)) { return; } time(&end); ast_channel_lock(chan); if (ast_channel_cdr(chan)->answer.tv_sec) { snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->answer.tv_sec); pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf); } if (ast_channel_cdr(chan)->start.tv_sec) { snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->start.tv_sec); pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf); } ast_channel_unlock(chan); } static void end_bridge_callback_data_fixup(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator) { bconfig->end_bridge_callback_data = originator; } static int dial_handle_playtones(struct ast_channel *chan, const char *data) { struct ast_tone_zone_sound *ts = NULL; int res; const char *str = data; if (ast_strlen_zero(str)) { ast_debug(1,"Nothing to play\n"); return -1; } ts = ast_get_indication_tone(ast_channel_zone(chan), str); if (ts && ts->data[0]) { res = ast_playtones_start(chan, 0, ts->data, 0); } else { res = -1; } if (ts) { ts = ast_tone_zone_sound_unref(ts); } if (res) { ast_log(LOG_WARNING, "Unable to start playtone \'%s\'\n", str); } return res; } static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast_flags64 *peerflags, int *continue_exec) { int res = -1; /* default: error */ char *rest, *cur; /* scan the list of destinations */ struct dial_head out_chans = AST_LIST_HEAD_NOLOCK_INIT_VALUE; /* list of destinations */ struct chanlist *outgoing; struct chanlist *tmp; struct ast_channel *peer; int to; /* timeout */ struct cause_args num = { chan, 0, 0, 0 }; int cause; struct ast_bridge_config config = { { 0, } }; struct timeval calldurationlimit = { 0, }; char *dtmfcalled = NULL, *dtmfcalling = NULL, *dtmf_progress=NULL; struct privacy_args pa = { .sentringing = 0, .privdb_val = 0, .status = "INVALIDARGS", }; int sentringing = 0, moh = 0; const char *outbound_group = NULL; int result = 0; char *parse; int opermode = 0; int delprivintro = 0; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(peers); AST_APP_ARG(timeout); AST_APP_ARG(options); AST_APP_ARG(url); ); struct ast_flags64 opts = { 0, }; char *opt_args[OPT_ARG_ARRAY_SIZE]; struct ast_datastore *datastore = NULL; int fulldial = 0, num_dialed = 0; int ignore_cc = 0; char device_name[AST_CHANNEL_NAME]; char forced_clid_name[AST_MAX_EXTENSION]; char stored_clid_name[AST_MAX_EXTENSION]; int force_forwards_only; /*!< TRUE if force CallerID on call forward only. Legacy behaviour.*/ /*! * \brief Forced CallerID party information to send. * \note This will not have any malloced strings so do not free it. */ struct ast_party_id forced_clid; /*! * \brief Stored CallerID information if needed. * * \note If OPT_ORIGINAL_CLID set then this is the o option * CallerID. Otherwise it is the dialplan extension and hint * name. * * \note This will not have any malloced strings so do not free it. */ struct ast_party_id stored_clid; /*! * \brief CallerID party information to store. * \note This will not have any malloced strings so do not free it. */ struct ast_party_caller caller; /* Reset all DIAL variables back to blank, to prevent confusion (in case we don't reset all of them). */ pbx_builtin_setvar_helper(chan, "DIALSTATUS", ""); pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", ""); pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", ""); pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", ""); pbx_builtin_setvar_helper(chan, "DIALEDTIME", ""); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "Dial requires an argument (technology/resource)\n"); pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (!ast_strlen_zero(args.options) && ast_app_parse_options64(dial_exec_options, &opts, opt_args, args.options)) { pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); goto done; } if (ast_strlen_zero(args.peers)) { ast_log(LOG_WARNING, "Dial requires an argument (technology/resource)\n"); pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); goto done; } if (ast_cc_call_init(chan, &ignore_cc)) { goto done; } if (ast_test_flag64(&opts, OPT_SCREEN_NOINTRO) && !ast_strlen_zero(opt_args[OPT_ARG_SCREEN_NOINTRO])) { delprivintro = atoi(opt_args[OPT_ARG_SCREEN_NOINTRO]); if (delprivintro < 0 || delprivintro > 1) { ast_log(LOG_WARNING, "Unknown argument %d specified to n option, ignoring\n", delprivintro); delprivintro = 0; } } if (!ast_test_flag64(&opts, OPT_RINGBACK)) { opt_args[OPT_ARG_RINGBACK] = NULL; } if (ast_test_flag64(&opts, OPT_OPERMODE)) { opermode = ast_strlen_zero(opt_args[OPT_ARG_OPERMODE]) ? 1 : atoi(opt_args[OPT_ARG_OPERMODE]); ast_verb(3, "Setting operator services mode to %d.\n", opermode); } if (ast_test_flag64(&opts, OPT_DURATION_STOP) && !ast_strlen_zero(opt_args[OPT_ARG_DURATION_STOP])) { calldurationlimit.tv_sec = atoi(opt_args[OPT_ARG_DURATION_STOP]); if (!calldurationlimit.tv_sec) { ast_log(LOG_WARNING, "Dial does not accept S(%s), hanging up.\n", opt_args[OPT_ARG_DURATION_STOP]); pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); goto done; } ast_verb(3, "Setting call duration limit to %.3lf seconds.\n", calldurationlimit.tv_sec + calldurationlimit.tv_usec / 1000000.0); } if (ast_test_flag64(&opts, OPT_SENDDTMF) && !ast_strlen_zero(opt_args[OPT_ARG_SENDDTMF])) { dtmf_progress = opt_args[OPT_ARG_SENDDTMF]; dtmfcalled = strsep(&dtmf_progress, ":"); dtmfcalling = strsep(&dtmf_progress, ":"); } if (ast_test_flag64(&opts, OPT_DURATION_LIMIT) && !ast_strlen_zero(opt_args[OPT_ARG_DURATION_LIMIT])) { if (ast_bridge_timelimit(chan, &config, opt_args[OPT_ARG_DURATION_LIMIT], &calldurationlimit)) goto done; } /* Setup the forced CallerID information to send if used. */ ast_party_id_init(&forced_clid); force_forwards_only = 0; if (ast_test_flag64(&opts, OPT_FORCECLID)) { if (ast_strlen_zero(opt_args[OPT_ARG_FORCECLID])) { ast_channel_lock(chan); forced_clid.number.str = ast_strdupa(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))); ast_channel_unlock(chan); forced_clid_name[0] = '\0'; forced_clid.name.str = (char *) get_cid_name(forced_clid_name, sizeof(forced_clid_name), chan); force_forwards_only = 1; } else { /* Note: The opt_args[OPT_ARG_FORCECLID] string value is altered here. */ ast_callerid_parse(opt_args[OPT_ARG_FORCECLID], &forced_clid.name.str, &forced_clid.number.str); } if (!ast_strlen_zero(forced_clid.name.str)) { forced_clid.name.valid = 1; } if (!ast_strlen_zero(forced_clid.number.str)) { forced_clid.number.valid = 1; } } if (ast_test_flag64(&opts, OPT_FORCE_CID_TAG) && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_TAG])) { forced_clid.tag = opt_args[OPT_ARG_FORCE_CID_TAG]; } forced_clid.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN; if (ast_test_flag64(&opts, OPT_FORCE_CID_PRES) && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_PRES])) { int pres; pres = ast_parse_caller_presentation(opt_args[OPT_ARG_FORCE_CID_PRES]); if (0 <= pres) { forced_clid.number.presentation = pres; } } /* Setup the stored CallerID information if needed. */ ast_party_id_init(&stored_clid); if (ast_test_flag64(&opts, OPT_ORIGINAL_CLID)) { if (ast_strlen_zero(opt_args[OPT_ARG_ORIGINAL_CLID])) { ast_channel_lock(chan); ast_party_id_set_init(&stored_clid, &ast_channel_caller(chan)->id); if (!ast_strlen_zero(ast_channel_caller(chan)->id.name.str)) { stored_clid.name.str = ast_strdupa(ast_channel_caller(chan)->id.name.str); } if (!ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) { stored_clid.number.str = ast_strdupa(ast_channel_caller(chan)->id.number.str); } if (!ast_strlen_zero(ast_channel_caller(chan)->id.subaddress.str)) { stored_clid.subaddress.str = ast_strdupa(ast_channel_caller(chan)->id.subaddress.str); } if (!ast_strlen_zero(ast_channel_caller(chan)->id.tag)) { stored_clid.tag = ast_strdupa(ast_channel_caller(chan)->id.tag); } ast_channel_unlock(chan); } else { /* Note: The opt_args[OPT_ARG_ORIGINAL_CLID] string value is altered here. */ ast_callerid_parse(opt_args[OPT_ARG_ORIGINAL_CLID], &stored_clid.name.str, &stored_clid.number.str); if (!ast_strlen_zero(stored_clid.name.str)) { stored_clid.name.valid = 1; } if (!ast_strlen_zero(stored_clid.number.str)) { stored_clid.number.valid = 1; } } } else { /* * In case the new channel has no preset CallerID number by the * channel driver, setup the dialplan extension and hint name. */ stored_clid_name[0] = '\0'; stored_clid.name.str = (char *) get_cid_name(stored_clid_name, sizeof(stored_clid_name), chan); if (ast_strlen_zero(stored_clid.name.str)) { stored_clid.name.str = NULL; } else { stored_clid.name.valid = 1; } ast_channel_lock(chan); stored_clid.number.str = ast_strdupa(S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))); stored_clid.number.valid = 1; ast_channel_unlock(chan); } if (ast_test_flag64(&opts, OPT_RESETCDR) && ast_channel_cdr(chan)) ast_cdr_reset(ast_channel_cdr(chan), NULL); if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY])) opt_args[OPT_ARG_PRIVACY] = ast_strdupa(ast_channel_exten(chan)); if (ast_test_flag64(&opts, OPT_PRIVACY) || ast_test_flag64(&opts, OPT_SCREENING)) { res = setup_privacy_args(&pa, &opts, opt_args, chan); if (res <= 0) goto out; res = -1; /* reset default */ } if (continue_exec) *continue_exec = 0; /* If a channel group has been specified, get it for use when we create peer channels */ ast_channel_lock(chan); if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP_ONCE"))) { outbound_group = ast_strdupa(outbound_group); pbx_builtin_setvar_helper(chan, "OUTBOUND_GROUP_ONCE", NULL); } else if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP"))) { outbound_group = ast_strdupa(outbound_group); } ast_channel_unlock(chan); /* Set per dial instance flags. These flags are also passed back to RetryDial. */ ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING | OPT_CANCEL_TIMEOUT | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB | OPT_FORCECLID); /* PREDIAL: Run gosub on the caller's channel */ if (ast_test_flag64(&opts, OPT_PREDIAL_CALLER) && !ast_strlen_zero(opt_args[OPT_ARG_PREDIAL_CALLER])) { ast_replace_subargument_delimiter(opt_args[OPT_ARG_PREDIAL_CALLER]); ast_app_exec_sub(NULL, chan, opt_args[OPT_ARG_PREDIAL_CALLER], 0); } /* loop through the list of dial destinations */ rest = args.peers; while ((cur = strsep(&rest, "&")) ) { struct ast_channel *tc; /* channel for this destination */ /* Get a technology/resource pair */ char *number = cur; char *tech = strsep(&number, "/"); size_t tech_len; size_t number_len; /* find if we already dialed this interface */ struct ast_dialed_interface *di; AST_LIST_HEAD(,ast_dialed_interface) *dialed_interfaces; num_dialed++; if (ast_strlen_zero(number)) { ast_log(LOG_WARNING, "Dial argument takes format (technology/resource)\n"); goto out; } tech_len = strlen(tech) + 1; number_len = strlen(number) + 1; tmp = ast_calloc(1, sizeof(*tmp) + (2 * tech_len) + number_len); if (!tmp) { goto out; } /* Save tech, number, and interface. */ cur = tmp->stuff; strcpy(cur, tech); tmp->tech = cur; cur += tech_len; strcpy(cur, tech); cur[tech_len - 1] = '/'; tmp->interface = cur; cur += tech_len; strcpy(cur, number); tmp->number = cur; if (opts.flags) { /* Set per outgoing call leg options. */ ast_copy_flags64(tmp, &opts, OPT_CANCEL_ELSEWHERE | OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER | OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP | OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK | OPT_CALLER_PARK | OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR | OPT_RINGBACK | OPT_MUSICBACK | OPT_FORCECLID | OPT_IGNORE_CONNECTEDLINE); ast_set2_flag64(tmp, args.url, DIAL_NOFORWARDHTML); } /* Request the peer */ ast_channel_lock(chan); datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL); /* * Seed the chanlist's connected line information with previously * acquired connected line info from the incoming channel. The * previously acquired connected line info could have been set * through the CONNECTED_LINE dialplan function. */ ast_party_connected_line_copy(&tmp->connected, ast_channel_connected(chan)); ast_channel_unlock(chan); if (datastore) dialed_interfaces = datastore->data; else { if (!(datastore = ast_datastore_alloc(&dialed_interface_info, NULL))) { ast_log(LOG_WARNING, "Unable to create channel datastore for dialed interfaces. Aborting!\n"); chanlist_free(tmp); goto out; } datastore->inheritance = DATASTORE_INHERIT_FOREVER; if (!(dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces)))) { ast_datastore_free(datastore); chanlist_free(tmp); goto out; } datastore->data = dialed_interfaces; AST_LIST_HEAD_INIT(dialed_interfaces); ast_channel_lock(chan); ast_channel_datastore_add(chan, datastore); ast_channel_unlock(chan); } AST_LIST_LOCK(dialed_interfaces); AST_LIST_TRAVERSE(dialed_interfaces, di, list) { if (!strcasecmp(di->interface, tmp->interface)) { ast_log(LOG_WARNING, "Skipping dialing interface '%s' again since it has already been dialed\n", di->interface); break; } } AST_LIST_UNLOCK(dialed_interfaces); if (di) { fulldial++; chanlist_free(tmp); continue; } /* It is always ok to dial a Local interface. We only keep track of * which "real" interfaces have been dialed. The Local channel will * inherit this list so that if it ends up dialing a real interface, * it won't call one that has already been called. */ if (strcasecmp(tmp->tech, "Local")) { if (!(di = ast_calloc(1, sizeof(*di) + strlen(tmp->interface)))) { chanlist_free(tmp); goto out; } strcpy(di->interface, tmp->interface); AST_LIST_LOCK(dialed_interfaces); AST_LIST_INSERT_TAIL(dialed_interfaces, di, list); AST_LIST_UNLOCK(dialed_interfaces); } tc = ast_request(tmp->tech, ast_channel_nativeformats(chan), chan, tmp->number, &cause); if (!tc) { /* If we can't, just go on to the next call */ ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n", tmp->tech, cause, ast_cause2str(cause)); handle_cause(cause, &num); if (!rest) { /* we are on the last destination */ ast_channel_hangupcause_set(chan, cause); } if (!ignore_cc && (cause == AST_CAUSE_BUSY || cause == AST_CAUSE_CONGESTION)) { if (!ast_cc_callback(chan, tmp->tech, tmp->number, ast_cc_busy_interface)) { ast_cc_extension_monitor_add_dialstring(chan, tmp->interface, ""); } } chanlist_free(tmp); continue; } ast_channel_get_device_name(tc, device_name, sizeof(device_name)); if (!ignore_cc) { ast_cc_extension_monitor_add_dialstring(chan, tmp->interface, device_name); } pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", tmp->number); ast_channel_lock_both(tc, chan); /* Setup outgoing SDP to match incoming one */ if (!AST_LIST_FIRST(&out_chans) && !rest && CAN_EARLY_BRIDGE(peerflags, chan, tc)) { /* We are on the only destination. */ ast_rtp_instance_early_bridge_make_compatible(tc, chan); } /* Inherit specially named variables from parent channel */ ast_channel_inherit_variables(chan, tc); ast_channel_datastore_inherit(chan, tc); ast_channel_appl_set(tc, "AppDial"); ast_channel_data_set(tc, "(Outgoing Line)"); memset(ast_channel_whentohangup(tc), 0, sizeof(*ast_channel_whentohangup(tc))); /* Determine CallerID to store in outgoing channel. */ ast_party_caller_set_init(&caller, ast_channel_caller(tc)); if (ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) { caller.id = stored_clid; ast_channel_set_caller_event(tc, &caller, NULL); ast_set_flag64(tmp, DIAL_CALLERID_ABSENT); } else if (ast_strlen_zero(S_COR(ast_channel_caller(tc)->id.number.valid, ast_channel_caller(tc)->id.number.str, NULL))) { /* * The new channel has no preset CallerID number by the channel * driver. Use the dialplan extension and hint name. */ caller.id = stored_clid; if (!caller.id.name.valid && !ast_strlen_zero(S_COR(ast_channel_connected(chan)->id.name.valid, ast_channel_connected(chan)->id.name.str, NULL))) { /* * No hint name available. We have a connected name supplied by * the dialplan we can use instead. */ caller.id.name.valid = 1; caller.id.name = ast_channel_connected(chan)->id.name; } ast_channel_set_caller_event(tc, &caller, NULL); ast_set_flag64(tmp, DIAL_CALLERID_ABSENT); } else if (ast_strlen_zero(S_COR(ast_channel_caller(tc)->id.name.valid, ast_channel_caller(tc)->id.name.str, NULL))) { /* The new channel has no preset CallerID name by the channel driver. */ if (!ast_strlen_zero(S_COR(ast_channel_connected(chan)->id.name.valid, ast_channel_connected(chan)->id.name.str, NULL))) { /* * We have a connected name supplied by the dialplan we can * use instead. */ caller.id.name.valid = 1; caller.id.name = ast_channel_connected(chan)->id.name; ast_channel_set_caller_event(tc, &caller, NULL); } } /* Determine CallerID for outgoing channel to send. */ if (ast_test_flag64(peerflags, OPT_FORCECLID) && !force_forwards_only) { struct ast_party_connected_line connected; ast_party_connected_line_set_init(&connected, ast_channel_connected(tc)); connected.id = forced_clid; ast_channel_set_connected_line(tc, &connected, NULL); } else { ast_connected_line_copy_from_caller(ast_channel_connected(tc), ast_channel_caller(chan)); } ast_party_redirecting_copy(ast_channel_redirecting(tc), ast_channel_redirecting(chan)); ast_channel_dialed(tc)->transit_network_select = ast_channel_dialed(chan)->transit_network_select; if (!ast_strlen_zero(ast_channel_accountcode(chan))) { ast_channel_accountcode_set(tc, ast_channel_accountcode(chan)); } if (ast_strlen_zero(ast_channel_musicclass(tc))) { ast_channel_musicclass_set(tc, ast_channel_musicclass(chan)); } /* Pass ADSI CPE and transfer capability */ ast_channel_adsicpe_set(tc, ast_channel_adsicpe(chan)); ast_channel_transfercapability_set(tc, ast_channel_transfercapability(chan)); /* If we have an outbound group, set this peer channel to it */ if (outbound_group) ast_app_group_set_channel(tc, outbound_group); /* If the calling channel has the ANSWERED_ELSEWHERE flag set, inherit it. This is to support local channels */ if (ast_channel_hangupcause(chan) == AST_CAUSE_ANSWERED_ELSEWHERE) ast_channel_hangupcause_set(tc, AST_CAUSE_ANSWERED_ELSEWHERE); /* Check if we're forced by configuration */ if (ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE)) ast_channel_hangupcause_set(tc, AST_CAUSE_ANSWERED_ELSEWHERE); /* Inherit context and extension */ ast_channel_dialcontext_set(tc, ast_strlen_zero(ast_channel_macrocontext(chan)) ? ast_channel_context(chan) : ast_channel_macrocontext(chan)); if (!ast_strlen_zero(ast_channel_macroexten(chan))) ast_channel_exten_set(tc, ast_channel_macroexten(chan)); else ast_channel_exten_set(tc, ast_channel_exten(chan)); ast_channel_unlock(tc); ast_channel_unlock(chan); /* Put channel in the list of outgoing thingies. */ tmp->chan = tc; AST_LIST_INSERT_TAIL(&out_chans, tmp, node); } /* * PREDIAL: Run gosub on all of the callee channels * * We run the callee predial before ast_call() in case the user * wishes to do something on the newly created channels before * the channel does anything important. * * Inside the target gosub we will be able to do something with * the newly created channel name ie: now the calling channel * can know what channel will be used to call the destination * ex: now we will know that SIP/abc-123 is calling SIP/def-124 */ if (ast_test_flag64(&opts, OPT_PREDIAL_CALLEE) && !ast_strlen_zero(opt_args[OPT_ARG_PREDIAL_CALLEE]) && !AST_LIST_EMPTY(&out_chans)) { const char *predial_callee; ast_replace_subargument_delimiter(opt_args[OPT_ARG_PREDIAL_CALLEE]); predial_callee = ast_app_expand_sub_args(chan, opt_args[OPT_ARG_PREDIAL_CALLEE]); if (predial_callee) { ast_autoservice_start(chan); AST_LIST_TRAVERSE(&out_chans, tmp, node) { ast_pre_call(tmp->chan, predial_callee); } ast_autoservice_stop(chan); ast_free((char *) predial_callee); } } /* Start all outgoing calls */ AST_LIST_TRAVERSE_SAFE_BEGIN(&out_chans, tmp, node) { res = ast_call(tmp->chan, tmp->number, 0); /* Place the call, but don't wait on the answer */ ast_channel_lock(chan); /* Save the info in cdr's that we called them */ if (ast_channel_cdr(chan)) ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(tmp->chan)); /* check the results of ast_call */ if (res) { /* Again, keep going even if there's an error */ ast_debug(1, "ast call on peer returned %d\n", res); ast_verb(3, "Couldn't call %s\n", tmp->interface); if (ast_channel_hangupcause(tmp->chan)) { ast_channel_hangupcause_set(chan, ast_channel_hangupcause(tmp->chan)); } ast_channel_unlock(chan); ast_cc_call_failed(chan, tmp->chan, tmp->interface); ast_hangup(tmp->chan); tmp->chan = NULL; AST_LIST_REMOVE_CURRENT(node); chanlist_free(tmp); continue; } senddialevent(chan, tmp->chan, tmp->number); ast_channel_unlock(chan); ast_verb(3, "Called %s\n", tmp->interface); ast_set_flag64(tmp, DIAL_STILLGOING); /* If this line is up, don't try anybody else */ if (ast_channel_state(tmp->chan) == AST_STATE_UP) { break; } } AST_LIST_TRAVERSE_SAFE_END; if (ast_strlen_zero(args.timeout)) { to = -1; } else { to = atoi(args.timeout); if (to > 0) to *= 1000; else { ast_log(LOG_WARNING, "Invalid timeout specified: '%s'. Setting timeout to infinite\n", args.timeout); to = -1; } } outgoing = AST_LIST_FIRST(&out_chans); if (!outgoing) { strcpy(pa.status, "CHANUNAVAIL"); if (fulldial == num_dialed) { res = -1; goto out; } } else { /* Our status will at least be NOANSWER */ strcpy(pa.status, "NOANSWER"); if (ast_test_flag64(outgoing, OPT_MUSICBACK)) { moh = 1; if (!ast_strlen_zero(opt_args[OPT_ARG_MUSICBACK])) { char *original_moh = ast_strdupa(ast_channel_musicclass(chan)); ast_channel_musicclass_set(chan, opt_args[OPT_ARG_MUSICBACK]); ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL); ast_channel_musicclass_set(chan, original_moh); } else { ast_moh_start(chan, NULL, NULL); } ast_indicate(chan, AST_CONTROL_PROGRESS); } else if (ast_test_flag64(outgoing, OPT_RINGBACK)) { if (!ast_strlen_zero(opt_args[OPT_ARG_RINGBACK])) { if (dial_handle_playtones(chan, opt_args[OPT_ARG_RINGBACK])){ ast_indicate(chan, AST_CONTROL_RINGING); sentringing++; } else { ast_indicate(chan, AST_CONTROL_PROGRESS); } } else { ast_indicate(chan, AST_CONTROL_RINGING); sentringing++; } } } peer = wait_for_answer(chan, &out_chans, &to, peerflags, opt_args, &pa, &num, &result, dtmf_progress, ignore_cc, &forced_clid, &stored_clid); /* The ast_channel_datastore_remove() function could fail here if the * datastore was moved to another channel during a masquerade. If this is * the case, don't free the datastore here because later, when the channel * to which the datastore was moved hangs up, it will attempt to free this * datastore again, causing a crash */ ast_channel_lock(chan); datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL); /* make sure we weren't cleaned up already */ if (datastore && !ast_channel_datastore_remove(chan, datastore)) { ast_datastore_free(datastore); } ast_channel_unlock(chan); if (!peer) { if (result) { res = result; } else if (to) { /* Musta gotten hung up */ res = -1; } else { /* Nobody answered, next please? */ res = 0; } } else { const char *number; if (ast_test_flag64(&opts, OPT_CALLER_ANSWER)) ast_answer(chan); strcpy(pa.status, "ANSWER"); pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); /* Ah ha! Someone answered within the desired timeframe. Of course after this we will always return with -1 so that it is hung up properly after the conversation. */ hanguptree(&out_chans, peer, 1); /* If appropriate, log that we have a destination channel and set the answer time */ if (ast_channel_cdr(chan)) { ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(peer)); ast_cdr_setanswer(ast_channel_cdr(chan), ast_channel_cdr(peer)->answer); } if (ast_channel_name(peer)) pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", ast_channel_name(peer)); ast_channel_lock(peer); number = pbx_builtin_getvar_helper(peer, "DIALEDPEERNUMBER"); if (ast_strlen_zero(number)) { number = NULL; } else { number = ast_strdupa(number); } ast_channel_unlock(peer); pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number); if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) { ast_debug(1, "app_dial: sendurl=%s.\n", args.url); ast_channel_sendurl( peer, args.url ); } if ( (ast_test_flag64(&opts, OPT_PRIVACY) || ast_test_flag64(&opts, OPT_SCREENING)) && pa.privdb_val == AST_PRIVACY_UNKNOWN) { if (do_privacy(chan, peer, &opts, opt_args, &pa)) { res = 0; goto out; } } if (!ast_test_flag64(&opts, OPT_ANNOUNCE) || ast_strlen_zero(opt_args[OPT_ARG_ANNOUNCE])) { res = 0; } else { int digit = 0; struct ast_channel *chans[2]; struct ast_channel *active_chan; chans[0] = chan; chans[1] = peer; /* we need to stream the announcment while monitoring the caller for a hangup */ /* stream the file */ res = ast_streamfile(peer, opt_args[OPT_ARG_ANNOUNCE], ast_channel_language(peer)); if (res) { res = 0; ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", opt_args[OPT_ARG_ANNOUNCE]); } ast_set_flag(ast_channel_flags(peer), AST_FLAG_END_DTMF_ONLY); while (ast_channel_stream(peer)) { int ms; ms = ast_sched_wait(ast_channel_sched(peer)); if (ms < 0 && !ast_channel_timingfunc(peer)) { ast_stopstream(peer); break; } if (ms < 0) ms = 1000; active_chan = ast_waitfor_n(chans, 2, &ms); if (active_chan) { struct ast_frame *fr = ast_read(active_chan); if (!fr) { ast_autoservice_chan_hangup_peer(chan, peer); res = -1; goto done; } switch(fr->frametype) { case AST_FRAME_DTMF_END: digit = fr->subclass.integer; if (active_chan == peer && strchr(AST_DIGIT_ANY, res)) { ast_stopstream(peer); res = ast_senddigit(chan, digit, 0); } break; case AST_FRAME_CONTROL: switch (fr->subclass.integer) { case AST_CONTROL_HANGUP: ast_frfree(fr); ast_autoservice_chan_hangup_peer(chan, peer); res = -1; goto done; default: break; } break; default: /* Ignore all others */ break; } ast_frfree(fr); } ast_sched_runq(ast_channel_sched(peer)); } ast_clear_flag(ast_channel_flags(peer), AST_FLAG_END_DTMF_ONLY); } if (chan && peer && ast_test_flag64(&opts, OPT_GOTO) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO])) { /* chan and peer are going into the PBX, they both * should probably get CDR records. */ ast_clear_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED); ast_clear_flag(ast_channel_cdr(peer), AST_CDR_FLAG_DIALED); ast_replace_subargument_delimiter(opt_args[OPT_ARG_GOTO]); ast_parseable_goto(chan, opt_args[OPT_ARG_GOTO]); /* peer goes to the same context and extension as chan, so just copy info from chan*/ ast_channel_context_set(peer, ast_channel_context(chan)); ast_channel_exten_set(peer, ast_channel_exten(chan)); ast_channel_priority_set(peer, ast_channel_priority(chan) + 2); if (ast_pbx_start(peer)) { ast_autoservice_chan_hangup_peer(chan, peer); } hanguptree(&out_chans, NULL, ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE) ? 1 : 0); if (continue_exec) *continue_exec = 1; res = 0; goto done; } if (ast_test_flag64(&opts, OPT_CALLEE_MACRO) && !ast_strlen_zero(opt_args[OPT_ARG_CALLEE_MACRO])) { const char *macro_result_peer; /* Set peer->exten and peer->context so that MACRO_EXTEN and MACRO_CONTEXT get set */ ast_channel_lock_both(chan, peer); ast_channel_context_set(peer, ast_channel_context(chan)); ast_channel_exten_set(peer, ast_channel_exten(chan)); ast_channel_unlock(peer); ast_channel_unlock(chan); ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]); res = ast_app_exec_macro(chan, peer, opt_args[OPT_ARG_CALLEE_MACRO]); ast_channel_lock(peer); if (!res && (macro_result_peer = pbx_builtin_getvar_helper(peer, "MACRO_RESULT"))) { char *macro_result = ast_strdupa(macro_result_peer); char *macro_transfer_dest; ast_channel_unlock(peer); if (!strcasecmp(macro_result, "BUSY")) { ast_copy_string(pa.status, macro_result, sizeof(pa.status)); ast_set_flag64(peerflags, OPT_GO_ON); res = -1; } else if (!strcasecmp(macro_result, "CONGESTION") || !strcasecmp(macro_result, "CHANUNAVAIL")) { ast_copy_string(pa.status, macro_result, sizeof(pa.status)); ast_set_flag64(peerflags, OPT_GO_ON); res = -1; } else if (!strcasecmp(macro_result, "CONTINUE")) { /* hangup peer and keep chan alive assuming the macro has changed the context / exten / priority or perhaps the next priority in the current exten is desired. */ ast_set_flag64(peerflags, OPT_GO_ON); res = -1; } else if (!strcasecmp(macro_result, "ABORT")) { /* Hangup both ends unless the caller has the g flag */ res = -1; } else if (!strncasecmp(macro_result, "GOTO:", 5)) { macro_transfer_dest = macro_result + 5; res = -1; /* perform a transfer to a new extension */ if (strchr(macro_transfer_dest, '^')) { /* context^exten^priority*/ ast_replace_subargument_delimiter(macro_transfer_dest); if (!ast_parseable_goto(chan, macro_transfer_dest)) ast_set_flag64(peerflags, OPT_GO_ON); } } } else { ast_channel_unlock(peer); } } if (ast_test_flag64(&opts, OPT_CALLEE_GOSUB) && !ast_strlen_zero(opt_args[OPT_ARG_CALLEE_GOSUB])) { const char *gosub_result_peer; char *gosub_argstart; char *gosub_args = NULL; int res9 = -1; ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_GOSUB]); gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ','); if (gosub_argstart) { const char *what_is_s = "s"; *gosub_argstart = 0; if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) && ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) { what_is_s = "~~s~~"; } if (ast_asprintf(&gosub_args, "%s,%s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s, gosub_argstart + 1) < 0) { gosub_args = NULL; } *gosub_argstart = ','; } else { const char *what_is_s = "s"; if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) && ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) { what_is_s = "~~s~~"; } if (ast_asprintf(&gosub_args, "%s,%s,1", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s) < 0) { gosub_args = NULL; } } if (gosub_args) { res9 = ast_app_exec_sub(chan, peer, gosub_args, 0); ast_free(gosub_args); } else { ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n"); } ast_channel_lock_both(chan, peer); if (!res9 && (gosub_result_peer = pbx_builtin_getvar_helper(peer, "GOSUB_RESULT"))) { char *gosub_transfer_dest; char *gosub_result = ast_strdupa(gosub_result_peer); const char *gosub_retval = pbx_builtin_getvar_helper(peer, "GOSUB_RETVAL"); /* Inherit return value from the peer, so it can be used in the master */ if (gosub_retval) { pbx_builtin_setvar_helper(chan, "GOSUB_RETVAL", gosub_retval); } ast_channel_unlock(peer); ast_channel_unlock(chan); if (!strcasecmp(gosub_result, "BUSY")) { ast_copy_string(pa.status, gosub_result, sizeof(pa.status)); ast_set_flag64(peerflags, OPT_GO_ON); res = -1; } else if (!strcasecmp(gosub_result, "CONGESTION") || !strcasecmp(gosub_result, "CHANUNAVAIL")) { ast_copy_string(pa.status, gosub_result, sizeof(pa.status)); ast_set_flag64(peerflags, OPT_GO_ON); res = -1; } else if (!strcasecmp(gosub_result, "CONTINUE")) { /* Hangup peer and continue with the next extension priority. */ ast_set_flag64(peerflags, OPT_GO_ON); res = -1; } else if (!strcasecmp(gosub_result, "ABORT")) { /* Hangup both ends unless the caller has the g flag */ res = -1; } else if (!strncasecmp(gosub_result, "GOTO:", 5)) { gosub_transfer_dest = gosub_result + 5; res = -1; /* perform a transfer to a new extension */ if (strchr(gosub_transfer_dest, '^')) { /* context^exten^priority*/ ast_replace_subargument_delimiter(gosub_transfer_dest); if (!ast_parseable_goto(chan, gosub_transfer_dest)) ast_set_flag64(peerflags, OPT_GO_ON); } } } else { ast_channel_unlock(peer); ast_channel_unlock(chan); } } if (!res) { if (!ast_tvzero(calldurationlimit)) { struct timeval whentohangup = ast_tvadd(ast_tvnow(), calldurationlimit); ast_channel_whentohangup_set(peer, &whentohangup); } if (!ast_strlen_zero(dtmfcalled)) { ast_verb(3, "Sending DTMF '%s' to the called party.\n", dtmfcalled); res = ast_dtmf_stream(peer, chan, dtmfcalled, 250, 0); } if (!ast_strlen_zero(dtmfcalling)) { ast_verb(3, "Sending DTMF '%s' to the calling party.\n", dtmfcalling); res = ast_dtmf_stream(chan, peer, dtmfcalling, 250, 0); } } if (res) { /* some error */ res = -1; } else { if (ast_test_flag64(peerflags, OPT_CALLEE_TRANSFER)) ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT); if (ast_test_flag64(peerflags, OPT_CALLER_TRANSFER)) ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT); if (ast_test_flag64(peerflags, OPT_CALLEE_HANGUP)) ast_set_flag(&(config.features_callee), AST_FEATURE_DISCONNECT); if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP)) ast_set_flag(&(config.features_caller), AST_FEATURE_DISCONNECT); if (ast_test_flag64(peerflags, OPT_CALLEE_MONITOR)) ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON); if (ast_test_flag64(peerflags, OPT_CALLER_MONITOR)) ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON); if (ast_test_flag64(peerflags, OPT_CALLEE_PARK)) ast_set_flag(&(config.features_callee), AST_FEATURE_PARKCALL); if (ast_test_flag64(peerflags, OPT_CALLER_PARK)) ast_set_flag(&(config.features_caller), AST_FEATURE_PARKCALL); if (ast_test_flag64(peerflags, OPT_CALLEE_MIXMONITOR)) ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMIXMON); if (ast_test_flag64(peerflags, OPT_CALLER_MIXMONITOR)) ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMIXMON); if (ast_test_flag64(peerflags, OPT_GO_ON)) ast_set_flag(&(config.features_caller), AST_FEATURE_NO_H_EXTEN); config.end_bridge_callback = end_bridge_callback; config.end_bridge_callback_data = chan; config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup; if (moh) { moh = 0; ast_moh_stop(chan); } else if (sentringing) { sentringing = 0; ast_indicate(chan, -1); } /* Be sure no generators are left on it and reset the visible indication */ ast_deactivate_generator(chan); ast_channel_visible_indication_set(chan, 0); /* Make sure channels are compatible */ res = ast_channel_make_compatible(chan, peer); if (res < 0) { ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", ast_channel_name(chan), ast_channel_name(peer)); ast_autoservice_chan_hangup_peer(chan, peer); res = -1; goto done; } if (opermode) { struct oprmode oprmode; oprmode.peer = peer; oprmode.mode = opermode; ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0); } res = ast_bridge_call(chan, peer, &config); } ast_channel_context_set(peer, ast_channel_context(chan)); if (ast_test_flag64(&opts, OPT_PEER_H) && ast_exists_extension(peer, ast_channel_context(peer), "h", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) { ast_autoservice_start(chan); ast_pbx_h_exten_run(peer, ast_channel_context(peer)); ast_autoservice_stop(chan); } if (!ast_check_hangup(peer)) { if (ast_test_flag64(&opts, OPT_CALLEE_GO_ON)) { int goto_res; if (!ast_strlen_zero(opt_args[OPT_ARG_CALLEE_GO_ON])) { ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_GO_ON]); goto_res = ast_parseable_goto(peer, opt_args[OPT_ARG_CALLEE_GO_ON]); } else { /* F() */ goto_res = ast_goto_if_exists(peer, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1); } if (!goto_res && !ast_pbx_start(peer)) { /* The peer is now running its own PBX. */ goto out; } } } else if (!ast_check_hangup(chan)) { ast_channel_hangupcause_set(chan, ast_channel_hangupcause(peer)); } ast_autoservice_chan_hangup_peer(chan, peer); } out: if (moh) { moh = 0; ast_moh_stop(chan); } else if (sentringing) { sentringing = 0; ast_indicate(chan, -1); } if (delprivintro && ast_fileexists(pa.privintro, NULL, NULL) > 0) { ast_filedelete(pa.privintro, NULL); if (ast_fileexists(pa.privintro, NULL, NULL) > 0) { ast_log(LOG_NOTICE, "privacy: ast_filedelete didn't do its job on %s\n", pa.privintro); } else { ast_verb(3, "Successfully deleted %s intro file\n", pa.privintro); } } ast_channel_early_bridge(chan, NULL); hanguptree(&out_chans, NULL, ast_channel_hangupcause(chan)==AST_CAUSE_ANSWERED_ELSEWHERE || ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE) ? 1 : 0 ); /* forward 'answered elsewhere' if we received it */ pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); senddialendevent(chan, pa.status); ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status); if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_INCOMPLETE)) { if (!ast_tvzero(calldurationlimit)) memset(ast_channel_whentohangup(chan), 0, sizeof(*ast_channel_whentohangup(chan))); res = 0; } done: if (config.warning_sound) { ast_free((char *)config.warning_sound); } if (config.end_sound) { ast_free((char *)config.end_sound); } if (config.start_sound) { ast_free((char *)config.start_sound); } ast_ignore_cc(chan); return res; } static int dial_exec(struct ast_channel *chan, const char *data) { struct ast_flags64 peerflags; memset(&peerflags, 0, sizeof(peerflags)); return dial_exec_full(chan, data, &peerflags, NULL); } static int retrydial_exec(struct ast_channel *chan, const char *data) { char *parse; const char *context = NULL; int sleepms = 0, loops = 0, res = -1; struct ast_flags64 peerflags = { 0, }; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(announce); AST_APP_ARG(sleep); AST_APP_ARG(retries); AST_APP_ARG(dialdata); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "RetryDial requires an argument!\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (!ast_strlen_zero(args.sleep) && (sleepms = atoi(args.sleep))) sleepms *= 1000; if (!ast_strlen_zero(args.retries)) { loops = atoi(args.retries); } if (!args.dialdata) { ast_log(LOG_ERROR, "%s requires a 4th argument (dialdata)\n", rapp); goto done; } if (sleepms < 1000) sleepms = 10000; if (!loops) loops = -1; /* run forever */ ast_channel_lock(chan); context = pbx_builtin_getvar_helper(chan, "EXITCONTEXT"); context = !ast_strlen_zero(context) ? ast_strdupa(context) : NULL; ast_channel_unlock(chan); res = 0; while (loops) { int continue_exec; ast_channel_data_set(chan, "Retrying"); if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_stop(chan); res = dial_exec_full(chan, args.dialdata, &peerflags, &continue_exec); if (continue_exec) break; if (res == 0) { if (ast_test_flag64(&peerflags, OPT_DTMF_EXIT)) { if (!ast_strlen_zero(args.announce)) { if (ast_fileexists(args.announce, NULL, ast_channel_language(chan)) > 0) { if (!(res = ast_streamfile(chan, args.announce, ast_channel_language(chan)))) ast_waitstream(chan, AST_DIGIT_ANY); } else ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce); } if (!res && sleepms) { if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_start(chan, NULL, NULL); res = ast_waitfordigit(chan, sleepms); } } else { if (!ast_strlen_zero(args.announce)) { if (ast_fileexists(args.announce, NULL, ast_channel_language(chan)) > 0) { if (!(res = ast_streamfile(chan, args.announce, ast_channel_language(chan)))) res = ast_waitstream(chan, ""); } else ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce); } if (sleepms) { if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_start(chan, NULL, NULL); if (!res) res = ast_waitfordigit(chan, sleepms); } } } if (res < 0 || res == AST_PBX_INCOMPLETE) { break; } else if (res > 0) { /* Trying to send the call elsewhere (1 digit ext) */ if (onedigit_goto(chan, context, (char) res, 1)) { res = 0; break; } } loops--; } if (loops == 0) res = 0; else if (res == 1) res = 0; if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_stop(chan); done: return res; } static int unload_module(void) { int res; res = ast_unregister_application(app); res |= ast_unregister_application(rapp); return res; } static int load_module(void) { int res; res = ast_register_application_xml(app, dial_exec); res |= ast_register_application_xml(rapp, retrydial_exec); return res; } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dialing Application"); asterisk-11.7.0/apps/app_dictate.c0000644000175000007640000002130412006037127016727 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2005, Anthony Minessale II * * Anthony Minessale II * * Donated by Sangoma Technologies * * 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 Virtual Dictation Machine Application For Asterisk * * \author Anthony Minessale II * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 370655 $") #include #include "asterisk/paths.h" /* use ast_config_AST_SPOOL_DIR */ #include "asterisk/file.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/say.h" #include "asterisk/app.h" /*** DOCUMENTATION Virtual Dictation Machine. Start dictation machine using optional base_dir for files. ***/ static const char app[] = "Dictate"; typedef enum { DFLAG_RECORD = (1 << 0), DFLAG_PLAY = (1 << 1), DFLAG_TRUNC = (1 << 2), DFLAG_PAUSE = (1 << 3), } dflags; typedef enum { DMODE_INIT, DMODE_RECORD, DMODE_PLAY } dmodes; #define ast_toggle_flag(it,flag) if(ast_test_flag(it, flag)) ast_clear_flag(it, flag); else ast_set_flag(it, flag) static int play_and_wait(struct ast_channel *chan, char *file, char *digits) { int res = -1; if (!ast_streamfile(chan, file, ast_channel_language(chan))) { res = ast_waitstream(chan, digits); } return res; } static int dictate_exec(struct ast_channel *chan, const char *data) { char *path = NULL, filein[256], *filename = ""; char *parse; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(base); AST_APP_ARG(filename); ); char dftbase[256]; char *base; struct ast_flags flags = {0}; struct ast_filestream *fs; struct ast_frame *f = NULL; int ffactor = 320 * 80, res = 0, done = 0, lastop = 0, samples = 0, speed = 1, digit = 0, len = 0, maxlen = 0, mode = 0; struct ast_format oldr; ast_format_clear(&oldr); snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR); if (!ast_strlen_zero(data)) { parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); } else args.argc = 0; if (args.argc && !ast_strlen_zero(args.base)) { base = args.base; } else { base = dftbase; } if (args.argc > 1 && args.filename) { filename = args.filename; } ast_format_copy(&oldr, ast_channel_readformat(chan)); if ((res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) < 0) { ast_log(LOG_WARNING, "Unable to set to linear mode.\n"); return -1; } if (ast_channel_state(chan) != AST_STATE_UP) { ast_answer(chan); } ast_safe_sleep(chan, 200); for (res = 0; !res;) { if (ast_strlen_zero(filename)) { if (ast_app_getdata(chan, "dictate/enter_filename", filein, sizeof(filein), 0) || ast_strlen_zero(filein)) { res = -1; break; } } else { ast_copy_string(filein, filename, sizeof(filein)); filename = ""; } ast_mkdir(base, 0755); len = strlen(base) + strlen(filein) + 2; if (!path || len > maxlen) { path = ast_alloca(len); memset(path, 0, len); maxlen = len; } else { memset(path, 0, maxlen); } snprintf(path, len, "%s/%s", base, filein); fs = ast_writefile(path, "raw", NULL, O_CREAT|O_APPEND, 0, AST_FILE_MODE); mode = DMODE_PLAY; memset(&flags, 0, sizeof(flags)); ast_set_flag(&flags, DFLAG_PAUSE); digit = play_and_wait(chan, "dictate/forhelp", AST_DIGIT_ANY); done = 0; speed = 1; res = 0; lastop = 0; samples = 0; while (!done && ((res = ast_waitfor(chan, -1)) > -1) && fs && (f = ast_read(chan))) { if (digit) { struct ast_frame fr = {AST_FRAME_DTMF, { .integer = digit } }; ast_queue_frame(chan, &fr); digit = 0; } if ((f->frametype == AST_FRAME_DTMF)) { int got = 1; switch(mode) { case DMODE_PLAY: switch (f->subclass.integer) { case '1': ast_set_flag(&flags, DFLAG_PAUSE); mode = DMODE_RECORD; break; case '2': speed++; if (speed > 4) { speed = 1; } res = ast_say_number(chan, speed, AST_DIGIT_ANY, ast_channel_language(chan), NULL); break; case '7': samples -= ffactor; if(samples < 0) { samples = 0; } ast_seekstream(fs, samples, SEEK_SET); break; case '8': samples += ffactor; ast_seekstream(fs, samples, SEEK_SET); break; default: got = 0; } break; case DMODE_RECORD: switch (f->subclass.integer) { case '1': ast_set_flag(&flags, DFLAG_PAUSE); mode = DMODE_PLAY; break; case '8': ast_toggle_flag(&flags, DFLAG_TRUNC); lastop = 0; break; default: got = 0; } break; default: got = 0; } if (!got) { switch (f->subclass.integer) { case '#': done = 1; continue; break; case '*': ast_toggle_flag(&flags, DFLAG_PAUSE); if (ast_test_flag(&flags, DFLAG_PAUSE)) { digit = play_and_wait(chan, "dictate/pause", AST_DIGIT_ANY); } else { digit = play_and_wait(chan, mode == DMODE_PLAY ? "dictate/playback" : "dictate/record", AST_DIGIT_ANY); } break; case '0': ast_set_flag(&flags, DFLAG_PAUSE); digit = play_and_wait(chan, "dictate/paused", AST_DIGIT_ANY); switch(mode) { case DMODE_PLAY: digit = play_and_wait(chan, "dictate/play_help", AST_DIGIT_ANY); break; case DMODE_RECORD: digit = play_and_wait(chan, "dictate/record_help", AST_DIGIT_ANY); break; } if (digit == 0) { digit = play_and_wait(chan, "dictate/both_help", AST_DIGIT_ANY); } else if (digit < 0) { done = 1; break; } break; } } } else if (f->frametype == AST_FRAME_VOICE) { switch(mode) { struct ast_frame *fr; int x; case DMODE_PLAY: if (lastop != DMODE_PLAY) { if (ast_test_flag(&flags, DFLAG_PAUSE)) { digit = play_and_wait(chan, "dictate/playback_mode", AST_DIGIT_ANY); if (digit == 0) { digit = play_and_wait(chan, "dictate/paused", AST_DIGIT_ANY); } else if (digit < 0) { break; } } if (lastop != DFLAG_PLAY) { lastop = DFLAG_PLAY; ast_closestream(fs); if (!(fs = ast_openstream(chan, path, ast_channel_language(chan)))) break; ast_seekstream(fs, samples, SEEK_SET); ast_channel_stream_set(chan, NULL); } lastop = DMODE_PLAY; } if (!ast_test_flag(&flags, DFLAG_PAUSE)) { for (x = 0; x < speed; x++) { if ((fr = ast_readframe(fs))) { ast_write(chan, fr); samples += fr->samples; ast_frfree(fr); fr = NULL; } else { samples = 0; ast_seekstream(fs, 0, SEEK_SET); } } } break; case DMODE_RECORD: if (lastop != DMODE_RECORD) { int oflags = O_CREAT | O_WRONLY; if (ast_test_flag(&flags, DFLAG_PAUSE)) { digit = play_and_wait(chan, "dictate/record_mode", AST_DIGIT_ANY); if (digit == 0) { digit = play_and_wait(chan, "dictate/paused", AST_DIGIT_ANY); } else if (digit < 0) { break; } } lastop = DMODE_RECORD; ast_closestream(fs); if ( ast_test_flag(&flags, DFLAG_TRUNC)) { oflags |= O_TRUNC; digit = play_and_wait(chan, "dictate/truncating_audio", AST_DIGIT_ANY); } else { oflags |= O_APPEND; } fs = ast_writefile(path, "raw", NULL, oflags, 0, AST_FILE_MODE); if (ast_test_flag(&flags, DFLAG_TRUNC)) { ast_seekstream(fs, 0, SEEK_SET); ast_clear_flag(&flags, DFLAG_TRUNC); } else { ast_seekstream(fs, 0, SEEK_END); } } if (!ast_test_flag(&flags, DFLAG_PAUSE)) { res = ast_writestream(fs, f); } break; } } ast_frfree(f); } } if (oldr.id) { ast_set_read_format(chan, &oldr); } return 0; } static int unload_module(void) { int res; res = ast_unregister_application(app); return res; } static int load_module(void) { return ast_register_application_xml(app, dictate_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Virtual Dictation Machine"); asterisk-11.7.0/apps/app_sms.c0000644000175000007640000017422112253651331016126 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2004 - 2005, Adrian Kennard, rights assigned to Digium * * 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 SMS application - ETSI ES 201 912 protocol 1 implementation * * \par Development notes * \note The ETSI standards are available free of charge from ETSI at * http://pda.etsi.org/pda/queryform.asp * Among the relevant documents here we have: * * ES 201 912 SMS for PSTN/ISDN * TS 123 040 Technical realization of SMS * * * \ingroup applications * * \author Adrian Kennard (for the original protocol 1 code) * \author Filippo Grassilli (Hyppo) - protocol 2 support * Not fully tested, under development */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 403978 $") #include #include #include #include "asterisk/paths.h" /* use ast_config_AST_SPOOL_DIR and LOG_DIR */ #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/alaw.h" #include "asterisk/callerid.h" #include "asterisk/utils.h" #include "asterisk/app.h" /*** DOCUMENTATION Communicates with SMS service centres and SMS capable analogue phones. The name of the queue used in /var/spool/asterisk/sms SMS handles exchange of SMS data with a call to/from SMS capable phone or SMS PSTN service center. Can send and/or receive SMS messages. Works to ETSI ES 201 912; compatible with BT SMS PSTN service in UK and Telecom Italia in Italy. Typical usage is to use to handle calls from the SMS service centre CLI, or to set up a call using outgoing or manager interface to connect service centre to SMS(). "Messages are processed as per text file message queues. smsq (a separate software) is a command to generate message queues and send messages. The protocol has tight delay bounds. Please use short frames and disable/keep short the jitter buffer on the ATA to make sure that respones (ACK etc.) are received in time. ***/ /* #define OUTALAW */ /* enable this to output Alaw rather than linear */ /* ToDo */ /* Add full VP support */ /* Handle status report messages (generation and reception) */ /* Time zones on time stamps */ /* user ref field */ static volatile unsigned char message_ref; /* arbitary message ref */ static volatile unsigned int seq; /* arbitrary message sequence number for unqiue files */ static char log_file[255]; static char *app = "SMS"; /* * 80 samples of a single period of the wave. At 8000 Hz, it means these * are the samples of a 100 Hz signal. * To pick the two carriers (1300Hz for '1' and 2100 Hz for '0') used by * the modulation, we should take one every 13 and 21 samples respectively. */ static const signed short wave[] = { 0, 392, 782, 1167, 1545, 1913, 2270, 2612, 2939, 3247, 3536, 3802, 4045, 4263, 4455, 4619, 4755, 4862, 4938, 4985, 5000, 4985, 4938, 4862, 4755, 4619, 4455, 4263, 4045, 3802, 3536, 3247, 2939, 2612, 2270, 1913, 1545, 1167, 782, 392, 0, -392, -782, -1167, -1545, -1913, -2270, -2612, -2939, -3247, -3536, -3802, -4045, -4263, -4455, -4619, -4755, -4862, -4938, -4985, -5000, -4985, -4938, -4862, -4755, -4619, -4455, -4263, -4045, -3802, -3536, -3247, -2939, -2612, -2270, -1913, -1545, -1167, -782, -392 }; #ifdef OUTALAW static unsigned char wavea[80]; typedef unsigned char output_t; static const output_t *wave_out = wavea; /* outgoing samples */ #define __OUT_FMT AST_FORMAT_ALAW; #else typedef signed short output_t; static const output_t *wave_out = wave; /* outgoing samples */ #define __OUT_FMT AST_FORMAT_SLINEAR #endif #define OSYNC_BITS 80 /* initial sync bits */ /*! * The SMS spec ETSI ES 201 912 defines two protocols with different message types. * Also note that the high bit is used to indicate whether the message * is complete or not, but in two opposite ways: * for Protocol 1, 0x80 means that the message is complete; * for Protocol 2, 0x00 means that the message is complete; */ enum message_types { DLL_SMS_MASK = 0x7f, /* mask for the valid bits */ /* Protocol 1 values */ DLL1_SMS_DATA = 0x11, /* data packet */ DLL1_SMS_ERROR = 0x12, DLL1_SMS_EST = 0x13, /* start the connection */ DLL1_SMS_REL = 0x14, /* end the connection */ DLL1_SMS_ACK = 0x15, DLL1_SMS_NACK = 0x16, DLL1_SMS_COMPLETE = 0x80, /* packet is complete */ DLL1_SMS_MORE = 0x00, /* more data to follow */ /* Protocol 2 values */ DLL2_SMS_EST = 0x7f, /* magic number. No message body */ DLL2_SMS_INFO_MO = 0x10, DLL2_SMS_INFO_MT = 0x11, DLL2_SMS_INFO_STA = 0x12, DLL2_SMS_NACK = 0x13, DLL2_SMS_ACK0 = 0x14, /* ack even-numbered frame */ DLL2_SMS_ACK1 = 0x15, /* ack odd-numbered frame */ DLL2_SMS_ENQ = 0x16, DLL2_SMS_REL = 0x17, /* end the connection */ DLL2_SMS_COMPLETE = 0x00, /* packet is complete */ DLL2_SMS_MORE = 0x80, /* more data to follow */ }; /* SMS 7 bit character mapping to UCS-2 */ static const unsigned short defaultalphabet[] = { 0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC, 0x00F2, 0x00E7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5, 0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0, 0x03A8, 0x03A3, 0x0398, 0x039E, 0x00A0, 0x00C6, 0x00E6, 0x00DF, 0x00C9, ' ', '!', '"', '#', 164, '%', '&', 39, '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', 161, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 196, 214, 209, 220, 167, 191, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 228, 246, 241, 252, 224, }; static const unsigned short escapes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x000C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x005E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x007B, 0x007D, 0, 0, 0, 0, 0, 0x005C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x005B, 0x007E, 0x005D, 0, 0x007C, 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, 0x20AC, 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, }; #define SMSLEN 160 /*!< max SMS length */ #define SMSLEN_8 140 /*!< max SMS length for 8-bit char */ typedef struct sms_s { unsigned char hangup; /*!< we are done... */ unsigned char err; /*!< set for any errors */ unsigned char smsc:1; /*!< we are SMSC */ unsigned char rx:1; /*!< this is a received message */ char queue[30]; /*!< queue name */ char oa[20]; /*!< originating address */ char da[20]; /*!< destination address */ struct timeval scts; /*!< time stamp, UTC */ unsigned char pid; /*!< protocol ID */ unsigned char dcs; /*!< data coding scheme */ short mr; /*!< message reference - actually a byte, but use -1 for not set */ int udl; /*!< user data length */ int udhl; /*!< user data header length */ unsigned char srr:1; /*!< Status Report request */ unsigned char udhi:1; /*!< User Data Header required, even if length 0 */ unsigned char rp:1; /*!< Reply Path */ unsigned int vp; /*!< validity period in minutes, 0 for not set */ unsigned short ud[SMSLEN]; /*!< user data (message), UCS-2 coded */ unsigned char udh[SMSLEN]; /*!< user data header */ char cli[20]; /*!< caller ID */ unsigned char ophase; /*!< phase (0-79) for 0 and 1 frequencies (1300Hz and 2100Hz) */ unsigned char ophasep; /*!< phase (0-79) for 1200 bps */ unsigned char obyte; /*!< byte being sent */ unsigned int opause; /*!< silent pause before sending (in sample periods) */ unsigned char obitp; /*!< bit in byte */ unsigned char osync; /*!< sync bits to send */ unsigned char obytep; /*!< byte in data */ unsigned char obyten; /*!< bytes in data */ unsigned char omsg[256]; /*!< data buffer (out) */ unsigned char imsg[250]; /*!< data buffer (in) */ signed long long ims0, imc0, ims1, imc1; /*!< magnitude averages sin/cos 0/1 */ unsigned int idle; unsigned short imag; /*!< signal level */ unsigned char ips0; /*!< phase sin for bit 0, start at 0 inc by 21 mod 80 */ unsigned char ips1; /*!< phase cos for bit 0, start at 20 inc by 21 mod 80 */ unsigned char ipc0; /*!< phase sin for bit 1, start at 0 inc by 13 mod 80 */ unsigned char ipc1; /*!< phase cos for bit 1, start at 20 inc by 13 mod 80 */ unsigned char ibitl; /*!< last bit */ unsigned char ibitc; /*!< bit run length count */ unsigned char iphasep; /*!< bit phase (0-79) for 1200 bps */ unsigned char ibitn; /*!< bit number in byte being received */ unsigned char ibytev; /*!< byte value being received */ unsigned char ibytep; /*!< byte pointer in message */ unsigned char ibytec; /*!< byte checksum for message */ unsigned char ierr; /*!< error flag */ unsigned char ibith; /*!< history of last bits */ unsigned char ibitt; /*!< total of 1's in last 3 bytes */ /* more to go here */ int opause_0; /*!< initial delay in ms, p() option */ int protocol; /*!< ETSI SMS protocol to use (passed at app call) */ int oseizure; /*!< protocol 2: channel seizure bits to send */ int framenumber; /*!< protocol 2: frame number (for sending ACK0 or ACK1) */ char udtxt[SMSLEN]; /*!< user data (message), PLAIN text */ } sms_t; /* different types of encoding */ #define is7bit(dcs) ( ((dcs) & 0xC0) ? (!((dcs) & 4) ) : (((dcs) & 0xc) == 0) ) #define is8bit(dcs) ( ((dcs) & 0xC0) ? ( ((dcs) & 4) ) : (((dcs) & 0xc) == 4) ) #define is16bit(dcs) ( ((dcs) & 0xC0) ? 0 : (((dcs) & 0xc) == 8) ) static void sms_messagetx(sms_t *h); /*! \brief copy number, skipping non digits apart from leading + */ static void numcpy(char *d, char *s) { if (*s == '+') { *d++ = *s++; } while (*s) { if (isdigit(*s)) { *d++ = *s; } s++; } *d = 0; } /*! \brief static, return a date/time in ISO format */ static char *isodate(time_t t, char *buf, int len) { struct ast_tm tm; struct timeval local = { t, 0 }; ast_localtime(&local, &tm, NULL); ast_strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm); return buf; } /*! \brief Reads next UCS character from NUL terminated UTF-8 string and advance pointer */ /* for non valid UTF-8 sequences, returns character as is */ /* Does not advance pointer for null termination */ static long utf8decode(unsigned char **pp) { unsigned char *p = *pp; if (!*p) { return 0; /* null termination of string */ } (*pp)++; if (*p < 0xC0) { return *p; /* ascii or continuation character */ } if (*p < 0xE0) { if (*p < 0xC2 || (p[1] & 0xC0) != 0x80) { return *p; /* not valid UTF-8 */ } (*pp)++; return ((*p & 0x1F) << 6) + (p[1] & 0x3F); } if (*p < 0xF0) { if ((*p == 0xE0 && p[1] < 0xA0) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80) { return *p; /* not valid UTF-8 */ } (*pp) += 2; return ((*p & 0x0F) << 12) + ((p[1] & 0x3F) << 6) + (p[2] & 0x3F); } if (*p < 0xF8) { if ((*p == 0xF0 && p[1] < 0x90) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80) { return *p; /* not valid UTF-8 */ } (*pp) += 3; return ((*p & 0x07) << 18) + ((p[1] & 0x3F) << 12) + ((p[2] & 0x3F) << 6) + (p[3] & 0x3F); } if (*p < 0xFC) { if ((*p == 0xF8 && p[1] < 0x88) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80 || (p[4] & 0xC0) != 0x80) { return *p; /* not valid UTF-8 */ } (*pp) += 4; return ((*p & 0x03) << 24) + ((p[1] & 0x3F) << 18) + ((p[2] & 0x3F) << 12) + ((p[3] & 0x3F) << 6) + (p[4] & 0x3F); } if (*p < 0xFE) { if ((*p == 0xFC && p[1] < 0x84) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80 || (p[4] & 0xC0) != 0x80 || (p[5] & 0xC0) != 0x80) { return *p; /* not valid UTF-8 */ } (*pp) += 5; return ((*p & 0x01) << 30) + ((p[1] & 0x3F) << 24) + ((p[2] & 0x3F) << 18) + ((p[3] & 0x3F) << 12) + ((p[4] & 0x3F) << 6) + (p[5] & 0x3F); } return *p; /* not sensible */ } /*! \brief takes a binary header (udhl bytes at udh) and UCS-2 message (udl characters at ud) and packs in to o using SMS 7 bit character codes */ /* The return value is the number of septets packed in to o, which is internally limited to SMSLEN */ /* o can be null, in which case this is used to validate or count only */ /* if the input contains invalid characters then the return value is -1 */ static int packsms7(unsigned char *o, int udhl, unsigned char *udh, int udl, unsigned short *ud) { unsigned char p = 0; /* output pointer (bytes) */ unsigned char b = 0; /* bit position */ unsigned char n = 0; /* output character count */ unsigned char dummy[SMSLEN]; if (o == NULL) { /* output to a dummy buffer if o not set */ o = dummy; } if (udhl) { /* header */ o[p++] = udhl; b = 1; n = 1; while (udhl--) { o[p++] = *udh++; b += 8; while (b >= 7) { b -= 7; n++; } if (n >= SMSLEN) return n; } if (b) { b = 7 - b; if (++n >= SMSLEN) return n; } /* filling to septet boundary */ } o[p] = 0; /* message */ while (udl--) { long u; unsigned char v; u = *ud++; /* XXX 0 is invalid ? */ /* look up in defaultalphabet[]. If found, v is the 7-bit code */ for (v = 0; v < 128 && defaultalphabet[v] != u; v++); if (v == 128 /* not found */ && u && n + 1 < SMSLEN) { /* if not found, look in the escapes table (we need 2 bytes) */ for (v = 0; v < 128 && escapes[v] != u; v++); if (v < 128) { /* escaped sequence, esc + v */ /* store the low (8-b) bits in o[p], the remaining bits in o[p+1] */ o[p] |= (27 << b); /* the low bits go into o[p] */ b += 7; if (b >= 8) { b -= 8; p++; o[p] = (27 >> (7 - b)); } n++; } } if (v == 128) return -1; /* invalid character */ /* store, same as above */ o[p] |= (v << b); b += 7; if (b >= 8) { b -= 8; p++; o[p] = (v >> (7 - b)); } if (++n >= SMSLEN) return n; } return n; } /*! \brief takes a binary header (udhl bytes at udh) and UCS-2 message (udl characters at ud) * and packs in to o using 8 bit character codes. * The return value is the number of bytes packed in to o, which is internally limited to 140. * o can be null, in which case this is used to validate or count only. * if the input contains invalid characters then the return value is -1 */ static int packsms8(unsigned char *o, int udhl, unsigned char *udh, int udl, unsigned short *ud) { unsigned char p = 0; unsigned char dummy[SMSLEN_8]; if (o == NULL) o = dummy; /* header - no encoding */ if (udhl) { o[p++] = udhl; while (udhl--) { o[p++] = *udh++; if (p >= SMSLEN_8) { return p; } } } while (udl--) { long u; u = *ud++; if (u < 0 || u > 0xFF) { return -1; /* not valid */ } o[p++] = u; if (p >= SMSLEN_8) { return p; } } return p; } /*! \brief takes a binary header (udhl bytes at udh) and UCS-2 message (udl characters at ud) and packs in to o using 16 bit UCS-2 character codes The return value is the number of bytes packed in to o, which is internally limited to 140 o can be null, in which case this is used to validate or count only if the input contains invalid characters then the return value is -1 */ static int packsms16(unsigned char *o, int udhl, unsigned char *udh, int udl, unsigned short *ud) { unsigned char p = 0; unsigned char dummy[SMSLEN_8]; if (o == NULL) { o = dummy; } /* header - no encoding */ if (udhl) { o[p++] = udhl; while (udhl--) { o[p++] = *udh++; if (p >= SMSLEN_8) { return p; } } } while (udl--) { long u; u = *ud++; o[p++] = (u >> 8); if (p >= SMSLEN_8) { return p - 1; /* could not fit last character */ } o[p++] = u; if (p >= SMSLEN_8) { return p; } } return p; } /*! \brief general pack, with length and data, returns number of bytes of target used */ static int packsms(unsigned char dcs, unsigned char *base, unsigned int udhl, unsigned char *udh, int udl, unsigned short *ud) { unsigned char *p = base; if (udl == 0) { *p++ = 0; /* no user data */ } else { int l = 0; if (is7bit(dcs)) { /* 7 bit */ if ((l = packsms7(p + 1, udhl, udh, udl, ud)) < 0) { l = 0; } *p++ = l; p += (l * 7 + 7) / 8; } else if (is8bit(dcs)) { /* 8 bit */ if ((l = packsms8(p + 1, udhl, udh, udl, ud)) < 0) { l = 0; } *p++ = l; p += l; } else { /* UCS-2 */ if ((l = packsms16(p + 1, udhl, udh, udl, ud)) < 0) { l = 0; } *p++ = l; p += l; } } return p - base; } /*! \brief pack a date and return */ static void packdate(unsigned char *o, time_t w) { struct ast_tm t; struct timeval topack = { w, 0 }; int z; ast_localtime(&topack, &t, NULL); #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__) z = -t.tm_gmtoff / 60 / 15; #else z = timezone / 60 / 15; #endif *o++ = ((t.tm_year % 10) << 4) + (t.tm_year % 100) / 10; *o++ = (((t.tm_mon + 1) % 10) << 4) + (t.tm_mon + 1) / 10; *o++ = ((t.tm_mday % 10) << 4) + t.tm_mday / 10; *o++ = ((t.tm_hour % 10) << 4) + t.tm_hour / 10; *o++ = ((t.tm_min % 10) << 4) + t.tm_min / 10; *o++ = ((t.tm_sec % 10) << 4) + t.tm_sec / 10; if (z < 0) { *o++ = (((-z) % 10) << 4) + (-z) / 10 + 0x08; } else { *o++ = ((z % 10) << 4) + z / 10; } } /*! \brief unpack a date and return */ static struct timeval unpackdate(unsigned char *i) { struct ast_tm t; t.tm_year = 100 + (i[0] & 0xF) * 10 + (i[0] >> 4); t.tm_mon = (i[1] & 0xF) * 10 + (i[1] >> 4) - 1; t.tm_mday = (i[2] & 0xF) * 10 + (i[2] >> 4); t.tm_hour = (i[3] & 0xF) * 10 + (i[3] >> 4); t.tm_min = (i[4] & 0xF) * 10 + (i[4] >> 4); t.tm_sec = (i[5] & 0xF) * 10 + (i[5] >> 4); t.tm_isdst = 0; if (i[6] & 0x08) { t.tm_min += 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4)); } else { t.tm_min -= 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4)); } return ast_mktime(&t, NULL); } /*! \brief unpacks bytes (7 bit encoding) at i, len l septets, and places in udh and ud setting udhl and udl. udh not used if udhi not set */ static void unpacksms7(unsigned char *i, unsigned char l, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi) { unsigned char b = 0, p = 0; unsigned short *o = ud; *udhl = 0; if (udhi && l) { /* header */ int h = i[p]; *udhl = h; if (h) { b = 1; p++; l--; while (h-- && l) { *udh++ = i[p++]; b += 8; while (b >= 7) { b -= 7; l--; if (!l) { break; } } } /* adjust for fill, septets */ if (b) { b = 7 - b; l--; } } } while (l--) { unsigned char v; if (b < 2) { v = ((i[p] >> b) & 0x7F); /* everything in one byte */ } else { v = ((((i[p] >> b) + (i[p + 1] << (8 - b)))) & 0x7F); } b += 7; if (b >= 8) { b -= 8; p++; } /* 0x00A0 is the encoding of ESC (27) in defaultalphabet */ if (o > ud && o[-1] == 0x00A0 && escapes[v]) { o[-1] = escapes[v]; } else { *o++ = defaultalphabet[v]; } } *udl = (o - ud); } /*! \brief unpacks bytes (8 bit encoding) at i, len l septets, * and places in udh and ud setting udhl and udl. udh not used * if udhi not set. */ static void unpacksms8(unsigned char *i, unsigned char l, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi) { unsigned short *o = ud; *udhl = 0; if (udhi) { int n = *i; *udhl = n; if (n) { i++; l--; while (l && n) { l--; n--; *udh++ = *i++; } } } while (l--) { *o++ = *i++; /* not to UTF-8 as explicitly 8 bit coding in DCS */ } *udl = (o - ud); } /*! \brief unpacks bytes (16 bit encoding) at i, len l septets, and places in udh and ud setting udhl and udl. udh not used if udhi not set */ static void unpacksms16(unsigned char *i, unsigned char l, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi) { unsigned short *o = ud; *udhl = 0; if (udhi) { int n = *i; *udhl = n; if (n) { i++; l--; while (l && n) { l--; n--; *udh++ = *i++; } } } while (l--) { int v = *i++; if (l && l--) { v = (v << 8) + *i++; } *o++ = v; } *udl = (o - ud); } /*! \brief general unpack - starts with length byte (octet or septet) and returns number of bytes used, inc length */ static int unpacksms(unsigned char dcs, unsigned char *i, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi) { int l = *i++; if (is7bit(dcs)) { unpacksms7(i, l, udh, udhl, ud, udl, udhi); l = (l * 7 + 7) / 8; /* adjust length to return */ } else if (is8bit(dcs)) { unpacksms8(i, l, udh, udhl, ud, udl, udhi); } else { l += l % 2; unpacksms16(i, l, udh, udhl, ud, udl, udhi); } return l + 1; } /*! \brief unpack an address from i, return byte length, unpack to o */ static unsigned char unpackaddress(char *o, unsigned char *i) { unsigned char l = i[0], p; if (i[1] == 0x91) { *o++ = '+'; } for (p = 0; p < l; p++) { if (p & 1) { *o++ = (i[2 + p / 2] >> 4) + '0'; } else { *o++ = (i[2 + p / 2] & 0xF) + '0'; } } *o = 0; return (l + 5) / 2; } /*! \brief store an address at o, and return number of bytes used */ static unsigned char packaddress(unsigned char *o, char *i) { unsigned char p = 2; o[0] = 0; /* number of bytes */ if (*i == '+') { /* record as bit 0 in byte 1 */ i++; o[1] = 0x91; } else { o[1] = 0x81; } for ( ; *i ; i++) { if (!isdigit(*i)) { /* ignore non-digits */ continue; } if (o[0] & 1) { o[p++] |= ((*i & 0xF) << 4); } else { o[p] = (*i & 0xF); } o[0]++; } if (o[0] & 1) { o[p++] |= 0xF0; /* pad */ } return p; } /*! \brief Log the output, and remove file */ static void sms_log(sms_t * h, char status) { int o; if (*h->oa == '\0' && *h->da == '\0') { return; } o = open(log_file, O_CREAT | O_APPEND | O_WRONLY, AST_FILE_MODE); if (o >= 0) { char line[1000], mrs[3] = "", *p; char buf[30]; unsigned char n; if (h->mr >= 0) { snprintf(mrs, sizeof(mrs), "%02X", h->mr); } snprintf(line, sizeof(line), "%s %c%c%c%s %s %s %s ", isodate(time(NULL), buf, sizeof(buf)), status, h->rx ? 'I' : 'O', h->smsc ? 'S' : 'M', mrs, h->queue, S_OR(h->oa, "-"), S_OR(h->da, "-") ); p = line + strlen(line); for (n = 0; n < h->udl; n++) { if (h->ud[n] == '\\') { *p++ = '\\'; *p++ = '\\'; } else if (h->ud[n] == '\n') { *p++ = '\\'; *p++ = 'n'; } else if (h->ud[n] == '\r') { *p++ = '\\'; *p++ = 'r'; } else if (h->ud[n] < 32 || h->ud[n] == 127) { *p++ = 191; } else { *p++ = h->ud[n]; } } *p++ = '\n'; *p = 0; if (write(o, line, strlen(line)) < 0) { ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); } close(o); } *h->oa = *h->da = h->udl = 0; } /*! \brief parse and delete a file */ static void sms_readfile(sms_t * h, char *fn) { char line[1000]; FILE *s; char dcsset = 0; /* if DSC set */ ast_log(LOG_NOTICE, "Sending %s\n", fn); h->rx = h->udl = *h->oa = *h->da = h->pid = h->srr = h->udhi = h->rp = h->vp = h->udhl = 0; h->mr = -1; h->dcs = 0xF1; /* normal messages class 1 */ h->scts = ast_tvnow(); s = fopen(fn, "r"); if (s) { if (unlink(fn)) { /* concurrent access, we lost */ fclose(s); return; } while (fgets (line, sizeof(line), s)) { /* process line in file */ char *p; void *pp = &p; for (p = line; *p && *p != '\n' && *p != '\r'; p++); *p = 0; /* strip eoln */ p = line; if (!*p || *p == ';') { continue; /* blank line or comment, ignore */ } while (isalnum(*p)) { *p = tolower (*p); p++; } while (isspace (*p)) { *p++ = 0; } if (*p == '=') { *p++ = 0; if (!strcmp(line, "ud")) { /* parse message (UTF-8) */ unsigned char o = 0; memcpy(h->udtxt, p, SMSLEN); /* for protocol 2 */ while (*p && o < SMSLEN) { h->ud[o++] = utf8decode(pp); } h->udl = o; if (*p) { ast_log(LOG_WARNING, "UD too long in %s\n", fn); } } else { while (isspace (*p)) { p++; } if (!strcmp(line, "oa") && strlen(p) < sizeof(h->oa)) { numcpy (h->oa, p); } else if (!strcmp(line, "da") && strlen(p) < sizeof(h->oa)) { numcpy (h->da, p); } else if (!strcmp(line, "pid")) { h->pid = atoi(p); } else if (!strcmp(line, "dcs")) { h->dcs = atoi(p); dcsset = 1; } else if (!strcmp(line, "mr")) { h->mr = atoi(p); } else if (!strcmp(line, "srr")) { h->srr = (atoi(p) ? 1 : 0); } else if (!strcmp(line, "vp")) { h->vp = atoi(p); } else if (!strcmp(line, "rp")) { h->rp = (atoi(p) ? 1 : 0); } else if (!strcmp(line, "scts")) { /* get date/time */ int Y, m, d, H, M, S; /* XXX Why aren't we using ast_strptime here? */ if (sscanf(p, "%4d-%2d-%2dT%2d:%2d:%2d", &Y, &m, &d, &H, &M, &S) == 6) { struct ast_tm t = { 0, }; t.tm_year = Y - 1900; t.tm_mon = m - 1; t.tm_mday = d; t.tm_hour = H; t.tm_min = M; t.tm_sec = S; t.tm_isdst = -1; h->scts = ast_mktime(&t, NULL); if (h->scts.tv_sec == 0) { ast_log(LOG_WARNING, "Bad date/timein %s: %s", fn, p); } } } else { ast_log(LOG_WARNING, "Cannot parse in %s: %s=%si\n", fn, line, p); } } } else if (*p == '#') { /* raw hex format */ *p++ = 0; if (*p == '#') { p++; if (!strcmp(line, "ud")) { /* user data */ int o = 0; while (*p && o < SMSLEN) { if (isxdigit(*p) && isxdigit(p[1]) && isxdigit(p[2]) && isxdigit(p[3])) { h->ud[o++] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 12) + (((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) + (((isalpha(p[2]) ? 9 : 0) + (p[2] & 0xF)) << 4) + ((isalpha(p[3]) ? 9 : 0) + (p[3] & 0xF)); p += 4; } else break; } h->udl = o; if (*p) ast_log(LOG_WARNING, "UD too long / invalid UCS-2 hex in %s\n", fn); } else ast_log(LOG_WARNING, "Only ud can use ## format, %s\n", fn); } else if (!strcmp(line, "ud")) { /* user data */ int o = 0; while (*p && o < SMSLEN) { if (isxdigit(*p) && isxdigit(p[1])) { h->ud[o++] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)); p += 2; } else { break; } } h->udl = o; if (*p) { ast_log(LOG_WARNING, "UD too long / invalid UCS-1 hex in %s\n", fn); } } else if (!strcmp(line, "udh")) { /* user data header */ unsigned char o = 0; h->udhi = 1; while (*p && o < SMSLEN) { if (isxdigit(*p) && isxdigit(p[1])) { h->udh[o] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)); o++; p += 2; } else { break; } } h->udhl = o; if (*p) { ast_log(LOG_WARNING, "UDH too long / invalid hex in %s\n", fn); } } else { ast_log(LOG_WARNING, "Only ud and udh can use # format, %s\n", fn); } } else { ast_log(LOG_WARNING, "Cannot parse in %s: %s\n", fn, line); } } fclose(s); if (!dcsset && packsms7(0, h->udhl, h->udh, h->udl, h->ud) < 0) { if (packsms8(0, h->udhl, h->udh, h->udl, h->ud) < 0) { if (packsms16(0, h->udhl, h->udh, h->udl, h->ud) < 0) { ast_log(LOG_WARNING, "Invalid UTF-8 message even for UCS-2 (%s)\n", fn); } else { h->dcs = 0x08; /* default to 16 bit */ ast_log(LOG_WARNING, "Sending in 16 bit format(%s)\n", fn); } } else { h->dcs = 0xF5; /* default to 8 bit */ ast_log(LOG_WARNING, "Sending in 8 bit format(%s)\n", fn); } } if (is7bit(h->dcs) && packsms7(0, h->udhl, h->udh, h->udl, h->ud) < 0) { ast_log(LOG_WARNING, "Invalid 7 bit GSM data %s\n", fn); } if (is8bit(h->dcs) && packsms8(0, h->udhl, h->udh, h->udl, h->ud) < 0) { ast_log(LOG_WARNING, "Invalid 8 bit data %s\n", fn); } if (is16bit(h->dcs) && packsms16(0, h->udhl, h->udh, h->udl, h->ud) < 0) { ast_log(LOG_WARNING, "Invalid 16 bit data %s\n", fn); } } } /*! \brief white a received text message to a file */ static void sms_writefile(sms_t * h) { char fn[200] = "", fn2[200] = ""; char buf[30]; FILE *o; if (ast_tvzero(h->scts)) { h->scts = ast_tvnow(); } snprintf(fn, sizeof(fn), "%s/sms/%s", ast_config_AST_SPOOL_DIR, h->smsc ? h->rx ? "morx" : "mttx" : h->rx ? "mtrx" : "motx"); ast_mkdir(fn, 0777); /* ensure it exists */ ast_copy_string(fn2, fn, sizeof(fn2)); snprintf(fn2 + strlen(fn2), sizeof(fn2) - strlen(fn2), "/%s.%s-%d", h->queue, isodate(h->scts.tv_sec, buf, sizeof(buf)), seq++); snprintf(fn + strlen(fn), sizeof(fn) - strlen(fn), "/.%s", fn2 + strlen(fn) + 1); if ((o = fopen(fn, "w")) == NULL) { return; } if (*h->oa) { fprintf(o, "oa=%s\n", h->oa); } if (*h->da) { fprintf(o, "da=%s\n", h->da); } if (h->udhi) { unsigned int p; fprintf(o, "udh#"); for (p = 0; p < h->udhl; p++) { fprintf(o, "%02X", h->udh[p]); } fprintf(o, "\n"); } if (h->udl) { unsigned int p; for (p = 0; p < h->udl && h->ud[p] >= ' '; p++); if (p < h->udl) { fputc(';', o); /* cannot use ud=, but include as a comment for human readable */ } fprintf(o, "ud="); for (p = 0; p < h->udl; p++) { unsigned short v = h->ud[p]; if (v < 32) { fputc(191, o); } else if (v < 0x80) { fputc(v, o); } else if (v < 0x800) { fputc(0xC0 + (v >> 6), o); fputc(0x80 + (v & 0x3F), o); } else { fputc(0xE0 + (v >> 12), o); fputc(0x80 + ((v >> 6) & 0x3F), o); fputc(0x80 + (v & 0x3F), o); } } fprintf(o, "\n"); for (p = 0; p < h->udl && h->ud[p] >= ' '; p++); if (p < h->udl) { for (p = 0; p < h->udl && h->ud[p] < 0x100; p++); if (p == h->udl) { /* can write in ucs-1 hex */ fprintf(o, "ud#"); for (p = 0; p < h->udl; p++) { fprintf(o, "%02X", h->ud[p]); } fprintf(o, "\n"); } else { /* write in UCS-2 */ fprintf(o, "ud##"); for (p = 0; p < h->udl; p++) { fprintf(o, "%04X", h->ud[p]); } fprintf(o, "\n"); } } } if (h->scts.tv_sec) { char datebuf[30]; fprintf(o, "scts=%s\n", isodate(h->scts.tv_sec, datebuf, sizeof(datebuf))); } if (h->pid) { fprintf(o, "pid=%d\n", h->pid); } if (h->dcs != 0xF1) { fprintf(o, "dcs=%d\n", h->dcs); } if (h->vp) { fprintf(o, "vp=%d\n", h->vp); } if (h->srr) { fprintf(o, "srr=1\n"); } if (h->mr >= 0) { fprintf(o, "mr=%d\n", h->mr); } if (h->rp) { fprintf(o, "rp=1\n"); } fclose(o); if (rename(fn, fn2)) { unlink(fn); } else { ast_log(LOG_NOTICE, "Received to %s\n", fn2); } } /*! \brief read dir skipping dot files... */ static struct dirent *readdirqueue(DIR *d, char *queue) { struct dirent *f; do { f = readdir(d); } while (f && (*f->d_name == '.' || strncmp(f->d_name, queue, strlen(queue)) || f->d_name[strlen(queue)] != '.')); return f; } /*! \brief handle the incoming message */ static unsigned char sms_handleincoming (sms_t * h) { unsigned char p = 3; if (h->smsc) { /* SMSC */ if ((h->imsg[2] & 3) == 1) { /* SMS-SUBMIT */ h->udhl = h->udl = 0; h->vp = 0; h->srr = ((h->imsg[2] & 0x20) ? 1 : 0); h->udhi = ((h->imsg[2] & 0x40) ? 1 : 0); h->rp = ((h->imsg[2] & 0x80) ? 1 : 0); ast_copy_string(h->oa, h->cli, sizeof(h->oa)); h->scts = ast_tvnow(); h->mr = h->imsg[p++]; p += unpackaddress(h->da, h->imsg + p); h->pid = h->imsg[p++]; h->dcs = h->imsg[p++]; if ((h->imsg[2] & 0x18) == 0x10) { /* relative VP */ if (h->imsg[p] < 144) { h->vp = (h->imsg[p] + 1) * 5; } else if (h->imsg[p] < 168) { h->vp = 720 + (h->imsg[p] - 143) * 30; } else if (h->imsg[p] < 197) { h->vp = (h->imsg[p] - 166) * 1440; } else { h->vp = (h->imsg[p] - 192) * 10080; } p++; } else if (h->imsg[2] & 0x18) { p += 7; /* ignore enhanced / absolute VP */ } p += unpacksms(h->dcs, h->imsg + p, h->udh, &h->udhl, h->ud, &h->udl, h->udhi); h->rx = 1; /* received message */ sms_writefile(h); /* write the file */ if (p != h->imsg[1] + 2) { ast_log(LOG_WARNING, "Mismatch receive unpacking %d/%d\n", p, h->imsg[1] + 2); return 0xFF; /* duh! */ } } else { ast_log(LOG_WARNING, "Unknown message type %02X\n", h->imsg[2]); return 0xFF; } } else { /* client */ if (!(h->imsg[2] & 3)) { /* SMS-DELIVER */ *h->da = h->srr = h->rp = h->vp = h->udhi = h->udhl = h->udl = 0; h->srr = ((h->imsg[2] & 0x20) ? 1 : 0); h->udhi = ((h->imsg[2] & 0x40) ? 1 : 0); h->rp = ((h->imsg[2] & 0x80) ? 1 : 0); h->mr = -1; p += unpackaddress(h->oa, h->imsg + p); h->pid = h->imsg[p++]; h->dcs = h->imsg[p++]; h->scts = unpackdate(h->imsg + p); p += 7; p += unpacksms(h->dcs, h->imsg + p, h->udh, &h->udhl, h->ud, &h->udl, h->udhi); h->rx = 1; /* received message */ sms_writefile(h); /* write the file */ if (p != h->imsg[1] + 2) { ast_log(LOG_WARNING, "Mismatch receive unpacking %d/%d\n", p, h->imsg[1] + 2); return 0xFF; /* duh! */ } } else { ast_log(LOG_WARNING, "Unknown message type %02X\n", h->imsg[2]); return 0xFF; } } return 0; /* no error */ } #ifdef SOLARIS #define NAME_MAX 1024 #endif /*! * Add data to a protocol 2 message. * Use the length field (h->omsg[1]) as a pointer to the next free position. */ static void adddata_proto2(sms_t *h, unsigned char msg, char *data, int size) { int x = h->omsg[1] + 2; /* Get current position */ if (x == 2) { x += 2; /* First: skip Payload length (set later) */ } h->omsg[x++] = msg; /* Message code */ h->omsg[x++] = (unsigned char)size; /* Data size Low */ h->omsg[x++] = 0; /* Data size Hi */ for (; size > 0 ; size--) { h->omsg[x++] = *data++; } h->omsg[1] = x - 2; /* Frame size */ h->omsg[2] = x - 4; /* Payload length (Lo) */ h->omsg[3] = 0; /* Payload length (Hi) */ } static void putdummydata_proto2(sms_t *h) { adddata_proto2(h, 0x10, "\0", 1); /* Media Identifier > SMS */ adddata_proto2(h, 0x11, "\0\0\0\0\0\0", 6); /* Firmware version */ adddata_proto2(h, 0x12, "\2\0\4", 3); /* SMS provider ID */ adddata_proto2(h, 0x13, h->udtxt, h->udl); /* Body */ } static void sms_compose2(sms_t *h, int more) { struct ast_tm tm; struct timeval now = h->scts; char stm[9]; h->omsg[0] = 0x00; /* set later... */ h->omsg[1] = 0; putdummydata_proto2(h); if (h->smsc) { /* deliver */ h->omsg[0] = 0x11; /* SMS_DELIVERY */ /* Required: 10 11 12 13 14 15 17 (seems they must be ordered!) */ ast_localtime(&now, &tm, NULL); sprintf(stm, "%02d%02d%02d%02d", tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min); /* Date mmddHHMM */ adddata_proto2(h, 0x14, stm, 8); /* Date */ if (*h->oa == 0) { strcpy(h->oa, "00000000"); } adddata_proto2(h, 0x15, h->oa, strlen(h->oa)); /* Originator */ adddata_proto2(h, 0x17, "\1", 1); /* Calling Terminal ID */ } else { /* submit */ h->omsg[0] = 0x10; /* SMS_SUBMIT */ /* Required: 10 11 12 13 17 18 1B 1C (seems they must be ordered!) */ adddata_proto2(h, 0x17, "\1", 1); /* Calling Terminal ID */ if (*h->da == 0) { strcpy(h->da, "00000000"); } adddata_proto2(h, 0x18, h->da, strlen(h->da)); /* Originator */ adddata_proto2(h, 0x1B, "\1", 1); /* Called Terminal ID */ adddata_proto2(h, 0x1C, "\0\0\0", 3); /* Notification */ } } static void putdummydata_proto2(sms_t *h); #define MAX_DEBUG_LEN 300 static char *sms_hexdump(unsigned char buf[], int size, char *s /* destination */) { char *p; int f; for (p = s, f = 0; f < size && f < MAX_DEBUG_LEN; f++, p += 3) { sprintf(p, "%02X ", (unsigned char)buf[f]); } return(s); } /*! \brief sms_handleincoming_proto2: handle the incoming message */ static int sms_handleincoming_proto2(sms_t *h) { int f, i, sz = 0; int msg, msgsz; struct ast_tm tm; struct timeval now = { 0, 0 }; char debug_buf[MAX_DEBUG_LEN * 3 + 1]; sz = h->imsg[1] + 2; /* ast_verb(3, "SMS-P2 Frame: %s\n", sms_hexdump(h->imsg, sz, debug_buf)); */ /* Parse message body (called payload) */ now = h->scts = ast_tvnow(); for (f = 4; f < sz; ) { msg = h->imsg[f++]; msgsz = h->imsg[f++]; msgsz += (h->imsg[f++] * 256); switch (msg) { case 0x13: /* Body */ ast_verb(3, "SMS-P2 Body#%02X=[%.*s]\n", msg, msgsz, &h->imsg[f]); if (msgsz >= sizeof(h->ud)) { msgsz = sizeof(h->ud) - 1; } for (i = 0; i < msgsz; i++) { h->ud[i] = h->imsg[f + i]; } h->udl = msgsz; break; case 0x14: /* Date SCTS */ now = h->scts = ast_tvnow(); ast_localtime(&now, &tm, NULL); tm.tm_mon = ( (h->imsg[f] * 10) + h->imsg[f + 1] ) - 1; tm.tm_mday = ( (h->imsg[f + 2] * 10) + h->imsg[f + 3] ); tm.tm_hour = ( (h->imsg[f + 4] * 10) + h->imsg[f + 5] ); tm.tm_min = ( (h->imsg[f + 6] * 10) + h->imsg[f + 7] ); tm.tm_sec = 0; h->scts = ast_mktime(&tm, NULL); ast_verb(3, "SMS-P2 Date#%02X=%02d/%02d %02d:%02d\n", msg, tm.tm_mday, tm.tm_mon + 1, tm.tm_hour, tm.tm_min); break; case 0x15: /* Calling line (from SMSC) */ if (msgsz >= 20) { msgsz = 20 - 1; } ast_verb(3, "SMS-P2 Origin#%02X=[%.*s]\n", msg, msgsz, &h->imsg[f]); ast_copy_string(h->oa, (char *)(&h->imsg[f]), msgsz + 1); break; case 0x18: /* Destination(from TE/phone) */ if (msgsz >= 20) { msgsz = 20 - 1; } ast_verb(3, "SMS-P2 Destination#%02X=[%.*s]\n", msg, msgsz, &h->imsg[f]); ast_copy_string(h->da, (char *)(&h->imsg[f]), msgsz + 1); break; case 0x1C: /* Notify */ ast_verb(3, "SMS-P2 Notify#%02X=%s\n", msg, sms_hexdump(&h->imsg[f], 3, debug_buf)); break; default: ast_verb(3, "SMS-P2 Par#%02X [%d]: %s\n", msg, msgsz, sms_hexdump(&h->imsg[f], msgsz, debug_buf)); break; } f+=msgsz; /* Skip to next */ } h->rx = 1; /* received message */ sms_writefile(h); /* write the file */ return 0; /* no error */ } #if 0 static void smssend(sms_t *h, char *c) { int f, x; for (f = 0; f < strlen(c); f++) { sscanf(&c[f*3], "%x", &x); h->omsg[f] = x; } sms_messagetx(h); } #endif static void sms_nextoutgoing (sms_t *h); static void sms_messagerx2(sms_t * h) { int p = h->imsg[0] & DLL_SMS_MASK ; /* mask the high bit */ int cause; #define DLL2_ACK(h) ((h->framenumber & 1) ? DLL2_SMS_ACK1: DLL2_SMS_ACK1) switch (p) { case DLL2_SMS_EST: /* Protocol 2: Connection ready (fake): send message */ sms_nextoutgoing (h); /* smssend(h,"11 29 27 00 10 01 00 00 11 06 00 00 00 00 00 00 00 12 03 00 02 00 04 13 01 00 41 14 08 00 30 39 31 35 30 02 30 02 15 02 00 39 30 "); */ break; case DLL2_SMS_INFO_MO: /* transport SMS_SUBMIT */ case DLL2_SMS_INFO_MT: /* transport SMS_DELIVERY */ cause = sms_handleincoming_proto2(h); if (!cause) { /* ACK */ sms_log(h, 'Y'); } h->omsg[0] = DLL2_ACK(h); h->omsg[1] = 0x06; /* msg len */ h->omsg[2] = 0x04; /* payload len */ h->omsg[3] = 0x00; /* payload len */ h->omsg[4] = 0x1f; /* Response type */ h->omsg[5] = 0x01; /* parameter len */ h->omsg[6] = 0x00; /* parameter len */ h->omsg[7] = cause; /* CONFIRM or error */ sms_messagetx(h); break; case DLL2_SMS_NACK: /* Protocol 2: SMS_NAK */ h->omsg[0] = DLL2_SMS_REL; /* SMS_REL */ h->omsg[1] = 0x00; /* msg len */ sms_messagetx(h); break; case DLL2_SMS_ACK0: case DLL2_SMS_ACK1: /* SMS_ACK also transport SMS_SUBMIT or SMS_DELIVERY */ if ( (h->omsg[0] & DLL_SMS_MASK) == DLL2_SMS_REL) { /* a response to our Release, just hangup */ h->hangup = 1; /* hangup */ } else { /* XXX depending on what we are.. */ ast_log(LOG_NOTICE, "SMS_SUBMIT or SMS_DELIVERY\n"); sms_nextoutgoing (h); } break; case DLL2_SMS_REL: /* Protocol 2: SMS_REL (hangup req) */ h->omsg[0] = DLL2_ACK(h); h->omsg[1] = 0; sms_messagetx(h); break; } } /*! \brief compose a message for protocol 1 */ static void sms_compose1(sms_t *h, int more) { unsigned int p = 2; /* next byte to write. Skip type and len */ h->omsg[0] = 0x91; /* SMS_DATA */ if (h->smsc) { /* deliver */ h->omsg[p++] = (more ? 4 : 0) + ((h->udhl > 0) ? 0x40 : 0); p += packaddress(h->omsg + p, h->oa); h->omsg[p++] = h->pid; h->omsg[p++] = h->dcs; packdate(h->omsg + p, h->scts.tv_sec); p += 7; p += packsms(h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud); } else { /* submit */ h->omsg[p++] = 0x01 + (more ? 4 : 0) + (h->srr ? 0x20 : 0) + (h->rp ? 0x80 : 0) + (h->vp ? 0x10 : 0) + (h->udhi ? 0x40 : 0); if (h->mr < 0) { h->mr = message_ref++; } h->omsg[p++] = h->mr; p += packaddress(h->omsg + p, h->da); h->omsg[p++] = h->pid; h->omsg[p++] = h->dcs; if (h->vp) { /* relative VP */ if (h->vp < 720) { h->omsg[p++] = (h->vp + 4) / 5 - 1; } else if (h->vp < 1440) { h->omsg[p++] = (h->vp - 720 + 29) / 30 + 143; } else if (h->vp < 43200) { h->omsg[p++] = (h->vp + 1439) / 1440 + 166; } else if (h->vp < 635040) { h->omsg[p++] = (h->vp + 10079) / 10080 + 192; } else { h->omsg[p++] = 255; /* max */ } } p += packsms(h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud); } h->omsg[1] = p - 2; } /*! \brief find and fill in next message, or send a REL if none waiting */ static void sms_nextoutgoing (sms_t * h) { char fn[100 + NAME_MAX] = ""; DIR *d; char more = 0; *h->da = *h->oa = '\0'; /* clear destinations */ h->rx = 0; /* outgoing message */ snprintf(fn, sizeof(fn), "%s/sms/%s", ast_config_AST_SPOOL_DIR, h->smsc ? "mttx" : "motx"); ast_mkdir(fn, 0777); /* ensure it exists */ d = opendir(fn); if (d) { struct dirent *f = readdirqueue(d, h->queue); if (f) { snprintf(fn + strlen(fn), sizeof(fn) - strlen(fn), "/%s", f->d_name); sms_readfile(h, fn); if (readdirqueue(d, h->queue)) { more = 1; /* more to send */ } } closedir(d); } if (*h->da || *h->oa) { /* message to send */ if (h->protocol == 2) { sms_compose2(h, more); } else { sms_compose1(h, more); } } else { /* no message */ if (h->protocol == 2) { h->omsg[0] = 0x17; /* SMS_REL */ h->omsg[1] = 0; } else { h->omsg[0] = 0x94; /* SMS_REL */ h->omsg[1] = 0; } } sms_messagetx(h); } #define DIR_RX 1 #define DIR_TX 2 static void sms_debug (int dir, sms_t *h) { char txt[259 * 3 + 1]; char *p = txt; /* always long enough */ unsigned char *msg = (dir == DIR_RX) ? h->imsg : h->omsg; int n = (dir == DIR_RX) ? h->ibytep : msg[1] + 2; int q = 0; while (q < n && q < 30) { sprintf(p, " %02X", msg[q++]); p += 3; } if (q < n) { sprintf(p, "..."); } ast_verb(3, "SMS %s%s\n", dir == DIR_RX ? "RX" : "TX", txt); } static void sms_messagerx(sms_t * h) { int cause; sms_debug (DIR_RX, h); if (h->protocol == 2) { sms_messagerx2(h); return; } /* parse incoming message for Protocol 1 */ switch (h->imsg[0]) { case 0x91: /* SMS_DATA */ cause = sms_handleincoming (h); if (!cause) { sms_log(h, 'Y'); h->omsg[0] = 0x95; /* SMS_ACK */ h->omsg[1] = 0x02; h->omsg[2] = 0x00; /* deliver report */ h->omsg[3] = 0x00; /* no parameters */ } else { /* NACK */ sms_log(h, 'N'); h->omsg[0] = 0x96; /* SMS_NACK */ h->omsg[1] = 3; h->omsg[2] = 0; /* delivery report */ h->omsg[3] = cause; /* cause */ h->omsg[4] = 0; /* no parameters */ } sms_messagetx(h); break; case 0x92: /* SMS_ERROR */ h->err = 1; sms_messagetx(h); /* send whatever we sent again */ break; case 0x93: /* SMS_EST */ sms_nextoutgoing (h); break; case 0x94: /* SMS_REL */ h->hangup = 1; /* hangup */ break; case 0x95: /* SMS_ACK */ sms_log(h, 'Y'); sms_nextoutgoing (h); break; case 0x96: /* SMS_NACK */ h->err = 1; sms_log(h, 'N'); sms_nextoutgoing (h); break; default: /* Unknown */ h->omsg[0] = 0x92; /* SMS_ERROR */ h->omsg[1] = 1; h->omsg[2] = 3; /* unknown message type */ sms_messagetx(h); break; } } static void sms_messagetx(sms_t * h) { unsigned char c = 0, p; int len = h->omsg[1] + 2; /* total message length excluding checksum */ for (p = 0; p < len; p++) { /* compute checksum */ c += h->omsg[p]; } h->omsg[len] = 0 - c; /* actually, (256 - (c & 0fxx)) & 0xff) */ sms_debug(DIR_TX, h); h->framenumber++; /* Proto 2 */ h->obytep = 0; h->obitp = 0; if (h->protocol == 2) { /* Proto 2: */ h->oseizure = 300; /* 300bits (or more ?) */ h->obyte = 0; /* Seizure starts with space (0) */ if (h->omsg[0] == 0x7F) { h->opause = 8 * h->opause_0; /* initial message delay */ } else { h->opause = 400; } } else { /* Proto 1: */ h->oseizure = 0; /* No seizure */ h->obyte = 1; /* send mark ('1') at the beginning */ /* Change the initial message delay. BT requires 300ms, * but for others this might be way too much and the phone * could time out. XXX make it configurable. */ if (h->omsg[0] == 0x93) { h->opause = 8 * h->opause_0; /* initial message delay */ } else { h->opause = 200; } } /* Note - setting osync triggers the generator */ h->osync = OSYNC_BITS; /* 80 sync bits */ h->obyten = len + 1; /* bytes to send (including checksum) */ } /*! * outgoing data are produced by this generator function, that reads from * the descriptor whether it has data to send and which ones. */ static int sms_generate(struct ast_channel *chan, void *data, int len, int samples) { struct ast_frame f = { 0 }; #define MAXSAMPLES (800) output_t *buf; sms_t *h = data; int i; if (samples > MAXSAMPLES) { ast_log(LOG_WARNING, "Only doing %d samples (%d requested)\n", MAXSAMPLES, samples); samples = MAXSAMPLES; } len = samples * sizeof(*buf) + AST_FRIENDLY_OFFSET; buf = ast_alloca(len); f.frametype = AST_FRAME_VOICE; ast_format_set(&f.subclass.format, __OUT_FMT, 0); f.datalen = samples * sizeof(*buf); f.offset = AST_FRIENDLY_OFFSET; f.mallocd = 0; f.data.ptr = buf; f.samples = samples; f.src = "app_sms"; /* create a buffer containing the digital sms pattern */ for (i = 0; i < samples; i++) { buf[i] = wave_out[0]; /* default is silence */ if (h->opause) { h->opause--; } else if (h->obyten || h->osync) { /* sending data */ buf[i] = wave_out[h->ophase]; h->ophase += (h->obyte & 1) ? 13 : 21; /* compute next phase */ if (h->ophase >= 80) h->ophase -= 80; if ((h->ophasep += 12) >= 80) { /* time to send the next bit */ h->ophasep -= 80; if (h->oseizure > 0) { /* sending channel seizure (proto 2) */ h->oseizure--; h->obyte ^= 1; /* toggle low bit */ } else if (h->osync) { h->obyte = 1; /* send mark as sync bit */ h->osync--; /* sending sync bits */ if (h->osync == 0 && h->protocol == 2 && h->omsg[0] == DLL2_SMS_EST) { h->obytep = h->obyten = 0; /* we are done */ } } else { h->obitp++; if (h->obitp == 1) { h->obyte = 0; /* start bit; */ } else if (h->obitp == 2) { h->obyte = h->omsg[h->obytep]; } else if (h->obitp == 10) { h->obyte = 1; /* stop bit */ h->obitp = 0; h->obytep++; if (h->obytep == h->obyten) { h->obytep = h->obyten = 0; /* sent */ h->osync = 10; /* trailing marks */ } } else { h->obyte >>= 1; } } } } } if (ast_write(chan, &f) < 0) { ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", ast_channel_name(chan), strerror(errno)); return -1; } return 0; #undef MAXSAMPLES } /*! * Just return the pointer to the descriptor that we received. */ static void *sms_alloc(struct ast_channel *chan, void *sms_t_ptr) { return sms_t_ptr; } static void sms_release(struct ast_channel *chan, void *data) { return; /* nothing to do here. */ } static struct ast_generator smsgen = { .alloc = sms_alloc, .release = sms_release, .generate = sms_generate, }; /*! * Process an incoming frame, trying to detect the carrier and * decode the message. The two frequencies are 1300 and 2100 Hz. * The decoder detects the amplitude of the signal over the last * few samples, filtering the absolute values with a lowpass filter. * If the magnitude (h->imag) is large enough, multiply the signal * by the two carriers, and compute the amplitudes m0 and m1. * Record the current sample as '0' or '1' depending on which one is greater. * The last 3 bits are stored in h->ibith, with the count of '1' * bits in h->ibitt. * XXX the rest is to be determined. */ static void sms_process(sms_t * h, int samples, signed short *data) { int bit; /* * Ignore incoming audio while a packet is being transmitted, * the protocol is half-duplex. * Unfortunately this means that if the outbound and incoming * transmission overlap (which is an error condition anyways), * we may miss some data and this makes debugging harder. */ if (h->obyten || h->osync) { return; } for ( ; samples-- ; data++) { unsigned long long m0, m1; if (abs(*data) > h->imag) { h->imag = abs(*data); } else { h->imag = h->imag * 7 / 8; } if (h->imag <= 500) { /* below [arbitrary] threahold: lost carrier */ if (h->idle++ == 80000) { /* nothing happening */ ast_log(LOG_NOTICE, "No data, hanging up\n"); h->hangup = 1; h->err = 1; } if (h->ierr) { /* error */ ast_log(LOG_NOTICE, "Error %d, hanging up\n", h->ierr); /* Protocol 1 */ h->err = 1; h->omsg[0] = 0x92; /* error */ h->omsg[1] = 1; h->omsg[2] = h->ierr; sms_messagetx(h); /* send error */ } h->ierr = h->ibitn = h->ibytep = h->ibytec = 0; continue; } h->idle = 0; /* multiply signal by the two carriers. */ h->ims0 = (h->ims0 * 6 + *data * wave[h->ips0]) / 7; h->imc0 = (h->imc0 * 6 + *data * wave[h->ipc0]) / 7; h->ims1 = (h->ims1 * 6 + *data * wave[h->ips1]) / 7; h->imc1 = (h->imc1 * 6 + *data * wave[h->ipc1]) / 7; /* compute the amplitudes */ m0 = h->ims0 * h->ims0 + h->imc0 * h->imc0; m1 = h->ims1 * h->ims1 + h->imc1 * h->imc1; /* advance the sin/cos pointers */ if ((h->ips0 += 21) >= 80) { h->ips0 -= 80; } if ((h->ipc0 += 21) >= 80) { h->ipc0 -= 80; } if ((h->ips1 += 13) >= 80) { h->ips1 -= 80; } if ((h->ipc1 += 13) >= 80) { h->ipc1 -= 80; } /* set new bit to 1 or 0 depending on which value is stronger */ h->ibith <<= 1; if (m1 > m0) { h->ibith |= 1; } if (h->ibith & 8) { h->ibitt--; } if (h->ibith & 1) { h->ibitt++; } bit = ((h->ibitt > 1) ? 1 : 0); if (bit != h->ibitl) { h->ibitc = 1; } else { h->ibitc++; } h->ibitl = bit; if (!h->ibitn && h->ibitc == 4 && !bit) { h->ibitn = 1; h->iphasep = 0; } if (bit && h->ibitc == 200) { /* sync, restart message */ /* Protocol 2: empty connection ready (I am master) */ if (h->framenumber < 0 && h->ibytec >= 160 && !memcmp(h->imsg, "UUUUUUUUUUUUUUUUUUUU", 20)) { h->framenumber = 1; ast_verb(3, "SMS protocol 2 detected\n"); h->protocol = 2; h->imsg[0] = 0xff; /* special message (fake) */ h->imsg[1] = h->imsg[2] = 0x00; h->ierr = h->ibitn = h->ibytep = h->ibytec = 0; sms_messagerx(h); } h->ierr = h->ibitn = h->ibytep = h->ibytec = 0; } if (h->ibitn) { h->iphasep += 12; if (h->iphasep >= 80) { /* next bit */ h->iphasep -= 80; if (h->ibitn++ == 9) { /* end of byte */ if (!bit) { /* bad stop bit */ ast_log(LOG_NOTICE, "bad stop bit\n"); h->ierr = 0xFF; /* unknown error */ } else { if (h->ibytep < sizeof(h->imsg)) { h->imsg[h->ibytep] = h->ibytev; h->ibytec += h->ibytev; h->ibytep++; } else if (h->ibytep == sizeof(h->imsg)) { ast_log(LOG_NOTICE, "msg too large\n"); h->ierr = 2; /* bad message length */ } if (h->ibytep > 1 && h->ibytep == 3 + h->imsg[1] && !h->ierr) { if (!h->ibytec) { sms_messagerx(h); } else { ast_log(LOG_NOTICE, "bad checksum\n"); h->ierr = 1; /* bad checksum */ } } } h->ibitn = 0; } h->ibytev = (h->ibytev >> 1) + (bit ? 0x80 : 0); } } } } /* * Standard argument parsing: * - one enum for the flags we recognise, * - one enum for argument indexes * - AST_APP_OPTIONS() to drive the parsing routine * - in the function, AST_DECLARE_APP_ARGS(...) for the arguments. */ enum sms_flags { OPTION_BE_SMSC = (1 << 0), /* act as sms center */ OPTION_ANSWER = (1 << 1), /* answer on incoming calls */ OPTION_TWO = (1 << 2), /* Use Protocol Two */ OPTION_PAUSE = (1 << 3), /* pause before sending data, in ms */ OPTION_SRR = (1 << 4), /* set srr */ OPTION_DCS = (1 << 5), /* set dcs */ }; enum sms_opt_args { OPTION_ARG_PAUSE = 0, OPTION_ARG_ARRAY_SIZE }; AST_APP_OPTIONS(sms_options, { AST_APP_OPTION('s', OPTION_BE_SMSC), AST_APP_OPTION('a', OPTION_ANSWER), AST_APP_OPTION('t', OPTION_TWO), AST_APP_OPTION('r', OPTION_SRR), AST_APP_OPTION('o', OPTION_DCS), AST_APP_OPTION_ARG('p', OPTION_PAUSE, OPTION_ARG_PAUSE), } ); static int sms_exec(struct ast_channel *chan, const char *data) { int res = -1; sms_t h = { 0 }; /* argument parsing support */ struct ast_flags flags; char *parse, *sms_opts[OPTION_ARG_ARRAY_SIZE] = { 0, }; char *p; AST_DECLARE_APP_ARGS(sms_args, AST_APP_ARG(queue); AST_APP_ARG(options); AST_APP_ARG(addr); AST_APP_ARG(body); ); if (!data) { ast_log(LOG_ERROR, "Requires queue name at least\n"); return -1; } parse = ast_strdupa(data); /* create a local copy */ AST_STANDARD_APP_ARGS(sms_args, parse); if (sms_args.argc > 1) { ast_app_parse_options(sms_options, &flags, sms_opts, sms_args.options); } ast_verb(1, "sms argc %d queue <%s> opts <%s> addr <%s> body <%s>\n", sms_args.argc, S_OR(sms_args.queue, ""), S_OR(sms_args.options, ""), S_OR(sms_args.addr, ""), S_OR(sms_args.body, "") ); h.ipc0 = h.ipc1 = 20; /* phase for cosine */ h.dcs = 0xF1; /* default */ ast_copy_string(h.cli, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""), sizeof(h.cli)); if (ast_strlen_zero(sms_args.queue)) { ast_log(LOG_ERROR, "Requires queue name\n"); goto done; } if (strlen(sms_args.queue) >= sizeof(h.queue)) { ast_log(LOG_ERROR, "Queue name too long\n"); goto done; } ast_copy_string(h.queue, sms_args.queue, sizeof(h.queue)); for (p = h.queue; *p; p++) { if (!isalnum(*p)) { *p = '-'; /* make very safe for filenames */ } } h.smsc = ast_test_flag(&flags, OPTION_BE_SMSC); h.protocol = ast_test_flag(&flags, OPTION_TWO) ? 2 : 1; if (!ast_strlen_zero(sms_opts[OPTION_ARG_PAUSE])) { h.opause_0 = atoi(sms_opts[OPTION_ARG_PAUSE]); } if (h.opause_0 < 25 || h.opause_0 > 2000) { h.opause_0 = 300; /* default 300ms */ } ast_verb(1, "initial delay %dms\n", h.opause_0); /* the following apply if there is an arg3/4 and apply to the created message file */ if (ast_test_flag(&flags, OPTION_SRR)) { h.srr = 1; } if (ast_test_flag(&flags, OPTION_DCS)) { h.dcs = 1; } #if 0 case '1': case '2': case '3': case '4': case '5': case '6': case '7': /* set the pid for saved local message */ h.pid = 0x40 + (*d & 0xF); break; } #endif if (sms_args.argc > 2) { unsigned char *up; /* submitting a message, not taking call. */ /* deprecated, use smsq instead */ h.scts = ast_tvnow(); if (ast_strlen_zero(sms_args.addr) || strlen(sms_args.addr) >= sizeof(h.oa)) { ast_log(LOG_ERROR, "Address too long %s\n", sms_args.addr); goto done; } if (h.smsc) { ast_copy_string(h.oa, sms_args.addr, sizeof(h.oa)); } else { ast_copy_string(h.da, sms_args.addr, sizeof(h.da)); ast_copy_string(h.oa, h.cli, sizeof(h.oa)); } h.udl = 0; if (ast_strlen_zero(sms_args.body)) { ast_log(LOG_ERROR, "Missing body for %s\n", sms_args.addr); goto done; } up = (unsigned char *)sms_args.body; while (*up && h.udl < SMSLEN) { h.ud[h.udl++] = utf8decode(&up); } if (is7bit(h.dcs) && packsms7(0, h.udhl, h.udh, h.udl, h.ud) < 0) { ast_log(LOG_WARNING, "Invalid 7 bit GSM data\n"); goto done; } if (is8bit(h.dcs) && packsms8(0, h.udhl, h.udh, h.udl, h.ud) < 0) { ast_log(LOG_WARNING, "Invalid 8 bit data\n"); goto done; } if (is16bit(h.dcs) && packsms16(0, h.udhl, h.udh, h.udl, h.ud) < 0) { ast_log(LOG_WARNING, "Invalid 16 bit data\n"); goto done; } h.rx = 0; /* sent message */ h.mr = -1; sms_writefile(&h); res = h.err; goto done; } if (ast_channel_state(chan) != AST_STATE_UP) { /* make sure channel is answered before any TX */ ast_answer(chan); } if (ast_test_flag(&flags, OPTION_ANSWER)) { h.framenumber = 1; /* Proto 2 */ /* set up SMS_EST initial message */ if (h.protocol == 2) { h.omsg[0] = DLL2_SMS_EST; h.omsg[1] = 0; } else { h.omsg[0] = DLL1_SMS_EST | DLL1_SMS_COMPLETE; h.omsg[1] = 0; } sms_messagetx(&h); } res = ast_set_write_format_by_id(chan, __OUT_FMT); if (res >= 0) { res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR); } if (res < 0) { ast_log(LOG_ERROR, "Unable to set to linear mode, giving up\n"); goto done; } if ( (res = ast_activate_generator(chan, &smsgen, &h)) < 0) { ast_log(LOG_ERROR, "Failed to activate generator on '%s'\n", ast_channel_name(chan)); goto done; } /* Do our thing here */ for (;;) { struct ast_frame *f; int i = ast_waitfor(chan, -1); if (i < 0) { ast_log(LOG_NOTICE, "waitfor failed\n"); break; } if (h.hangup) { ast_log(LOG_NOTICE, "channel hangup\n"); break; } f = ast_read(chan); if (!f) { ast_log(LOG_NOTICE, "ast_read failed\n"); break; } if (f->frametype == AST_FRAME_VOICE) { sms_process(&h, f->samples, f->data.ptr); } ast_frfree(f); } res = h.err; /* XXX */ /* * The SMS generator data is on the stack. We _MUST_ make sure the generator * is stopped before returning from this function. */ ast_deactivate_generator(chan); sms_log(&h, '?'); /* log incomplete message */ done: return (res); } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { #ifdef OUTALAW int p; for (p = 0; p < 80; p++) { wavea[p] = AST_LIN2A(wave[p]); } #endif snprintf(log_file, sizeof(log_file), "%s/sms", ast_config_AST_LOG_DIR); return ast_register_application_xml(app, sms_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SMS/PSTN handler"); asterisk-11.7.0/apps/app_dumpchan.c0000644000175000007640000001470512207744111017121 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2004 - 2005, Anthony Minessale II. * * Anthony Minessale * * A license has been granted to Digium (via disclaimer) for the use of * this code. * * 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 Application to dump channel variables * * \author Anthony Minessale * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 397948 $") #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/channel.h" #include "asterisk/app.h" #include "asterisk/translate.h" /*** DOCUMENTATION Dump Info About The Calling Channel. Minimun verbose level Displays information on channel and listing of all channel variables. If level is specified, output is only displayed when the verbose level is currently set to that number or greater. NoOp Verbose ***/ static const char app[] = "DumpChan"; static int serialize_showchan(struct ast_channel *c, char *buf, size_t size) { struct timeval now; long elapsed_seconds = 0; int hour = 0, min = 0, sec = 0; char nf[256]; char cgrp[256]; char pgrp[256]; struct ast_str *write_transpath = ast_str_alloca(256); struct ast_str *read_transpath = ast_str_alloca(256); now = ast_tvnow(); memset(buf, 0, size); if (!c) return 0; if (ast_channel_cdr(c)) { elapsed_seconds = now.tv_sec - ast_channel_cdr(c)->start.tv_sec; hour = elapsed_seconds / 3600; min = (elapsed_seconds % 3600) / 60; sec = elapsed_seconds % 60; } snprintf(buf,size, "Name= %s\n" "Type= %s\n" "UniqueID= %s\n" "LinkedID= %s\n" "CallerIDNum= %s\n" "CallerIDName= %s\n" "ConnectedLineIDNum= %s\n" "ConnectedLineIDName=%s\n" "DNIDDigits= %s\n" "RDNIS= %s\n" "Parkinglot= %s\n" "Language= %s\n" "State= %s (%d)\n" "Rings= %d\n" "NativeFormat= %s\n" "WriteFormat= %s\n" "ReadFormat= %s\n" "RawWriteFormat= %s\n" "RawReadFormat= %s\n" "WriteTranscode= %s %s\n" "ReadTranscode= %s %s\n" "1stFileDescriptor= %d\n" "Framesin= %d %s\n" "Framesout= %d %s\n" "TimetoHangup= %ld\n" "ElapsedTime= %dh%dm%ds\n" "DirectBridge= %s\n" "IndirectBridge= %s\n" "Context= %s\n" "Extension= %s\n" "Priority= %d\n" "CallGroup= %s\n" "PickupGroup= %s\n" "Application= %s\n" "Data= %s\n" "Blocking_in= %s\n", ast_channel_name(c), ast_channel_tech(c)->type, ast_channel_uniqueid(c), ast_channel_linkedid(c), S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, "(N/A)"), S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, "(N/A)"), S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "(N/A)"), S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "(N/A)"), S_OR(ast_channel_dialed(c)->number.str, "(N/A)"), S_COR(ast_channel_redirecting(c)->from.number.valid, ast_channel_redirecting(c)->from.number.str, "(N/A)"), ast_channel_parkinglot(c), ast_channel_language(c), ast_state2str(ast_channel_state(c)), ast_channel_state(c), ast_channel_rings(c), ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)), ast_getformatname(ast_channel_writeformat(c)), ast_getformatname(ast_channel_readformat(c)), ast_getformatname(ast_channel_rawwriteformat(c)), ast_getformatname(ast_channel_rawreadformat(c)), ast_channel_writetrans(c) ? "Yes" : "No", ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath), ast_channel_readtrans(c) ? "Yes" : "No", ast_translate_path_to_str(ast_channel_readtrans(c), &read_transpath), ast_channel_fd(c, 0), ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)ast_channel_whentohangup(c)->tv_sec, hour, min, sec, ast_channel_internal_bridged_channel(c) ? ast_channel_name(ast_channel_internal_bridged_channel(c)) : "", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_print_group(cgrp, sizeof(cgrp), ast_channel_callgroup(c)), ast_print_group(pgrp, sizeof(pgrp), ast_channel_pickupgroup(c)), ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)", ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)", (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)")); return 0; } static int dumpchan_exec(struct ast_channel *chan, const char *data) { struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16); char info[2048]; int level = 0; static char *line = "================================================================================"; if (!ast_strlen_zero(data)) level = atoi(data); serialize_showchan(chan, info, sizeof(info)); pbx_builtin_serialize_variables(chan, &vars); ast_verb(level, "\n" "Dumping Info For Channel: %s:\n" "%s\n" "Info:\n" "%s\n" "Variables:\n" "%s%s\n", ast_channel_name(chan), line, info, ast_str_buffer(vars), line); return 0; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, dumpchan_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dump Info About The Calling Channel"); asterisk-11.7.0/apps/app_minivm.c0000644000175000007640000034270612077137351016635 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * and Edvina AB, Sollentuna, Sweden * * Mark Spencer (Comedian Mail) * and Olle E. Johansson, Edvina.net (Mini-Voicemail changes) * * 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 MiniVoiceMail - A Minimal Voicemail System for Asterisk * * A voicemail system in small building blocks, working together * based on the Comedian Mail voicemail system (app_voicemail.c). * * \par See also * \arg \ref Config_minivm * \arg \ref Config_minivm_examples * \arg \ref App_minivm * * \ingroup applications * * \page App_minivm Asterisk Mini-voicemail - A minimal voicemail system * * This is a minimal voicemail system, building blocks for something * else. It is built for multi-language systems. * The current version is focused on accounts where voicemail is * forwarded to users in e-mail. It's work in progress, with loosed ends hanging * around from the old voicemail system and it's configuration. * * Hopefully, we can expand this to be a full replacement of voicemail() and voicemailmain() * in the future. * * Dialplan applications * - minivmRecord - record voicemail and send as e-mail ( \ref minivm_record_exec() ) * - minivmGreet - Play user's greeting or default greeting ( \ref minivm_greet_exec() ) * - minivmNotify - Notify user of message ( \ref minivm_notify_exec() ) * - minivmDelete - Delete voicemail message ( \ref minivm_delete_exec() ) * - minivmAccMess - Record personal messages (busy | unavailable | temporary) * * Dialplan functions * - MINIVMACCOUNT() - A dialplan function * - MINIVMCOUNTER() - Manage voicemail-related counters for accounts or domains * * CLI Commands * - minivm list accounts * - minivm list zones * - minivm list templates * - minivm show stats * - minivm show settings * * Some notes * - General configuration in minivm.conf * - Users in realtime or configuration file * - Or configured on the command line with just the e-mail address * * Voicemail accounts are identified by userid and domain * * Language codes are like setlocale - langcode_countrycode * \note Don't use language codes like the rest of Asterisk, two letter countrycode. Use * language_country like setlocale(). * * Examples: * - Swedish, Sweden sv_se * - Swedish, Finland sv_fi * - English, USA en_us * - English, GB en_gb * * \par See also * \arg \ref Config_minivm * \arg \ref Config_minivm_examples * \arg \ref Minivm_directories * \arg \ref app_minivm.c * \arg Comedian mail: app_voicemail.c * \arg \ref descrip_minivm_accmess * \arg \ref descrip_minivm_greet * \arg \ref descrip_minivm_record * \arg \ref descrip_minivm_delete * \arg \ref descrip_minivm_notify * * \arg \ref App_minivm_todo */ /*! \page Minivm_directories Asterisk Mini-Voicemail Directory structure * * The directory structure for storing voicemail * - AST_SPOOL_DIR - usually /var/spool/asterisk (configurable in asterisk.conf) * - MVM_SPOOL_DIR - should be configurable, usually AST_SPOOL_DIR/voicemail * - Domain MVM_SPOOL_DIR/domain * - Username MVM_SPOOL_DIR/domain/username * - /greet : Recording of account owner's name * - /busy : Busy message * - /unavailable : Unavailable message * - /temp : Temporary message * * For account anita@localdomain.xx the account directory would as a default be * \b /var/spool/asterisk/voicemail/localdomain.xx/anita * * To avoid transcoding, these sound files should be converted into several formats * They are recorded in the format closest to the incoming streams * * * Back: \ref App_minivm */ /*! \page Config_minivm_examples Example dialplan for Mini-Voicemail * \section Example dialplan scripts for Mini-Voicemail * \verbinclude extensions_minivm.conf.sample * * Back: \ref App_minivm */ /*! \page App_minivm_todo Asterisk Mini-Voicemail - todo * - configure accounts from AMI? * - test, test, test, test * - fix "vm-theextensionis.gsm" voiceprompt from Allison in various formats * "The extension you are calling" * - For trunk, consider using channel storage for information passing between small applications * - Set default directory for voicemail * - New app for creating directory for account if it does not exist * - Re-insert code for IMAP storage at some point * - Jabber integration for notifications * - Figure out how to handle video in voicemail * - Integration with the HTTP server * - New app for moving messages between mailboxes, and optionally mark it as "new" * * For Asterisk 1.4/trunk * - Use string fields for minivm_account * * Back: \ref App_minivm */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 379609 $") #include #include #include #include #include #include #include #include "asterisk/paths.h" /* use various paths */ #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/config.h" #include "asterisk/say.h" #include "asterisk/module.h" #include "asterisk/app.h" #include "asterisk/manager.h" #include "asterisk/dsp.h" #include "asterisk/localtime.h" #include "asterisk/cli.h" #include "asterisk/utils.h" #include "asterisk/linkedlists.h" #include "asterisk/callerid.h" #include "asterisk/event.h" /*** DOCUMENTATION Receive Mini-Voicemail and forward via e-mail. Voicemail username Voicemail domain This application is part of the Mini-Voicemail system, configured in minivm.conf MiniVM records audio file in configured format and forwards message to e-mail and pager. If there's no user account for that address, a temporary account will be used with default options. The recorded file name and path will be stored in MVM_FILENAME and the duration of the message will be stored in MVM_DURATION If the caller hangs up after the recording, the only way to send the message and clean up is to execute in the h extension. The application will exit if any of the following DTMF digits are received and the requested extension exist in the current context. This is the status of the record operation Play Mini-Voicemail prompts. Voicemail username Voicemail domain This application is part of the Mini-Voicemail system, configured in minivm.conf. MinivmGreet() plays default prompts or user specific prompts for an account. Busy and unavailable messages can be choosen, but will be overridden if a temporary message exists for the account. This is the status of the greeting playback. Notify voicemail owner about new messages. Voicemail username Voicemail domain This application is part of the Mini-Voicemail system, configured in minivm.conf. MiniVMnotify forwards messages about new voicemail to e-mail and pager. If there's no user account for that address, a temporary account will be used with default options (set in minivm.conf). If the channel variable MVM_COUNTER is set, this will be used in the message file name and available in the template for the message. If no template is given, the default email template will be used to send email and default pager template to send paging message (if the user account is configured with a paging address. This is the status of the notification attempt Delete Mini-Voicemail voicemail messages. File to delete This application is part of the Mini-Voicemail system, configured in minivm.conf. It deletes voicemail file set in MVM_FILENAME or given filename. This is the status of the delete operation. Record account specific messages. Voicemail username Voicemail domain This application is part of the Mini-Voicemail system, configured in minivm.conf. Use this application to record account specific audio/video messages for busy, unavailable and temporary messages. Account specific directories will be created if they do not exist. This is the result of the attempt to record the specified greeting. FAILED is set if the file can't be created. Send Message Waiting Notification to subscriber(s) of mailbox. Voicemail username Voicemail domain Number of urgent messages in mailbox. Number of new messages in mailbox. Number of old messages in mailbox. This application is part of the Mini-Voicemail system, configured in minivm.conf. MinivmMWI is used to send message waiting indication to any devices whose channels have subscribed to the mailbox passed in the first parameter. Reads or sets counters for MiniVoicemail message. If account is given and it exists, the counter is specific for the account. If account is a domain and the domain directory exists, counters are specific for a domain. The name of the counter is a string, up to 10 characters. The counters never goes below zero. Valid operands for changing the value of a counter when assigning a value are: Increment by value. Decrement by value. Set to value. The operation is atomic and the counter is locked while changing the value. The counters are stored as text files in the minivm account directories. It might be better to use realtime functions if you are using a database to operate your Asterisk. MinivmRecord MinivmGreet MinivmNotify MinivmDelete MinivmAccMess MinivmMWI MINIVMACCOUNT Gets MiniVoicemail account information. Valid items are: Path to account mailbox (if account exists, otherwise temporary mailbox). 1 is static Minivm account exists, 0 otherwise. Full name of account owner. Email address used for account. Email template for account (default template if none is configured). Pager template for account (default template if none is configured). Account code for the voicemail account. Pin code for voicemail account. Time zone for voicemail account. Language for voicemail account. Channel variable value (set in configuration for account). MinivmRecord MinivmGreet MinivmNotify MinivmDelete MinivmAccMess MinivmMWI MINIVMCOUNTER ***/ #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define MVM_REVIEW (1 << 0) /*!< Review message */ #define MVM_OPERATOR (1 << 1) /*!< Operator exit during voicemail recording */ #define MVM_REALTIME (1 << 2) /*!< This user is a realtime account */ #define MVM_SVMAIL (1 << 3) #define MVM_ENVELOPE (1 << 4) #define MVM_PBXSKIP (1 << 9) #define MVM_ALLOCED (1 << 13) /*! \brief Default mail command to mail voicemail. Change it with the mailcmd= command in voicemail.conf */ #define SENDMAIL "/usr/sbin/sendmail -t" #define SOUND_INTRO "vm-intro" #define B64_BASEMAXINLINE 256 /*!< Buffer size for Base 64 attachment encoding */ #define B64_BASELINELEN 72 /*!< Line length for Base 64 endoded messages */ #define EOL "\r\n" #define MAX_DATETIME_FORMAT 512 #define MAX_NUM_CID_CONTEXTS 10 #define ERROR_LOCK_PATH -100 #define VOICEMAIL_DIR_MODE 0700 #define VOICEMAIL_CONFIG "minivm.conf" #define ASTERISK_USERNAME "asterisk" /*!< Default username for sending mail is asterisk\@localhost */ /*! \brief Message types for notification */ enum mvm_messagetype { MVM_MESSAGE_EMAIL, MVM_MESSAGE_PAGE /* For trunk: MVM_MESSAGE_JABBER, */ }; static char MVM_SPOOL_DIR[PATH_MAX]; /* Module declarations */ static char *app_minivm_record = "MinivmRecord"; /* Leave a message */ static char *app_minivm_greet = "MinivmGreet"; /* Play voicemail prompts */ static char *app_minivm_notify = "MinivmNotify"; /* Notify about voicemail by using one of several methods */ static char *app_minivm_delete = "MinivmDelete"; /* Notify about voicemail by using one of several methods */ static char *app_minivm_accmess = "MinivmAccMess"; /* Record personal voicemail messages */ static char *app_minivm_mwi = "MinivmMWI"; enum minivm_option_flags { OPT_SILENT = (1 << 0), OPT_BUSY_GREETING = (1 << 1), OPT_UNAVAIL_GREETING = (1 << 2), OPT_TEMP_GREETING = (1 << 3), OPT_NAME_GREETING = (1 << 4), OPT_RECORDGAIN = (1 << 5), }; enum minivm_option_args { OPT_ARG_RECORDGAIN = 0, OPT_ARG_ARRAY_SIZE = 1, }; AST_APP_OPTIONS(minivm_app_options, { AST_APP_OPTION('s', OPT_SILENT), AST_APP_OPTION('b', OPT_BUSY_GREETING), AST_APP_OPTION('u', OPT_UNAVAIL_GREETING), AST_APP_OPTION_ARG('g', OPT_RECORDGAIN, OPT_ARG_RECORDGAIN), }); AST_APP_OPTIONS(minivm_accmess_options, { AST_APP_OPTION('b', OPT_BUSY_GREETING), AST_APP_OPTION('u', OPT_UNAVAIL_GREETING), AST_APP_OPTION('t', OPT_TEMP_GREETING), AST_APP_OPTION('n', OPT_NAME_GREETING), }); /*!\internal * \brief Structure for linked list of Mini-Voicemail users: \ref minivm_accounts */ struct minivm_account { char username[AST_MAX_CONTEXT]; /*!< Mailbox username */ char domain[AST_MAX_CONTEXT]; /*!< Voicemail domain */ char pincode[10]; /*!< Secret pin code, numbers only */ char fullname[120]; /*!< Full name, for directory app */ char email[80]; /*!< E-mail address - override */ char pager[80]; /*!< E-mail address to pager (no attachment) */ char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Voicemail account account code */ char serveremail[80]; /*!< From: Mail address */ char externnotify[160]; /*!< Configurable notification command */ char language[MAX_LANGUAGE]; /*!< Config: Language setting */ char zonetag[80]; /*!< Time zone */ char uniqueid[20]; /*!< Unique integer identifier */ char exit[80]; /*!< Options for exiting from voicemail() */ char attachfmt[80]; /*!< Format for voicemail audio file attachment */ char etemplate[80]; /*!< Pager template */ char ptemplate[80]; /*!< Voicemail format */ unsigned int flags; /*!< MVM_ flags */ struct ast_variable *chanvars; /*!< Variables for e-mail template */ double volgain; /*!< Volume gain for voicemails sent via e-mail */ AST_LIST_ENTRY(minivm_account) list; }; /*!\internal * \brief The list of e-mail accounts */ static AST_LIST_HEAD_STATIC(minivm_accounts, minivm_account); /*!\internal * \brief Linked list of e-mail templates in various languages * These are used as templates for e-mails, pager messages and jabber messages * \ref message_templates */ struct minivm_template { char name[80]; /*!< Template name */ char *body; /*!< Body of this template */ char fromaddress[100]; /*!< Who's sending the e-mail? */ char serveremail[80]; /*!< From: Mail address */ char subject[100]; /*!< Subject line */ char charset[32]; /*!< Default character set for this template */ char locale[20]; /*!< Locale for setlocale() */ char dateformat[80]; /*!< Date format to use in this attachment */ int attachment; /*!< Attachment of media yes/no - no for pager messages */ AST_LIST_ENTRY(minivm_template) list; /*!< List mechanics */ }; /*! \brief The list of e-mail templates */ static AST_LIST_HEAD_STATIC(message_templates, minivm_template); /*! \brief Options for leaving voicemail with the voicemail() application */ struct leave_vm_options { unsigned int flags; signed char record_gain; }; /*! \brief Structure for base64 encoding */ struct b64_baseio { int iocp; int iolen; int linelength; int ateof; unsigned char iobuf[B64_BASEMAXINLINE]; }; /*! \brief Voicemail time zones */ struct minivm_zone { char name[80]; /*!< Name of this time zone */ char timezone[80]; /*!< Timezone definition */ char msg_format[BUFSIZ]; /*!< Not used in minivm ...yet */ AST_LIST_ENTRY(minivm_zone) list; /*!< List mechanics */ }; /*! \brief The list of e-mail time zones */ static AST_LIST_HEAD_STATIC(minivm_zones, minivm_zone); /*! \brief Structure for gathering statistics */ struct minivm_stats { int voicemailaccounts; /*!< Number of static accounts */ int timezones; /*!< Number of time zones */ int templates; /*!< Number of templates */ struct timeval reset; /*!< Time for last reset */ int receivedmessages; /*!< Number of received messages since reset */ struct timeval lastreceived; /*!< Time for last voicemail sent */ }; /*! \brief Statistics for voicemail */ static struct minivm_stats global_stats; AST_MUTEX_DEFINE_STATIC(minivmlock); /*!< Lock to protect voicemail system */ AST_MUTEX_DEFINE_STATIC(minivmloglock); /*!< Lock to protect voicemail system log file */ static FILE *minivmlogfile; /*!< The minivm log file */ static int global_vmminmessage; /*!< Minimum duration of messages */ static int global_vmmaxmessage; /*!< Maximum duration of message */ static int global_maxsilence; /*!< Maximum silence during recording */ static int global_maxgreet; /*!< Maximum length of prompts */ static int global_silencethreshold = 128; static char global_mailcmd[160]; /*!< Configurable mail cmd */ static char global_externnotify[160]; /*!< External notification application */ static char global_logfile[PATH_MAX]; /*!< Global log file for messages */ static char default_vmformat[80]; static struct ast_flags globalflags = {0}; /*!< Global voicemail flags */ static int global_saydurationminfo; static double global_volgain; /*!< Volume gain for voicmemail via e-mail */ /*!\internal * \brief Default dateformat, can be overridden in configuration file */ #define DEFAULT_DATEFORMAT "%A, %B %d, %Y at %r" #define DEFAULT_CHARSET "ISO-8859-1" /* Forward declarations */ static char *message_template_parse_filebody(const char *filename); static char *message_template_parse_emailbody(const char *body); static int create_vmaccount(char *name, struct ast_variable *var, int realtime); static struct minivm_account *find_user_realtime(const char *domain, const char *username); static char *handle_minivm_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); /*!\internal * \brief Create message template */ static struct minivm_template *message_template_create(const char *name) { struct minivm_template *template; template = ast_calloc(1, sizeof(*template)); if (!template) return NULL; /* Set some defaults for templates */ ast_copy_string(template->name, name, sizeof(template->name)); ast_copy_string(template->dateformat, DEFAULT_DATEFORMAT, sizeof(template->dateformat)); ast_copy_string(template->charset, DEFAULT_CHARSET, sizeof(template->charset)); ast_copy_string(template->subject, "New message in mailbox ${MVM_USERNAME}@${MVM_DOMAIN}", sizeof(template->subject)); template->attachment = TRUE; return template; } /*!\internal * \brief Release memory allocated by message template */ static void message_template_free(struct minivm_template *template) { if (template->body) ast_free(template->body); ast_free (template); } /*!\internal * \brief Build message template from configuration */ static int message_template_build(const char *name, struct ast_variable *var) { struct minivm_template *template; int error = 0; template = message_template_create(name); if (!template) { ast_log(LOG_ERROR, "Out of memory, can't allocate message template object %s.\n", name); return -1; } while (var) { ast_debug(3, "Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name); if (!strcasecmp(var->name, "fromaddress")) { ast_copy_string(template->fromaddress, var->value, sizeof(template->fromaddress)); } else if (!strcasecmp(var->name, "fromemail")) { ast_copy_string(template->serveremail, var->value, sizeof(template->serveremail)); } else if (!strcasecmp(var->name, "subject")) { ast_copy_string(template->subject, var->value, sizeof(template->subject)); } else if (!strcasecmp(var->name, "locale")) { ast_copy_string(template->locale, var->value, sizeof(template->locale)); } else if (!strcasecmp(var->name, "attachmedia")) { template->attachment = ast_true(var->value); } else if (!strcasecmp(var->name, "dateformat")) { ast_copy_string(template->dateformat, var->value, sizeof(template->dateformat)); } else if (!strcasecmp(var->name, "charset")) { ast_copy_string(template->charset, var->value, sizeof(template->charset)); } else if (!strcasecmp(var->name, "templatefile")) { if (template->body) ast_free(template->body); template->body = message_template_parse_filebody(var->value); if (!template->body) { ast_log(LOG_ERROR, "Error reading message body definition file %s\n", var->value); error++; } } else if (!strcasecmp(var->name, "messagebody")) { if (template->body) ast_free(template->body); template->body = message_template_parse_emailbody(var->value); if (!template->body) { ast_log(LOG_ERROR, "Error parsing message body definition:\n %s\n", var->value); error++; } } else { ast_log(LOG_ERROR, "Unknown message template configuration option \"%s=%s\"\n", var->name, var->value); error++; } var = var->next; } if (error) ast_log(LOG_ERROR, "-- %d errors found parsing message template definition %s\n", error, name); AST_LIST_LOCK(&message_templates); AST_LIST_INSERT_TAIL(&message_templates, template, list); AST_LIST_UNLOCK(&message_templates); global_stats.templates++; return error; } /*!\internal * \brief Find named template */ static struct minivm_template *message_template_find(const char *name) { struct minivm_template *this, *res = NULL; if (ast_strlen_zero(name)) return NULL; AST_LIST_LOCK(&message_templates); AST_LIST_TRAVERSE(&message_templates, this, list) { if (!strcasecmp(this->name, name)) { res = this; break; } } AST_LIST_UNLOCK(&message_templates); return res; } /*!\internal * \brief Clear list of templates */ static void message_destroy_list(void) { struct minivm_template *this; AST_LIST_LOCK(&message_templates); while ((this = AST_LIST_REMOVE_HEAD(&message_templates, list))) { message_template_free(this); } AST_LIST_UNLOCK(&message_templates); } /*!\internal * \brief read buffer from file (base64 conversion) */ static int b64_inbuf(struct b64_baseio *bio, FILE *fi) { int l; if (bio->ateof) return 0; if ((l = fread(bio->iobuf, 1, B64_BASEMAXINLINE,fi)) <= 0) { if (ferror(fi)) return -1; bio->ateof = 1; return 0; } bio->iolen= l; bio->iocp= 0; return 1; } /*!\internal * \brief read character from file to buffer (base64 conversion) */ static int b64_inchar(struct b64_baseio *bio, FILE *fi) { if (bio->iocp >= bio->iolen) { if (!b64_inbuf(bio, fi)) return EOF; } return bio->iobuf[bio->iocp++]; } /*!\internal * \brief write buffer to file (base64 conversion) */ static int b64_ochar(struct b64_baseio *bio, int c, FILE *so) { if (bio->linelength >= B64_BASELINELEN) { if (fputs(EOL,so) == EOF) return -1; bio->linelength= 0; } if (putc(((unsigned char) c), so) == EOF) return -1; bio->linelength++; return 1; } /*!\internal * \brief Encode file to base64 encoding for email attachment (base64 conversion) */ static int base_encode(char *filename, FILE *so) { unsigned char dtable[B64_BASEMAXINLINE]; int i,hiteof= 0; FILE *fi; struct b64_baseio bio; memset(&bio, 0, sizeof(bio)); bio.iocp = B64_BASEMAXINLINE; if (!(fi = fopen(filename, "rb"))) { ast_log(LOG_WARNING, "Failed to open file: %s: %s\n", filename, strerror(errno)); return -1; } for (i= 0; i<9; i++) { dtable[i]= 'A'+i; dtable[i+9]= 'J'+i; dtable[26+i]= 'a'+i; dtable[26+i+9]= 'j'+i; } for (i= 0; i < 8; i++) { dtable[i+18]= 'S'+i; dtable[26+i+18]= 's'+i; } for (i= 0; i < 10; i++) { dtable[52+i]= '0'+i; } dtable[62]= '+'; dtable[63]= '/'; while (!hiteof){ unsigned char igroup[3], ogroup[4]; int c,n; igroup[0]= igroup[1]= igroup[2]= 0; for (n= 0; n < 3; n++) { if ((c = b64_inchar(&bio, fi)) == EOF) { hiteof= 1; break; } igroup[n]= (unsigned char)c; } if (n> 0) { ogroup[0]= dtable[igroup[0]>>2]; ogroup[1]= dtable[((igroup[0]&3)<<4) | (igroup[1]>>4)]; ogroup[2]= dtable[((igroup[1]&0xF)<<2) | (igroup[2]>>6)]; ogroup[3]= dtable[igroup[2]&0x3F]; if (n<3) { ogroup[3]= '='; if (n<2) ogroup[2]= '='; } for (i= 0;i<4;i++) b64_ochar(&bio, ogroup[i], so); } } /* Put end of line - line feed */ if (fputs(EOL, so) == EOF) return 0; fclose(fi); return 1; } static int get_date(char *s, int len) { struct ast_tm tm; struct timeval now = ast_tvnow(); ast_localtime(&now, &tm, NULL); return ast_strftime(s, len, "%a %b %e %r %Z %Y", &tm); } /*!\internal * \brief Free user structure - if it's allocated */ static void free_user(struct minivm_account *vmu) { if (vmu->chanvars) ast_variables_destroy(vmu->chanvars); ast_free(vmu); } /*!\internal * \brief Prepare for voicemail template by adding channel variables * to the channel */ static void prep_email_sub_vars(struct ast_channel *channel, const struct minivm_account *vmu, const char *cidnum, const char *cidname, const char *dur, const char *date, const char *counter) { char callerid[256]; struct ast_variable *var; if (!channel) { ast_log(LOG_ERROR, "No allocated channel, giving up...\n"); return; } for (var = vmu->chanvars ; var ; var = var->next) { pbx_builtin_setvar_helper(channel, var->name, var->value); } /* Prepare variables for substition in email body and subject */ pbx_builtin_setvar_helper(channel, "MVM_NAME", vmu->fullname); pbx_builtin_setvar_helper(channel, "MVM_DUR", dur); pbx_builtin_setvar_helper(channel, "MVM_DOMAIN", vmu->domain); pbx_builtin_setvar_helper(channel, "MVM_USERNAME", vmu->username); pbx_builtin_setvar_helper(channel, "MVM_CALLERID", ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, "Unknown Caller")); pbx_builtin_setvar_helper(channel, "MVM_CIDNAME", (cidname ? cidname : "an unknown caller")); pbx_builtin_setvar_helper(channel, "MVM_CIDNUM", (cidnum ? cidnum : "an unknown caller")); pbx_builtin_setvar_helper(channel, "MVM_DATE", date); if (!ast_strlen_zero(counter)) pbx_builtin_setvar_helper(channel, "MVM_COUNTER", counter); } /*!\internal * \brief Set default values for Mini-Voicemail users */ static void populate_defaults(struct minivm_account *vmu) { ast_copy_flags(vmu, (&globalflags), AST_FLAGS_ALL); ast_copy_string(vmu->attachfmt, default_vmformat, sizeof(vmu->attachfmt)); vmu->volgain = global_volgain; } /*!\internal * \brief Allocate new vm user and set default values */ static struct minivm_account *mvm_user_alloc(void) { struct minivm_account *new; new = ast_calloc(1, sizeof(*new)); if (!new) return NULL; populate_defaults(new); return new; } /*!\internal * \brief Clear list of users */ static void vmaccounts_destroy_list(void) { struct minivm_account *this; AST_LIST_LOCK(&minivm_accounts); while ((this = AST_LIST_REMOVE_HEAD(&minivm_accounts, list))) ast_free(this); AST_LIST_UNLOCK(&minivm_accounts); } /*!\internal * \brief Find user from static memory object list */ static struct minivm_account *find_account(const char *domain, const char *username, int createtemp) { struct minivm_account *vmu = NULL, *cur; if (ast_strlen_zero(domain) || ast_strlen_zero(username)) { ast_log(LOG_NOTICE, "No username or domain? \n"); return NULL; } ast_debug(3, "Looking for voicemail user %s in domain %s\n", username, domain); AST_LIST_LOCK(&minivm_accounts); AST_LIST_TRAVERSE(&minivm_accounts, cur, list) { /* Is this the voicemail account we're looking for? */ if (!strcasecmp(domain, cur->domain) && !strcasecmp(username, cur->username)) break; } AST_LIST_UNLOCK(&minivm_accounts); if (cur) { ast_debug(3, "Found account for %s@%s\n", username, domain); vmu = cur; } else vmu = find_user_realtime(domain, username); if (createtemp && !vmu) { /* Create a temporary user, send e-mail and be gone */ vmu = mvm_user_alloc(); ast_set2_flag(vmu, TRUE, MVM_ALLOCED); if (vmu) { ast_copy_string(vmu->username, username, sizeof(vmu->username)); ast_copy_string(vmu->domain, domain, sizeof(vmu->domain)); ast_debug(1, "Created temporary account\n"); } } return vmu; } /*!\internal * \brief Find user in realtime storage * \return pointer to minivm_account structure */ static struct minivm_account *find_user_realtime(const char *domain, const char *username) { struct ast_variable *var; struct minivm_account *retval; char name[MAXHOSTNAMELEN]; retval = mvm_user_alloc(); if (!retval) return NULL; if (username) ast_copy_string(retval->username, username, sizeof(retval->username)); populate_defaults(retval); var = ast_load_realtime("minivm", "username", username, "domain", domain, SENTINEL); if (!var) { ast_free(retval); return NULL; } snprintf(name, sizeof(name), "%s@%s", username, domain); create_vmaccount(name, var, TRUE); ast_variables_destroy(var); return retval; } /*!\internal * \brief Check if the string would need encoding within the MIME standard, to * avoid confusing certain mail software that expects messages to be 7-bit * clean. */ static int check_mime(const char *str) { for (; *str; str++) { if (*str > 126 || *str < 32 || strchr("()<>@,:;/\"[]?.=", *str)) { return 1; } } return 0; } /*!\internal * \brief Encode a string according to the MIME rules for encoding strings * that are not 7-bit clean or contain control characters. * * Additionally, if the encoded string would exceed the MIME limit of 76 * characters per line, then the encoding will be broken up into multiple * sections, separated by a space character, in order to facilitate * breaking up the associated header across multiple lines. * * \param end An expandable buffer for holding the result * \param maxlen \see ast_str * \param charset Character set in which the result should be encoded * \param start A string to be encoded * \param preamble The length of the first line already used for this string, * to ensure that each line maintains a maximum length of 76 chars. * \param postamble the length of any additional characters appended to the * line, used to ensure proper field wrapping. * \return The encoded string. */ static const char *ast_str_encode_mime(struct ast_str **end, ssize_t maxlen, const char *charset, const char *start, size_t preamble, size_t postamble) { struct ast_str *tmp = ast_str_alloca(80); int first_section = 1; ast_str_reset(*end); ast_str_set(&tmp, -1, "=?%s?Q?", charset); for (; *start; start++) { int need_encoding = 0; if (*start < 33 || *start > 126 || strchr("()<>@,:;/\"[]?.=_", *start)) { need_encoding = 1; } if ((first_section && need_encoding && preamble + ast_str_strlen(tmp) > 70) || (first_section && !need_encoding && preamble + ast_str_strlen(tmp) > 72) || (!first_section && need_encoding && ast_str_strlen(tmp) > 70) || (!first_section && !need_encoding && ast_str_strlen(tmp) > 72)) { /* Start new line */ ast_str_append(end, maxlen, "%s%s?=", first_section ? "" : " ", ast_str_buffer(tmp)); ast_str_set(&tmp, -1, "=?%s?Q?", charset); first_section = 0; } if (need_encoding && *start == ' ') { ast_str_append(&tmp, -1, "_"); } else if (need_encoding) { ast_str_append(&tmp, -1, "=%hhX", *start); } else { ast_str_append(&tmp, -1, "%c", *start); } } ast_str_append(end, maxlen, "%s%s?=%s", first_section ? "" : " ", ast_str_buffer(tmp), ast_str_strlen(tmp) + postamble > 74 ? " " : ""); return ast_str_buffer(*end); } /*!\internal * \brief Wraps a character sequence in double quotes, escaping occurences of quotes within the string. * \param from The string to work with. * \param buf The destination buffer to write the modified quoted string. * \param maxlen Always zero. \see ast_str * * \return The destination string with quotes wrapped on it (the to field). */ static const char *ast_str_quote(struct ast_str **buf, ssize_t maxlen, const char *from) { const char *ptr; /* We're only ever passing 0 to maxlen, so short output isn't possible */ ast_str_set(buf, maxlen, "\""); for (ptr = from; *ptr; ptr++) { if (*ptr == '"' || *ptr == '\\') { ast_str_append(buf, maxlen, "\\%c", *ptr); } else { ast_str_append(buf, maxlen, "%c", *ptr); } } ast_str_append(buf, maxlen, "\""); return ast_str_buffer(*buf); } /*!\internal * \brief Send voicemail with audio file as an attachment */ static int sendmail(struct minivm_template *template, struct minivm_account *vmu, char *cidnum, char *cidname, const char *filename, char *format, int duration, int attach_user_voicemail, enum mvm_messagetype type, const char *counter) { FILE *p = NULL; int pfd; char email[256] = ""; char who[256] = ""; char date[256]; char bound[256]; char fname[PATH_MAX]; char dur[PATH_MAX]; char tmp[80] = "/tmp/astmail-XXXXXX"; char tmp2[PATH_MAX]; char newtmp[PATH_MAX]; /* Only used with volgain */ struct timeval now; struct ast_tm tm; struct minivm_zone *the_zone = NULL; struct ast_channel *ast; char *finalfilename = ""; struct ast_str *str1 = ast_str_create(16), *str2 = ast_str_create(16); char *fromaddress; char *fromemail; if (!str1 || !str2) { ast_free(str1); ast_free(str2); return -1; } if (type == MVM_MESSAGE_EMAIL) { if (vmu && !ast_strlen_zero(vmu->email)) { ast_copy_string(email, vmu->email, sizeof(email)); } else if (!ast_strlen_zero(vmu->username) && !ast_strlen_zero(vmu->domain)) snprintf(email, sizeof(email), "%s@%s", vmu->username, vmu->domain); } else if (type == MVM_MESSAGE_PAGE) { ast_copy_string(email, vmu->pager, sizeof(email)); } if (ast_strlen_zero(email)) { ast_log(LOG_WARNING, "No address to send message to.\n"); ast_free(str1); ast_free(str2); return -1; } ast_debug(3, "Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name); if (!strcmp(format, "wav49")) format = "WAV"; /* If we have a gain option, process it now with sox */ if (type == MVM_MESSAGE_EMAIL && (vmu->volgain < -.001 || vmu->volgain > .001) ) { char tmpcmd[PATH_MAX]; int tmpfd; ast_copy_string(newtmp, "/tmp/XXXXXX", sizeof(newtmp)); ast_debug(3, "newtmp: %s\n", newtmp); tmpfd = mkstemp(newtmp); if (tmpfd < 0) { ast_log(LOG_WARNING, "Failed to create temporary file for volgain: %d\n", errno); ast_free(str1); ast_free(str2); return -1; } snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format); ast_safe_system(tmpcmd); close(tmpfd); finalfilename = newtmp; ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", filename, format, vmu->volgain, vmu->username); } else { finalfilename = ast_strdupa(filename); } /* Create file name */ snprintf(fname, sizeof(fname), "%s.%s", finalfilename, format); if (template->attachment) ast_debug(1, "Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail); /* Make a temporary file instead of piping directly to sendmail, in case the mail command hangs */ pfd = mkstemp(tmp); if (pfd > -1) { p = fdopen(pfd, "w"); if (!p) { close(pfd); pfd = -1; } ast_debug(1, "Opening temp file for e-mail: %s\n", tmp); } if (!p) { ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp); ast_free(str1); ast_free(str2); return -1; } /* Allocate channel used for chanvar substitution */ ast = ast_dummy_channel_alloc(); if (!ast) { ast_free(str1); ast_free(str2); return -1; } snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60); /* Does this user have a timezone specified? */ if (!ast_strlen_zero(vmu->zonetag)) { /* Find the zone in the list */ struct minivm_zone *z; AST_LIST_LOCK(&minivm_zones); AST_LIST_TRAVERSE(&minivm_zones, z, list) { if (strcmp(z->name, vmu->zonetag)) continue; the_zone = z; } AST_LIST_UNLOCK(&minivm_zones); } now = ast_tvnow(); ast_localtime(&now, &tm, the_zone ? the_zone->timezone : NULL); ast_strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm); /* Start printing the email to the temporary file */ fprintf(p, "Date: %s\n", date); /* Set date format for voicemail mail */ ast_strftime(date, sizeof(date), template->dateformat, &tm); /* Populate channel with channel variables for substitution */ prep_email_sub_vars(ast, vmu, cidnum, cidname, dur, date, counter); /* Find email address to use */ /* If there's a server e-mail adress in the account, user that, othterwise template */ fromemail = ast_strlen_zero(vmu->serveremail) ? template->serveremail : vmu->serveremail; /* Find name to user for server e-mail */ fromaddress = ast_strlen_zero(template->fromaddress) ? "" : template->fromaddress; /* If needed, add hostname as domain */ if (ast_strlen_zero(fromemail)) fromemail = "asterisk"; if (strchr(fromemail, '@')) ast_copy_string(who, fromemail, sizeof(who)); else { char host[MAXHOSTNAMELEN]; gethostname(host, sizeof(host)-1); snprintf(who, sizeof(who), "%s@%s", fromemail, host); } if (ast_strlen_zero(fromaddress)) { fprintf(p, "From: Asterisk PBX <%s>\n", who); } else { ast_debug(4, "Fromaddress template: %s\n", fromaddress); ast_str_substitute_variables(&str1, 0, ast, fromaddress); if (check_mime(ast_str_buffer(str1))) { int first_line = 1; char *ptr; ast_str_encode_mime(&str2, 0, template->charset, ast_str_buffer(str1), strlen("From: "), strlen(who) + 3); while ((ptr = strchr(ast_str_buffer(str2), ' '))) { *ptr = '\0'; fprintf(p, "%s %s\n", first_line ? "From:" : "", ast_str_buffer(str2)); first_line = 0; /* Substring is smaller, so this will never grow */ ast_str_set(&str2, 0, "%s", ptr + 1); } fprintf(p, "%s %s <%s>\n", first_line ? "From:" : "", ast_str_buffer(str2), who); } else { fprintf(p, "From: %s <%s>\n", ast_str_quote(&str2, 0, ast_str_buffer(str1)), who); } } fprintf(p, "Message-ID: \n", (unsigned int)ast_random(), vmu->username, (int)getpid(), who); if (ast_strlen_zero(vmu->email)) { snprintf(email, sizeof(email), "%s@%s", vmu->username, vmu->domain); } else { ast_copy_string(email, vmu->email, sizeof(email)); } if (check_mime(vmu->fullname)) { int first_line = 1; char *ptr; ast_str_encode_mime(&str2, 0, template->charset, vmu->fullname, strlen("To: "), strlen(email) + 3); while ((ptr = strchr(ast_str_buffer(str2), ' '))) { *ptr = '\0'; fprintf(p, "%s %s\n", first_line ? "To:" : "", ast_str_buffer(str2)); first_line = 0; /* Substring is smaller, so this will never grow */ ast_str_set(&str2, 0, "%s", ptr + 1); } fprintf(p, "%s %s <%s>\n", first_line ? "To:" : "", ast_str_buffer(str2), email); } else { fprintf(p, "To: %s <%s>\n", ast_str_quote(&str2, 0, vmu->fullname), email); } if (!ast_strlen_zero(template->subject)) { ast_str_substitute_variables(&str1, 0, ast, template->subject); if (check_mime(ast_str_buffer(str1))) { int first_line = 1; char *ptr; ast_str_encode_mime(&str2, 0, template->charset, ast_str_buffer(str1), strlen("Subject: "), 0); while ((ptr = strchr(ast_str_buffer(str2), ' '))) { *ptr = '\0'; fprintf(p, "%s %s\n", first_line ? "Subject:" : "", ast_str_buffer(str2)); first_line = 0; /* Substring is smaller, so this will never grow */ ast_str_set(&str2, 0, "%s", ptr + 1); } fprintf(p, "%s %s\n", first_line ? "Subject:" : "", ast_str_buffer(str2)); } else { fprintf(p, "Subject: %s\n", ast_str_buffer(str1)); } } else { fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain); ast_debug(1, "Using default subject for this email \n"); } if (option_debug > 2) fprintf(p, "X-Asterisk-debug: template %s user account %s@%s\n", template->name, vmu->username, vmu->domain); fprintf(p, "MIME-Version: 1.0\n"); /* Something unique. */ snprintf(bound, sizeof(bound), "voicemail_%s%d%d", vmu->username, (int)getpid(), (unsigned int)ast_random()); fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"\n\n\n", bound); fprintf(p, "--%s\n", bound); fprintf(p, "Content-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n\n", template->charset); if (!ast_strlen_zero(template->body)) { ast_str_substitute_variables(&str1, 0, ast, template->body); ast_debug(3, "Message now: %s\n-----\n", ast_str_buffer(str1)); fprintf(p, "%s\n", ast_str_buffer(str1)); } else { fprintf(p, "Dear %s:\n\n\tJust wanted to let you know you were just left a %s long message \n" "in mailbox %s from %s, on %s so you might\n" "want to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n\n", vmu->fullname, dur, vmu->username, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date); ast_debug(3, "Using default message body (no template)\n-----\n"); } /* Eww. We want formats to tell us their own MIME type */ if (template->attachment) { char *ctype = "audio/x-"; ast_debug(3, "Attaching file to message: %s\n", fname); if (!strcasecmp(format, "ogg")) ctype = "application/"; fprintf(p, "--%s\n", bound); fprintf(p, "Content-Type: %s%s; name=\"voicemailmsg.%s\"\n", ctype, format, format); fprintf(p, "Content-Transfer-Encoding: base64\n"); fprintf(p, "Content-Description: Voicemail sound attachment.\n"); fprintf(p, "Content-Disposition: attachment; filename=\"voicemail%s.%s\"\n\n", counter ? counter : "", format); base_encode(fname, p); fprintf(p, "\n\n--%s--\n.\n", bound); } fclose(p); snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", global_mailcmd, tmp, tmp); ast_safe_system(tmp2); ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : ""); ast_debug(3, "Actual command used: %s\n", tmp2); ast = ast_channel_unref(ast); ast_free(str1); ast_free(str2); return 0; } /*!\internal * \brief Create directory based on components */ static int make_dir(char *dest, int len, const char *domain, const char *username, const char *folder) { return snprintf(dest, len, "%s%s/%s%s%s", MVM_SPOOL_DIR, domain, username, ast_strlen_zero(folder) ? "" : "/", folder ? folder : ""); } /*!\internal * \brief Checks if directory exists. Does not create directory, but builds string in dest * \param dest String. base directory. * \param len Int. Length base directory string. * \param domain String. Ignored if is null or empty string. * \param username String. Ignored if is null or empty string. * \param folder String. Ignored if is null or empty string. * \return 0 on failure, 1 on success. */ static int check_dirpath(char *dest, int len, char *domain, char *username, char *folder) { struct stat filestat; make_dir(dest, len, domain, username, folder ? folder : ""); if (stat(dest, &filestat)== -1) return FALSE; else return TRUE; } /*!\internal * \brief basically mkdir -p $dest/$domain/$username/$folder * \param dest String. base directory. * \param len Length of directory string * \param domain String. Ignored if is null or empty string. * \param folder String. Ignored if is null or empty string. * \param username String. Ignored if is null or empty string. * \return -1 on failure, 0 on success. */ static int create_dirpath(char *dest, int len, char *domain, char *username, char *folder) { int res; make_dir(dest, len, domain, username, folder); if ((res = ast_mkdir(dest, 0777))) { ast_log(LOG_WARNING, "ast_mkdir '%s' failed: %s\n", dest, strerror(res)); return -1; } ast_debug(2, "Creating directory for %s@%s folder %s : %s\n", username, domain, folder, dest); return 0; } /*!\internal * \brief Play intro message before recording voicemail */ static int invent_message(struct ast_channel *chan, char *domain, char *username, int busy, char *ecodes) { int res; char fn[PATH_MAX]; ast_debug(2, "Still preparing to play message ...\n"); snprintf(fn, sizeof(fn), "%s%s/%s/greet", MVM_SPOOL_DIR, domain, username); if (ast_fileexists(fn, NULL, NULL) > 0) { res = ast_streamfile(chan, fn, ast_channel_language(chan)); if (res) return -1; res = ast_waitstream(chan, ecodes); if (res) return res; } else { int numericusername = 1; char *i = username; ast_debug(2, "No personal prompts. Using default prompt set for language\n"); while (*i) { ast_debug(2, "Numeric? Checking %c\n", *i); if (!isdigit(*i)) { numericusername = FALSE; break; } i++; } if (numericusername) { if (ast_streamfile(chan, "vm-theperson", ast_channel_language(chan))) return -1; if ((res = ast_waitstream(chan, ecodes))) return res; res = ast_say_digit_str(chan, username, ecodes, ast_channel_language(chan)); if (res) return res; } else { if (ast_streamfile(chan, "vm-theextensionis", ast_channel_language(chan))) return -1; if ((res = ast_waitstream(chan, ecodes))) return res; } } res = ast_streamfile(chan, busy ? "vm-isonphone" : "vm-isunavail", ast_channel_language(chan)); if (res) return -1; res = ast_waitstream(chan, ecodes); return res; } /*!\internal * \brief Delete media files and attribute file */ static int vm_delete(char *file) { int res; ast_debug(1, "Deleting voicemail file %s\n", file); res = unlink(file); /* Remove the meta data file */ res |= ast_filedelete(file, NULL); /* remove the media file */ return res; } /*!\internal * \brief Record voicemail message & let caller review or re-record it, or set options if applicable */ static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct minivm_account *vmu, int *duration, int *sound_duration, const char *unlockdir, signed char record_gain) { int cmd = 0; int max_attempts = 3; int attempts = 0; int recorded = 0; int message_exists = 0; signed char zero_gain = 0; char *acceptdtmf = "#"; char *canceldtmf = ""; /* Note that urgent and private are for flagging messages as such in the future */ /* barf if no pointer passed to store duration in */ if (duration == NULL) { ast_log(LOG_WARNING, "Error play_record_review called without duration pointer\n"); return -1; } cmd = '3'; /* Want to start by recording */ while ((cmd >= 0) && (cmd != 't')) { switch (cmd) { case '1': ast_verb(3, "Saving message as is\n"); ast_stream_and_wait(chan, "vm-msgsaved", ""); cmd = 't'; break; case '2': /* Review */ ast_verb(3, "Reviewing the message\n"); ast_streamfile(chan, recordfile, ast_channel_language(chan)); cmd = ast_waitstream(chan, AST_DIGIT_ANY); break; case '3': message_exists = 0; /* Record */ if (recorded == 1) ast_verb(3, "Re-recording the message\n"); else ast_verb(3, "Recording the message\n"); if (recorded && outsidecaller) cmd = ast_play_and_wait(chan, "beep"); recorded = 1; /* After an attempt has been made to record message, we have to take care of INTRO and beep for incoming messages, but not for greetings */ if (record_gain) ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0); if (ast_test_flag(vmu, MVM_OPERATOR)) canceldtmf = "0"; cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, global_silencethreshold, global_maxsilence, unlockdir, acceptdtmf, canceldtmf); if (record_gain) ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0); if (cmd == -1) /* User has hung up, no options to give */ return cmd; if (cmd == '0') break; else if (cmd == '*') break; else { /* If all is well, a message exists */ message_exists = 1; cmd = 0; } break; case '4': case '5': case '6': case '7': case '8': case '9': case '*': case '#': cmd = ast_play_and_wait(chan, "vm-sorry"); break; case '0': if(!ast_test_flag(vmu, MVM_OPERATOR)) { cmd = ast_play_and_wait(chan, "vm-sorry"); break; } if (message_exists || recorded) { cmd = ast_play_and_wait(chan, "vm-saveoper"); if (!cmd) cmd = ast_waitfordigit(chan, 3000); if (cmd == '1') { ast_play_and_wait(chan, "vm-msgsaved"); cmd = '0'; } else { ast_play_and_wait(chan, "vm-deleted"); vm_delete(recordfile); cmd = '0'; } } return cmd; default: /* If the caller is an ouside caller, and the review option is enabled, allow them to review the message, but let the owner of the box review their OGM's */ if (outsidecaller && !ast_test_flag(vmu, MVM_REVIEW)) return cmd; if (message_exists) { cmd = ast_play_and_wait(chan, "vm-review"); } else { cmd = ast_play_and_wait(chan, "vm-torerecord"); if (!cmd) cmd = ast_waitfordigit(chan, 600); } if (!cmd && outsidecaller && ast_test_flag(vmu, MVM_OPERATOR)) { cmd = ast_play_and_wait(chan, "vm-reachoper"); if (!cmd) cmd = ast_waitfordigit(chan, 600); } if (!cmd) cmd = ast_waitfordigit(chan, 6000); if (!cmd) { attempts++; } if (attempts > max_attempts) { cmd = 't'; } } } if (outsidecaller) ast_play_and_wait(chan, "vm-goodbye"); if (cmd == 't') cmd = 0; return cmd; } /*! \brief Run external notification for voicemail message */ static void run_externnotify(struct ast_channel *chan, struct minivm_account *vmu) { char arguments[BUFSIZ]; if (ast_strlen_zero(vmu->externnotify) && ast_strlen_zero(global_externnotify)) return; snprintf(arguments, sizeof(arguments), "%s %s@%s %s %s&", ast_strlen_zero(vmu->externnotify) ? global_externnotify : vmu->externnotify, vmu->username, vmu->domain, (ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) ? ast_channel_caller(chan)->id.name.str : "", (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) ? ast_channel_caller(chan)->id.number.str : ""); ast_debug(1, "Executing: %s\n", arguments); ast_safe_system(arguments); } /*!\internal * \brief Send message to voicemail account owner */ static int notify_new_message(struct ast_channel *chan, const char *templatename, struct minivm_account *vmu, const char *filename, long duration, const char *format, char *cidnum, char *cidname) { char *stringp; struct minivm_template *etemplate; char *messageformat; int res = 0; char oldlocale[100]; const char *counter; if (!ast_strlen_zero(vmu->attachfmt)) { if (strstr(format, vmu->attachfmt)) { format = vmu->attachfmt; } else { ast_log(LOG_WARNING, "Attachment format '%s' is not one of the recorded formats '%s'. Falling back to default format for '%s@%s'.\n", vmu->attachfmt, format, vmu->username, vmu->domain); } } etemplate = message_template_find(vmu->etemplate); if (!etemplate) etemplate = message_template_find(templatename); if (!etemplate) etemplate = message_template_find("email-default"); /* Attach only the first format */ stringp = messageformat = ast_strdupa(format); strsep(&stringp, "|"); if (!ast_strlen_zero(etemplate->locale)) { char *new_locale; ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale)); ast_debug(2, "Changing locale from %s to %s\n", oldlocale, etemplate->locale); new_locale = setlocale(LC_TIME, etemplate->locale); if (new_locale == NULL) { ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale); } } /* Read counter if available */ ast_channel_lock(chan); if ((counter = pbx_builtin_getvar_helper(chan, "MVM_COUNTER"))) { counter = ast_strdupa(counter); } ast_channel_unlock(chan); if (ast_strlen_zero(counter)) { ast_debug(2, "MVM_COUNTER not found\n"); } else { ast_debug(2, "MVM_COUNTER found - will use it with value %s\n", counter); } res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_EMAIL, counter); if (res == 0 && !ast_strlen_zero(vmu->pager)) { /* Find template for paging */ etemplate = message_template_find(vmu->ptemplate); if (!etemplate) etemplate = message_template_find("pager-default"); if (etemplate->locale) { ast_copy_string(oldlocale, setlocale(LC_TIME, ""), sizeof(oldlocale)); setlocale(LC_TIME, etemplate->locale); } res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_PAGE, counter); } ast_manager_event(chan, EVENT_FLAG_CALL, "MiniVoiceMail", "Action: SentNotification\rn\nMailbox: %s@%s\r\nCounter: %s\r\n", vmu->username, vmu->domain, counter); run_externnotify(chan, vmu); /* Run external notification */ if (etemplate->locale) { setlocale(LC_TIME, oldlocale); /* Rest to old locale */ } return res; } /*!\internal * \brief Record voicemail message, store into file prepared for sending e-mail */ static int leave_voicemail(struct ast_channel *chan, char *username, struct leave_vm_options *options) { char tmptxtfile[PATH_MAX]; char callerid[256]; FILE *txt; int res = 0, txtdes; int duration = 0; int sound_duration = 0; char date[256]; char tmpdir[PATH_MAX]; char ext_context[256] = ""; char fmt[80]; char *domain; char tmp[256] = ""; struct minivm_account *vmu; int userdir; ast_copy_string(tmp, username, sizeof(tmp)); username = tmp; domain = strchr(tmp, '@'); if (domain) { *domain = '\0'; domain++; } if (!(vmu = find_account(domain, username, TRUE))) { /* We could not find user, let's exit */ ast_log(LOG_ERROR, "Can't allocate temporary account for '%s@%s'\n", username, domain); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); return 0; } /* Setup pre-file if appropriate */ if (strcmp(vmu->domain, "localhost")) snprintf(ext_context, sizeof(ext_context), "%s@%s", username, vmu->domain); else ast_copy_string(ext_context, vmu->domain, sizeof(ext_context)); /* The meat of recording the message... All the announcements and beeps have been played*/ if (ast_strlen_zero(vmu->attachfmt)) ast_copy_string(fmt, default_vmformat, sizeof(fmt)); else ast_copy_string(fmt, vmu->attachfmt, sizeof(fmt)); if (ast_strlen_zero(fmt)) { ast_log(LOG_WARNING, "No format for saving voicemail? Default %s\n", default_vmformat); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); return res; } userdir = check_dirpath(tmpdir, sizeof(tmpdir), vmu->domain, username, "tmp"); /* If we have no user directory, use generic temporary directory */ if (!userdir) { create_dirpath(tmpdir, sizeof(tmpdir), "0000_minivm_temp", "mediafiles", ""); ast_debug(3, "Creating temporary directory %s\n", tmpdir); } snprintf(tmptxtfile, sizeof(tmptxtfile), "%s/XXXXXX", tmpdir); /* XXX This file needs to be in temp directory */ txtdes = mkstemp(tmptxtfile); if (txtdes < 0) { ast_log(LOG_ERROR, "Unable to create message file %s: %s\n", tmptxtfile, strerror(errno)); res = ast_streamfile(chan, "vm-mailboxfull", ast_channel_language(chan)); if (!res) res = ast_waitstream(chan, ""); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); return res; } if (res >= 0) { /* Unless we're *really* silent, try to send the beep */ res = ast_streamfile(chan, "beep", ast_channel_language(chan)); if (!res) res = ast_waitstream(chan, ""); } /* OEJ XXX Maybe this can be turned into a log file? Hmm. */ /* Store information */ ast_debug(2, "Open file for metadata: %s\n", tmptxtfile); res = play_record_review(chan, NULL, tmptxtfile, global_vmmaxmessage, fmt, 1, vmu, &duration, &sound_duration, NULL, options->record_gain); txt = fdopen(txtdes, "w+"); if (!txt) { ast_log(LOG_WARNING, "Error opening text file for output\n"); } else { struct ast_tm tm; struct timeval now = ast_tvnow(); char timebuf[30]; char logbuf[BUFSIZ]; get_date(date, sizeof(date)); ast_localtime(&now, &tm, NULL); ast_strftime(timebuf, sizeof(timebuf), "%H:%M:%S", &tm); ast_callerid_merge(callerid, sizeof(callerid), S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL), S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL), "Unknown"); snprintf(logbuf, sizeof(logbuf), /* "Mailbox:domain:macrocontext:exten:priority:callerchan:callerid:origdate:origtime:duration:durationstatus:accountcode" */ "%s:%s:%s:%s:%d:%s:%s:%s:%s:%d:%s:%s\n", username, ast_channel_context(chan), ast_channel_macrocontext(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan), callerid, date, timebuf, duration, duration < global_vmminmessage ? "IGNORED" : "OK", vmu->accountcode ); fprintf(txt, "%s", logbuf); if (minivmlogfile) { ast_mutex_lock(&minivmloglock); fprintf(minivmlogfile, "%s", logbuf); ast_mutex_unlock(&minivmloglock); } if (sound_duration < global_vmminmessage) { ast_verb(3, "Recording was %d seconds long but needs to be at least %d - abandoning\n", sound_duration, global_vmminmessage); fclose(txt); ast_filedelete(tmptxtfile, NULL); unlink(tmptxtfile); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); return 0; } fclose(txt); /* Close log file */ if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) { ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n"); unlink(tmptxtfile); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); return 0; } /* Set channel variables for the notify application */ pbx_builtin_setvar_helper(chan, "MVM_FILENAME", tmptxtfile); snprintf(timebuf, sizeof(timebuf), "%d", duration); pbx_builtin_setvar_helper(chan, "MVM_DURATION", timebuf); pbx_builtin_setvar_helper(chan, "MVM_FORMAT", fmt); } global_stats.lastreceived = ast_tvnow(); global_stats.receivedmessages++; #if 0 /* Go ahead and delete audio files from system, they're not needed any more */ if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) { ast_filedelete(tmptxtfile, NULL); /* Even not being used at the moment, it's better to convert ast_log to ast_debug anyway */ ast_debug(2, "-_-_- Deleted audio file after notification :: %s \n", tmptxtfile); } #endif if (res > 0) res = 0; if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "SUCCESS"); return res; } /*!\internal * \brief Queue a message waiting event */ static void queue_mwi_event(const char *mbx, const char *ctx, int urgent, int new, int old) { struct ast_event *event; char *mailbox, *context; mailbox = ast_strdupa(mbx); context = ast_strdupa(ctx); if (ast_strlen_zero(context)) { context = "default"; } if (!(event = ast_event_new(AST_EVENT_MWI, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context, AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, (new+urgent), AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old, AST_EVENT_IE_END))) { return; } ast_event_queue_and_cache(event); } /*!\internal * \brief Send MWI using interal Asterisk event subsystem */ static int minivm_mwi_exec(struct ast_channel *chan, const char *data) { int argc; char *argv[4]; int res = 0; char *tmpptr; char tmp[PATH_MAX]; char *mailbox; char *domain; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "Minivm needs at least an account argument \n"); return -1; } tmpptr = ast_strdupa((char *)data); argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); if (argc < 4) { ast_log(LOG_ERROR, "%d arguments passed to MiniVM_MWI, need 4.\n", argc); return -1; } ast_copy_string(tmp, argv[0], sizeof(tmp)); mailbox = tmp; domain = strchr(tmp, '@'); if (domain) { *domain = '\0'; domain++; } if (ast_strlen_zero(domain) || ast_strlen_zero(mailbox)) { ast_log(LOG_ERROR, "Need mailbox@context as argument. Sorry. Argument 0 %s\n", argv[0]); return -1; } queue_mwi_event(mailbox, domain, atoi(argv[1]), atoi(argv[2]), atoi(argv[3])); return res; } /*!\internal * \brief Notify voicemail account owners - either generic template or user specific */ static int minivm_notify_exec(struct ast_channel *chan, const char *data) { int argc; char *argv[2]; int res = 0; char tmp[PATH_MAX]; char *domain; char *tmpptr; struct minivm_account *vmu; char *username; const char *template = ""; const char *filename; const char *format; const char *duration_string; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "Minivm needs at least an account argument \n"); return -1; } tmpptr = ast_strdupa((char *)data); argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); if (argc == 2 && !ast_strlen_zero(argv[1])) template = argv[1]; ast_copy_string(tmp, argv[0], sizeof(tmp)); username = tmp; domain = strchr(tmp, '@'); if (domain) { *domain = '\0'; domain++; } if (ast_strlen_zero(domain) || ast_strlen_zero(username)) { ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument 0 %s\n", argv[0]); return -1; } if(!(vmu = find_account(domain, username, TRUE))) { /* We could not find user, let's exit */ ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain); pbx_builtin_setvar_helper(chan, "MVM_NOTIFY_STATUS", "FAILED"); return -1; } ast_channel_lock(chan); if ((filename = pbx_builtin_getvar_helper(chan, "MVM_FILENAME"))) { filename = ast_strdupa(filename); } ast_channel_unlock(chan); /* Notify of new message to e-mail and pager */ if (!ast_strlen_zero(filename)) { ast_channel_lock(chan); if ((format = pbx_builtin_getvar_helper(chan, "MVM_FORMAT"))) { format = ast_strdupa(format); } if ((duration_string = pbx_builtin_getvar_helper(chan, "MVM_DURATION"))) { duration_string = ast_strdupa(duration_string); } ast_channel_unlock(chan); res = notify_new_message(chan, template, vmu, filename, atoi(duration_string), format, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL), S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL)); } pbx_builtin_setvar_helper(chan, "MVM_NOTIFY_STATUS", res == 0 ? "SUCCESS" : "FAILED"); if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); /* Ok, we're ready to rock and roll. Return to dialplan */ return res; } /*!\internal * \brief Dialplan function to record voicemail */ static int minivm_record_exec(struct ast_channel *chan, const char *data) { int res = 0; char *tmp; struct leave_vm_options leave_options; int argc; char *argv[2]; struct ast_flags flags = { 0 }; char *opts[OPT_ARG_ARRAY_SIZE]; memset(&leave_options, 0, sizeof(leave_options)); /* Answer channel if it's not already answered */ if (ast_channel_state(chan) != AST_STATE_UP) ast_answer(chan); if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "Minivm needs at least an account argument \n"); return -1; } tmp = ast_strdupa((char *)data); argc = ast_app_separate_args(tmp, ',', argv, ARRAY_LEN(argv)); if (argc == 2) { if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) { return -1; } ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING ); if (ast_test_flag(&flags, OPT_RECORDGAIN)) { int gain; if (sscanf(opts[OPT_ARG_RECORDGAIN], "%30d", &gain) != 1) { ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]); return -1; } else leave_options.record_gain = (signed char) gain; } } /* Now run the appliation and good luck to you! */ res = leave_voicemail(chan, argv[0], &leave_options); if (res == ERROR_LOCK_PATH) { ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); res = 0; } pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "SUCCESS"); return res; } /*!\internal * \brief Play voicemail prompts - either generic or user specific */ static int minivm_greet_exec(struct ast_channel *chan, const char *data) { struct leave_vm_options leave_options = { 0, '\0'}; int argc; char *argv[2]; struct ast_flags flags = { 0 }; char *opts[OPT_ARG_ARRAY_SIZE]; int res = 0; int ausemacro = 0; int ousemacro = 0; int ouseexten = 0; char tmp[PATH_MAX]; char dest[PATH_MAX]; char prefile[PATH_MAX] = ""; char tempfile[PATH_MAX] = ""; char ext_context[256] = ""; char *domain; char ecodes[16] = "#"; char *tmpptr; struct minivm_account *vmu; char *username = argv[0]; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "Minivm needs at least an account argument \n"); return -1; } tmpptr = ast_strdupa((char *)data); argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); if (argc == 2) { if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) return -1; ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING ); } ast_copy_string(tmp, argv[0], sizeof(tmp)); username = tmp; domain = strchr(tmp, '@'); if (domain) { *domain = '\0'; domain++; } if (ast_strlen_zero(domain) || ast_strlen_zero(username)) { ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument: %s\n", argv[0]); return -1; } ast_debug(1, "Trying to find configuration for user %s in domain %s\n", username, domain); if (!(vmu = find_account(domain, username, TRUE))) { ast_log(LOG_ERROR, "Could not allocate memory. \n"); return -1; } /* Answer channel if it's not already answered */ if (ast_channel_state(chan) != AST_STATE_UP) ast_answer(chan); /* Setup pre-file if appropriate */ if (strcmp(vmu->domain, "localhost")) snprintf(ext_context, sizeof(ext_context), "%s@%s", username, vmu->domain); else ast_copy_string(ext_context, vmu->domain, sizeof(ext_context)); if (ast_test_flag(&leave_options, OPT_BUSY_GREETING)) { res = check_dirpath(dest, sizeof(dest), vmu->domain, username, "busy"); if (res) snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", MVM_SPOOL_DIR, vmu->domain, username); } else if (ast_test_flag(&leave_options, OPT_UNAVAIL_GREETING)) { res = check_dirpath(dest, sizeof(dest), vmu->domain, username, "unavail"); if (res) snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", MVM_SPOOL_DIR, vmu->domain, username); } /* Check for temporary greeting - it overrides busy and unavail */ snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", MVM_SPOOL_DIR, vmu->domain, username); if (!(res = check_dirpath(dest, sizeof(dest), vmu->domain, username, "temp"))) { ast_debug(2, "Temporary message directory does not exist, using default (%s)\n", tempfile); ast_copy_string(prefile, tempfile, sizeof(prefile)); } ast_debug(2, "Preparing to play message ...\n"); /* Check current or macro-calling context for special extensions */ if (ast_test_flag(vmu, MVM_OPERATOR)) { if (!ast_strlen_zero(vmu->exit)) { if (ast_exists_extension(chan, vmu->exit, "o", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1); ouseexten = 1; } } else if (ast_exists_extension(chan, ast_channel_context(chan), "o", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1); ouseexten = 1; } else if (!ast_strlen_zero(ast_channel_macrocontext(chan)) && ast_exists_extension(chan, ast_channel_macrocontext(chan), "o", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1); ousemacro = 1; } } if (!ast_strlen_zero(vmu->exit)) { if (ast_exists_extension(chan, vmu->exit, "a", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1); } } else if (ast_exists_extension(chan, ast_channel_context(chan), "a", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1); } else if (!ast_strlen_zero(ast_channel_macrocontext(chan)) && ast_exists_extension(chan, ast_channel_macrocontext(chan), "a", 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1); ausemacro = 1; } res = 0; /* Reset */ /* Play the beginning intro if desired */ if (!ast_strlen_zero(prefile)) { if (ast_streamfile(chan, prefile, ast_channel_language(chan)) > -1) res = ast_waitstream(chan, ecodes); } else { ast_debug(2, "%s doesn't exist, doing what we can\n", prefile); res = invent_message(chan, vmu->domain, username, ast_test_flag(&leave_options, OPT_BUSY_GREETING), ecodes); } if (res < 0) { ast_debug(2, "Hang up during prefile playback\n"); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "FAILED"); if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); return -1; } if (res == '#') { /* On a '#' we skip the instructions */ ast_set_flag(&leave_options, OPT_SILENT); res = 0; } if (!res && !ast_test_flag(&leave_options, OPT_SILENT)) { res = ast_streamfile(chan, SOUND_INTRO, ast_channel_language(chan)); if (!res) res = ast_waitstream(chan, ecodes); if (res == '#') { ast_set_flag(&leave_options, OPT_SILENT); res = 0; } } if (res > 0) ast_stopstream(chan); /* Check for a '*' here in case the caller wants to escape from voicemail to something other than the operator -- an automated attendant or mailbox login for example */ if (res == '*') { ast_channel_exten_set(chan, "a"); if (!ast_strlen_zero(vmu->exit)) { ast_channel_context_set(chan, vmu->exit); } else if (ausemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) { ast_channel_context_set(chan, ast_channel_macrocontext(chan)); } ast_channel_priority_set(chan, 0); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT"); res = 0; } else if (res == '0') { /* Check for a '0' here */ if(ouseexten || ousemacro) { ast_channel_exten_set(chan, "o"); if (!ast_strlen_zero(vmu->exit)) { ast_channel_context_set(chan, vmu->exit); } else if (ousemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) { ast_channel_context_set(chan, ast_channel_macrocontext(chan)); } ast_play_and_wait(chan, "transfer"); ast_channel_priority_set(chan, 0); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT"); } res = 0; } else if (res < 0) { pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "FAILED"); res = -1; } else pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "SUCCESS"); if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); /* Ok, we're ready to rock and roll. Return to dialplan */ return res; } /*!\internal * \brief Dialplan application to delete voicemail */ static int minivm_delete_exec(struct ast_channel *chan, const char *data) { int res = 0; char filename[BUFSIZ]; if (!ast_strlen_zero(data)) { ast_copy_string(filename, (char *) data, sizeof(filename)); } else { ast_channel_lock(chan); ast_copy_string(filename, pbx_builtin_getvar_helper(chan, "MVM_FILENAME"), sizeof(filename)); ast_channel_unlock(chan); } if (ast_strlen_zero(filename)) { ast_log(LOG_ERROR, "No filename given in application arguments or channel variable MVM_FILENAME\n"); return res; } /* Go ahead and delete audio files from system, they're not needed any more */ /* We should look for both audio and text files here */ if (ast_fileexists(filename, NULL, NULL) > 0) { res = vm_delete(filename); if (res) { ast_debug(2, "Can't delete file: %s\n", filename); pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "FAILED"); } else { ast_debug(2, "Deleted voicemail file :: %s \n", filename); pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "SUCCESS"); } } else { ast_debug(2, "Filename does not exist: %s\n", filename); pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "FAILED"); } return res; } /*! \brief Record specific messages for voicemail account */ static int minivm_accmess_exec(struct ast_channel *chan, const char *data) { int argc = 0; char *argv[2]; char filename[PATH_MAX]; char tmp[PATH_MAX]; char *domain; char *tmpptr = NULL; struct minivm_account *vmu; char *username; struct ast_flags flags = { 0 }; char *opts[OPT_ARG_ARRAY_SIZE]; int error = FALSE; char *message = NULL; char *prompt = NULL; int duration; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "MinivmAccmess needs at least two arguments: account and option\n"); error = TRUE; } else { tmpptr = ast_strdupa((char *)data); argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); } if (argc <=1) { ast_log(LOG_ERROR, "MinivmAccmess needs at least two arguments: account and option\n"); error = TRUE; } if (!error && strlen(argv[1]) > 1) { ast_log(LOG_ERROR, "MinivmAccmess can only handle one option at a time. Bad option string: %s\n", argv[1]); error = TRUE; } if (!error && ast_app_parse_options(minivm_accmess_options, &flags, opts, argv[1])) { ast_log(LOG_ERROR, "Can't parse option %s\n", argv[1]); error = TRUE; } if (error) { pbx_builtin_setvar_helper(chan, "MVM_ACCMESS_STATUS", "FAILED"); return -1; } ast_copy_string(tmp, argv[0], sizeof(tmp)); username = tmp; domain = strchr(tmp, '@'); if (domain) { *domain = '\0'; domain++; } if (ast_strlen_zero(domain) || ast_strlen_zero(username)) { ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument 0 %s\n", argv[0]); pbx_builtin_setvar_helper(chan, "MVM_ACCMESS_STATUS", "FAILED"); return -1; } if(!(vmu = find_account(domain, username, TRUE))) { /* We could not find user, let's exit */ ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain); pbx_builtin_setvar_helper(chan, "MVM_ACCMESS_STATUS", "FAILED"); return -1; } /* Answer channel if it's not already answered */ if (ast_channel_state(chan) != AST_STATE_UP) ast_answer(chan); /* Here's where the action is */ if (ast_test_flag(&flags, OPT_BUSY_GREETING)) { message = "busy"; prompt = "vm-rec-busy"; } else if (ast_test_flag(&flags, OPT_UNAVAIL_GREETING)) { message = "unavailable"; prompt = "vm-rec-unv"; } else if (ast_test_flag(&flags, OPT_TEMP_GREETING)) { message = "temp"; prompt = "vm-rec-temp"; } else if (ast_test_flag(&flags, OPT_NAME_GREETING)) { message = "greet"; prompt = "vm-rec-name"; } snprintf(filename,sizeof(filename), "%s%s/%s/%s", MVM_SPOOL_DIR, vmu->domain, vmu->username, message); /* Maybe we should check the result of play_record_review ? */ play_record_review(chan, prompt, filename, global_maxgreet, default_vmformat, 0, vmu, &duration, NULL, NULL, FALSE); ast_debug(1, "Recorded new %s message in %s (duration %d)\n", message, filename, duration); if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); pbx_builtin_setvar_helper(chan, "MVM_ACCMESS_STATUS", "SUCCESS"); /* Ok, we're ready to rock and roll. Return to dialplan */ return 0; } /*! \brief Append new mailbox to mailbox list from configuration file */ static int create_vmaccount(char *name, struct ast_variable *var, int realtime) { struct minivm_account *vmu; char *domain; char *username; char accbuf[BUFSIZ]; ast_debug(3, "Creating %s account for [%s]\n", realtime ? "realtime" : "static", name); ast_copy_string(accbuf, name, sizeof(accbuf)); username = accbuf; domain = strchr(accbuf, '@'); if (domain) { *domain = '\0'; domain++; } if (ast_strlen_zero(domain)) { ast_log(LOG_ERROR, "No domain given for mini-voicemail account %s. Not configured.\n", name); return 0; } ast_debug(3, "Creating static account for user %s domain %s\n", username, domain); /* Allocate user account */ vmu = ast_calloc(1, sizeof(*vmu)); if (!vmu) return 0; ast_copy_string(vmu->domain, domain, sizeof(vmu->domain)); ast_copy_string(vmu->username, username, sizeof(vmu->username)); populate_defaults(vmu); ast_debug(3, "...Configuring account %s\n", name); while (var) { ast_debug(3, "Configuring %s = \"%s\" for account %s\n", var->name, var->value, name); if (!strcasecmp(var->name, "serveremail")) { ast_copy_string(vmu->serveremail, var->value, sizeof(vmu->serveremail)); } else if (!strcasecmp(var->name, "email")) { ast_copy_string(vmu->email, var->value, sizeof(vmu->email)); } else if (!strcasecmp(var->name, "accountcode")) { ast_copy_string(vmu->accountcode, var->value, sizeof(vmu->accountcode)); } else if (!strcasecmp(var->name, "pincode")) { ast_copy_string(vmu->pincode, var->value, sizeof(vmu->pincode)); } else if (!strcasecmp(var->name, "domain")) { ast_copy_string(vmu->domain, var->value, sizeof(vmu->domain)); } else if (!strcasecmp(var->name, "language")) { ast_copy_string(vmu->language, var->value, sizeof(vmu->language)); } else if (!strcasecmp(var->name, "timezone")) { ast_copy_string(vmu->zonetag, var->value, sizeof(vmu->zonetag)); } else if (!strcasecmp(var->name, "externnotify")) { ast_copy_string(vmu->externnotify, var->value, sizeof(vmu->externnotify)); } else if (!strcasecmp(var->name, "etemplate")) { ast_copy_string(vmu->etemplate, var->value, sizeof(vmu->etemplate)); } else if (!strcasecmp(var->name, "ptemplate")) { ast_copy_string(vmu->ptemplate, var->value, sizeof(vmu->ptemplate)); } else if (!strcasecmp(var->name, "fullname")) { ast_copy_string(vmu->fullname, var->value, sizeof(vmu->fullname)); } else if (!strcasecmp(var->name, "setvar")) { char *varval; char *varname = ast_strdupa(var->value); struct ast_variable *tmpvar; if ((varval = strchr(varname, '='))) { *varval = '\0'; varval++; if ((tmpvar = ast_variable_new(varname, varval, ""))) { tmpvar->next = vmu->chanvars; vmu->chanvars = tmpvar; } } } else if (!strcasecmp(var->name, "pager")) { ast_copy_string(vmu->pager, var->value, sizeof(vmu->pager)); } else if (!strcasecmp(var->name, "volgain")) { sscanf(var->value, "%30lf", &vmu->volgain); } else { ast_log(LOG_ERROR, "Unknown configuration option for minivm account %s : %s\n", name, var->name); } var = var->next; } ast_debug(3, "...Linking account %s\n", name); AST_LIST_LOCK(&minivm_accounts); AST_LIST_INSERT_TAIL(&minivm_accounts, vmu, list); AST_LIST_UNLOCK(&minivm_accounts); global_stats.voicemailaccounts++; ast_debug(2, "MVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : ""); return 0; } /*! \brief Free Mini Voicemail timezone */ static void free_zone(struct minivm_zone *z) { ast_free(z); } /*! \brief Clear list of timezones */ static void timezone_destroy_list(void) { struct minivm_zone *this; AST_LIST_LOCK(&minivm_zones); while ((this = AST_LIST_REMOVE_HEAD(&minivm_zones, list))) free_zone(this); AST_LIST_UNLOCK(&minivm_zones); } /*! \brief Add time zone to memory list */ static int timezone_add(const char *zonename, const char *config) { struct minivm_zone *newzone; char *msg_format, *timezone_str; newzone = ast_calloc(1, sizeof(*newzone)); if (newzone == NULL) return 0; msg_format = ast_strdupa(config); timezone_str = strsep(&msg_format, "|"); if (!msg_format) { ast_log(LOG_WARNING, "Invalid timezone definition : %s\n", zonename); ast_free(newzone); return 0; } ast_copy_string(newzone->name, zonename, sizeof(newzone->name)); ast_copy_string(newzone->timezone, timezone_str, sizeof(newzone->timezone)); ast_copy_string(newzone->msg_format, msg_format, sizeof(newzone->msg_format)); AST_LIST_LOCK(&minivm_zones); AST_LIST_INSERT_TAIL(&minivm_zones, newzone, list); AST_LIST_UNLOCK(&minivm_zones); global_stats.timezones++; return 0; } /*! \brief Read message template from file */ static char *message_template_parse_filebody(const char *filename) { char buf[BUFSIZ * 6]; char readbuf[BUFSIZ]; char filenamebuf[BUFSIZ]; char *writepos; char *messagebody; FILE *fi; int lines = 0; if (ast_strlen_zero(filename)) return NULL; if (*filename == '/') ast_copy_string(filenamebuf, filename, sizeof(filenamebuf)); else snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ast_config_AST_CONFIG_DIR, filename); if (!(fi = fopen(filenamebuf, "r"))) { ast_log(LOG_ERROR, "Can't read message template from file: %s\n", filenamebuf); return NULL; } writepos = buf; while (fgets(readbuf, sizeof(readbuf), fi)) { lines ++; if (writepos != buf) { *writepos = '\n'; /* Replace EOL with new line */ writepos++; } ast_copy_string(writepos, readbuf, sizeof(buf) - (writepos - buf)); writepos += strlen(readbuf) - 1; } fclose(fi); messagebody = ast_calloc(1, strlen(buf + 1)); ast_copy_string(messagebody, buf, strlen(buf) + 1); ast_debug(4, "---> Size of allocation %d\n", (int) strlen(buf + 1) ); ast_debug(4, "---> Done reading message template : \n%s\n---- END message template--- \n", messagebody); return messagebody; } /*! \brief Parse emailbody template from configuration file */ static char *message_template_parse_emailbody(const char *configuration) { char *tmpread, *tmpwrite; char *emailbody = ast_strdup(configuration); /* substitute strings \t and \n into the apropriate characters */ tmpread = tmpwrite = emailbody; while ((tmpwrite = strchr(tmpread,'\\'))) { int len = strlen("\n"); switch (tmpwrite[1]) { case 'n': memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1); strncpy(tmpwrite, "\n", len); break; case 't': memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1); strncpy(tmpwrite, "\t", len); break; default: ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]); } tmpread = tmpwrite + len; } return emailbody; } /*! \brief Apply general configuration options */ static int apply_general_options(struct ast_variable *var) { int error = 0; while (var) { /* Mail command */ if (!strcmp(var->name, "mailcmd")) { ast_copy_string(global_mailcmd, var->value, sizeof(global_mailcmd)); /* User setting */ } else if (!strcmp(var->name, "maxgreet")) { global_maxgreet = atoi(var->value); } else if (!strcmp(var->name, "maxsilence")) { global_maxsilence = atoi(var->value); if (global_maxsilence > 0) global_maxsilence *= 1000; } else if (!strcmp(var->name, "logfile")) { if (!ast_strlen_zero(var->value) ) { if(*(var->value) == '/') ast_copy_string(global_logfile, var->value, sizeof(global_logfile)); else snprintf(global_logfile, sizeof(global_logfile), "%s/%s", ast_config_AST_LOG_DIR, var->value); } } else if (!strcmp(var->name, "externnotify")) { /* External voicemail notify application */ ast_copy_string(global_externnotify, var->value, sizeof(global_externnotify)); } else if (!strcmp(var->name, "silencetreshold")) { /* Silence treshold */ global_silencethreshold = atoi(var->value); } else if (!strcmp(var->name, "maxmessage")) { int x; if (sscanf(var->value, "%30d", &x) == 1) { global_vmmaxmessage = x; } else { error ++; ast_log(LOG_WARNING, "Invalid max message time length\n"); } } else if (!strcmp(var->name, "minmessage")) { int x; if (sscanf(var->value, "%30d", &x) == 1) { global_vmminmessage = x; if (global_maxsilence <= global_vmminmessage) ast_log(LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n"); } else { error ++; ast_log(LOG_WARNING, "Invalid min message time length\n"); } } else if (!strcmp(var->name, "format")) { ast_copy_string(default_vmformat, var->value, sizeof(default_vmformat)); } else if (!strcmp(var->name, "review")) { ast_set2_flag((&globalflags), ast_true(var->value), MVM_REVIEW); } else if (!strcmp(var->name, "operator")) { ast_set2_flag((&globalflags), ast_true(var->value), MVM_OPERATOR); } var = var->next; } return error; } /*! \brief Load minivoicemail configuration */ static int load_config(int reload) { struct ast_config *cfg; struct ast_variable *var; char *cat; const char *chanvar; int error = 0; struct minivm_template *template; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags); if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; } else if (cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n"); return 0; } ast_mutex_lock(&minivmlock); /* Destroy lists to reconfigure */ message_destroy_list(); /* Destroy list of voicemail message templates */ timezone_destroy_list(); /* Destroy list of timezones */ vmaccounts_destroy_list(); /* Destroy list of voicemail accounts */ ast_debug(2, "Destroyed memory objects...\n"); /* First, set some default settings */ global_externnotify[0] = '\0'; global_logfile[0] = '\0'; global_vmmaxmessage = 2000; global_maxgreet = 2000; global_vmminmessage = 0; strcpy(global_mailcmd, SENDMAIL); global_maxsilence = 0; global_saydurationminfo = 2; ast_copy_string(default_vmformat, "wav", sizeof(default_vmformat)); ast_set2_flag((&globalflags), FALSE, MVM_REVIEW); ast_set2_flag((&globalflags), FALSE, MVM_OPERATOR); /* Reset statistics */ memset(&global_stats, 0, sizeof(global_stats)); global_stats.reset = ast_tvnow(); global_silencethreshold = ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE); /* Make sure we could load configuration file */ if (!cfg) { ast_log(LOG_WARNING, "Failed to load configuration file. Module activated with default settings.\n"); ast_mutex_unlock(&minivmlock); return 0; } ast_debug(2, "Loaded configuration file, now parsing\n"); /* General settings */ cat = ast_category_browse(cfg, NULL); while (cat) { ast_debug(3, "Found configuration section [%s]\n", cat); if (!strcasecmp(cat, "general")) { /* Nothing right now */ error += apply_general_options(ast_variable_browse(cfg, cat)); } else if (!strncasecmp(cat, "template-", 9)) { /* Template */ char *name = cat + 9; /* Now build and link template to list */ error += message_template_build(name, ast_variable_browse(cfg, cat)); } else { var = ast_variable_browse(cfg, cat); if (!strcasecmp(cat, "zonemessages")) { /* Timezones in this context */ while (var) { timezone_add(var->name, var->value); var = var->next; } } else { /* Create mailbox from this */ error += create_vmaccount(cat, var, FALSE); } } /* Find next section in configuration file */ cat = ast_category_browse(cfg, cat); } /* Configure the default email template */ message_template_build("email-default", NULL); template = message_template_find("email-default"); /* Load date format config for voicemail mail */ if ((chanvar = ast_variable_retrieve(cfg, "general", "emaildateformat"))) ast_copy_string(template->dateformat, chanvar, sizeof(template->dateformat)); if ((chanvar = ast_variable_retrieve(cfg, "general", "emailfromstring"))) ast_copy_string(template->fromaddress, chanvar, sizeof(template->fromaddress)); if ((chanvar = ast_variable_retrieve(cfg, "general", "emailaaddress"))) ast_copy_string(template->serveremail, chanvar, sizeof(template->serveremail)); if ((chanvar = ast_variable_retrieve(cfg, "general", "emailcharset"))) ast_copy_string(template->charset, chanvar, sizeof(template->charset)); if ((chanvar = ast_variable_retrieve(cfg, "general", "emailsubject"))) ast_copy_string(template->subject, chanvar, sizeof(template->subject)); if ((chanvar = ast_variable_retrieve(cfg, "general", "emailbody"))) template->body = message_template_parse_emailbody(chanvar); template->attachment = TRUE; message_template_build("pager-default", NULL); template = message_template_find("pager-default"); if ((chanvar = ast_variable_retrieve(cfg, "general", "pagerfromstring"))) ast_copy_string(template->fromaddress, chanvar, sizeof(template->fromaddress)); if ((chanvar = ast_variable_retrieve(cfg, "general", "pageraddress"))) ast_copy_string(template->serveremail, chanvar, sizeof(template->serveremail)); if ((chanvar = ast_variable_retrieve(cfg, "general", "pagercharset"))) ast_copy_string(template->charset, chanvar, sizeof(template->charset)); if ((chanvar = ast_variable_retrieve(cfg, "general", "pagersubject"))) ast_copy_string(template->subject, chanvar,sizeof(template->subject)); if ((chanvar = ast_variable_retrieve(cfg, "general", "pagerbody"))) template->body = message_template_parse_emailbody(chanvar); template->attachment = FALSE; if (error) ast_log(LOG_ERROR, "--- A total of %d errors found in mini-voicemail configuration\n", error); ast_mutex_unlock(&minivmlock); ast_config_destroy(cfg); /* Close log file if it's open and disabled */ if(minivmlogfile) fclose(minivmlogfile); /* Open log file if it's enabled */ if(!ast_strlen_zero(global_logfile)) { minivmlogfile = fopen(global_logfile, "a"); if(!minivmlogfile) ast_log(LOG_ERROR, "Failed to open minivm log file %s : %s\n", global_logfile, strerror(errno)); if (minivmlogfile) ast_debug(3, "Opened log file %s \n", global_logfile); } return 0; } /*! \brief CLI routine for listing templates */ static char *handle_minivm_list_templates(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct minivm_template *this; #define HVLT_OUTPUT_FORMAT "%-15s %-10s %-10s %-15.15s %-50s\n" int count = 0; switch (cmd) { case CLI_INIT: e->command = "minivm list templates"; e->usage = "Usage: minivm list templates\n" " Lists message templates for e-mail, paging and IM\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc > 3) return CLI_SHOWUSAGE; AST_LIST_LOCK(&message_templates); if (AST_LIST_EMPTY(&message_templates)) { ast_cli(a->fd, "There are no message templates defined\n"); AST_LIST_UNLOCK(&message_templates); return CLI_FAILURE; } ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "Template name", "Charset", "Locale", "Attach media", "Subject"); ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "-------------", "-------", "------", "------------", "-------"); AST_LIST_TRAVERSE(&message_templates, this, list) { ast_cli(a->fd, HVLT_OUTPUT_FORMAT, this->name, this->charset ? this->charset : "-", this->locale ? this->locale : "-", this->attachment ? "Yes" : "No", this->subject ? this->subject : "-"); count++; } AST_LIST_UNLOCK(&message_templates); ast_cli(a->fd, "\n * Total: %d minivoicemail message templates\n", count); return CLI_SUCCESS; } static char *complete_minivm_show_users(const char *line, const char *word, int pos, int state) { int which = 0; int wordlen; struct minivm_account *vmu; const char *domain = ""; /* 0 - voicemail; 1 - list; 2 - accounts; 3 - for; 4 - */ if (pos > 4) return NULL; if (pos == 3) return (state == 0) ? ast_strdup("for") : NULL; wordlen = strlen(word); AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) { if (!strncasecmp(word, vmu->domain, wordlen)) { if (domain && strcmp(domain, vmu->domain) && ++which > state) return ast_strdup(vmu->domain); /* ignore repeated domains ? */ domain = vmu->domain; } } return NULL; } /*! \brief CLI command to list voicemail accounts */ static char *handle_minivm_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct minivm_account *vmu; #define HMSU_OUTPUT_FORMAT "%-23s %-15s %-15s %-10s %-10s %-50s\n" int count = 0; switch (cmd) { case CLI_INIT: e->command = "minivm list accounts"; e->usage = "Usage: minivm list accounts\n" " Lists all mailboxes currently set up\n"; return NULL; case CLI_GENERATE: return complete_minivm_show_users(a->line, a->word, a->pos, a->n); } if ((a->argc < 3) || (a->argc > 5) || (a->argc == 4)) return CLI_SHOWUSAGE; if ((a->argc == 5) && strcmp(a->argv[3],"for")) return CLI_SHOWUSAGE; AST_LIST_LOCK(&minivm_accounts); if (AST_LIST_EMPTY(&minivm_accounts)) { ast_cli(a->fd, "There are no voicemail users currently defined\n"); AST_LIST_UNLOCK(&minivm_accounts); return CLI_FAILURE; } ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "User", "E-Template", "P-template", "Zone", "Format", "Full name"); ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "----", "----------", "----------", "----", "------", "---------"); AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) { char tmp[256] = ""; if ((a->argc == 3) || ((a->argc == 5) && !strcmp(a->argv[4], vmu->domain))) { count++; snprintf(tmp, sizeof(tmp), "%s@%s", vmu->username, vmu->domain); ast_cli(a->fd, HMSU_OUTPUT_FORMAT, tmp, vmu->etemplate ? vmu->etemplate : "-", vmu->ptemplate ? vmu->ptemplate : "-", vmu->zonetag ? vmu->zonetag : "-", vmu->attachfmt ? vmu->attachfmt : "-", vmu->fullname); } } AST_LIST_UNLOCK(&minivm_accounts); ast_cli(a->fd, "\n * Total: %d minivoicemail accounts\n", count); return CLI_SUCCESS; } /*! \brief Show a list of voicemail zones in the CLI */ static char *handle_minivm_show_zones(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct minivm_zone *zone; #define HMSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n" char *res = CLI_SUCCESS; switch (cmd) { case CLI_INIT: e->command = "minivm list zones"; e->usage = "Usage: minivm list zones\n" " Lists zone message formats\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != e->args) return CLI_SHOWUSAGE; AST_LIST_LOCK(&minivm_zones); if (!AST_LIST_EMPTY(&minivm_zones)) { ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "Zone", "Timezone", "Message Format"); ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "----", "--------", "--------------"); AST_LIST_TRAVERSE(&minivm_zones, zone, list) { ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, zone->name, zone->timezone, zone->msg_format); } } else { ast_cli(a->fd, "There are no voicemail zones currently defined\n"); res = CLI_FAILURE; } AST_LIST_UNLOCK(&minivm_zones); return res; } /*! \brief CLI Show settings */ static char *handle_minivm_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: e->command = "minivm show settings"; e->usage = "Usage: minivm show settings\n" " Display Mini-Voicemail general settings\n"; return NULL; case CLI_GENERATE: return NULL; } ast_cli(a->fd, "* Mini-Voicemail general settings\n"); ast_cli(a->fd, " -------------------------------\n"); ast_cli(a->fd, "\n"); ast_cli(a->fd, " Mail command (shell): %s\n", global_mailcmd); ast_cli(a->fd, " Max silence: %d\n", global_maxsilence); ast_cli(a->fd, " Silence threshold: %d\n", global_silencethreshold); ast_cli(a->fd, " Max message length (secs): %d\n", global_vmmaxmessage); ast_cli(a->fd, " Min message length (secs): %d\n", global_vmminmessage); ast_cli(a->fd, " Default format: %s\n", default_vmformat); ast_cli(a->fd, " Extern notify (shell): %s\n", global_externnotify); ast_cli(a->fd, " Logfile: %s\n", global_logfile[0] ? global_logfile : ""); ast_cli(a->fd, " Operator exit: %s\n", ast_test_flag(&globalflags, MVM_OPERATOR) ? "Yes" : "No"); ast_cli(a->fd, " Message review: %s\n", ast_test_flag(&globalflags, MVM_REVIEW) ? "Yes" : "No"); ast_cli(a->fd, "\n"); return CLI_SUCCESS; } /*! \brief Show stats */ static char *handle_minivm_show_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ast_tm timebuf; char buf[BUFSIZ]; switch (cmd) { case CLI_INIT: e->command = "minivm show stats"; e->usage = "Usage: minivm show stats\n" " Display Mini-Voicemail counters\n"; return NULL; case CLI_GENERATE: return NULL; } ast_cli(a->fd, "* Mini-Voicemail statistics\n"); ast_cli(a->fd, " -------------------------\n"); ast_cli(a->fd, "\n"); ast_cli(a->fd, " Voicemail accounts: %5d\n", global_stats.voicemailaccounts); ast_cli(a->fd, " Templates: %5d\n", global_stats.templates); ast_cli(a->fd, " Timezones: %5d\n", global_stats.timezones); if (global_stats.receivedmessages == 0) { ast_cli(a->fd, " Received messages since last reset: \n"); } else { ast_cli(a->fd, " Received messages since last reset: %d\n", global_stats.receivedmessages); ast_localtime(&global_stats.lastreceived, &timebuf, NULL); ast_strftime(buf, sizeof(buf), "%a %b %e %r %Z %Y", &timebuf); ast_cli(a->fd, " Last received voicemail: %s\n", buf); } ast_localtime(&global_stats.reset, &timebuf, NULL); ast_strftime(buf, sizeof(buf), "%a %b %e %r %Z %Y", &timebuf); ast_cli(a->fd, " Last reset: %s\n", buf); ast_cli(a->fd, "\n"); return CLI_SUCCESS; } /*! \brief ${MINIVMACCOUNT()} Dialplan function - reads account data */ static int minivm_account_func_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct minivm_account *vmu; char *username, *domain, *colname; username = ast_strdupa(data); if ((colname = strchr(username, ':'))) { *colname = '\0'; colname++; } else { colname = "path"; } if ((domain = strchr(username, '@'))) { *domain = '\0'; domain++; } if (ast_strlen_zero(username) || ast_strlen_zero(domain)) { ast_log(LOG_ERROR, "This function needs a username and a domain: username@domain\n"); return 0; } if (!(vmu = find_account(domain, username, TRUE))) return 0; if (!strcasecmp(colname, "hasaccount")) { ast_copy_string(buf, (ast_test_flag(vmu, MVM_ALLOCED) ? "0" : "1"), len); } else if (!strcasecmp(colname, "fullname")) { ast_copy_string(buf, vmu->fullname, len); } else if (!strcasecmp(colname, "email")) { if (!ast_strlen_zero(vmu->email)) ast_copy_string(buf, vmu->email, len); else snprintf(buf, len, "%s@%s", vmu->username, vmu->domain); } else if (!strcasecmp(colname, "pager")) { ast_copy_string(buf, vmu->pager, len); } else if (!strcasecmp(colname, "etemplate")) { if (!ast_strlen_zero(vmu->etemplate)) ast_copy_string(buf, vmu->etemplate, len); else ast_copy_string(buf, "email-default", len); } else if (!strcasecmp(colname, "language")) { ast_copy_string(buf, vmu->language, len); } else if (!strcasecmp(colname, "timezone")) { ast_copy_string(buf, vmu->zonetag, len); } else if (!strcasecmp(colname, "ptemplate")) { if (!ast_strlen_zero(vmu->ptemplate)) ast_copy_string(buf, vmu->ptemplate, len); else ast_copy_string(buf, "email-default", len); } else if (!strcasecmp(colname, "accountcode")) { ast_copy_string(buf, vmu->accountcode, len); } else if (!strcasecmp(colname, "pincode")) { ast_copy_string(buf, vmu->pincode, len); } else if (!strcasecmp(colname, "path")) { check_dirpath(buf, len, vmu->domain, vmu->username, NULL); } else { /* Look in channel variables */ struct ast_variable *var; for (var = vmu->chanvars ; var ; var = var->next) if (!strcmp(var->name, colname)) { ast_copy_string(buf, var->value, len); break; } } if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); return 0; } /*! \brief lock directory only return failure if ast_lock_path returns 'timeout', not if the path does not exist or any other reason */ static int vm_lock_path(const char *path) { switch (ast_lock_path(path)) { case AST_LOCK_TIMEOUT: return -1; default: return 0; } } /*! \brief Access counter file, lock directory, read and possibly write it again changed \param directory Directory to crate file in \param countername filename \param value If set to zero, we only read the variable \param operand 0 to read, 1 to set new value, 2 to change \return -1 on error, otherwise counter value */ static int access_counter_file(char *directory, char *countername, int value, int operand) { char filename[BUFSIZ]; char readbuf[BUFSIZ]; FILE *counterfile; int old = 0, counter = 0; /* Lock directory */ if (vm_lock_path(directory)) { return -1; /* Could not lock directory */ } snprintf(filename, sizeof(filename), "%s/%s.counter", directory, countername); if (operand != 1) { counterfile = fopen(filename, "r"); if (counterfile) { if(fgets(readbuf, sizeof(readbuf), counterfile)) { ast_debug(3, "Read this string from counter file: %s\n", readbuf); old = counter = atoi(readbuf); } fclose(counterfile); } } switch (operand) { case 0: /* Read only */ ast_unlock_path(directory); ast_debug(2, "MINIVM Counter %s/%s: Value %d\n", directory, countername, counter); return counter; break; case 1: /* Set new value */ counter = value; break; case 2: /* Change value */ counter += value; if (counter < 0) /* Don't allow counters to fall below zero */ counter = 0; break; } /* Now, write the new value to the file */ counterfile = fopen(filename, "w"); if (!counterfile) { ast_log(LOG_ERROR, "Could not open counter file for writing : %s - %s\n", filename, strerror(errno)); ast_unlock_path(directory); return -1; /* Could not open file for writing */ } fprintf(counterfile, "%d\n\n", counter); fclose(counterfile); ast_unlock_path(directory); ast_debug(2, "MINIVM Counter %s/%s: Old value %d New value %d\n", directory, countername, old, counter); return counter; } /*! \brief ${MINIVMCOUNTER()} Dialplan function - read counters */ static int minivm_counter_func_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { char *username, *domain, *countername; char userpath[BUFSIZ]; int res; *buf = '\0'; username = ast_strdupa(data); if ((countername = strchr(username, ':'))) { *countername = '\0'; countername++; } if ((domain = strchr(username, '@'))) { *domain = '\0'; domain++; } /* If we have neither username nor domain now, let's give up */ if (ast_strlen_zero(username) && ast_strlen_zero(domain)) { ast_log(LOG_ERROR, "No account given\n"); return -1; } if (ast_strlen_zero(countername)) { ast_log(LOG_ERROR, "This function needs two arguments: Account:countername\n"); return -1; } /* We only have a domain, no username */ if (!ast_strlen_zero(username) && ast_strlen_zero(domain)) { domain = username; username = NULL; } /* If we can't find account or if the account is temporary, return. */ if (!ast_strlen_zero(username) && !find_account(domain, username, FALSE)) { ast_log(LOG_ERROR, "Minivm account does not exist: %s@%s\n", username, domain); return 0; } create_dirpath(userpath, sizeof(userpath), domain, username, NULL); /* We have the path, now read the counter file */ res = access_counter_file(userpath, countername, 0, 0); if (res >= 0) snprintf(buf, len, "%d", res); return 0; } /*! \brief ${MINIVMCOUNTER()} Dialplan function - changes counter data */ static int minivm_counter_func_write(struct ast_channel *chan, const char *cmd, char *data, const char *value) { char *username, *domain, *countername, *operand; char userpath[BUFSIZ]; int change = 0; int operation = 0; if(!value) return -1; change = atoi(value); username = ast_strdupa(data); if ((countername = strchr(username, ':'))) { *countername = '\0'; countername++; } if ((operand = strchr(countername, ':'))) { *operand = '\0'; operand++; } if ((domain = strchr(username, '@'))) { *domain = '\0'; domain++; } /* If we have neither username nor domain now, let's give up */ if (ast_strlen_zero(username) && ast_strlen_zero(domain)) { ast_log(LOG_ERROR, "No account given\n"); return -1; } /* We only have a domain, no username */ if (!ast_strlen_zero(username) && ast_strlen_zero(domain)) { domain = username; username = NULL; } if (ast_strlen_zero(operand) || ast_strlen_zero(countername)) { ast_log(LOG_ERROR, "Writing to this function requires three arguments: Account:countername:operand\n"); return -1; } /* If we can't find account or if the account is temporary, return. */ if (!ast_strlen_zero(username) && !find_account(domain, username, FALSE)) { ast_log(LOG_ERROR, "Minivm account does not exist: %s@%s\n", username, domain); return 0; } create_dirpath(userpath, sizeof(userpath), domain, username, NULL); /* Now, find out our operator */ if (*operand == 'i') /* Increment */ operation = 2; else if (*operand == 'd') { change = change * -1; operation = 2; } else if (*operand == 's') operation = 1; else { ast_log(LOG_ERROR, "Unknown operator: %s\n", operand); return -1; } /* We have the path, now read the counter file */ access_counter_file(userpath, countername, change, operation); return 0; } /*! \brief CLI commands for Mini-voicemail */ static struct ast_cli_entry cli_minivm[] = { AST_CLI_DEFINE(handle_minivm_show_users, "List defined mini-voicemail boxes"), AST_CLI_DEFINE(handle_minivm_show_zones, "List zone message formats"), AST_CLI_DEFINE(handle_minivm_list_templates, "List message templates"), AST_CLI_DEFINE(handle_minivm_reload, "Reload Mini-voicemail configuration"), AST_CLI_DEFINE(handle_minivm_show_stats, "Show some mini-voicemail statistics"), AST_CLI_DEFINE(handle_minivm_show_settings, "Show mini-voicemail general settings"), }; static struct ast_custom_function minivm_counter_function = { .name = "MINIVMCOUNTER", .read = minivm_counter_func_read, .write = minivm_counter_func_write, }; static struct ast_custom_function minivm_account_function = { .name = "MINIVMACCOUNT", .read = minivm_account_func_read, }; /*! \brief Load mini voicemail module */ static int load_module(void) { int res; res = ast_register_application_xml(app_minivm_record, minivm_record_exec); res = ast_register_application_xml(app_minivm_greet, minivm_greet_exec); res = ast_register_application_xml(app_minivm_notify, minivm_notify_exec); res = ast_register_application_xml(app_minivm_delete, minivm_delete_exec); res = ast_register_application_xml(app_minivm_accmess, minivm_accmess_exec); res = ast_register_application_xml(app_minivm_mwi, minivm_mwi_exec); ast_custom_function_register(&minivm_account_function); ast_custom_function_register(&minivm_counter_function); if (res) return(res); if ((res = load_config(0))) return(res); ast_cli_register_multiple(cli_minivm, ARRAY_LEN(cli_minivm)); /* compute the location of the voicemail spool directory */ snprintf(MVM_SPOOL_DIR, sizeof(MVM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR); return res; } /*! \brief Reload mini voicemail module */ static int reload(void) { return(load_config(1)); } /*! \brief Reload cofiguration */ static char *handle_minivm_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: e->command = "minivm reload"; e->usage = "Usage: minivm reload\n" " Reload mini-voicemail configuration and reset statistics\n"; return NULL; case CLI_GENERATE: return NULL; } reload(); ast_cli(a->fd, "\n-- Mini voicemail re-configured \n"); return CLI_SUCCESS; } /*! \brief Unload mini voicemail module */ static int unload_module(void) { int res; res = ast_unregister_application(app_minivm_record); res |= ast_unregister_application(app_minivm_greet); res |= ast_unregister_application(app_minivm_notify); res |= ast_unregister_application(app_minivm_delete); res |= ast_unregister_application(app_minivm_accmess); res |= ast_unregister_application(app_minivm_mwi); ast_cli_unregister_multiple(cli_minivm, ARRAY_LEN(cli_minivm)); ast_custom_function_unregister(&minivm_account_function); ast_custom_function_unregister(&minivm_counter_function); message_destroy_list(); /* Destroy list of voicemail message templates */ timezone_destroy_list(); /* Destroy list of timezones */ vmaccounts_destroy_list(); /* Destroy list of voicemail accounts */ return res; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Mini VoiceMail (A minimal Voicemail e-mail System)", .load = load_module, .unload = unload_module, .reload = reload, ); asterisk-11.7.0/apps/app_waitforring.c0000644000175000007640000000635212046530216017654 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Wait for Ring Application * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 376014 $") #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/lock.h" /*** DOCUMENTATION Wait for Ring Application. Returns 0 after waiting at least timeout seconds, and only after the next ring has completed. Returns 0 on success or -1 on hangup. ***/ static char *app = "WaitForRing"; static int waitforring_exec(struct ast_channel *chan, const char *data) { struct ast_frame *f; struct ast_silence_generator *silgen = NULL; int res = 0; double s; int timeout_ms; int ms; struct timeval start = ast_tvnow(); if (!data || (sscanf(data, "%30lg", &s) != 1)) { ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n"); return 0; } if (s < 0.0) { ast_log(LOG_WARNING, "Invalid timeout provided for WaitForRing (%lg)\n", s); return 0; } if (ast_opt_transmit_silence) { silgen = ast_channel_start_silence_generator(chan); } timeout_ms = s * 1000.0; while ((ms = ast_remaining_ms(start, timeout_ms))) { ms = ast_waitfor(chan, ms); if (ms < 0) { res = -1; break; } if (ms > 0) { f = ast_read(chan); if (!f) { res = -1; break; } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) { ast_verb(3, "Got a ring but still waiting for timeout\n"); } ast_frfree(f); } } /* Now we're really ready for the ring */ if (!res) { for (;;) { int wait_res = ast_waitfor(chan, -1); if (wait_res < 0) { res = -1; break; } else { f = ast_read(chan); if (!f) { res = -1; break; } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) { ast_verb(3, "Got a ring after the timeout\n"); ast_frfree(f); break; } ast_frfree(f); } } } if (silgen) { ast_channel_stop_silence_generator(chan, silgen); } return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { return ast_register_application_xml(app, waitforring_exec); } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Waits until first ring after time"); asterisk-11.7.0/apps/app_adsiprog.c0000644000175000007640000013554011702663426017143 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * 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 Program Asterisk ADSI Scripts into phone * * \author Mark Spencer * * \ingroup applications */ /*** MODULEINFO res_adsi extended ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 350223 $") #include #include #include "asterisk/paths.h" /* use ast_config_AST_CONFIG_DIR */ #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/adsi.h" #include "asterisk/utils.h" #include "asterisk/lock.h" static const char app[] = "ADSIProg"; /*** DOCUMENTATION Load Asterisk ADSI Scripts into phone adsi script to use. If not given uses the default script asterisk.adsi This application programs an ADSI Phone with the given script GetCPEID adsi.conf ***/ /* #define DUMP_MESSAGES */ struct adsi_event { int id; const char *name; }; static const struct adsi_event events[] = { { 1, "CALLERID" }, { 2, "VMWI" }, { 3, "NEARANSWER" }, { 4, "FARANSWER" }, { 5, "ENDOFRING" }, { 6, "IDLE" }, { 7, "OFFHOOK" }, { 8, "CIDCW" }, { 9, "BUSY" }, { 10, "FARRING" }, { 11, "DIALTONE" }, { 12, "RECALL" }, { 13, "MESSAGE" }, { 14, "REORDER" }, { 15, "DISTINCTIVERING" }, { 16, "RING" }, { 17, "REMINDERRING" }, { 18, "SPECIALRING" }, { 19, "CODEDRING" }, { 20, "TIMER" }, { 21, "INUSE" }, { 22, "EVENT22" }, { 23, "EVENT23" }, { 24, "CPEID" }, }; static const struct adsi_event justify[] = { { 0, "CENTER" }, { 1, "RIGHT" }, { 2, "LEFT" }, { 3, "INDENT" }, }; #define STATE_NORMAL 0 #define STATE_INKEY 1 #define STATE_INSUB 2 #define STATE_INIF 3 #define MAX_RET_CODE 20 #define MAX_SUB_LEN 255 #define MAX_MAIN_LEN 1600 #define ARG_STRING (1 << 0) #define ARG_NUMBER (1 << 1) struct adsi_soft_key { char vname[40]; /* Which "variable" is associated with it */ int retstrlen; /* Length of return string */ int initlen; /* initial length */ int id; int defined; char retstr[80]; /* Return string data */ }; struct adsi_subscript { char vname[40]; int id; int defined; int datalen; int inscount; int ifinscount; char *ifdata; char data[2048]; }; struct adsi_state { char vname[40]; int id; }; struct adsi_flag { char vname[40]; int id; }; struct adsi_display { char vname[40]; int id; char data[70]; int datalen; }; struct adsi_script { int state; int numkeys; int numsubs; int numstates; int numdisplays; int numflags; struct adsi_soft_key *key; struct adsi_subscript *sub; /* Pre-defined displays */ struct adsi_display displays[63]; /* ADSI States 1 (initial) - 254 */ struct adsi_state states[256]; /* Keys 2-63 */ struct adsi_soft_key keys[62]; /* Subscripts 0 (main) to 127 */ struct adsi_subscript subs[128]; /* Flags 1-7 */ struct adsi_flag flags[7]; /* Stuff from adsi script */ unsigned char sec[5]; char desc[19]; unsigned char fdn[5]; int ver; }; static int process_token(void *out, char *src, int maxlen, int argtype) { if ((strlen(src) > 1) && src[0] == '\"') { /* This is a quoted string */ if (!(argtype & ARG_STRING)) return -1; src++; /* Don't take more than what's there */ if (maxlen > strlen(src) - 1) maxlen = strlen(src) - 1; memcpy(out, src, maxlen); ((char *)out)[maxlen] = '\0'; } else if (!ast_strlen_zero(src) && (src[0] == '\\')) { if (!(argtype & ARG_NUMBER)) return -1; /* Octal value */ if (sscanf(src, "%30o", (int *)out) != 1) return -1; if (argtype & ARG_STRING) { /* Convert */ *((unsigned int *)out) = htonl(*((unsigned int *)out)); } } else if ((strlen(src) > 2) && (src[0] == '0') && (tolower(src[1]) == 'x')) { if (!(argtype & ARG_NUMBER)) return -1; /* Hex value */ if (sscanf(src + 2, "%30x", (unsigned int *)out) != 1) return -1; if (argtype & ARG_STRING) { /* Convert */ *((unsigned int *)out) = htonl(*((unsigned int *)out)); } } else if ((!ast_strlen_zero(src) && isdigit(src[0]))) { if (!(argtype & ARG_NUMBER)) return -1; /* Hex value */ if (sscanf(src, "%30d", (int *)out) != 1) return -1; if (argtype & ARG_STRING) { /* Convert */ *((unsigned int *)out) = htonl(*((unsigned int *)out)); } } else return -1; return 0; } static char *get_token(char **buf, const char *script, int lineno) { char *tmp = *buf, *keyword; int quoted = 0; /* Advance past any white space */ while(*tmp && (*tmp < 33)) tmp++; if (!*tmp) return NULL; keyword = tmp; while(*tmp && ((*tmp > 32) || quoted)) { if (*tmp == '\"') { quoted = !quoted; } tmp++; } if (quoted) { ast_log(LOG_WARNING, "Mismatched quotes at line %d of %s\n", lineno, script); return NULL; } *tmp = '\0'; tmp++; while(*tmp && (*tmp < 33)) tmp++; /* Note where we left off */ *buf = tmp; return keyword; } static char *validdtmf = "123456789*0#ABCD"; static int send_dtmf(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char dtmfstr[80], *a; int bytes = 0; if (!(a = get_token(&args, script, lineno))) { ast_log(LOG_WARNING, "Expecting something to send for SENDDTMF at line %d of %s\n", lineno, script); return 0; } if (process_token(dtmfstr, a, sizeof(dtmfstr) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Invalid token for SENDDTMF at line %d of %s\n", lineno, script); return 0; } a = dtmfstr; while (*a) { if (strchr(validdtmf, *a)) { *buf = *a; buf++; bytes++; } else ast_log(LOG_WARNING, "'%c' is not a valid DTMF tone at line %d of %s\n", *a, lineno, script); a++; } return bytes; } static int goto_line(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *page = get_token(&args, script, lineno); char *gline = get_token(&args, script, lineno); int line; unsigned char cmd; if (!page || !gline) { ast_log(LOG_WARNING, "Expecting page and line number for GOTOLINE at line %d of %s\n", lineno, script); return 0; } if (!strcasecmp(page, "INFO")) cmd = 0; else if (!strcasecmp(page, "COMM")) cmd = 0x80; else { ast_log(LOG_WARNING, "Expecting either 'INFO' or 'COMM' page, got got '%s' at line %d of %s\n", page, lineno, script); return 0; } if (process_token(&line, gline, sizeof(line), ARG_NUMBER)) { ast_log(LOG_WARNING, "Invalid line number '%s' at line %d of %s\n", gline, lineno, script); return 0; } cmd |= line; buf[0] = 0x8b; buf[1] = cmd; return 2; } static int goto_line_rel(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *dir = get_token(&args, script, lineno); char *gline = get_token(&args, script, lineno); int line; unsigned char cmd; if (!dir || !gline) { ast_log(LOG_WARNING, "Expecting direction and number of lines for GOTOLINEREL at line %d of %s\n", lineno, script); return 0; } if (!strcasecmp(dir, "UP")) cmd = 0; else if (!strcasecmp(dir, "DOWN")) cmd = 0x20; else { ast_log(LOG_WARNING, "Expecting either 'UP' or 'DOWN' direction, got '%s' at line %d of %s\n", dir, lineno, script); return 0; } if (process_token(&line, gline, sizeof(line), ARG_NUMBER)) { ast_log(LOG_WARNING, "Invalid line number '%s' at line %d of %s\n", gline, lineno, script); return 0; } cmd |= line; buf[0] = 0x8c; buf[1] = cmd; return 2; } static int send_delay(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *gtime = get_token(&args, script, lineno); int ms; if (!gtime) { ast_log(LOG_WARNING, "Expecting number of milliseconds to wait at line %d of %s\n", lineno, script); return 0; } if (process_token(&ms, gtime, sizeof(ms), ARG_NUMBER)) { ast_log(LOG_WARNING, "Invalid delay milliseconds '%s' at line %d of %s\n", gtime, lineno, script); return 0; } buf[0] = 0x90; if (id == 11) buf[1] = ms / 100; else buf[1] = ms / 10; return 2; } static int set_state(char *buf, char *name, int id, char *args, struct adsi_script *istate, const char *script, int lineno) { char *gstate = get_token(&args, script, lineno); int state; if (!gstate) { ast_log(LOG_WARNING, "Expecting state number at line %d of %s\n", lineno, script); return 0; } if (process_token(&state, gstate, sizeof(state), ARG_NUMBER)) { ast_log(LOG_WARNING, "Invalid state number '%s' at line %d of %s\n", gstate, lineno, script); return 0; } buf[0] = id; buf[1] = state; return 2; } static int cleartimer(char *buf, char *name, int id, char *args, struct adsi_script *istate, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); if (tok) ast_log(LOG_WARNING, "Clearing timer requires no arguments ('%s') at line %d of %s\n", tok, lineno, script); buf[0] = id; /* For some reason the clear code is different slightly */ if (id == 7) buf[1] = 0x10; else buf[1] = 0x00; return 2; } static struct adsi_flag *getflagbyname(struct adsi_script *state, char *name, const char *script, int lineno, int create) { int x; for (x = 0; x < state->numflags; x++) { if (!strcasecmp(state->flags[x].vname, name)) return &state->flags[x]; } /* Return now if we're not allowed to create */ if (!create) return NULL; if (state->numflags > 6) { ast_log(LOG_WARNING, "No more flag space at line %d of %s\n", lineno, script); return NULL; } ast_copy_string(state->flags[state->numflags].vname, name, sizeof(state->flags[state->numflags].vname)); state->flags[state->numflags].id = state->numflags + 1; state->numflags++; return &state->flags[state->numflags-1]; } static int setflag(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); char sname[80]; struct adsi_flag *flag; if (!tok) { ast_log(LOG_WARNING, "Setting flag requires a flag number at line %d of %s\n", lineno, script); return 0; } if (process_token(sname, tok, sizeof(sname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Invalid flag '%s' at line %d of %s\n", tok, lineno, script); return 0; } if (!(flag = getflagbyname(state, sname, script, lineno, 0))) { ast_log(LOG_WARNING, "Flag '%s' is undeclared at line %d of %s\n", sname, lineno, script); return 0; } buf[0] = id; buf[1] = ((flag->id & 0x7) << 4) | 1; return 2; } static int clearflag(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); struct adsi_flag *flag; char sname[80]; if (!tok) { ast_log(LOG_WARNING, "Clearing flag requires a flag number at line %d of %s\n", lineno, script); return 0; } if (process_token(sname, tok, sizeof(sname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Invalid flag '%s' at line %d of %s\n", tok, lineno, script); return 0; } if (!(flag = getflagbyname(state, sname, script, lineno, 0))) { ast_log(LOG_WARNING, "Flag '%s' is undeclared at line %d of %s\n", sname, lineno, script); return 0; } buf[0] = id; buf[1] = ((flag->id & 0x7) << 4); return 2; } static int starttimer(char *buf, char *name, int id, char *args, struct adsi_script *istate, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); int secs; if (!tok) { ast_log(LOG_WARNING, "Missing number of seconds at line %d of %s\n", lineno, script); return 0; } if (process_token(&secs, tok, sizeof(secs), ARG_NUMBER)) { ast_log(LOG_WARNING, "Invalid number of seconds '%s' at line %d of %s\n", tok, lineno, script); return 0; } buf[0] = id; buf[1] = 0x1; buf[2] = secs; return 3; } static int geteventbyname(char *name) { int x; for (x = 0; x < ARRAY_LEN(events); x++) { if (!strcasecmp(events[x].name, name)) return events[x].id; } return 0; } static int getjustifybyname(char *name) { int x; for (x = 0; x < ARRAY_LEN(justify); x++) { if (!strcasecmp(justify[x].name, name)) return justify[x].id; } return -1; } static struct adsi_soft_key *getkeybyname(struct adsi_script *state, char *name, const char *script, int lineno) { int x; for (x = 0; x < state->numkeys; x++) { if (!strcasecmp(state->keys[x].vname, name)) return &state->keys[x]; } if (state->numkeys > 61) { ast_log(LOG_WARNING, "No more key space at line %d of %s\n", lineno, script); return NULL; } ast_copy_string(state->keys[state->numkeys].vname, name, sizeof(state->keys[state->numkeys].vname)); state->keys[state->numkeys].id = state->numkeys + 2; state->numkeys++; return &state->keys[state->numkeys-1]; } static struct adsi_subscript *getsubbyname(struct adsi_script *state, char *name, const char *script, int lineno) { int x; for (x = 0; x < state->numsubs; x++) { if (!strcasecmp(state->subs[x].vname, name)) return &state->subs[x]; } if (state->numsubs > 127) { ast_log(LOG_WARNING, "No more subscript space at line %d of %s\n", lineno, script); return NULL; } ast_copy_string(state->subs[state->numsubs].vname, name, sizeof(state->subs[state->numsubs].vname)); state->subs[state->numsubs].id = state->numsubs; state->numsubs++; return &state->subs[state->numsubs-1]; } static struct adsi_state *getstatebyname(struct adsi_script *state, char *name, const char *script, int lineno, int create) { int x; for (x = 0; x numstates; x++) { if (!strcasecmp(state->states[x].vname, name)) return &state->states[x]; } /* Return now if we're not allowed to create */ if (!create) return NULL; if (state->numstates > 253) { ast_log(LOG_WARNING, "No more state space at line %d of %s\n", lineno, script); return NULL; } ast_copy_string(state->states[state->numstates].vname, name, sizeof(state->states[state->numstates].vname)); state->states[state->numstates].id = state->numstates + 1; state->numstates++; return &state->states[state->numstates-1]; } static struct adsi_display *getdisplaybyname(struct adsi_script *state, char *name, const char *script, int lineno, int create) { int x; for (x = 0; x < state->numdisplays; x++) { if (!strcasecmp(state->displays[x].vname, name)) return &state->displays[x]; } /* Return now if we're not allowed to create */ if (!create) return NULL; if (state->numdisplays > 61) { ast_log(LOG_WARNING, "No more display space at line %d of %s\n", lineno, script); return NULL; } ast_copy_string(state->displays[state->numdisplays].vname, name, sizeof(state->displays[state->numdisplays].vname)); state->displays[state->numdisplays].id = state->numdisplays + 1; state->numdisplays++; return &state->displays[state->numdisplays-1]; } static int showkeys(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *tok, newkey[80]; int bytes, x, flagid = 0; unsigned char keyid[6]; struct adsi_soft_key *key; struct adsi_flag *flag; for (x = 0; x < 7; x++) { /* Up to 6 key arguments */ if (!(tok = get_token(&args, script, lineno))) break; if (!strcasecmp(tok, "UNLESS")) { /* Check for trailing UNLESS flag */ if (!(tok = get_token(&args, script, lineno))) ast_log(LOG_WARNING, "Missing argument for UNLESS clause at line %d of %s\n", lineno, script); else if (process_token(newkey, tok, sizeof(newkey) - 1, ARG_STRING)) ast_log(LOG_WARNING, "Invalid flag name '%s' at line %d of %s\n", tok, lineno, script); else if (!(flag = getflagbyname(state, newkey, script, lineno, 0))) ast_log(LOG_WARNING, "Flag '%s' is undeclared at line %d of %s\n", newkey, lineno, script); else flagid = flag->id; if ((tok = get_token(&args, script, lineno))) ast_log(LOG_WARNING, "Extra arguments after UNLESS clause: '%s' at line %d of %s\n", tok, lineno, script); break; } if (x > 5) { ast_log(LOG_WARNING, "Only 6 keys can be defined, ignoring '%s' at line %d of %s\n", tok, lineno, script); break; } if (process_token(newkey, tok, sizeof(newkey) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Invalid token for key name: %s\n", tok); continue; } if (!(key = getkeybyname(state, newkey, script, lineno))) break; keyid[x] = key->id; } buf[0] = id; buf[1] = (flagid & 0x7) << 3 | (x & 0x7); for (bytes = 0; bytes < x; bytes++) buf[bytes + 2] = keyid[bytes]; return 2 + x; } static int showdisplay(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *tok, dispname[80]; int line = 0, flag = 0, cmd = 3; struct adsi_display *disp; /* Get display */ if (!(tok = get_token(&args, script, lineno)) || process_token(dispname, tok, sizeof(dispname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Invalid display name: %s at line %d of %s\n", tok ? tok : "", lineno, script); return 0; } if (!(disp = getdisplaybyname(state, dispname, script, lineno, 0))) { ast_log(LOG_WARNING, "Display '%s' is undefined at line %d of %s\n", dispname, lineno, script); return 0; } if (!(tok = get_token(&args, script, lineno)) || strcasecmp(tok, "AT")) { ast_log(LOG_WARNING, "Missing token 'AT' at line %d of %s\n", lineno, script); return 0; } /* Get line number */ if (!(tok = get_token(&args, script, lineno)) || process_token(&line, tok, sizeof(line), ARG_NUMBER)) { ast_log(LOG_WARNING, "Invalid line: '%s' at line %d of %s\n", tok ? tok : "", lineno, script); return 0; } if ((tok = get_token(&args, script, lineno)) && !strcasecmp(tok, "NOUPDATE")) { cmd = 1; tok = get_token(&args, script, lineno); } if (tok && !strcasecmp(tok, "UNLESS")) { /* Check for trailing UNLESS flag */ if (!(tok = get_token(&args, script, lineno))) ast_log(LOG_WARNING, "Missing argument for UNLESS clause at line %d of %s\n", lineno, script); else if (process_token(&flag, tok, sizeof(flag), ARG_NUMBER)) ast_log(LOG_WARNING, "Invalid flag number '%s' at line %d of %s\n", tok, lineno, script); if ((tok = get_token(&args, script, lineno))) ast_log(LOG_WARNING, "Extra arguments after UNLESS clause: '%s' at line %d of %s\n", tok, lineno, script); } buf[0] = id; buf[1] = (cmd << 6) | (disp->id & 0x3f); buf[2] = ((line & 0x1f) << 3) | (flag & 0x7); return 3; } static int cleardisplay(char *buf, char *name, int id, char *args, struct adsi_script *istate, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); if (tok) ast_log(LOG_WARNING, "Clearing display requires no arguments ('%s') at line %d of %s\n", tok, lineno, script); buf[0] = id; buf[1] = 0x00; return 2; } static int digitdirect(char *buf, char *name, int id, char *args, struct adsi_script *istate, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); if (tok) ast_log(LOG_WARNING, "Digitdirect requires no arguments ('%s') at line %d of %s\n", tok, lineno, script); buf[0] = id; buf[1] = 0x7; return 2; } static int clearcbone(char *buf, char *name, int id, char *args, struct adsi_script *istate, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); if (tok) ast_log(LOG_WARNING, "CLEARCB1 requires no arguments ('%s') at line %d of %s\n", tok, lineno, script); buf[0] = id; buf[1] = 0; return 2; } static int digitcollect(char *buf, char *name, int id, char *args, struct adsi_script *istate, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); if (tok) ast_log(LOG_WARNING, "Digitcollect requires no arguments ('%s') at line %d of %s\n", tok, lineno, script); buf[0] = id; buf[1] = 0xf; return 2; } static int subscript(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); char subscr[80]; struct adsi_subscript *sub; if (!tok) { ast_log(LOG_WARNING, "Missing subscript to call at line %d of %s\n", lineno, script); return 0; } if (process_token(subscr, tok, sizeof(subscr) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Invalid number of seconds '%s' at line %d of %s\n", tok, lineno, script); return 0; } if (!(sub = getsubbyname(state, subscr, script, lineno))) return 0; buf[0] = 0x9d; buf[1] = sub->id; return 2; } static int onevent(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno) { char *tok = get_token(&args, script, lineno); char subscr[80], sname[80]; int sawin = 0, event, snums[8], scnt = 0, x; struct adsi_subscript *sub; if (!tok) { ast_log(LOG_WARNING, "Missing event for 'ONEVENT' at line %d of %s\n", lineno, script); return 0; } if ((event = geteventbyname(tok)) < 1) { ast_log(LOG_WARNING, "'%s' is not a valid event name, at line %d of %s\n", args, lineno, script); return 0; } tok = get_token(&args, script, lineno); while ((!sawin && !strcasecmp(tok, "IN")) || (sawin && !strcasecmp(tok, "OR"))) { sawin = 1; if (scnt > 7) { ast_log(LOG_WARNING, "No more than 8 states may be specified for inclusion at line %d of %s\n", lineno, script); return 0; } /* Process 'in' things */ tok = get_token(&args, script, lineno); if (process_token(sname, tok, sizeof(sname), ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid state name at line %d of %s\n", tok, lineno, script); return 0; } if ((snums[scnt] = getstatebyname(state, sname, script, lineno, 0) == NULL)) { ast_log(LOG_WARNING, "State '%s' not declared at line %d of %s\n", sname, lineno, script); return 0; } scnt++; if (!(tok = get_token(&args, script, lineno))) break; } if (!tok || strcasecmp(tok, "GOTO")) { if (!tok) tok = ""; if (sawin) ast_log(LOG_WARNING, "Got '%s' while looking for 'GOTO' or 'OR' at line %d of %s\n", tok, lineno, script); else ast_log(LOG_WARNING, "Got '%s' while looking for 'GOTO' or 'IN' at line %d of %s\n", tok, lineno, script); } if (!(tok = get_token(&args, script, lineno))) { ast_log(LOG_WARNING, "Missing subscript to call at line %d of %s\n", lineno, script); return 0; } if (process_token(subscr, tok, sizeof(subscr) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Invalid subscript '%s' at line %d of %s\n", tok, lineno, script); return 0; } if (!(sub = getsubbyname(state, subscr, script, lineno))) return 0; buf[0] = 8; buf[1] = event; buf[2] = sub->id | 0x80; for (x = 0; x < scnt; x++) buf[3 + x] = snums[x]; return 3 + scnt; } struct adsi_key_cmd { char *name; int id; int (*add_args)(char *buf, char *name, int id, char *args, struct adsi_script *state, const char *script, int lineno); }; static const struct adsi_key_cmd kcmds[] = { { "SENDDTMF", 0, send_dtmf }, /* Encoded DTMF would go here */ { "ONHOOK", 0x81 }, { "OFFHOOK", 0x82 }, { "FLASH", 0x83 }, { "WAITDIALTONE", 0x84 }, /* Send line number */ { "BLANK", 0x86 }, { "SENDCHARS", 0x87 }, { "CLEARCHARS", 0x88 }, { "BACKSPACE", 0x89 }, /* Tab column */ { "GOTOLINE", 0x8b, goto_line }, { "GOTOLINEREL", 0x8c, goto_line_rel }, { "PAGEUP", 0x8d }, { "PAGEDOWN", 0x8e }, /* Extended DTMF */ { "DELAY", 0x90, send_delay }, { "DIALPULSEONE", 0x91 }, { "DATAMODE", 0x92 }, { "VOICEMODE", 0x93 }, /* Display call buffer 'n' */ /* Clear call buffer 'n' */ { "CLEARCB1", 0x95, clearcbone }, { "DIGITCOLLECT", 0x96, digitcollect }, { "DIGITDIRECT", 0x96, digitdirect }, { "CLEAR", 0x97 }, { "SHOWDISPLAY", 0x98, showdisplay }, { "CLEARDISPLAY", 0x98, cleardisplay }, { "SHOWKEYS", 0x99, showkeys }, { "SETSTATE", 0x9a, set_state }, { "TIMERSTART", 0x9b, starttimer }, { "TIMERCLEAR", 0x9b, cleartimer }, { "SETFLAG", 0x9c, setflag }, { "CLEARFLAG", 0x9c, clearflag }, { "GOTO", 0x9d, subscript }, { "EVENT22", 0x9e }, { "EVENT23", 0x9f }, { "EXIT", 0xa0 }, }; static const struct adsi_key_cmd opcmds[] = { /* 1 - Branch on event -- handled specially */ { "SHOWKEYS", 2, showkeys }, /* Display Control */ { "SHOWDISPLAY", 3, showdisplay }, { "CLEARDISPLAY", 3, cleardisplay }, { "CLEAR", 5 }, { "SETSTATE", 6, set_state }, { "TIMERSTART", 7, starttimer }, { "TIMERCLEAR", 7, cleartimer }, { "ONEVENT", 8, onevent }, /* 9 - Subroutine label, treated specially */ { "SETFLAG", 10, setflag }, { "CLEARFLAG", 10, clearflag }, { "DELAY", 11, send_delay }, { "EXIT", 12 }, }; static int process_returncode(struct adsi_soft_key *key, char *code, char *args, struct adsi_script *state, const char *script, int lineno) { int x, res; char *unused; for (x = 0; x < ARRAY_LEN(kcmds); x++) { if ((kcmds[x].id > -1) && !strcasecmp(kcmds[x].name, code)) { if (kcmds[x].add_args) { res = kcmds[x].add_args(key->retstr + key->retstrlen, code, kcmds[x].id, args, state, script, lineno); if ((key->retstrlen + res - key->initlen) <= MAX_RET_CODE) key->retstrlen += res; else ast_log(LOG_WARNING, "No space for '%s' code in key '%s' at line %d of %s\n", kcmds[x].name, key->vname, lineno, script); } else { if ((unused = get_token(&args, script, lineno))) ast_log(LOG_WARNING, "'%s' takes no arguments at line %d of %s (token is '%s')\n", kcmds[x].name, lineno, script, unused); if ((key->retstrlen + 1 - key->initlen) <= MAX_RET_CODE) { key->retstr[key->retstrlen] = kcmds[x].id; key->retstrlen++; } else ast_log(LOG_WARNING, "No space for '%s' code in key '%s' at line %d of %s\n", kcmds[x].name, key->vname, lineno, script); } return 0; } } return -1; } static int process_opcode(struct adsi_subscript *sub, char *code, char *args, struct adsi_script *state, const char *script, int lineno) { int x, res, max = sub->id ? MAX_SUB_LEN : MAX_MAIN_LEN; char *unused; for (x = 0; x < ARRAY_LEN(opcmds); x++) { if ((opcmds[x].id > -1) && !strcasecmp(opcmds[x].name, code)) { if (opcmds[x].add_args) { res = opcmds[x].add_args(sub->data + sub->datalen, code, opcmds[x].id, args, state, script, lineno); if ((sub->datalen + res + 1) <= max) sub->datalen += res; else { ast_log(LOG_WARNING, "No space for '%s' code in subscript '%s' at line %d of %s\n", opcmds[x].name, sub->vname, lineno, script); return -1; } } else { if ((unused = get_token(&args, script, lineno))) ast_log(LOG_WARNING, "'%s' takes no arguments at line %d of %s (token is '%s')\n", opcmds[x].name, lineno, script, unused); if ((sub->datalen + 2) <= max) { sub->data[sub->datalen] = opcmds[x].id; sub->datalen++; } else { ast_log(LOG_WARNING, "No space for '%s' code in key '%s' at line %d of %s\n", opcmds[x].name, sub->vname, lineno, script); return -1; } } /* Separate commands with 0xff */ sub->data[sub->datalen] = 0xff; sub->datalen++; sub->inscount++; return 0; } } return -1; } static int adsi_process(struct adsi_script *state, char *buf, const char *script, int lineno) { char *keyword = get_token(&buf, script, lineno); char *args, vname[256], tmp[80], tmp2[80]; int lrci, wi, event; struct adsi_display *disp; struct adsi_subscript *newsub; if (!keyword) return 0; switch(state->state) { case STATE_NORMAL: if (!strcasecmp(keyword, "DESCRIPTION")) { if ((args = get_token(&buf, script, lineno))) { if (process_token(state->desc, args, sizeof(state->desc) - 1, ARG_STRING)) ast_log(LOG_WARNING, "'%s' is not a valid token for DESCRIPTION at line %d of %s\n", args, lineno, script); } else ast_log(LOG_WARNING, "Missing argument for DESCRIPTION at line %d of %s\n", lineno, script); } else if (!strcasecmp(keyword, "VERSION")) { if ((args = get_token(&buf, script, lineno))) { if (process_token(&state->ver, args, sizeof(state->ver) - 1, ARG_NUMBER)) ast_log(LOG_WARNING, "'%s' is not a valid token for VERSION at line %d of %s\n", args, lineno, script); } else ast_log(LOG_WARNING, "Missing argument for VERSION at line %d of %s\n", lineno, script); } else if (!strcasecmp(keyword, "SECURITY")) { if ((args = get_token(&buf, script, lineno))) { if (process_token(state->sec, args, sizeof(state->sec) - 1, ARG_STRING | ARG_NUMBER)) ast_log(LOG_WARNING, "'%s' is not a valid token for SECURITY at line %d of %s\n", args, lineno, script); } else ast_log(LOG_WARNING, "Missing argument for SECURITY at line %d of %s\n", lineno, script); } else if (!strcasecmp(keyword, "FDN")) { if ((args = get_token(&buf, script, lineno))) { if (process_token(state->fdn, args, sizeof(state->fdn) - 1, ARG_STRING | ARG_NUMBER)) ast_log(LOG_WARNING, "'%s' is not a valid token for FDN at line %d of %s\n", args, lineno, script); } else ast_log(LOG_WARNING, "Missing argument for FDN at line %d of %s\n", lineno, script); } else if (!strcasecmp(keyword, "KEY")) { if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "KEY definition missing name at line %d of %s\n", lineno, script); break; } if (process_token(vname, args, sizeof(vname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid token for a KEY name at line %d of %s\n", args, lineno, script); break; } if (!(state->key = getkeybyname(state, vname, script, lineno))) { ast_log(LOG_WARNING, "Out of key space at line %d of %s\n", lineno, script); break; } if (state->key->defined) { ast_log(LOG_WARNING, "Cannot redefine key '%s' at line %d of %s\n", vname, lineno, script); break; } if (!(args = get_token(&buf, script, lineno)) || strcasecmp(args, "IS")) { ast_log(LOG_WARNING, "Expecting 'IS', but got '%s' at line %d of %s\n", args ? args : "", lineno, script); break; } if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "KEY definition missing short name at line %d of %s\n", lineno, script); break; } if (process_token(tmp, args, sizeof(tmp) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid token for a KEY short name at line %d of %s\n", args, lineno, script); break; } if ((args = get_token(&buf, script, lineno))) { if (strcasecmp(args, "OR")) { ast_log(LOG_WARNING, "Expecting 'OR' but got '%s' instead at line %d of %s\n", args, lineno, script); break; } if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "KEY definition missing optional long name at line %d of %s\n", lineno, script); break; } if (process_token(tmp2, args, sizeof(tmp2) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid token for a KEY long name at line %d of %s\n", args, lineno, script); break; } } else { ast_copy_string(tmp2, tmp, sizeof(tmp2)); } if (strlen(tmp2) > 18) { ast_log(LOG_WARNING, "Truncating full name to 18 characters at line %d of %s\n", lineno, script); tmp2[18] = '\0'; } if (strlen(tmp) > 7) { ast_log(LOG_WARNING, "Truncating short name to 7 bytes at line %d of %s\n", lineno, script); tmp[7] = '\0'; } /* Setup initial stuff */ state->key->retstr[0] = 128; /* 1 has the length */ state->key->retstr[2] = state->key->id; /* Put the Full name in */ memcpy(state->key->retstr + 3, tmp2, strlen(tmp2)); /* Update length */ state->key->retstrlen = strlen(tmp2) + 3; /* Put trailing 0xff */ state->key->retstr[state->key->retstrlen++] = 0xff; /* Put the short name */ memcpy(state->key->retstr + state->key->retstrlen, tmp, strlen(tmp)); /* Update length */ state->key->retstrlen += strlen(tmp); /* Put trailing 0xff */ state->key->retstr[state->key->retstrlen++] = 0xff; /* Record initial length */ state->key->initlen = state->key->retstrlen; state->state = STATE_INKEY; } else if (!strcasecmp(keyword, "SUB")) { if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "SUB definition missing name at line %d of %s\n", lineno, script); break; } if (process_token(vname, args, sizeof(vname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid token for a KEY name at line %d of %s\n", args, lineno, script); break; } if (!(state->sub = getsubbyname(state, vname, script, lineno))) { ast_log(LOG_WARNING, "Out of subroutine space at line %d of %s\n", lineno, script); break; } if (state->sub->defined) { ast_log(LOG_WARNING, "Cannot redefine subroutine '%s' at line %d of %s\n", vname, lineno, script); break; } /* Setup sub */ state->sub->data[0] = 130; /* 1 is the length */ state->sub->data[2] = 0x0; /* Clear extensibility bit */ state->sub->datalen = 3; if (state->sub->id) { /* If this isn't the main subroutine, make a subroutine label for it */ state->sub->data[3] = 9; state->sub->data[4] = state->sub->id; /* 5 is length */ state->sub->data[6] = 0xff; state->sub->datalen = 7; } if (!(args = get_token(&buf, script, lineno)) || strcasecmp(args, "IS")) { ast_log(LOG_WARNING, "Expecting 'IS', but got '%s' at line %d of %s\n", args ? args : "", lineno, script); break; } state->state = STATE_INSUB; } else if (!strcasecmp(keyword, "STATE")) { if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "STATE definition missing name at line %d of %s\n", lineno, script); break; } if (process_token(vname, args, sizeof(vname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid token for a STATE name at line %d of %s\n", args, lineno, script); break; } if (getstatebyname(state, vname, script, lineno, 0)) { ast_log(LOG_WARNING, "State '%s' is already defined at line %d of %s\n", vname, lineno, script); break; } getstatebyname(state, vname, script, lineno, 1); } else if (!strcasecmp(keyword, "FLAG")) { if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "FLAG definition missing name at line %d of %s\n", lineno, script); break; } if (process_token(vname, args, sizeof(vname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid token for a FLAG name at line %d of %s\n", args, lineno, script); break; } if (getflagbyname(state, vname, script, lineno, 0)) { ast_log(LOG_WARNING, "Flag '%s' is already defined\n", vname); break; } getflagbyname(state, vname, script, lineno, 1); } else if (!strcasecmp(keyword, "DISPLAY")) { lrci = 0; wi = 0; if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "SUB definition missing name at line %d of %s\n", lineno, script); break; } if (process_token(vname, args, sizeof(vname) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid token for a KEY name at line %d of %s\n", args, lineno, script); break; } if (getdisplaybyname(state, vname, script, lineno, 0)) { ast_log(LOG_WARNING, "State '%s' is already defined\n", vname); break; } if (!(disp = getdisplaybyname(state, vname, script, lineno, 1))) break; if (!(args = get_token(&buf, script, lineno)) || strcasecmp(args, "IS")) { ast_log(LOG_WARNING, "Missing 'IS' at line %d of %s\n", lineno, script); break; } if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "Missing Column 1 text at line %d of %s\n", lineno, script); break; } if (process_token(tmp, args, sizeof(tmp) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "Token '%s' is not valid column 1 text at line %d of %s\n", args, lineno, script); break; } if (strlen(tmp) > 20) { ast_log(LOG_WARNING, "Truncating column one to 20 characters at line %d of %s\n", lineno, script); tmp[20] = '\0'; } memcpy(disp->data + 5, tmp, strlen(tmp)); disp->datalen = strlen(tmp) + 5; disp->data[disp->datalen++] = 0xff; args = get_token(&buf, script, lineno); if (args && !process_token(tmp, args, sizeof(tmp) - 1, ARG_STRING)) { /* Got a column two */ if (strlen(tmp) > 20) { ast_log(LOG_WARNING, "Truncating column two to 20 characters at line %d of %s\n", lineno, script); tmp[20] = '\0'; } memcpy(disp->data + disp->datalen, tmp, strlen(tmp)); disp->datalen += strlen(tmp); args = get_token(&buf, script, lineno); } while (args) { if (!strcasecmp(args, "JUSTIFY")) { args = get_token(&buf, script, lineno); if (!args) { ast_log(LOG_WARNING, "Qualifier 'JUSTIFY' requires an argument at line %d of %s\n", lineno, script); break; } lrci = getjustifybyname(args); if (lrci < 0) { ast_log(LOG_WARNING, "'%s' is not a valid justification at line %d of %s\n", args, lineno, script); break; } } else if (!strcasecmp(args, "WRAP")) { wi = 0x80; } else { ast_log(LOG_WARNING, "'%s' is not a known qualifier at line %d of %s\n", args, lineno, script); break; } args = get_token(&buf, script, lineno); } if (args) { /* Something bad happened */ break; } disp->data[0] = 129; disp->data[1] = disp->datalen - 2; disp->data[2] = ((lrci & 0x3) << 6) | disp->id; disp->data[3] = wi; disp->data[4] = 0xff; } else { ast_log(LOG_WARNING, "Invalid or Unknown keyword '%s' in PROGRAM\n", keyword); } break; case STATE_INKEY: if (process_returncode(state->key, keyword, buf, state, script, lineno)) { if (!strcasecmp(keyword, "ENDKEY")) { /* Return to normal operation and increment current key */ state->state = STATE_NORMAL; state->key->defined = 1; state->key->retstr[1] = state->key->retstrlen - 2; state->key = NULL; } else { ast_log(LOG_WARNING, "Invalid or Unknown keyword '%s' in SOFTKEY definition at line %d of %s\n", keyword, lineno, script); } } break; case STATE_INIF: if (process_opcode(state->sub, keyword, buf, state, script, lineno)) { if (!strcasecmp(keyword, "ENDIF")) { /* Return to normal SUB operation and increment current key */ state->state = STATE_INSUB; state->sub->defined = 1; /* Store the proper number of instructions */ state->sub->ifdata[2] = state->sub->ifinscount; } else if (!strcasecmp(keyword, "GOTO")) { if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "GOTO clause missing Subscript name at line %d of %s\n", lineno, script); break; } if (process_token(tmp, args, sizeof(tmp) - 1, ARG_STRING)) { ast_log(LOG_WARNING, "'%s' is not a valid subscript name token at line %d of %s\n", args, lineno, script); break; } if (!(newsub = getsubbyname(state, tmp, script, lineno))) break; /* Somehow you use GOTO to go to another place */ state->sub->data[state->sub->datalen++] = 0x8; state->sub->data[state->sub->datalen++] = state->sub->ifdata[1]; state->sub->data[state->sub->datalen++] = newsub->id; /* Terminate */ state->sub->data[state->sub->datalen++] = 0xff; /* Increment counters */ state->sub->inscount++; state->sub->ifinscount++; } else { ast_log(LOG_WARNING, "Invalid or Unknown keyword '%s' in IF clause at line %d of %s\n", keyword, lineno, script); } } else state->sub->ifinscount++; break; case STATE_INSUB: if (process_opcode(state->sub, keyword, buf, state, script, lineno)) { if (!strcasecmp(keyword, "ENDSUB")) { /* Return to normal operation and increment current key */ state->state = STATE_NORMAL; state->sub->defined = 1; /* Store the proper length */ state->sub->data[1] = state->sub->datalen - 2; if (state->sub->id) { /* if this isn't main, store number of instructions, too */ state->sub->data[5] = state->sub->inscount; } state->sub = NULL; } else if (!strcasecmp(keyword, "IFEVENT")) { if (!(args = get_token(&buf, script, lineno))) { ast_log(LOG_WARNING, "IFEVENT clause missing Event name at line %d of %s\n", lineno, script); break; } if ((event = geteventbyname(args)) < 1) { ast_log(LOG_WARNING, "'%s' is not a valid event\n", args); break; } if (!(args = get_token(&buf, script, lineno)) || strcasecmp(args, "THEN")) { ast_log(LOG_WARNING, "IFEVENT clause missing 'THEN' at line %d of %s\n", lineno, script); break; } state->sub->ifinscount = 0; state->sub->ifdata = state->sub->data + state->sub->datalen; /* Reserve header and insert op codes */ state->sub->ifdata[0] = 0x1; state->sub->ifdata[1] = event; /* 2 is for the number of instructions */ state->sub->ifdata[3] = 0xff; state->sub->datalen += 4; /* Update Subscript instruction count */ state->sub->inscount++; state->state = STATE_INIF; } else { ast_log(LOG_WARNING, "Invalid or Unknown keyword '%s' in SUB definition at line %d of %s\n", keyword, lineno, script); } } break; default: ast_log(LOG_WARNING, "Can't process keyword '%s' in weird state %d\n", keyword, state->state); } return 0; } static struct adsi_script *compile_script(const char *script) { FILE *f; char fn[256], buf[256], *c; int lineno = 0, x, err; struct adsi_script *scr; if (script[0] == '/') ast_copy_string(fn, script, sizeof(fn)); else snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, script); if (!(f = fopen(fn, "r"))) { ast_log(LOG_WARNING, "Can't open file '%s'\n", fn); return NULL; } if (!(scr = ast_calloc(1, sizeof(*scr)))) { fclose(f); return NULL; } /* Create "main" as first subroutine */ getsubbyname(scr, "main", NULL, 0); while (!feof(f)) { if (!fgets(buf, sizeof(buf), f)) { continue; } if (!feof(f)) { lineno++; /* Trim off trailing return */ buf[strlen(buf) - 1] = '\0'; /* Strip comments */ if ((c = strchr(buf, ';'))) *c = '\0'; if (!ast_strlen_zero(buf)) adsi_process(scr, buf, script, lineno); } } fclose(f); /* Make sure we're in the main routine again */ switch(scr->state) { case STATE_NORMAL: break; case STATE_INSUB: ast_log(LOG_WARNING, "Missing ENDSUB at end of file %s\n", script); ast_free(scr); return NULL; case STATE_INKEY: ast_log(LOG_WARNING, "Missing ENDKEY at end of file %s\n", script); ast_free(scr); return NULL; } err = 0; /* Resolve all keys and record their lengths */ for (x = 0; x < scr->numkeys; x++) { if (!scr->keys[x].defined) { ast_log(LOG_WARNING, "Key '%s' referenced but never defined in file %s\n", scr->keys[x].vname, fn); err++; } } /* Resolve all subs */ for (x = 0; x < scr->numsubs; x++) { if (!scr->subs[x].defined) { ast_log(LOG_WARNING, "Subscript '%s' referenced but never defined in file %s\n", scr->subs[x].vname, fn); err++; } if (x == (scr->numsubs - 1)) { /* Clear out extension bit on last message */ scr->subs[x].data[2] = 0x80; } } if (err) { ast_free(scr); return NULL; } return scr; } #ifdef DUMP_MESSAGES static void dump_message(char *type, char *vname, unsigned char *buf, int buflen) { int x; printf("%s %s: [ ", type, vname); for (x = 0; x < buflen; x++) printf("%02x ", buf[x]); printf("]\n"); } #endif static int adsi_prog(struct ast_channel *chan, const char *script) { struct adsi_script *scr; int x, bytes; unsigned char buf[1024]; if (!(scr = compile_script(script))) return -1; /* Start an empty ADSI Session */ if (ast_adsi_load_session(chan, NULL, 0, 1) < 1) return -1; /* Now begin the download attempt */ if (ast_adsi_begin_download(chan, scr->desc, scr->fdn, scr->sec, scr->ver)) { /* User rejected us for some reason */ ast_verb(3, "User rejected download attempt\n"); ast_log(LOG_NOTICE, "User rejected download on channel %s\n", ast_channel_name(chan)); ast_free(scr); return -1; } bytes = 0; /* Start with key definitions */ for (x = 0; x < scr->numkeys; x++) { if (bytes + scr->keys[x].retstrlen > 253) { /* Send what we've collected so far */ if (ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD)) { ast_log(LOG_WARNING, "Unable to send chunk ending at %d\n", x); return -1; } bytes =0; } memcpy(buf + bytes, scr->keys[x].retstr, scr->keys[x].retstrlen); bytes += scr->keys[x].retstrlen; #ifdef DUMP_MESSAGES dump_message("Key", scr->keys[x].vname, scr->keys[x].retstr, scr->keys[x].retstrlen); #endif } if (bytes) { if (ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD)) { ast_log(LOG_WARNING, "Unable to send chunk ending at %d\n", x); return -1; } } bytes = 0; /* Continue with the display messages */ for (x = 0; x < scr->numdisplays; x++) { if (bytes + scr->displays[x].datalen > 253) { /* Send what we've collected so far */ if (ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD)) { ast_log(LOG_WARNING, "Unable to send chunk ending at %d\n", x); return -1; } bytes =0; } memcpy(buf + bytes, scr->displays[x].data, scr->displays[x].datalen); bytes += scr->displays[x].datalen; #ifdef DUMP_MESSAGES dump_message("Display", scr->displays[x].vname, scr->displays[x].data, scr->displays[x].datalen); #endif } if (bytes) { if (ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD)) { ast_log(LOG_WARNING, "Unable to send chunk ending at %d\n", x); return -1; } } bytes = 0; /* Send subroutines */ for (x = 0; x < scr->numsubs; x++) { if (bytes + scr->subs[x].datalen > 253) { /* Send what we've collected so far */ if (ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD)) { ast_log(LOG_WARNING, "Unable to send chunk ending at %d\n", x); return -1; } bytes =0; } memcpy(buf + bytes, scr->subs[x].data, scr->subs[x].datalen); bytes += scr->subs[x].datalen; #ifdef DUMP_MESSAGES dump_message("Sub", scr->subs[x].vname, scr->subs[x].data, scr->subs[x].datalen); #endif } if (bytes) { if (ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD)) { ast_log(LOG_WARNING, "Unable to send chunk ending at %d\n", x); return -1; } } bytes = 0; bytes += ast_adsi_display(buf, ADSI_INFO_PAGE, 1, ADSI_JUST_LEFT, 0, "Download complete.", ""); bytes += ast_adsi_set_line(buf, ADSI_INFO_PAGE, 1); if (ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY) < 0) return -1; if (ast_adsi_end_download(chan)) { /* Download failed for some reason */ ast_verb(3, "Download attempt failed\n"); ast_log(LOG_NOTICE, "Download failed on %s\n", ast_channel_name(chan)); ast_free(scr); return -1; } ast_free(scr); ast_adsi_unload_session(chan); return 0; } static int adsi_exec(struct ast_channel *chan, const char *data) { int res = 0; if (ast_strlen_zero(data)) data = "asterisk.adsi"; if (!ast_adsi_available(chan)) { ast_verb(3, "ADSI Unavailable on CPE. Not bothering to try.\n"); } else { ast_verb(3, "ADSI Available on CPE. Attempting Upload.\n"); res = adsi_prog(chan, data); } return res; } static int unload_module(void) { return ast_unregister_application(app); } static int load_module(void) { if (ast_register_application_xml(app, adsi_exec)) return AST_MODULE_LOAD_FAILURE; return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk ADSI Programming Application", .load = load_module, .unload = unload_module, .nonoptreq = "res_adsi", ); asterisk-11.7.0/apps/app_speech_utils.c0000644000175000007640000006765511744273702020035 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2006, Digium, Inc. * * Joshua Colp * * 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 Speech Recognition Utility Applications * * \author Joshua Colp * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 362817 $"); #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/app.h" #include "asterisk/speech.h" /*** DOCUMENTATION Create a Speech Structure. This application creates information to be used by all the other applications. It must be called before doing any speech recognition activities such as activating a grammar. It takes the engine name to use as the argument, if not specified the default engine will be used. Sets the ERROR channel variable to 1 if the engine cannot be used. Activate a grammar. This activates the specified grammar to be recognized by the engine. A grammar tells the speech recognition engine what to recognize, and how to portray it back to you in the dialplan. The grammar name is the only argument to this application. Hangs up the channel on failure. If this is not desired, use TryExec. Start recognizing voice in the audio stream. Tell the speech recognition engine that it should start trying to get results from audio being fed to it. Hangs up the channel on failure. If this is not desired, use TryExec. Play a sound file and wait for speech to be recognized. Timeout integer in seconds. Note the timeout will only start once the sound file has stopped playing. This application plays a sound file and waits for the person to speak. Once they start speaking playback of the file stops, and silence is heard. Once they stop talking the processing sound is played to indicate the speech recognition engine is working. Once results are available the application returns and results (score and text) are available using dialplan functions. The first text and score are ${SPEECH_TEXT(0)} AND ${SPEECH_SCORE(0)} while the second are ${SPEECH_TEXT(1)} and ${SPEECH_SCORE(1)}. The first argument is the sound file and the second is the timeout integer in seconds. Hangs up the channel on failure. If this is not desired, use TryExec. Deactivate a grammar. The grammar name to deactivate This deactivates the specified grammar so that it is no longer recognized. Hangs up the channel on failure. If this is not desired, use TryExec. Change background processing sound. This changes the processing sound that SpeechBackground plays back when the speech recognition engine is processing and working to get results. Hangs up the channel on failure. If this is not desired, use TryExec. End speech recognition. This destroys the information used by all the other speech recognition applications. If you call this application but end up wanting to recognize more speech, you must call SpeechCreate() again before calling any other application. Hangs up the channel on failure. If this is not desired, use TryExec. Load a grammar. Load a grammar only on the channel, not globally. Hangs up the channel on failure. If this is not desired, use TryExec. Unload a grammar. Unload a grammar. Hangs up the channel on failure. If this is not desired, use TryExec. Gets the confidence score of a result. Gets the confidence score of a result. Gets the recognized text of a result. Gets the recognized text of a result. Gets the matched grammar of a result if available. Gets the matched grammar of a result if available. Change a speech engine specific attribute. Changes a speech engine specific attribute. Sets the type of results that will be returned. Sets the type of results that will be returned. Valid options are normal or nbest. Gets information about speech recognition results. Returns 1 upon speech object existing, or 0 if not Returns 1 if spoker spoke, or 0 if not Returns number of results that were recognized. Gets information about speech recognition results. ***/ /*! \brief Helper function used by datastores to destroy the speech structure upon hangup */ static void destroy_callback(void *data) { struct ast_speech *speech = (struct ast_speech*)data; if (speech == NULL) { return; } /* Deallocate now */ ast_speech_destroy(speech); return; } /*! \brief Static structure for datastore information */ static const struct ast_datastore_info speech_datastore = { .type = "speech", .destroy = destroy_callback }; /*! \brief Helper function used to find the speech structure attached to a channel */ static struct ast_speech *find_speech(struct ast_channel *chan) { struct ast_speech *speech = NULL; struct ast_datastore *datastore = NULL; datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL); if (datastore == NULL) { return NULL; } speech = datastore->data; return speech; } /* Helper function to find a specific speech recognition result by number and nbest alternative */ static struct ast_speech_result *find_result(struct ast_speech_result *results, char *result_num) { struct ast_speech_result *result = results; char *tmp = NULL; int nbest_num = 0, wanted_num = 0, i = 0; if (!result) { return NULL; } if ((tmp = strchr(result_num, '/'))) { *tmp++ = '\0'; nbest_num = atoi(result_num); wanted_num = atoi(tmp); } else { wanted_num = atoi(result_num); } do { if (result->nbest_num != nbest_num) continue; if (i == wanted_num) break; i++; } while ((result = AST_LIST_NEXT(result, list))); return result; } /*! \brief SPEECH_SCORE() Dialplan Function */ static int speech_score(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct ast_speech_result *result = NULL; struct ast_speech *speech = find_speech(chan); char tmp[128] = ""; if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) { return -1; } snprintf(tmp, sizeof(tmp), "%d", result->score); ast_copy_string(buf, tmp, len); return 0; } static struct ast_custom_function speech_score_function = { .name = "SPEECH_SCORE", .read = speech_score, .write = NULL, }; /*! \brief SPEECH_TEXT() Dialplan Function */ static int speech_text(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct ast_speech_result *result = NULL; struct ast_speech *speech = find_speech(chan); if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) { return -1; } if (result->text != NULL) { ast_copy_string(buf, result->text, len); } else { buf[0] = '\0'; } return 0; } static struct ast_custom_function speech_text_function = { .name = "SPEECH_TEXT", .read = speech_text, .write = NULL, }; /*! \brief SPEECH_GRAMMAR() Dialplan Function */ static int speech_grammar(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct ast_speech_result *result = NULL; struct ast_speech *speech = find_speech(chan); if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) { return -1; } if (result->grammar != NULL) { ast_copy_string(buf, result->grammar, len); } else { buf[0] = '\0'; } return 0; } static struct ast_custom_function speech_grammar_function = { .name = "SPEECH_GRAMMAR", .read = speech_grammar, .write = NULL, }; /*! \brief SPEECH_ENGINE() Dialplan Function */ static int speech_engine_write(struct ast_channel *chan, const char *cmd, char *data, const char *value) { struct ast_speech *speech = find_speech(chan); if (data == NULL || speech == NULL) { return -1; } ast_speech_change(speech, data, value); return 0; } static struct ast_custom_function speech_engine_function = { .name = "SPEECH_ENGINE", .read = NULL, .write = speech_engine_write, }; /*! \brief SPEECH_RESULTS_TYPE() Dialplan Function */ static int speech_results_type_write(struct ast_channel *chan, const char *cmd, char *data, const char *value) { struct ast_speech *speech = find_speech(chan); if (data == NULL || speech == NULL) return -1; if (!strcasecmp(value, "normal")) ast_speech_change_results_type(speech, AST_SPEECH_RESULTS_TYPE_NORMAL); else if (!strcasecmp(value, "nbest")) ast_speech_change_results_type(speech, AST_SPEECH_RESULTS_TYPE_NBEST); return 0; } static struct ast_custom_function speech_results_type_function = { .name = "SPEECH_RESULTS_TYPE", .read = NULL, .write = speech_results_type_write, }; /*! \brief SPEECH() Dialplan Function */ static int speech_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { int results = 0; struct ast_speech_result *result = NULL; struct ast_speech *speech = find_speech(chan); char tmp[128] = ""; /* Now go for the various options */ if (!strcasecmp(data, "status")) { if (speech != NULL) ast_copy_string(buf, "1", len); else ast_copy_string(buf, "0", len); return 0; } /* Make sure we have a speech structure for everything else */ if (speech == NULL) { return -1; } /* Check to see if they are checking for silence */ if (!strcasecmp(data, "spoke")) { if (ast_test_flag(speech, AST_SPEECH_SPOKE)) ast_copy_string(buf, "1", len); else ast_copy_string(buf, "0", len); } else if (!strcasecmp(data, "results")) { /* Count number of results */ for (result = speech->results; result; result = AST_LIST_NEXT(result, list)) results++; snprintf(tmp, sizeof(tmp), "%d", results); ast_copy_string(buf, tmp, len); } else { buf[0] = '\0'; } return 0; } static struct ast_custom_function speech_function = { .name = "SPEECH", .read = speech_read, .write = NULL, }; /*! \brief SpeechCreate() Dialplan Application */ static int speech_create(struct ast_channel *chan, const char *data) { struct ast_speech *speech = NULL; struct ast_datastore *datastore = NULL; /* Request a speech object */ speech = ast_speech_new(data, ast_channel_nativeformats(chan)); if (speech == NULL) { /* Not available */ pbx_builtin_setvar_helper(chan, "ERROR", "1"); return 0; } datastore = ast_datastore_alloc(&speech_datastore, NULL); if (datastore == NULL) { ast_speech_destroy(speech); pbx_builtin_setvar_helper(chan, "ERROR", "1"); return 0; } pbx_builtin_setvar_helper(chan, "ERROR", NULL); datastore->data = speech; ast_channel_datastore_add(chan, datastore); return 0; } /*! \brief SpeechLoadGrammar(Grammar Name,Path) Dialplan Application */ static int speech_load(struct ast_channel *chan, const char *vdata) { int res = 0; struct ast_speech *speech = find_speech(chan); char *data; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(grammar); AST_APP_ARG(path); ); data = ast_strdupa(vdata); AST_STANDARD_APP_ARGS(args, data); if (speech == NULL) return -1; if (args.argc != 2) return -1; /* Load the grammar locally on the object */ res = ast_speech_grammar_load(speech, args.grammar, args.path); return res; } /*! \brief SpeechUnloadGrammar(Grammar Name) Dialplan Application */ static int speech_unload(struct ast_channel *chan, const char *data) { int res = 0; struct ast_speech *speech = find_speech(chan); if (speech == NULL) return -1; /* Unload the grammar */ res = ast_speech_grammar_unload(speech, data); return res; } /*! \brief SpeechDeactivateGrammar(Grammar Name) Dialplan Application */ static int speech_deactivate(struct ast_channel *chan, const char *data) { int res = 0; struct ast_speech *speech = find_speech(chan); if (speech == NULL) return -1; /* Deactivate the grammar on the speech object */ res = ast_speech_grammar_deactivate(speech, data); return res; } /*! \brief SpeechActivateGrammar(Grammar Name) Dialplan Application */ static int speech_activate(struct ast_channel *chan, const char *data) { int res = 0; struct ast_speech *speech = find_speech(chan); if (speech == NULL) return -1; /* Activate the grammar on the speech object */ res = ast_speech_grammar_activate(speech, data); return res; } /*! \brief SpeechStart() Dialplan Application */ static int speech_start(struct ast_channel *chan, const char *data) { int res = 0; struct ast_speech *speech = find_speech(chan); if (speech == NULL) return -1; ast_speech_start(speech); return res; } /*! \brief SpeechProcessingSound(Sound File) Dialplan Application */ static int speech_processing_sound(struct ast_channel *chan, const char *data) { int res = 0; struct ast_speech *speech = find_speech(chan); if (speech == NULL) return -1; if (speech->processing_sound != NULL) { ast_free(speech->processing_sound); speech->processing_sound = NULL; } speech->processing_sound = ast_strdup(data); return res; } /*! \brief Helper function used by speech_background to playback a soundfile */ static int speech_streamfile(struct ast_channel *chan, const char *filename, const char *preflang) { struct ast_filestream *fs = NULL; if (!(fs = ast_openstream(chan, filename, preflang))) return -1; if (ast_applystream(chan, fs)) return -1; ast_playstream(fs); return 0; } enum { SB_OPT_NOANSWER = (1 << 0), }; AST_APP_OPTIONS(speech_background_options, BEGIN_OPTIONS AST_APP_OPTION('n', SB_OPT_NOANSWER), END_OPTIONS ); /*! \brief SpeechBackground(Sound File,Timeout) Dialplan Application */ static int speech_background(struct ast_channel *chan, const char *data) { unsigned int timeout = 0; int res = 0, done = 0, started = 0, quieted = 0, max_dtmf_len = 0; struct ast_speech *speech = find_speech(chan); struct ast_frame *f = NULL; struct ast_format oldreadformat; char dtmf[AST_MAX_EXTENSION] = ""; struct timeval start = { 0, 0 }, current; struct ast_datastore *datastore = NULL; char *parse, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#'; const char *tmp2 = NULL; struct ast_flags options = { 0 }; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(soundfile); AST_APP_ARG(timeout); AST_APP_ARG(options); ); parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); ast_format_clear(&oldreadformat); if (speech == NULL) return -1; if (!ast_strlen_zero(args.options)) { char *options_buf = ast_strdupa(args.options); ast_app_parse_options(speech_background_options, &options, NULL, options_buf); } /* If channel is not already answered, then answer it */ if (ast_channel_state(chan) != AST_STATE_UP && !ast_test_flag(&options, SB_OPT_NOANSWER) && ast_answer(chan)) { return -1; } /* Record old read format */ ast_format_copy(&oldreadformat, ast_channel_readformat(chan)); /* Change read format to be signed linear */ if (ast_set_read_format(chan, &speech->format)) return -1; if (!ast_strlen_zero(args.soundfile)) { /* Yay sound file */ filename_tmp = ast_strdupa(args.soundfile); if (!ast_strlen_zero(args.timeout)) { if ((timeout = atof(args.timeout) * 1000.0) == 0) timeout = -1; } else timeout = 0; } /* See if the maximum DTMF length variable is set... we use a variable in case they want to carry it through their entire dialplan */ ast_channel_lock(chan); if ((tmp2 = pbx_builtin_getvar_helper(chan, "SPEECH_DTMF_MAXLEN")) && !ast_strlen_zero(tmp2)) { max_dtmf_len = atoi(tmp2); } /* See if a terminator is specified */ if ((tmp2 = pbx_builtin_getvar_helper(chan, "SPEECH_DTMF_TERMINATOR"))) { if (ast_strlen_zero(tmp2)) dtmf_terminator = '\0'; else dtmf_terminator = tmp2[0]; } ast_channel_unlock(chan); /* Before we go into waiting for stuff... make sure the structure is ready, if not - start it again */ if (speech->state == AST_SPEECH_STATE_NOT_READY || speech->state == AST_SPEECH_STATE_DONE) { ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY); ast_speech_start(speech); } /* Ensure no streams are currently running */ ast_stopstream(chan); /* Okay it's streaming so go into a loop grabbing frames! */ while (done == 0) { /* If the filename is null and stream is not running, start up a new sound file */ if (!quieted && (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) && (filename = strsep(&filename_tmp, "&"))) { /* Discard old stream information */ ast_stopstream(chan); /* Start new stream */ speech_streamfile(chan, filename, ast_channel_language(chan)); } /* Run scheduled stuff */ ast_sched_runq(ast_channel_sched(chan)); /* Yay scheduling */ res = ast_sched_wait(ast_channel_sched(chan)); if (res < 0) res = 1000; /* If there is a frame waiting, get it - if not - oh well */ if (ast_waitfor(chan, res) > 0) { f = ast_read(chan); if (f == NULL) { /* The channel has hung up most likely */ done = 3; break; } } /* Do timeout check (shared between audio/dtmf) */ if ((!quieted || strlen(dtmf)) && started == 1) { current = ast_tvnow(); if ((ast_tvdiff_ms(current, start)) >= timeout) { done = 1; if (f) ast_frfree(f); break; } } /* Do checks on speech structure to see if it's changed */ ast_mutex_lock(&speech->lock); if (ast_test_flag(speech, AST_SPEECH_QUIET)) { if (ast_channel_stream(chan)) ast_stopstream(chan); ast_clear_flag(speech, AST_SPEECH_QUIET); quieted = 1; } /* Check state so we can see what to do */ switch (speech->state) { case AST_SPEECH_STATE_READY: /* If audio playback has stopped do a check for timeout purposes */ if (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) ast_stopstream(chan); if (!quieted && ast_channel_stream(chan) == NULL && timeout && started == 0 && !filename_tmp) { if (timeout == -1) { done = 1; if (f) ast_frfree(f); break; } start = ast_tvnow(); started = 1; } /* Write audio frame out to speech engine if no DTMF has been received */ if (!strlen(dtmf) && f != NULL && f->frametype == AST_FRAME_VOICE) { ast_speech_write(speech, f->data.ptr, f->datalen); } break; case AST_SPEECH_STATE_WAIT: /* Cue up waiting sound if not already playing */ if (!strlen(dtmf)) { if (ast_channel_stream(chan) == NULL) { if (speech->processing_sound != NULL) { if (strlen(speech->processing_sound) > 0 && strcasecmp(speech->processing_sound, "none")) { speech_streamfile(chan, speech->processing_sound, ast_channel_language(chan)); } } } else if (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) { ast_stopstream(chan); if (speech->processing_sound != NULL) { if (strlen(speech->processing_sound) > 0 && strcasecmp(speech->processing_sound, "none")) { speech_streamfile(chan, speech->processing_sound, ast_channel_language(chan)); } } } } break; case AST_SPEECH_STATE_DONE: /* Now that we are done... let's switch back to not ready state */ ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY); if (!strlen(dtmf)) { /* Copy to speech structure the results, if available */ speech->results = ast_speech_results_get(speech); /* Break out of our background too */ done = 1; /* Stop audio playback */ if (ast_channel_stream(chan) != NULL) { ast_stopstream(chan); } } break; default: break; } ast_mutex_unlock(&speech->lock); /* Deal with other frame types */ if (f != NULL) { /* Free the frame we received */ switch (f->frametype) { case AST_FRAME_DTMF: if (dtmf_terminator != '\0' && f->subclass.integer == dtmf_terminator) { done = 1; } else { quieted = 1; if (ast_channel_stream(chan) != NULL) { ast_stopstream(chan); } if (!started) { /* Change timeout to be 5 seconds for DTMF input */ timeout = (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) ? ast_channel_pbx(chan)->dtimeoutms : 5000; started = 1; } start = ast_tvnow(); snprintf(tmp, sizeof(tmp), "%c", f->subclass.integer); strncat(dtmf, tmp, sizeof(dtmf) - strlen(dtmf) - 1); /* If the maximum length of the DTMF has been reached, stop now */ if (max_dtmf_len && strlen(dtmf) == max_dtmf_len) done = 1; } break; case AST_FRAME_CONTROL: switch (f->subclass.integer) { case AST_CONTROL_HANGUP: /* Since they hung up we should destroy the speech structure */ done = 3; default: break; } default: break; } ast_frfree(f); f = NULL; } } if (!ast_strlen_zero(dtmf)) { /* We sort of make a results entry */ speech->results = ast_calloc(1, sizeof(*speech->results)); if (speech->results != NULL) { ast_speech_dtmf(speech, dtmf); speech->results->score = 1000; speech->results->text = ast_strdup(dtmf); speech->results->grammar = ast_strdup("dtmf"); } ast_speech_change_state(speech, AST_SPEECH_STATE_NOT_READY); } /* See if it was because they hung up */ if (done == 3) { /* Destroy speech structure */ ast_speech_destroy(speech); datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL); if (datastore != NULL) ast_channel_datastore_remove(chan, datastore); } else { /* Channel is okay so restore read format */ ast_set_read_format(chan, &oldreadformat); } return 0; } /*! \brief SpeechDestroy() Dialplan Application */ static int speech_destroy(struct ast_channel *chan, const char *data) { int res = 0; struct ast_speech *speech = find_speech(chan); struct ast_datastore *datastore = NULL; if (speech == NULL) return -1; /* Destroy speech structure */ ast_speech_destroy(speech); datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL); if (datastore != NULL) { ast_channel_datastore_remove(chan, datastore); } return res; } static int unload_module(void) { int res = 0; res = ast_unregister_application("SpeechCreate"); res |= ast_unregister_application("SpeechLoadGrammar"); res |= ast_unregister_application("SpeechUnloadGrammar"); res |= ast_unregister_application("SpeechActivateGrammar"); res |= ast_unregister_application("SpeechDeactivateGrammar"); res |= ast_unregister_application("SpeechStart"); res |= ast_unregister_application("SpeechBackground"); res |= ast_unregister_application("SpeechDestroy"); res |= ast_unregister_application("SpeechProcessingSound"); res |= ast_custom_function_unregister(&speech_function); res |= ast_custom_function_unregister(&speech_score_function); res |= ast_custom_function_unregister(&speech_text_function); res |= ast_custom_function_unregister(&speech_grammar_function); res |= ast_custom_function_unregister(&speech_engine_function); res |= ast_custom_function_unregister(&speech_results_type_function); return res; } static int load_module(void) { int res = 0; res = ast_register_application_xml("SpeechCreate", speech_create); res |= ast_register_application_xml("SpeechLoadGrammar", speech_load); res |= ast_register_application_xml("SpeechUnloadGrammar", speech_unload); res |= ast_register_application_xml("SpeechActivateGrammar", speech_activate); res |= ast_register_application_xml("SpeechDeactivateGrammar", speech_deactivate); res |= ast_register_application_xml("SpeechStart", speech_start); res |= ast_register_application_xml("SpeechBackground", speech_background); res |= ast_register_application_xml("SpeechDestroy", speech_destroy); res |= ast_register_application_xml("SpeechProcessingSound", speech_processing_sound); res |= ast_custom_function_register(&speech_function); res |= ast_custom_function_register(&speech_score_function); res |= ast_custom_function_register(&speech_text_function); res |= ast_custom_function_register(&speech_grammar_function); res |= ast_custom_function_register(&speech_engine_function); res |= ast_custom_function_register(&speech_results_type_function); return res; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Dialplan Speech Applications", .load = load_module, .unload = unload_module, .nonoptreq = "res_speech", ); asterisk-11.7.0/apps/confbridge/0000755000175000007640000000000012254071122016406 5ustar sharkyjerrywebasterisk-11.7.0/apps/confbridge/conf_state_multi.c0000644000175000007640000000414312034617656022131 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling for the MULTI state * * \author\verbatim Terry Wilson \endverbatim * * \ingroup applications */ /*** MODULEINFO core ***/ #include "include/confbridge.h" #include "include/conf_state.h" static void join_unmarked(struct conference_bridge_user *cbu); static void join_marked(struct conference_bridge_user *cbu); static void leave_unmarked(struct conference_bridge_user *cbu); void transition_to_multi(struct conference_bridge_user *cbu); struct conference_state STATE_MULTI = { .name = "MULTI", .join_unmarked = join_unmarked, .join_waitmarked = conf_default_join_waitmarked, .join_marked = join_marked, .leave_unmarked = leave_unmarked, .leave_waitmarked = conf_default_leave_waitmarked, .entry = transition_to_multi, }; struct conference_state *CONF_STATE_MULTI = &STATE_MULTI; static void join_unmarked(struct conference_bridge_user *cbu) { conf_add_user_active(cbu->conference_bridge, cbu); } static void join_marked(struct conference_bridge_user *cbu) { conf_add_user_marked(cbu->conference_bridge, cbu); conf_change_state(cbu, CONF_STATE_MULTI_MARKED); } static void leave_unmarked(struct conference_bridge_user *cbu) { conf_remove_user_active(cbu->conference_bridge, cbu); if (cbu->conference_bridge->activeusers == 1) { conf_change_state(cbu, CONF_STATE_SINGLE); } } void transition_to_multi(struct conference_bridge_user *cbu) { return; } asterisk-11.7.0/apps/confbridge/conf_config_parser.c0000644000175000007640000015235712225063626022425 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2011, Digium, Inc. * * David Vossel * * 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 ConfBridge config parser * * \author David Vossel */ /*** MODULEINFO core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 400741 $") #include "asterisk/logger.h" #include "asterisk/config.h" #include "asterisk/config_options.h" #include "include/confbridge.h" #include "asterisk/astobj2.h" #include "asterisk/cli.h" #include "asterisk/bridging_features.h" #include "asterisk/stringfields.h" #include "asterisk/pbx.h" struct confbridge_cfg { struct ao2_container *bridge_profiles; struct ao2_container *user_profiles; struct ao2_container *menus; }; static int verify_default_profiles(void); static void *bridge_profile_alloc(const char *category); static void *bridge_profile_find(struct ao2_container *container, const char *category); static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void); static void bridge_profile_destructor(void *obj) { struct bridge_profile *b_profile = obj; ao2_cleanup(b_profile->sounds); } static void *bridge_profile_alloc(const char *category) { struct bridge_profile *b_profile; if (!(b_profile = ao2_alloc(sizeof(*b_profile), bridge_profile_destructor))) { return NULL; } if (!(b_profile->sounds = bridge_profile_sounds_alloc())) { ao2_ref(b_profile, -1); return NULL; } ast_copy_string(b_profile->name, category, sizeof(b_profile->name)); return b_profile; } static void *bridge_profile_find(struct ao2_container *container, const char *category) { return ao2_find(container, category, OBJ_KEY); } static struct aco_type bridge_type = { .type = ACO_ITEM, .category_match = ACO_BLACKLIST, .category = "^general$", .matchfield = "type", .matchvalue = "bridge", .item_alloc = bridge_profile_alloc, .item_find = bridge_profile_find, .item_offset = offsetof(struct confbridge_cfg, bridge_profiles), }; static void *user_profile_alloc(const char *category); static void *user_profile_find(struct ao2_container *container, const char *category); static void user_profile_destructor(void *obj) { return; } static void *user_profile_alloc(const char *category) { struct user_profile *u_profile; if (!(u_profile = ao2_alloc(sizeof(*u_profile), user_profile_destructor))) { return NULL; } ast_copy_string(u_profile->name, category, sizeof(u_profile->name)); return u_profile; } static void *user_profile_find(struct ao2_container *container, const char *category) { return ao2_find(container, category, OBJ_KEY); } static struct aco_type user_type = { .type = ACO_ITEM, .category_match = ACO_BLACKLIST, .category = "^general$", .matchfield = "type", .matchvalue = "user", .item_alloc = user_profile_alloc, .item_find = user_profile_find, .item_offset = offsetof(struct confbridge_cfg, user_profiles), }; static void *menu_alloc(const char *category); static void *menu_find(struct ao2_container *container, const char *category); static void menu_destructor(void *obj); static void *menu_alloc(const char *category) { struct conf_menu *menu; if (!(menu = ao2_alloc(sizeof(*menu), menu_destructor))) { return NULL; } ast_copy_string(menu->name, category, sizeof(menu->name)); return menu; } static void *menu_find(struct ao2_container *container, const char *category) { return ao2_find(container, category, OBJ_KEY); } static struct aco_type menu_type = { .type = ACO_ITEM, .category_match = ACO_BLACKLIST, .category = "^general$", .matchfield = "type", .matchvalue = "menu", .item_alloc = menu_alloc, .item_find = menu_find, .item_offset = offsetof(struct confbridge_cfg, menus), }; /* Used to pass to aco_option_register */ static struct aco_type *bridge_types[] = ACO_TYPES(&bridge_type); static struct aco_type *menu_types[] = ACO_TYPES(&menu_type); static struct aco_type *user_types[] = ACO_TYPES(&user_type); /* The general category is reserved, but unused */ static struct aco_type general_type = { .type = ACO_GLOBAL, .category_match = ACO_WHITELIST, .category = "^general$", }; static struct aco_file confbridge_conf = { .filename = "confbridge.conf", .types = ACO_TYPES(&bridge_type, &user_type, &menu_type, &general_type), }; static AO2_GLOBAL_OBJ_STATIC(cfg_handle); static void *confbridge_cfg_alloc(void); CONFIG_INFO_STANDARD(cfg_info, cfg_handle, confbridge_cfg_alloc, .files = ACO_FILES(&confbridge_conf), .pre_apply_config = verify_default_profiles, ); /*! bridge profile container functions */ static int bridge_cmp_cb(void *obj, void *arg, int flags) { const struct bridge_profile *entry1 = obj, *entry2 = arg; const char *name = arg; return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ? CMP_MATCH | CMP_STOP : 0; } static int bridge_hash_cb(const void *obj, const int flags) { const struct bridge_profile *b_profile = obj; const char *name = obj; return ast_str_case_hash(flags & OBJ_KEY ? name : b_profile->name); } /*! menu container functions */ static int menu_cmp_cb(void *obj, void *arg, int flags) { const struct conf_menu *entry1 = obj, *entry2 = arg; const char *name = arg; return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ? CMP_MATCH | CMP_STOP : 0; } static int menu_hash_cb(const void *obj, const int flags) { const struct conf_menu *menu = obj; const char *name = obj; return ast_str_case_hash(flags & OBJ_KEY ? name : menu->name); } static void menu_destructor(void *obj) { struct conf_menu *menu = obj; struct conf_menu_entry *entry = NULL; while ((entry = AST_LIST_REMOVE_HEAD(&menu->entries, entry))) { conf_menu_entry_destroy(entry); ast_free(entry); } } /*! User profile container functions */ static int user_cmp_cb(void *obj, void *arg, int flags) { const struct user_profile *entry1 = obj, *entry2 = arg; const char *name = arg; return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ? CMP_MATCH | CMP_STOP : 0; } static int user_hash_cb(const void *obj, const int flags) { const struct user_profile *u_profile = obj; const char *name = obj; return ast_str_case_hash(flags & OBJ_KEY ? name : u_profile->name); } /*! Bridge Profile Sounds functions */ static void bridge_profile_sounds_destroy_cb(void *obj) { struct bridge_profile_sounds *sounds = obj; ast_string_field_free_memory(sounds); } static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void) { struct bridge_profile_sounds *sounds = ao2_alloc(sizeof(*sounds), bridge_profile_sounds_destroy_cb); if (!sounds) { return NULL; } if (ast_string_field_init(sounds, 512)) { ao2_ref(sounds, -1); return NULL; } return sounds; } static int set_sound(const char *sound_name, const char *sound_file, struct bridge_profile *b_profile) { struct bridge_profile_sounds *sounds = b_profile->sounds; if (ast_strlen_zero(sound_file)) { return -1; } if (!strcasecmp(sound_name, "sound_only_person")) { ast_string_field_set(sounds, onlyperson, sound_file); } else if (!strcasecmp(sound_name, "sound_only_one")) { ast_string_field_set(sounds, onlyone, sound_file); } else if (!strcasecmp(sound_name, "sound_has_joined")) { ast_string_field_set(sounds, hasjoin, sound_file); } else if (!strcasecmp(sound_name, "sound_has_left")) { ast_string_field_set(sounds, hasleft, sound_file); } else if (!strcasecmp(sound_name, "sound_kicked")) { ast_string_field_set(sounds, kicked, sound_file); } else if (!strcasecmp(sound_name, "sound_muted")) { ast_string_field_set(sounds, muted, sound_file); } else if (!strcasecmp(sound_name, "sound_unmuted")) { ast_string_field_set(sounds, unmuted, sound_file); } else if (!strcasecmp(sound_name, "sound_there_are")) { ast_string_field_set(sounds, thereare, sound_file); } else if (!strcasecmp(sound_name, "sound_other_in_party")) { ast_string_field_set(sounds, otherinparty, sound_file); } else if (!strcasecmp(sound_name, "sound_place_into_conference")) { ast_string_field_set(sounds, placeintoconf, sound_file); } else if (!strcasecmp(sound_name, "sound_wait_for_leader")) { ast_string_field_set(sounds, waitforleader, sound_file); } else if (!strcasecmp(sound_name, "sound_leader_has_left")) { ast_string_field_set(sounds, leaderhasleft, sound_file); } else if (!strcasecmp(sound_name, "sound_get_pin")) { ast_string_field_set(sounds, getpin, sound_file); } else if (!strcasecmp(sound_name, "sound_invalid_pin")) { ast_string_field_set(sounds, invalidpin, sound_file); } else if (!strcasecmp(sound_name, "sound_locked")) { ast_string_field_set(sounds, locked, sound_file); } else if (!strcasecmp(sound_name, "sound_unlocked_now")) { ast_string_field_set(sounds, unlockednow, sound_file); } else if (!strcasecmp(sound_name, "sound_locked_now")) { ast_string_field_set(sounds, lockednow, sound_file); } else if (!strcasecmp(sound_name, "sound_error_menu")) { ast_string_field_set(sounds, errormenu, sound_file); } else if (!strcasecmp(sound_name, "sound_join")) { ast_string_field_set(sounds, join, sound_file); } else if (!strcasecmp(sound_name, "sound_leave")) { ast_string_field_set(sounds, leave, sound_file); } else if (!strcasecmp(sound_name, "sound_participants_muted")) { ast_string_field_set(sounds, participantsmuted, sound_file); } else if (!strcasecmp(sound_name, "sound_participants_unmuted")) { ast_string_field_set(sounds, participantsunmuted, sound_file); } else { return -1; } return 0; } /*! CONFBRIDGE dialplan function functions and channel datastore. */ struct func_confbridge_data { struct bridge_profile b_profile; struct user_profile u_profile; unsigned int b_usable:1; /*!< Tells if bridge profile is usable or not */ unsigned int u_usable:1; /*!< Tells if user profile is usable or not */ }; static void func_confbridge_destroy_cb(void *data) { struct func_confbridge_data *b_data = data; conf_bridge_profile_destroy(&b_data->b_profile); ast_free(b_data); }; static const struct ast_datastore_info confbridge_datastore = { .type = "confbridge", .destroy = func_confbridge_destroy_cb }; int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value) { struct ast_datastore *datastore; struct func_confbridge_data *b_data; char *parse; struct ast_variable tmpvar = { 0, }; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(type); AST_APP_ARG(option); ); /* parse all the required arguments and make sure they exist. */ if (ast_strlen_zero(data)) { return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.type) || ast_strlen_zero(args.option)) { return -1; } ast_channel_lock(chan); datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL); if (!datastore) { datastore = ast_datastore_alloc(&confbridge_datastore, NULL); if (!datastore) { ast_channel_unlock(chan); return 0; } b_data = ast_calloc(1, sizeof(*b_data)); if (!b_data) { ast_channel_unlock(chan); ast_datastore_free(datastore); return 0; } b_data->b_profile.sounds = bridge_profile_sounds_alloc(); if (!b_data->b_profile.sounds) { ast_channel_unlock(chan); ast_datastore_free(datastore); ast_free(b_data); return 0; } datastore->data = b_data; ast_channel_datastore_add(chan, datastore); } else { b_data = datastore->data; } ast_channel_unlock(chan); /* SET(CONFBRIDGE(type,option)=value) */ if (!value) { value = ""; } tmpvar.name = args.option; tmpvar.value = value; tmpvar.file = "CONFBRIDGE"; if (!strcasecmp(args.type, "bridge")) { if (!aco_process_var(&bridge_type, "dialplan", &tmpvar, &b_data->b_profile)) { b_data->b_usable = 1; return 0; } } else if (!strcasecmp(args.type, "user")) { if (!aco_process_var(&user_type, "dialplan", &tmpvar, &b_data->u_profile)) { b_data->u_usable = 1; return 0; } } ast_log(LOG_WARNING, "%s(%s,%s) cannot be set to '%s'. Invalid type, option, or value.\n", cmd, args.type, args.option, value); return -1; } static int add_action_to_menu_entry(struct conf_menu_entry *menu_entry, enum conf_menu_action_id id, char *databuf) { struct conf_menu_action *menu_action = ast_calloc(1, sizeof(*menu_action)); if (!menu_action) { return -1; } menu_action->id = id; switch (id) { case MENU_ACTION_NOOP: case MENU_ACTION_TOGGLE_MUTE: case MENU_ACTION_INCREASE_LISTENING: case MENU_ACTION_DECREASE_LISTENING: case MENU_ACTION_INCREASE_TALKING: case MENU_ACTION_DECREASE_TALKING: case MENU_ACTION_RESET_LISTENING: case MENU_ACTION_RESET_TALKING: case MENU_ACTION_ADMIN_TOGGLE_LOCK: case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS: case MENU_ACTION_PARTICIPANT_COUNT: case MENU_ACTION_ADMIN_KICK_LAST: case MENU_ACTION_LEAVE: case MENU_ACTION_SET_SINGLE_VIDEO_SRC: case MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC: break; case MENU_ACTION_PLAYBACK: case MENU_ACTION_PLAYBACK_AND_CONTINUE: if (!(ast_strlen_zero(databuf))) { ast_copy_string(menu_action->data.playback_file, databuf, sizeof(menu_action->data.playback_file)); } else { ast_free(menu_action); return -1; } break; case MENU_ACTION_DIALPLAN_EXEC: if (!(ast_strlen_zero(databuf))) { AST_DECLARE_APP_ARGS(args, AST_APP_ARG(context); AST_APP_ARG(exten); AST_APP_ARG(priority); ); AST_STANDARD_APP_ARGS(args, databuf); if (!ast_strlen_zero(args.context)) { ast_copy_string(menu_action->data.dialplan_args.context, args.context, sizeof(menu_action->data.dialplan_args.context)); } if (!ast_strlen_zero(args.exten)) { ast_copy_string(menu_action->data.dialplan_args.exten, args.exten, sizeof(menu_action->data.dialplan_args.exten)); } menu_action->data.dialplan_args.priority = 1; /* 1 by default */ if (!ast_strlen_zero(args.priority) && (sscanf(args.priority, "%30u", &menu_action->data.dialplan_args.priority) != 1)) { /* invalid priority */ ast_free(menu_action); return -1; } } else { ast_free(menu_action); return -1; } }; AST_LIST_INSERT_TAIL(&menu_entry->actions, menu_action, action); return 0; } static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char *action_names) { struct conf_menu_entry *menu_entry = NULL, *cur = NULL; int res = 0; char *tmp_action_names = ast_strdupa(action_names); char *action = NULL; char *action_args; char *tmp; char buf[PATH_MAX]; char *delimiter = ","; if (!(menu_entry = ast_calloc(1, sizeof(*menu_entry)))) { return -1; } for (;;) { char *comma; char *startbrace; char *endbrace; unsigned int action_len; if (ast_strlen_zero(tmp_action_names)) { break; } startbrace = strchr(tmp_action_names, '('); endbrace = strchr(tmp_action_names, ')'); comma = strchr(tmp_action_names, ','); /* If the next action has brackets with comma delimited arguments in it, * make the delimeter ')' instead of a comma to preserve the argments */ if (startbrace && endbrace && comma && (comma > startbrace && comma < endbrace)) { delimiter = ")"; } else { delimiter = ","; } if (!(action = strsep(&tmp_action_names, delimiter))) { break; } action = ast_strip(action); if (ast_strlen_zero(action)) { continue; } action_len = strlen(action); ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf)); if (!strcasecmp(action, "toggle_mute")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL); } else if (!strcasecmp(action, "no_op")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_NOOP, NULL); } else if (!strcasecmp(action, "increase_listening_volume")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_LISTENING, NULL); } else if (!strcasecmp(action, "decrease_listening_volume")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_LISTENING, NULL); } else if (!strcasecmp(action, "increase_talking_volume")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_TALKING, NULL); } else if (!strcasecmp(action, "reset_listening_volume")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_LISTENING, NULL); } else if (!strcasecmp(action, "reset_talking_volume")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_TALKING, NULL); } else if (!strcasecmp(action, "decrease_talking_volume")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_TALKING, NULL); } else if (!strcasecmp(action, "admin_toggle_conference_lock")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_LOCK, NULL); } else if (!strcasecmp(action, "admin_toggle_mute_participants")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS, NULL); } else if (!strcasecmp(action, "participant_count")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PARTICIPANT_COUNT, NULL); } else if (!strcasecmp(action, "admin_kick_last")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL); } else if (!strcasecmp(action, "leave_conference")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL); } else if (!strcasecmp(action, "set_as_single_video_src")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_SET_SINGLE_VIDEO_SRC, NULL); } else if (!strcasecmp(action, "release_as_single_video_src")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC, NULL); } else if (!strncasecmp(action, "dialplan_exec(", 14)) { ast_copy_string(buf, action, sizeof(buf)); action_args = buf; if ((action_args = strchr(action, '('))) { action_args++; } /* it is possible that this argument may or may not * have a closing brace at this point, it all depends on if * comma delimited arguments were provided */ if ((tmp = strchr(action, ')'))) { *tmp = '\0'; } res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args); } else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue(", 22)) { ast_copy_string(buf, action, sizeof(buf)); action_args = buf; if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) { *tmp = '\0'; action_args++; } res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args); } else if (action_len >= 8 && !strncasecmp(action, "playback(", 9)) { ast_copy_string(buf, action, sizeof(buf)); action_args = buf; if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) { *tmp = '\0'; action_args++; } res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, action_args); } } /* if adding any of the actions failed, bail */ if (res) { struct conf_menu_action *menu_action; while ((menu_action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) { ast_free(menu_action); } ast_free(menu_entry); return -1; } /* remove any list entry with an identical DTMF sequence for overrides */ AST_LIST_TRAVERSE_SAFE_BEGIN(&menu->entries, cur, entry) { if (!strcasecmp(cur->dtmf, menu_entry->dtmf)) { AST_LIST_REMOVE_CURRENT(entry); ast_free(cur); break; } } AST_LIST_TRAVERSE_SAFE_END; AST_LIST_INSERT_TAIL(&menu->entries, menu_entry, entry); return 0; } static char *complete_user_profile_name(const char *line, const char *word, int pos, int state) { int which = 0; char *res = NULL; int wordlen = strlen(word); struct ao2_iterator i; struct user_profile *u_profile = NULL; RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); if (!cfg) { return NULL; } i = ao2_iterator_init(cfg->user_profiles, 0); while ((u_profile = ao2_iterator_next(&i))) { if (!strncasecmp(u_profile->name, word, wordlen) && ++which > state) { res = ast_strdup(u_profile->name); ao2_ref(u_profile, -1); break; } ao2_ref(u_profile, -1); } ao2_iterator_destroy(&i); return res; } static char *handle_cli_confbridge_show_user_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ao2_iterator it; struct user_profile *u_profile; RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); switch (cmd) { case CLI_INIT: e->command = "confbridge show profile users"; e->usage = "Usage confbridge show profile users\n"; return NULL; case CLI_GENERATE: return NULL; } if (!(cfg = ao2_global_obj_ref(cfg_handle))) { return NULL; } ast_cli(a->fd,"--------- User Profiles -----------\n"); ao2_lock(cfg->user_profiles); it = ao2_iterator_init(cfg->user_profiles, 0); while ((u_profile = ao2_iterator_next(&it))) { ast_cli(a->fd,"%s\n", u_profile->name); ao2_ref(u_profile, -1); } ao2_iterator_destroy(&it); ao2_unlock(cfg->user_profiles); return CLI_SUCCESS; } static char *handle_cli_confbridge_show_user_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct user_profile u_profile; switch (cmd) { case CLI_INIT: e->command = "confbridge show profile user"; e->usage = "Usage confbridge show profile user []\n"; return NULL; case CLI_GENERATE: if (a->pos == 4) { return complete_user_profile_name(a->line, a->word, a->pos, a->n); } return NULL; } if (a->argc != 5) { return CLI_SHOWUSAGE; } if (!(conf_find_user_profile(NULL, a->argv[4], &u_profile))) { ast_cli(a->fd, "No conference user profile named '%s' found!\n", a->argv[4]); return CLI_SUCCESS; } ast_cli(a->fd,"--------------------------------------------\n"); ast_cli(a->fd,"Name: %s\n", u_profile.name); ast_cli(a->fd,"Admin: %s\n", u_profile.flags & USER_OPT_ADMIN ? "true" : "false"); ast_cli(a->fd,"Marked User: %s\n", u_profile.flags & USER_OPT_MARKEDUSER ? "true" : "false"); ast_cli(a->fd,"Start Muted: %s\n", u_profile.flags & USER_OPT_STARTMUTED? "true" : "false"); ast_cli(a->fd,"MOH When Empty: %s\n", u_profile.flags & USER_OPT_MUSICONHOLD ? "enabled" : "disabled"); ast_cli(a->fd,"MOH Class: %s\n", ast_strlen_zero(u_profile.moh_class) ? "default" : u_profile.moh_class); ast_cli(a->fd,"Announcement: %s\n", u_profile.announcement); ast_cli(a->fd,"Quiet: %s\n", u_profile.flags & USER_OPT_QUIET ? "enabled" : "disabled"); ast_cli(a->fd,"Wait Marked: %s\n", u_profile.flags & USER_OPT_WAITMARKED ? "enabled" : "disabled"); ast_cli(a->fd,"END Marked: %s\n", u_profile.flags & USER_OPT_ENDMARKED ? "enabled" : "disabled"); ast_cli(a->fd,"Drop_silence: %s\n", u_profile.flags & USER_OPT_DROP_SILENCE ? "enabled" : "disabled"); ast_cli(a->fd,"Silence Threshold: %dms\n", u_profile.silence_threshold); ast_cli(a->fd,"Talking Threshold: %dms\n", u_profile.talking_threshold); ast_cli(a->fd,"Denoise: %s\n", u_profile.flags & USER_OPT_DENOISE ? "enabled" : "disabled"); ast_cli(a->fd,"Jitterbuffer: %s\n", u_profile.flags & USER_OPT_JITTERBUFFER ? "enabled" : "disabled"); ast_cli(a->fd,"Talk Detect Events: %s\n", u_profile.flags & USER_OPT_TALKER_DETECT ? "enabled" : "disabled"); ast_cli(a->fd,"DTMF Pass Through: %s\n", u_profile.flags & USER_OPT_DTMF_PASS ? "enabled" : "disabled"); ast_cli(a->fd,"PIN: %s\n", ast_strlen_zero(u_profile.pin) ? "None" : u_profile.pin); ast_cli(a->fd,"Announce User Count: %s\n", u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNT ? "enabled" : "disabled"); ast_cli(a->fd,"Announce join/leave: %s\n", u_profile.flags & USER_OPT_ANNOUNCE_JOIN_LEAVE ? "enabled" : "disabled"); ast_cli(a->fd,"Announce User Count all: %s\n", u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNTALL ? "enabled" : "disabled"); ast_cli(a->fd,"\n"); return CLI_SUCCESS; } static char *complete_bridge_profile_name(const char *line, const char *word, int pos, int state) { int which = 0; char *res = NULL; int wordlen = strlen(word); struct ao2_iterator i; struct bridge_profile *b_profile = NULL; RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); if (!cfg) { return NULL; } i = ao2_iterator_init(cfg->bridge_profiles, 0); while ((b_profile = ao2_iterator_next(&i))) { if (!strncasecmp(b_profile->name, word, wordlen) && ++which > state) { res = ast_strdup(b_profile->name); ao2_ref(b_profile, -1); break; } ao2_ref(b_profile, -1); } ao2_iterator_destroy(&i); return res; } static char *handle_cli_confbridge_show_bridge_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ao2_iterator it; struct bridge_profile *b_profile; RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); switch (cmd) { case CLI_INIT: e->command = "confbridge show profile bridges"; e->usage = "Usage confbridge show profile bridges\n"; return NULL; case CLI_GENERATE: return NULL; } if (!(cfg = ao2_global_obj_ref(cfg_handle))) { return NULL; } ast_cli(a->fd,"--------- Bridge Profiles -----------\n"); ao2_lock(cfg->bridge_profiles); it = ao2_iterator_init(cfg->bridge_profiles, 0); while ((b_profile = ao2_iterator_next(&it))) { ast_cli(a->fd,"%s\n", b_profile->name); ao2_ref(b_profile, -1); } ao2_iterator_destroy(&it); ao2_unlock(cfg->bridge_profiles); return CLI_SUCCESS; } static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct bridge_profile b_profile; char tmp[64]; switch (cmd) { case CLI_INIT: e->command = "confbridge show profile bridge"; e->usage = "Usage confbridge show profile bridge \n"; return NULL; case CLI_GENERATE: if (a->pos == 4) { return complete_bridge_profile_name(a->line, a->word, a->pos, a->n); } return NULL; } if (a->argc != 5) { return CLI_SHOWUSAGE; } if (!(conf_find_bridge_profile(NULL, a->argv[4], &b_profile))) { ast_cli(a->fd, "No conference bridge profile named '%s' found!\n", a->argv[4]); return CLI_SUCCESS; } ast_cli(a->fd,"--------------------------------------------\n"); ast_cli(a->fd,"Name: %s\n", b_profile.name); ast_cli(a->fd,"Language: %s\n", b_profile.language); if (b_profile.internal_sample_rate) { snprintf(tmp, sizeof(tmp), "%d", b_profile.internal_sample_rate); } else { ast_copy_string(tmp, "auto", sizeof(tmp)); } ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp); if (b_profile.mix_interval) { ast_cli(a->fd,"Mixing Interval: %d\n", b_profile.mix_interval); } else { ast_cli(a->fd,"Mixing Interval: Default 20ms\n"); } ast_cli(a->fd,"Record Conference: %s\n", b_profile.flags & BRIDGE_OPT_RECORD_CONFERENCE ? "yes" : "no"); ast_cli(a->fd,"Record File: %s\n", ast_strlen_zero(b_profile.rec_file) ? "Auto Generated" : b_profile.rec_file); if (b_profile.max_members) { ast_cli(a->fd,"Max Members: %d\n", b_profile.max_members); } else { ast_cli(a->fd,"Max Members: No Limit\n"); } switch (b_profile.flags & (BRIDGE_OPT_VIDEO_SRC_LAST_MARKED | BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED | BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER)) { case BRIDGE_OPT_VIDEO_SRC_LAST_MARKED: ast_cli(a->fd, "Video Mode: last_marked\n"); break; case BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED: ast_cli(a->fd, "Video Mode: first_marked\n"); break; case BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER: ast_cli(a->fd, "Video Mode: follow_talker\n"); break; case 0: ast_cli(a->fd, "Video Mode: no video\n"); break; default: /* Opps. We have more than one video mode flag set. */ ast_assert(0); break; } ast_cli(a->fd,"sound_only_person: %s\n", conf_get_sound(CONF_SOUND_ONLY_PERSON, b_profile.sounds)); ast_cli(a->fd,"sound_only_one: %s\n", conf_get_sound(CONF_SOUND_ONLY_ONE, b_profile.sounds)); ast_cli(a->fd,"sound_has_joined: %s\n", conf_get_sound(CONF_SOUND_HAS_JOINED, b_profile.sounds)); ast_cli(a->fd,"sound_has_left: %s\n", conf_get_sound(CONF_SOUND_HAS_LEFT, b_profile.sounds)); ast_cli(a->fd,"sound_kicked: %s\n", conf_get_sound(CONF_SOUND_KICKED, b_profile.sounds)); ast_cli(a->fd,"sound_muted: %s\n", conf_get_sound(CONF_SOUND_MUTED, b_profile.sounds)); ast_cli(a->fd,"sound_unmuted: %s\n", conf_get_sound(CONF_SOUND_UNMUTED, b_profile.sounds)); ast_cli(a->fd,"sound_there_are: %s\n", conf_get_sound(CONF_SOUND_THERE_ARE, b_profile.sounds)); ast_cli(a->fd,"sound_other_in_party: %s\n", conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, b_profile.sounds)); ast_cli(a->fd,"sound_place_into_conference: %s\n", conf_get_sound(CONF_SOUND_PLACE_IN_CONF, b_profile.sounds)); ast_cli(a->fd,"sound_wait_for_leader: %s\n", conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, b_profile.sounds)); ast_cli(a->fd,"sound_leader_has_left: %s\n", conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, b_profile.sounds)); ast_cli(a->fd,"sound_get_pin: %s\n", conf_get_sound(CONF_SOUND_GET_PIN, b_profile.sounds)); ast_cli(a->fd,"sound_invalid_pin: %s\n", conf_get_sound(CONF_SOUND_INVALID_PIN, b_profile.sounds)); ast_cli(a->fd,"sound_locked: %s\n", conf_get_sound(CONF_SOUND_LOCKED, b_profile.sounds)); ast_cli(a->fd,"sound_unlocked_now: %s\n", conf_get_sound(CONF_SOUND_UNLOCKED_NOW, b_profile.sounds)); ast_cli(a->fd,"sound_lockednow: %s\n", conf_get_sound(CONF_SOUND_LOCKED_NOW, b_profile.sounds)); ast_cli(a->fd,"sound_error_menu: %s\n", conf_get_sound(CONF_SOUND_ERROR_MENU, b_profile.sounds)); ast_cli(a->fd,"sound_join: %s\n", conf_get_sound(CONF_SOUND_JOIN, b_profile.sounds)); ast_cli(a->fd,"sound_leave: %s\n", conf_get_sound(CONF_SOUND_LEAVE, b_profile.sounds)); ast_cli(a->fd,"sound_participants_muted: %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_MUTED, b_profile.sounds)); ast_cli(a->fd,"sound_participants_unmuted: %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_UNMUTED, b_profile.sounds)); ast_cli(a->fd,"\n"); conf_bridge_profile_destroy(&b_profile); return CLI_SUCCESS; } static char *complete_menu_name(const char *line, const char *word, int pos, int state) { int which = 0; char *res = NULL; int wordlen = strlen(word); struct ao2_iterator i; struct conf_menu *menu = NULL; RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); if (!cfg) { return NULL; } i = ao2_iterator_init(cfg->menus, 0); while ((menu = ao2_iterator_next(&i))) { if (!strncasecmp(menu->name, word, wordlen) && ++which > state) { res = ast_strdup(menu->name); ao2_ref(menu, -1); break; } ao2_ref(menu, -1); } ao2_iterator_destroy(&i); return res; } static char *handle_cli_confbridge_show_menus(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct ao2_iterator it; struct conf_menu *menu; RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); switch (cmd) { case CLI_INIT: e->command = "confbridge show menus"; e->usage = "Usage confbridge show profile menus\n"; return NULL; case CLI_GENERATE: return NULL; } if (!(cfg = ao2_global_obj_ref(cfg_handle))) { return NULL; } ast_cli(a->fd,"--------- Menus -----------\n"); ao2_lock(cfg->menus); it = ao2_iterator_init(cfg->menus, 0); while ((menu = ao2_iterator_next(&it))) { ast_cli(a->fd,"%s\n", menu->name); ao2_ref(menu, -1); } ao2_iterator_destroy(&it); ao2_unlock(cfg->menus); return CLI_SUCCESS; } static char *handle_cli_confbridge_show_menu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { RAII_VAR(struct conf_menu *, menu, NULL, ao2_cleanup); RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); struct conf_menu_entry *menu_entry = NULL; struct conf_menu_action *menu_action = NULL; switch (cmd) { case CLI_INIT: e->command = "confbridge show menu"; e->usage = "Usage confbridge show menu [

]\n"; return NULL; case CLI_GENERATE: if (a->pos == 3) { return complete_menu_name(a->line, a->word, a->pos, a->n); } return NULL; } if (a->argc != 4) { return CLI_SHOWUSAGE; } if (!(cfg = ao2_global_obj_ref(cfg_handle))) { return NULL; } if (!(menu = menu_find(cfg->menus, a->argv[3]))) { ast_cli(a->fd, "No conference menu named '%s' found!\n", a->argv[3]); return CLI_SUCCESS; } ao2_lock(menu); ast_cli(a->fd,"Name: %s\n", menu->name); AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) { int action_num = 0; ast_cli(a->fd, "%s=", menu_entry->dtmf); AST_LIST_TRAVERSE(&menu_entry->actions, menu_action, action) { if (action_num) { ast_cli(a->fd, ", "); } switch (menu_action->id) { case MENU_ACTION_TOGGLE_MUTE: ast_cli(a->fd, "toggle_mute"); break; case MENU_ACTION_NOOP: ast_cli(a->fd, "no_op"); break; case MENU_ACTION_INCREASE_LISTENING: ast_cli(a->fd, "increase_listening_volume"); break; case MENU_ACTION_DECREASE_LISTENING: ast_cli(a->fd, "decrease_listening_volume"); break; case MENU_ACTION_RESET_LISTENING: ast_cli(a->fd, "reset_listening_volume"); break; case MENU_ACTION_RESET_TALKING: ast_cli(a->fd, "reset_talking_volume"); break; case MENU_ACTION_INCREASE_TALKING: ast_cli(a->fd, "increase_talking_volume"); break; case MENU_ACTION_DECREASE_TALKING: ast_cli(a->fd, "decrease_talking_volume"); break; case MENU_ACTION_PLAYBACK: ast_cli(a->fd, "playback(%s)", menu_action->data.playback_file); break; case MENU_ACTION_PLAYBACK_AND_CONTINUE: ast_cli(a->fd, "playback_and_continue(%s)", menu_action->data.playback_file); break; case MENU_ACTION_DIALPLAN_EXEC: ast_cli(a->fd, "dialplan_exec(%s,%s,%d)", menu_action->data.dialplan_args.context, menu_action->data.dialplan_args.exten, menu_action->data.dialplan_args.priority); break; case MENU_ACTION_ADMIN_TOGGLE_LOCK: ast_cli(a->fd, "admin_toggle_conference_lock"); break; case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS: ast_cli(a->fd, "admin_toggle_mute_participants"); break; case MENU_ACTION_PARTICIPANT_COUNT: ast_cli(a->fd, "participant_count"); break; case MENU_ACTION_ADMIN_KICK_LAST: ast_cli(a->fd, "admin_kick_last"); break; case MENU_ACTION_LEAVE: ast_cli(a->fd, "leave_conference"); break; case MENU_ACTION_SET_SINGLE_VIDEO_SRC: ast_cli(a->fd, "set_as_single_video_src"); break; case MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC: ast_cli(a->fd, "release_as_single_video_src"); break; } action_num++; } ast_cli(a->fd,"\n"); } ao2_unlock(menu); return CLI_SUCCESS; } static struct ast_cli_entry cli_confbridge_parser[] = { AST_CLI_DEFINE(handle_cli_confbridge_show_user_profile, "Show a conference user profile."), AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profile, "Show a conference bridge profile."), AST_CLI_DEFINE(handle_cli_confbridge_show_menu, "Show a conference menu"), AST_CLI_DEFINE(handle_cli_confbridge_show_user_profiles, "Show a list of conference user profiles."), AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profiles, "Show a list of conference bridge profiles."), AST_CLI_DEFINE(handle_cli_confbridge_show_menus, "Show a list of conference menus"), }; static void confbridge_cfg_destructor(void *obj) { struct confbridge_cfg *cfg = obj; ao2_cleanup(cfg->user_profiles); ao2_cleanup(cfg->bridge_profiles); ao2_cleanup(cfg->menus); } void *confbridge_cfg_alloc(void) { struct confbridge_cfg *cfg; if (!(cfg = ao2_alloc(sizeof(*cfg), confbridge_cfg_destructor))) { return NULL; } if (!(cfg->user_profiles = ao2_container_alloc(283, user_hash_cb, user_cmp_cb))) { goto error; } if (!(cfg->bridge_profiles = ao2_container_alloc(283, bridge_hash_cb, bridge_cmp_cb))) { goto error; } if (!(cfg->menus = ao2_container_alloc(283, menu_hash_cb, menu_cmp_cb))) { goto error; } return cfg; error: ao2_ref(cfg, -1); return NULL; } static int announce_user_count_all_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { struct user_profile *u_profile = obj; if (strcasecmp(var->name, "announce_user_count_all")) { return -1; } if (ast_true(var->value)) { u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL; } else if (ast_false(var->value)) { u_profile->flags = u_profile->flags & ~USER_OPT_ANNOUNCEUSERCOUNTALL; } else if (sscanf(var->value, "%30u", &u_profile->announce_user_count_all_after) == 1) { u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL; } else { return -1; } return 0; } static int mix_interval_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { struct bridge_profile *b_profile = obj; if (strcasecmp(var->name, "mixing_interval")) { return -1; } if (sscanf(var->value, "%30u", &b_profile->mix_interval) != 1) { return -1; } switch (b_profile->mix_interval) { case 10: case 20: case 40: case 80: return 0; default: return -1; } } static int video_mode_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { struct bridge_profile *b_profile = obj; if (strcasecmp(var->name, "video_mode")) { return -1; } if (!strcasecmp(var->value, "first_marked")) { ast_set_flags_to(b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED | BRIDGE_OPT_VIDEO_SRC_LAST_MARKED | BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED); } else if (!strcasecmp(var->value, "last_marked")) { ast_set_flags_to(b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED | BRIDGE_OPT_VIDEO_SRC_LAST_MARKED | BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER, BRIDGE_OPT_VIDEO_SRC_LAST_MARKED); } else if (!strcasecmp(var->value, "follow_talker")) { ast_set_flags_to(b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED | BRIDGE_OPT_VIDEO_SRC_LAST_MARKED | BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER); } else if (!strcasecmp(var->value, "none")) { ast_clear_flag(b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED | BRIDGE_OPT_VIDEO_SRC_LAST_MARKED | BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER); } else { return -1; } return 0; } static int user_template_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { struct user_profile *u_profile = obj; return conf_find_user_profile(NULL, var->value, u_profile) ? 0 : -1; } static int bridge_template_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { struct bridge_profile *b_profile = obj; struct bridge_profile_sounds *sounds = bridge_profile_sounds_alloc(); struct bridge_profile_sounds *oldsounds = b_profile->sounds; if (!sounds) { return -1; } if (!(conf_find_bridge_profile(NULL, var->value, b_profile))) { ao2_ref(sounds, -1); return -1; } /* Using a bridge profile as a template is a little complicated due to the sounds. Since the sounds * structure of a dynamic profile will need to be altered, a completely new sounds structure must be * created instead of simply holding a reference to the one built by the config file. */ ast_string_field_set(sounds, onlyperson, b_profile->sounds->onlyperson); ast_string_field_set(sounds, onlyone, b_profile->sounds->onlyone); ast_string_field_set(sounds, hasjoin, b_profile->sounds->hasjoin); ast_string_field_set(sounds, hasleft, b_profile->sounds->hasleft); ast_string_field_set(sounds, kicked, b_profile->sounds->kicked); ast_string_field_set(sounds, muted, b_profile->sounds->muted); ast_string_field_set(sounds, unmuted, b_profile->sounds->unmuted); ast_string_field_set(sounds, thereare, b_profile->sounds->thereare); ast_string_field_set(sounds, otherinparty, b_profile->sounds->otherinparty); ast_string_field_set(sounds, placeintoconf, b_profile->sounds->placeintoconf); ast_string_field_set(sounds, waitforleader, b_profile->sounds->waitforleader); ast_string_field_set(sounds, leaderhasleft, b_profile->sounds->leaderhasleft); ast_string_field_set(sounds, getpin, b_profile->sounds->getpin); ast_string_field_set(sounds, invalidpin, b_profile->sounds->invalidpin); ast_string_field_set(sounds, locked, b_profile->sounds->locked); ast_string_field_set(sounds, unlockednow, b_profile->sounds->unlockednow); ast_string_field_set(sounds, lockednow, b_profile->sounds->lockednow); ast_string_field_set(sounds, errormenu, b_profile->sounds->errormenu); ast_string_field_set(sounds, join, b_profile->sounds->join); ast_string_field_set(sounds, leave, b_profile->sounds->leave); ast_string_field_set(sounds, participantsmuted, b_profile->sounds->participantsmuted); ast_string_field_set(sounds, participantsunmuted, b_profile->sounds->participantsunmuted); ao2_ref(b_profile->sounds, -1); /* sounds struct copied over to it from the template by reference only. */ ao2_ref(oldsounds, -1); /* original sounds struct we don't need anymore */ b_profile->sounds = sounds; /* the new sounds struct that is a deep copy of the one from the template. */ return 0; } static int sound_option_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { set_sound(var->name, var->value, obj); return 0; } static int menu_option_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { add_menu_entry(obj, var->name, var->value); return 0; } static int verify_default_profiles(void) { RAII_VAR(struct user_profile *, user_profile, NULL, ao2_cleanup); RAII_VAR(struct bridge_profile *, bridge_profile, NULL, ao2_cleanup); struct confbridge_cfg *cfg = aco_pending_config(&cfg_info); if (!cfg) { return 0; } bridge_profile = ao2_find(cfg->bridge_profiles, DEFAULT_BRIDGE_PROFILE, OBJ_KEY); if (!bridge_profile) { bridge_profile = bridge_profile_alloc(DEFAULT_BRIDGE_PROFILE); if (!bridge_profile) { return -1; } ast_log(AST_LOG_NOTICE, "Adding %s profile to app_confbridge\n", DEFAULT_BRIDGE_PROFILE); aco_set_defaults(&bridge_type, DEFAULT_BRIDGE_PROFILE, bridge_profile); ao2_link(cfg->bridge_profiles, bridge_profile); } user_profile = ao2_find(cfg->user_profiles, DEFAULT_USER_PROFILE, OBJ_KEY); if (!user_profile) { user_profile = user_profile_alloc(DEFAULT_USER_PROFILE); if (!user_profile) { return -1; } ast_log(AST_LOG_NOTICE, "Adding %s profile to app_confbridge\n", DEFAULT_USER_PROFILE); aco_set_defaults(&user_type, DEFAULT_USER_PROFILE, user_profile); ao2_link(cfg->user_profiles, user_profile); } return 0; } int conf_load_config(void) { if (aco_info_init(&cfg_info)) { return -1; } /* User options */ aco_option_register(&cfg_info, "type", ACO_EXACT, user_types, NULL, OPT_NOOP_T, 0, 0); aco_option_register(&cfg_info, "type", ACO_EXACT, bridge_types, NULL, OPT_NOOP_T, 0, 0); aco_option_register(&cfg_info, "type", ACO_EXACT, menu_types, NULL, OPT_NOOP_T, 0, 0); aco_option_register(&cfg_info, "admin", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ADMIN); aco_option_register(&cfg_info, "marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_MARKEDUSER); aco_option_register(&cfg_info, "startmuted", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_STARTMUTED); aco_option_register(&cfg_info, "music_on_hold_when_empty", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_MUSICONHOLD); aco_option_register(&cfg_info, "quiet", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_QUIET); aco_option_register_custom(&cfg_info, "announce_user_count_all", ACO_EXACT, user_types, "no", announce_user_count_all_handler, 0); aco_option_register(&cfg_info, "announce_user_count", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCEUSERCOUNT); /* Negative logic. Defaults to "yes" and evaluates with ast_false(). If !ast_false(), USER_OPT_NOONLYPERSON is cleared */ aco_option_register(&cfg_info, "announce_only_user", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 0, FLDSET(struct user_profile, flags), USER_OPT_NOONLYPERSON); aco_option_register(&cfg_info, "wait_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_WAITMARKED); aco_option_register(&cfg_info, "end_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ENDMARKED); aco_option_register(&cfg_info, "talk_detection_events", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_TALKER_DETECT); aco_option_register(&cfg_info, "dtmf_passthrough", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DTMF_PASS); aco_option_register(&cfg_info, "announce_join_leave", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCE_JOIN_LEAVE); aco_option_register(&cfg_info, "pin", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, pin)); aco_option_register(&cfg_info, "music_on_hold_class", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, moh_class)); aco_option_register(&cfg_info, "announcement", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, announcement)); aco_option_register(&cfg_info, "denoise", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DENOISE); aco_option_register(&cfg_info, "dsp_drop_silence", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DROP_SILENCE); aco_option_register(&cfg_info, "dsp_silence_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_SILENCE_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, silence_threshold)); aco_option_register(&cfg_info, "dsp_talking_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_TALKING_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, silence_threshold)); aco_option_register(&cfg_info, "jitterbuffer", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_JITTERBUFFER); /* This option should only be used with the CONFBRIDGE dialplan function */ aco_option_register_custom(&cfg_info, "template", ACO_EXACT, user_types, NULL, user_template_handler, 0); /* Bridge options */ aco_option_register(&cfg_info, "jitterbuffer", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), USER_OPT_JITTERBUFFER); /* "auto" will fail to parse as a uint, but we use PARSE_DEFAULT to set the value to 0 in that case, which is the value that auto resolves to */ aco_option_register(&cfg_info, "internal_sample_rate", ACO_EXACT, bridge_types, "0", OPT_UINT_T, PARSE_DEFAULT, FLDSET(struct bridge_profile, internal_sample_rate), 0); aco_option_register_custom(&cfg_info, "mixing_interval", ACO_EXACT, bridge_types, "20", mix_interval_handler, 0); aco_option_register(&cfg_info, "record_conference", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_RECORD_CONFERENCE); aco_option_register_custom(&cfg_info, "video_mode", ACO_EXACT, bridge_types, NULL, video_mode_handler, 0); aco_option_register(&cfg_info, "max_members", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, max_members)); aco_option_register(&cfg_info, "record_file", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, rec_file)); aco_option_register(&cfg_info, "language", ACO_EXACT, bridge_types, "en", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, language)); aco_option_register_custom(&cfg_info, "^sound_", ACO_REGEX, bridge_types, NULL, sound_option_handler, 0); /* This option should only be used with the CONFBRIDGE dialplan function */ aco_option_register_custom(&cfg_info, "template", ACO_EXACT, bridge_types, NULL, bridge_template_handler, 0); /* Menu options */ aco_option_register_custom(&cfg_info, "^[0-9A-D*#]+$", ACO_REGEX, menu_types, NULL, menu_option_handler, 0); if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) { goto error; } if (ast_cli_register_multiple(cli_confbridge_parser, ARRAY_LEN(cli_confbridge_parser))) { goto error; } return 0; error: conf_destroy_config(); return -1; } int conf_reload_config(void) { if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) { /* On a reload, just keep the config we already have in place. */ return -1; } return 0; } static void conf_user_profile_copy(struct user_profile *dst, struct user_profile *src) { *dst = *src; } const struct user_profile *conf_find_user_profile(struct ast_channel *chan, const char *user_profile_name, struct user_profile *result) { struct user_profile *tmp2; struct ast_datastore *datastore = NULL; struct func_confbridge_data *b_data = NULL; RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); if (!cfg) { return NULL; } if (chan) { ast_channel_lock(chan); datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL); ast_channel_unlock(chan); if (datastore) { b_data = datastore->data; if (b_data->u_usable) { conf_user_profile_copy(result, &b_data->u_profile); return result; } } } if (ast_strlen_zero(user_profile_name)) { user_profile_name = DEFAULT_USER_PROFILE; } if (!(tmp2 = ao2_find(cfg->user_profiles, user_profile_name, OBJ_KEY))) { return NULL; } ao2_lock(tmp2); conf_user_profile_copy(result, tmp2); ao2_unlock(tmp2); ao2_ref(tmp2, -1); return result; } void conf_bridge_profile_copy(struct bridge_profile *dst, struct bridge_profile *src) { *dst = *src; if (src->sounds) { ao2_ref(src->sounds, +1); } } void conf_bridge_profile_destroy(struct bridge_profile *b_profile) { if (b_profile->sounds) { ao2_ref(b_profile->sounds, -1); b_profile->sounds = NULL; } } const struct bridge_profile *conf_find_bridge_profile(struct ast_channel *chan, const char *bridge_profile_name, struct bridge_profile *result) { struct bridge_profile *tmp2; struct ast_datastore *datastore = NULL; struct func_confbridge_data *b_data = NULL; RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); if (!cfg) { return NULL; } if (chan) { ast_channel_lock(chan); datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL); ast_channel_unlock(chan); if (datastore) { b_data = datastore->data; if (b_data->b_usable) { conf_bridge_profile_copy(result, &b_data->b_profile); return result; } } } if (ast_strlen_zero(bridge_profile_name)) { bridge_profile_name = DEFAULT_BRIDGE_PROFILE; } if (!(tmp2 = ao2_find(cfg->bridge_profiles, bridge_profile_name, OBJ_KEY))) { return NULL; } ao2_lock(tmp2); conf_bridge_profile_copy(result, tmp2); ao2_unlock(tmp2); ao2_ref(tmp2, -1); return result; } struct dtmf_menu_hook_pvt { struct conference_bridge_user *conference_bridge_user; struct conf_menu_entry menu_entry; struct conf_menu *menu; }; static void menu_hook_destroy(void *hook_pvt) { struct dtmf_menu_hook_pvt *pvt = hook_pvt; struct conf_menu_action *action = NULL; ao2_ref(pvt->menu, -1); while ((action = AST_LIST_REMOVE_HEAD(&pvt->menu_entry.actions, action))) { ast_free(action); } ast_free(pvt); } static int menu_hook_callback(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt) { struct dtmf_menu_hook_pvt *pvt = hook_pvt; return conf_handle_dtmf(bridge_channel, pvt->conference_bridge_user, &pvt->menu_entry, pvt->menu); } static int copy_menu_entry(struct conf_menu_entry *dst, struct conf_menu_entry *src) { struct conf_menu_action *menu_action = NULL; struct conf_menu_action *new_menu_action = NULL; memcpy(dst, src, sizeof(*dst)); AST_LIST_HEAD_INIT_NOLOCK(&dst->actions); AST_LIST_TRAVERSE(&src->actions, menu_action, action) { if (!(new_menu_action = ast_calloc(1, sizeof(*new_menu_action)))) { return -1; } memcpy(new_menu_action, menu_action, sizeof(*new_menu_action)); AST_LIST_INSERT_HEAD(&dst->actions, new_menu_action, action); } return 0; } void conf_menu_entry_destroy(struct conf_menu_entry *menu_entry) { struct conf_menu_action *menu_action = NULL; while ((menu_action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) { ast_free(menu_action); } } int conf_find_menu_entry_by_sequence(const char *dtmf_sequence, struct conf_menu *menu, struct conf_menu_entry *result) { struct conf_menu_entry *menu_entry = NULL; ao2_lock(menu); AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) { if (!strcasecmp(menu_entry->dtmf, dtmf_sequence)) { copy_menu_entry(result, menu_entry); ao2_unlock(menu); return 1; } } ao2_unlock(menu); return 0; } int conf_set_menu_to_user(const char *menu_name, struct conference_bridge_user *conference_bridge_user) { struct conf_menu *menu; struct conf_menu_entry *menu_entry = NULL; RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); if (!cfg) { return -1; } if (!(menu = menu_find(cfg->menus, menu_name))) { return -1; } ao2_lock(menu); AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) { struct dtmf_menu_hook_pvt *pvt; if (!(pvt = ast_calloc(1, sizeof(*pvt)))) { ao2_unlock(menu); ao2_ref(menu, -1); return -1; } if (copy_menu_entry(&pvt->menu_entry, menu_entry)) { ast_free(pvt); ao2_unlock(menu); ao2_ref(menu, -1); return -1; } pvt->conference_bridge_user = conference_bridge_user; ao2_ref(menu, +1); pvt->menu = menu; ast_bridge_features_hook(&conference_bridge_user->features, pvt->menu_entry.dtmf, menu_hook_callback, pvt, menu_hook_destroy); } ao2_unlock(menu); ao2_ref(menu, -1); return 0; } void conf_destroy_config(void) { ast_cli_unregister_multiple(cli_confbridge_parser, ARRAY_LEN(cli_confbridge_parser)); aco_info_destroy(&cfg_info); ao2_global_obj_release(cfg_handle); } asterisk-11.7.0/apps/confbridge/conf_state.c0000644000175000007640000000540312062441320020677 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling * * \author\verbatim Terry Wilson \endverbatim * * This file contains functions that are used from multiple conf_state * files for handling stage change behavior. * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" #include "asterisk/logger.h" #include "asterisk/test.h" #include "include/conf_state.h" #include "include/confbridge.h" void conf_invalid_event_fn(struct conference_bridge_user *cbu) { ast_log(LOG_ERROR, "Invalid event for confbridge user '%s'\n", cbu->u_profile.name); } /*! * \internal * \brief Mute the user and play MOH if the user requires it. * * \param user Conference user to mute and optionally start MOH on. * * \return Nothing */ static void conf_mute_moh_inactive_waitmarked(struct conference_bridge_user *user) { /* Be sure we are muted so we can't talk to anybody else waiting */ user->features.mute = 1; /* Start music on hold if needed */ if (ast_test_flag(&user->u_profile, USER_OPT_MUSICONHOLD)) { conf_moh_start(user); } } void conf_default_join_waitmarked(struct conference_bridge_user *cbu) { conf_add_user_waiting(cbu->conference_bridge, cbu); conf_mute_moh_inactive_waitmarked(cbu); conf_add_post_join_action(cbu, conf_handle_inactive_waitmarked); } void conf_default_leave_waitmarked(struct conference_bridge_user *cbu) { conf_remove_user_waiting(cbu->conference_bridge, cbu); } void conf_change_state(struct conference_bridge_user *cbu, struct conference_state *newstate) { ast_debug(1, "Changing conference '%s' state from %s to %s\n", cbu->conference_bridge->name, cbu->conference_bridge->state->name, newstate->name); ast_test_suite_event_notify("CONF_CHANGE_STATE", "Conference: %s\r\nOldState: %s\r\nNewState: %s\r\n", cbu->conference_bridge->name, cbu->conference_bridge->state->name, newstate->name); if (cbu->conference_bridge->state->exit) { cbu->conference_bridge->state->exit(cbu); } cbu->conference_bridge->state = newstate; if (cbu->conference_bridge->state->entry) { cbu->conference_bridge->state->entry(cbu); } } asterisk-11.7.0/apps/confbridge/include/0000755000175000007640000000000012254071122020031 5ustar sharkyjerrywebasterisk-11.7.0/apps/confbridge/include/confbridge.h0000644000175000007640000004655712225063626022335 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2011, Digium, Inc. * * David Vossel * Joshua Colp * * 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. */ #ifndef _CONFBRIDGE_H #define _CONFBRIDGE_H #include "asterisk.h" #include "asterisk/app.h" #include "asterisk/logger.h" #include "asterisk/linkedlists.h" #include "asterisk/channel.h" #include "asterisk/bridging.h" #include "asterisk/bridging_features.h" #include "conf_state.h" /* Maximum length of a conference bridge name */ #define MAX_CONF_NAME 32 /* Maximum length of a conference pin */ #define MAX_PIN 80 #define DEFAULT_USER_PROFILE "default_user" #define DEFAULT_BRIDGE_PROFILE "default_bridge" #define DEFAULT_TALKING_THRESHOLD 160 #define DEFAULT_SILENCE_THRESHOLD 2500 enum user_profile_flags { USER_OPT_ADMIN = (1 << 0), /*!< Set if the caller is an administrator */ USER_OPT_NOONLYPERSON = (1 << 1), /*!< Set if the "you are currently the only person in this conference" sound file should not be played */ USER_OPT_MARKEDUSER = (1 << 2), /*!< Set if the caller is a marked user */ USER_OPT_STARTMUTED = (1 << 3), /*!< Set if the caller should be initially set muted */ USER_OPT_MUSICONHOLD = (1 << 4), /*!< Set if music on hold should be played if nobody else is in the conference bridge */ USER_OPT_QUIET = (1 << 5), /*!< Set if no audio prompts should be played */ USER_OPT_ANNOUNCEUSERCOUNT = (1 << 6), /*!< Set if the number of users should be announced to the caller */ USER_OPT_WAITMARKED = (1 << 7), /*!< Set if the user must wait for a marked user before starting */ USER_OPT_ENDMARKED = (1 << 8), /*!< Set if the user should be kicked after the last Marked user exits */ USER_OPT_DENOISE = (1 << 9), /*!< Sets if denoise filter should be used on audio before mixing. */ USER_OPT_ANNOUNCE_JOIN_LEAVE = (1 << 10), /*!< Sets if the user's name should be recorded and announced on join and leave. */ USER_OPT_TALKER_DETECT = (1 << 11), /*!< Sets if start and stop talking events should generated for this user over AMI. */ USER_OPT_DROP_SILENCE = (1 << 12), /*!< Sets if silence should be dropped from the mix or not. */ USER_OPT_DTMF_PASS = (1 << 13), /*!< Sets if dtmf should be passed into the conference or not */ USER_OPT_ANNOUNCEUSERCOUNTALL = (1 << 14), /*!< Sets if the number of users should be announced to everyone. */ USER_OPT_JITTERBUFFER = (1 << 15), /*!< Places a jitterbuffer on the user. */ }; enum bridge_profile_flags { BRIDGE_OPT_RECORD_CONFERENCE = (1 << 0), /*!< Set if the conference should be recorded */ BRIDGE_OPT_VIDEO_SRC_LAST_MARKED = (1 << 1), /*!< Set if conference should feed video of last marked user to all participants. */ BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED = (1 << 2), /*!< Set if conference should feed video of first marked user to all participants. */ BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER = (1 << 3), /*!< Set if conference set the video feed to follow the loudest talker. */ }; enum conf_menu_action_id { MENU_ACTION_TOGGLE_MUTE = 1, MENU_ACTION_PLAYBACK, MENU_ACTION_PLAYBACK_AND_CONTINUE, MENU_ACTION_INCREASE_LISTENING, MENU_ACTION_DECREASE_LISTENING, MENU_ACTION_RESET_LISTENING, MENU_ACTION_RESET_TALKING, MENU_ACTION_INCREASE_TALKING, MENU_ACTION_DECREASE_TALKING, MENU_ACTION_DIALPLAN_EXEC, MENU_ACTION_ADMIN_TOGGLE_LOCK, MENU_ACTION_ADMIN_KICK_LAST, MENU_ACTION_LEAVE, MENU_ACTION_NOOP, MENU_ACTION_SET_SINGLE_VIDEO_SRC, MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC, MENU_ACTION_PARTICIPANT_COUNT, MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS, }; /*! The conference menu action contains both * the action id that represents the action that * must take place, along with any data associated * with that action. */ struct conf_menu_action { enum conf_menu_action_id id; union { char playback_file[PATH_MAX]; struct { char context[AST_MAX_CONTEXT]; char exten[AST_MAX_EXTENSION]; int priority; } dialplan_args; } data; AST_LIST_ENTRY(conf_menu_action) action; }; /*! Conference menu entries contain the DTMF sequence * and the list of actions that are associated with that * sequence. */ struct conf_menu_entry { /*! the DTMF sequence that triggers the actions */ char dtmf[MAXIMUM_DTMF_FEATURE_STRING]; /*! The actions associated with this menu entry. */ AST_LIST_HEAD_NOLOCK(, conf_menu_action) actions; AST_LIST_ENTRY(conf_menu_entry) entry; }; /*! Conference menu structure. Contains a list * of DTMF sequences coupled with the actions those * sequences invoke.*/ struct conf_menu { char name[128]; AST_LIST_HEAD_NOLOCK(, conf_menu_entry) entries; }; struct user_profile { char name[128]; char pin[MAX_PIN]; char moh_class[128]; char announcement[PATH_MAX]; unsigned int flags; unsigned int announce_user_count_all_after; /*! The time in ms of talking before a user is considered to be talking by the dsp. */ unsigned int talking_threshold; /*! The time in ms of silence before a user is considered to be silent by the dsp. */ unsigned int silence_threshold; }; enum conf_sounds { CONF_SOUND_HAS_JOINED, CONF_SOUND_HAS_LEFT, CONF_SOUND_KICKED, CONF_SOUND_MUTED, CONF_SOUND_UNMUTED, CONF_SOUND_ONLY_ONE, CONF_SOUND_THERE_ARE, CONF_SOUND_OTHER_IN_PARTY, CONF_SOUND_PLACE_IN_CONF, CONF_SOUND_WAIT_FOR_LEADER, CONF_SOUND_LEADER_HAS_LEFT, CONF_SOUND_GET_PIN, CONF_SOUND_INVALID_PIN, CONF_SOUND_ONLY_PERSON, CONF_SOUND_LOCKED, CONF_SOUND_LOCKED_NOW, CONF_SOUND_UNLOCKED_NOW, CONF_SOUND_ERROR_MENU, CONF_SOUND_JOIN, CONF_SOUND_LEAVE, CONF_SOUND_PARTICIPANTS_MUTED, CONF_SOUND_PARTICIPANTS_UNMUTED, }; struct bridge_profile_sounds { AST_DECLARE_STRING_FIELDS( AST_STRING_FIELD(hasjoin); AST_STRING_FIELD(hasleft); AST_STRING_FIELD(kicked); AST_STRING_FIELD(muted); AST_STRING_FIELD(unmuted); AST_STRING_FIELD(onlyone); AST_STRING_FIELD(thereare); AST_STRING_FIELD(otherinparty); AST_STRING_FIELD(placeintoconf); AST_STRING_FIELD(waitforleader); AST_STRING_FIELD(leaderhasleft); AST_STRING_FIELD(getpin); AST_STRING_FIELD(invalidpin); AST_STRING_FIELD(onlyperson); AST_STRING_FIELD(locked); AST_STRING_FIELD(lockednow); AST_STRING_FIELD(unlockednow); AST_STRING_FIELD(errormenu); AST_STRING_FIELD(leave); AST_STRING_FIELD(join); AST_STRING_FIELD(participantsmuted); AST_STRING_FIELD(participantsunmuted); ); }; struct bridge_profile { char name[64]; char language[MAX_LANGUAGE]; /*!< Language used for playback_chan */ char rec_file[PATH_MAX]; unsigned int flags; unsigned int max_members; /*!< The maximum number of participants allowed in the conference */ unsigned int internal_sample_rate; /*!< The internal sample rate of the bridge. 0 when set to auto adjust mode. */ unsigned int mix_interval; /*!< The internal mixing interval used by the bridge. When set to 0 the bridgewill use a default interval. */ struct bridge_profile_sounds *sounds; }; /*! \brief The structure that represents a conference bridge */ struct conference_bridge { char name[MAX_CONF_NAME]; /*!< Name of the conference bridge */ struct conference_state *state; /*!< Conference state information */ struct ast_bridge *bridge; /*!< Bridge structure doing the mixing */ struct bridge_profile b_profile; /*!< The Bridge Configuration Profile */ unsigned int activeusers; /*!< Number of active users present */ unsigned int markedusers; /*!< Number of marked users present */ unsigned int waitingusers; /*!< Number of waiting users present */ unsigned int locked:1; /*!< Is this conference bridge locked? */ unsigned int muted:1; /*!< Is this conference bridge muted? */ unsigned int record_state:2; /*!< Whether recording is started, stopped, or should exit */ struct ast_channel *playback_chan; /*!< Channel used for playback into the conference bridge */ struct ast_channel *record_chan; /*!< Channel used for recording the conference */ pthread_t record_thread; /*!< The thread the recording chan lives in */ ast_mutex_t playback_lock; /*!< Lock used for playback channel */ ast_mutex_t record_lock; /*!< Lock used for the record thread */ ast_cond_t record_cond; /*!< Recording condition variable */ AST_LIST_HEAD_NOLOCK(, conference_bridge_user) active_list; /*!< List of users participating in the conference bridge */ AST_LIST_HEAD_NOLOCK(, conference_bridge_user) waiting_list; /*!< List of users waiting to join the conference bridge */ }; struct post_join_action { int (*func)(struct conference_bridge_user *); AST_LIST_ENTRY(post_join_action) list; }; /*! \brief The structure that represents a conference bridge user */ struct conference_bridge_user { struct conference_bridge *conference_bridge; /*!< Conference bridge they are participating in */ struct bridge_profile b_profile; /*!< The Bridge Configuration Profile */ struct user_profile u_profile; /*!< The User Configuration Profile */ char menu_name[64]; /*!< The name of the DTMF menu assigned to this user */ char name_rec_location[PATH_MAX]; /*!< Location of the User's name recorded file if it exists */ struct ast_channel *chan; /*!< Asterisk channel participating */ struct ast_bridge_features features; /*!< Bridge features structure */ struct ast_bridge_tech_optimizations tech_args; /*!< Bridge technology optimizations for talk detection */ unsigned int suspended_moh; /*!< Count of active suspended MOH actions. */ unsigned int kicked:1; /*!< User has been kicked from the conference */ unsigned int playing_moh:1; /*!< MOH is currently being played to the user */ AST_LIST_HEAD_NOLOCK(, post_join_action) post_join_list; /*!< List of sounds to play after joining */; AST_LIST_ENTRY(conference_bridge_user) list; /*!< Linked list information */ }; /*! \brief load confbridge.conf file */ int conf_load_config(void); /*! \brief reload confbridge.conf file */ int conf_reload_config(void); /*! \brief destroy the information loaded from the confbridge.conf file*/ void conf_destroy_config(void); /*! * \brief find a user profile given a user profile's name and store * that profile in result structure. * * \details This function first attempts to find any custom user * profile that might exist on a channel datastore, if that doesn't * exist it looks up the provided user profile name, if that doesn't * exist either the default_user profile is used. * \retval user profile on success * \retval NULL on failure */ const struct user_profile *conf_find_user_profile(struct ast_channel *chan, const char *user_profile_name, struct user_profile *result); /*! * \brief Find a bridge profile * * \details Any bridge profile found using this function must be * destroyed using conf_bridge_profile_destroy. This function first * attempts to find any custom bridge profile that might exist on * a channel datastore, if that doesn't exist it looks up the * provided bridge profile name, if that doesn't exist either * the default_bridge profile is used. * * \retval Bridge profile on success * \retval NULL on failure */ const struct bridge_profile *conf_find_bridge_profile(struct ast_channel *chan, const char *bridge_profile_name, struct bridge_profile *result); /*! * \brief Destroy a bridge profile found by 'conf_find_bridge_profile' */ void conf_bridge_profile_destroy(struct bridge_profile *b_profile); /*! * \brief copies a bridge profile * \note conf_bridge_profile_destroy must be called on the dst structure */ void conf_bridge_profile_copy(struct bridge_profile *dst, struct bridge_profile *src); /*! * \brief Set a DTMF menu to a conference user by menu name. * * \retval 0 on success, menu was found and set * \retval -1 on error, menu was not found */ int conf_set_menu_to_user(const char *menu_name, struct conference_bridge_user *conference_bridge_user); /*! * \brief Finds a menu_entry in a menu structure matched by DTMF sequence. * * \note the menu entry found must be destroyed using conf_menu_entry_destroy() * * \retval 1 success, entry is found and stored in result * \retval 0 failure, no entry found for given DTMF sequence */ int conf_find_menu_entry_by_sequence(const char *dtmf_sequence, struct conf_menu *menu, struct conf_menu_entry *result); /*! * \brief Destroys and frees all the actions stored in a menu_entry structure */ void conf_menu_entry_destroy(struct conf_menu_entry *menu_entry); /*! * \brief Once a DTMF sequence matches a sequence in the user's DTMF menu, this function will get * called to perform the menu action. * * \param bridge_channel, Bridged channel this is involving * \param conference_bridge_user, the conference user to perform the action on. * \param menu_entry, the menu entry that invoked this callback to occur. * \param menu, an AO2 referenced pointer to the entire menu structure the menu_entry * derived from. * * \note The menu_entry is a deep copy of the entry found in the menu structure. This allows * for the menu_entry to be accessed without requiring the menu lock. If the menu must * be accessed, the menu lock must be held. Reference counting of the menu structure is * handled outside of the scope of this function. * * \retval 0 success * \retval -1 failure */ int conf_handle_dtmf( struct ast_bridge_channel *bridge_channel, struct conference_bridge_user *conference_bridge_user, struct conf_menu_entry *menu_entry, struct conf_menu *menu); /*! \brief Looks to see if sound file is stored in bridge profile sounds, if not * default sound is provided.*/ const char *conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds); int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value); /*! * \brief Play sound file into conference bridge * * \param conference_bridge The conference bridge to play sound file into * \param filename Sound file to play * * \retval 0 success * \retval -1 failure */ int play_sound_file(struct conference_bridge *conference_bridge, const char *filename); /*! \brief Callback to be called when the conference has become empty * \param conference_bridge The conference bridge */ void conf_ended(struct conference_bridge *conference_bridge); /*! * \brief Stop MOH for the conference user. * * \param user Conference user to stop MOH on. * * \return Nothing */ void conf_moh_stop(struct conference_bridge_user *user); /*! * \brief Start MOH for the conference user. * * \param user Conference user to start MOH on. * * \return Nothing */ void conf_moh_start(struct conference_bridge_user *user); /*! \brief Attempt to mute/play MOH to the only user in the conference if they require it * \param conference_bridge A conference bridge containing a single user */ void conf_mute_only_active(struct conference_bridge *conference_bridge); /*! \brief Callback to execute any time we transition from zero to one marked users * \param cbu The first marked user joining the conference * \retval 0 success * \retval -1 failure */ int conf_handle_first_marked_common(struct conference_bridge_user *cbu); /*! \brief Callback to execute any time we transition from zero to one active users * \param conference_bridge The conference bridge with a single active user joined * \retval 0 success * \retval -1 failure */ void conf_handle_first_join(struct conference_bridge *conference_bridge); /*! \brief Handle actions every time a waitmarked user joins w/o a marked user present * \param cbu The waitmarked user * \retval 0 success * \retval -1 failure */ int conf_handle_inactive_waitmarked(struct conference_bridge_user *cbu); /*! \brief Handle actions whenever an unmarked user joins an inactive conference * \note These actions seem like they could apply just as well to a marked user * and possibly be made to happen any time transitioning to a single state. * * \param cbu The unmarked user */ int conf_handle_only_unmarked(struct conference_bridge_user *cbu); /*! \brief Handle when a conference moves to having more than one active participant * \param conference_bridge The conference bridge with more than one active participant */ void conf_handle_second_active(struct conference_bridge *conference_bridge); /*! \brief Add a conference bridge user as an unmarked active user of the conference * \param conference_bridge The conference bridge to add the user to * \param cbu The conference bridge user to add to the conference */ void conf_add_user_active(struct conference_bridge *conference_bridge, struct conference_bridge_user *cbu); /*! \brief Add a conference bridge user as a marked active user of the conference * \param conference_bridge The conference bridge to add the user to * \param cbu The conference bridge user to add to the conference */ void conf_add_user_marked(struct conference_bridge *conference_bridge, struct conference_bridge_user *cbu); /*! \brief Add a conference bridge user as an waiting user of the conference * \param conference_bridge The conference bridge to add the user to * \param cbu The conference bridge user to add to the conference */ void conf_add_user_waiting(struct conference_bridge *conference_bridge, struct conference_bridge_user *cbu); /*! \brief Remove a conference bridge user from the unmarked active conference users in the conference * \param conference_bridge The conference bridge to remove the user from * \param cbu The conference bridge user to remove from the conference */ void conf_remove_user_active(struct conference_bridge *conference_bridge, struct conference_bridge_user *cbu); /*! \brief Remove a conference bridge user from the marked active conference users in the conference * \param conference_bridge The conference bridge to remove the user from * \param cbu The conference bridge user to remove from the conference */ void conf_remove_user_marked(struct conference_bridge *conference_bridge, struct conference_bridge_user *cbu); /*! \brief Remove a conference bridge user from the waiting conference users in the conference * \param conference_bridge The conference bridge to remove the user from * \param cbu The conference bridge user to remove from the conference */ void conf_remove_user_waiting(struct conference_bridge *conference_bridge, struct conference_bridge_user *cbu); /*! \brief Queue a function to run with the given conference bridge user as an argument once the state transition is complete * \param cbu The conference bridge user to pass to the function * \param func The function to queue * \retval 0 success * \retval non-zero failure */ int conf_add_post_join_action(struct conference_bridge_user *cbu, int (*func)(struct conference_bridge_user *cbu)); #endif asterisk-11.7.0/apps/confbridge/include/conf_state.h0000644000175000007640000000711312034617656022347 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling * * \author\verbatim Terry Wilson \endverbatim * * See https://wiki.asterisk.org/wiki/display/AST/Confbridge+state+changes for * a more complete description of how conference states work. */ /*** MODULEINFO core ***/ #ifndef _CONF_STATE_H_ #define _CONF_STATE_H_ struct conference_state; struct conference_bridge; struct conference_bridge_user; typedef void (*conference_event_fn)(struct conference_bridge_user *cbu); typedef void (*conference_entry_fn)(struct conference_bridge_user *cbu); typedef void (*conference_exit_fn)(struct conference_bridge_user *cbu); /*! \brief A conference state object to hold the various state callback functions */ struct conference_state { const char *name; conference_event_fn join_unmarked; /*!< Handle an unmarked join event */ conference_event_fn join_waitmarked; /*!< Handle a waitmarked join event */ conference_event_fn join_marked; /*!< Handle a marked join event */ conference_event_fn leave_unmarked; /*!< Handle an unmarked leave event */ conference_event_fn leave_waitmarked; /*!< Handle a waitmarked leave event */ conference_event_fn leave_marked; /*!< Handle a marked leave event */ conference_entry_fn entry; /*!< Function to handle entry to a state */ conference_exit_fn exit; /*!< Function to handle exiting from a state */ }; /*! \brief Conference state with no active or waiting users */ extern struct conference_state *CONF_STATE_EMPTY; /*! \brief Conference state with only waiting users */ extern struct conference_state *CONF_STATE_INACTIVE; /*! \brief Conference state with only a single unmarked active user */ extern struct conference_state *CONF_STATE_SINGLE; /*! \brief Conference state with only a single marked active user */ extern struct conference_state *CONF_STATE_SINGLE_MARKED; /*! \brief Conference state with multiple active users, but no marked users */ extern struct conference_state *CONF_STATE_MULTI; /*! \brief Conference state with multiple active users and at least one marked user */ extern struct conference_state *CONF_STATE_MULTI_MARKED; /*! \brief Execute conference state transition because of a user action * \param cbu The user that joined/left * \param newstate The state to transition to */ void conf_change_state(struct conference_bridge_user *cbu, struct conference_state *newstate); /* Common event handlers shared between different states */ /*! \brief Logic to execute every time a waitmarked user joins an unmarked conference */ void conf_default_join_waitmarked(struct conference_bridge_user *cbu); /*! \brief Logic to execute every time a waitmarked user leaves an unmarked conference */ void conf_default_leave_waitmarked(struct conference_bridge_user *cbu); /*! \brief A handler for join/leave events that are invalid in a particular state */ void conf_invalid_event_fn(struct conference_bridge_user *cbu); #endif asterisk-11.7.0/apps/confbridge/conf_state_single_marked.c0000644000175000007640000000435312034617656023606 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling for the SINGLE_MARKED state * * \author\verbatim Terry Wilson \endverbatim * * \ingroup applications */ /*** MODULEINFO core ***/ #include "include/confbridge.h" #include "include/conf_state.h" static void join_active(struct conference_bridge_user *cbu); static void join_marked(struct conference_bridge_user *cbu); static void leave_marked(struct conference_bridge_user *cbu); static void transition_to_single_marked(struct conference_bridge_user *cbu); struct conference_state STATE_SINGLE_MARKED = { .name = "SINGLE_MARKED", .join_unmarked = join_active, .join_waitmarked = join_active, .join_marked = join_marked, .leave_marked = leave_marked, .entry = transition_to_single_marked, }; struct conference_state *CONF_STATE_SINGLE_MARKED = &STATE_SINGLE_MARKED; static void join_active(struct conference_bridge_user *cbu) { conf_add_user_active(cbu->conference_bridge, cbu); conf_handle_second_active(cbu->conference_bridge); conf_change_state(cbu, CONF_STATE_MULTI_MARKED); } static void join_marked(struct conference_bridge_user *cbu) { conf_add_user_marked(cbu->conference_bridge, cbu); conf_handle_second_active(cbu->conference_bridge); conf_change_state(cbu, CONF_STATE_MULTI_MARKED); } static void leave_marked(struct conference_bridge_user *cbu) { conf_remove_user_marked(cbu->conference_bridge, cbu); conf_change_state(cbu, CONF_STATE_EMPTY); } static void transition_to_single_marked(struct conference_bridge_user *cbu) { conf_mute_only_active(cbu->conference_bridge); } asterisk-11.7.0/apps/confbridge/conf_state_inactive.c0000644000175000007640000000437312034617656022606 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling for the INACTIVE state * * \author\verbatim Terry Wilson \endverbatim * * \ingroup applications */ /*** MODULEINFO core ***/ #include "include/confbridge.h" #include "include/conf_state.h" static void join_unmarked(struct conference_bridge_user *cbu); static void join_marked(struct conference_bridge_user *cbu); static void leave_waitmarked(struct conference_bridge_user *cbu); static void transition_to_inactive(struct conference_bridge_user *cbu); struct conference_state STATE_INACTIVE = { .name = "INACTIVE", .join_unmarked = join_unmarked, .join_waitmarked = conf_default_join_waitmarked, .join_marked = join_marked, .leave_waitmarked = leave_waitmarked, .entry = transition_to_inactive, }; struct conference_state *CONF_STATE_INACTIVE = &STATE_INACTIVE; static void join_unmarked(struct conference_bridge_user *cbu) { conf_add_user_active(cbu->conference_bridge, cbu); conf_add_post_join_action(cbu, conf_handle_only_unmarked); conf_change_state(cbu, CONF_STATE_SINGLE); } static void join_marked(struct conference_bridge_user *cbu) { conf_add_user_marked(cbu->conference_bridge, cbu); conf_handle_second_active(cbu->conference_bridge); conf_change_state(cbu, CONF_STATE_MULTI_MARKED); } static void leave_waitmarked(struct conference_bridge_user *cbu) { conf_remove_user_waiting(cbu->conference_bridge, cbu); if (cbu->conference_bridge->waitingusers == 0) { conf_change_state(cbu, CONF_STATE_EMPTY); } } static void transition_to_inactive(struct conference_bridge_user *cbu) { return; } asterisk-11.7.0/apps/confbridge/conf_state_multi_marked.c0000644000175000007640000001362612216063002023440 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling for the MULTI_MARKED state * * \author\verbatim Terry Wilson \endverbatim * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" #include "asterisk/utils.h" #include "asterisk/linkedlists.h" #include "include/confbridge.h" #include "asterisk/musiconhold.h" #include "include/conf_state.h" static void join_active(struct conference_bridge_user *cbu); static void join_marked(struct conference_bridge_user *cbu); static void leave_active(struct conference_bridge_user *cbu); static void leave_marked(struct conference_bridge_user *cbu); static void transition_to_marked(struct conference_bridge_user *cbu); static struct conference_state STATE_MULTI_MARKED = { .name = "MULTI_MARKED", .join_unmarked = join_active, .join_waitmarked = join_active, .join_marked = join_marked, .leave_unmarked = leave_active, .leave_waitmarked = leave_active, .leave_marked = leave_marked, .entry = transition_to_marked, }; struct conference_state *CONF_STATE_MULTI_MARKED = &STATE_MULTI_MARKED; static void join_active(struct conference_bridge_user *cbu) { conf_add_user_active(cbu->conference_bridge, cbu); } static void join_marked(struct conference_bridge_user *cbu) { conf_add_user_marked(cbu->conference_bridge, cbu); } static void leave_active(struct conference_bridge_user *cbu) { conf_remove_user_active(cbu->conference_bridge, cbu); if (cbu->conference_bridge->activeusers == 1) { conf_change_state(cbu, CONF_STATE_SINGLE_MARKED); } } static void leave_marked(struct conference_bridge_user *cbu) { struct conference_bridge_user *cbu_iter; conf_remove_user_marked(cbu->conference_bridge, cbu); if (cbu->conference_bridge->markedusers == 0) { /* Play back the audio prompt saying the leader has left the conference */ if (!ast_test_flag(&cbu->u_profile, USER_OPT_QUIET)) { ao2_unlock(cbu->conference_bridge); ast_autoservice_start(cbu->chan); play_sound_file(cbu->conference_bridge, conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, cbu->b_profile.sounds)); ast_autoservice_stop(cbu->chan); ao2_lock(cbu->conference_bridge); } AST_LIST_TRAVERSE_SAFE_BEGIN(&cbu->conference_bridge->active_list, cbu_iter, list) { /* Kick ENDMARKED cbu_iters */ if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_ENDMARKED)) { if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_WAITMARKED) && !ast_test_flag(&cbu_iter->u_profile, USER_OPT_MARKEDUSER)) { AST_LIST_REMOVE_CURRENT(list); cbu_iter->conference_bridge->activeusers--; AST_LIST_INSERT_TAIL(&cbu_iter->conference_bridge->waiting_list, cbu_iter, list); cbu_iter->conference_bridge->waitingusers++; } cbu_iter->kicked = 1; ast_bridge_remove(cbu_iter->conference_bridge->bridge, cbu_iter->chan); } else if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_WAITMARKED) && !ast_test_flag(&cbu_iter->u_profile, USER_OPT_MARKEDUSER)) { AST_LIST_REMOVE_CURRENT(list); cbu_iter->conference_bridge->activeusers--; AST_LIST_INSERT_TAIL(&cbu_iter->conference_bridge->waiting_list, cbu_iter, list); cbu_iter->conference_bridge->waitingusers++; /* Handle muting/moh of cbu_iter if necessary */ if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_MUSICONHOLD)) { cbu_iter->features.mute = 1; conf_moh_start(cbu_iter); } } } AST_LIST_TRAVERSE_SAFE_END; } switch (cbu->conference_bridge->activeusers) { case 0: /* Implies markedusers == 0 */ switch (cbu->conference_bridge->waitingusers) { case 0: conf_change_state(cbu, CONF_STATE_EMPTY); break; default: conf_change_state(cbu, CONF_STATE_INACTIVE); break; } break; case 1: switch (cbu->conference_bridge->markedusers) { case 0: conf_change_state(cbu, CONF_STATE_SINGLE); break; case 1: /* XXX I seem to remember doing this for a reason, but right now it escapes me * how we could possibly ever have a waiting user while we have a marked user */ switch (cbu->conference_bridge->waitingusers) { case 0: conf_change_state(cbu, CONF_STATE_SINGLE_MARKED); break; case 1: break; /* Stay in marked */ } break; } break; default: switch (cbu->conference_bridge->markedusers) { case 0: conf_change_state(cbu, CONF_STATE_MULTI); break; default: break; /* Stay in marked */ } } } static void transition_to_marked(struct conference_bridge_user *cbu) { struct conference_bridge_user *cbu_iter; /* Play the audio file stating they are going to be placed into the conference */ if (cbu->conference_bridge->markedusers == 1 && ast_test_flag(&cbu->u_profile, USER_OPT_MARKEDUSER)) { conf_handle_first_marked_common(cbu); } /* Move all waiting users to active, stopping MOH and umuting if necessary */ AST_LIST_TRAVERSE_SAFE_BEGIN(&cbu->conference_bridge->waiting_list, cbu_iter, list) { AST_LIST_REMOVE_CURRENT(list); cbu->conference_bridge->waitingusers--; AST_LIST_INSERT_TAIL(&cbu->conference_bridge->active_list, cbu_iter, list); cbu->conference_bridge->activeusers++; if (cbu_iter->playing_moh) { conf_moh_stop(cbu_iter); } /* only unmute them if they are not supposed to start muted */ if (!ast_test_flag(&cbu_iter->u_profile, USER_OPT_STARTMUTED)) { cbu_iter->features.mute = 0; } } AST_LIST_TRAVERSE_SAFE_END; } asterisk-11.7.0/apps/confbridge/conf_state_empty.c0000644000175000007640000000477112071073763022140 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling for the EMPTY state * * \author\verbatim Terry Wilson \endverbatim * * \ingroup applications */ /*** MODULEINFO core ***/ #include "asterisk.h" #include "asterisk/devicestate.h" #include "include/confbridge.h" #include "include/conf_state.h" static void join_unmarked(struct conference_bridge_user *cbu); static void join_waitmarked(struct conference_bridge_user *cbu); static void join_marked(struct conference_bridge_user *cbu); static void transition_to_empty(struct conference_bridge_user *cbu); struct conference_state STATE_EMPTY = { .name = "EMPTY", .join_unmarked = join_unmarked, .join_waitmarked = join_waitmarked, .join_marked = join_marked, .entry = transition_to_empty, }; struct conference_state *CONF_STATE_EMPTY = &STATE_EMPTY; static void join_unmarked(struct conference_bridge_user *cbu) { conf_add_user_active(cbu->conference_bridge, cbu); conf_handle_first_join(cbu->conference_bridge); conf_add_post_join_action(cbu, conf_handle_only_unmarked); conf_change_state(cbu, CONF_STATE_SINGLE); } static void join_waitmarked(struct conference_bridge_user *cbu) { conf_default_join_waitmarked(cbu); conf_handle_first_join(cbu->conference_bridge); conf_change_state(cbu, CONF_STATE_INACTIVE); } static void join_marked(struct conference_bridge_user *cbu) { conf_add_user_marked(cbu->conference_bridge, cbu); conf_handle_first_join(cbu->conference_bridge); conf_add_post_join_action(cbu, conf_handle_first_marked_common); conf_change_state(cbu, CONF_STATE_SINGLE_MARKED); } static void transition_to_empty(struct conference_bridge_user *cbu) { /* Set device state to "not in use" */ ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", cbu->conference_bridge->name); conf_ended(cbu->conference_bridge); } asterisk-11.7.0/apps/confbridge/conf_state_single.c0000644000175000007640000000455112034617656022263 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2012, Terry Wilson * * Terry Wilson * * 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. * * Please follow coding guidelines * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES */ /*! \file * * \brief Confbridge state handling for the SINGLE state * * \author\verbatim Terry Wilson \endverbatim * * \ingroup applications */ /*** MODULEINFO core ***/ #include "include/confbridge.h" #include "include/conf_state.h" static void join_unmarked(struct conference_bridge_user *cbu); static void join_marked(struct conference_bridge_user *cbu); static void leave_unmarked(struct conference_bridge_user *cbu); static void transition_to_single(struct conference_bridge_user *cbu); struct conference_state STATE_SINGLE = { .name = "SINGLE", .join_unmarked = join_unmarked, .join_waitmarked = conf_default_join_waitmarked, .join_marked = join_marked, .leave_unmarked = leave_unmarked, .leave_waitmarked = conf_default_leave_waitmarked, .entry = transition_to_single, }; struct conference_state *CONF_STATE_SINGLE = &STATE_SINGLE; static void join_unmarked(struct conference_bridge_user *cbu) { conf_add_user_active(cbu->conference_bridge, cbu); conf_handle_second_active(cbu->conference_bridge); conf_change_state(cbu, CONF_STATE_MULTI); } static void join_marked(struct conference_bridge_user *cbu) { conf_add_user_marked(cbu->conference_bridge, cbu); conf_handle_second_active(cbu->conference_bridge); conf_change_state(cbu, CONF_STATE_MULTI_MARKED); } static void leave_unmarked(struct conference_bridge_user *cbu) { conf_remove_user_active(cbu->conference_bridge, cbu); if (cbu->conference_bridge->waitingusers) { conf_change_state(cbu, CONF_STATE_INACTIVE); } else { conf_change_state(cbu, CONF_STATE_EMPTY); } } static void transition_to_single(struct conference_bridge_user *cbu) { conf_mute_only_active(cbu->conference_bridge); } asterisk-11.7.0/apps/app_queue.c0000644000175000007640000121677012231545667016471 0ustar sharkyjerryweb/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer * * 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 True call queues with optional send URL on answer * * \author Mark Spencer * * \arg Config in \ref Config_qu queues.conf * * \par Development notes * \note 2004-11-25: Persistent Dynamic Members added by: * NetNation Communications (www.netnation.com) * Kevin Lindsay * * Each dynamic agent in each queue is now stored in the astdb. * When asterisk is restarted, each agent will be automatically * readded into their recorded queues. This feature can be * configured with the 'persistent_members=<1|0>' setting in the * '[general]' category in queues.conf. The default is on. * * \note 2004-06-04: Priorities in queues added by inAccess Networks (work funded by Hellas On Line (HOL) www.hol.gr). * * \note These features added by David C. Troy : * - Per-queue holdtime calculation * - Estimated holdtime announcement * - Position announcement * - Abandoned/completed call counters * - Failout timer passed as optional app parameter * - Optional monitoring of calls, started when call is answered * * Patch Version 1.07 2003-12-24 01 * * Added servicelevel statistic by Michiel Betel * Added Priority jumping code for adding and removing queue members by Jonathan Stanton * * Fixed to work with CVS as of 2004-02-25 and released as 1.07a * by Matthew Enger * * \ingroup applications */ /*** MODULEINFO res_monitor core ***/ #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision: 401433 $") #include #include #include #include #include "asterisk/lock.h" #include "asterisk/file.h" #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/app.h" #include "asterisk/linkedlists.h" #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/say.h" #include "asterisk/features.h" #include "asterisk/musiconhold.h" #include "asterisk/cli.h" #include "asterisk/manager.h" #include "asterisk/config.h" #include "asterisk/monitor.h" #include "asterisk/utils.h" #include "asterisk/causes.h" #include "asterisk/astdb.h" #include "asterisk/devicestate.h" #include "asterisk/stringfields.h" #include "asterisk/event.h" #include "asterisk/astobj2.h" #include "asterisk/strings.h" #include "asterisk/global_datastores.h" #include "asterisk/taskprocessor.h" #include "asterisk/aoc.h" #include "asterisk/callerid.h" #include "asterisk/cel.h" #include "asterisk/data.h" /* Define, to debug reference counts on queues, without debugging reference counts on queue members */ /* #define REF_DEBUG_ONLY_QUEUES */ /*! * \par Please read before modifying this file. * There are three locks which are regularly used * throughout this file, the queue list lock, the lock * for each individual queue, and the interface list lock. * Please be extra careful to always lock in the following order * 1) queue list lock * 2) individual queue lock * 3) interface list lock * This order has sort of "evolved" over the lifetime of this * application, but it is now in place this way, so please adhere * to this order! */ /*** DOCUMENTATION Queue a call for a call queue. URL will be sent to the called party if the channel supports it. Will cause the queue to fail out after a specified number of seconds, checked between each queues.conf timeout and retry cycle. Will setup an AGI script to be executed on the calling party's channel once they are connected to a queue member. Will run a macro on the calling party's channel once they are connected to a queue member. Will run a gosub on the calling party's channel once they are connected to a queue member. Will cause the queue's defaultrule to be overridden by the rule specified. Attempt to enter the caller into the queue at the numerical position specified. 1 would attempt to enter the caller at the head of the queue, and 3 would attempt to place the caller third in the queue. In addition to transferring the call, a call may be parked and then picked up by another user. This application will return to the dialplan if the queue does not exist, or any of the join options cause the caller to not enter the queue. This application does not automatically answer and should be preceeded by an application such as Answer(), Progress(), or Ringing(). This application sets the following channel variable upon completion: The status of the call as a text string. Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Dynamically adds queue members. Dynamically adds interface to an existing queue. If the interface is already in the queue it will return an error. This application sets the following channel variable upon completion: The status of the attempt to add a queue member as a text string. Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Dynamically removes queue members. If the interface is NOT in the queue it will return an error. This application sets the following channel variable upon completion: Example: RemoveQueueMember(techsupport,SIP/3000) Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Pauses a queue member. Is used to add extra information to the appropriate queue_log entries and manager events. Pauses (blocks calls for) a queue member. The given interface will be paused in the given queue. This prevents any calls from being sent from the queue to the interface until it is unpaused with UnpauseQueueMember or the manager interface. If no queuename is given, the interface is paused in every queue it is a member of. The application will fail if the interface is not found. This application sets the following channel variable upon completion: The status of the attempt to pause a queue member as a text string. Example: PauseQueueMember(,SIP/3000) Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Unpauses a queue member. Is used to add extra information to the appropriate queue_log entries and manager events. Unpauses (resumes calls to) a queue member. This is the counterpart to PauseQueueMember() and operates exactly the same way, except it unpauses instead of pausing the given interface. This application sets the following channel variable upon completion: The status of the attempt to unpause a queue member as a text string. Example: UnpauseQueueMember(,SIP/3000) Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Writes to the queue_log file. Allows you to write your own events into the queue log. Example: QueueLog(101,${UNIQUEID},${AGENT},WENTONBREAK,600) Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Return Queue information in variables. Maxmimum number of calls allowed. The strategy of the queue. Number of calls currently in the queue. Current average hold time. Number of completed calls for the queue. Number of abandoned calls. Queue service level. Current service level performance. Makes the following queue variables available. Returns 0 if queue is found and setqueuevar is defined, -1 otherwise. Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Count number of members answering a queue. Returns the number of logged-in members for the specified queue. Returns the number of logged-in members for the specified queue that either can take calls or are currently wrapping up after a previous call. Returns the number of logged-in members for the specified queue that are immediately available to answer a call. Returns the total number of members for the specified queue. Gets or sets queue member penalty. Gets or sets queue member paused status. Gets or sets queue member ringinuse. Allows access to queue counts [R] and member information [R/W]. queuename is required for all operations interface is required for all member operations. Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Count number of members answering a queue. Returns the number of members currently associated with the specified queuename. This function has been deprecated in favor of the QUEUE_MEMBER() function Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Check if a named queue exists on this server Returns 1 if the specified queue exists, 0 if it does not Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Count number of calls currently waiting in a queue. Returns the number of callers currently waiting in the specified queuename. Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Returns a list of interfaces on a queue. Returns a comma-separated list of members associated with the specified queuename. Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Gets or sets queue members penalty. Gets or sets queue members penalty. This function has been deprecated in favor of the QUEUE_MEMBER() function Queue QueueLog AddQueueMember RemoveQueueMember PauseQueueMember UnpauseQueueMember QUEUE_VARIABLES QUEUE_MEMBER QUEUE_MEMBER_COUNT QUEUE_EXISTS QUEUE_WAITING_COUNT QUEUE_MEMBER_LIST QUEUE_MEMBER_PENALTY Queues. Show queue status. Show queue summary. Add interface to queue. Remove interface from queue. Makes a queue member temporarily unavailable. Adds custom entry in queue_log. Set the penalty for a queue member. Set the ringinuse value for a queue member. Queue Rules. Reload a queue, queues, or any sub-section of a queue or queues. Reset queue statistics. ***/ enum { OPT_MARK_AS_ANSWERED = (1 << 0), OPT_GO_ON = (1 << 1), OPT_DATA_QUALITY = (1 << 2), OPT_CALLEE_GO_ON = (1 << 3), OPT_CALLEE_HANGUP = (1 << 4), OPT_CALLER_HANGUP = (1 << 5), OPT_IGNORE_CALL_FW = (1 << 6), OPT_IGNORE_CONNECTEDLINE = (1 << 7), OPT_CALLEE_PARK = (1 << 8), OPT_CALLER_PARK = (1 << 9), OPT_NO_RETRY = (1 << 10), OPT_RINGING = (1 << 11), OPT_RING_WHEN_RINGING = (1 << 12), OPT_CALLEE_TRANSFER = (1 << 13), OPT_CALLER_TRANSFER = (1 << 14), OPT_CALLEE_AUTOMIXMON = (1 << 15), OPT_CALLER_AUTOMIXMON = (1 << 16), OPT_CALLEE_AUTOMON = (1 << 17), OPT_CALLER_AUTOMON = (1 << 18), }; enum { OPT_ARG_CALLEE_GO_ON = 0, /* note: this entry _MUST_ be the last one in the enum */ OPT_ARG_ARRAY_SIZE }; AST_APP_OPTIONS(queue_exec_options, BEGIN_OPTIONS AST_APP_OPTION('C', OPT_MARK_AS_ANSWERED), AST_APP_OPTION('c', OPT_GO_ON), AST_APP_OPTION('d', OPT_DATA_QUALITY), AST_APP_OPTION_ARG('F', OPT_CALLEE_GO_ON, OPT_ARG_CALLEE_GO_ON), AST_APP_OPTION('h', OPT_CALLEE_HANGUP), AST_APP_OPTION('H', OPT_CALLER_HANGUP), AST_APP_OPTION('i', OPT_IGNORE_CALL_FW), AST_APP_OPTION('I', OPT_IGNORE_CONNECTEDLINE), AST_APP_OPTION('k', OPT_CALLEE_PARK), AST_APP_OPTION('K', OPT_CALLER_PARK), AST_APP_OPTION('n', OPT_NO_RETRY), AST_APP_OPTION('r', OPT_RINGING), AST_APP_OPTION('R', OPT_RING_WHEN_RINGING), AST_APP_OPTION('t', OPT_CALLEE_TRANSFER), AST_APP_OPTION('T', OPT_CALLER_TRANSFER), AST_APP_OPTION('x', OPT_CALLEE_AUTOMIXMON), AST_APP_OPTION('X', OPT_CALLER_AUTOMIXMON), AST_APP_OPTION('w', OPT_CALLEE_AUTOMON), AST_APP_OPTION('W', OPT_CALLER_AUTOMON), END_OPTIONS); enum { QUEUE_STRATEGY_RINGALL = 0, QUEUE_STRATEGY_LEASTRECENT, QUEUE_STRATEGY_FEWESTCALLS, QUEUE_STRATEGY_RANDOM, QUEUE_STRATEGY_RRMEMORY, QUEUE_STRATEGY_LINEAR, QUEUE_STRATEGY_WRANDOM, QUEUE_STRATEGY_RRORDERED, }; enum { QUEUE_AUTOPAUSE_OFF = 0, QUEUE_AUTOPAUSE_ON, QUEUE_AUTOPAUSE_ALL }; enum queue_reload_mask { QUEUE_RELOAD_PARAMETERS = (1 << 0), QUEUE_RELOAD_MEMBER = (1 << 1), QUEUE_RELOAD_RULES = (1 << 2), QUEUE_RESET_STATS = (1 << 3), }; static const struct strategy { int strategy; const char *name; } strategies[] = { { QUEUE_STRATEGY_RINGALL, "ringall" }, { QUEUE_STRATEGY_LEASTRECENT, "leastrecent" }, { QUEUE_STRATEGY_FEWESTCALLS, "fewestcalls" }, { QUEUE_STRATEGY_RANDOM, "random" }, { QUEUE_STRATEGY_RRMEMORY, "rrmemory" }, { QUEUE_STRATEGY_RRMEMORY, "roundrobin" }, { QUEUE_STRATEGY_LINEAR, "linear" }, { QUEUE_STRATEGY_WRANDOM, "wrandom"}, { QUEUE_STRATEGY_RRORDERED, "rrordered"}, }; static const struct autopause { int autopause; const char *name; } autopausesmodes [] = { { QUEUE_AUTOPAUSE_OFF,"no" }, { QUEUE_AUTOPAUSE_ON, "yes" }, { QUEUE_AUTOPAUSE_ALL,"all" }, }; static struct ast_taskprocessor *devicestate_tps; #define DEFAULT_RETRY 5 #define DEFAULT_TIMEOUT 15 #define RECHECK 1 /*!< Recheck every second to see we we're at the top yet */ #define MAX_PERIODIC_ANNOUNCEMENTS 10 /*!< The maximum periodic announcements we can have */ #define DEFAULT_MIN_ANNOUNCE_FREQUENCY 15 /*!< The minimum number of seconds between position announcements \ The default value of 15 provides backwards compatibility */ #define MAX_QUEUE_BUCKETS 53 #define RES_OKAY 0 /*!< Action completed */ #define RES_EXISTS (-1) /*!< Entry already exists */ #define RES_OUTOFMEMORY (-2) /*!< Out of memory */ #define RES_NOSUCHQUEUE (-3) /*!< No such queue */ #define RES_NOT_DYNAMIC (-4) /*!< Member is not dynamic */ static char *app = "Queue"; static char *app_aqm = "AddQueueMember" ; static char *app_rqm = "RemoveQueueMember" ; static char *app_pqm = "PauseQueueMember" ; static char *app_upqm = "UnpauseQueueMember" ; static char *app_ql = "QueueLog" ; /*! \brief Persistent Members astdb family */ static const char * const pm_family = "Queue/PersistentMembers"; /*! \brief queues.conf [general] option */ static int queue_persistent_members = 0; /*! \brief queues.conf per-queue weight option */ static int use_weight = 0; /*! \brief queues.conf [general] option */ static int autofill_default = 1; /*! \brief queues.conf [general] option */ static int montype_default = 0; /*! \brief queues.conf [general] option */ static int shared_lastcall = 1; /*! \brief Subscription to device state change events */ static struct ast_event_sub *device_state_sub; /*! \brief queues.conf [general] option */ static int update_cdr = 0; /*! \brief queues.conf [general] option */ static int negative_penalty_invalid = 0; /*! \brief queues.conf [general] option */ static int log_membername_as_agent = 0; /*! \brief name of the ringinuse field in the realtime database */ static char *realtime_ringinuse_field; enum queue_result { QUEUE_UNKNOWN = 0, QUEUE_TIMEOUT = 1, QUEUE_JOINEMPTY = 2, QUEUE_LEAVEEMPTY = 3, QUEUE_JOINUNAVAIL = 4, QUEUE_LEAVEUNAVAIL = 5, QUEUE_FULL = 6, QUEUE_CONTINUE = 7, }; static const struct { enum queue_result id; char *text; } queue_results[] = { { QUEUE_UNKNOWN, "UNKNOWN" }, { QUEUE_TIMEOUT, "TIMEOUT" }, { QUEUE_JOINEMPTY,"JOINEMPTY" }, { QUEUE_LEAVEEMPTY, "LEAVEEMPTY" }, { QUEUE_JOINUNAVAIL, "JOINUNAVAIL" }, { QUEUE_LEAVEUNAVAIL, "LEAVEUNAVAIL" }, { QUEUE_FULL, "FULL" }, { QUEUE_CONTINUE, "CONTINUE" }, }; enum queue_timeout_priority { TIMEOUT_PRIORITY_APP, TIMEOUT_PRIORITY_CONF, }; /*! \brief We define a custom "local user" structure because we * use it not only for keeping track of what is in use but * also for keeping track of who we're dialing. * * There are two "links" defined in this structure, q_next and call_next. * q_next links ALL defined callattempt structures into a linked list. call_next is * a link which allows for a subset of the callattempts to be traversed. This subset * is used in wait_for_answer so that irrelevant callattempts are not traversed. This * also is helpful so that queue logs are always accurate in the case where a call to * a member times out, especially if using the ringall strategy. */ struct callattempt { struct callattempt *q_next; struct callattempt *call_next; struct ast_channel *chan; char interface[256]; /*!< An Asterisk dial string (not a channel name) */ int metric; time_t lastcall; struct call_queue *lastqueue; struct member *member; /*! Saved connected party info from an AST_CONTROL_CONNECTED_LINE. */ struct ast_party_connected_line connected; /*! TRUE if an AST_CONTROL_CONNECTED_LINE update was saved to the connected element. */ unsigned int pending_connected_update:1; /*! TRUE if the connected line update is blocked. */ unsigned int block_connected_update:1; /*! TRUE if caller id is not available for connected line */ unsigned int dial_callerid_absent:1; /*! TRUE if the call is still active */ unsigned int stillgoing:1; struct ast_aoc_decoded *aoc_s_rate_list; }; struct queue_ent { struct call_queue *parent; /*!< What queue is our parent */ char moh[MAX_MUSICCLASS]; /*!< Name of musiconhold to be used */ char announce[PATH_MAX]; /*!< Announcement to play for member when call is answered */ char context[AST_MAX_CONTEXT]; /*!< Context when user exits queue */ char digits[AST_MAX_EXTENSION]; /*!< Digits entered while in queue */ int valid_digits; /*!< Digits entered correspond to valid extension. Exited */ int pos; /*!< Where we are in the queue */ int prio; /*!< Our priority */ int last_pos_said; /*!< Last position we told the user */ int ring_when_ringing; /*!< Should we only use ring indication when a channel is ringing? */ time_t last_periodic_announce_time; /*!< The last time we played a periodic announcement */ int last_periodic_announce_sound; /*!< The last periodic announcement we made */ time_t last_pos; /*!< Last time we told the user their position */ int opos; /*!< Where we started in the queue */ int handled; /*!< Whether our call was handled */ int pending; /*!< Non-zero if we are attempting to call a member */ int max_penalty; /*!< Limit the members that can take this call to this penalty or lower */ int min_penalty; /*!< Limit the members that can take this call to this penalty or higher */ int linpos; /*!< If using linear strategy, what position are we at? */ int linwrapped; /*!< Is the linpos wrapped? */ time_t start; /*!< When we started holding */ time_t expire; /*!< When this entry should expire (time out of queue) */ int cancel_answered_elsewhere; /*!< Whether we should force the CAE flag on this call (C) option*/ struct ast_channel *chan; /*!< Our channel */ AST_LIST_HEAD_NOLOCK(,penalty_rule) qe_rules; /*!< Local copy of the queue's penalty rules */ struct penalty_rule *pr; /*!< Pointer to the next penalty rule to implement */ struct queue_ent *next; /*!< The next queue entry */ }; struct member { char interface[AST_CHANNEL_NAME]; /*!< Technology/Location to dial to reach this member*/ char state_exten[AST_MAX_EXTENSION]; /*!< Extension to get state from (if using hint) */ char state_context[AST_MAX_CONTEXT]; /*!< Context to use when getting state (if using hint) */ char state_interface[AST_CHANNEL_NAME]; /*!< Technology/Location from which to read devicestate changes */ char membername[80]; /*!< Member name to use in queue logs */ int penalty; /*!< Are we a last resort? */ int calls; /*!< Number of calls serviced by this member */ int dynamic; /*!< Are we dynamically added? */ int realtime; /*!< Is this member realtime? */ int status; /*!< Status of queue member */ int paused; /*!< Are we paused (not accepting calls)? */ int queuepos; /*!< In what order (pertains to certain strategies) should this member be called? */ time_t lastcall; /*!< When last successful call was hungup */ struct call_queue *lastqueue; /*!< Last queue we received a call */ unsigned int dead:1; /*!< Used to detect members deleted in realtime */ unsigned int delme:1; /*!< Flag to delete entry on reload */ unsigned int call_pending:1; /*!< TRUE if the Q is attempting to place a call to the member. */ char rt_uniqueid[80]; /*!< Unique id of realtime member entry */ unsigned int ringinuse:1; /*!< Flag to ring queue members even if their status is 'inuse' */ }; enum empty_conditions { QUEUE_EMPTY_PENALTY = (1 << 0), QUEUE_EMPTY_PAUSED = (1 << 1), QUEUE_EMPTY_INUSE = (1 << 2), QUEUE_EMPTY_RINGING = (1 << 3), QUEUE_EMPTY_UNAVAILABLE = (1 << 4), QUEUE_EMPTY_INVALID = (1 << 5), QUEUE_EMPTY_UNKNOWN = (1 << 6), QUEUE_EMPTY_WRAPUP = (1 << 7), }; enum member_properties { MEMBER_PENALTY = 0, MEMBER_RINGINUSE = 1, }; /* values used in multi-bit flags in call_queue */ #define ANNOUNCEHOLDTIME_ALWAYS 1 #define ANNOUNCEHOLDTIME_ONCE 2 #define QUEUE_EVENT_VARIABLES 3 struct penalty_rule { int time; /*!< Number of seconds that need to pass before applying this rule */ int max_value; /*!< The amount specified in the penalty rule for max penalty */ int min_value; /*!< The amount specified in the penalty rule for min penalty */ int max_relative; /*!< Is the max adjustment relative? 1 for relative, 0 for absolute */ int min_relative; /*!< Is the min adjustment relative? 1 for relative, 0 for absolute */ AST_LIST_ENTRY(penalty_rule) list; /*!< Next penalty_rule */ }; #define ANNOUNCEPOSITION_YES 1 /*!< We announce position */ #define ANNOUNCEPOSITION_NO 2 /*!< We don't announce position */ #define ANNOUNCEPOSITION_MORE_THAN 3 /*!< We say "Currently there are more than " */ #define ANNOUNCEPOSITION_LIMIT 4 /*!< We not announce position more than */ struct call_queue { AST_DECLARE_STRING_FIELDS( /*! Queue name */ AST_STRING_FIELD(name); /*! Music on Hold class */ AST_STRING_FIELD(moh); /*! Announcement to play when call is answered */ AST_STRING_FIELD(announce); /*! Exit context */ AST_STRING_FIELD(context); /*! Macro to run upon member connection */ AST_STRING_FIELD(membermacro); /*! Gosub to run upon member connection */ AST_STRING_FIELD(membergosub); /*! Default rule to use if none specified in call to Queue() */ AST_STRING_FIELD(defaultrule); /*! Sound file: "Your call is now first in line" (def. queue-youarenext) */ AST_STRING_FIELD(sound_next); /*! Sound file: "There are currently" (def. queue-thereare) */ AST_STRING_FIELD(sound_thereare); /*! Sound file: "calls waiting to speak to a representative." (def. queue-callswaiting) */ AST_STRING_FIELD(sound_calls); /*! Sound file: "Currently there are more than" (def. queue-quantity1) */ AST_STRING_FIELD(queue_quantity1); /*! Sound file: "callers waiting to speak with a representative" (def. queue-quantity2) */ AST_STRING_FIELD(queue_quantity2); /*! Sound file: "The current estimated total holdtime is" (def. queue-holdtime) */ AST_STRING_FIELD(sound_holdtime); /*! Sound file: "minutes." (def. queue-minutes) */ AST_STRING_FIELD(sound_minutes); /*! Sound file: "minute." (def. queue-minute) */ AST_STRING_FIELD(sound_minute); /*! Sound file: "seconds." (def. queue-seconds) */ AST_STRING_FIELD(sound_seconds); /*! Sound file: "Thank you for your patience." (def. queue-thankyou) */ AST_STRING_FIELD(sound_thanks); /*! Sound file: Custom announce for caller, no default */ AST_STRING_FIELD(sound_callerannounce); /*! Sound file: "Hold time" (def. queue-reporthold) */ AST_STRING_FIELD(sound_reporthold); ); /*! Sound files: Custom announce, no default */ struct ast_str *sound_periodicannounce[MAX_PERIODIC_ANNOUNCEMENTS]; unsigned int dead:1; unsigned int eventwhencalled:2; unsigned int ringinuse:1; unsigned int announce_to_first_user:1; /*!< Whether or not we announce to the first user in a queue */ unsigned int setinterfacevar:1; unsigned int setqueuevar:1; unsigned int setqueueentryvar:1; unsigned int reportholdtime:1; unsigned int wrapped:1; unsigned int timeoutrestart:1; unsigned int announceholdtime:2; unsigned int announceposition:3; int strategy:4; unsigned int maskmemberstatus:1; unsigned int realtime:1; unsigned int found:1; unsigned int relativeperiodicannounce:1; unsigned int autopausebusy:1; unsigned int autopauseunavail:1; enum empty_conditions joinempty; enum empty_conditions leavewhenempty; int announcepositionlimit; /*!< How many positions we announce? */ int announcefrequency; /*!< How often to announce their position */ int minannouncefrequency; /*!< The minimum number of seconds between position announcements (def. 15) */ int periodicannouncefrequency; /*!< How often to play periodic announcement */ int numperiodicannounce; /*!< The number of periodic announcements configured */ int randomperiodicannounce; /*!< Are periodic announcments randomly chosen */ int roundingseconds; /*!< How many seconds do we round to? */ int holdtime; /*!< Current avg holdtime, based on an exponential average */ int talktime; /*!< Current avg talktime, based on the same exponential average */ int callscompleted; /*!< Number of queue calls completed */ int callsabandoned; /*!< Number of queue calls abandoned */ int servicelevel; /*!< seconds setting for servicelevel*/ int callscompletedinsl; /*!< Number of calls answered with servicelevel*/ char monfmt[8]; /*!< Format to use when recording calls */ int montype; /*!< Monitor type Monitor vs. MixMonitor */ int count; /*!< How many entries */ int maxlen; /*!< Max number of entries */ int wrapuptime; /*!< Wrapup Time */ int penaltymemberslimit; /*!< Disregard penalty when queue has fewer than this many members */ int retry; /*!< Retry calling everyone after this amount of time */ int timeout; /*!< How long to wait for an answer */ int weight; /*!< Respective weight */ int autopause; /*!< Auto pause queue members if they fail to answer */ int autopausedelay; /*!< Delay auto pause for autopausedelay seconds since last call */ int timeoutpriority; /*!< Do we allow a fraction of the timeout to occur for a ring? */ /* Queue strategy things */ int rrpos; /*!< Round Robin - position */ int memberdelay; /*!< Seconds to delay connecting member to caller */ int autofill; /*!< Ignore the head call status and ring an available agent */ struct ao2_container *members; /*!< Head of the list of members */ struct queue_ent *head; /*!< Head of the list of callers */ AST_LIST_ENTRY(call_queue) list; /*!< Next call queue */ AST_LIST_HEAD_NOLOCK(, penalty_rule) rules; /*!< The list of penalty rules to invoke */ }; struct rule_list { char name[80]; AST_LIST_HEAD_NOLOCK(,penalty_rule) rules; AST_LIST_ENTRY(rule_list) list; }; static AST_LIST_HEAD_STATIC(rule_lists, rule_list); static struct ao2_container *queues; static void update_realtime_members(struct call_queue *q); static struct member *interface_exists(struct call_queue *q, const char *interface); static int set_member_paused(const char *queuename, const char *interface, const char *reason, int paused); static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan); static struct member *find_member_by_queuename_and_interface(const char *queuename, const char *interface); /*! \brief sets the QUEUESTATUS channel variable */ static void set_queue_result(struct ast_channel *chan, enum queue_result res) { int i; for (i = 0; i < ARRAY_LEN(queue_results); i++) { if (queue_results[i].id == res) { pbx_builtin_setvar_helper(chan, "QUEUESTATUS", queue_results[i].text); return; } } } static const char *int2strat(int strategy) { int x; for (x = 0; x < ARRAY_LEN(strategies); x++) { if (strategy == strategies[x].strategy) { return strategies[x].name; } } return ""; } static int strat2int(const char *strategy) { int x; for (x = 0; x < ARRAY_LEN(strategies); x++) { if (!strcasecmp(strategy, strategies[x].name)) { return strategies[x].strategy; } } return -1; } static int autopause2int(const char *autopause) { int x; /*This 'double check' that default value is OFF */ if (ast_strlen_zero(autopause)) { return QUEUE_AUTOPAUSE_OFF; } /*This 'double check' is to ensure old values works */ if(ast_true(autopause)) { return QUEUE_AUTOPAUSE_ON; } for (x = 0; x < ARRAY_LEN(autopausesmodes); x++) { if (!strcasecmp(autopause, autopausesmodes[x].name)) { return autopausesmodes[x].autopause; } } /*This 'double check' that default value is OFF */ return QUEUE_AUTOPAUSE_OFF; } static int queue_hash_cb(const void *obj, const int flags) { const struct call_queue *q = obj; return ast_str_case_hash(q->name); } static int queue_cmp_cb(void *obj, void *arg, int flags) { struct call_queue *q = obj, *q2 = arg; return !strcasecmp(q->name, q2->name) ? CMP_MATCH | CMP_STOP : 0; } /*! \internal * \brief ao2_callback, Decreases queuepos of all followers with a queuepos greater than arg. * \param obj the member being acted on * \param arg pointer to an integer containing the position value that was removed and requires reduction for anything above */ static int queue_member_decrement_followers(void *obj, void *arg, int flag) { struct member *mem = obj; int *decrement_followers_after = arg; if (mem->queuepos > *decrement_followers_after) { mem->queuepos--; } return 0; } /*! \internal * \brief ao2_callback, finds members in a queue marked for deletion and in a cascading fashion runs queue_member_decrement_followers * on them. This callback should always be ran before performing mass unlinking of delmarked members from queues. * \param obj member being acted on * \param arg pointer to the queue members are being removed from */ static int queue_delme_members_decrement_followers(void *obj, void *arg, int flag) { struct member *mem = obj; struct call_queue *queue = arg; int rrpos = mem->queuepos; if (mem->delme) { ao2_callback(queue->members, OBJ_NODATA | OBJ_MULTIPLE, queue_member_decrement_followers, &rrpos); } return 0; } /*! \internal * \brief Use this to decrement followers during removal of a member * \param queue which queue the member is being removed from * \param mem which member is being removed from the queue */ static void queue_member_follower_removal(struct call_queue *queue, struct member *mem) { int pos = mem->queuepos; /* If the position being removed is less than the current place in the queue, reduce the queue position by one so that we don't skip the member * who would have been next otherwise. */ if (pos < queue->rrpos) { queue->rrpos--; } ao2_callback(queue->members, OBJ_NODATA | OBJ_MULTIPLE, queue_member_decrement_followers, &pos); } #ifdef REF_DEBUG_ONLY_QUEUES #define queue_ref(q) _queue_ref(q, "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #define queue_unref(q) _queue_unref(q, "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #define queue_t_ref(q, tag) _queue_ref(q, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) #define queue_t_unref(q, tag) _queue_unref(q, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) #define queues_t_link(c, q, tag) __ao2_link_debug(c, q, 0, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) #define queues_t_unlink(c, q, tag) __ao2_unlink_debug(c, q, 0, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) static inline struct call_queue *_queue_ref(struct call_queue *q, const char *tag, const char *file, int line, const char *filename) { __ao2_ref_debug(q, 1, tag, file, line, filename); return q; } static inline struct call_queue *_queue_unref(struct call_queue *q, const char *tag, const char *file, int line, const char *filename) { __ao2_ref_debug(q, -1, tag, file, line, filename); return NULL; } #else #define queue_t_ref(q, tag) queue_ref(q) #define queue_t_unref(q, tag) queue_unref(q) #define queues_t_link(c, q, tag) ao2_t_link(c, q, tag) #define queues_t_unlink(c, q, tag) ao2_t_unlink(c, q, tag) static inline struct call_queue *queue_ref(struct call_queue *q) { ao2_ref(q, 1); return q; } static inline struct call_queue *queue_unref(struct call_queue *q) { ao2_ref(q, -1); return NULL; } #endif /*! \brief Set variables of queue */ static void set_queue_variables(struct call_queue *q, struct ast_channel *chan) { char interfacevar[256]=""; float sl = 0; ao2_lock(q); if (q->setqueuevar) { sl = 0; if (q->callscompleted > 0) { sl = 100 * ((float) q->callscompletedinsl / (float) q->callscompleted); } snprintf(interfacevar, sizeof(interfacevar), "QUEUENAME=%s,QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUETALKTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, q->callsabandoned, q->servicelevel, sl); ao2_unlock(q); pbx_builtin_setvar_multiple(chan, interfacevar); } else { ao2_unlock(q); } } /*! \brief Insert the 'new' entry after the 'prev' entry of queue 'q' */ static inline void insert_entry(struct call_queue *q, struct queue_ent *prev, struct queue_ent *new, int *pos) { struct queue_ent *cur; if (!q || !new) return; if (prev) { cur = prev->next; prev->next = new; } else { cur = q->head; q->head = new; } new->next = cur; /* every queue_ent must have a reference to it's parent call_queue, this * reference does not go away until the end of the queue_ent's life, meaning * that even when the queue_ent leaves the call_queue this ref must remain. */ queue_ref(q); new->parent = q; new->pos = ++(*pos); new->opos = *pos; } /*! \brief Check if members are available * * This function checks to see if members are available to be called. If any member * is available, the function immediately returns 0. If no members are available, * then -1 is returned. */ static int get_member_status(struct call_queue *q, int max_penalty, int min_penalty, enum empty_conditions conditions) { struct member *member; struct ao2_iterator mem_iter; ao2_lock(q); mem_iter = ao2_iterator_init(q->members, 0); for (; (member = ao2_iterator_next(&mem_iter)); ao2_ref(member, -1)) { if ((max_penalty && (member->penalty > max_penalty)) || (min_penalty && (member->penalty < min_penalty))) { if (conditions & QUEUE_EMPTY_PENALTY) { ast_debug(4, "%s is unavailable because his penalty is not between %d and %d\n", member->membername, min_penalty, max_penalty); continue; } } switch (member->status) { case AST_DEVICE_INVALID: if (conditions & QUEUE_EMPTY_INVALID) { ast_debug(4, "%s is unavailable because his device state is 'invalid'\n", member->membername); break; } goto default_case; case AST_DEVICE_UNAVAILABLE: if (conditions & QUEUE_EMPTY_UNAVAILABLE) { ast_debug(4, "%s is unavailable because his device state is 'unavailable'\n", member->membername); break; } goto default_case; case AST_DEVICE_INUSE: if (conditions & QUEUE_EMPTY_INUSE) { ast_debug(4, "%s is unavailable because his device state is 'inuse'\n", member->membername); break; } goto default_case; case AST_DEVICE_RINGING: if (conditions & QUEUE_EMPTY_RINGING) { ast_debug(4, "%s is unavailable because his device state is 'ringing'\n", member->membername); break; } goto default_case; case AST_DEVICE_UNKNOWN: if (conditions & QUEUE_EMPTY_UNKNOWN) { ast_debug(4, "%s is unavailable because his device state is 'unknown'\n", member->membername); break; } /* Fall-through */ default: default_case: if (member->paused && (conditions & QUEUE_EMPTY_PAUSED)) { ast_debug(4, "%s is unavailable because he is paused'\n", member->membername); break; } else if ((conditions & QUEUE_EMPTY_WRAPUP) && member->lastcall && q->wrapuptime && (time(NULL) - q->wrapuptime < member->lastcall)) { ast_debug(4, "%s is unavailable because it has only been %d seconds since his last call (wrapup time is %d)\n", member->membername, (int) (time(NULL) - member->lastcall), q->wrapuptime); break; } else { ao2_ref(member, -1); ao2_iterator_destroy(&mem_iter); ao2_unlock(q); ast_debug(4, "%s is available.\n", member->membername); return 0; } break; } } ao2_iterator_destroy(&mem_iter); ao2_unlock(q); return -1; } struct statechange { AST_LIST_ENTRY(statechange) entry; int state; char dev[0]; }; /*! \brief set a member's status based on device state of that member's state_interface. * * Lock interface list find sc, iterate through each queues queue_member list for member to * update state inside queues */ static int update_status(struct call_queue *q, struct member *m, const int status) { m->status = status; if (q->maskmemberstatus) { return 0; } /*** DOCUMENTATION Raised when a Queue member's status has changed. The name of the queue. The queue member's channel technology or location. The name of the queue member. Channel technology or location from which to read device state changes. The penalty associated with the queue member. The number of calls this queue member has serviced. The time this member last took call, expressed in seconds since 00:00, Jan 1, 1970 UTC. The numeric device state status of the queue member. AST_DEVICE_UNKNOWN AST_DEVICE_NOT_INUSE AST_DEVICE_INUSE AST_DEVICE_BUSY AST_DEVICE_INVALID AST_DEVICE_UNAVAILABLE AST_DEVICE_RINGING AST_DEVICE_RINGINUSE AST_DEVICE_ONHOLD ***/ manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus", "Queue: %s\r\n" "Location: %s\r\n" "MemberName: %s\r\n" "StateInterface: %s\r\n" "Membership: %s\r\n" "Penalty: %d\r\n" "CallsTaken: %d\r\n" "LastCall: %d\r\n" "Status: %d\r\n" "Paused: %d\r\n", q->name, m->interface, m->membername, m->state_interface, m->dynamic ? "dynamic" : m->realtime ? "realtime" : "static", m->penalty, m->calls, (int)m->lastcall, m->status, m->paused ); return 0; } /*! * \internal \brief Determine if a queue member is available * \retval 1 if the member is available * \retval 0 if the member is not available */ static int is_member_available(struct call_queue *q, struct member *mem) { int available = 0; switch (mem->status) { case AST_DEVICE_INVALID: case AST_DEVICE_UNAVAILABLE: break; case AST_DEVICE_INUSE: case AST_DEVICE_BUSY: case AST_DEVICE_RINGING: case AST_DEVICE_RINGINUSE: case AST_DEVICE_ONHOLD: if (!mem->ringinuse) { break; } /* else fall through */ case AST_DEVICE_NOT_INUSE: case AST_DEVICE_UNKNOWN: if (!mem->paused) { available = 1; } break; } /* Let wrapuptimes override device state availability */ if (mem->lastcall && q->wrapuptime && (time(NULL) - q->wrapuptime < mem->lastcall)) { available = 0; } return available; } /*! \brief set a member's status based on device state of that member's interface*/ static int handle_statechange(void *datap) { struct statechange *sc = datap; struct ao2_iterator miter, qiter; struct member *m; struct call_queue *q; char interface[80], *slash_pos; int found = 0; /* Found this member in any queue */ int found_member; /* Found this member in this queue */ int avail = 0; /* Found an available member in this queue */ qiter = ao2_iterator_init(queues, 0); while ((q = ao2_t_iterator_next(&qiter, "Iterate over queues"))) { ao2_lock(q); avail = 0; found_member = 0; miter = ao2_iterator_init(q->members, 0); for (; (m = ao2_iterator_next(&miter)); ao2_ref(m, -1)) { if (!found_member) { ast_copy_string(interface, m->state_interface, sizeof(interface)); if ((slash_pos = strchr(interface, '/'))) { if (!strncasecmp(interface, "Local/", 6) && (slash_pos = strchr(slash_pos + 1, '/'))) { *slash_pos = '\0'; } } if (!strcasecmp(interface, sc->dev)) { found_member = 1; update_status(q, m, sc->state); } } /* check every member until we find one NOT_INUSE */ if (!avail) { avail = is_member_available(q, m); } if (avail && found_member) { /* early exit as we've found an available member and the member of interest */ ao2_ref(m, -1); break; } } if (found_member) { found = 1; if (avail) { ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name); } else { ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name); } } ao2_iterator_destroy(&miter); ao2_unlock(q); queue_t_unref(q, "Done with iterator"); } ao2_iterator_destroy(&qiter); if (found) { ast_debug(1, "Device '%s' changed to state '%d' (%s)\n", sc->dev, sc->state, ast_devstate2str(sc->state)); } else { ast_debug(3, "Device '%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", sc->dev, sc->state, ast_devstate2str(sc->state)); } ast_free(sc); return 0; } static void device_state_cb(const struct ast_event *event, void *unused) { enum ast_device_state state; const char *device; struct statechange *sc; size_t datapsize; state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE); device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE); if (ast_strlen_zero(device)) { ast_log(LOG_ERROR, "Received invalid event that had no device IE\n"); return; } datapsize = sizeof(*sc) + strlen(device) + 1; if (!(sc = ast_calloc(1, datapsize))) { ast_log(LOG_ERROR, "failed to calloc a state change struct\n"); return; } sc->state = state; strcpy(sc->dev, device); if (ast_taskprocessor_push(devicestate_tps, handle_statechange, sc) < 0) { ast_free(sc); } } /*! \brief Helper function which converts from extension state to device state values */ static int extensionstate2devicestate(int state) { switch (state) { case AST_EXTENSION_NOT_INUSE: state = AST_DEVICE_NOT_INUSE; break; case AST_EXTENSION_INUSE: state = AST_DEVICE_INUSE; break; case AST_EXTENSION_BUSY: state = AST_DEVICE_BUSY; break; case AST_EXTENSION_RINGING: state = AST_DEVICE_RINGING; break; case AST_EXTENSION_ONHOLD: state = AST_DEVICE_ONHOLD; break; case AST_EXTENSION_UNAVAILABLE: state = AST_DEVICE_UNAVAILABLE; break; case AST_EXTENSION_REMOVED: case AST_EXTENSION_DEACTIVATED: default: state = AST_DEVICE_INVALID; break; } return state; } static int extension_state_cb(char *context, char *exten, struct ast_state_cb_info *info, void *data) { struct ao2_iterator miter, qiter; struct member *m; struct call_queue *q; int state = info->exten_state; int found = 0, device_state = extensionstate2devicestate(state); /* only interested in extension state updates involving device states */ if (info->reason != AST_HINT_UPDATE_DEVICE) { return 0; } qiter = ao2_iterator_init(queues, 0); while ((q = ao2_t_iterator_next(&qiter, "Iterate through queues"))) { ao2_lock(q); miter = ao2_iterator_init(q->members, 0); for (; (m = ao2_iterator_next(&miter)); ao2_ref(m, -1)) { if (!strcmp(m->state_context, context) && !strcmp(m->state_exten, exten)) { update_status(q, m, device_state); ao2_ref(m, -1); found = 1; break; } } ao2_iterator_destroy(&miter); ao2_unlock(q); queue_t_unref(q, "Done with iterator"); } ao2_iterator_destroy(&qiter); if (found) { ast_debug(1, "Extension '%s@%s' changed to state '%d' (%s)\n", exten, context, device_state, ast_devstate2str(device_state)); } else { ast_debug(3, "Extension '%s@%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", exten, context, device_state, ast_devstate2str(device_state)); } return 0; } /*! \brief Return the current state of a member */ static int get_queue_member_status(struct member *cur) { return ast_strlen_zero(cur->state_exten) ? ast_device_state(cur->state_interface) : extensionstate2devicestate(ast_extension_state(NULL, cur->state_context, cur->state_exten)); } /*! \brief allocate space for new queue member and set fields based on parameters passed */ static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface, int ringinuse) { struct member *cur; if ((cur = ao2_alloc(sizeof(*cur), NULL))) { cur->ringinuse = ringinuse; cur->penalty = penalty; cur->paused = paused; ast_copy_string(cur->interface, interface, sizeof(cur->interface)); if (!ast_strlen_zero(state_interface)) { ast_copy_string(cur->state_interface, state_interface, sizeof(cur->state_interface)); } else { ast_copy_string(cur->state_interface, interface, sizeof(cur->state_interface)); } if (!ast_strlen_zero(membername)) { ast_copy_string(cur->membername, membername, sizeof(cur->membername)); } else { ast_copy_string(cur->membername, interface, sizeof(cur->membername)); } if (!strchr(cur->interface, '/')) { ast_log(LOG_WARNING, "No location at interface '%s'\n", interface); } if (!strncmp(cur->state_interface, "hint:", 5)) { char *tmp = ast_strdupa(cur->state_interface), *context = tmp; char *exten = strsep(&context, "@") + 5; ast_copy_string(cur->state_exten, exten, sizeof(cur->state_exten)); ast_copy_string(cur->state_context, S_OR(context, "default"), sizeof(cur->state_context)); } cur->status = get_queue_member_status(cur); } return cur; } static int compress_char(const char c) { if (c < 32) { return 0; } else if (c > 96) { return c - 64; } return c - 32; } static int member_hash_fn(const void *obj, const int flags) { const struct member *mem = obj; const char *interface = (flags & OBJ_KEY) ? obj : mem->interface; const char *chname = strchr(interface, '/'); int ret = 0, i; if (!chname) { chname = interface; } for (i = 0; i < 5 && chname[i]; i++) { ret += compress_char(chname[i]) << (i * 6); } return ret; } static int member_cmp_fn(void *obj1, void *obj2, int flags) { struct member *mem1 = obj1; struct member *mem2 = obj2; const char *interface = (flags & OBJ_KEY) ? obj2 : mem2->interface; return strcasecmp(mem1->interface, interface) ? 0 : CMP_MATCH | CMP_STOP; } /*! * \brief Initialize Queue default values. * \note the queue's lock must be held before executing this function */ static void init_queue(struct call_queue *q) { int i; struct penalty_rule *pr_iter; q->dead = 0; q->retry = DEFAULT_RETRY; q->timeout = DEFAULT_TIMEOUT; q->maxlen = 0; q->announcefrequency = 0; q->minannouncefrequency = DEFAULT_MIN_ANNOUNCE_FREQUENCY; q->announceholdtime = 1; q->announcepositionlimit = 10; /* Default 10 positions */ q->announceposition = ANNOUNCEPOSITION_YES; /* Default yes */ q->roundingseconds = 0; /* Default - don't announce seconds */ q->servicelevel = 0; q->ringinuse = 1; q->announce_to_first_user = 0; q->setinterfacevar = 0; q->setqueuevar = 0; q->setqueueentryvar = 0; q->autofill = autofill_default; q->montype = montype_default; q->monfmt[0] = '\0'; q->reportholdtime = 0; q->wrapuptime = 0; q->penaltymemberslimit = 0; q->joinempty = 0; q->leavewhenempty = 0; q->memberdelay = 0; q->maskmemberstatus = 0; q->eventwhencalled = 0; q->weight = 0; q->timeoutrestart = 0; q->periodicannouncefrequency = 0; q->randomperiodicannounce = 0; q->numperiodicannounce = 0; q->autopause = QUEUE_AUTOPAUSE_OFF; q->timeoutpriority = TIMEOUT_PRIORITY_APP; q->autopausedelay = 0; if (!q->members) { if (q->strategy == QUEUE_STRATEGY_LINEAR || q->strategy == QUEUE_STRATEGY_RRORDERED) { /* linear strategy depends on order, so we have to place all members in a single bucket */ q->members = ao2_container_alloc(1, member_hash_fn, member_cmp_fn); } else { q->members = ao2_container_alloc(37, member_hash_fn, member_cmp_fn); } } q->found = 1; ast_string_field_set(q, sound_next, "queue-youarenext"); ast_string_field_set(q, sound_thereare, "queue-thereare"); ast_string_field_set(q, sound_calls, "queue-callswaiting"); ast_string_field_set(q, queue_quantity1, "queue-quantity1"); ast_string_field_set(q, queue_quantity2, "queue-quantity2"); ast_string_field_set(q, sound_holdtime, "queue-holdtime"); ast_string_field_set(q, sound_minutes, "queue-minutes"); ast_string_field_set(q, sound_minute, "queue-minute"); ast_string_field_set(q, sound_seconds, "queue-seconds"); ast_string_field_set(q, sound_thanks, "queue-thankyou"); ast_string_field_set(q, sound_reporthold, "queue-reporthold"); if (!q->sound_periodicannounce[0]) { q->sound_periodicannounce[0] = ast_str_create(32); } if (q->sound_periodicannounce[0]) { ast_str_set(&q->sound_periodicannounce[0], 0, "queue-periodic-announce"); } for (i = 1; i < MAX_PERIODIC_ANNOUNCEMENTS; i++) { if (q->sound_periodicannounce[i]) { ast_str_set(&q->sound_periodicannounce[i], 0, "%s", ""); } } while ((pr_iter = AST_LIST_REMOVE_HEAD(&q->rules,list))) { ast_free(pr_iter); } /* On restart assume no members are available. * The queue_avail hint is a boolean state to indicate whether a member is available or not. * * This seems counter intuitive, but is required to light a BLF * AST_DEVICE_INUSE indicates no members are available. * AST_DEVICE_NOT_INUSE indicates a member is available. */ ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name); } static void clear_queue(struct call_queue *q) { q->holdtime = 0; q->callscompleted = 0; q->callsabandoned = 0; q->callscompletedinsl = 0; q->talktime = 0; if (q->members) { struct member *mem; struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0); while ((mem = ao2_iterator_next(&mem_iter))) { mem->calls = 0; mem->lastcall = 0; ao2_ref(mem, -1); } ao2_iterator_destroy(&mem_iter); } } /*! * \brief Change queue penalty by adding rule. * * Check rule for errors with time or fomatting, see if rule is relative to rest * of queue, iterate list of rules to find correct insertion point, insert and return. * \retval -1 on failure * \retval 0 on success * \note Call this with the rule_lists locked */ static int insert_penaltychange(const char *list_name, const char *content, const int linenum) { char *timestr, *maxstr, *minstr, *contentdup; struct penalty_rule *rule = NULL, *rule_iter; struct rule_list *rl_iter; int penaltychangetime, inserted = 0; if (!(rule = ast_calloc(1, sizeof(*rule)))) { return -1; } contentdup = ast_strdupa(content); if (!(maxstr = strchr(contentdup, ','))) { ast_log(LOG_WARNING, "Improperly formatted penaltychange rule at line %d. Ignoring.\n", linenum); ast_free(rule); return -1; } *maxstr++ = '\0'; timestr = contentdup; if ((penaltychangetime = atoi(timestr)) < 0) { ast_log(LOG_WARNING, "Improper time parameter specified for penaltychange rule at line %d. Ignoring.\n", linenum); ast_free(rule); return -1; } rule->time = penaltychangetime; if ((minstr = strchr(maxstr,','))) { *minstr++ = '\0'; } /* The last check will evaluate true if either no penalty change is indicated for a given rule * OR if a min penalty change is indicated but no max penalty change is */ if (*maxstr == '+' || *maxstr == '-' || *maxstr == '\0') { rule->max_relative = 1; } rule->max_value = atoi(maxstr); if (!ast_strlen_zero(minstr)) { if (*minstr == '+' || *minstr == '-') { rule->min_relative = 1; } rule->min_value = atoi(minstr); } else { /*there was no minimum specified, so assume this means no change*/ rule->min_relative = 1; } /*We have the rule made, now we need to insert it where it belongs*/ AST_LIST_TRAVERSE(&rule_lists, rl_iter, list){ if (strcasecmp(rl_iter->name, list_name)) { continue; } AST_LIST_TRAVERSE_SAFE_BEGIN(&rl_iter->rules, rule_iter, list) { if (rule->time < rule_iter->time) { AST_LIST_INSERT_BEFORE_CURRENT(rule, list); inserted = 1; break; } } AST_LIST_TRAVERSE_SAFE_END; if (!inserted) { AST_LIST_INSERT_TAIL(&rl_iter->rules, rule, list); inserted = 1; } break; } if (!inserted) { ast_log(LOG_WARNING, "Unknown rule list name %s; ignoring.\n", list_name); ast_free(rule); return -1; } return 0; } static void parse_empty_options(const char *value, enum empty_conditions *empty, int joinempty) { char *value_copy = ast_strdupa(value); char *option = NULL; while ((option = strsep(&value_copy, ","))) { if (!strcasecmp(option, "paused")) { *empty |= QUEUE_EMPTY_PAUSED; } else if (!strcasecmp(option, "penalty")) { *empty |= QUEUE_EMPTY_PENALTY; } else if (!strcasecmp(option, "inuse")) { *empty |= QUEUE_EMPTY_INUSE; } else if (!strcasecmp(option, "ringing")) { *empty |= QUEUE_EMPTY_RINGING; } else if (!strcasecmp(option, "invalid")) { *empty |= QUEUE_EMPTY_INVALID; } else if (!strcasecmp(option, "wrapup")) { *empty |= QUEUE_EMPTY_WRAPUP; } else if (!strcasecmp(option, "unavailable")) { *empty |= QUEUE_EMPTY_UNAVAILABLE; } else if (!strcasecmp(option, "unknown")) { *empty |= QUEUE_EMPTY_UNKNOWN; } else if (!strcasecmp(option, "loose")) { *empty = (QUEUE_EMPTY_PENALTY | QUEUE_EMPTY_INVALID); } else if (!strcasecmp(option, "strict")) { *empty = (QUEUE_EMPTY_PENALTY | QUEUE_EMPTY_INVALID | QUEUE_EMPTY_PAUSED | QUEUE_EMPTY_UNAVAILABLE); } else if ((ast_false(option) && joinempty) || (ast_true(option) && !joinempty)) { *empty = (QUEUE_EMPTY_PENALTY | QUEUE_EMPTY_INVALID | QUEUE_EMPTY_PAUSED); } else if ((ast_false(option) && !joinempty) || (ast_true(option) && joinempty)) { *empty = 0; } else { ast_log(LOG_WARNING, "Unknown option %s for '%s'\n", option, joinempty ? "joinempty" : "leavewhenempty"); } } } /*! \brief Configure a queue parameter. * * The failunknown flag is set for config files (and static realtime) to show * errors for unknown parameters. It is cleared for dynamic realtime to allow * extra fields in the tables. * \note For error reporting, line number is passed for .conf static configuration, * for Realtime queues, linenum is -1. */ static void queue_set_param(struct call_queue *q, const char *param, const char *val, int linenum, int failunknown) { if (!strcasecmp(param, "musicclass") || !strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) { ast_string_field_set(q, moh, val); } else if (!strcasecmp(param, "announce")) { ast_string_field_set(q, announce, val); } else if (!strcasecmp(param, "context")) { ast_string_field_set(q, context, val); } else if (!strcasecmp(param, "timeout")) { q->timeout = atoi(val); if (q->timeout < 0) { q->timeout = DEFAULT_TIMEOUT; } } else if (!strcasecmp(param, "ringinuse")) { q->ringinuse = ast_true(val); } else if (!strcasecmp(param, "setinterfacevar")) { q->setinterfacevar = ast_true(val); } else if (!strcasecmp(param, "setqueuevar")) { q->setqueuevar = ast_true(val); } else if (!strcasecmp(param, "setqueueentryvar")) { q->setqueueentryvar = ast_true(val); } else if (!strcasecmp(param, "monitor-format")) { ast_copy_string(q->monfmt, val, sizeof(q->monfmt)); } else if (!strcasecmp(param, "membermacro")) { ast_string_field_set(q, membermacro, val); } else if (!strcasecmp(param, "membergosub")) { ast_string_field_set(q, membergosub, val); } else if (!strcasecmp(param, "queue-youarenext")) { ast_string_field_set(q, sound_next, val); } else if (!strcasecmp(param, "queue-thereare")) { ast_string_field_set(q, sound_thereare, val); } else if (!strcasecmp(param, "queue-callswaiting")) { ast_string_field_set(q, sound_calls, val); } else if (!strcasecmp(param, "queue-quantity1")) { ast_string_field_set(q, queue_quantity1, val); } else if (!strcasecmp(param, "queue-quantity2")) { ast_string_field_set(q, queue_quantity2, val); } else if (!strcasecmp(param, "queue-holdtime")) { ast_string_field_set(q, sound_holdtime, val); } else if (!strcasecmp(param, "queue-minutes")) { ast_string_field_set(q, sound_minutes, val); } else if (!strcasecmp(param, "queue-minute")) { ast_string_field_set(q, sound_minute, val); } else if (!strcasecmp(param, "queue-seconds")) { ast_string_field_set(q, sound_seconds, val); } else if (!strcasecmp(param, "queue-thankyou")) { ast_string_field_set(q, sound_thanks, val); } else if (!strcasecmp(param, "queue-callerannounce")) { ast_string_field_set(q, sound_callerannounce, val); } else if (!strcasecmp(param, "queue-reporthold")) { ast_string_field_set(q, sound_reporthold, val); } else if (!strcasecmp(param, "announce-frequency")) { q->announcefrequency = atoi(val); } else if (!strcasecmp(param, "announce-to-first-user")) { q->announce_to_first_user = ast_true(val); } else if (!strcasecmp(param, "min-announce-frequency")) { q->minannouncefrequency = atoi(val); ast_debug(1, "%s=%s for queue '%s'\n", param, val, q->name); } else if (!strcasecmp(param, "announce-round-seconds")) { q->roundingseconds = atoi(val); /* Rounding to any other values just doesn't make sense... */ if (!(q->roundingseconds == 0 || q->roundingseconds == 5 || q->roundingseconds == 10 || q->roundingseconds == 15 || q->roundingseconds == 20 || q->roundingseconds == 30)) { if (linenum >= 0) { ast_log(LOG_WARNING, "'%s' isn't a valid value for %s " "using 0 instead for queue '%s' at line %d of queues.conf\n", val, param, q->name, linenum); } else { ast_log(LOG_WARNING, "'%s' isn't a valid value for %s " "using 0 instead for queue '%s'\n", val, param, q->name); } q->roundingseconds=0; } } else if (!strcasecmp(param, "announce-holdtime")) { if (!strcasecmp(val, "once")) { q->announceholdtime = ANNOUNCEHOLDTIME_ONCE; } else if (ast_true(val)) { q->announceholdtime = ANNOUNCEHOLDTIME_ALWAYS; } else { q->announceholdtime = 0; } } else if (!strcasecmp(param, "announce-position")) { if (!strcasecmp(val, "limit")) { q->announceposition = ANNOUNCEPOSITION_LIMIT; } else if (!strcasecmp(val, "more")) { q->announceposition = ANNOUNCEPOSITION_MORE_THAN; } else if (ast_true(val)) { q->announceposition = ANNOUNCEPOSITION_YES; } else { q->announceposition = ANNOUNCEPOSITION_NO; } } else if (!strcasecmp(param, "announce-position-limit")) { q->announcepositionlimit = atoi(val); } else if (!strcasecmp(param, "periodic-announce")) { if (strchr(val, ',')) { char *s, *buf = ast_strdupa(val); unsigned int i = 0; while ((s = strsep(&buf, ",|"))) { if (!q->sound_periodicannounce[i]) { q->sound_periodicannounce[i] = ast_str_create(16); } ast_str_set(&q->sound_periodicannounce[i], 0, "%s", s); i++; if (i == MAX_PERIODIC_ANNOUNCEMENTS) { break; } } q->numperiodicannounce = i; } else { ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val); q->numperiodicannounce = 1; } } else if (!strcasecmp(param, "periodic-announce-frequency")) { q->periodicannouncefrequency = atoi(val); } else if (!strcasecmp(param, "relative-periodic-announce")) { q->relativeperiodicannounce = ast_true(val); } else if (!strcasecmp(param, "random-periodic-announce")) { q->randomperiodicannounce = ast_true(val); } else if (!strcasecmp(param, "retry")) { q->retry = atoi(val); if (q->retry <= 0) { q->retry = DEFAULT_RETRY; } } else if (!strcasecmp(param, "wrapuptime")) { q->wrapuptime = atoi(val); } else if (!strcasecmp(param, "penaltymemberslimit")) { if ((sscanf(val, "%10d", &q->penaltymemberslimit) != 1)) { q->penaltymemberslimit = 0; } } else if (!strcasecmp(param, "autofill")) { q->autofill = ast_true(val); } else if (!strcasecmp(param, "monitor-type")) { if (!strcasecmp(val, "mixmonitor")) { q->montype = 1; } } else if (!strcasecmp(param, "autopause")) { q->autopause = autopause2int(val); } else if (!strcasecmp(param, "autopausedelay")) { q->autopausedelay = atoi(val); } else if (!strcasecmp(param, "autopausebusy")) { q->autopausebusy = ast_true(val); } else if (!strcasecmp(param, "autopauseunavail")) { q->autopauseunavail = ast_true(val); } else if (!strcasecmp(param, "maxlen")) { q->maxlen = atoi(val); if (q->maxlen < 0) { q->maxlen = 0; } } else if (!strcasecmp(param, "servicelevel")) { q->servicelevel= atoi(val); } else if (!strcasecmp(param, "strategy")) { int strategy; /* We are a static queue and already have set this, no need to do it again */ if (failunknown) { return; } strategy = strat2int(val); if (strategy < 0) { ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n", val, q->name); q->strategy = QUEUE_STRATEGY_RINGALL; } if (strategy == q->strategy) { return; } if (strategy == QUEUE_STRATEGY_LINEAR) { ast_log(LOG_WARNING, "Changing to the linear strategy currently requires asterisk to be restarted.\n"); return; } q->strategy = strategy; } else if (!strcasecmp(param, "joinempty")) { parse_empty_options(val, &q->joinempty, 1); } else if (!strcasecmp(param, "leavewhenempty")) { parse_empty_options(val, &q->leavewhenempty, 0); } else if (!strcasecmp(param, "eventmemberstatus")) { q->maskmemberstatus = !ast_true(val); } else if (!strcasecmp(param, "eventwhencalled")) { if (!strcasecmp(val, "vars")) { q->eventwhencalled = QUEUE_EVENT_VARIABLES; } else { q->eventwhencalled = ast_true(val) ? 1 : 0; } } else if (!strcasecmp(param, "reportholdtime")) { q->reportholdtime = ast_true(val); } else if (!strcasecmp(param, "memberdelay")) { q->memberdelay = atoi(val); } else if (!strcasecmp(param, "weight")) { q->weight = atoi(val); } else if (!strcasecmp(param, "timeoutrestart")) { q->timeoutrestart = ast_true(val); } else if (!strcasecmp(param, "defaultrule")) { ast_string_field_set(q, defaultrule, val); } else if (!strcasecmp(param, "timeoutpriority")) { if (!strcasecmp(val, "conf")) { q->timeoutpriority = TIMEOUT_PRIORITY_CONF; } else { q->timeoutpriority = TIMEOUT_PRIORITY_APP; } } else if (failunknown) { if (linenum >= 0) { ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s at line %d of queues.conf\n", q->name, param, linenum); } else { ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s\n", q->name, param); } } } /*! \internal * \brief If adding a single new member to a queue, use this function instead of ao2_linking. * This adds round robin queue position data for a fresh member as well as links it. * \param queue Which queue the member is being added to * \param mem Which member is being added to the queue */ static void member_add_to_queue(struct call_queue *queue, struct member *mem) { ao2_lock(queue->members); mem->queuepos = ao2_container_count(queue->members); ao2_link(queue->members, mem); ao2_unlock(queue->members); } /*! \internal * \brief If removing a single member from a queue, use this function instead of ao2_unlinking. * This will perform round robin queue position reordering for the remaining members. * \param queue Which queue the member is being removed from * \param member Which member is being removed from the queue */ static void member_remove_from_queue(struct call_queue *queue, struct member *mem) { ao2_lock(queue->members); queue_member_follower_removal(queue, mem); ao2_unlink(queue->members, mem); ao2_unlock(queue->members); } /*! * \brief Find rt member record to update otherwise create one. * * Search for member in queue, if found update penalty/paused state, * if no member exists create one flag it as a RT member and add to queue member list. */ static void rt_handle_member_record(struct call_queue *q, char *interface, struct ast_config *member_config) { struct member *m; struct ao2_iterator mem_iter; int penalty = 0; int paused = 0; int found = 0; int ringinuse = q->ringinuse; const char *config_val; const char *rt_uniqueid = ast_variable_retrieve(member_config, interface, "uniqueid"); const char *membername = S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface); const char *state_interface = S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface); const char *penalty_str = ast_variable_retrieve(member_config, interface, "penalty"); const char *paused_str = ast_variable_retrieve(member_config, interface, "paused"); if (ast_strlen_zero(rt_uniqueid)) { ast_log(LOG_WARNING, "Realtime field uniqueid is empty for member %s\n", S_OR(membername, "NULL")); return; } if (penalty_str) { penalty = atoi(penalty_str); if ((penalty < 0) && negative_penalty_invalid) { return; } else if (penalty < 0) { penalty = 0; } } if (paused_str) { paused = atoi(paused_str); if (paused < 0) { paused = 0; } } if ((config_val = ast_variable_retrieve(member_config, interface, realtime_ringinuse_field))) { if (ast_true(config_val)) { ringinuse = 1; } else if (ast_false(config_val)) { ringinuse = 0; } else { ast_log(LOG_WARNING, "Invalid value of '%s' field for %s in queue '%s'\n", realtime_ringinuse_field, interface, q->name); } } /* Find member by realtime uniqueid and update */ mem_iter = ao2_iterator_init(q->members, 0); while ((m = ao2_iterator_next(&mem_iter))) { if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) { m->dead = 0; /* Do not delete this one. */ ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid)); if (paused_str) { m->paused = paused; } if (strcasecmp(state_interface, m->state_interface)) { ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface)); } m->penalty = penalty; m->ringinuse = ringinuse; found = 1; ao2_ref(m, -1); break; } ao2_ref(m, -1); } ao2_iterator_destroy(&mem_iter); /* Create a new member */ if (!found) { if ((m = create_queue_member(interface, membername, penalty, paused, state_interface, ringinuse))) { m->dead = 0; m->realtime = 1; ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid)); if (!log_membername_as_agent) { ast_queue_log(q->name, "REALTIME", m->interface, "ADDMEMBER", "%s", paused ? "PAUSED" : ""); } else { ast_queue_log(q->name, "REALTIME", m->membername, "ADDMEMBER", "%s", paused ? "PAUSED" : ""); } member_add_to_queue(q, m); ao2_ref(m, -1); m = NULL; } } } /*! \brief Iterate through queue's member list and delete them */ static void free_members(struct call_queue *q, int all) { /* Free non-dynamic members */ struct member *cur; struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0); while ((cur = ao2_iterator_next(&mem_iter))) { if (all || !cur->dynamic) { member_remove_from_queue(q, cur); } ao2_ref(cur, -1); } ao2_iterator_destroy(&mem_iter); } /*! \brief Free queue's member list then its string fields */ static void destroy_queue(void *obj) { struct call_queue *q = obj; int i; free_members(q, 1); ast_string_field_free_memory(q); for (i = 0; i < MAX_PERIODIC_ANNOUNCEMENTS; i++) { if (q->sound_periodicannounce[i]) { free(q->sound_periodicannounce[i]); } } ao2_ref(q->members, -1); } static struct call_queue *alloc_queue(const char *queuename) { struct call_queue *q; if ((q = ao2_t_alloc(sizeof(*q), destroy_queue, "Allocate queue"))) { if (ast_string_field_init(q, 64)) { queue_t_unref(q, "String field allocation failed"); return NULL; } ast_string_field_set(q, name, queuename); } return q; } /*! * \brief Reload a single queue via realtime. * * Check for statically defined queue first, check if deleted RT queue, * check for new RT queue, if queue vars are not defined init them with defaults. * reload RT queue vars, set RT queue members dead and reload them, return finished queue. * \retval the queue, * \retval NULL if it doesn't exist. * \note Should be called with the "queues" container locked. */ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config) { struct ast_variable *v; struct call_queue *q, tmpq = { .name = queuename, }; struct member *m; struct ao2_iterator mem_iter; char *interface = NULL; const char *tmp_name; char *tmp; char tmpbuf[64]; /* Must be longer than the longest queue param name. */ /* Static queues override realtime. */ if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Check if static queue exists"))) { ao2_lock(q); if (!q->realtime) { if (q->dead) { ao2_unlock(q); queue_t_unref(q, "Queue is dead; can't return it"); return NULL; } ast_log(LOG_WARNING, "Static queue '%s' already exists. Not loading from realtime\n", q->name); ao2_unlock(q); return q; } } else if (!member_config) { /* Not found in the list, and it's not realtime ... */ return NULL; } /* Check if queue is defined in realtime. */ if (!queue_vars) { /* Delete queue from in-core list if it has been deleted in realtime. */ if (q) { /*! \note Hmm, can't seem to distinguish a DB failure from a not found condition... So we might delete an in-core queue in case of DB failure. */ ast_debug(1, "Queue %s not found in realtime.\n", queuename); q->dead = 1; /* Delete if unused (else will be deleted when last caller leaves). */ queues_t_unlink(queues, q, "Unused; removing from container"); ao2_unlock(q); queue_t_unref(q, "Queue is dead; can't return it"); } return NULL; } /* Create a new queue if an in-core entry does not exist yet. */ if (!q) { struct ast_variable *tmpvar = NULL; if (!(q = alloc_queue(queuename))) { return NULL; } ao2_lock(q); clear_queue(q); q->realtime = 1; /*Before we initialize the queue, we need to set the strategy, so that linear strategy * will allocate the members properly */ for (tmpvar = queue_vars; tmpvar; tmpvar = tmpvar->next) { if (!strcasecmp(tmpvar->name, "strategy")) { q->strategy = strat2int(tmpvar->value); if (q->strategy < 0) { ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n", tmpvar->value, q->name); q->strategy = QUEUE_STRATEGY_RINGALL; } break; } } /* We traversed all variables and didn't find a strategy */ if (!tmpvar) { q->strategy = QUEUE_STRATEGY_RINGALL; } queues_t_link(queues, q, "Add queue to container"); } init_queue(q); /* Ensure defaults for all parameters not set explicitly. */ memset(tmpbuf, 0, sizeof(tmpbuf)); for (v = queue_vars; v; v = v->next) { /* Convert to dashes `-' from underscores `_' as the latter are more SQL friendly. */ if (strchr(v->name, '_')) { ast_copy_string(tmpbuf, v->name, sizeof(tmpbuf)); tmp_name = tmpbuf; tmp = tmpbuf; while ((tmp = strchr(tmp, '_'))) { *tmp++ = '-'; } } else { tmp_name = v->name; } /* NULL values don't get returned from realtime; blank values should * still get set. If someone doesn't want a value to be set, they * should set the realtime column to NULL, not blank. */ queue_set_param(q, tmp_name, v->value, -1, 0); } /* Temporarily set realtime members dead so we can detect deleted ones. */ mem_iter = ao2_iterator_init(q->members, 0); while ((m = ao2_iterator_next(&mem_iter))) { if (m->realtime) { m->dead = 1; } ao2_ref(m, -1); } ao2_iterator_destroy(&mem_iter); while ((interface = ast_category_browse(member_config, interface))) { rt_handle_member_record(q, interface, member_config); } /* Delete all realtime members that have been deleted in DB. */ mem_iter = ao2_iterator_init(q->members, 0); while ((m = ao2_iterator_next(&mem_iter))) { if (m->dead) { if (ast_strlen_zero(m->membername) || !log_membername_as_agent) { ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", ""); } else { ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", ""); } member_remove_from_queue(q, m); } ao2_ref(m, -1); } ao2_iterator_destroy(&mem_iter); ao2_unlock(q); return q; } /*! * note */ /*! * \internal * \brief Returns reference to the named queue. If the queue is realtime, it will load the queue as well. * \param queuename - name of the desired queue * * \retval the queue * \retval NULL if it doesn't exist */ static struct call_queue *find_load_queue_rt_friendly(const char *queuename) { struct ast_variable *queue_vars; struct ast_config *member_config = NULL; struct call_queue *q = NULL, tmpq = { .name = queuename, }; int prev_weight = 0; /* Find the queue in the in-core list first. */ q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Look for queue in memory first"); if (!q || q->realtime) { /*! \note Load from realtime before taking the "queues" container lock, to avoid blocking all queue operations while waiting for the DB. This will be two separate database transactions, so we might see queue parameters as they were before another process changed the queue and member list as it was after the change. Thus we might see an empty member list when a queue is deleted. In practise, this is unlikely to cause a problem. */ queue_vars = ast_load_realtime("queues", "name", queuename, SENTINEL); if (queue_vars) { member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", queuename, SENTINEL); if (!member_config) { ast_debug(1, "No queue_members defined in config extconfig.conf\n"); member_config = ast_config_new(); } } if (q) { prev_weight = q->weight ? 1 : 0; queue_t_unref(q, "Need to find realtime queue"); } q = find_queue_by_name_rt(queuename, queue_vars, member_config); ast_config_destroy(member_config); ast_variables_destroy(queue_vars); /* update the use_weight value if the queue's has gained or lost a weight */ if (q) { if (!q->weight && prev_weight) { ast_atomic_fetchadd_int(&use_weight, -1); } if (q->weight && !prev_weight) { ast_atomic_fetchadd_int(&use_weight, +1); } } /* Other cases will end up with the proper value for use_weight */ } else { update_realtime_members(q); } return q; } static int update_realtime_member_field(struct member *mem, const char *queue_name, const char *field, const char *value) { int ret = -1; if (ast_strlen_zero(mem->rt_uniqueid)) { return ret; } if ((ast_update_realtime("queue_members", "uniqueid", mem->rt_uniqueid, field, value, SENTINEL)) > 0) { ret = 0; } return ret; } static void update_realtime_members(struct call_queue *q) { struct ast_config *member_config = NULL; struct member *m; char *interface = NULL; struct ao2_iterator mem_iter; if (!(member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", q->name , SENTINEL))) { /* This queue doesn't have realtime members. If the queue still has any realtime * members in memory, they need to be removed. */ ao2_lock(q); mem_iter = ao2_iterator_init(q->members, 0); while ((m = ao2_iterator_next(&mem_iter))) { if (m->realtime) { member_remove_from_queue(q, m); } ao2_ref(m, -1); } ast_debug(3, "Queue %s has no realtime members defined. No need for update\n", q->name); ao2_unlock(q); return; } ao2_lock(q); /* Temporarily set realtime members dead so we can detect deleted ones.*/ mem_iter = ao2_iterator_init(q->members, 0); while ((m = ao2_iterator_next(&mem_iter))) { if (m->realtime) { m->dead = 1; } ao2_ref(m, -1); } ao2_iterator_destroy(&mem_iter); while ((interface = ast_category_browse(member_config, interface))) { rt_handle_member_record(q, interface, member_config); } /* Delete all realtime members that have been deleted in DB. */ mem_iter = ao2_iterator_init(q->members, 0); while ((m = ao2_iterator_next(&mem_iter))) { if (m->dead) { if (ast_strlen_zero(m->membername) || !log_membername_as_agent) { ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", ""); } else { ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", ""); } member_remove_from_queue(q, m); } ao2_ref(m, -1); } ao2_iterator_destroy(&mem_iter); ao2_unlock(q); ast_config_destroy(member_config); } static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *reason, int position) { struct call_queue *q; struct queue_ent *cur, *prev = NULL; int res = -1; int pos = 0; int inserted = 0; if (!(q = find_load_queue_rt_friendly(queuename))) { return res; } ao2_lock(q); /* This is our one */ if (q->joinempty) { int status = 0; if ((status = get_member_status(q, qe->max_penalty, qe->min_penalty, q->joinempty))) { *reason = QUEUE_JOINEMPTY; ao2_unlock(q); queue_t_unref(q, "Done with realtime queue"); return res; } } if (*reason == QUEUE_UNKNOWN && q->maxlen && (q->count >= q->maxlen)) { *reason = QUEUE_FULL; } else if (*reason == QUEUE_UNKNOWN) { /* There's space for us, put us at the right position inside * the queue. * Take into account the priority of the calling user */ inserted = 0; prev = NULL; cur = q->head; while (cur) { /* We have higher priority than the current user, enter * before him, after all the other users with priority * higher or equal to our priority. */ if ((!inserted) && (qe->prio > cur->prio)) { insert_entry(q, prev, qe, &pos); inserted = 1; } /* <= is necessary for the position comparison because it may not be possible to enter * at our desired position since higher-priority callers may have taken the position we want */ if (!inserted && (qe->prio >= cur->prio) && position && (position <= pos + 1)) { insert_entry(q, prev, qe, &pos); inserted = 1; /*pos is incremented inside insert_entry, so don't need to add 1 here*/ if (position < pos) { ast_log(LOG_NOTICE, "Asked to be inserted at position %d but forced into position %d due to higher priority callers\n", position, pos); } } cur->pos = ++pos; prev = cur; cur = cur->next; } /* No luck, join at the end of the queue */ if (!inserted) { insert_entry(q, prev, qe, &pos); } ast_copy_string(qe->moh, q->moh, sizeof(qe->moh)); ast_copy_string(qe->announce, q->announce, sizeof(qe->announce)); ast_copy_string(qe->context, q->context, sizeof(qe->context)); q->count++; if (q->count == 1) { ast_devstate_changed(AST_DEVICE_RINGING, AST_DEVSTATE_CACHABLE, "Queue:%s", q->name); } res = 0; /*** DOCUMENTATION Raised when a channel joins a Queue. This channel's current position in the queue. The total number of channels in the queue. Leave Queue ***/ ast_manager_event(qe->chan, EVENT_FLAG_CALL, "Join", "Channel: %s\r\n" "CallerIDNum: %s\r\n" "CallerIDName: %s\r\n" "ConnectedLineNum: %s\r\n" "ConnectedLineName: %s\r\n" "Queue: %s\r\n" "Position: %d\r\n" "Count: %d\r\n" "Uniqueid: %s\r\n", ast_channel_name(qe->chan), S_COR(ast_channel_caller(qe->chan)->id.number.valid, ast_channel_caller(qe->chan)->id.number.str, "unknown"),/* XXX somewhere else it is */ S_COR(ast_channel_caller(qe->chan)->id.name.valid, ast_channel_caller(qe->chan)->id.name.str, "unknown"), S_COR(ast_channel_connected(qe->chan)->id.number.valid, ast_channel_connected(qe->chan)->id.number.str, "unknown"),/* XXX somewhere else it is */ S_COR(ast_channel_connected(qe->chan)->id.name.valid, ast_channel_connected(qe->chan)->id.name.str, "unknown"), q->name, qe->pos, q->count, ast_channel_uniqueid(qe->chan)); ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, ast_channel_name(qe->chan), qe->pos ); } ao2_unlock(q); queue_t_unref(q, "Done with realtime queue"); return res; } static int play_file(struct ast_channel *chan, const char *filename) { int res; if (ast_strlen_zero(filename)) { return 0; } if (!ast_fileexists(filename, NULL, ast_channel_language(chan))) { return 0; } ast_stopstream(chan); res = ast_streamfile(chan, filename, ast_channel_language(chan)); if (!res) { res = ast_waitstream(chan, AST_DIGIT_ANY); } ast_stopstream(chan); return res; } /*! * \brief Check for valid exit from queue via goto * \retval 0 if failure * \retval 1 if successful */ static int valid_exit(struct queue_ent *qe, char digit) { int digitlen = strlen(qe->digits); /* Prevent possible buffer overflow */ if (digitlen < sizeof(qe->digits) - 2) { qe->digits[digitlen] = digit; qe->digits[digitlen + 1] = '\0'; } else { qe->digits[0] = '\0'; return 0; } /* If there's no context to goto, short-circuit */ if (ast_strlen_zero(qe->context)) { return 0; } /* If the extension is bad, then reset the digits to blank */ if (!ast_canmatch_extension(qe->chan, qe->context, qe->digits, 1, S_COR(ast_channel_caller(qe->chan)->id.number.valid, ast_channel_caller(qe->chan)->id.number.str, NULL))) { qe->digits[0] = '\0'; return 0; } /* We have an exact match */ if (!ast_goto_if_exists(qe->chan, qe->context, qe->digits, 1)) { qe->valid_digits = 1; /* Return 1 on a successful goto */ return 1; } return 0; } static int say_position(struct queue_ent *qe, int ringing) { int res = 0, avgholdmins, avgholdsecs, announceposition = 0; int say_thanks = 1; time_t now; /* Let minannouncefrequency seconds pass between the start of each position announcement */ time(&now); if ((now - qe->last_pos) < qe->parent->minannouncefrequency) { return 0; } /* If either our position has changed, or we are over the freq timer, say position */ if ((qe->last_pos_said == qe->pos) && ((now - qe->last_pos) < qe->parent->announcefrequency)) { return 0; } if (ringing) { ast_indicate(qe->chan,-1); } else { ast_moh_stop(qe->chan); } if (qe->parent->announceposition == ANNOUNCEPOSITION_YES || qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN || (qe->parent->announceposition == ANNOUNCEPOSITION_LIMIT && qe->pos <= qe->parent->announcepositionlimit)) { announceposition = 1; } if (announceposition == 1) { /* Say we're next, if we are */ if (qe->pos == 1) { res = play_file(qe->chan, qe->parent->sound_next); if (res) { goto playout; } goto posout; } else { if (qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN && qe->pos > qe->parent->announcepositionlimit){ /* More than Case*/ res = play_file(qe->chan, qe->parent->queue_quantity1); if (res) { goto playout; } res = ast_say_number(qe->chan, qe->parent->announcepositionlimit, AST_DIGIT_ANY, ast_channel_language(qe->chan), NULL); /* Needs gender */ if (res) { goto playout; } } else { /* Normal Case */ res = play_file(qe->chan, qe->parent->sound_thereare); if (res) { goto playout; } res = ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, ast_channel_language(qe->chan), NULL); /* Needs gender */ if (res) { goto playout; } } if (qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN && qe->pos > qe->parent->announcepositionlimit){ /* More than Case*/ res = play_file(qe->chan, qe->parent->queue_quantity2); if (res) { goto playout; } } else { res = play_file(qe->chan, qe->parent->sound_calls); if (res) { goto playout; } } } } /* Round hold time to nearest minute */ avgholdmins = abs(((qe->parent->holdtime + 30) - (now - qe->start)) / 60); /* If they have specified a rounding then round the seconds as well */ if (qe->parent->roundingseconds) { avgholdsecs = (abs(((qe->parent->holdtime + 30) - (now - qe->start))) - 60 * avgholdmins) / qe->parent->roundingseconds; avgholdsecs *= qe->parent->roundingseconds; } else { avgholdsecs = 0; } ast_verb(3, "Hold time for %s is %d minute(s) %d seconds\n", qe->parent->name, avgholdmins, avgholdsecs); /* If the hold time is >1 min, if it's enabled, and if it's not supposed to be only once and we have already said it, say it */ if ((avgholdmins+avgholdsecs) > 0 && qe->parent->announceholdtime && ((qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE && !qe->last_pos) || !(qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE))) { res = play_file(qe->chan, qe->parent->sound_holdtime); if (res) { goto playout; } if (avgholdmins >= 1) { res = ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, ast_channel_language(qe->chan), NULL); if (res) { goto playout; } if (avgholdmins == 1) { res = play_file(qe->chan, qe->parent->sound_minute); if (res) { goto playout; } } else { res = play_file(qe->chan, qe->parent->sound_minutes); if (res) { goto playout; } } } if (avgholdsecs >= 1) { res = ast_say_number(qe->chan, avgholdsecs, AST_DIGIT_ANY, ast_channel_language(qe->chan), NULL); if (res) { goto playout; } res = play_file(qe->chan, qe->parent->sound_seconds); if (res) { goto playout; } } } else if (qe->parent->announceholdtime && !qe->parent->announceposition) { say_thanks = 0; } posout: if (qe->parent->announceposition) { ast_verb(3, "Told %s in %s their queue position (which was %d)\n", ast_channel_name(qe->chan), qe->parent->name, qe->pos); } if (say_thanks) { res = play_file(qe->chan, qe->parent->sound_thanks); } playout: if ((res > 0 && !valid_exit(qe, res))) { res = 0; } /* Set our last_pos indicators */ qe->last_pos = now; qe->last_pos_said = qe->pos; /* Don't restart music on hold if we're about to exit the caller from the queue */ if (!res) { if (ringing) { ast_indicate(qe->chan, AST_CONTROL_RINGING); } else { ast_moh_start(qe->chan, qe->moh, NULL); } } return res; } static void recalc_holdtime(struct queue_ent *qe, int newholdtime) { int oldvalue; /* Calculate holdtime using an exponential average */ /* Thanks to SRT for this contribution */ /* 2^2 (4) is the filter coefficient; a higher exponent would give old entries more weight */ ao2_lock(qe->parent); oldvalue = qe->parent->holdtime; qe->parent->holdtime = (((oldvalue << 2) - oldvalue) + newholdtime) >> 2; ao2_unlock(qe->parent); } /*! \brief Caller leaving queue. * * Search the queue to find the leaving client, if found remove from queue * create manager event, move others up the queue. */ static void leave_queue(struct queue_ent *qe) { struct call_queue *q; struct queue_ent *current, *prev = NULL; struct penalty_rule *pr_iter; int pos = 0; if (!(q = qe->parent)) { return; } queue_t_ref(q, "Copy queue pointer from queue entry"); ao2_lock(q); prev = NULL; for (current = q->head; current; current = current->next) { if (current == qe) { char posstr[20]; q->count--; if (!q->count) { ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s", q->name); } /* Take us out of the queue */ /*** DOCUMENTATION Raised when a channel leaves a Queue. Join ***/ ast_manager_event(qe->chan, EVENT_FLAG_CALL, "Leave", "Channel: %s\r\nQueue: %s\r\nCount: %d\r\nPosition: %d\r\nUniqueid: %s\r\n", ast_channel_name(qe->chan), q->name, q->count, qe->pos, ast_channel_uniqueid(qe->chan)); ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, ast_channel_name(qe->chan)); /* Take us out of the queue */ if (prev) { prev->next = current->next; } else { q->head = current->next; } /* Free penalty rules */ while ((pr_iter = AST_LIST_REMOVE_HEAD(&qe->qe_rules, list))) { ast_free(pr_iter); } snprintf(posstr, sizeof(posstr), "%d", qe->pos); pbx_builtin_setvar_helper(qe->chan, "QUEUEPOSITION", posstr); } else { /* Renumber the people after us in the queue based on a new count */ current->pos = ++pos; prev = current; } } ao2_unlock(q); /*If the queue is a realtime queue, check to see if it's still defined in real time*/ if (q->realtime) { struct ast_variable *var; if (!(var = ast_load_realtime("queues", "name", q->name, SENTINEL))) { q->dead = 1; } else { ast_variables_destroy(var); } } if (q->dead) { /* It's dead and nobody is in it, so kill it */ queues_t_unlink(queues, q, "Queue is now dead; remove it from the container"); } /* unref the explicit ref earlier in the function */ queue_t_unref(q, "Expire copied reference"); } /*! * \internal * \brief Destroy the given callattempt structure and free it. * \since 1.8 * * \param doomed callattempt structure to destroy. * * \return Nothing */ static void callattempt_free(struct callattempt *doomed) { if (doomed->member) { ao2_ref(doomed->member, -1); } ast_party_connected_line_free(&doomed->connected); ast_free(doomed); } /*! \brief Hang up a list of outgoing calls */ static void hangupcalls(struct callattempt *outgoing, struct ast_channel *exception, int cancel_answered_elsewhere) { struct callattempt *oo; while (outgoing) { /* If someone else answered the call we should indicate this in the CANCEL */ /* Hangup any existing lines we have open */ if (outgoing->chan && (outgoing->chan != exception)) { if (exception || cancel_answered_elsewhere) { ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } ast_hangup(outgoing->chan); } oo = outgoing; outgoing = outgoing->q_next; ast_aoc_destroy_decoded(oo->aoc_s_rate_list); callattempt_free(oo); } } /*! * \brief Get the number of members available to accept a call. * * \note The queue passed in should be locked prior to this function call * * \param[in] q The queue for which we are couting the number of available members * \return Return the number of available members in queue q */ static int num_available_members(struct call_queue *q) { struct member *mem; int avl = 0; struct ao2_iterator mem_iter; mem_iter = ao2_iterator_init(q->members, 0); while ((mem = ao2_iterator_next(&mem_iter))) { avl += is_member_available(q, mem); ao2_ref(mem, -1); /* If autofill is not enabled or if the queue's strategy is ringall, then * we really don't care about the number of available members so much as we * do that there is at least one available. * * In fact, we purposely will return from this function stating that only * one member is available if either of those conditions hold. That way, * functions which determine what action to take based on the number of available * members will operate properly. The reasoning is that even if multiple * members are available, only the head caller can actually be serviced. */ if ((!q->autofill || q->strategy == QUEUE_STRATEGY_RINGALL) && avl) { break; } } ao2_iterator_destroy(&mem_iter); return avl; } /* traverse all defined queues which have calls waiting and contain this member return 0 if no other queue has precedence (higher weight) or 1 if found */ static int compare_weight(struct call_queue *rq, struct member *member) { struct call_queue *q; struct member *mem; int found = 0; struct ao2_iterator queue_iter; queue_iter = ao2_iterator_init(queues, 0); while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { if (q == rq) { /* don't check myself, could deadlock */ queue_t_unref(q, "Done with iterator"); continue; } ao2_lock(q); if (q->count && q->members) { if ((mem = ao2_find(q->members, member, OBJ_POINTER))) { ast_debug(1, "Found matching member %s in queue '%s'\n", mem->interface, q->name); if (q->weight > rq->weight && q->count >= num_available_members(q)) { ast_debug(1, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count); found = 1; } ao2_ref(mem, -1); } } ao2_unlock(q); queue_t_unref(q, "Done with iterator"); if (found) { break; } } ao2_iterator_destroy(&queue_iter); return found; } /*! \brief common hangup actions */ static void do_hang(struct callattempt *o) { o->stillgoing = 0; ast_hangup(o->chan); o->chan = NULL; } /*! \brief convert "\n" to "\nVariable: " ready for manager to use */ static char *vars2manager(struct ast_channel *chan, char *vars, size_t len) { struct ast_str *buf = ast_str_thread_get(&ast_str_thread_global_buf, len + 1); const char *tmp; if (pbx_builtin_serialize_variables(chan, &buf)) { int i, j; /* convert "\n" to "\nVariable: " */ strcpy(vars, "Variable: "); tmp = ast_str_buffer(buf); for (i = 0, j = 10; (i < len - 1) && (j < len - 1); i++, j++) { vars[j] = tmp[i]; if (tmp[i + 1] == '\0') { break; } if (tmp[i] == '\n') { vars[j++] = '\r'; vars[j++] = '\n'; ast_copy_string(&(vars[j]), "Variable: ", len - j); j += 9; } } if (j > len - 3) { j = len - 3; } vars[j++] = '\r'; vars[j++] = '\n'; vars[j] = '\0'; } else { /* there are no channel variables; leave it blank */ *vars = '\0'; } return vars; } /*! * \internal * \brief Check if the member status is available. * * \param status Member status to check if available. * * \retval non-zero if the member status is available. */ static int member_status_available(int status) { return status == AST_DEVICE_NOT_INUSE || status == AST_DEVICE_UNKNOWN; } /*! * \internal * \brief Clear the member call pending flag. * * \param mem Queue member. * * \return Nothing */ static void member_call_pending_clear(struct member *mem) { ao2_lock(mem); mem->call_pending = 0; ao2_unlock(mem); } /*! * \internal * \brief Set the member call pending flag. * * \param mem Queue member. * * \retval non-zero if call pending flag was already set. */ static int member_call_pending_set(struct member *mem) { int old_pending; ao2_lock(mem); old_pending = mem->call_pending; mem->call_pending = 1; ao2_unlock(mem); return old_pending; } /*! * \internal * \brief Determine if can ring a queue entry. * * \param qe Queue entry to check. * \param call Member call attempt. * * \retval non-zero if an entry can be called. */ static int can_ring_entry(struct queue_ent *qe, struct callattempt *call) { if (call->member->paused) { ast_debug(1, "%s paused, can't receive call\n", call->interface); return 0; } if (!call->member->ringinuse && !member_status_available(call->member->status)) { ast_debug(1, "%s not available, can't receive call\n", call->interface); return 0; } if ((call->lastqueue && call->lastqueue->wrapuptime && (time(NULL) - call->lastcall < call->lastqueue->wrapuptime)) || (!call->lastqueue && qe->parent->wrapuptime && (time(NULL) - call->lastcall < qe->parent->wrapuptime))) { ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n", (call->lastqueue ? call->lastqueue->name : qe->parent->name), call->interface); return 0; } if (use_weight && compare_weight(qe->parent, call->member)) { ast_debug(1, "Priority queue delaying call to %s:%s\n", qe->parent->name, call->interface); return 0; } if (!call->member->ringinuse) { if (member_call_pending_set(call->member)) { ast_debug(1, "%s has another call pending, can't receive call\n", call->interface); return 0; } /* * The queue member is available. Get current status to be sure * because the device state and extension state callbacks may * not have updated the status yet. */ if (!member_status_available(get_queue_member_status(call->member))) { ast_debug(1, "%s actually not available, can't receive call\n", call->interface); member_call_pending_clear(call->member); return 0; } } return 1; } /*! * \brief Part 2 of ring_one * * Does error checking before attempting to request a channel and call a member. * This function is only called from ring_one(). * Failure can occur if: * - Agent on call * - Agent is paused * - Wrapup time not expired * - Priority by another queue * * \retval 1 on success to reach a free agent * \retval 0 on failure to get agent. */ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies) { int res; int status; char tech[256]; char *location; const char *macrocontext, *macroexten; /* on entry here, we know that tmp->chan == NULL */ if (!can_ring_entry(qe, tmp)) { if (ast_channel_cdr(qe->chan)) { ast_cdr_busy(ast_channel_cdr(qe->chan)); } tmp->stillgoing = 0; ++*busies; return 0; } ast_assert(tmp->member->ringinuse || tmp->member->call_pending); ast_copy_string(tech, tmp->interface, sizeof(tech)); if ((location = strchr(tech, '/'))) { *location++ = '\0'; } else { location = ""; } /* Request the peer */ tmp->chan = ast_request(tech, ast_channel_nativeformats(qe->chan), qe->chan, location, &status); if (!tmp->chan) { /* If we can't, just go on to the next call */ ao2_lock(qe->parent); qe->parent->rrpos++; qe->linpos++; ao2_unlock(qe->parent); member_call_pending_clear(tmp->member); if (ast_channel_cdr(qe->chan)) { ast_cdr_busy(ast_channel_cdr(qe->chan)); } tmp->stillgoing = 0; ++*busies; return 0; } ast_channel_lock_both(tmp->chan, qe->chan); if (qe->cancel_answered_elsewhere) { ast_channel_hangupcause_set(tmp->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } ast_channel_appl_set(tmp->chan, "AppQueue"); ast_channel_data_set(tmp->chan, "(Outgoing Line)"); memset(ast_channel_whentohangup(tmp->chan), 0, sizeof(*ast_channel_whentohangup(tmp->chan))); /* If the new channel has no callerid, try to guess what it should be */ if (!ast_channel_caller(tmp->chan)->id.number.valid) { if (ast_channel_connected(qe->chan)->id.number.valid) { struct ast_party_caller caller; ast_party_caller_set_init(&caller, ast_channel_caller(tmp->chan)); caller.id = ast_channel_connected(qe->chan)->id; caller.ani = ast_channel_connected(qe->chan)->ani; ast_channel_set_caller_event(tmp->chan, &caller, NULL); } else if (!ast_strlen_zero(ast_channel_dialed(qe->chan)->number.str)) { ast_set_callerid(tmp->chan, ast_channel_dialed(qe->chan)->number.str, NULL, NULL); } else if (!ast_strlen_zero(S_OR(ast_channel_macroexten(qe->chan), ast_channel_exten(qe->chan)))) { ast_set_callerid(tmp->chan, S_OR(ast_channel_macroexten(qe->chan), ast_channel_exten(qe->chan)), NULL, NULL); } tmp->dial_callerid_absent = 1; } ast_party_redirecting_copy(ast_channel_redirecting(tmp->chan), ast_channel_redirecting(qe->chan)); ast_channel_dialed(tmp->chan)->transit_network_select = ast_channel_dialed(qe->chan)->transit_network_select; ast_connected_line_copy_from_caller(ast_channel_connected(tmp->chan), ast_channel_caller(qe->chan)); /* Inherit specially named variables from parent channel */ ast_channel_inherit_variables(qe->chan, tmp->chan); ast_channel_datastore_inherit(qe->chan, tmp->chan); /* Presense of ADSI CPE on outgoing channel follows ours */ ast_channel_adsicpe_set(tmp->chan, ast_channel_adsicpe(qe->chan)); /* Inherit context and extension */ macrocontext = pbx_builtin_getvar_helper(qe->chan, "MACRO_CONTEXT"); ast_channel_dialcontext_set(tmp->chan, ast_strlen_zero(macrocontext) ? ast_channel_context(qe->chan) : macrocontext); macroexten = pbx_builtin_getvar_helper(qe->chan, "MACRO_EXTEN"); if (!ast_strlen_zero(macroexten)) { ast_channel_exten_set(tmp->chan, macroexten); } else { ast_channel_exten_set(tmp->chan, ast_channel_exten(qe->chan)); } if (ast_cdr_isset_unanswered()) { /* they want to see the unanswered dial attempts! */ /* set up the CDR fields on all the CDRs to give sensical information */ ast_cdr_setdestchan(ast_channel_cdr(tmp->chan), ast_channel_name(tmp->chan)); strcpy(ast_channel_cdr(tmp->chan)->clid, ast_channel_cdr(qe->chan)->clid); strcpy(ast_channel_cdr(tmp->chan)->channel, ast_channel_cdr(qe->chan)->channel); strcpy(ast_channel_cdr(tmp->chan)->src, ast_channel_cdr(qe->chan)->src); strcpy(ast_channel_cdr(tmp->chan)->dst, ast_channel_exten(qe->chan)); strcpy(ast_channel_cdr(tmp->chan)->dcontext, ast_channel_context(qe->chan)); strcpy(ast_channel_cdr(tmp->chan)->lastapp, ast_channel_cdr(qe->chan)->lastapp); strcpy(ast_channel_cdr(tmp->chan)->lastdata, ast_channel_cdr(qe->chan)->lastdata); ast_channel_cdr(tmp->chan)->amaflags = ast_channel_cdr(qe->chan)->amaflags; strcpy(ast_channel_cdr(tmp->chan)->accountcode, ast_channel_cdr(qe->chan)->accountcode); strcpy(ast_channel_cdr(tmp->chan)->userfield, ast_channel_cdr(qe->chan)->userfield); } ast_channel_unlock(tmp->chan); ast_channel_unlock(qe->chan); /* Place the call, but don't wait on the answer */ if ((res = ast_call(tmp->chan, location, 0))) { /* Again, keep going even if there's an error */ ast_verb(3, "Couldn't call %s\n", tmp->interface); do_hang(tmp); member_call_pending_clear(tmp->member); ++*busies; return 0; } if (qe->parent->eventwhencalled) { char vars[2048]; ast_channel_lock_both(tmp->chan, qe->chan); /*** DOCUMENTATION Raised when an Agent is notified of a member in the queue. The agent's technology or location. The name of the agent. Optional channel variables from the ChannelCalling channel AgentRingNoAnswer AgentComplete AgentConnect ***/ manager_event(EVENT_FLAG_AGENT, "AgentCalled", "Queue: %s\r\n" "AgentCalled: %s\r\n" "AgentName: %s\r\n" "ChannelCalling: %s\r\n" "DestinationChannel: %s\r\n" "CallerIDNum: %s\r\n" "CallerIDName: %s\r\n" "ConnectedLineNum: %s\r\n" "ConnectedLineName: %s\r\n" "Context: %s\r\n" "Extension: %s\r\n" "Priority: %d\r\n" "Uniqueid: %s\r\n" "%s", qe->parent->name, tmp->interface, tmp->member->membername, ast_channel_name(qe->chan), ast_channel_name(tmp->chan), S_COR(ast_channel_caller(qe->chan)->id.number.valid, ast_channel_caller(qe->chan)->id.number.str, "unknown"), S_COR(ast_channel_caller(qe->chan)->id.name.valid, ast_channel_caller(qe->chan)->id.name.str, "unknown"), S_COR(ast_channel_connected(qe->chan)->id.number.valid, ast_channel_connected(qe->chan)->id.number.str, "unknown"), S_COR(ast_channel_connected(qe->chan)->id.name.valid, ast_channel_connected(qe->chan)->id.name.str, "unknown"), ast_channel_context(qe->chan), ast_channel_exten(qe->chan), ast_channel_priority(qe->chan), ast_channel_uniqueid(qe->chan), qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); ast_channel_unlock(tmp->chan); ast_channel_unlock(qe->chan); ast_verb(3, "Called %s\n", tmp->interface); } member_call_pending_clear(tmp->member); return 1; } /*! \brief find the entry with the best metric, or NULL */ static struct callattempt *find_best(struct callattempt *outgoing) { struct callattempt *best = NULL, *cur; for (cur = outgoing; cur; cur = cur->q_next) { if (cur->stillgoing && /* Not already done */ !cur->chan && /* Isn't already going */ (!best || cur->metric < best->metric)) { /* We haven't found one yet, or it's better */ best = cur; } } return best; } /*! * \brief Place a call to a queue member. * * Once metrics have been calculated for each member, this function is used * to place a call to the appropriate member (or members). The low-level * channel-handling and error detection is handled in ring_entry * * \retval 1 if a member was called successfully * \retval 0 otherwise */ static int ring_one(struct queue_ent *qe, struct callattempt *outgoing, int *busies) { int ret = 0; while (ret == 0) { struct callattempt *best = find_best(outgoing); if (!best) { ast_debug(1, "Nobody left to try ringing in queue\n"); break; } if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) { struct callattempt *cur; /* Ring everyone who shares this best metric (for ringall) */ for (cur = outgoing; cur; cur = cur->q_next) { if (cur->stillgoing && !cur->chan && cur->metric <= best->metric) { ast_debug(1, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric); ret |= ring_entry(qe, cur, busies); } } } else { /* Ring just the best channel */ ast_debug(1, "Trying '%s' with metric %d\n", best->interface, best->metric); ret = ring_entry(qe, best, busies); } /* If we have timed out, break out */ if (qe->expire && (time(NULL) >= qe->expire)) { ast_debug(1, "Queue timed out while ringing members.\n"); ret = 0; break; } } return ret; } /*! \brief Search for best metric and add to Round Robbin queue */ static int store_next_rr(struct queue_ent *qe, struct callattempt *outgoing) { struct callattempt *best = find_best(outgoing); if (best) { /* Ring just the best channel */ ast_debug(1, "Next is '%s' with metric %d\n", best->interface, best->metric); qe->parent->rrpos = best->metric % 1000; } else { /* Just increment rrpos */ if (qe->parent->wrapped) { /* No more channels, start over */ qe->parent->rrpos = 0; } else { /* Prioritize next entry */ qe->parent->rrpos++; } } qe->parent->wrapped = 0; return 0; } /*! \brief Search for best metric and add to Linear queue */ static int store_next_lin(struct queue_ent *qe, struct callattempt *outgoing) { struct callattempt *best = find_best(outgoing); if (best) { /* Ring just the best channel */ ast_debug(1, "Next is '%s' with metric %d\n", best->interface, best->metric); qe->linpos = best->metric % 1000; } else { /* Just increment rrpos */ if (qe->linwrapped) { /* No more channels, start over */ qe->linpos = 0; } else { /* Prioritize next entry */ qe->linpos++; } } qe->linwrapped = 0; return 0; } /*! \brief Playback announcement to queued members if period has elapsed */ static int say_periodic_announcement(struct queue_ent *qe, int ringing) { int res = 0; time_t now; /* Get the current time */ time(&now); /* Check to see if it is time to announce */ if ((now - qe->last_periodic_announce_time) < qe->parent->periodicannouncefrequency) { return 0; } /* Stop the music on hold so we can play our own file */ if (ringing) { ast_indicate(qe->chan,-1); } else { ast_moh_stop(qe->chan); } ast_verb(3, "Playing periodic announcement\n"); if (qe->parent->randomperiodicannounce && qe->parent->numperiodicannounce) { qe->last_periodic_announce_sound = ((unsigned long) ast_random()) % qe->parent->numperiodicannounce; } else if (qe->last_periodic_announce_sound >= qe->parent->numperiodicannounce || ast_str_strlen(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]) == 0) { qe->last_periodic_announce_sound = 0; } /* play the announcement */ res = play_file(qe->chan, ast_str_buffer(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound])); if (res > 0 && !valid_exit(qe, res)) { res = 0; } /* Resume Music on Hold if the caller is going to stay in the queue */ if (!res) { if (ringing) { ast_indicate(qe->chan, AST_CONTROL_RINGING); } else { ast_moh_start(qe->chan, qe->moh, NULL); } } /* update last_periodic_announce_time */ if (qe->parent->relativeperiodicannounce) { time(&qe->last_periodic_announce_time); } else { qe->last_periodic_announce_time = now; } /* Update the current periodic announcement to the next announcement */ if (!qe->parent->randomperiodicannounce) { qe->last_periodic_announce_sound++; } return res; } /*! \brief Record that a caller gave up on waiting in queue */ static void record_abandoned(struct queue_ent *qe) { set_queue_variables(qe->parent, qe->chan); ao2_lock(qe->parent); /*** DOCUMENTATION Raised when an caller abandons the queue. The channel's original position in the queue. The time the channel was in the queue, expressed in seconds since 00:00, Jan 1, 1970 UTC. ***/ manager_event(EVENT_FLAG_AGENT, "QueueCallerAbandon", "Queue: %s\r\n" "Uniqueid: %s\r\n" "Position: %d\r\n" "OriginalPosition: %d\r\n" "HoldTime: %d\r\n", qe->parent->name, ast_channel_uniqueid(qe->chan), qe->pos, qe->opos, (int)(time(NULL) - qe->start)); qe->parent->callsabandoned++; ao2_unlock(qe->parent); } /*! \brief RNA == Ring No Answer. Common code that is executed when we try a queue member and they don't answer. */ static void rna(int rnatime, struct queue_ent *qe, char *interface, char *membername, int autopause) { ast_verb(3, "Nobody picked up in %d ms\n", rnatime); /* Stop ringing, and resume MOH if specified */ if (qe->ring_when_ringing) { ast_indicate(qe->chan, -1); ast_moh_start(qe->chan, qe->moh, NULL); } if (qe->parent->eventwhencalled) { char vars[2048]; /*** DOCUMENTATION Raised when an agent is notified of a member in the queue and fails to answer. The queue member's channel technology or location. The time the agent was rung, expressed in seconds since 00:00, Jan 1, 1970 UTC. AgentCalled ***/ manager_event(EVENT_FLAG_AGENT, "AgentRingNoAnswer", "Queue: %s\r\n" "Uniqueid: %s\r\n" "Channel: %s\r\n" "Member: %s\r\n" "MemberName: %s\r\n" "RingTime: %d\r\n" "%s", qe->parent->name, ast_channel_uniqueid(qe->chan), ast_channel_name(qe->chan), interface, membername, rnatime, qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); } ast_queue_log(qe->parent->name, ast_channel_uniqueid(qe->chan), membername, "RINGNOANSWER", "%d", rnatime); if (qe->parent->autopause != QUEUE_AUTOPAUSE_OFF && autopause) { if (qe->parent->autopausedelay > 0) { struct member *mem; ao2_lock(qe->parent); if ((mem = interface_exists(qe->parent, interface))) { time_t idletime = time(&idletime)-mem->lastcall; if ((mem->lastcall != 0) && (qe->parent->autopausedelay > idletime)) { ao2_unlock(qe->parent); ao2_ref(mem, -1); return; } ao2_ref(mem, -1); } ao2_unlock(qe->parent); } if (qe->parent->autopause == QUEUE_AUTOPAUSE_ON) { if (!set_member_paused(qe->parent->name, interface, "Auto-Pause", 1)) { ast_verb(3, "Auto-Pausing Queue Member %s in queue %s since they failed to answer.\n", interface, qe->parent->name); } else { ast_verb(3, "Failed to pause Queue Member %s in queue %s!\n", interface, qe->parent->name); } } else { /* If queue autopause is mode all, just don't send any queue to stop. * the function will stop in all queues */ if (!set_member_paused("", interface, "Auto-Pause", 1)) { ast_verb(3, "Auto-Pausing Queue Member %s in all queues since they failed to answer on queue %s.\n", interface, qe->parent->name); } else { ast_verb(3, "Failed to pause Queue Member %s in all queues!\n", interface); } } } return; } #define AST_MAX_WATCHERS 256 /*! * \brief Wait for a member to answer the call * * \param[in] qe the queue_ent corresponding to the caller in the queue * \param[in] outgoing the list of callattempts. Relevant ones will have their chan and stillgoing parameters non-zero * \param[in] to the amount of time (in milliseconds) to wait for a response * \param[out] digit if a user presses a digit to exit the queue, this is the digit the caller pressed * \param[in] prebusies number of busy members calculated prior to calling wait_for_answer * \param[in] caller_disconnect if the 'H' option is used when calling Queue(), this is used to detect if the caller pressed * to disconnect the call * \param[in] forwardsallowed used to detect if we should allow call forwarding, based on the 'i' option to Queue() * * \todo eventually all call forward logic should be intergerated into and replaced by ast_call_forward() */ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callattempt *outgoing, int *to, char *digit, int prebusies, int caller_disconnect, int forwardsallowed, int ringing) { const char *queue = qe->parent->name; struct callattempt *o, *start = NULL, *prev = NULL; int status; int numbusies = prebusies; int numnochan = 0; int stillgoing = 0; int orig = *to; struct ast_frame *f; struct callattempt *peer = NULL; struct ast_channel *winner; struct ast_channel *in = qe->chan; char on[80] = ""; char membername[80] = ""; long starttime = 0; long endtime = 0; #ifdef HAVE_EPOLL struct callattempt *epollo; #endif struct ast_party_connected_line connected_caller; char *inchan_name; struct timeval start_time_tv = ast_tvnow(); ast_party_connected_line_init(&connected_caller); ast_channel_lock(qe->chan); inchan_name = ast_strdupa(ast_channel_name(qe->chan)); ast_channel_unlock(qe->chan); starttime = (long) time(NULL); #ifdef HAVE_EPOLL for (epollo = outgoing; epollo; epollo = epollo->q_next) { if (epollo->chan) { ast_poll_channel_add(in, epollo->chan); } } #endif while ((*to = ast_remaining_ms(start_time_tv, orig)) && !peer) { int numlines, retry, pos = 1; struct ast_channel *watchers[AST_MAX_WATCHERS]; watchers[0] = in; start = NULL; for (retry = 0; retry < 2; retry++) { numlines = 0; for (o = outgoing; o; o = o->q_next) { /* Keep track of important channels */ if (o->stillgoing) { /* Keep track of important channels */ stillgoing = 1; if (o->chan) { if (pos < AST_MAX_WATCHERS) { watchers[pos++] = o->chan; } if (!start) { start = o; } else { prev->call_next = o; } prev = o; } } numlines++; } if (pos > 1 /* found */ || !stillgoing /* nobody listening */ || (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) /* ring would not be delivered */) { break; } /* On "ringall" strategy we only move to the next penalty level when *all* ringing phones are done in the current penalty level */ ring_one(qe, outgoing, &numbusies); /* and retry... */ } if (pos == 1 /* not found */) { if (numlines == (numbusies + numnochan)) { ast_debug(1, "Everyone is busy at this time\n"); } else { ast_debug(3, "No one is answering queue '%s' (%d numlines / %d busies / %d failed channels)\n", queue, numlines, numbusies, numnochan); } *to = 0; return NULL; } /* Poll for events from both the incoming channel as well as any outgoing channels */ winner = ast_waitfor_n(watchers, pos, to); /* Service all of the outgoing channels */ for (o = start; o; o = o->call_next) { /* We go with a fixed buffer here instead of using ast_strdupa. Using * ast_strdupa in a loop like this one can cause a stack overflow */ char ochan_name[AST_CHANNEL_NAME]; if (o->chan) { ast_channel_lock(o->chan); ast_copy_string(ochan_name, ast_channel_name(o->chan), sizeof(ochan_name)); ast_channel_unlock(o->chan); } if (o->stillgoing && (o->chan) && (ast_channel_state(o->chan) == AST_STATE_UP)) { if (!peer) { ast_verb(3, "%s answered %s\n", ochan_name, inchan_name); if (!o->block_connected_update) { if (o->pending_connected_update) { if (ast_channel_connected_line_sub(o->chan, in, &o->connected, 0) && ast_channel_connected_line_macro(o->chan, in, &o->connected, 1, 0)) { ast_channel_update_connected_line(in, &o->connected, NULL); } } else if (!o->dial_callerid_absent) { ast_channel_lock(o->chan); ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(o->chan)); ast_channel_unlock(o->chan); connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; if (ast_channel_connected_line_sub(o->chan, in, &connected_caller, 0) && ast_channel_connected_line_macro(o->chan, in, &connected_caller, 1, 0)) { ast_channel_update_connected_line(in, &connected_caller, NULL); } ast_party_connected_line_free(&connected_caller); } } if (o->aoc_s_rate_list) { size_t encoded_size; struct ast_aoc_encoded *encoded; if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) { ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size); ast_aoc_destroy_encoded(encoded); } } peer = o; } } else if (o->chan && (o->chan == winner)) { ast_copy_string(on, o->member->interface, sizeof(on)); ast_copy_string(membername, o->member->membername, sizeof(membername)); /* Before processing channel, go ahead and check for forwarding */ if (!ast_strlen_zero(ast_channel_call_forward(o->chan)) && !forwardsallowed) { ast_verb(3, "Forwarding %s to '%s' prevented.\n", inchan_name, ast_channel_call_forward(o->chan)); numnochan++; do_hang(o); winner = NULL; continue; } else if (!ast_strlen_zero(ast_channel_call_forward(o->chan))) { struct ast_channel *original = o->chan; char tmpchan[256]; char *stuff; char *tech; ast_copy_string(tmpchan, ast_channel_call_forward(o->chan), sizeof(tmpchan)); if ((stuff = strchr(tmpchan, '/'))) { *stuff++ = '\0'; tech = tmpchan; } else { snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(o->chan), ast_channel_context(o->chan)); stuff = tmpchan; tech = "Local"; } if (!strcasecmp(tech, "Local")) { /* * Drop the connected line update block for local channels since * this is going to run dialplan and the user can change his * mind about what connected line information he wants to send. */ o->block_connected_update = 0; } ast_cel_report_event(in, AST_CEL_FORWARD, NULL, ast_channel_call_forward(o->chan), NULL); ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", inchan_name, tech, stuff, ochan_name); /* Setup parameters */ o->chan = ast_request(tech, ast_channel_nativeformats(in), in, stuff, &status); if (!o->chan) { ast_log(LOG_NOTICE, "Forwarding failed to create channel to dial '%s/%s'\n", tech, stuff); o->stillgoing = 0; numnochan++; } else { ast_channel_lock_both(o->chan, original); ast_party_redirecting_copy(ast_channel_redirecting(o->chan), ast_channel_redirecting(original)); ast_channel_unlock(o->chan); ast_channel_unlock(original); ast_channel_lock_both(o->chan, in); ast_channel_inherit_variables(in, o->chan); ast_channel_datastore_inherit(in, o->chan); if (o->pending_connected_update) { /* * Re-seed the callattempt's connected line information with * previously acquired connected line info from the queued * channel. The previously acquired connected line info could * have been set through the CONNECTED_LINE dialplan function. */ o->pending_connected_update = 0; ast_party_connected_line_copy(&o->connected, ast_channel_connected(in)); } ast_channel_accountcode_set(o->chan, ast_channel_accountcode(in)); if (!ast_channel_redirecting(o->chan)->from.number.valid || ast_strlen_zero(ast_channel_redirecting(o->chan)->from.number.str)) { /* * The call was not previously redirected so it is * now redirected from this number. */ ast_party_number_free(&ast_channel_redirecting(o->chan)->from.number); ast_party_number_init(&ast_channel_redirecting(o->chan)->from.number); ast_channel_redirecting(o->chan)->from.number.valid = 1; ast_channel_redirecting(o->chan)->from.number.str = ast_strdup(S_OR(ast_channel_macroexten(in), ast_channel_exten(in))); } ast_channel_dialed(o->chan)->transit_network_select = ast_channel_dialed(in)->transit_network_select; o->dial_callerid_absent = !ast_channel_caller(o->chan)->id.number.valid || ast_strlen_zero(ast_channel_caller(o->chan)->id.number.str); ast_connected_line_copy_from_caller(ast_channel_connected(o->chan), ast_channel_caller(in)); ast_channel_unlock(in); if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL && !o->block_connected_update) { struct ast_party_redirecting redirecting; /* * Redirecting updates to the caller make sense only on single * call at a time strategies. * * We must unlock o->chan before calling * ast_channel_redirecting_macro, because we put o->chan into * autoservice there. That is pretty much a guaranteed * deadlock. This is why the handling of o->chan's lock may * seem a bit unusual here. */ ast_party_redirecting_init(&redirecting); ast_party_redirecting_copy(&redirecting, ast_channel_redirecting(o->chan)); ast_channel_unlock(o->chan); if (ast_channel_redirecting_sub(o->chan, in, &redirecting, 0) && ast_channel_redirecting_macro(o->chan, in, &redirecting, 1, 0)) { ast_channel_update_redirecting(in, &redirecting, NULL); } ast_party_redirecting_free(&redirecting); } else { ast_channel_unlock(o->chan); } if (ast_call(o->chan, stuff, 0)) { ast_log(LOG_NOTICE, "Forwarding failed to dial '%s/%s'\n", tech, stuff); do_hang(o); numnochan++; } } /* Hangup the original channel now, in case we needed it */ ast_hangup(winner); continue; } f = ast_read(winner); if (f) { if (f->frametype == AST_FRAME_CONTROL) { switch (f->subclass.integer) { case AST_CONTROL_ANSWER: /* This is our guy if someone answered. */ if (!peer) { ast_verb(3, "%s answered %s\n", ochan_name, inchan_name); if (!o->block_connected_update) { if (o->pending_connected_update) { if (ast_channel_connected_line_sub(o->chan, in, &o->connected, 0) && ast_channel_connected_line_macro(o->chan, in, &o->connected, 1, 0)) { ast_channel_update_connected_line(in, &o->connected, NULL); } } else if (!o->dial_callerid_absent) { ast_channel_lock(o->chan); ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(o->chan)); ast_channel_unlock(o->chan); connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; if (ast_channel_connected_line_sub(o->chan, in, &connected_caller, 0) && ast_channel_connected_line_macro(o->chan, in, &connected_caller, 1, 0)) { ast_channel_update_connected_line(in, &connected_caller, NULL); } ast_party_connected_line_free(&connected_caller); } } if (o->aoc_s_rate_list) { size_t encoded_size; struct ast_aoc_encoded *encoded; if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) { ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size); ast_aoc_destroy_encoded(encoded); } } peer = o; } break; case AST_CONTROL_BUSY: ast_verb(3, "%s is busy\n", ochan_name); if (ast_channel_cdr(in)) { ast_cdr_busy(ast_channel_cdr(in)); } do_hang(o); endtime = (long) time(NULL); endtime -= starttime; rna(endtime * 1000, qe, on, membername, qe->parent->autopausebusy); if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) { if (qe->parent->timeoutrestart) { start_time_tv = ast_tvnow(); } /* Have enough time for a queue member to answer? */ if (ast_remaining_ms(start_time_tv, orig) > 500) { ring_one(qe, outgoing, &numbusies); starttime = (long) time(NULL); } } numbusies++; break; case AST_CONTROL_CONGESTION: ast_verb(3, "%s is circuit-busy\n", ochan_name); if (ast_channel_cdr(in)) { ast_cdr_busy(ast_channel_cdr(in)); } endtime = (long) time(NULL); endtime -= starttime; rna(endtime * 1000, qe, on, membername, qe->parent->autopauseunavail); do_hang(o); if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) { if (qe->parent->timeoutrestart) { start_time_tv = ast_tvnow(); } if (ast_remaining_ms(start_time_tv, orig) > 500) { ring_one(qe, outgoing, &numbusies); starttime = (long) time(NULL); } } numbusies++; break; case AST_CONTROL_RINGING: ast_verb(3, "%s is ringing\n", ochan_name); /* Start ring indication when the channel is ringing, if specified */ if (qe->ring_when_ringing) { ast_moh_stop(qe->chan); ast_indicate(qe->chan, AST_CONTROL_RINGING); } break; case AST_CONTROL_OFFHOOK: /* Ignore going off hook */ break; case AST_CONTROL_CONNECTED_LINE: if (o->block_connected_update) { ast_verb(3, "Connected line update to %s prevented.\n", inchan_name); break; } if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) { struct ast_party_connected_line connected; ast_verb(3, "%s connected line has changed. Saving it until answer for %s\n", ochan_name, inchan_name); ast_party_connected_line_set_init(&connected, &o->connected); ast_connected_line_parse_data(f->data.ptr, f->datalen, &connected); ast_party_connected_line_set(&o->connected, &connected, NULL); ast_party_connected_line_free(&connected); o->pending_connected_update = 1; break; } /* * Prevent using the CallerID from the outgoing channel since we * got a connected line update from it. */ o->dial_callerid_absent = 1; if (ast_channel_connected_line_sub(o->chan, in, f, 1) && ast_channel_connected_line_macro(o->chan, in, f, 1, 1)) { ast_indicate_data(in, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen); } break; case AST_CONTROL_AOC: { struct ast_aoc_decoded *decoded = ast_aoc_decode(f->data.ptr, f->datalen, o->chan); if (decoded && (ast_aoc_get_msg_type(decoded) == AST_AOC_S)) { ast_aoc_destroy_decoded(o->aoc_s_rate_list); o->aoc_s_rate_list = decoded; } else { ast_aoc_destroy_decoded(decoded); } } break; case AST_CONTROL_REDIRECTING: if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) { /* * Redirecting updates to the caller make sense only on single * call at a time strategies. */ break; } if (o->block_connected_update) { ast_verb(3, "Redirecting update to %s prevented\n", inchan_name); break; } ast_verb(3, "%s redirecting info has changed, passing it to %s\n", ochan_name, inchan_name); if (ast_channel_redirecting_sub(o->chan, in, f, 1) && ast_channel_redirecting_macro(o->chan, in, f, 1, 1)) { ast_indicate_data(in, AST_CONTROL_REDIRECTING, f->data.ptr, f->datalen); } break; case AST_CONTROL_PVT_CAUSE_CODE: ast_indicate_data(in, AST_CONTROL_PVT_CAUSE_CODE, f->data.ptr, f->datalen); break; default: ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer); break; } } ast_frfree(f); } else { /* ast_read() returned NULL */ endtime = (long) time(NULL) - starttime; rna(endtime * 1000, qe, on, membername, 1); do_hang(o); if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) { if (qe->parent->timeoutrestart) { start_time_tv = ast_tvnow(); } if (ast_remaining_ms(start_time_tv, orig) > 500) { ring_one(qe, outgoing, &numbusies); starttime = (long) time(NULL); } } } } } /* If we received an event from the caller, deal with it. */ if (winner == in) { f = ast_read(in); if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) { /* Got hung up */ *to = -1; if (f) { if (f->data.uint32) { ast_channel_hangupcause_set(in, f->data.uint32); } ast_frfree(f); } return NULL; } if ((f->frametype == AST_FRAME_DTMF) && caller_disconnect && (f->subclass.integer == '*')) { ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer); *to = 0; ast_frfree(f); return NULL; } if ((f->frametype == AST_FRAME_DTMF) && valid_exit(qe, f->subclass.integer)) { ast_verb(3, "User pressed digit: %c\n", f->subclass.integer); *to = 0; *digit = f->subclass.integer; ast_frfree(f); return NULL; } /* Send the frame from the in channel to all outgoing channels. */ for (o = start; o; o = o->call_next) { if (!o->stillgoing || !o->chan) { /* This outgoing channel has died so don't send the frame to it. */ continue; } switch (f->frametype) { case AST_FRAME_CONTROL: switch (f->subclass.integer) { case AST_CONTROL_CONNECTED_LINE: if (ast_channel_connected_line_sub(in, o->chan, f, 1) && ast_channel_connected_line_macro(in, o->chan, f, 0, 1)) { ast_indicate_data(o->chan, f->subclass.integer, f->data.ptr, f->datalen); } break; case AST_CONTROL_REDIRECTING: if (ast_channel_redirecting_sub(in, o->chan, f, 1) && ast_channel_redirecting_macro(in, o->chan, f, 0, 1)) { ast_indicate_data(o->chan, f->subclass.integer, f->data.ptr, f->datalen); } break; default: /* We are not going to do anything with this frame. */ goto skip_frame; } break; default: /* We are not going to do anything with this frame. */ goto skip_frame; } } skip_frame:; ast_frfree(f); } } /* Make a position announcement, if enabled */ if (qe->parent->announcefrequency && qe->parent->announce_to_first_user) { say_position(qe, ringing); } /* Make a periodic announcement, if enabled */ if (qe->parent->periodicannouncefrequency && qe->parent->announce_to_first_user) { say_periodic_announcement(qe, ringing); } if (!*to) { for (o = start; o; o = o->call_next) { rna(orig, qe, o->interface, o->member->membername, 1); } } #ifdef HAVE_EPOLL for (epollo = outgoing; epollo; epollo = epollo->q_next) { if (epollo->chan) { ast_poll_channel_del(in, epollo->chan); } } #endif return peer; } /*! * \brief Check if we should start attempting to call queue members. * * A simple process, really. Count the number of members who are available * to take our call and then see if we are in a position in the queue at * which a member could accept our call. * * \param[in] qe The caller who wants to know if it is his turn * \retval 0 It is not our turn * \retval 1 It is our turn */ static int is_our_turn(struct queue_ent *qe) { struct queue_ent *ch; int res; int avl; int idx = 0; /* This needs a lock. How many members are available to be served? */ ao2_lock(qe->parent); avl = num_available_members(qe->parent); ch = qe->parent->head; ast_debug(1, "There %s %d available %s.\n", avl != 1 ? "are" : "is", avl, avl != 1 ? "members" : "member"); while ((idx < avl) && (ch) && (ch != qe)) { if (!ch->pending) { idx++; } ch = ch->next; } ao2_unlock(qe->parent); /* If the queue entry is within avl [the number of available members] calls from the top ... * Autofill and position check added to support autofill=no (as only calls * from the front of the queue are valid when autofill is disabled) */ if (ch && idx < avl && (qe->parent->autofill || qe->pos == 1)) { ast_debug(1, "It's our turn (%s).\n", ast_channel_name(qe->chan)); res = 1; } else { ast_debug(1, "It's not our turn (%s).\n", ast_channel_name(qe->chan)); res = 0; } return res; } /*! * \brief update rules for queues * * Calculate min/max penalties making sure if relative they stay within bounds. * Update queues penalty and set dialplan vars, goto next list entry. */ static void update_qe_rule(struct queue_ent *qe) { int max_penalty = qe->pr->max_relative ? qe->max_penalty + qe->pr->max_value : qe->pr->max_value; int min_penalty = qe->pr->min_relative ? qe->min_penalty + qe->pr->min_value : qe->pr->min_value; char max_penalty_str[20], min_penalty_str[20]; /* a relative change to the penalty could put it below 0 */ if (max_penalty < 0) { max_penalty = 0; } if (min_penalty < 0) { min_penalty = 0; } if (min_penalty > max_penalty) { min_penalty = max_penalty; } snprintf(max_penalty_str, sizeof(max_penalty_str), "%d", max_penalty); snprintf(min_penalty_str, sizeof(min_penalty_str), "%d", min_penalty); pbx_builtin_setvar_helper(qe->chan, "QUEUE_MAX_PENALTY", max_penalty_str); pbx_builtin_setvar_helper(qe->chan, "QUEUE_MIN_PENALTY", min_penalty_str); qe->max_penalty = max_penalty; qe->min_penalty = min_penalty; ast_debug(3, "Setting max penalty to %d and min penalty to %d for caller %s since %d seconds have elapsed\n", qe->max_penalty, qe->min_penalty, ast_channel_name(qe->chan), qe->pr->time); qe->pr = AST_LIST_NEXT(qe->pr, list); } /*! \brief The waiting areas for callers who are not actively calling members * * This function is one large loop. This function will return if a caller * either exits the queue or it becomes that caller's turn to attempt calling * queue members. Inside the loop, we service the caller with periodic announcements, * holdtime announcements, etc. as configured in queues.conf * * \retval 0 if the caller's turn has arrived * \retval -1 if the caller should exit the queue. */ static int wait_our_turn(struct queue_ent *qe, int ringing, enum queue_result *reason) { int res = 0; /* This is the holding pen for callers 2 through maxlen */ for (;;) { if (is_our_turn(qe)) { break; } /* If we have timed out, break out */ if (qe->expire && (time(NULL) >= qe->expire)) { *reason = QUEUE_TIMEOUT; break; } if (qe->parent->leavewhenempty) { int status = 0; if ((status = get_member_status(qe->parent, qe->max_penalty, qe->min_penalty, qe->parent->leavewhenempty))) { *reason = QUEUE_LEAVEEMPTY; ast_queue_log(qe->parent->name, ast_channel_uniqueid(qe->chan), "NONE", "EXITEMPTY", "%d|%d|%ld", qe->pos, qe->opos, (long) time(NULL) - qe->start); leave_queue(qe); break; } } /* Make a position announcement, if enabled */ if (qe->parent->announcefrequency && (res = say_position(qe,ringing))) { break; } /* If we have timed out, break out */ if (qe->expire && (time(NULL) >= qe->expire)) { *reason = QUEUE_TIMEOUT; break; } /* Make a periodic announcement, if enabled */ if (qe->parent->periodicannouncefrequency && (res = say_periodic_announcement(qe,ringing))) break; /* see if we need to move to the next penalty level for this queue */ while (qe->pr && ((time(NULL) - qe->start) >= qe->pr->time)) { update_qe_rule(qe); } /* If we have timed out, break out */ if (qe->expire && (time(NULL) >= qe->expire)) { *reason = QUEUE_TIMEOUT; break; } /* Wait a second before checking again */ if ((res = ast_waitfordigit(qe->chan, RECHECK * 1000))) { if (res > 0 && !valid_exit(qe, res)) { res = 0; } else { break; } } /* If we have timed out, break out */ if (qe->expire && (time(NULL) >= qe->expire)) { *reason = QUEUE_TIMEOUT; break; } } return res; } /*! * \brief update the queue status * \retval Always 0 */ static int update_queue(struct call_queue *q, struct member *member, int callcompletedinsl, int newtalktime) { int oldtalktime; struct member *mem; struct call_queue *qtmp; struct ao2_iterator queue_iter; if (shared_lastcall) { queue_iter = ao2_iterator_init(queues, 0); while ((qtmp = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { ao2_lock(qtmp); if ((mem = ao2_find(qtmp->members, member, OBJ_POINTER))) { time(&mem->lastcall); mem->calls++; mem->lastqueue = q; ao2_ref(mem, -1); } ao2_unlock(qtmp); queue_t_unref(qtmp, "Done with iterator"); } ao2_iterator_destroy(&queue_iter); } else { ao2_lock(q); time(&member->lastcall); member->calls++; member->lastqueue = q; ao2_unlock(q); } ao2_lock(q); q->callscompleted++; if (callcompletedinsl) { q->callscompletedinsl++; } /* Calculate talktime using the same exponential average as holdtime code*/ oldtalktime = q->talktime; q->talktime = (((oldtalktime << 2) - oldtalktime) + newtalktime) >> 2; ao2_unlock(q); return 0; } /*! \brief Calculate the metric of each member in the outgoing callattempts * * A numeric metric is given to each member depending on the ring strategy used * by the queue. Members with lower metrics will be called before members with * higher metrics * \retval -1 if penalties are exceeded * \retval 0 otherwise */ static int calc_metric(struct call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct callattempt *tmp) { /* disregarding penalty on too few members? */ int membercount = ao2_container_count(q->members); unsigned char usepenalty = (membercount <= q->penaltymemberslimit) ? 0 : 1; if (usepenalty) { if ((qe->max_penalty && (mem->penalty > qe->max_penalty)) || (qe->min_penalty && (mem->penalty < qe->min_penalty))) { return -1; } } else { ast_debug(1, "Disregarding penalty, %d members and %d in penaltymemberslimit.\n", membercount, q->penaltymemberslimit); } switch (q->strategy) { case QUEUE_STRATEGY_RINGALL: /* Everyone equal, except for penalty */ tmp->metric = mem->penalty * 1000000 * usepenalty; break; case QUEUE_STRATEGY_LINEAR: if (pos < qe->linpos) { tmp->metric = 1000 + pos; } else { if (pos > qe->linpos) { /* Indicate there is another priority */ qe->linwrapped = 1; } tmp->metric = pos; } tmp->metric += mem->penalty * 1000000 * usepenalty; break; case QUEUE_STRATEGY_RRORDERED: case QUEUE_STRATEGY_RRMEMORY: pos = mem->queuepos; if (pos < q->rrpos) { tmp->metric = 1000 + pos; } else { if (pos > q->rrpos) { /* Indicate there is another priority */ q->wrapped = 1; } tmp->metric = pos; } tmp->metric += mem->penalty * 1000000 * usepenalty; break; case QUEUE_STRATEGY_RANDOM: tmp->metric = ast_random() % 1000; tmp->metric += mem->penalty * 1000000 * usepenalty; break; case QUEUE_STRATEGY_WRANDOM: tmp->metric = ast_random() % ((1 + mem->penalty) * 1000); break; case QUEUE_STRATEGY_FEWESTCALLS: tmp->metric = mem->calls; tmp->metric += mem->penalty * 1000000 * usepenalty; break; case QUEUE_STRATEGY_LEASTRECENT: if (!mem->lastcall) { tmp->metric = 0; } else { tmp->metric = 1000000 - (time(NULL) - mem->lastcall); } tmp->metric += mem->penalty * 1000000 * usepenalty; break; default: ast_log(LOG_WARNING, "Can't calculate metric for unknown strategy %d\n", q->strategy); break; } return 0; } enum agent_complete_reason { CALLER, AGENT, TRANSFER }; /*! \brief Send out AMI message with member call completion status information */ static void send_agent_complete(const struct queue_ent *qe, const char *queuename, const struct ast_channel *peer, const struct member *member, time_t callstart, char *vars, size_t vars_len, enum agent_complete_reason rsn) { const char *reason = NULL; /* silence dumb compilers */ if (!qe->parent->eventwhencalled) { return; } switch (rsn) { case CALLER: reason = "caller"; break; case AGENT: reason = "agent"; break; case TRANSFER: reason = "transfer"; break; } /*** DOCUMENTATION Raised when an agent has finished servicing a member in the queue. The time the agent talked with the member in the queue, expressed in seconds since 00:00, Jan 1, 1970 UTC. AgentCalled AgentConnect ***/ manager_event(EVENT_FLAG_AGENT, "AgentComplete", "Queue: %s\r\n" "Uniqueid: %s\r\n" "Channel: %s\r\n" "Member: %s\r\n" "MemberName: %s\r\n" "HoldTime: %ld\r\n" "TalkTime: %ld\r\n" "Reason: %s\r\n" "%s", queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername, (long)(callstart - qe->start), (long)(time(NULL) - callstart), reason, qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, vars_len) : ""); } struct queue_transfer_ds { struct queue_ent *qe; struct member *member; time_t starttime; int callcompletedinsl; }; static void queue_transfer_destroy(void *data) { struct queue_transfer_ds *qtds = data; ast_free(qtds); } /*! \brief a datastore used to help correctly log attended transfers of queue callers */ static const struct ast_datastore_info queue_transfer_info = { .type = "queue_transfer", .chan_fixup = queue_transfer_fixup, .destroy = queue_transfer_destroy, }; /*! \brief Log an attended transfer when a queue caller channel is masqueraded * * When a caller is masqueraded, we want to log a transfer. Fixup time is the closest we can come to when * the actual transfer occurs. This happens during the masquerade after datastores are moved from old_chan * to new_chan. This is why new_chan is referenced for exten, context, and datastore information. * * At the end of this, we want to remove the datastore so that this fixup function is not called on any * future masquerades of the caller during the current call. */ static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan) { struct queue_transfer_ds *qtds = data; struct queue_ent *qe = qtds->qe; struct member *member = qtds->member; time_t callstart = qtds->starttime; int callcompletedinsl = qtds->callcompletedinsl; struct ast_datastore *datastore; ast_queue_log(qe->parent->name, ast_channel_uniqueid(qe->chan), member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d", ast_channel_exten(new_chan), ast_channel_context(new_chan), (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos); update_queue(qe->parent, member, callcompletedinsl, (time(NULL) - callstart)); /* No need to lock the channels because they are already locked in ast_do_masquerade */ if ((datastore = ast_channel_datastore_find(old_chan, &queue_transfer_info, NULL))) { ast_channel_datastore_remove(old_chan, datastore); } else { ast_log(LOG_WARNING, "Can't find the queue_transfer datastore.\n"); } } /*! \brief mechanism to tell if a queue caller was atxferred by a queue member. * * When a caller is atxferred, then the queue_transfer_info datastore * is removed from the channel. If it's still there after the bridge is * broken, then the caller was not atxferred. * * \note Only call this with chan locked */ static int attended_transfer_occurred(struct ast_channel *chan) { return ast_channel_datastore_find(chan, &queue_transfer_info, NULL) ? 0 : 1; } /*! \brief create a datastore for storing relevant info to log attended transfers in the queue_log */ static struct ast_datastore *setup_transfer_datastore(struct queue_ent *qe, struct member *member, time_t starttime, int callcompletedinsl) { struct ast_datastore *ds; struct queue_transfer_ds *qtds = ast_calloc(1, sizeof(*qtds)); if (!qtds) { ast_log(LOG_WARNING, "Memory allocation error!\n"); return NULL; } ast_channel_lock(qe->chan); if (!(ds = ast_datastore_alloc(&queue_transfer_info, NULL))) { ast_channel_unlock(qe->chan); ast_free(qtds); ast_log(LOG_WARNING, "Unable to create transfer datastore. queue_log will not show attended transfer\n"); return NULL; } qtds->qe = qe; /* This member is refcounted in try_calling, so no need to add it here, too */ qtds->member = member; qtds->starttime = starttime; qtds->callcompletedinsl = callcompletedinsl; ds->data = qtds; ast_channel_datastore_add(qe->chan, ds); ast_channel_unlock(qe->chan); return ds; } struct queue_end_bridge { struct call_queue *q; struct ast_channel *chan; }; static void end_bridge_callback_data_fixup(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator) { struct queue_end_bridge *qeb = bconfig->end_bridge_callback_data; ao2_ref(qeb, +1); qeb->chan = originator; } static void end_bridge_callback(void *data) { struct queue_end_bridge *qeb = data; struct call_queue *q = qeb->q; struct ast_channel *chan = qeb->chan; if (ao2_ref(qeb, -1) == 1) { set_queue_variables(q, chan); /* This unrefs the reference we made in try_calling when we allocated qeb */ queue_t_unref(q, "Expire bridge_config reference"); } } /*! * \internal * \brief A large function which calls members, updates statistics, and bridges the caller and a member * * Here is the process of this function * 1. Process any options passed to the Queue() application. Options here mean the third argument to Queue() * 2. Iterate trough the members of the queue, creating a callattempt corresponding to each member. During this * iteration, we also check the dialed_interfaces datastore to see if we have already attempted calling this * member. If we have, we do not create a callattempt. This is in place to prevent call forwarding loops. Also * during each iteration, we call calc_metric to determine which members should be rung when. * 3. Call ring_one to place a call to the appropriate member(s) * 4. Call wait_for_answer to wait for an answer. If no one answers, return. * 5. Take care of any holdtime announcements, member delays, or other options which occur after a call has been answered. * 6. Start the monitor or mixmonitor if the option is set * 7. Remove the caller from the queue to allow other callers to advance * 8. Bridge the call. * 9. Do any post processing after the call has disconnected. * * \param[in] qe the queue_ent structure which corresponds to the caller attempting to reach members * \param[in] opts the options passed as the third parameter to the Queue() application * \param[in] opt_args the options passed as the third parameter to the Queue() application * \param[in] announceoverride filename to play to user when waiting * \param[in] url the url passed as the fourth parameter to the Queue() application * \param[in,out] tries the number of times we have tried calling queue members * \param[out] noption set if the call to Queue() has the 'n' option set. * \param[in] agi the agi passed as the fifth parameter to the Queue() application * \param[in] macro the macro passed as the sixth parameter to the Queue() application * \param[in] gosub the gosub passed as the seventh parameter to the Queue() application * \param[in] ringing 1 if the 'r' option is set, otherwise 0 */ static int try_calling(struct queue_ent *qe, const struct ast_flags opts, char **opt_args, char *announceoverride, const char *url, int *tries, int *noption, const char *agi, const char *macro, const char *gosub, int ringing) { struct member *cur; struct callattempt *outgoing = NULL; /* the list of calls we are building */ int to, orig; char oldexten[AST_MAX_EXTENSION]=""; char oldcontext[AST_MAX_CONTEXT]=""; char queuename[256]=""; char interfacevar[256]=""; struct ast_channel *peer; struct ast_channel *which; struct callattempt *lpeer; struct member *member; struct ast_app *application; int res = 0, bridge = 0; int numbusies = 0; int x=0; char *announce = NULL; char digit = 0; time_t callstart; time_t now = time(NULL); struct ast_bridge_config bridge_config; char nondataquality = 1; char *agiexec = NULL; char *macroexec = NULL; char *gosubexec = NULL; const char *monitorfilename; const char *monitor_exec; const char *monitor_options; char tmpid[256], tmpid2[256]; char meid[1024], meid2[1024]; char mixmonargs[1512]; struct ast_app *mixmonapp = NULL; char *p; char vars[2048]; int forwardsallowed = 1; int block_connected_line = 0; int callcompletedinsl; struct ao2_iterator memi; struct ast_datastore *datastore, *transfer_ds; struct queue_end_bridge *queue_end_bridge = NULL; ast_channel_lock(qe->chan); datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL); ast_channel_unlock(qe->chan); memset(&bridge_config, 0, sizeof(bridge_config)); tmpid[0] = 0; meid[0] = 0; time(&now); /* If we've already exceeded our timeout, then just stop * This should be extremely rare. queue_exec will take care * of removing the caller and reporting the timeout as the reason. */ if (qe->expire && now >= qe->expire) { res = 0; goto out; } if (ast_test_flag(&opts, OPT_CALLEE_TRANSFER)) { ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_REDIRECT); } if (ast_test_flag(&opts, OPT_CALLER_TRANSFER)) { ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_REDIRECT); } if (ast_test_flag(&opts, OPT_CALLEE_AUTOMON)) { ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_AUTOMON); } if (ast_test_flag(&opts, OPT_CALLER_AUTOMON)) { ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_AUTOMON); } if (ast_test_flag(&opts, OPT_GO_ON)) { ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_NO_H_EXTEN); } if (ast_test_flag(&opts, OPT_DATA_QUALITY)) { nondataquality = 0; } if (ast_test_flag(&opts, OPT_CALLEE_HANGUP)) { ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_DISCONNECT); } if (ast_test_flag(&opts, OPT_CALLER_HANGUP)) { ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT); } if (ast_test_flag(&opts, OPT_CALLEE_PARK)) { ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_PARKCALL); } if (ast_test_flag(&opts, OPT_CALLER_PARK)) { ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_PARKCALL); } if (ast_test_flag(&opts, OPT_NO_RETRY)) { if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY || qe->parent->strategy == QUEUE_STRATEGY_LINEAR || qe->parent->strategy == QUEUE_STRATEGY_RRORDERED) { (*tries)++; } else { *tries = ao2_container_count(qe->parent->members); } *noption = 1; } if (ast_test_flag(&opts, OPT_IGNORE_CALL_FW)) { forwardsallowed = 0; } if (ast_test_flag(&opts, OPT_IGNORE_CONNECTEDLINE)) { block_connected_line = 1; } if (ast_test_flag(&opts, OPT_CALLEE_AUTOMIXMON)) { ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_AUTOMIXMON); } if (ast_test_flag(&opts, OPT_CALLER_AUTOMIXMON)) { ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_AUTOMIXMON); } if (ast_test_flag(&opts, OPT_MARK_AS_ANSWERED)) { qe->cancel_answered_elsewhere = 1; } /* if the calling channel has AST_CAUSE_ANSWERED_ELSEWHERE set, make sure this is inherited. (this is mainly to support chan_local) */ if (ast_channel_hangupcause(qe->chan) == AST_CAUSE_ANSWERED_ELSEWHERE) { qe->cancel_answered_elsewhere = 1; } ao2_lock(qe->parent); ast_debug(1, "%s is trying to call a queue member.\n", ast_channel_name(qe->chan)); ast_copy_string(queuename, qe->parent->name, sizeof(queuename)); if (!ast_strlen_zero(qe->announce)) { announce = qe->announce; } if (!ast_strlen_zero(announceoverride)) { announce = announceoverride; } memi = ao2_iterator_init(qe->parent->members, 0); while ((cur = ao2_iterator_next(&memi))) { struct callattempt *tmp = ast_calloc(1, sizeof(*tmp)); struct ast_dialed_interface *di; AST_LIST_HEAD(,ast_dialed_interface) *dialed_interfaces; if (!tmp) { ao2_ref(cur, -1); ao2_iterator_destroy(&memi); ao2_unlock(qe->parent); goto out; } if (!datastore) { if (!(datastore = ast_datastore_alloc(&dialed_interface_info, NULL))) { callattempt_free(tmp); ao2_ref(cur, -1); ao2_iterator_destroy(&memi); ao2_unlock(qe->parent); goto out; } datastore->inheritance = DATASTORE_INHERIT_FOREVER; if (!(dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces)))) { callattempt_free(tmp); ao2_ref(cur, -1); ao2_iterator_destroy(&memi); ao2_unlock(qe->parent); goto out; } datastore->data = dialed_interfaces; AST_LIST_HEAD_INIT(dialed_interfaces); ast_channel_lock(qe->chan); ast_channel_datastore_add(qe->chan, datastore); ast_channel_unlock(qe->chan); } else dialed_interfaces = datastore->data; AST_LIST_LOCK(dialed_interfaces); AST_LIST_TRAVERSE(dialed_interfaces, di, list) { if (!strcasecmp(cur->interface, di->interface)) { ast_debug(1, "Skipping dialing interface '%s' since it has already been dialed\n", di->interface); break; } } AST_LIST_UNLOCK(dialed_interfaces); if (di) { callattempt_free(tmp); ao2_ref(cur, -1); continue; } /* It is always ok to dial a Local interface. We only keep track of * which "real" interfaces have been dialed. The Local channel will * inherit this list so that if it ends up dialing a real interface, * it won't call one that has already been called. */ if (strncasecmp(cur->interface, "Local/", 6)) { if (!(di = ast_calloc(1, sizeof(*di) + strlen(cur->interface)))) { callattempt_free(tmp); ao2_ref(cur, -1); ao2_iterator_destroy(&memi); ao2_unlock(qe->parent); goto out; } strcpy(di->interface, cur->interface); AST_LIST_LOCK(dialed_interfaces); AST_LIST_INSERT_TAIL(dialed_interfaces, di, list); AST_LIST_UNLOCK(dialed_interfaces); } /* * Seed the callattempt's connected line information with previously * acquired connected line info from the queued channel. The * previously acquired connected line info could have been set * through the CONNECTED_LINE dialplan function. */ ast_channel_lock(qe->chan); ast_party_connected_line_copy(&tmp->connected, ast_channel_connected(qe->chan)); ast_channel_unlock(qe->chan); tmp->block_connected_update = block_connected_line; tmp->stillgoing = 1; tmp->member = cur;/* Place the reference for cur into callattempt. */ tmp->lastcall = cur->lastcall; tmp->lastqueue = cur->lastqueue; ast_copy_string(tmp->interface, cur->interface, sizeof(tmp->interface)); /* Special case: If we ring everyone, go ahead and ring them, otherwise just calculate their metric for the appropriate strategy */ if (!calc_metric(qe->parent, cur, x++, qe, tmp)) { /* Put them in the list of outgoing thingies... We're ready now. XXX If we're forcibly removed, these outgoing calls won't get hung up XXX */ tmp->q_next = outgoing; outgoing = tmp; /* If this line is up, don't try anybody else */ if (outgoing->chan && (ast_channel_state(outgoing->chan) == AST_STATE_UP)) break; } else { callattempt_free(tmp); } } ao2_iterator_destroy(&memi); if (qe->parent->timeoutpriority == TIMEOUT_PRIORITY_APP) { /* Application arguments have higher timeout priority (behaviour for <=1.6) */ if (qe->expire && (!qe->parent->timeout || (qe->expire - now) <= qe->parent->timeout)) { to = (qe->expire - now) * 1000; } else { to = (qe->parent->timeout) ? qe->parent->timeout * 1000 : -1; } } else { /* Config timeout is higher priority thatn application timeout */ if (qe->expire && qe->expire<=now) { to = 0; } else if (qe->parent->timeout) { to = qe->parent->timeout * 1000; } else { to = -1; } } orig = to; ++qe->pending; ao2_unlock(qe->parent); ring_one(qe, outgoing, &numbusies); lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT), forwardsallowed, ringing); /* The ast_channel_datastore_remove() function could fail here if the * datastore was moved to another channel during a masquerade. If this is * the case, don't free the datastore here because later, when the channel * to which the datastore was moved hangs up, it will attempt to free this * datastore again, causing a crash */ ast_channel_lock(qe->chan); if (datastore && !ast_channel_datastore_remove(qe->chan, datastore)) { ast_datastore_free(datastore); } ast_channel_unlock(qe->chan); ao2_lock(qe->parent); if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY || qe->parent->strategy == QUEUE_STRATEGY_RRORDERED) { store_next_rr(qe, outgoing); } if (qe->parent->strategy == QUEUE_STRATEGY_LINEAR) { store_next_lin(qe, outgoing); } ao2_unlock(qe->parent); peer = lpeer ? lpeer->chan : NULL; if (!peer) { qe->pending = 0; if (to) { /* Must gotten hung up */ res = -1; } else { /* User exited by pressing a digit */ res = digit; } if (res == -1) { ast_debug(1, "%s: Nobody answered.\n", ast_channel_name(qe->chan)); } if (ast_cdr_isset_unanswered()) { /* channel contains the name of one of the outgoing channels in its CDR; zero out this CDR to avoid a dual-posting */ struct callattempt *o; for (o = outgoing; o; o = o->q_next) { if (!o->chan) { continue; } if (strcmp(ast_channel_cdr(o->chan)->dstchannel, ast_channel_cdr(qe->chan)->dstchannel) == 0) { ast_set_flag(ast_channel_cdr(o->chan), AST_CDR_FLAG_POST_DISABLED); break; } } } } else { /* peer is valid */ /* These variables are used with the F option without arguments (callee jumps to next priority after queue) */ char *caller_context; char *caller_extension; int caller_priority; /* Ah ha! Someone answered within the desired timeframe. Of course after this we will always return with -1 so that it is hung up properly after the conversation. */ if (!strcmp(ast_channel_tech(qe->chan)->type, "DAHDI")) { ast_channel_setoption(qe->chan, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0); } if (!strcmp(ast_channel_tech(peer)->type, "DAHDI")) { ast_channel_setoption(peer, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0); } /* Update parameters for the queue */ time(&now); recalc_holdtime(qe, (now - qe->start)); ao2_lock(qe->parent); callcompletedinsl = ((now - qe->start) <= qe->parent->servicelevel); ao2_unlock(qe->parent); member = lpeer->member; /* Increment the refcount for this member, since we're going to be using it for awhile in here. */ ao2_ref(member, 1); hangupcalls(outgoing, peer, qe->cancel_answered_elsewhere); outgoing = NULL; if (announce || qe->parent->reportholdtime || qe->parent->memberdelay) { int res2; res2 = ast_autoservice_start(qe->chan); if (!res2) { if (qe->parent->memberdelay) { ast_log(LOG_NOTICE, "Delaying member connect for %d seconds\n", qe->parent->memberdelay); res2 = ast_safe_sleep(peer, qe->parent->memberdelay * 1000); } if (!res2 && announce) { if (play_file(peer, announce) < 0) { ast_log(LOG_ERROR, "play_file failed for '%s' on %s\n", announce, ast_channel_name(peer)); } } if (!res2 && qe->parent->reportholdtime) { if (!play_file(peer, qe->parent->sound_reporthold)) { int holdtime, holdtimesecs; time(&now); holdtime = abs((now - qe->start) / 60); holdtimesecs = abs((now - qe->start) % 60); if (holdtime > 0) { ast_say_number(peer, holdtime, AST_DIGIT_ANY, ast_channel_language(peer), NULL); if (play_file(peer, qe->parent->sound_minutes) < 0) { ast_log(LOG_ERROR, "play_file failed for '%s' on %s\n", qe->parent->sound_minutes, ast_channel_name(peer)); } } if (holdtimesecs > 1) { ast_say_number(peer, holdtimesecs, AST_DIGIT_ANY, ast_channel_language(peer), NULL); if (play_file(peer, qe->parent->sound_seconds) < 0) { ast_log(LOG_ERROR, "play_file failed for '%s' on %s\n", qe->parent->sound_seconds, ast_channel_name(peer)); } } } } ast_autoservice_stop(qe->chan); } if (ast_check_hangup(peer)) { /* Agent must have hung up */ ast_log(LOG_WARNING, "Agent on %s hungup on the customer.\n", ast_channel_name(peer)); ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "AGENTDUMP", "%s", ""); if (qe->parent->eventwhencalled) /*** DOCUMENTATION Raised when an agent hangs up on a member in the queue. AgentCalled AgentConnect ***/ manager_event(EVENT_FLAG_AGENT, "AgentDump", "Queue: %s\r\n" "Uniqueid: %s\r\n" "Channel: %s\r\n" "Member: %s\r\n" "MemberName: %s\r\n" "%s", queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername, qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); ast_autoservice_chan_hangup_peer(qe->chan, peer); ao2_ref(member, -1); goto out; } else if (ast_check_hangup(qe->chan)) { /* Caller must have hung up just before being connected */ ast_log(LOG_NOTICE, "Caller was about to talk to agent on %s but the caller hungup.\n", ast_channel_name(peer)); ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "ABANDON", "%d|%d|%ld", qe->pos, qe->opos, (long) time(NULL) - qe->start); record_abandoned(qe); ast_autoservice_chan_hangup_peer(qe->chan, peer); ao2_ref(member, -1); return -1; } } /* Stop music on hold */ if (ringing) { ast_indicate(qe->chan,-1); } else { ast_moh_stop(qe->chan); } /* If appropriate, log that we have a destination channel */ if (ast_channel_cdr(qe->chan)) { ast_cdr_setdestchan(ast_channel_cdr(qe->chan), ast_channel_name(peer)); } /* Make sure channels are compatible */ res = ast_channel_make_compatible(qe->chan, peer); if (res < 0) { ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "SYSCOMPAT", "%s", ""); ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", ast_channel_name(qe->chan), ast_channel_name(peer)); record_abandoned(qe); ast_cdr_failed(ast_channel_cdr(qe->chan)); ast_autoservice_chan_hangup_peer(qe->chan, peer); ao2_ref(member, -1); return -1; } /* Play announcement to the caller telling it's his turn if defined */ if (!ast_strlen_zero(qe->parent->sound_callerannounce)) { if (play_file(qe->chan, qe->parent->sound_callerannounce)) { ast_log(LOG_WARNING, "Announcement file '%s' is unavailable, continuing anyway...\n", qe->parent->sound_callerannounce); } } ao2_lock(qe->parent); /* if setinterfacevar is defined, make member variables available to the channel */ /* use pbx_builtin_setvar to set a load of variables with one call */ if (qe->parent->setinterfacevar) { snprintf(interfacevar, sizeof(interfacevar), "MEMBERINTERFACE=%s,MEMBERNAME=%s,MEMBERCALLS=%d,MEMBERLASTCALL=%ld,MEMBERPENALTY=%d,MEMBERDYNAMIC=%d,MEMBERREALTIME=%d", member->interface, member->membername, member->calls, (long)member->lastcall, member->penalty, member->dynamic, member->realtime); pbx_builtin_setvar_multiple(qe->chan, interfacevar); pbx_builtin_setvar_multiple(peer, interfacevar); } /* if setqueueentryvar is defined, make queue entry (i.e. the caller) variables available to the channel */ /* use pbx_builtin_setvar to set a load of variables with one call */ if (qe->parent->setqueueentryvar) { snprintf(interfacevar, sizeof(interfacevar), "QEHOLDTIME=%ld,QEORIGINALPOS=%d", (long) time(NULL) - qe->start, qe->opos); pbx_builtin_setvar_multiple(qe->chan, interfacevar); pbx_builtin_setvar_multiple(peer, interfacevar); } ao2_unlock(qe->parent); /* try to set queue variables if configured to do so*/ set_queue_variables(qe->parent, qe->chan); set_queue_variables(qe->parent, peer); ast_channel_lock(qe->chan); /* Copy next destination data for 'F' option (no args) */ caller_context = ast_strdupa(ast_channel_context(qe->chan)); caller_extension = ast_strdupa(ast_channel_exten(qe->chan)); caller_priority = ast_channel_priority(qe->chan); if ((monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME"))) { monitorfilename = ast_strdupa(monitorfilename); } ast_channel_unlock(qe->chan); /* Begin Monitoring */ if (qe->parent->monfmt && *qe->parent->monfmt) { if (!qe->parent->montype) { const char *monexec; ast_debug(1, "Starting Monitor as requested.\n"); ast_channel_lock(qe->chan); if ((monexec = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC")) || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS")) { which = qe->chan; monexec = monexec ? ast_strdupa(monexec) : NULL; } else { which = peer; } ast_channel_unlock(qe->chan); if (monitorfilename) { ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1, X_REC_IN | X_REC_OUT); } else if (ast_channel_cdr(qe->chan)) { ast_monitor_start(which, qe->parent->monfmt, ast_channel_cdr(qe->chan)->uniqueid, 1, X_REC_IN | X_REC_OUT); } else { /* Last ditch effort -- no CDR, make up something */ snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random()); ast_monitor_start(which, qe->parent->monfmt, tmpid, 1, X_REC_IN | X_REC_OUT); } if (!ast_strlen_zero(monexec)) { ast_monitor_setjoinfiles(which, 1); } } else { mixmonapp = pbx_findapp("MixMonitor"); if (mixmonapp) { ast_debug(1, "Starting MixMonitor as requested.\n"); if (!monitorfilename) { if (ast_channel_cdr(qe->chan)) { ast_copy_string(tmpid, ast_channel_cdr(qe->chan)->uniqueid, sizeof(tmpid)); } else { snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random()); } } else { const char *m = monitorfilename; for (p = tmpid2; p < tmpid2 + sizeof(tmpid2) - 1; p++, m++) { switch (*m) { case '^': if (*(m + 1) == '{') *p = '$'; break; case ',': *p++ = '\\'; /* Fall through */ default: *p = *m; } if (*m == '\0') break; } if (p == tmpid2 + sizeof(tmpid2)) tmpid2[sizeof(tmpid2) - 1] = '\0'; pbx_substitute_variables_helper(qe->chan, tmpid2, tmpid, sizeof(tmpid) - 1); } ast_channel_lock(qe->chan); if ((monitor_exec = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC"))) { monitor_exec = ast_strdupa(monitor_exec); } if ((monitor_options = pbx_builtin_getvar_helper(qe->chan, "MONITOR_OPTIONS"))) { monitor_options = ast_strdupa(monitor_options); } else { monitor_options = ""; } ast_channel_unlock(qe->chan); if (monitor_exec) { const char *m = monitor_exec; for (p = meid2; p < meid2 + sizeof(meid2) - 1; p++, m++) { switch (*m) { case '^': if (*(m + 1) == '{') *p = '$'; break; case ',': *p++ = '\\'; /* Fall through */ default: *p = *m; } if (*m == '\0') { break; } } if (p == meid2 + sizeof(meid2)) { meid2[sizeof(meid2) - 1] = '\0'; } pbx_substitute_variables_helper(qe->chan, meid2, meid, sizeof(meid) - 1); } snprintf(tmpid2, sizeof(tmpid2), "%s.%s", tmpid, qe->parent->monfmt); if (!ast_strlen_zero(monitor_exec)) { snprintf(mixmonargs, sizeof(mixmonargs), "%s,b%s,%s", tmpid2, monitor_options, monitor_exec); } else { snprintf(mixmonargs, sizeof(mixmonargs), "%s,b%s", tmpid2, monitor_options); } ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs); /* We purposely lock the CDR so that pbx_exec does not update the application data */ if (ast_channel_cdr(qe->chan)) { ast_set_flag(ast_channel_cdr(qe->chan), AST_CDR_FLAG_LOCKED); } pbx_exec(qe->chan, mixmonapp, mixmonargs); if (ast_channel_cdr(qe->chan)) { ast_clear_flag(ast_channel_cdr(qe->chan), AST_CDR_FLAG_LOCKED); } } else { ast_log(LOG_WARNING, "Asked to run MixMonitor on this call, but cannot find the MixMonitor app!\n"); } } } /* Drop out of the queue at this point, to prepare for next caller */ leave_queue(qe); if (!ast_strlen_zero(url) && ast_channel_supports_html(peer)) { ast_debug(1, "app_queue: sendurl=%s.\n", url); ast_channel_sendurl(peer, url); } /* run a macro for this connection if defined. The macro simply returns, no action is taken on the result */ /* use macro from dialplan if passed as a option, otherwise use the default queue macro */ if (!ast_strlen_zero(macro)) { macroexec = ast_strdupa(macro); } else { if (qe->parent->membermacro) { macroexec = ast_strdupa(qe->parent->membermacro); } } if (!ast_strlen_zero(macroexec)) { ast_debug(1, "app_queue: macro=%s.\n", macroexec); ast_app_exec_macro(qe->chan, peer, macroexec); } /* run a gosub for this connection if defined. The gosub simply returns, no action is taken on the result */ /* use gosub from dialplan if passed as a option, otherwise use the default queue gosub */ if (!ast_strlen_zero(gosub)) { gosubexec = ast_strdupa(gosub); } else { if (qe->parent->membergosub) { gosubexec = ast_strdupa(qe->parent->membergosub); } } if (!ast_strlen_zero(gosubexec)) { char *gosub_args = NULL; char *gosub_argstart; ast_debug(1, "app_queue: gosub=%s.\n", gosubexec); gosub_argstart = strchr(gosubexec, ','); if (gosub_argstart) { const char *what_is_s = "s"; *gosub_argstart = 0; if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) && ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) { what_is_s = "~~s~~"; } if (ast_asprintf(&gosub_args, "%s,%s,1(%s)", gosubexec, what_is_s, gosub_argstart + 1) < 0) { gosub_args = NULL; } *gosub_argstart = ','; } else { const char *what_is_s = "s"; if (!ast_exists_extension(peer, gosubexec, "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) && ast_exists_extension(peer, gosubexec, "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) { what_is_s = "~~s~~"; } if (ast_asprintf(&gosub_args, "%s,%s,1", gosubexec, what_is_s) < 0) { gosub_args = NULL; } } if (gosub_args) { ast_app_exec_sub(qe->chan, peer, gosub_args, 0); ast_free(gosub_args); } else { ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n"); } } if (!ast_strlen_zero(agi)) { ast_debug(1, "app_queue: agi=%s.\n", agi); application = pbx_findapp("agi"); if (application) { agiexec = ast_strdupa(agi); pbx_exec(qe->chan, application, agiexec); } else { ast_log(LOG_WARNING, "Asked to execute an AGI on this channel, but could not find application (agi)!\n"); } } qe->handled++; ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "CONNECT", "%ld|%s|%ld", (long) time(NULL) - qe->start, ast_channel_uniqueid(peer), (long)(orig - to > 0 ? (orig - to) / 1000 : 0)); if (ast_channel_cdr(qe->chan)) { struct ast_cdr *cdr; struct ast_cdr *newcdr; /* Only work with the last CDR in the stack*/ cdr = ast_channel_cdr(qe->chan); while (cdr->next) { cdr = cdr->next; } /* If this CDR is not related to us add new one*/ if ((strcasecmp(cdr->uniqueid, ast_channel_uniqueid(qe->chan))) && (strcasecmp(cdr->linkedid, ast_channel_uniqueid(qe->chan))) && (newcdr = ast_cdr_dup(cdr))) { ast_channel_lock(qe->chan); ast_cdr_init(newcdr, qe->chan); ast_cdr_reset(newcdr, 0); cdr = ast_cdr_append(cdr, newcdr); cdr = cdr->next; ast_channel_unlock(qe->chan); } if (update_cdr) { ast_copy_string(cdr->dstchannel, member->membername, sizeof(cdr->dstchannel)); } } if (qe->parent->eventwhencalled) /*** DOCUMENTATION Raised when an agent answers and is bridged to a member in the queue. AgentCalled AgentComplete AgentDump ***/ manager_event(EVENT_FLAG_AGENT, "AgentConnect", "Queue: %s\r\n" "Uniqueid: %s\r\n" "Channel: %s\r\n" "Member: %s\r\n" "MemberName: %s\r\n" "HoldTime: %ld\r\n" "BridgedChannel: %s\r\n" "RingTime: %ld\r\n" "%s", queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername, (long) time(NULL) - qe->start, ast_channel_uniqueid(peer), (long)(orig - to > 0 ? (orig - to) / 1000 : 0), qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); ast_copy_string(oldcontext, ast_channel_context(qe->chan), sizeof(oldcontext)); ast_copy_string(oldexten, ast_channel_exten(qe->chan), sizeof(oldexten)); if ((queue_end_bridge = ao2_alloc(sizeof(*queue_end_bridge), NULL))) { queue_end_bridge->q = qe->parent; queue_end_bridge->chan = qe->chan; bridge_config.end_bridge_callback = end_bridge_callback; bridge_config.end_bridge_callback_data = queue_end_bridge; bridge_config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup; /* Since queue_end_bridge can survive beyond the life of this call to Queue, we need * to make sure to increase the refcount of this queue so it cannot be freed until we * are done with it. We remove this reference in end_bridge_callback. */ queue_t_ref(qe->parent, "For bridge_config reference"); } time(&callstart); transfer_ds = setup_transfer_datastore(qe, member, callstart, callcompletedinsl); bridge = ast_bridge_call(qe->chan, peer, &bridge_config); /* If the queue member did an attended transfer, then the TRANSFER already was logged in the queue_log * when the masquerade occurred. These other "ending" queue_log messages are unnecessary, except for * the AgentComplete manager event */ ast_channel_lock(qe->chan); if (!attended_transfer_occurred(qe->chan)) { struct ast_datastore *tds; /* detect a blind transfer */ if (!(ast_channel_softhangup_internal_flag(qe->chan) | ast_channel_softhangup_internal_flag(peer)) && (strcasecmp(oldcontext, ast_channel_context(qe->chan)) || strcasecmp(oldexten, ast_channel_exten(qe->chan)))) { ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d", ast_channel_exten(qe->chan), ast_channel_context(qe->chan), (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos); send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER); } else if (ast_check_hangup(qe->chan) && !ast_check_hangup(peer)) { ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "COMPLETECALLER", "%ld|%ld|%d", (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos); send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), CALLER); } else { ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "COMPLETEAGENT", "%ld|%ld|%d", (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos); send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), AGENT); } if ((tds = ast_channel_datastore_find(qe->chan, &queue_transfer_info, NULL))) { ast_channel_datastore_remove(qe->chan, tds); } ast_channel_unlock(qe->chan); update_queue(qe->parent, member, callcompletedinsl, (time(NULL) - callstart)); } else { ast_channel_unlock(qe->chan); /* We already logged the TRANSFER on the queue_log, but we still need to send the AgentComplete event */ send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER); } if (transfer_ds) { ast_datastore_free(transfer_ds); } if (!ast_check_hangup(peer) && ast_test_flag(&opts, OPT_CALLEE_GO_ON)) { int goto_res; if (!ast_strlen_zero(opt_args[OPT_ARG_CALLEE_GO_ON])) { ast_replace_subargument_delimiter(opt_args[OPT_ARG_CALLEE_GO_ON]); goto_res = ast_parseable_goto(peer, opt_args[OPT_ARG_CALLEE_GO_ON]); } else { /* F() */ goto_res = ast_goto_if_exists(peer, caller_context, caller_extension, caller_priority + 1); } if (goto_res || ast_pbx_start(peer)) { ast_autoservice_chan_hangup_peer(qe->chan, peer); } } else { ast_autoservice_chan_hangup_peer(qe->chan, peer); } res = bridge ? bridge : 1; ao2_ref(member, -1); } out: hangupcalls(outgoing, NULL, qe->cancel_answered_elsewhere); return res; } static int wait_a_bit(struct queue_ent *qe) { /* Don't need to hold the lock while we setup the outgoing calls */ int retrywait = qe->parent->retry * 1000; int res = ast_waitfordigit(qe->chan, retrywait); if (res > 0 && !valid_exit(qe, res)) { res = 0; } return res; } static struct member *interface_exists(struct call_queue *q, const char *interface) { struct member *mem; struct ao2_iterator mem_iter; if (!q) { return NULL; } mem_iter = ao2_iterator_init(q->members, 0); while ((mem = ao2_iterator_next(&mem_iter))) { if (!strcasecmp(interface, mem->interface)) { ao2_iterator_destroy(&mem_iter); return mem; } ao2_ref(mem, -1); } ao2_iterator_destroy(&mem_iter); return NULL; } /*! \brief Dump all members in a specific queue to the database * * / = ;;;[|...] */ static void dump_queue_members(struct call_queue *pm_queue) { struct member *cur_member; struct ast_str *value; struct ao2_iterator mem_iter; if (!pm_queue) { return; } /* 4K is a reasonable default for most applications, but we grow to * accommodate more if necessary. */ if (!(value = ast_str_create(4096))) { return; } mem_iter = ao2_iterator_init(pm_queue->members, 0); while ((cur_member = ao2_iterator_next(&mem_iter))) { if (!cur_member->dynamic) { ao2_ref(cur_member, -1); continue; } ast_str_append(&value, 0, "%s%s;%d;%d;%s;%s", ast_str_strlen(value) ? "|" : "", cur_member->interface, cur_member->penalty, cur_member->paused, cur_member->membername, cur_member->state_interface); ao2_ref(cur_member, -1); } ao2_iterator_destroy(&mem_iter); if (ast_str_strlen(value) && !cur_member) { if (ast_db_put(pm_family, pm_queue->name, ast_str_buffer(value))) { ast_log(LOG_WARNING, "failed to create persistent dynamic entry!\n"); } } else { /* Delete the entry if the queue is empty or there is an error */ ast_db_del(pm_family, pm_queue->name); } ast_free(value); } /*! \brief Remove member from queue * \retval RES_NOT_DYNAMIC when they aren't a RT member * \retval RES_NOSUCHQUEUE queue does not exist * \retval RES_OKAY removed member from queue * \retval RES_EXISTS queue exists but no members */ static int remove_from_queue(const char *queuename, const char *interface) { struct call_queue *q, tmpq = { .name = queuename, }; struct member *mem, tmpmem; int res = RES_NOSUCHQUEUE; ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface)); if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Temporary reference for interface removal"))) { ao2_lock(q); if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER))) { /* XXX future changes should beware of this assumption!! */ /*Change Penalty on realtime users*/ if (mem->realtime && !ast_strlen_zero(mem->rt_uniqueid) && negative_penalty_invalid) { update_realtime_member_field(mem, q->name, "penalty", "-1"); } else if (!mem->dynamic) { ao2_ref(mem, -1); ao2_unlock(q); queue_t_unref(q, "Interface wasn't dynamic, expiring temporary reference"); return RES_NOT_DYNAMIC; } /*** DOCUMENTATION Raised when a member is removed from the queue. QueueMemberAdded RemoveQueueMember ***/ manager_event(EVENT_FLAG_AGENT, "QueueMemberRemoved", "Queue: %s\r\n" "Location: %s\r\n" "MemberName: %s\r\n", q->name, mem->interface, mem->membername); member_remove_from_queue(q, mem); ao2_ref(mem, -1); if (queue_persistent_members) { dump_queue_members(q); } if (!num_available_members(q)) { ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name); } res = RES_OKAY; } else { res = RES_EXISTS; } ao2_unlock(q); queue_t_unref(q, "Expiring temporary reference"); } return res; } /*! \brief Add member to queue * \retval RES_NOT_DYNAMIC when they aren't a RT member * \retval RES_NOSUCHQUEUE queue does not exist * \retval RES_OKAY added member from queue * \retval RES_EXISTS queue exists but no members * \retval RES_OUT_OF_MEMORY queue exists but not enough memory to create member */ static int add_to_queue(const char *queuename, const char *interface, const char *membername, int penalty, int paused, int dump, const char *state_interface) { struct call_queue *q; struct member *new_member, *old_member; int res = RES_NOSUCHQUEUE; /*! \note Ensure the appropriate realtime queue is loaded. Note that this * short-circuits if the queue is already in memory. */ if (!(q = find_load_queue_rt_friendly(queuename))) { return res; } ao2_lock(q); if ((old_member = interface_exists(q, interface)) == NULL) { if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface, q->ringinuse))) { new_member->ringinuse = q->ringinuse; new_member->dynamic = 1; member_add_to_queue(q, new_member); /*** DOCUMENTATION Raised when a member is added to the queue. QueueMemberRemoved AddQueueMember ***/ manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded", "Queue: %s\r\n" "Location: %s\r\n" "MemberName: %s\r\n" "StateInterface: %s\r\n" "Membership: %s\r\n" "Penalty: %d\r\n" "CallsTaken: %d\r\n" "LastCall: %d\r\n" "Status: %d\r\n" "Paused: %d\r\n", q->name, new_member->interface, new_member->membername, state_interface, "dynamic", new_member->penalty, new_member->calls, (int) new_member->lastcall, new_member->status, new_member->paused); if (is_member_available(q, new_member)) { ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name); } ao2_ref(new_member, -1); new_member = NULL; if (dump) { dump_queue_members(q); } res = RES_OKAY; } else { res = RES_OUTOFMEMORY; } } else { ao2_ref(old_member, -1); res = RES_EXISTS; } ao2_unlock(q); queue_t_unref(q, "Expiring temporary reference"); return res; } static int set_member_paused(const char *queuename, const char *interface, const char *reason, int paused) { int found = 0; struct call_queue *q; struct member *mem; struct ao2_iterator queue_iter; int failed; /* Special event for when all queues are paused - individual events still generated */ /* XXX In all other cases, we use the membername, but since this affects all queues, we cannot */ if (ast_strlen_zero(queuename)) ast_queue_log("NONE", "NONE", interface, (paused ? "PAUSEALL" : "UNPAUSEALL"), "%s", ""); queue_iter = ao2_iterator_init(queues, 0); while ((q = ao2_t_iterator_next(&queue_iter, "Iterate over queues"))) { ao2_lock(q); if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) { if ((mem = interface_exists(q, interface))) { if (mem->paused == paused) { ast_debug(1, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface); } failed = 0; if (mem->realtime) { failed = update_realtime_member_field(mem, q->name, "paused", paused ? "1" : "0"); } if (failed) { ast_log(LOG_WARNING, "Failed %spausing realtime queue member %s:%s\n", (paused ? "" : "un"), q->name, interface); ao2_ref(mem, -1); ao2_unlock(q); queue_t_unref(q, "Done with iterator"); continue; } found++; mem->paused = paused; if (queue_persistent_members) { dump_queue_members(q); } if (is_member_available(q, mem)) { ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name); } else if (!num_available_members(q)) { ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name); } ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, "")); /*** DOCUMENTATION Raised when a member is paused/unpaused in the queue with a reason. PauseQueueMember UnPauseQueueMember ***/ if (!ast_strlen_zero(reason)) { manager_event(EVENT_FLAG_AGENT, "QueueMemberPaused", "Queue: %s\r\n" "Location: %s\r\n" "MemberName: %s\r\n" "Paused: %d\r\n" "Reason: %s\r\n", q->name, mem->interface, mem->membername, paused, reason); } else { /*** DOCUMENTATION Raised when a member is paused/unpaused in the queue without a reason. PauseQueueMember UnPauseQueueMember ***/ manager_event(EVENT_FLAG_AGENT, "QueueMemberPaused", "Queue: %s\r\n" "Location: %s\r\n" "MemberName: %s\r\n" "Paused: %d\r\n", q->name, mem->interface, mem->membername, paused); } ao2_ref(mem, -1); } } if (!ast_strlen_zero(queuename) && !strcasecmp(queuename, q->name)) { ao2_unlock(q); queue_t_unref(q, "Done with iterator"); break; } ao2_unlock(q); queue_t_unref(q, "Done with iterator"); } ao2_iterator_destroy(&queue_iter); return found ? RESULT_SUCCESS : RESULT_FAILURE; } /*! * \internal * \brief helper function for set_member_penalty - given a queue, sets all member penalties with the interface * \param[in] q queue which is having its member's penalty changed - must be unlocked prior to calling * \param[in] interface String of interface used to search for queue members being changed * \param[in] penalty Value penalty is being changed to for the member. * \retval 0 if the there is no member with interface belonging to q and no change is made * \retval 1 if the there is a member with interface belonging to q and changes are made */ static int set_member_penalty_help_members(struct call_queue *q, const char *interface, int penalty) { struct member *mem; int foundinterface = 0; char rtpenalty[80]; ao2_lock(q); if ((mem = interface_exists(q, interface))) { foundinterface++; if (!mem->realtime) { mem->penalty = penalty; } else { sprintf(rtpenalty, "%i", penalty); update_realtime_member_field(mem, q->name, "penalty", rtpenalty); } ast_queue_log(q->name, "NONE", interface, "PENALTY", "%d", penalty); /*** DOCUMENTATION Raised when a member's penalty is changed. QUEUE_MEMBER ***/ manager_event(EVENT_FLAG_AGENT, "QueueMemberPenalty", "Queue: %s\r\n" "Location: %s\r\n" "Penalty: %d\r\n", q->name, mem->interface, penalty); ao2_ref(mem, -1); } ao2_unlock(q); return foundinterface; } static int set_member_ringinuse_help_members(struct call_queue *q, const char *interface, int ringinuse) { struct member *mem; int foundinterface = 0; char rtringinuse[80]; ao2_lock(q); if ((mem = interface_exists(q, interface))) { foundinterface++; if (!mem->realtime) { mem->ringinuse = ringinuse; } else { sprintf(rtringinuse, "%i", ringinuse); update_realtime_member_field(mem, q->name, realtime_ringinuse_field, rtringinuse); } ast_queue_log(q->name, "NONE", interface, "RINGINUSE", "%d", ringinuse); /*** DOCUMENTATION Raised when a member's ringinuse setting is changed. QUEUE_MEMBER ***/ manager_event(EVENT_FLAG_AGENT, "QueueMemberRinginuse", "Queue: %s\r\n" "Location: %s\r\n" "Ringinuse: %d\r\n", q->name, mem->interface, ringinuse); ao2_ref(mem, -1); } ao2_unlock(q); return foundinterface; } static int set_member_value_help_members(struct call_queue *q, const char *interface, int property, int value) { switch(property) { case MEMBER_PENALTY: return set_member_penalty_help_members(q, interface, value); case MEMBER_RINGINUSE: return set_member_ringinuse_help_members(q, interface, value); default: ast_log(LOG_ERROR, "Attempted to set invalid property\n"); return 0; } } /*! * \internal * \brief Sets members penalty, if queuename=NULL we set member penalty in all the queues. * \param[in] queuename If specified, only act on a member if it belongs to this queue * \param[in] interface Interface of queue member(s) having priority set. * \param[in] property Which queue property is being set * \param[in] penalty Value penalty is being changed to for each member */ static int set_member_value(const char *queuename, const char *interface, int property, int value) { int foundinterface = 0, foundqueue = 0; struct call_queue *q; struct ast_config *queue_config = NULL; struct ao2_iterator queue_iter; /* property dependent restrictions on values should be checked in this switch */ switch (property) { case MEMBER_PENALTY: if (value < 0 && !negative_penalty_invalid) { ast_log(LOG_ERROR, "Invalid penalty (%d)\n", value); return RESULT_FAILURE; } } if (ast_strlen_zero(queuename)) { /* This means we need to iterate through all the queues. */ if (ast_check_realtime("queues")) { char *name; queue_config = ast_load_realtime_multientry("queues", "name LIKE", "%", SENTINEL); if (queue_config) { for (name = ast_category_browse(queue_config, NULL); !ast_strlen_zero(name); name = ast_category_browse(queue_config, name)) { if ((q = find_load_queue_rt_friendly(name))) { foundqueue++; foundinterface += set_member_value_help_members(q, interface, property, value); } } } } /* After hitting realtime queues, go back and get the regular ones. */ queue_iter = ao2_iterator_init(queues, 0); while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { foundqueue++; foundinterface += set_member_value_help_members(q, interface, property, value); } ao2_iterator_destroy(&queue_iter); } else { /* We actually have a queuename, so we can just act on the single queue. */ if ((q = find_load_queue_rt_friendly(queuename))) { foundqueue++; foundinterface += set_member_value_help_members(q, interface, property, value); } } if (foundinterface) { return RESULT_SUCCESS; } else if (!foundqueue) { ast_log (LOG_ERROR, "Invalid queuename\n"); } else { ast_log (LOG_ERROR, "Invalid interface\n"); } return RESULT_FAILURE; } /* \brief Gets members penalty. * \return Return the members penalty or RESULT_FAILURE on error. */ static int get_member_penalty(char *queuename, char *interface) { int foundqueue = 0, penalty; struct call_queue *q, tmpq = { .name = queuename, }; struct member *mem; if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Search for queue"))) { foundqueue = 1; ao2_lock(q); if ((mem = interface_exists(q, interface))) { penalty = mem->penalty; ao2_ref(mem, -1); ao2_unlock(q); queue_t_unref(q, "Search complete"); return penalty; } ao2_unlock(q); queue_t_unref(q, "Search complete"); } /* some useful debuging */ if (foundqueue) { ast_log (LOG_ERROR, "Invalid queuename\n"); } else { ast_log (LOG_ERROR, "Invalid interface\n"); } return RESULT_FAILURE; } /*! \brief Reload dynamic queue members persisted into the astdb */ static void reload_queue_members(void) { char *cur_ptr; const char *queue_name; char *member; char *interface; char *membername = NULL; char *state_interface; char *penalty_tok; int penalty = 0; char *paused_tok; int paused = 0; struct ast_db_entry *db_tree; struct ast_db_entry *entry; struct call_queue *cur_queue; char *queue_data; /* Each key in 'pm_family' is the name of a queue */ db_tree = ast_db_gettree(pm_family, NULL); for (entry = db_tree; entry; entry = entry->next) { queue_name = entry->key + strlen(pm_family) + 2; { struct call_queue tmpq = { .name = queue_name, }; cur_queue = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Reload queue members"); } if (!cur_queue) { cur_queue = find_load_queue_rt_friendly(queue_name); } if (!cur_queue) { /* If the queue no longer exists, remove it from the * database */ ast_log(LOG_WARNING, "Error loading persistent queue: '%s': it does not exist\n", queue_name); ast_db_del(pm_family, queue_name); continue; } if (ast_db_get_allocated(pm_family, queue_name, &queue_data)) { queue_t_unref(cur_queue, "Expire reload reference"); continue; } cur_ptr = queue_data; while ((member = strsep(&cur_ptr, ",|"))) { if (ast_strlen_zero(member)) { continue; } interface = strsep(&member, ";"); penalty_tok = strsep(&member, ";"); paused_tok = strsep(&member, ";"); membername = strsep(&member, ";"); state_interface = strsep(&member, ";"); if (!penalty_tok) { ast_log(LOG_WARNING, "Error parsing persistent member string for '%s' (penalty)\n", queue_name); break; } penalty = strtol(penalty_tok, NULL, 10); if (errno == ERANGE) { ast_log(LOG_WARNING, "Error converting penalty: %s: Out of range.\n", penalty_tok); break; } if (!paused_tok) { ast_log(LOG_WARNING, "Error parsing persistent member string for '%s' (paused)\n", queue_name); break; } paused = strtol(paused_tok, NULL, 10); if ((errno == ERANGE) || paused < 0 || paused > 1) { ast_log(LOG_WARNING, "Error converting paused: %s: Expected 0 or 1.\n", paused_tok); break; } ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused); if (add_to_queue(queue_name, interface, membername, penalty, paused, 0, state_interface) == RES_OUTOFMEMORY) { ast_log(LOG_ERROR, "Out of Memory when reloading persistent queue member\n"); break; } } queue_t_unref(cur_queue, "Expire reload reference"); ast_free(queue_data); } if (db_tree) { ast_log(LOG_NOTICE, "Queue members successfully reloaded from database.\n"); ast_db_freetree(db_tree); } } /*! \brief PauseQueueMember application */ static int pqm_exec(struct ast_channel *chan, const char *data) { char *parse; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(queuename); AST_APP_ARG(interface); AST_APP_ARG(options); AST_APP_ARG(reason); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "PauseQueueMember requires an argument ([queuename],interface[,options][,reason])\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.interface)) { ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename],interface[,options[,reason]])\n"); return -1; } if (set_member_paused(args.queuename, args.interface, args.reason, 1)) { ast_log(LOG_WARNING, "Attempt to pause interface %s, not found\n", args.interface); pbx_builtin_setvar_helper(chan, "PQMSTATUS", "NOTFOUND"); return 0; } pbx_builtin_setvar_helper(chan, "PQMSTATUS", "PAUSED"); return 0; } /*! \brief UnPauseQueueMember application */ static int upqm_exec(struct ast_channel *chan, const char *data) { char *parse; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(queuename); AST_APP_ARG(interface); AST_APP_ARG(options); AST_APP_ARG(reason); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "UnpauseQueueMember requires an argument ([queuename],interface[,options[,reason]])\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.interface)) { ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename],interface[,options[,reason]])\n"); return -1; } if (set_member_paused(args.queuename, args.interface, args.reason, 0)) { ast_log(LOG_WARNING, "Attempt to unpause interface %s, not found\n", args.interface); pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "NOTFOUND"); return 0; } pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "UNPAUSED"); return 0; } /*! \brief RemoveQueueMember application */ static int rqm_exec(struct ast_channel *chan, const char *data) { int res=-1; char *parse, *temppos = NULL; struct member *mem = NULL; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(queuename); AST_APP_ARG(interface); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "RemoveQueueMember requires an argument (queuename[,interface])\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.interface)) { args.interface = ast_strdupa(ast_channel_name(chan)); temppos = strrchr(args.interface, '-'); if (temppos) { *temppos = '\0'; } } ast_debug(1, "queue: %s, member: %s\n", args.queuename, args.interface); if (log_membername_as_agent) { mem = find_member_by_queuename_and_interface(args.queuename, args.interface); } switch (remove_from_queue(args.queuename, args.interface)) { case RES_OKAY: if (!mem || ast_strlen_zero(mem->membername)) { ast_queue_log(args.queuename, ast_channel_uniqueid(chan), args.interface, "REMOVEMEMBER", "%s", ""); } else { ast_queue_log(args.queuename, ast_channel_uniqueid(chan), mem->membername, "REMOVEMEMBER", "%s", ""); } ast_log(LOG_NOTICE, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename); pbx_builtin_setvar_helper(chan, "RQMSTATUS", "REMOVED"); res = 0; break; case RES_EXISTS: ast_debug(1, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename); pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE"); res = 0; break; case RES_NOSUCHQUEUE: ast_log(LOG_WARNING, "Unable to remove interface from queue '%s': No such queue\n", args.queuename); pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOSUCHQUEUE"); res = 0; break; case RES_NOT_DYNAMIC: ast_log(LOG_WARNING, "Unable to remove interface from queue '%s': '%s' is not a dynamic member\n", args.queuename, args.interface); pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTDYNAMIC"); res = 0; break; } if (mem) { ao2_ref(mem, -1); } return res; } /*! \brief AddQueueMember application */ static int aqm_exec(struct ast_channel *chan, const char *data) { int res=-1; char *parse, *temppos = NULL; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(queuename); AST_APP_ARG(interface); AST_APP_ARG(penalty); AST_APP_ARG(options); AST_APP_ARG(membername); AST_APP_ARG(state_interface); ); int penalty = 0; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[,interface[,penalty[,options[,membername[,stateinterface]]]]])\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.interface)) { args.interface = ast_strdupa(ast_channel_name(chan)); temppos = strrchr(args.interface, '-'); if (temppos) { *temppos = '\0'; } } if (!ast_strlen_zero(args.penalty)) { if ((sscanf(args.penalty, "%30d", &penalty) != 1) || penalty < 0) { ast_log(LOG_WARNING, "Penalty '%s' is invalid, must be an integer >= 0\n", args.penalty); penalty = 0; } } switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface)) { case RES_OKAY: if (ast_strlen_zero(args.membername) || !log_membername_as_agent) { ast_queue_log(args.queuename, ast_channel_uniqueid(chan), args.interface, "ADDMEMBER", "%s", ""); } else { ast_queue_log(args.queuename, ast_channel_uniqueid(chan), args.membername, "ADDMEMBER", "%s", ""); } ast_log(LOG_NOTICE, "Added interface '%s' to queue '%s'\n", args.interface, args.queuename); pbx_builtin_setvar_helper(chan, "AQMSTATUS", "ADDED"); res = 0; break; case RES_EXISTS: ast_log(LOG_WARNING, "Unable to add interface '%s' to queue '%s': Already there\n", args.interface, args.queuename); pbx_builtin_setvar_helper(chan, "AQMSTATUS", "MEMBERALREADY"); res = 0; break; case RES_NOSUCHQUEUE: ast_log(LOG_WARNING, "Unable to add interface to queue '%s': No such queue\n", args.queuename); pbx_builtin_setvar_helper(chan, "AQMSTATUS", "NOSUCHQUEUE"); res = 0; break; case RES_OUTOFMEMORY: ast_log(LOG_ERROR, "Out of memory adding interface %s to queue %s\n", args.interface, args.queuename); break; } return res; } /*! \brief QueueLog application */ static int ql_exec(struct ast_channel *chan, const char *data) { char *parse; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(queuename); AST_APP_ARG(uniqueid); AST_APP_ARG(membername); AST_APP_ARG(event); AST_APP_ARG(params); ); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "QueueLog requires arguments (queuename,uniqueid,membername,event[,additionalinfo]\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); if (ast_strlen_zero(args.queuename) || ast_strlen_zero(args.uniqueid) || ast_strlen_zero(args.membername) || ast_strlen_zero(args.event)) { ast_log(LOG_WARNING, "QueueLog requires arguments (queuename,uniqueid,membername,event[,additionalinfo])\n"); return -1; } ast_queue_log(args.queuename, args.uniqueid, args.membername, args.event, "%s", args.params ? args.params : ""); return 0; } /*! \brief Copy rule from global list into specified queue */ static void copy_rules(struct queue_ent *qe, const char *rulename) { struct penalty_rule *pr_iter; struct rule_list *rl_iter; const char *tmp = ast_strlen_zero(rulename) ? qe->parent->defaultrule : rulename; AST_LIST_LOCK(&rule_lists); AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) { if (!strcasecmp(rl_iter->name, tmp)) { break; } } if (rl_iter) { AST_LIST_TRAVERSE(&rl_iter->rules, pr_iter, list) { struct penalty_rule *new_pr = ast_calloc(1, sizeof(*new_pr)); if (!new_pr) { ast_log(LOG_ERROR, "Memory allocation error when copying penalty rules! Aborting!\n"); break; } new_pr->time = pr_iter->time; new_pr->max_value = pr_iter->max_value; new_pr->min_value = pr_iter->min_value; new_pr->max_relative = pr_iter->max_relative; new_pr->min_relative = pr_iter->min_relative; AST_LIST_INSERT_TAIL(&qe->qe_rules, new_pr, list); } } AST_LIST_UNLOCK(&rule_lists); } /*!\brief The starting point for all queue calls * * The process involved here is to * 1. Parse the options specified in the call to Queue() * 2. Join the queue * 3. Wait in a loop until it is our turn to try calling a queue member * 4. Attempt to call a queue member * 5. If 4. did not result in a bridged call, then check for between * call options such as periodic announcements etc. * 6. Try 4 again unless some condition (such as an expiration time) causes us to * exit the queue. */ static int queue_exec(struct ast_channel *chan, const char *data) { int res=-1; int ringing=0; const char *user_priority; const char *max_penalty_str; const char *min_penalty_str; int prio; int qcontinue = 0; int max_penalty, min_penalty; enum queue_result reason = QUEUE_UNKNOWN; /* whether to exit Queue application after the timeout hits */ int tries = 0; int noption = 0; char *parse; int makeannouncement = 0; int position = 0; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(queuename); AST_APP_ARG(options); AST_APP_ARG(url); AST_APP_ARG(announceoverride); AST_APP_ARG(queuetimeoutstr); AST_APP_ARG(agi); AST_APP_ARG(macro); AST_APP_ARG(gosub); AST_APP_ARG(rule); AST_APP_ARG(position); ); /* Our queue entry */ struct queue_ent qe = { 0 }; struct ast_flags opts = { 0, }; char *opt_args[OPT_ARG_ARRAY_SIZE]; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "Queue requires an argument: queuename[,options[,URL[,announceoverride[,timeout[,agi[,macro[,gosub[,rule[,position]]]]]]]]]\n"); return -1; } parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); ast_debug(1, "queue: %s, options: %s, url: %s, announce: %s, timeout: %s, agi: %s, macro: %s, gosub: %s, rule: %s, position: %s\n", args.queuename, S_OR(args.options, ""), S_OR(args.url, ""), S_OR(args.announceoverride, ""), S_OR(args.queuetimeoutstr, ""), S_OR(args.agi, ""), S_OR(args.macro, ""), S_OR(args.gosub, ""), S_OR(args.rule, ""), S_OR(args.position, "")); if (!ast_strlen_zero(args.options)) { ast_app_parse_options(queue_exec_options, &opts, opt_args, args.options); } /* Setup our queue entry */ qe.start = time(NULL); /* set the expire time based on the supplied timeout; */ if (!ast_strlen_zero(args.queuetimeoutstr)) { qe.expire = qe.start + atoi(args.queuetimeoutstr); } else { qe.expire = 0; } /* Get the priority from the variable ${QUEUE_PRIO} */ ast_channel_lock(chan); user_priority = pbx_builtin_getvar_helper(chan, "QUEUE_PRIO"); if (user_priority) { if (sscanf(user_priority, "%30d", &prio) == 1) { ast_debug(1, "%s: Got priority %d from ${QUEUE_PRIO}.\n", ast_channel_name(chan), prio); } else { ast_log(LOG_WARNING, "${QUEUE_PRIO}: Invalid value (%s), channel %s.\n", user_priority, ast_channel_name(chan)); prio = 0; } } else { ast_debug(3, "NO QUEUE_PRIO variable found. Using default.\n"); prio = 0; } /* Get the maximum penalty from the variable ${QUEUE_MAX_PENALTY} */ if ((max_penalty_str = pbx_builtin_getvar_helper(chan, "QUEUE_MAX_PENALTY"))) { if (sscanf(max_penalty_str, "%30d", &max_penalty) == 1) { ast_debug(1, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n", ast_channel_name(chan), max_penalty); } else { ast_log(LOG_WARNING, "${QUEUE_MAX_PENALTY}: Invalid value (%s), channel %s.\n", max_penalty_str, ast_channel_name(chan)); max_penalty = 0; } } else { max_penalty = 0; } if ((min_penalty_str = pbx_builtin_getvar_helper(chan, "QUEUE_MIN_PENALTY"))) { if (sscanf(min_penalty_str, "%30d", &min_penalty) == 1) { ast_debug(1, "%s: Got min penalty %d from ${QUEUE_MIN_PENALTY}.\n", ast_channel_name(chan), min_penalty); } else { ast_log(LOG_WARNING, "${QUEUE_MIN_PENALTY}: Invalid value (%s), channel %s.\n", min_penalty_str, ast_channel_name(chan)); min_penalty = 0; } } else { min_penalty = 0; } ast_channel_unlock(chan); if (ast_test_flag(&opts, OPT_RINGING)) { ringing = 1; } if (ringing != 1 && ast_test_flag(&opts, OPT_RING_WHEN_RINGING)) { qe.ring_when_ringing = 1; } if (ast_test_flag(&opts, OPT_GO_ON)) { qcontinue = 1; } if (args.position) { position = atoi(args.position); if (position < 0) { ast_log(LOG_WARNING, "Invalid position '%s' given for call to queue '%s'. Assuming no preference for position\n", args.position, args.queuename); position = 0; } } ast_debug(1, "queue: %s, expires: %ld, priority: %d\n", args.queuename, (long)qe.expire, prio); qe.chan = chan; qe.prio = prio; qe.max_penalty = max_penalty; qe.min_penalty = min_penalty; qe.last_pos_said = 0; qe.last_pos = 0; qe.last_periodic_announce_time = time(NULL); qe.last_periodic_announce_sound = 0; qe.valid_digits = 0; if (join_queue(args.queuename, &qe, &reason, position)) { ast_log(LOG_WARNING, "Unable to join queue '%s'\n", args.queuename); set_queue_result(chan, reason); return 0; } ast_assert(qe.parent != NULL); ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "ENTERQUEUE", "%s|%s|%d", S_OR(args.url, ""), S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""), qe.opos); copy_rules(&qe, args.rule); qe.pr = AST_LIST_FIRST(&qe.qe_rules); check_turns: if (ringing) { ast_indicate(chan, AST_CONTROL_RINGING); } else { ast_moh_start(chan, qe.moh, NULL); } /* This is the wait loop for callers 2 through maxlen */ res = wait_our_turn(&qe, ringing, &reason); if (res) { goto stop; } makeannouncement = 0; for (;;) { /* This is the wait loop for the head caller*/ /* To exit, they may get their call answered; */ /* they may dial a digit from the queue context; */ /* or, they may timeout. */ /* Leave if we have exceeded our queuetimeout */ if (qe.expire && (time(NULL) >= qe.expire)) { record_abandoned(&qe); reason = QUEUE_TIMEOUT; res = 0; ast_queue_log(args.queuename, ast_channel_uniqueid(chan),"NONE", "EXITWITHTIMEOUT", "%d|%d|%ld", qe.pos, qe.opos, (long) time(NULL) - qe.start); break; } if (makeannouncement) { /* Make a position announcement, if enabled */ if (qe.parent->announcefrequency) if ((res = say_position(&qe,ringing))) goto stop; } makeannouncement = 1; /* Make a periodic announcement, if enabled */ if (qe.parent->periodicannouncefrequency) { if ((res = say_periodic_announcement(&qe,ringing))) { goto stop; } } /* Leave if we have exceeded our queuetimeout */ if (qe.expire && (time(NULL) >= qe.expire)) { record_abandoned(&qe); reason = QUEUE_TIMEOUT; res = 0; ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "EXITWITHTIMEOUT", "%d", qe.pos); break; } /* see if we need to move to the next penalty level for this queue */ while (qe.pr && ((time(NULL) - qe.start) > qe.pr->time)) { update_qe_rule(&qe); } /* Try calling all queue members for 'timeout' seconds */ res = try_calling(&qe, opts, opt_args, args.announceoverride, args.url, &tries, &noption, args.agi, args.macro, args.gosub, ringing); if (res) { goto stop; } if (qe.parent->leavewhenempty) { int status = 0; if ((status = get_member_status(qe.parent, qe.max_penalty, qe.min_penalty, qe.parent->leavewhenempty))) { record_abandoned(&qe); reason = QUEUE_LEAVEEMPTY; ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "EXITEMPTY", "%d|%d|%ld", qe.pos, qe.opos, (long)(time(NULL) - qe.start)); res = 0; break; } } /* exit after 'timeout' cycle if 'n' option enabled */ if (noption && tries >= ao2_container_count(qe.parent->members)) { ast_verb(3, "Exiting on time-out cycle\n"); ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "EXITWITHTIMEOUT", "%d", qe.pos); record_abandoned(&qe); reason = QUEUE_TIMEOUT; res = 0; break; } /* Leave if we have exceeded our queuetimeout */ if (qe.expire && (time(NULL) >= qe.expire)) { record_abandoned(&qe); reason = QUEUE_TIMEOUT; res = 0; ast_queue_log(qe.parent->name, ast_channel_uniqueid(qe.chan),"NONE", "EXITWITHTIMEOUT", "%d|%d|%ld", qe.pos, qe.opos, (long) time(NULL) - qe.start); break; } /* If using dynamic realtime members, we should regenerate the member list for this queue */ update_realtime_members(qe.parent); /* OK, we didn't get anybody; wait for 'retry' seconds; may get a digit to exit with */ res = wait_a_bit(&qe); if (res) { goto stop; } /* Since this is a priority queue and * it is not sure that we are still at the head * of the queue, go and check for our turn again. */ if (!is_our_turn(&qe)) { ast_debug(1, "Darn priorities, going back in queue (%s)!\n", ast_channel_name(qe.chan)); goto check_turns; } } stop: if (res) { if (res < 0) { if (!qe.handled) { record_abandoned(&qe); ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long) time(NULL) - qe.start); res = -1; } else if (qcontinue) { reason = QUEUE_CONTINUE; res = 0; } } else if (qe.valid_digits) { ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "EXITWITHKEY", "%s|%d|%d|%ld", qe.digits, qe.pos, qe.opos, (long) time(NULL) - qe.start); } } /* Don't allow return code > 0 */ if (res >= 0) { res = 0; if (ringing) { ast_indicate(chan, -1); } else { ast_moh_stop(chan); } ast_stopstream(chan); } set_queue_variables(qe.parent, qe.chan); leave_queue(&qe); if (reason != QUEUE_UNKNOWN) set_queue_result(chan, reason); /* * every queue_ent is given a reference to it's parent * call_queue when it joins the queue. This ref must be taken * away right before the queue_ent is destroyed. In this case * the queue_ent is about to be returned on the stack */ qe.parent = queue_unref(qe.parent); return res; } /*! * \brief create interface var with all queue details. * \retval 0 on success * \retval -1 on error */ static int queue_function_var(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { int res = -1; struct call_queue *q, tmpq = { .name = data, }; char interfacevar[256] = ""; float sl = 0; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); return -1; } if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Find for QUEUE() function"))) { ao2_lock(q); if (q->setqueuevar) { sl = 0; res = 0; if (q->callscompleted > 0) { sl = 100 * ((float) q->callscompletedinsl / (float) q->callscompleted); } snprintf(interfacevar, sizeof(interfacevar), "QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUETALKTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, q->callsabandoned, q->servicelevel, sl); pbx_builtin_setvar_multiple(chan, interfacevar); } ao2_unlock(q); queue_t_unref(q, "Done with QUEUE() function"); } else { ast_log(LOG_WARNING, "queue %s was not found\n", data); } snprintf(buf, len, "%d", res); return 0; } /*! * \brief Check if a given queue exists * */ static int queue_function_exists(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct call_queue *q; buf[0] = '\0'; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); return -1; } q = find_load_queue_rt_friendly(data); snprintf(buf, len, "%d", q != NULL? 1 : 0); if (q) { queue_t_unref(q, "Done with temporary reference in QUEUE_EXISTS()"); } return 0; } /*! * \brief Get number either busy / free / ready or total members of a specific queue * \brief Get or set member properties penalty / paused / ringinuse * \retval number of members (busy / free / ready / total) or member info (penalty / paused / ringinuse) * \retval -1 on error */ static int queue_function_mem_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { int count = 0; struct member *m; struct ao2_iterator mem_iter; struct call_queue *q; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(queuename); AST_APP_ARG(option); AST_APP_ARG(interface); ); /* Make sure the returned value on error is zero length string. */ buf[0] = '\0'; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "Missing required argument. %s(,