2001-05-13 00:57:53 +08:00
|
|
|
/*
|
|
|
|
* 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_INTERNAL_H
|
|
|
|
#define _PRI_INTERNAL_H
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
struct pri_sched {
|
|
|
|
struct timeval when;
|
|
|
|
void (*callback)(void *data);
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct q921_frame;
|
|
|
|
enum q931_state;
|
|
|
|
enum q931_mode;
|
|
|
|
|
|
|
|
/* No more than 128 scheduled events */
|
|
|
|
#define MAX_SCHED 128
|
|
|
|
|
2004-10-02 22:55:20 +08:00
|
|
|
#define MAX_TIMERS 32
|
|
|
|
|
2001-05-13 00:57:53 +08:00
|
|
|
struct pri {
|
|
|
|
int fd; /* File descriptor for D-Channel */
|
2005-03-17 23:46:23 +08:00
|
|
|
pri_io_cb read_func; /* Read data callback */
|
|
|
|
pri_io_cb write_func; /* Write data callback */
|
|
|
|
void *userdata;
|
2004-06-05 14:50:55 +08:00
|
|
|
struct pri *subchannel; /* Sub-channel if appropriate */
|
|
|
|
struct pri *master; /* Master channel if appropriate */
|
2001-05-13 00:57:53 +08:00
|
|
|
struct pri_sched pri_sched[MAX_SCHED]; /* Scheduled events */
|
|
|
|
int debug; /* Debug stuff */
|
|
|
|
int state; /* State of D-channel */
|
|
|
|
int switchtype; /* Switch type */
|
2004-06-26 12:37:09 +08:00
|
|
|
int nsf; /* Network-Specific Facility (if any) */
|
2001-05-13 00:57:53 +08:00
|
|
|
int localtype; /* Local network type (unknown, network, cpe) */
|
|
|
|
int remotetype; /* Remote network type (unknown, network, cpe) */
|
2004-06-05 14:50:55 +08:00
|
|
|
|
|
|
|
int sapi;
|
|
|
|
int tei;
|
|
|
|
int protodisc;
|
2001-05-13 00:57:53 +08:00
|
|
|
|
|
|
|
/* Q.921 State */
|
|
|
|
int q921_state;
|
|
|
|
int window; /* Max window size */
|
2004-03-29 16:09:01 +08:00
|
|
|
int windowlen; /* Fullness of window */
|
2001-05-13 00:57:53 +08:00
|
|
|
int v_s; /* Next N(S) for transmission */
|
|
|
|
int v_a; /* Last acknowledged frame */
|
|
|
|
int v_r; /* Next frame expected to be received */
|
|
|
|
int v_na; /* What we've told our peer we've acknowledged */
|
|
|
|
int solicitfbit; /* Have we sent an I or S frame with the F-bit set? */
|
|
|
|
int retrans; /* Retransmissions */
|
2003-09-25 14:13:14 +08:00
|
|
|
int sentrej; /* Are we in reject state */
|
2001-05-13 00:57:53 +08:00
|
|
|
|
|
|
|
int cref; /* Next call reference value */
|
|
|
|
|
|
|
|
int busy; /* Peer is busy */
|
|
|
|
|
|
|
|
/* Various timers */
|
|
|
|
int sabme_timer; /* SABME retransmit */
|
|
|
|
int t203_timer; /* Max idle time */
|
|
|
|
int t200_timer; /* T-200 retransmission timer */
|
2004-10-02 22:55:20 +08:00
|
|
|
/* All ISDN Timer values */
|
|
|
|
int timers[MAX_TIMERS];
|
|
|
|
|
2001-05-13 00:57:53 +08:00
|
|
|
/* Used by scheduler */
|
|
|
|
struct timeval tv;
|
2001-11-26 10:54:32 +08:00
|
|
|
int schedev;
|
2001-05-13 00:57:53 +08:00
|
|
|
pri_event ev; /* Static event thingy */
|
|
|
|
|
|
|
|
/* Q.921 Re-transmission queue */
|
|
|
|
struct q921_frame *txqueue;
|
|
|
|
|
|
|
|
/* Q.931 calls */
|
2004-06-07 11:33:51 +08:00
|
|
|
q931_call **callpool;
|
|
|
|
q931_call *localpool;
|
2003-05-16 03:35:05 +08:00
|
|
|
|
|
|
|
/* do we do overlap dialing */
|
|
|
|
int overlapdial;
|
2004-03-15 13:53:25 +08:00
|
|
|
|
|
|
|
#ifdef LIBPRI_COUNTERS
|
|
|
|
/* q921/q931 packet counters */
|
|
|
|
unsigned int q921_txcount;
|
|
|
|
unsigned int q921_rxcount;
|
|
|
|
unsigned int q931_txcount;
|
|
|
|
unsigned int q931_rxcount;
|
|
|
|
#endif
|
2005-02-04 06:14:44 +08:00
|
|
|
|
|
|
|
unsigned char last_invoke; /* Last ROSE invoke ID */
|
2005-05-12 22:48:00 +08:00
|
|
|
unsigned char sendfacility;
|
2001-05-13 00:57:53 +08:00
|
|
|
};
|
|
|
|
|
2004-06-16 23:33:58 +08:00
|
|
|
struct pri_sr {
|
|
|
|
int transmode;
|
|
|
|
int channel;
|
|
|
|
int exclusive;
|
|
|
|
int nonisdn;
|
|
|
|
char *caller;
|
|
|
|
int callerplan;
|
|
|
|
char *callername;
|
|
|
|
int callerpres;
|
|
|
|
char *called;
|
|
|
|
int calledplan;
|
|
|
|
int userl1;
|
|
|
|
int numcomplete;
|
2004-10-31 04:13:20 +08:00
|
|
|
char *redirectingnum;
|
|
|
|
int redirectingplan;
|
|
|
|
int redirectingpres;
|
|
|
|
int redirectingreason;
|
2005-03-02 23:56:11 +08:00
|
|
|
int justsignalling;
|
2005-12-04 23:32:46 +08:00
|
|
|
const char *useruserinfo;
|
2006-01-20 02:22:06 +08:00
|
|
|
int transferable;
|
2004-06-16 23:33:58 +08:00
|
|
|
};
|
|
|
|
|
2004-06-05 14:50:55 +08:00
|
|
|
/* Internal switch types */
|
2005-03-02 23:56:11 +08:00
|
|
|
#define PRI_SWITCH_GR303_EOC_PATH 19
|
|
|
|
#define PRI_SWITCH_GR303_TMC_SWITCHING 20
|
|
|
|
|
|
|
|
struct apdu_event {
|
|
|
|
int message; /* What message to send the ADPU in */
|
|
|
|
void (*callback)(void *data); /* Callback function for when response is received */
|
|
|
|
void *data; /* Data to callback */
|
|
|
|
unsigned char apdu[255]; /* ADPU to send */
|
|
|
|
int apdu_len; /* Length of ADPU */
|
|
|
|
int sent; /* Have we been sent already? */
|
|
|
|
struct apdu_event *next; /* Linked list pointer */
|
|
|
|
};
|
2004-06-05 14:50:55 +08:00
|
|
|
|
2004-10-28 04:43:23 +08:00
|
|
|
/* q931_call datastructure */
|
|
|
|
|
|
|
|
struct q931_call {
|
|
|
|
struct pri *pri; /* PRI */
|
2005-01-17 20:58:05 +08:00
|
|
|
int cr; /* Call Reference */
|
2004-10-28 04:43:23 +08:00
|
|
|
int forceinvert; /* Force inversion of call number even if 0 */
|
|
|
|
q931_call *next;
|
|
|
|
/* Slotmap specified (bitmap of channels 31/24-1) (Channel Identifier IE) (-1 means not specified) */
|
|
|
|
int slotmap;
|
|
|
|
/* An explicit channel (Channel Identifier IE) (-1 means not specified) */
|
|
|
|
int channelno;
|
|
|
|
/* An explicit DS1 (-1 means not specified) */
|
|
|
|
int ds1no;
|
2005-05-19 22:06:43 +08:00
|
|
|
/* Whether or not the ds1 is explicitly identified or implicit. If implicit
|
|
|
|
the bchan is on the same span as the current active dchan (NFAS) */
|
|
|
|
int ds1explicit;
|
2004-10-28 04:43:23 +08:00
|
|
|
/* Channel flags (0 means none retrieved) */
|
|
|
|
int chanflags;
|
|
|
|
|
|
|
|
int alive; /* Whether or not the call is alive */
|
|
|
|
int acked; /* Whether setup has been acked or not */
|
2005-01-17 20:58:05 +08:00
|
|
|
int sendhangupack; /* Whether or not to send a hangup ack */
|
2004-10-28 04:43:23 +08:00
|
|
|
int proc; /* Whether we've sent a call proceeding / alerting */
|
|
|
|
|
2005-01-17 20:58:05 +08:00
|
|
|
int ri; /* Restart Indicator (Restart Indicator IE) */
|
2004-10-28 04:43:23 +08:00
|
|
|
|
|
|
|
/* Bearer Capability */
|
|
|
|
int transcapability;
|
|
|
|
int transmoderate;
|
|
|
|
int transmultiple;
|
|
|
|
int userl1;
|
|
|
|
int userl2;
|
|
|
|
int userl3;
|
|
|
|
int rateadaption;
|
|
|
|
|
|
|
|
int sentchannel;
|
2005-03-02 23:56:11 +08:00
|
|
|
int justsignalling; /* for a signalling-only connection */
|
2004-10-28 04:43:23 +08:00
|
|
|
|
|
|
|
int progcode; /* Progress coding */
|
|
|
|
int progloc; /* Progress Location */
|
|
|
|
int progress; /* Progress indicator */
|
2005-01-17 20:58:05 +08:00
|
|
|
int progressmask; /* Progress Indicator bitmask */
|
2004-10-28 04:43:23 +08:00
|
|
|
|
2005-01-17 20:58:05 +08:00
|
|
|
int notify; /* Notification */
|
2004-10-28 04:43:23 +08:00
|
|
|
|
|
|
|
int causecode; /* Cause Coding */
|
|
|
|
int causeloc; /* Cause Location */
|
|
|
|
int cause; /* Cause of clearing */
|
|
|
|
|
2005-01-17 20:58:05 +08:00
|
|
|
int peercallstate; /* Call state of peer as reported */
|
2004-10-28 04:43:23 +08:00
|
|
|
int ourcallstate; /* Our call state */
|
|
|
|
int sugcallstate; /* Status call state */
|
|
|
|
|
|
|
|
int callerplan;
|
2005-07-12 10:33:25 +08:00
|
|
|
int callerplanani;
|
2004-10-28 04:43:23 +08:00
|
|
|
int callerpres; /* Caller presentation */
|
2005-06-22 04:37:22 +08:00
|
|
|
char callerani[256]; /* Caller */
|
|
|
|
char callernum[256];
|
2004-10-28 04:43:23 +08:00
|
|
|
char callername[256];
|
|
|
|
|
2005-12-02 01:59:56 +08:00
|
|
|
char keypad_digits[64]; /* Buffer for digits that come in KEYPAD_FACILITY */
|
2005-03-02 23:56:11 +08:00
|
|
|
|
2004-10-28 04:43:23 +08:00
|
|
|
int ani2; /* ANI II */
|
|
|
|
|
2005-07-12 10:33:25 +08:00
|
|
|
int calledplan;
|
2004-10-28 04:43:23 +08:00
|
|
|
int nonisdn;
|
|
|
|
char callednum[256]; /* Called Number */
|
|
|
|
int complete; /* no more digits coming */
|
2005-01-17 20:58:05 +08:00
|
|
|
int newcall; /* if the received message has a new call reference value */
|
2004-10-28 04:43:23 +08:00
|
|
|
|
|
|
|
int retranstimer; /* Timer for retransmitting DISC */
|
|
|
|
int t308_timedout; /* Whether t308 timed out once */
|
2005-04-07 03:42:41 +08:00
|
|
|
|
2004-10-28 04:43:23 +08:00
|
|
|
int redirectingplan;
|
|
|
|
int redirectingpres;
|
|
|
|
int redirectingreason;
|
2005-04-07 03:42:41 +08:00
|
|
|
char redirectingnum[256]; /* Number of redirecting party */
|
|
|
|
char redirectingname[256]; /* Name of redirecting party */
|
|
|
|
|
|
|
|
/* Filled in cases of multiple diversions */
|
|
|
|
int origcalledplan;
|
|
|
|
int origcalledpres;
|
2005-07-12 10:33:25 +08:00
|
|
|
int origredirectingreason; /* Original reason for redirect (in cases of multiple redirects) */
|
2005-04-07 03:42:41 +08:00
|
|
|
char origcalledname[256]; /* Original name of person being called */
|
2005-07-12 10:33:25 +08:00
|
|
|
char origcallednum[256]; /* Orignal number of person being called */
|
2004-10-28 04:43:23 +08:00
|
|
|
|
2005-07-12 10:33:25 +08:00
|
|
|
int useruserprotocoldisc;
|
2004-10-28 04:43:23 +08:00
|
|
|
char useruserinfo[256];
|
|
|
|
char callingsubaddr[256]; /* Calling parties sub address */
|
2005-04-05 11:55:58 +08:00
|
|
|
|
|
|
|
long aoc_units; /* Advice of Charge Units */
|
2005-03-02 23:56:11 +08:00
|
|
|
|
|
|
|
struct apdu_event *apdus; /* APDU queue for call */
|
2006-01-20 02:22:06 +08:00
|
|
|
|
|
|
|
int transferable;
|
|
|
|
unsigned int rlt_call_id; /* RLT call id */
|
2004-10-28 04:43:23 +08:00
|
|
|
};
|
|
|
|
|
2001-05-13 00:57:53 +08:00
|
|
|
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
|
|
|
|
|
2001-11-26 10:54:32 +08:00
|
|
|
extern pri_event *pri_schedule_run(struct pri *pri);
|
2001-05-13 00:57:53 +08:00
|
|
|
|
|
|
|
extern void pri_schedule_del(struct pri *pri, int ev);
|
|
|
|
|
|
|
|
extern pri_event *pri_mkerror(struct pri *pri, char *errstr);
|
|
|
|
|
2005-05-23 23:06:33 +08:00
|
|
|
extern void pri_message(struct pri *pri, char *fmt, ...);
|
2003-02-12 21:59:23 +08:00
|
|
|
|
2005-05-23 23:06:33 +08:00
|
|
|
extern void pri_error(struct pri *pri, char *fmt, ...);
|
2003-02-12 21:59:23 +08:00
|
|
|
|
2005-06-22 06:47:39 +08:00
|
|
|
void libpri_copy_string(char *dst, const char *src, size_t size);
|
|
|
|
|
2001-05-13 00:57:53 +08:00
|
|
|
#endif
|