From 887913bffcbb6fef78e5c862b4cb0652c421e07e Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Sun, 12 Jun 2005 14:27:26 +0000 Subject: [PATCH] don't allow double ALERT_REQ and cleanup of state values --- chan_capi.c | 14 ++++++++------ chan_capi_pvt.h | 15 +++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/chan_capi.c b/chan_capi.c index 526a71a..0b41758 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -477,7 +477,14 @@ static int capi_alert(struct ast_channel *c) { struct ast_capi_pvt *i = CC_AST_CHANNEL_PVT(c); _cmsg CMSG; - + + if ((i->state != CAPI_STATE_DISCONNECTED) && + (i->state != CAPI_STATE_DID)) { + ast_log(LOG_WARNING, "CAPI attempting ALERT in state %d\n", + i->state); + return -1; + } + ALERT_REQ_HEADER(&CMSG, ast_capi_ApplID, i->MessageNumber, 0); ALERT_REQ_PLCI(&CMSG) = i->PLCI; @@ -954,11 +961,6 @@ struct ast_frame *capi_read(struct ast_channel *c) return NULL; } - if ((i->state == CAPI_STATE_REMOTE_HANGUP)) { - ast_log(LOG_ERROR, "this channel is not connected\n"); - return NULL; - } - if (i->state == CAPI_STATE_ONHOLD) { i->fr.frametype = AST_FRAME_NULL; return &i->fr; diff --git a/chan_capi_pvt.h b/chan_capi_pvt.h index 73994c2..e8efd41 100644 --- a/chan_capi_pvt.h +++ b/chan_capi_pvt.h @@ -86,16 +86,15 @@ static inline void write_capi_word(void *m, unsigned short val) #define CAPI_STATE_DISCONNECTING 4 #define CAPI_STATE_DISCONNECTED 5 -#define CAPI_STATE_REMOTE_HANGUP 6 -#define CAPI_STATE_CONNECTPENDING 7 -#define CAPI_STATE_ONHOLD 8 -#define CAPI_STATE_NETWORKHANGUP 9 -#define CAPI_STATE_ANSWERING 10 -#define CAPI_STATE_PUTTINGONHOLD 11 -#define CAPI_STATE_RETRIEVING 12 +#define CAPI_STATE_CONNECTPENDING 6 +#define CAPI_STATE_ANSWERING 7 +#define CAPI_STATE_DID 8 + +#define CAPI_STATE_PUTTINGONHOLD 10 +#define CAPI_STATE_RETRIEVING 11 +#define CAPI_STATE_ONHOLD 12 -#define CAPI_STATE_DID 13 #define AST_CAPI_B3_DONT 0 #define AST_CAPI_B3_ALWAYS 1