Review Board 1.7.16


Add ISDN Calling and Called Subaddress support functions to LIBPRI

Review Request #406 - Created Oct. 14, 2009 and submitted

Alec Davis
15604
Reviewers
asterisk-dev
mattf, rmudgett
LibPRI
Further Libpri support for subaddress, previously LIBPRI only supported receiving Calling Subaddress.

The first intentions of this are to add Transmit and Receive capabilites for Calling Subaddress and Called Subaddress.

Calling, Called, Connected and Redirecting Subaddress, now correctly supports User Specific type and the default NSAP.

Redirection and Redirecting Subaddress have been identified, but will come later.

 

Changes between revision 6 and 7

1 2 3 4 5 6 7
1 2 3 4 5 6 7

  1. /team/rmudgett/subaddr/pri_internal.h: Loading...
  2. /team/rmudgett/subaddr/q931.c: Loading...
/team/rmudgett/subaddr/pri_internal.h
Diff Revision 6 Diff Revision 7
1
/*
1
/*
2
 * libpri: An implementation of Primary Rate ISDN
2
 * libpri: An implementation of Primary Rate ISDN
3
 *
3
 *
4
 * Written by Mark Spencer <markster@digium.com>
4
 * Written by Mark Spencer <markster@digium.com>
5
 *
5
 *
6
 * Copyright (C) 2001, Digium, Inc.
6
 * Copyright (C) 2001, Digium, Inc.
7
 * All Rights Reserved.
7
 * All Rights Reserved.
8
 */
8
 */
9

    
   
9

   
10
/*
10
/*
11
 * See http://www.asterisk.org for more information about
11
 * See http://www.asterisk.org for more information about
12
 * the Asterisk project. Please do not directly contact
12
 * the Asterisk project. Please do not directly contact
13
 * any of the maintainers of this project for assistance;
13
 * any of the maintainers of this project for assistance;
14
 * the project provides a web site, mailing lists and IRC
14
 * the project provides a web site, mailing lists and IRC
15
 * channels for your use.
15
 * channels for your use.
16
 *
16
 *
17
 * This program is free software, distributed under the terms of
17
 * This program is free software, distributed under the terms of
18
 * the GNU General Public License Version 2 as published by the
18
 * the GNU General Public License Version 2 as published by the
19
 * Free Software Foundation. See the LICENSE file included with
19
 * Free Software Foundation. See the LICENSE file included with
20
 * this program for more details.
20
 * this program for more details.
21
 *
21
 *
22
 * In addition, when this program is distributed with Asterisk in
22
 * In addition, when this program is distributed with Asterisk in
23
 * any form that would qualify as a 'combined work' or as a
23
 * any form that would qualify as a 'combined work' or as a
24
 * 'derivative work' (but not mere aggregation), you can redistribute
24
 * 'derivative work' (but not mere aggregation), you can redistribute
25
 * and/or modify the combination under the terms of the license
25
 * and/or modify the combination under the terms of the license
26
 * provided with that copy of Asterisk, instead of the license
26
 * provided with that copy of Asterisk, instead of the license
27
 * terms granted here.
27
 * terms granted here.
28
 */
28
 */
29
 
29
 
30
#ifndef _PRI_INTERNAL_H
30
#ifndef _PRI_INTERNAL_H
31
#define _PRI_INTERNAL_H
31
#define _PRI_INTERNAL_H
32

    
   
32

   
33
#include <stddef.h>
33
#include <stddef.h>
34
#include <sys/time.h>
34
#include <sys/time.h>
35
#include "pri_q921.h"
35
#include "pri_q921.h"
36
#include "pri_q931.h"
36
#include "pri_q931.h"
37

    
   
37

   
38
#define ARRAY_LEN(arr)	(sizeof(arr) / sizeof((arr)[0]))
38
#define ARRAY_LEN(arr)	(sizeof(arr) / sizeof((arr)[0]))
39

    
   
39

   
40
#define DBGHEAD __FILE__ ":%d %s: "
40
#define DBGHEAD __FILE__ ":%d %s: "
41
#define DBGINFO __LINE__,__PRETTY_FUNCTION__
41
#define DBGINFO __LINE__,__PRETTY_FUNCTION__
42

    
   
42

   
43
struct pri_sched {
43
struct pri_sched {
44
	struct timeval when;
44
	struct timeval when;
45
	void (*callback)(void *data);
45
	void (*callback)(void *data);
46
	void *data;
46
	void *data;
47
};
47
};
48

    
   
48

   
49
/*! Maximum number of scheduled events active at the same time. */
49
/*! Maximum number of scheduled events active at the same time. */
50
#define MAX_SCHED 128
50
#define MAX_SCHED 128
51

    
   
51

   
52
/*! \brief D channel controller structure */
52
/*! \brief D channel controller structure */
53
struct pri {
53
struct pri {
54
	int fd;				/* File descriptor for D-Channel */
54
	int fd;				/* File descriptor for D-Channel */
55
	pri_io_cb read_func;		/* Read data callback */
55
	pri_io_cb read_func;		/* Read data callback */
56
	pri_io_cb write_func;		/* Write data callback */
56
	pri_io_cb write_func;		/* Write data callback */
57
	void *userdata;
57
	void *userdata;
58
	struct pri *subchannel;	/* Sub-channel if appropriate */
58
	struct pri *subchannel;	/* Sub-channel if appropriate */
59
	struct pri *master;		/* Master channel if appropriate */
59
	struct pri *master;		/* Master channel if appropriate */
60
	struct pri_sched pri_sched[MAX_SCHED];	/* Scheduled events */
60
	struct pri_sched pri_sched[MAX_SCHED];	/* Scheduled events */
61
	int debug;			/* Debug stuff */
61
	int debug;			/* Debug stuff */
62
	int state;			/* State of D-channel */
62
	int state;			/* State of D-channel */
63
	int switchtype;		/* Switch type */
63
	int switchtype;		/* Switch type */
64
	int nsf;		/* Network-Specific Facility (if any) */
64
	int nsf;		/* Network-Specific Facility (if any) */
65
	int localtype;		/* Local network type (unknown, network, cpe) */
65
	int localtype;		/* Local network type (unknown, network, cpe) */
66
	int remotetype;		/* Remote network type (unknown, network, cpe) */
66
	int remotetype;		/* Remote network type (unknown, network, cpe) */
67

    
   
67

   
68
	int sapi;
68
	int sapi;
69
	int tei;
69
	int tei;
70
	int protodisc;
70
	int protodisc;
71
	unsigned int bri:1;
71
	unsigned int bri:1;
72
	unsigned int acceptinbanddisconnect:1;	/* Should we allow inband progress after DISCONNECT? */
72
	unsigned int acceptinbanddisconnect:1;	/* Should we allow inband progress after DISCONNECT? */
73
	
73
	
74
	/* Q.921 State */
74
	/* Q.921 State */
75
	int q921_state;	
75
	int q921_state;	
76
	int window;			/* Max window size */
76
	int window;			/* Max window size */
77
	int windowlen;		/* Fullness of window */
77
	int windowlen;		/* Fullness of window */
78
	int v_s;			/* Next N(S) for transmission */
78
	int v_s;			/* Next N(S) for transmission */
79
	int v_a;			/* Last acknowledged frame */
79
	int v_a;			/* Last acknowledged frame */
80
	int v_r;			/* Next frame expected to be received */
80
	int v_r;			/* Next frame expected to be received */
81
	int v_na;			/* What we've told our peer we've acknowledged */
81
	int v_na;			/* What we've told our peer we've acknowledged */
82
	int solicitfbit;	/* Have we sent an I or S frame with the F-bit set? */
82
	int solicitfbit;	/* Have we sent an I or S frame with the F-bit set? */
83
	int retrans;		/* Retransmissions */
83
	int retrans;		/* Retransmissions */
84
	int sentrej;		/* Are we in reject state */
84
	int sentrej;		/* Are we in reject state */
85
	
85
	
86
	int cref;			/* Next call reference value */
86
	int cref;			/* Next call reference value */
87
	
87
	
88
	int busy;			/* Peer is busy */
88
	int busy;			/* Peer is busy */
89

    
   
89

   
90
	/* Various timers */
90
	/* Various timers */
91
	int sabme_timer;	/* SABME retransmit */
91
	int sabme_timer;	/* SABME retransmit */
92
	int sabme_count;	/* SABME retransmit counter for BRI */
92
	int sabme_count;	/* SABME retransmit counter for BRI */
93
	int t203_timer;		/* Max idle time */
93
	int t203_timer;		/* Max idle time */
94
	int t202_timer;
94
	int t202_timer;
95
	int n202_counter;
95
	int n202_counter;
96
	int ri;
96
	int ri;
97
	int t200_timer;		/* T-200 retransmission timer */
97
	int t200_timer;		/* T-200 retransmission timer */
98
	/* All ISDN Timer values */
98
	/* All ISDN Timer values */
99
	int timers[PRI_MAX_TIMERS];
99
	int timers[PRI_MAX_TIMERS];
100

    
   
100

   
101
	/* Used by scheduler */
101
	/* Used by scheduler */
102
	struct timeval tv;
102
	struct timeval tv;
103
	int schedev;
103
	int schedev;
104
	pri_event ev;		/* Static event thingy */
104
	pri_event ev;		/* Static event thingy */
105
	/*! Subcommands for static event thingy. */
105
	/*! Subcommands for static event thingy. */
106
	struct pri_subcommands subcmds;
106
	struct pri_subcommands subcmds;
107
	
107
	
108
	/* Q.921 Re-transmission queue */
108
	/* Q.921 Re-transmission queue */
109
	struct q921_frame *txqueue;
109
	struct q921_frame *txqueue;
110
	
110
	
111
	/* Q.931 calls */
111
	/* Q.931 calls */
112
	q931_call **callpool;
112
	q931_call **callpool;
113
	q931_call *localpool;
113
	q931_call *localpool;
114

    
   
114

   
115
	/* do we do overlap dialing */
115
	/* do we do overlap dialing */
116
	int overlapdial;
116
	int overlapdial;
117

    
   
117

   
118
	/* do we support SERVICE messages */
118
	/* do we support SERVICE messages */
119
	int service_message_support;
119
	int service_message_support;
120

    
   
120

   
121
	/* do not skip channel 16 */
121
	/* do not skip channel 16 */
122
	int chan_mapping_logical;
122
	int chan_mapping_logical;
123

    
   
123

   
124
#ifdef LIBPRI_COUNTERS
124
#ifdef LIBPRI_COUNTERS
125
	/* q921/q931 packet counters */
125
	/* q921/q931 packet counters */
126
	unsigned int q921_txcount;
126
	unsigned int q921_txcount;
127
	unsigned int q921_rxcount;
127
	unsigned int q921_rxcount;
128
	unsigned int q931_txcount;
128
	unsigned int q931_txcount;
129
	unsigned int q931_rxcount;
129
	unsigned int q931_rxcount;
130
#endif
130
#endif
131

    
   
131

   
132
	short last_invoke;	/* Last ROSE invoke ID */
132
	short last_invoke;	/* Last ROSE invoke ID */
133
	unsigned char sendfacility;
133
	unsigned char sendfacility;
134
};
134
};
135

    
   
135

   
136
/*! \brief Maximum name length plus null terminator (From ECMA-164) */
136
/*! \brief Maximum name length plus null terminator (From ECMA-164) */
137
#define PRI_MAX_NAME_LEN		(50 + 1)
137
#define PRI_MAX_NAME_LEN		(50 + 1)
138

    
   
138

   
139
/*! \brief Q.SIG name information. */
139
/*! \brief Q.SIG name information. */
140
struct q931_party_name {
140
struct q931_party_name {
141
	/*! \brief TRUE if name data is valid */
141
	/*! \brief TRUE if name data is valid */
142
	unsigned char valid;
142
	unsigned char valid;
143
	/*!
143
	/*!
144
	 * \brief Q.931 presentation-indicator encoded field
144
	 * \brief Q.931 presentation-indicator encoded field
145
	 * \note Must tollerate the Q.931 screening-indicator field values being present.
145
	 * \note Must tollerate the Q.931 screening-indicator field values being present.
146
	 */
146
	 */
147
	unsigned char presentation;
147
	unsigned char presentation;
148
	/*!
148
	/*!
149
	 * \brief Character set the name is using.
149
	 * \brief Character set the name is using.
150
	 * \details
150
	 * \details
151
	 * unknown(0),
151
	 * unknown(0),
152
	 * iso8859-1(1),
152
	 * iso8859-1(1),
153
	 * enum-value-withdrawn-by-ITU-T(2)
153
	 * enum-value-withdrawn-by-ITU-T(2)
154
	 * iso8859-2(3),
154
	 * iso8859-2(3),
155
	 * iso8859-3(4),
155
	 * iso8859-3(4),
156
	 * iso8859-4(5),
156
	 * iso8859-4(5),
157
	 * iso8859-5(6),
157
	 * iso8859-5(6),
158
	 * iso8859-7(7),
158
	 * iso8859-7(7),
159
	 * iso10646-BmpString(8),
159
	 * iso10646-BmpString(8),
160
	 * iso10646-utf-8String(9)
160
	 * iso10646-utf-8String(9)
161
	 */
161
	 */
162
	unsigned char char_set;
162
	unsigned char char_set;
163
	/*! \brief Name data with null terminator. */
163
	/*! \brief Name data with null terminator. */
164
	char str[PRI_MAX_NAME_LEN];
164
	char str[PRI_MAX_NAME_LEN];
165
};
165
};
166

    
   
166

   
167
/*! \brief Maximum phone number (address) length plus null terminator */
167
/*! \brief Maximum phone number (address) length plus null terminator */
168
#define PRI_MAX_NUMBER_LEN		(31 + 1)
168
#define PRI_MAX_NUMBER_LEN		(31 + 1)
169

    
   
169

   
170
struct q931_party_number {
170
struct q931_party_number {
171
	/*! \brief TRUE if number data is valid */
171
	/*! \brief TRUE if number data is valid */
172
	unsigned char valid;
172
	unsigned char valid;
173
	/*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
173
	/*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
174
	unsigned char presentation;
174
	unsigned char presentation;
175
	/*! \brief Q.931 Type-Of-Number and numbering-plan encoded fields */
175
	/*! \brief Q.931 Type-Of-Number and numbering-plan encoded fields */
176
	unsigned char plan;
176
	unsigned char plan;
177
	/*! \brief Number data with terminator. */
177
	/*! \brief Number data with terminator. */
178
	char str[PRI_MAX_NUMBER_LEN];
178
	char str[PRI_MAX_NUMBER_LEN];
179
};
179
};
180

    
   
180

   
181
/*! \brief Maximum subaddress length plus null terminator */
181
/*! \brief Maximum subaddress length plus null terminator */
182
#define PRI_MAX_SUBADDRESS_LEN	(20 + 1)
182
#define PRI_MAX_SUBADDRESS_LEN	(20 + 1)
183

    
   
183

   
184
struct q931_party_subaddress {
184
struct q931_party_subaddress {
185
	/*! \brief TRUE if the subaddress information is valid/present */
185
	/*! \brief TRUE if the subaddress information is valid/present */
186
	unsigned char valid;
186
	unsigned char valid;
187
	/*!
187
	/*!
188
	 * \brief Subaddress type.
188
	 * \brief Subaddress type.
189
	 * \details
189
	 * \details
190
	 * nsap(0),
190
	 * nsap(0),
191
	 * user_specified(2)
191
	 * user_specified(2)
192
	 */
192
	 */
193
	unsigned char type;
193
	unsigned char type;
194
	/*!
194
	/*!
195
	 * \brief TRUE if odd number of address signals
195
	 * \brief TRUE if odd number of address signals
196
	 * \note The odd/even indicator is used when the type of subaddress is
196
	 * \note The odd/even indicator is used when the type of subaddress is
197
	 * user_specified and the coding is BCD.
197
	 * user_specified and the coding is BCD.
198
	 */
198
	 */
199
	unsigned char odd_even_indicator;
199
	unsigned char odd_even_indicator;
200
	/*! \brief Length of the subaddress data */
200
	/*! \brief Length of the subaddress data */
201
	unsigned char length;
201
	unsigned char length;
202
	/*!
202
	/*!
203
	 * \brief Subaddress data with null terminator.
203
	 * \brief Subaddress data with null terminator.
204
	 * \note The null terminator is a convenience only since the data could be
204
	 * \note The null terminator is a convenience only since the data could be
205
	 * BCD/binary and thus have a null byte as part of the contents.
205
	 * BCD/binary and thus have a null byte as part of the contents.
206
	 */
206
	 */
207
	char data[PRI_MAX_SUBADDRESS_LEN];
207
	unsigned char data[PRI_MAX_SUBADDRESS_LEN];
208
};
208
};
209

    
   
209

   
210
struct q931_party_address {
210
struct q931_party_address {
211
	/*! \brief Subscriber phone number */
211
	/*! \brief Subscriber phone number */
212
	struct q931_party_number number;
212
	struct q931_party_number number;
213
	/*! \brief Subscriber subaddress */
213
	/*! \brief Subscriber subaddress */
214
	struct q931_party_subaddress subaddress;
214
	struct q931_party_subaddress subaddress;
215
};
215
};
216

    
   
216

   
217
/*! \brief Information needed to identify an endpoint in a call. */
217
/*! \brief Information needed to identify an endpoint in a call. */
218
struct q931_party_id {
218
struct q931_party_id {
219
	/*! \brief Subscriber name */
219
	/*! \brief Subscriber name */
220
	struct q931_party_name name;
220
	struct q931_party_name name;
221
	/*! \brief Subscriber phone number */
221
	/*! \brief Subscriber phone number */
222
	struct q931_party_number number;
222
	struct q931_party_number number;
223
	/*! \brief Subscriber subaddress */
223
	/*! \brief Subscriber subaddress */
224
	struct q931_party_subaddress subaddress;
224
	struct q931_party_subaddress subaddress;
225
};
225
};
226

    
   
226

   
227
enum Q931_REDIRECTING_STATE {
227
enum Q931_REDIRECTING_STATE {
228
	/*!
228
	/*!
229
	 * \details
229
	 * \details
230
	 * CDO-Idle/CDF-Inv-Idle
230
	 * CDO-Idle/CDF-Inv-Idle
231
	 */
231
	 */
232
	Q931_REDIRECTING_STATE_IDLE,
232
	Q931_REDIRECTING_STATE_IDLE,
233
	/*!
233
	/*!
234
	 * \details
234
	 * \details
235
	 * CDF-Inv-Wait - A DivLeg2 has been received and
235
	 * CDF-Inv-Wait - A DivLeg2 has been received and
236
	 * we are waiting for valid presentation restriction information to send.
236
	 * we are waiting for valid presentation restriction information to send.
237
	 */
237
	 */
238
	Q931_REDIRECTING_STATE_PENDING_TX_DIV_LEG_3,
238
	Q931_REDIRECTING_STATE_PENDING_TX_DIV_LEG_3,
239
	/*!
239
	/*!
240
	 * \details
240
	 * \details
241
	 * CDO-Divert - A DivLeg1 has been received and
241
	 * CDO-Divert - A DivLeg1 has been received and
242
	 * we are waiting for the presentation restriction information to come in.
242
	 * we are waiting for the presentation restriction information to come in.
243
	 */
243
	 */
244
	Q931_REDIRECTING_STATE_EXPECTING_RX_DIV_LEG_3,
244
	Q931_REDIRECTING_STATE_EXPECTING_RX_DIV_LEG_3,
245
};
245
};
246

    
   
246

   
247
/*!
247
/*!
248
 * \brief Do not increment above this count.
248
 * \brief Do not increment above this count.
249
 * \details
249
 * \details
250
 * It is not our responsibility to enforce the maximum number of redirects.
250
 * It is not our responsibility to enforce the maximum number of redirects.
251
 * However, we cannot allow an increment past this number without breaking things.
251
 * However, we cannot allow an increment past this number without breaking things.
252
 * Besides, more than 255 redirects is probably not a good thing.
252
 * Besides, more than 255 redirects is probably not a good thing.
253
 */
253
 */
254
#define PRI_MAX_REDIRECTS	0xFF
254
#define PRI_MAX_REDIRECTS	0xFF
255

    
   
255

   
256
/*! \brief Redirecting information struct */
256
/*! \brief Redirecting information struct */
257
struct q931_party_redirecting {
257
struct q931_party_redirecting {
258
	enum Q931_REDIRECTING_STATE state;
258
	enum Q931_REDIRECTING_STATE state;
259
	/*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
259
	/*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
260
	struct q931_party_id from;
260
	struct q931_party_id from;
261
	/*! \brief Call is redirecting to a new party (Sent to the caller) */
261
	/*! \brief Call is redirecting to a new party (Sent to the caller) */
262
	struct q931_party_id to;
262
	struct q931_party_id to;
263
	/*! Originally called party (in cases of multiple redirects) */
263
	/*! Originally called party (in cases of multiple redirects) */
264
	struct q931_party_id orig_called;
264
	struct q931_party_id orig_called;
265
	/*!
265
	/*!
266
	 * \brief Number of times the call was redirected
266
	 * \brief Number of times the call was redirected
267
	 * \note The call is being redirected if the count is non-zero.
267
	 * \note The call is being redirected if the count is non-zero.
268
	 */
268
	 */
269
	unsigned char count;
269
	unsigned char count;
270
	/*! Original reason for redirect (in cases of multiple redirects) */
270
	/*! Original reason for redirect (in cases of multiple redirects) */
271
	unsigned char orig_reason;
271
	unsigned char orig_reason;
272
	/*! \brief Redirection reasons */
272
	/*! \brief Redirection reasons */
273
	unsigned char reason;
273
	unsigned char reason;
274
};
274
};
275

    
   
275

   
276
/*! \brief New call setup parameter structure */
276
/*! \brief New call setup parameter structure */
277
struct pri_sr {
277
struct pri_sr {
278
	int transmode;
278
	int transmode;
279
	int channel;
279
	int channel;
280
	int exclusive;
280
	int exclusive;
281
	int nonisdn;
281
	int nonisdn;
282
	struct q931_party_redirecting redirecting;
282
	struct q931_party_redirecting redirecting;
283
	struct q931_party_id caller;
283
	struct q931_party_id caller;
284
	struct q931_party_address called;
284
	struct q931_party_address called;
285
	int userl1;
285
	int userl1;
286
	int numcomplete;
286
	int numcomplete;
287
	int cis_call;
287
	int cis_call;
288
	int cis_auto_disconnect;
288
	int cis_auto_disconnect;
289
	const char *useruserinfo;
289
	const char *useruserinfo;
290
	int transferable;
290
	int transferable;
291
	int reversecharge;
291
	int reversecharge;
292
};
292
};
293

    
   
293

   
294
/* Internal switch types */
294
/* Internal switch types */
295
#define PRI_SWITCH_GR303_EOC_PATH	19
295
#define PRI_SWITCH_GR303_EOC_PATH	19
296
#define PRI_SWITCH_GR303_TMC_SWITCHING	20
296
#define PRI_SWITCH_GR303_TMC_SWITCHING	20
297

    
   
297

   
298
struct apdu_event {
298
struct apdu_event {
299
	int message;			/* What message to send the ADPU in */
299
	int message;			/* What message to send the ADPU in */
300
	void (*callback)(void *data);	/* Callback function for when response is received */
300
	void (*callback)(void *data);	/* Callback function for when response is received */
301
	void *data;			/* Data to callback */
301
	void *data;			/* Data to callback */
302
	unsigned char apdu[255];			/* ADPU to send */
302
	unsigned char apdu[255];			/* ADPU to send */
303
	int apdu_len; 			/* Length of ADPU */
303
	int apdu_len; 			/* Length of ADPU */
304
	int sent;  			/* Have we been sent already? */
304
	int sent;  			/* Have we been sent already? */
305
	struct apdu_event *next;	/* Linked list pointer */
305
	struct apdu_event *next;	/* Linked list pointer */
306
};
306
};
307

    
   
307

   
308
/*! \brief Incoming call transfer states. */
308
/*! \brief Incoming call transfer states. */
309
enum INCOMING_CT_STATE {
309
enum INCOMING_CT_STATE {
310
	/*!
310
	/*!
311
	 * \details
311
	 * \details
312
	 * Incoming call transfer is not active.
312
	 * Incoming call transfer is not active.
313
	 */
313
	 */
314
	INCOMING_CT_STATE_IDLE,
314
	INCOMING_CT_STATE_IDLE,
315
	/*!
315
	/*!
316
	 * \details
316
	 * \details
317
	 * We have seen an incoming CallTransferComplete(alerting)
317
	 * We have seen an incoming CallTransferComplete(alerting)
318
	 * so we are waiting for the expected CallTransferActive
318
	 * so we are waiting for the expected CallTransferActive
319
	 * before updating the connected line about the remote party id.
319
	 * before updating the connected line about the remote party id.
320
	 */
320
	 */
321
	INCOMING_CT_STATE_EXPECT_CT_ACTIVE,
321
	INCOMING_CT_STATE_EXPECT_CT_ACTIVE,
322
	/*!
322
	/*!
323
	 * \details
323
	 * \details
324
	 * A call transfer message came in that updated the remote party id
324
	 * A call transfer message came in that updated the remote party id
325
	 * that we need to post a connected line update.
325
	 * that we need to post a connected line update.
326
	 */
326
	 */
327
	INCOMING_CT_STATE_POST_CONNECTED_LINE
327
	INCOMING_CT_STATE_POST_CONNECTED_LINE
328
};
328
};
329

    
   
329

   
330
/* q931_call datastructure */
330
/* q931_call datastructure */
331
struct q931_call {
331
struct q931_call {
332
	struct pri *pri;	/* PRI */
332
	struct pri *pri;	/* PRI */
333
	int cr;				/* Call Reference */
333
	int cr;				/* Call Reference */
334
	q931_call *next;
334
	q931_call *next;
335
	/* Slotmap specified (bitmap of channels 31/24-1) (Channel Identifier IE) (-1 means not specified) */
335
	/* Slotmap specified (bitmap of channels 31/24-1) (Channel Identifier IE) (-1 means not specified) */
336
	int slotmap;
336
	int slotmap;
337
	/* An explicit channel (Channel Identifier IE) (-1 means not specified) */
337
	/* An explicit channel (Channel Identifier IE) (-1 means not specified) */
338
	int channelno;
338
	int channelno;
339
	/* An explicit DS1 (-1 means not specified) */
339
	/* An explicit DS1 (-1 means not specified) */
340
	int ds1no;
340
	int ds1no;
341
	/* Whether or not the ds1 is explicitly identified or implicit.  If implicit
341
	/* Whether or not the ds1 is explicitly identified or implicit.  If implicit
342
	   the bchan is on the same span as the current active dchan (NFAS) */
342
	   the bchan is on the same span as the current active dchan (NFAS) */
343
	int ds1explicit;
343
	int ds1explicit;
344
	/* Channel flags (0 means none retrieved) */
344
	/* Channel flags (0 means none retrieved) */
345
	int chanflags;
345
	int chanflags;
346
	
346
	
347
	int alive;			/* Whether or not the call is alive */
347
	int alive;			/* Whether or not the call is alive */
348
	int acked;			/* Whether setup has been acked or not */
348
	int acked;			/* Whether setup has been acked or not */
349
	int sendhangupack;	/* Whether or not to send a hangup ack */
349
	int sendhangupack;	/* Whether or not to send a hangup ack */
350
	int proc;			/* Whether we've sent a call proceeding / alerting */
350
	int proc;			/* Whether we've sent a call proceeding / alerting */
351
	
351
	
352
	int ri;				/* Restart Indicator (Restart Indicator IE) */
352
	int ri;				/* Restart Indicator (Restart Indicator IE) */
353

    
   
353

   
354
	/* Bearer Capability */
354
	/* Bearer Capability */
355
	int transcapability;
355
	int transcapability;
356
	int transmoderate;
356
	int transmoderate;
357
	int transmultiple;
357
	int transmultiple;
358
	int userl1;
358
	int userl1;
359
	int userl2;
359
	int userl2;
360
	int userl3;
360
	int userl3;
361
	int rateadaption;
361
	int rateadaption;
362

    
   
362

   
363
	/*!
363
	/*!
364
	 * \brief TRUE if the call is a Call Independent Signalling connection.
364
	 * \brief TRUE if the call is a Call Independent Signalling connection.
365
	 * \note The call has no B channel associated with it. (Just signalling)
365
	 * \note The call has no B channel associated with it. (Just signalling)
366
	 */
366
	 */
367
	int cis_call;
367
	int cis_call;
368
	/*! \brief TRUE if we will auto disconnect the cis_call we originated. */
368
	/*! \brief TRUE if we will auto disconnect the cis_call we originated. */
369
	int cis_auto_disconnect;
369
	int cis_auto_disconnect;
370

    
   
370

   
371
	int progcode;			/* Progress coding */
371
	int progcode;			/* Progress coding */
372
	int progloc;			/* Progress Location */	
372
	int progloc;			/* Progress Location */	
373
	int progress;			/* Progress indicator */
373
	int progress;			/* Progress indicator */
374
	int progressmask;		/* Progress Indicator bitmask */
374
	int progressmask;		/* Progress Indicator bitmask */
375
	
375
	
376
	int notify;				/* Notification indicator. */
376
	int notify;				/* Notification indicator. */
377
	
377
	
378
	int causecode;			/* Cause Coding */
378
	int causecode;			/* Cause Coding */
379
	int causeloc;			/* Cause Location */
379
	int causeloc;			/* Cause Location */
380
	int cause;				/* Cause of clearing */
380
	int cause;				/* Cause of clearing */
381
	
381
	
382
	enum Q931_CALL_STATE peercallstate;	/* Call state of peer as reported */
382
	enum Q931_CALL_STATE peercallstate;	/* Call state of peer as reported */
383
	enum Q931_CALL_STATE ourcallstate;	/* Our call state */
383
	enum Q931_CALL_STATE ourcallstate;	/* Our call state */
384
	enum Q931_CALL_STATE sugcallstate;	/* Status call state */
384
	enum Q931_CALL_STATE sugcallstate;	/* Status call state */
385

    
   
385

   
386
	int ani2;               /* ANI II */
386
	int ani2;               /* ANI II */
387

    
   
387

   
388
	/*! Buffer for digits that come in KEYPAD_FACILITY */
388
	/*! Buffer for digits that come in KEYPAD_FACILITY */
389
	char keypad_digits[32 + 1];
389
	char keypad_digits[32 + 1];
390

    
   
390

   
391
	/*! Current dialed digits to be sent or just received. */
391
	/*! Current dialed digits to be sent or just received. */
392
	char overlap_digits[PRI_MAX_NUMBER_LEN];
392
	char overlap_digits[PRI_MAX_NUMBER_LEN];
393

    
   
393

   
394
	/*!
394
	/*!
395
	 * \brief Local party ID
395
	 * \brief Local party ID
396
	 * \details
396
	 * \details
397
	 * The Caller-ID and connected-line ID are just roles the local and remote party
397
	 * The Caller-ID and connected-line ID are just roles the local and remote party
398
	 * play while a call is being established.  Which roll depends upon the direction
398
	 * play while a call is being established.  Which roll depends upon the direction
399
	 * of the call.
399
	 * of the call.
400
	 * Outgoing party info is to identify the local party to the other end.
400
	 * Outgoing party info is to identify the local party to the other end.
401
	 *    (Caller-ID for originated or connected-line for answered calls.)
401
	 *    (Caller-ID for originated or connected-line for answered calls.)
402
	 * Incoming party info is to identify the remote party to us.
402
	 * Incoming party info is to identify the remote party to us.
403
	 *    (Caller-ID for answered or connected-line for originated calls.)
403
	 *    (Caller-ID for answered or connected-line for originated calls.)
404
	 */
404
	 */
405
	struct q931_party_id local_id;
405
	struct q931_party_id local_id;
406
	/*!
406
	/*!
407
	 * \brief Remote party ID
407
	 * \brief Remote party ID
408
	 * \details
408
	 * \details
409
	 * The Caller-ID and connected-line ID are just roles the local and remote party
409
	 * The Caller-ID and connected-line ID are just roles the local and remote party
410
	 * play while a call is being established.  Which roll depends upon the direction
410
	 * play while a call is being established.  Which roll depends upon the direction
411
	 * of the call.
411
	 * of the call.
412
	 * Outgoing party info is to identify the local party to the other end.
412
	 * Outgoing party info is to identify the local party to the other end.
413
	 *    (Caller-ID for originated or connected-line for answered calls.)
413
	 *    (Caller-ID for originated or connected-line for answered calls.)
414
	 * Incoming party info is to identify the remote party to us.
414
	 * Incoming party info is to identify the remote party to us.
415
	 *    (Caller-ID for answered or connected-line for originated calls.)
415
	 *    (Caller-ID for answered or connected-line for originated calls.)
416
	 */
416
	 */
417
	struct q931_party_id remote_id;
417
	struct q931_party_id remote_id;
418

    
   
418

   
419
	/*!
419
	/*!
420
	 * \brief Staging place for the Q.931 redirection number ie.
420
	 * \brief Staging place for the Q.931 redirection number ie.
421
	 * \note
421
	 * \note
422
	 * The number could be the remote_id.number or redirecting.to.number
422
	 * The number could be the remote_id.number or redirecting.to.number
423
	 * depending upon the notification indicator.
423
	 * depending upon the notification indicator.
424
	 */
424
	 */
425
	struct q931_party_number redirection_number;
425
	struct q931_party_number redirection_number;
426

    
   
426

   
427
	/*!
427
	/*!
428
	 * \brief Called party address.
428
	 * \brief Called party address.
429
	 * \note The called.number.str is the accumulated overlap dial digits
429
	 * \note The called.number.str is the accumulated overlap dial digits
430
	 * and enbloc digits.
430
	 * and enbloc digits.
431
	 * \note The called.number.presentation value is not used.
431
	 * \note The called.number.presentation value is not used.
432
	 */
432
	 */
433
	struct q931_party_address called;
433
	struct q931_party_address called;
434
	int nonisdn;
434
	int nonisdn;
435
	int complete;			/* no more digits coming */
435
	int complete;			/* no more digits coming */
436
	int newcall;			/* if the received message has a new call reference value */
436
	int newcall;			/* if the received message has a new call reference value */
437

    
   
437

   
438
	int retranstimer;		/* Timer for retransmitting DISC */
438
	int retranstimer;		/* Timer for retransmitting DISC */
439
	int t308_timedout;		/* Whether t308 timed out once */
439
	int t308_timedout;		/* Whether t308 timed out once */
440

    
   
440

   
441
	struct q931_party_redirecting redirecting;
441
	struct q931_party_redirecting redirecting;
442

    
   
442

   
443
	/*! \brief Incoming call transfer state. */
443
	/*! \brief Incoming call transfer state. */
444
	enum INCOMING_CT_STATE incoming_ct_state;
444
	enum INCOMING_CT_STATE incoming_ct_state;
445

    
   
445

   
446
	int useruserprotocoldisc;
446
	int useruserprotocoldisc;
447
	char useruserinfo[256];
447
	char useruserinfo[256];
448
	char callingsubaddr[PRI_MAX_SUBADDRESS_LEN];	/* Calling party subaddress */
448
	char callingsubaddr[PRI_MAX_SUBADDRESS_LEN];	/* Calling party subaddress */
449
	
449
	
450
	long aoc_units;				/* Advice of Charge Units */
450
	long aoc_units;				/* Advice of Charge Units */
451

    
   
451

   
452
	struct apdu_event *apdus;	/* APDU queue for call */
452
	struct apdu_event *apdus;	/* APDU queue for call */
453

    
   
453

   
454
	int transferable;			/* RLT call is transferable */
454
	int transferable;			/* RLT call is transferable */
455
	unsigned int rlt_call_id;	/* RLT call id */
455
	unsigned int rlt_call_id;	/* RLT call id */
456

    
   
456

   
457
	/* Bridged call info */
457
	/* Bridged call info */
458
	q931_call *bridged_call;        /* Pointer to other leg of bridged call (Used by Q.SIG when eliminating tromboned calls) */
458
	q931_call *bridged_call;        /* Pointer to other leg of bridged call (Used by Q.SIG when eliminating tromboned calls) */
459

    
   
459

   
460
	int changestatus;		/* SERVICE message changestatus */
460
	int changestatus;		/* SERVICE message changestatus */
461
	int reversecharge;		/* Reverse charging indication:
461
	int reversecharge;		/* Reverse charging indication:
462
							   -1 - No reverse charging
462
							   -1 - No reverse charging
463
							    1 - Reverse charging
463
							    1 - Reverse charging
464
							0,2-7 - Reserved for future use */
464
							0,2-7 - Reserved for future use */
465
};
465
};
466

    
   
466

   
467
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
467
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
468

    
   
468

   
469
extern pri_event *pri_schedule_run(struct pri *pri);
469
extern pri_event *pri_schedule_run(struct pri *pri);
470

    
   
470

   
471
extern void pri_schedule_del(struct pri *pri, int ev);
471
extern void pri_schedule_del(struct pri *pri, int ev);
472

    
   
472

   
473
extern pri_event *pri_mkerror(struct pri *pri, char *errstr);
473
extern pri_event *pri_mkerror(struct pri *pri, char *errstr);
474

    
   
474

   
475
void pri_message(struct pri *ctrl, char *fmt, ...) __attribute__((format(printf, 2, 3)));
475
void pri_message(struct pri *ctrl, char *fmt, ...) __attribute__((format(printf, 2, 3)));
476
void pri_error(struct pri *ctrl, char *fmt, ...) __attribute__((format(printf, 2, 3)));
476
void pri_error(struct pri *ctrl, char *fmt, ...) __attribute__((format(printf, 2, 3)));
477

    
   
477

   
478
void libpri_copy_string(char *dst, const char *src, size_t size);
478
void libpri_copy_string(char *dst, const char *src, size_t size);
479

    
   
479

   
480
struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata, int tei, int bri);
480
struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata, int tei, int bri);
481

    
   
481

   
482
void __pri_free_tei(struct pri *p);
482
void __pri_free_tei(struct pri *p);
483

    
   
483

   
484
void q931_party_name_init(struct q931_party_name *name);
484
void q931_party_name_init(struct q931_party_name *name);
485
void q931_party_number_init(struct q931_party_number *number);
485
void q931_party_number_init(struct q931_party_number *number);
486
void q931_party_subaddress_init(struct q931_party_subaddress *subaddr);
486
void q931_party_subaddress_init(struct q931_party_subaddress *subaddr);
487
void q931_party_address_init(struct q931_party_address *address);
487
void q931_party_address_init(struct q931_party_address *address);
488
void q931_party_id_init(struct q931_party_id *id);
488
void q931_party_id_init(struct q931_party_id *id);
489
void q931_party_redirecting_init(struct q931_party_redirecting *redirecting);
489
void q931_party_redirecting_init(struct q931_party_redirecting *redirecting);
490

    
   
490

   
491
int q931_party_name_cmp(const struct q931_party_name *left, const struct q931_party_name *right);
491
int q931_party_name_cmp(const struct q931_party_name *left, const struct q931_party_name *right);
492
int q931_party_number_cmp(const struct q931_party_number *left, const struct q931_party_number *right);
492
int q931_party_number_cmp(const struct q931_party_number *left, const struct q931_party_number *right);
493
int q931_party_subaddress_cmp(const struct q931_party_subaddress *left, const struct q931_party_subaddress *right);
493
int q931_party_subaddress_cmp(const struct q931_party_subaddress *left, const struct q931_party_subaddress *right);
494
int q931_party_id_cmp(const struct q931_party_id *left, const struct q931_party_id *right);
494
int q931_party_id_cmp(const struct q931_party_id *left, const struct q931_party_id *right);
495

    
   
495

   
496
void q931_party_name_copy_to_pri(struct pri_party_name *pri_name, const struct q931_party_name *q931_name);
496
void q931_party_name_copy_to_pri(struct pri_party_name *pri_name, const struct q931_party_name *q931_name);
497
void q931_party_number_copy_to_pri(struct pri_party_number *pri_number, const struct q931_party_number *q931_number);
497
void q931_party_number_copy_to_pri(struct pri_party_number *pri_number, const struct q931_party_number *q931_number);
498
void q931_party_subaddress_copy_to_pri(struct pri_party_subaddress *pri_subaddress, const struct q931_party_subaddress *q931_subaddress);
498
void q931_party_subaddress_copy_to_pri(struct pri_party_subaddress *pri_subaddress, const struct q931_party_subaddress *q931_subaddress);
499
void q931_party_id_copy_to_pri(struct pri_party_id *pri_id, const struct q931_party_id *q931_id);
499
void q931_party_id_copy_to_pri(struct pri_party_id *pri_id, const struct q931_party_id *q931_id);
500
void q931_party_redirecting_copy_to_pri(struct pri_party_redirecting *pri_redirecting, const struct q931_party_redirecting *q931_redirecting);
500
void q931_party_redirecting_copy_to_pri(struct pri_party_redirecting *pri_redirecting, const struct q931_party_redirecting *q931_redirecting);
501

    
   
501

   
502
void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id);
502
void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id);
503
int q931_party_id_presentation(const struct q931_party_id *id);
503
int q931_party_id_presentation(const struct q931_party_id *id);
504

    
   
504

   
505
const char *q931_call_state_str(enum Q931_CALL_STATE callstate);
505
const char *q931_call_state_str(enum Q931_CALL_STATE callstate);
506

    
   
506

   
507
int q931_is_ptmp(const struct pri *ctrl);
507
int q931_is_ptmp(const struct pri *ctrl);
508
struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl);
508
struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl);
509

    
   
509

   
510
int q931_notify_redirection(struct pri *ctrl, q931_call *call, int notify, const struct q931_party_number *number);
510
int q931_notify_redirection(struct pri *ctrl, q931_call *call, int notify, const struct q931_party_number *number);
511

    
   
511

   
512
#endif
512
#endif
/team/rmudgett/subaddr/q931.c
Diff Revision 6 Diff Revision 7
 
  1. /team/rmudgett/subaddr/pri_internal.h: Loading...
  2. /team/rmudgett/subaddr/q931.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.