Index: chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.420 diff -u -r1.420 chan_zap.c --- chan_zap.c 23 Mar 2005 21:12:01 -0000 1.420 +++ chan_zap.c 27 Mar 2005 16:23:27 -0000 @@ -3858,8 +3858,21 @@ (ast->_state == AST_STATE_RINGING))) { ast_log(LOG_DEBUG, "Answering on polarity switch!\n"); ast_setstate(p->owner, AST_STATE_UP); + gettimeofday(&p->polaritydelaytv, NULL); } else - ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state); + //If polarity was IDLE and we are not + //in state DIALING or RINGING, it's a + //remote hungup, at least in Spain + //Added check for FXS signaling, to be + //sure it doesn't break other things + //julianjm@gmail.com + if (p->hanguponpolarityswitch && (p->sig==SIG_FXSLS || p->sig==SIG_FXSGS || p->sig==SIG_FXSKS)) { + ast_log(LOG_DEBUG, "Hangup due to Reverse Polarity on channel %d (julianjm)\n", p->channel); + ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT); + p->polarity = POLARITY_IDLE; + } else { + ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state); + } } else if(p->hanguponpolarityswitch && (p->polarityonanswerdelay > 0) && (p->polarity == POLARITY_REV) &&