Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ff93b2644 | ||
|
|
8f2a475a9d | ||
|
|
29a53c8f56 | ||
|
|
8b4e1ff5d0 | ||
|
|
f48109dd0f | ||
|
|
9ed9295cd5 | ||
|
|
803f8b1e99 | ||
|
|
64301d47eb | ||
|
|
7f75e2b80a | ||
|
|
4be7589429 | ||
|
|
5bd165c51c | ||
|
|
c89077c707 | ||
|
|
c94bb651cb | ||
|
|
030e422d90 | ||
|
|
31543e7d4b | ||
|
|
af8e88d31d | ||
|
|
1776a47991 | ||
|
|
1b53ca3726 | ||
|
|
f678b0be15 | ||
|
|
19821ae420 | ||
|
|
18deddad8a | ||
|
|
753377c57d | ||
|
|
fd6237ebb6 | ||
|
|
dda51ee0bc |
31
ChangeLog
31
ChangeLog
@@ -1,15 +1,30 @@
|
||||
libpri 1.0.9
|
||||
-- No Changes
|
||||
libpri 1.0.8
|
||||
-- fix compile warnings for gcc4
|
||||
libpri 1.0.7
|
||||
-- No Changes
|
||||
libpri 1.0.6
|
||||
-- Dependencies from .depend were valid from static libary only, not dynamic. 'mkdep'
|
||||
has been fixed to support the dynamic library version.
|
||||
libpri 1.0.4
|
||||
-- Makefile fix for SELinux
|
||||
libpri 1.0.3
|
||||
-- Fix Endian to compile for FreeBSD
|
||||
|
||||
...
|
||||
libpri 0.3.0
|
||||
-- Fix talking to switch
|
||||
-- Add pri dump
|
||||
-- Add test application
|
||||
-- Fix strncpy stuff
|
||||
-- Fix talking to switch
|
||||
-- Add pri dump
|
||||
-- Add test application
|
||||
-- Fix strncpy stuff
|
||||
libpri 0.1.2
|
||||
-- Added PRI_EVENT_HANGUP_ACK so you can know when the disconnect was
|
||||
acknowledged
|
||||
-- Added PRI_EVENT_HANGUP_ACK so you can know when the disconnect was
|
||||
acknowledged
|
||||
|
||||
libpri 0.1.1
|
||||
-- Added PRI_DEBUG_Q931_ANOMALY flag so that certain non-error-related
|
||||
messages would not be output unless specifically desired.
|
||||
-- Added PRI_DEBUG_Q931_ANOMALY flag so that certain non-error-related
|
||||
messages would not be output unless specifically desired.
|
||||
|
||||
libpri 0.1.0
|
||||
-- Initial release
|
||||
|
||||
3
Makefile
3
Makefile
@@ -66,6 +66,7 @@ install: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
|
||||
mkdir -p $(INSTALL_PREFIX)/usr/include
|
||||
install -m 644 libpri.h $(INSTALL_PREFIX)/usr/include
|
||||
install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)/usr/lib
|
||||
if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then restorecon -v $(INSTALL_PREFIX)/$(INSTALL_BASE)/lib/$(DYNAMIC_LIBRARY); fi
|
||||
( cd $(INSTALL_PREFIX)/usr/lib ; ln -sf libpri.so.1 libpri.so )
|
||||
install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)/usr/lib
|
||||
/sbin/ldconfig
|
||||
@@ -89,7 +90,9 @@ testprilib: testprilib.o
|
||||
pridump: pridump.o
|
||||
$(CC) -o pridump pridump.o -L. -lpri -lzap $(CFLAGS)
|
||||
|
||||
ifneq ($(wildcard .depend),)
|
||||
include .depend
|
||||
endif
|
||||
|
||||
%.lo : %.c
|
||||
$(CC) -fPIC $(CFLAGS) -o $@ -c $<
|
||||
|
||||
51
libpri.h
51
libpri.h
@@ -364,7 +364,7 @@ pri_event *pri_check_event(struct pri *pri);
|
||||
/* Give a name to a given event ID */
|
||||
extern char *pri_event2str(int id);
|
||||
|
||||
/* Give a name toa node type */
|
||||
/* Give a name to a node type */
|
||||
extern char *pri_node2str(int id);
|
||||
|
||||
/* Give a name to a switch type */
|
||||
@@ -373,9 +373,6 @@ extern char *pri_switch2str(int id);
|
||||
/* Print an event */
|
||||
extern void pri_dump_event(struct pri *pri, pri_event *e);
|
||||
|
||||
/* Turn an event ID into a string */
|
||||
extern char *pri_event2str(int e);
|
||||
|
||||
/* Turn presentation into a string */
|
||||
extern char *pri_pres2str(int pres);
|
||||
|
||||
@@ -459,8 +456,8 @@ extern void pri_set_error(void (*__pri_error)(char *));
|
||||
#define PRI_SET_OVERLAPDIAL
|
||||
extern void pri_set_overlapdial(struct pri *pri,int state);
|
||||
|
||||
#define PRI_DUMP_INFO
|
||||
extern void pri_dump_info(struct pri *pri);
|
||||
#define PRI_DUMP_INFO_STR
|
||||
extern char *pri_dump_info_str(struct pri *pri);
|
||||
|
||||
/* Get file descriptor */
|
||||
extern int pri_fd(struct pri *pri);
|
||||
@@ -481,47 +478,7 @@ extern void pri_enslave(struct pri *master, struct pri *slave);
|
||||
#define PRI_ENSLAVE_SUPPORT
|
||||
#define PRI_SETUP_CALL
|
||||
#define PRI_RECEIVE_SUBADDR
|
||||
#endif
|
||||
|
||||
/* Send notification */
|
||||
extern int pri_notify(struct pri *pri, q931_call *c, int channel, int info);
|
||||
|
||||
/* Get/Set PRI Timers */
|
||||
#define PRI_GETSET_TIMERS
|
||||
extern int pri_set_timer(struct pri *pri, int timer, int value);
|
||||
extern int pri_get_timer(struct pri *pri, int timer);
|
||||
extern int pri_timer2idx(char *timer);
|
||||
|
||||
#define PRI_MAX_TIMERS 32
|
||||
|
||||
#define PRI_TIMER_N200 0 /* Maximum numer of q921 retransmissions */
|
||||
#define PRI_TIMER_N201 1 /* Maximum numer of octets in an information field */
|
||||
#define PRI_TIMER_N202 2 /* Maximum numer of transmissions of the TEI identity request message */
|
||||
#define PRI_TIMER_K 3 /* Maximum number of outstanding I-frames */
|
||||
|
||||
#define PRI_TIMER_T200 4 /* time between SABME's */
|
||||
#define PRI_TIMER_T201 5 /* minimum time between retransmissions of the TEI Identity check messages */
|
||||
#define PRI_TIMER_T202 6 /* minimum time between transmission of TEI Identity request messages */
|
||||
#define PRI_TIMER_T203 7 /* maxiumum time without exchanging packets */
|
||||
|
||||
#define PRI_TIMER_T300 8
|
||||
#define PRI_TIMER_T301 9 /* maximum time to respond to an ALERT */
|
||||
#define PRI_TIMER_T302 10
|
||||
#define PRI_TIMER_T303 11 /* maximum time to wait after sending a SETUP without a response */
|
||||
#define PRI_TIMER_T304 12
|
||||
#define PRI_TIMER_T305 13
|
||||
#define PRI_TIMER_T306 14
|
||||
#define PRI_TIMER_T307 15
|
||||
#define PRI_TIMER_T308 16
|
||||
#define PRI_TIMER_T309 17
|
||||
#define PRI_TIMER_T310 18 /* maximum time between receiving a CALLPROCEEDING and receiving a ALERT/CONNECT/DISCONNECT/PROGRESS */
|
||||
#define PRI_TIMER_T313 19
|
||||
#define PRI_TIMER_T314 20
|
||||
#define PRI_TIMER_T316 21 /* maximum time between transmitting a RESTART and receiving a RESTART ACK */
|
||||
#define PRI_TIMER_T317 22
|
||||
#define PRI_TIMER_T318 23
|
||||
#define PRI_TIMER_T319 24
|
||||
#define PRI_TIMER_T320 25
|
||||
#define PRI_TIMER_T321 26
|
||||
#define PRI_TIMER_T322 27
|
||||
|
||||
#endif
|
||||
|
||||
18
mkdep
18
mkdep
@@ -100,10 +100,22 @@ if [ $append = 1 ]; then
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
mv $TMP $D
|
||||
cat $TMP | sed -e 's/\.o:/.lo:/g' >>$D
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: rename failed.'
|
||||
echo 'mkdep: append failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
cat $TMP > $D
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: overwrite failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
cat $TMP | sed -e 's/\.o:/.lo:/g' >>$D
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: append failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
|
||||
134
pri.c
134
pri.c
@@ -23,7 +23,6 @@
|
||||
#include "pri_internal.h"
|
||||
#include "pri_q921.h"
|
||||
#include "pri_q931.h"
|
||||
#include "pri_timers.h"
|
||||
|
||||
char *pri_node2str(int node)
|
||||
{
|
||||
@@ -63,92 +62,6 @@ char *pri_switch2str(int sw)
|
||||
}
|
||||
}
|
||||
|
||||
static void pri_default_timers(struct pri *pri, int switchtype)
|
||||
{
|
||||
int defaulttimers[20][PRI_MAX_TIMERS] = PRI_TIMERS_ALL;
|
||||
int x;
|
||||
|
||||
for (x = 0; x<PRI_MAX_TIMERS; x++) {
|
||||
pri->timers[x] = defaulttimers[switchtype][x];
|
||||
}
|
||||
}
|
||||
|
||||
int pri_set_timer(struct pri *pri, int timer, int value)
|
||||
{
|
||||
if (timer < 0 || timer > PRI_MAX_TIMERS || value < 0)
|
||||
return -1;
|
||||
|
||||
pri->timers[timer] = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pri_get_timer(struct pri *pri, int timer)
|
||||
{
|
||||
if (timer < 0 || timer > PRI_MAX_TIMERS)
|
||||
return -1;
|
||||
return pri->timers[timer];
|
||||
}
|
||||
|
||||
int pri_timer2idx(char *timer)
|
||||
{
|
||||
if (!strcasecmp(timer, "N200"))
|
||||
return PRI_TIMER_N200;
|
||||
else if (!strcasecmp(timer, "N201"))
|
||||
return PRI_TIMER_N201;
|
||||
else if (!strcasecmp(timer, "N202"))
|
||||
return PRI_TIMER_N202;
|
||||
else if (!strcasecmp(timer, "K"))
|
||||
return PRI_TIMER_K;
|
||||
else if (!strcasecmp(timer, "T200"))
|
||||
return PRI_TIMER_T200;
|
||||
else if (!strcasecmp(timer, "T202"))
|
||||
return PRI_TIMER_T202;
|
||||
else if (!strcasecmp(timer, "T203"))
|
||||
return PRI_TIMER_T203;
|
||||
else if (!strcasecmp(timer, "T300"))
|
||||
return PRI_TIMER_T300;
|
||||
else if (!strcasecmp(timer, "T301"))
|
||||
return PRI_TIMER_T301;
|
||||
else if (!strcasecmp(timer, "T302"))
|
||||
return PRI_TIMER_T302;
|
||||
else if (!strcasecmp(timer, "T303"))
|
||||
return PRI_TIMER_T303;
|
||||
else if (!strcasecmp(timer, "T304"))
|
||||
return PRI_TIMER_T304;
|
||||
else if (!strcasecmp(timer, "T305"))
|
||||
return PRI_TIMER_T305;
|
||||
else if (!strcasecmp(timer, "T306"))
|
||||
return PRI_TIMER_T306;
|
||||
else if (!strcasecmp(timer, "T307"))
|
||||
return PRI_TIMER_T307;
|
||||
else if (!strcasecmp(timer, "T308"))
|
||||
return PRI_TIMER_T308;
|
||||
else if (!strcasecmp(timer, "T309"))
|
||||
return PRI_TIMER_T309;
|
||||
else if (!strcasecmp(timer, "T310"))
|
||||
return PRI_TIMER_T310;
|
||||
else if (!strcasecmp(timer, "T313"))
|
||||
return PRI_TIMER_T313;
|
||||
else if (!strcasecmp(timer, "T314"))
|
||||
return PRI_TIMER_T314;
|
||||
else if (!strcasecmp(timer, "T316"))
|
||||
return PRI_TIMER_T316;
|
||||
else if (!strcasecmp(timer, "T317"))
|
||||
return PRI_TIMER_T317;
|
||||
else if (!strcasecmp(timer, "T318"))
|
||||
return PRI_TIMER_T318;
|
||||
else if (!strcasecmp(timer, "T319"))
|
||||
return PRI_TIMER_T319;
|
||||
else if (!strcasecmp(timer, "T320"))
|
||||
return PRI_TIMER_T320;
|
||||
else if (!strcasecmp(timer, "T321"))
|
||||
return PRI_TIMER_T321;
|
||||
else if (!strcasecmp(timer, "T322"))
|
||||
return PRI_TIMER_T322;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct pri *__pri_new(int fd, int node, int switchtype, struct pri *master)
|
||||
{
|
||||
struct pri *p;
|
||||
@@ -165,7 +78,6 @@ static struct pri *__pri_new(int fd, int node, int switchtype, struct pri *maste
|
||||
p->protodisc = Q931_PROTOCOL_DISCRIMINATOR;
|
||||
p->master = master;
|
||||
p->callpool = &p->localpool;
|
||||
pri_default_timers(p, switchtype);
|
||||
#ifdef LIBPRI_COUNTERS
|
||||
p->q921_rxcount = 0;
|
||||
p->q921_txcount = 0;
|
||||
@@ -505,7 +417,7 @@ void pri_message(char *fmt, ...)
|
||||
if (__pri_message)
|
||||
__pri_message(tmp);
|
||||
else
|
||||
fprintf(stdout, tmp);
|
||||
fputs(tmp, stdout);
|
||||
}
|
||||
|
||||
void pri_error(char *fmt, ...)
|
||||
@@ -518,8 +430,9 @@ void pri_error(char *fmt, ...)
|
||||
if (__pri_error)
|
||||
__pri_error(tmp);
|
||||
else
|
||||
fprintf(stderr, tmp);
|
||||
fputs(tmp, stderr);
|
||||
}
|
||||
|
||||
/* Set overlap mode */
|
||||
void pri_set_overlapdial(struct pri *pri,int state)
|
||||
{
|
||||
@@ -531,43 +444,41 @@ int pri_fd(struct pri *pri)
|
||||
return pri->fd;
|
||||
}
|
||||
|
||||
void pri_dump_info(struct pri *pri)
|
||||
char *pri_dump_info_str(struct pri *pri)
|
||||
{
|
||||
char buf[4096];
|
||||
int len = 0;
|
||||
#ifdef LIBPRI_COUNTERS
|
||||
struct q921_frame *f;
|
||||
int q921outstanding = 0;
|
||||
#endif
|
||||
if (!pri)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
/* Might be nice to format these a little better */
|
||||
pri_message("Switchtype: %s\n", pri_switch2str(pri->switchtype));
|
||||
pri_message("Type: %s\n", pri_node2str(pri->localtype));
|
||||
len += sprintf(buf + len, "Switchtype: %s\n", pri_switch2str(pri->switchtype));
|
||||
len += sprintf(buf + len, "Type: %s\n", pri_node2str(pri->localtype));
|
||||
#ifdef LIBPRI_COUNTERS
|
||||
/* Remember that Q921 Counters include Q931 packets (and any retransmissions) */
|
||||
pri_message("Q931 RX: %d\n", pri->q931_rxcount);
|
||||
pri_message("Q931 TX: %d\n", pri->q931_txcount);
|
||||
pri_message("Q921 RX: %d\n", pri->q921_rxcount);
|
||||
pri_message("Q921 TX: %d\n", pri->q921_txcount);
|
||||
len += sprintf(buf + len, "Q931 RX: %d\n", pri->q931_rxcount);
|
||||
len += sprintf(buf + len, "Q931 TX: %d\n", pri->q931_txcount);
|
||||
len += sprintf(buf + len, "Q921 RX: %d\n", pri->q921_rxcount);
|
||||
len += sprintf(buf + len, "Q921 TX: %d\n", pri->q921_txcount);
|
||||
f = pri->txqueue;
|
||||
while (f) {
|
||||
q921outstanding++;
|
||||
f = f->next;
|
||||
}
|
||||
pri_message("Q921 Outstanding: %d\n", q921outstanding);
|
||||
len += sprintf(buf + len, "Q921 Outstanding: %d\n", q921outstanding);
|
||||
#endif
|
||||
pri_message("Window Length: %d/%d\n", pri->windowlen, pri->window);
|
||||
pri_message("Sentrej: %d\n", pri->sentrej);
|
||||
pri_message("SolicitFbit: %d\n", pri->solicitfbit);
|
||||
pri_message("Retrans: %d\n", pri->retrans);
|
||||
pri_message("Busy: %d\n", pri->busy);
|
||||
pri_message("Overlap Dial: %d\n", pri->overlapdial);
|
||||
pri_message("T200 Timer: %d\n", pri->timers[PRI_TIMER_T200]);
|
||||
pri_message("T203 Timer: %d\n", pri->timers[PRI_TIMER_T203]);
|
||||
pri_message("T305 Timer: %d\n", pri->timers[PRI_TIMER_T305]);
|
||||
pri_message("T308 Timer: %d\n", pri->timers[PRI_TIMER_T308]);
|
||||
pri_message("T313 Timer: %d\n", pri->timers[PRI_TIMER_T313]);
|
||||
pri_message("N200 Counter: %d\n", pri->timers[PRI_TIMER_N200]);
|
||||
len += sprintf(buf + len, "Window Length: %d/%d\n", pri->windowlen, pri->window);
|
||||
len += sprintf(buf + len, "Sentrej: %d\n", pri->sentrej);
|
||||
len += sprintf(buf + len, "SolicitFbit: %d\n", pri->solicitfbit);
|
||||
len += sprintf(buf + len, "Retrans: %d\n", pri->retrans);
|
||||
len += sprintf(buf + len, "Busy: %d\n", pri->busy);
|
||||
len += sprintf(buf + len, "Overlap Dial: %d\n", pri->overlapdial);
|
||||
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
int pri_get_crv(struct pri *pri, q931_call *call, int *callmode)
|
||||
@@ -631,4 +542,3 @@ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int cal
|
||||
sr->callerpres = callerpres;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,6 @@ enum q931_mode;
|
||||
/* No more than 128 scheduled events */
|
||||
#define MAX_SCHED 128
|
||||
|
||||
#define MAX_TIMERS 32
|
||||
|
||||
struct pri {
|
||||
int fd; /* File descriptor for D-Channel */
|
||||
struct pri *subchannel; /* Sub-channel if appropriate */
|
||||
@@ -78,9 +76,7 @@ struct pri {
|
||||
int sabme_timer; /* SABME retransmit */
|
||||
int t203_timer; /* Max idle time */
|
||||
int t200_timer; /* T-200 retransmission timer */
|
||||
/* All ISDN Timer values */
|
||||
int timers[MAX_TIMERS];
|
||||
|
||||
|
||||
/* Used by scheduler */
|
||||
struct timeval tv;
|
||||
int schedev;
|
||||
|
||||
@@ -30,12 +30,18 @@
|
||||
#include <endian.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/endian.h>
|
||||
#define __BYTE_ORDER _BYTE_ORDER
|
||||
#define __BIG_ENDIAN _BIG_ENDIAN
|
||||
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
/* Timer values */
|
||||
|
||||
#define T_WAIT_MIN 2000
|
||||
#define T_WAIT_MAX 10000
|
||||
#define T_200 1000 /* 1 second between SABME's */
|
||||
#define T_203 10000 /* 10 seconds with no packets max */
|
||||
#define N_200 3 /* 3 retries */
|
||||
|
||||
#define Q921_FRAMETYPE_MASK 0x3
|
||||
|
||||
|
||||
83
pri_timers.h
83
pri_timers.h
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* libpri: An implementation of Primary Rate ISDN
|
||||
*
|
||||
* Written by Mark Spencer <markster@linux-support.net>
|
||||
*
|
||||
* Copyright (C) 2001, Linux Support Services, Inc.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PRI_TIMERS_H
|
||||
#define _PRI_TIMERS_H
|
||||
|
||||
/* -1 means we dont currently support the timer/counter */
|
||||
#define PRI_TIMERS_DEFAULT { 3, /* N200 */ \
|
||||
-1, /* N201 */ \
|
||||
-1, /* N202 */ \
|
||||
7, /* K */ \
|
||||
1000, /* T200 */ \
|
||||
-1, /* T201 */ \
|
||||
-1, /* T202 */ \
|
||||
10000, /* T203 */ \
|
||||
-1, /* T300 */ \
|
||||
-1, /* T301 */ \
|
||||
-1, /* T302 */ \
|
||||
-1, /* T303 */ \
|
||||
-1, /* T304 */ \
|
||||
30000, /* T305 */ \
|
||||
-1, /* T306 */ \
|
||||
-1, /* T307 */ \
|
||||
4000, /* T308 */ \
|
||||
-1, /* T309 */ \
|
||||
-1, /* T310 */ \
|
||||
4000, /* T313 */ \
|
||||
-1, /* T314 */ \
|
||||
-1, /* T316 */ \
|
||||
-1, /* T317 */ \
|
||||
-1, /* T318 */ \
|
||||
-1, /* T319 */ \
|
||||
-1, /* T320 */ \
|
||||
-1, /* T321 */ \
|
||||
-1 /* T322 */ \
|
||||
}
|
||||
|
||||
/* XXX Only our default timers are setup now XXX */
|
||||
#define PRI_TIMERS_UNKNOWN PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_NI2 PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_DMS100 PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_LUCENT5E PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_ATT4ESS PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_EUROISDN_E1 PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_EUROISDN_T1 PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_NI1 PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_GR303_EOC PRI_TIMERS_DEFAULT
|
||||
#define PRI_TIMERS_GR303_TMC PRI_TIMERS_DEFAULT
|
||||
|
||||
#define PRI_TIMERS_ALL { PRI_TIMERS_UNKNOWN, \
|
||||
PRI_TIMERS_NI2, \
|
||||
PRI_TIMERS_DMS100, \
|
||||
PRI_TIMERS_LUCENT5E, \
|
||||
PRI_TIMERS_ATT4ESS, \
|
||||
PRI_TIMERS_EUROISDN_E1, \
|
||||
PRI_TIMERS_EUROISDN_T1, \
|
||||
PRI_TIMERS_NI1, \
|
||||
PRI_TIMERS_GR303_EOC, \
|
||||
PRI_TIMERS_GR303_TMC \
|
||||
}
|
||||
|
||||
#endif
|
||||
26
q921.c
26
q921.c
@@ -123,7 +123,7 @@ static void q921_send_sabme(void *vpri, int now)
|
||||
q921_h h;
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri->sabme_timer = 0;
|
||||
pri->sabme_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], q921_send_sabme_now, pri);
|
||||
pri->sabme_timer = pri_schedule_event(pri, T_200, q921_send_sabme_now, pri);
|
||||
if (!now)
|
||||
return;
|
||||
Q921_INIT(pri, h);
|
||||
@@ -208,7 +208,7 @@ static void reschedule_t203(struct pri *pri)
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Restarting T203 counter\n");
|
||||
/* Nothing to transmit, start the T203 counter instead */
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
pri->t203_timer = pri_schedule_event(pri, T_203, t203_expire, pri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,12 +250,12 @@ static pri_event *q921_ack_rx(struct pri *pri, int ack)
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Something left to transmit (%d), restarting T200 counter\n", pri->txqueue->h.n_s);
|
||||
if (!pri->t200_timer)
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Nothing left, starting T203 counter\n");
|
||||
/* Nothing to transmit, start the T203 counter instead */
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
pri->t203_timer = pri_schedule_event(pri, T_203, t203_expire, pri);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -332,7 +332,7 @@ static void t200_expire(void *vpri)
|
||||
pri->solicitfbit = 1;
|
||||
pri->retrans++;
|
||||
/* Up to three retransmissions */
|
||||
if (pri->retrans < pri->timers[PRI_TIMER_N200]) {
|
||||
if (pri->retrans < N_200) {
|
||||
/* Reschedule t200_timer */
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Retransmitting %d bytes\n", pri->txqueue->len);
|
||||
@@ -345,7 +345,7 @@ static void t200_expire(void *vpri)
|
||||
}
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Rescheduling retransmission (%d)\n", pri->retrans);
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Timeout occured, restarting PRI\n");
|
||||
@@ -359,10 +359,10 @@ static void t200_expire(void *vpri)
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Retrying poll with f-bit\n");
|
||||
pri->retrans++;
|
||||
if (pri->retrans < pri->timers[PRI_TIMER_N200]) {
|
||||
if (pri->retrans < N_200) {
|
||||
pri->solicitfbit = 1;
|
||||
q921_rr(pri, 1, 1);
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("-- Timeout occured, restarting PRI\n");
|
||||
@@ -436,7 +436,7 @@ int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr)
|
||||
if (!pri->t200_timer) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("Starting T_200 timer\n");
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
|
||||
} else
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("T_200 timer already going (%d)\n", pri->t200_timer);
|
||||
@@ -459,7 +459,7 @@ static void t203_expire(void *vpri)
|
||||
pri->retrans = 0;
|
||||
q921_rr(pri, 1, 1);
|
||||
/* Start timer T200 to resend our RR if we don't get it */
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
pri->t203_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message("T203 counter expired in weird state %d\n", pri->q921_state);
|
||||
@@ -656,7 +656,7 @@ static pri_event *q921_dchannel_up(struct pri *pri)
|
||||
pri->q921_state = Q921_LINK_CONNECTION_ESTABLISHED;
|
||||
|
||||
/* Start the T203 timer */
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
pri->t203_timer = pri_schedule_event(pri, T_203, t203_expire, pri);
|
||||
|
||||
/* Report event that D-Channel is now up */
|
||||
pri->ev.gen.e = PRI_EVENT_DCHAN_UP;
|
||||
@@ -680,7 +680,7 @@ void q921_reset(struct pri *pri)
|
||||
pri->v_a = 0;
|
||||
pri->v_r = 0;
|
||||
pri->v_na = 0;
|
||||
pri->window = pri->timers[PRI_TIMER_K];
|
||||
pri->window = 7;
|
||||
pri->windowlen = 0;
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
@@ -797,7 +797,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
/* Reset and restart t203 timer */
|
||||
if (pri->t203_timer)
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
pri->t203_timer = pri_schedule_event(pri, T_203, t203_expire, pri);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
48
q931.c
48
q931.c
@@ -36,7 +36,7 @@
|
||||
|
||||
struct msgtype {
|
||||
int msgnum;
|
||||
unsigned char *name;
|
||||
char *name;
|
||||
int mandies[MAX_MAND_IES];
|
||||
};
|
||||
|
||||
@@ -201,6 +201,10 @@ struct msgtype facilities[] = {
|
||||
#define LOC_INTERNATIONAL_NETWORK 0x7
|
||||
#define LOC_NETWORK_BEYOND_INTERWORKING 0xa
|
||||
|
||||
#define T_308 4000
|
||||
#define T_305 30000
|
||||
#define T_313 4000
|
||||
|
||||
struct q931_call {
|
||||
struct pri *pri; /* PRI */
|
||||
int cr; /* Call Reference */
|
||||
@@ -771,7 +775,7 @@ static void q931_get_number(unsigned char *num, int maxlen, unsigned char *src,
|
||||
|
||||
static FUNC_DUMP(dump_called_party_number)
|
||||
{
|
||||
char cnum[256];
|
||||
unsigned char cnum[256];
|
||||
|
||||
q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
|
||||
pri_message("%c Called Number (len=%2d) [ Ext: %d TON: %s (%d) NPI: %s (%d) '%s' ]\n",
|
||||
@@ -780,7 +784,7 @@ static FUNC_DUMP(dump_called_party_number)
|
||||
|
||||
static FUNC_DUMP(dump_called_party_subaddr)
|
||||
{
|
||||
char cnum[256];
|
||||
unsigned char cnum[256];
|
||||
q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
|
||||
pri_message("%c Called Sub-Address (len=%2d) [ Ext: %d Type: %s (%d) O: %d '%s' ]\n",
|
||||
prefix, len, ie->data[0] >> 7,
|
||||
@@ -790,7 +794,7 @@ static FUNC_DUMP(dump_called_party_subaddr)
|
||||
|
||||
static FUNC_DUMP(dump_calling_party_number)
|
||||
{
|
||||
char cnum[256];
|
||||
unsigned char cnum[256];
|
||||
if (ie->data[0] & 0x80)
|
||||
q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
|
||||
else
|
||||
@@ -804,7 +808,7 @@ static FUNC_DUMP(dump_calling_party_number)
|
||||
|
||||
static FUNC_DUMP(dump_calling_party_subaddr)
|
||||
{
|
||||
char cnum[256];
|
||||
unsigned char cnum[256];
|
||||
q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
|
||||
pri_message("%c Calling Sub-Address (len=%2d) [ Ext: %d Type: %s (%d) O: %d '%s' ]\n",
|
||||
prefix, len, ie->data[0] >> 7,
|
||||
@@ -814,7 +818,7 @@ static FUNC_DUMP(dump_calling_party_subaddr)
|
||||
|
||||
static FUNC_DUMP(dump_redirecting_number)
|
||||
{
|
||||
char cnum[256];
|
||||
unsigned char cnum[256];
|
||||
int i = 0;
|
||||
/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
|
||||
walking through all bytes until one with ext bit (8) set to 1 */
|
||||
@@ -841,7 +845,7 @@ static FUNC_DUMP(dump_redirecting_number)
|
||||
|
||||
static FUNC_DUMP(dump_connected_number)
|
||||
{
|
||||
char cnum[256];
|
||||
unsigned char cnum[256];
|
||||
int i = 0;
|
||||
/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
|
||||
walking through all bytes until one with ext bit (8) set to 1 */
|
||||
@@ -883,14 +887,14 @@ static FUNC_RECV(receive_redirecting_number)
|
||||
}
|
||||
}
|
||||
while(!(ie->data[i++] & 0x80));
|
||||
q931_get_number(call->redirectingnum, sizeof(call->redirectingnum), ie->data + i, ie->len - i);
|
||||
q931_get_number((unsigned char *) call->redirectingnum, sizeof(call->redirectingnum), ie->data + i, ie->len - i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static FUNC_DUMP(dump_redirecting_subaddr)
|
||||
{
|
||||
char cnum[256];
|
||||
unsigned char cnum[256];
|
||||
q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
|
||||
pri_message("%c Redirecting Sub-Address (len=%2d) [ Ext: %d Type: %s (%d) O: %d '%s' ]\n",
|
||||
prefix, len, ie->data[0] >> 7,
|
||||
@@ -901,14 +905,14 @@ static FUNC_DUMP(dump_redirecting_subaddr)
|
||||
static FUNC_RECV(receive_calling_party_subaddr)
|
||||
{
|
||||
/* copy digits to call->callingsubaddr */
|
||||
q931_get_number(call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 2, len - 4);
|
||||
q931_get_number((unsigned char *) call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 2, len - 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FUNC_RECV(receive_called_party_number)
|
||||
{
|
||||
/* copy digits to call->callednum */
|
||||
q931_get_number(call->callednum, sizeof(call->callednum), ie->data + 1, len - 3);
|
||||
q931_get_number((unsigned char *) call->callednum, sizeof(call->callednum), ie->data + 1, len - 3);
|
||||
call->calledplan = ie->data[0] & 0x7f;
|
||||
return 0;
|
||||
}
|
||||
@@ -929,11 +933,11 @@ static FUNC_RECV(receive_calling_party_number)
|
||||
extbit = (ie->data[0] >> 7) & 0x01;
|
||||
|
||||
if (extbit) {
|
||||
q931_get_number(call->callernum, sizeof(call->callernum), ie->data + 1, len - 3);
|
||||
q931_get_number((unsigned char *) call->callernum, sizeof(call->callernum), ie->data + 1, len - 3);
|
||||
call->callerpres = 0; /* PI presentation allowed
|
||||
SI user-provided, not screened */
|
||||
} else {
|
||||
q931_get_number(call->callernum, sizeof(call->callernum), ie->data + 2, len - 4);
|
||||
q931_get_number((unsigned char *) call->callernum, sizeof(call->callernum), ie->data + 2, len - 4);
|
||||
call->callerpres = ie->data[1] & 0x7f;
|
||||
}
|
||||
return 0;
|
||||
@@ -962,7 +966,7 @@ static FUNC_RECV(receive_user_user)
|
||||
{
|
||||
call->useruserprotocoldisc = ie->data[0] & 0xff;
|
||||
if (call->useruserprotocoldisc == 4) /* IA5 */
|
||||
q931_get_number(call->useruserinfo, sizeof(call->useruserinfo), ie->data + 1, len - 3);
|
||||
q931_get_number((unsigned char *) call->useruserinfo, sizeof(call->useruserinfo), ie->data + 1, len - 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1026,7 +1030,7 @@ static FUNC_RECV(receive_display)
|
||||
data++;
|
||||
len--;
|
||||
}
|
||||
q931_get_number(call->callername, sizeof(call->callername), data, len - 2);
|
||||
q931_get_number((unsigned char *) call->callername, sizeof(call->callername), data, len - 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1060,7 +1064,7 @@ static FUNC_RECV(receive_facility)
|
||||
return 0;
|
||||
}
|
||||
if (ie->data[13] + 14 == ie->len) {
|
||||
q931_get_number(call->callername, sizeof(call->callername) - 1, ie->data + 14, ie->len - 14);
|
||||
q931_get_number((unsigned char *) call->callername, sizeof(call->callername) - 1, ie->data + 14, ie->len - 14);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1812,7 +1816,7 @@ static int q931_handle_ie(int codeset, struct pri *pri, q931_call *c, int msg, q
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void init_header(struct pri *pri, q931_call *call, char *buf, q931_h **hb, q931_mh **mhb, int *len)
|
||||
static void init_header(struct pri *pri, q931_call *call, unsigned char *buf, q931_h **hb, q931_mh **mhb, int *len)
|
||||
{
|
||||
/* Returns header and message header and modifies length in place */
|
||||
q931_h *h = (q931_h *)buf;
|
||||
@@ -2111,7 +2115,7 @@ int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn)
|
||||
pri_schedule_del(pri, c->retranstimer);
|
||||
c->retranstimer = 0;
|
||||
if ((pri->localtype == PRI_CPE) && (!pri->subchannel))
|
||||
c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T313], pri_connect_timeout, c);
|
||||
c->retranstimer = pri_schedule_event(pri, T_313, pri_connect_timeout, c);
|
||||
return send_message(pri, c, Q931_CONNECT, connect_ies);
|
||||
}
|
||||
|
||||
@@ -2130,9 +2134,9 @@ int q931_release(struct pri *pri, q931_call *c, int cause)
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(pri, c->retranstimer);
|
||||
if (!c->t308_timedout) {
|
||||
c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T308], pri_release_timeout, c);
|
||||
c->retranstimer = pri_schedule_event(pri, T_308, pri_release_timeout, c);
|
||||
} else {
|
||||
c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T308], pri_release_finaltimeout, c);
|
||||
c->retranstimer = pri_schedule_event(pri, T_308, pri_release_finaltimeout, c);
|
||||
}
|
||||
return send_message(pri, c, Q931_RELEASE, release_ies);
|
||||
} else
|
||||
@@ -2176,7 +2180,7 @@ int q931_disconnect(struct pri *pri, q931_call *c, int cause)
|
||||
c->sendhangupack = 1;
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(pri, c->retranstimer);
|
||||
c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T305], pri_disconnect_timeout, c);
|
||||
c->retranstimer = pri_schedule_event(pri, T_305, pri_disconnect_timeout, c);
|
||||
return send_message(pri, c, Q931_DISCONNECT, disconnect_ies);
|
||||
} else
|
||||
return 0;
|
||||
@@ -2374,7 +2378,7 @@ int q931_hangup(struct pri *pri, q931_call *c, int cause)
|
||||
pri_error("q931_hangup shouldn't be called in this state, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
|
||||
break;
|
||||
default:
|
||||
pri_error("We're not yet handling hanging up when our state is %d, contact support@digium.com, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
|
||||
pri_error("We're not yet handling hanging up when our state is %d, contact support@digium.com, ourstate %s, peerstate %s\n",c->ourcallstate,callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
|
||||
return -1;
|
||||
}
|
||||
/* we did handle hangup properly at this point */
|
||||
|
||||
Reference in New Issue
Block a user