*
* \note Contents protected by the iaxsl[] locks
*/
-static AST_LIST_HEAD_NOLOCK(, iax_frame) frame_queue[IAX_MAX_CALLS + 1];
+static AST_LIST_HEAD_NOLOCK(, iax_frame) frame_queue[IAX_MAX_CALLS];
static struct ast_taskprocessor *transmit_processor;
* based on the local call number. The local call number is used as the
* index into the array where the associated pvt structure is stored.
*/
-static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS + 1];
+static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS];
static struct ast_callid *iax_pvt_callid_get(int callno)
{
/* Flag to use with trunk calls, keeping these calls high up. It halves our effective use
but keeps the division between trunked and non-trunked better. */
-#define TRUNK_CALL_START IAX_MAX_CALLS / 2
+#define TRUNK_CALL_START (IAX_MAX_CALLS / 2)
/* Debug routines... */
static struct sockaddr_in debugaddr;
ast_log(LOG_WARNING, "Can't make trunk once a call has started!\n");
return -1;
}
- if (callno & TRUNK_CALL_START) {
+ if (callno >= TRUNK_CALL_START) {
ast_log(LOG_WARNING, "Call %d is already a trunk\n", callno);
return -1;
}
}
/* start at 2, 0 and 1 are reserved */
- for (i = 2; i <= IAX_MAX_CALLS; i++) {
+ for (i = 2; i < IAX_MAX_CALLS; i++) {
struct callno_entry *callno_entry;
if (!(callno_entry = ao2_alloc(sizeof(*callno_entry), NULL))) {
/* Max version of IAX protocol we support */
#define IAX_PROTO_VERSION 2
-/* NOTE: IT IS CRITICAL THAT IAX_MAX_CALLS BE A POWER OF 2. */
+/* NOTE: It is recommended that IAX_MAX_CALLS be a power of 2, but it is not
+ * required. The maximum number of calls supported by the protocol is 32768.
+ *
+ * For LOW_MEMORY, we use 2049 for compatibility with earlier code because
+ * callno 2048 leaked out when the intended callno range was 2 - 2047. */
#if defined(LOW_MEMORY)
-#define IAX_MAX_CALLS 2048
+#define IAX_MAX_CALLS 2049
#else
#define IAX_MAX_CALLS 32768
#endif