11diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
2- index 4d9512aa8e..eb422d2677 100644
2+ index d96683413c..6d3aa1dc58 100644
33--- a/channels/chan_dahdi.c
44+++ b/channels/chan_dahdi.c
55@@ -68,8 +68,34 @@
@@ -37,31 +37,31 @@ index 4d9512aa8e..eb422d2677 100644
3737 #if defined(HAVE_PRI)
3838 #include "sig_pri.h"
3939 #ifndef PRI_RESTART
40- @@ -6477 ,6 +6503 ,7 @@ static int dahdi_hangup(struct ast_channel *ast)
40+ @@ -6499 ,6 +6525 ,7 @@ static int dahdi_hangup(struct ast_channel *ast)
4141 p->ignoredtmf = 0;
4242
4343 if (idx > -1) {
4444+ if (p->channel != CHAN_PSEUDO) ANALOG_UNREACHABLE(analog_hangup, p->radio || p->oprmode, p, ast); /* Medium confidence. */
4545 /* Real channel, do some fixup */
4646 p->subs[idx].owner = NULL;
4747 p->subs[idx].needanswer = 0;
48- @@ -7539 ,6 +7566 ,7 @@ static int dahdi_ring_phone(struct dahdi_pvt *p)
48+ @@ -7561 ,6 +7588 ,7 @@ static int dahdi_ring_phone(struct dahdi_pvt *p)
4949 return res;
5050 }
5151
5252+ #ifndef SIG_ANALOG_HANDLED
5353 static void *analog_ss_thread(void *data);
5454
5555 /*!
56- @@ -7585 ,6 +7613 ,7 @@ static int attempt_transfer(struct dahdi_pvt *p)
56+ @@ -7607 ,6 +7635 ,7 @@ static int attempt_transfer(struct dahdi_pvt *p)
5757
5858 return res;
5959 }
6060+ #endif /* !defined(SIG_ANALOG_HANDLED) */
6161
6262 static int check_for_conference(struct dahdi_pvt *p)
6363 {
64- @@ -7796 ,12 +7825 ,22 @@ static void handle_alarms(struct dahdi_pvt *p, int alms)
64+ @@ -7818 ,12 +7847 ,22 @@ static void handle_alarms(struct dahdi_pvt *p, int alms)
6565
6666 static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
6767 {
@@ -85,7 +85,7 @@ index 4d9512aa8e..eb422d2677 100644
8585 struct ast_frame *f;
8686
8787 idx = dahdi_get_index(ast, p, 0);
88- @@ -7939 ,6 +7978 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
88+ @@ -7961 ,6 +8000 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
8989 #endif
9090 if (p->inalarm) break;
9191 if ((p->radio || (p->oprmode < 0))) break;
@@ -95,15 +95,15 @@ index 4d9512aa8e..eb422d2677 100644
9595 if (ioctl(p->subs[idx].dfd,DAHDI_DIALING,&x) == -1) {
9696 ast_debug(1, "DAHDI_DIALING ioctl failed on %s: %s\n",ast_channel_name(ast), strerror(errno));
9797 return NULL;
98- @@ -7991 ,6 +8033 ,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
98+ @@ -8013 ,6 +8055 ,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
9999 }
100100 }
101101 }
102102+ #endif /* !defined(SIG_ANALOG_HANDLED) */
103103 break;
104104 case DAHDI_EVENT_ALARM:
105105 switch (p->sig) {
106- @@ -8049 ,6 +8092 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
106+ @@ -8071 ,6 +8114 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
107107 }
108108 break;
109109 }
@@ -113,15 +113,15 @@ index 4d9512aa8e..eb422d2677 100644
113113 switch (p->sig) {
114114 case SIG_FXOLS:
115115 case SIG_FXOGS:
116- @@ -8147 ,6 +8193 ,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
116+ @@ -8169 ,6 +8215 ,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
117117 dahdi_ec_disable(p);
118118 return NULL;
119119 }
120120+ #endif /* !defined(SIG_ANALOG_HANDLED) */
121121 break;
122122 case DAHDI_EVENT_RINGOFFHOOK:
123123 if (p->inalarm) break;
124- @@ -8168 ,6 +8215 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
124+ @@ -8190 ,6 +8237 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
125125 p->subs[idx].f.subclass.integer = AST_CONTROL_RADIO_KEY;
126126 break;
127127 }
@@ -131,15 +131,15 @@ index 4d9512aa8e..eb422d2677 100644
131131 /* for E911, its supposed to wait for offhook then dial
132132 the second half of the dial string */
133133 if (((mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF)) && (ast_channel_state(ast) == AST_STATE_DIALING_OFFHOOK)) {
134- @@ -8322 ,6 +8372 ,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
134+ @@ -8344 ,6 +8394 ,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
135135 default:
136136 ast_log(LOG_WARNING, "Don't know how to handle ring/off hook for signalling %d\n", p->sig);
137137 }
138138+ #endif /* !defined(SIG_ANALOG_HANDLED) */
139139 break;
140140 case DAHDI_EVENT_RINGBEGIN:
141141 switch (p->sig) {
142- @@ -8377 ,6 +8428 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
142+ @@ -8399 ,6 +8450 ,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
143143 }
144144 break;
145145 }
@@ -149,7 +149,7 @@ index 4d9512aa8e..eb422d2677 100644
149149 /* Remember last time we got a flash-hook */
150150 p->flashtime = ast_tvnow();
151151 switch (mysig) {
152- @@ -8607 ,9 +8661 ,12 @@ winkflashdone:
152+ @@ -8629 ,9 +8683 ,12 @@ winkflashdone:
153153 ast_log(LOG_WARNING, "Don't know how to handle ring/off hook for signalling %d\n", p->sig);
154154 }
155155 break;
@@ -162,7 +162,7 @@ index 4d9512aa8e..eb422d2677 100644
162162 if (p->waitingfordt.tv_sec) break;
163163 switch (mysig) {
164164 case SIG_FXSLS: /* only interesting for FXS */
165- @@ -8720 ,6 +8777 ,8 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
165+ @@ -8742 ,6 +8799 ,8 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
166166
167167
168168 if ((!p->owner) && (!(p->radio || (p->oprmode < 0)))) {
@@ -171,7 +171,7 @@ index 4d9512aa8e..eb422d2677 100644
171171 /* If nobody owns us, absorb the event appropriately, otherwise
172172 we loop indefinitely. This occurs when, during call waiting, the
173173 other end hangs up our channel so that it no longer exists, but we
174- @@ -9824 ,7 +9883 ,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
174+ @@ -9846 ,7 +9905 ,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
175175 return tmp;
176176 }
177177
@@ -180,39 +180,39 @@ index 4d9512aa8e..eb422d2677 100644
180180 static int my_getsigstr(struct ast_channel *chan, char *str, const char *term, int ms)
181181 {
182182 char c;
183- @@ -9843 ,6 +9902 ,7 @@ static int my_getsigstr(struct ast_channel *chan, char *str, const char *term, i
183+ @@ -9865 ,6 +9924 ,7 @@ static int my_getsigstr(struct ast_channel *chan, char *str, const char *term, i
184184 return 1;
185185 }
186186 }
187187+ #endif /* !defined(SIG_ANALOG_HANDLED) */
188188
189189 static int dahdi_wink(struct dahdi_pvt *p, int idx)
190190 {
191- @@ -9910 ,6 +9970 ,7 @@ static int dahdi_dnd(struct dahdi_pvt *dahdichan, int flag)
191+ @@ -9932 ,6 +9992 ,7 @@ static int dahdi_dnd(struct dahdi_pvt *dahdichan, int flag)
192192 return 0;
193193 }
194194
195195+ #ifndef SIG_ANALOG_HANDLED
196196 static int canmatch_featurecode(const char *pickupexten, const char *exten)
197197 {
198198 int extlen = strlen(exten);
199- @@ -11130 ,6 +11191 ,7 @@ quit:
199+ @@ -11152 ,6 +11213 ,7 @@ quit:
200200 ast_mutex_unlock(&ss_thread_lock);
201201 return NULL;
202202 }
203203+ #endif /* !defined(SIG_ANALOG_HANDLED) */
204204
205205 struct mwi_thread_data {
206206 struct dahdi_pvt *pvt;
207- @@ -11155 ,7 +11217 ,6 @@ static void *mwi_thread(void *data)
207+ @@ -11177 ,7 +11239 ,6 @@ static void *mwi_thread(void *data)
208208 {
209209 struct mwi_thread_data *mtd = data;
210210 struct callerid_state *cs;
211211- pthread_t threadid;
212212 int samples = 0;
213213 char *name, *number;
214214 int flags;
215- @@ -11227 ,7 +11288 ,12 @@ static void *mwi_thread(void *data)
215+ @@ -11249 ,7 +11310 ,12 @@ static void *mwi_thread(void *data)
216216 if (dahdi_analog_lib_handles(mtd->pvt->sig, mtd->pvt->radio, mtd->pvt->oprmode)) {
217217 result = analog_ss_thread_start(mtd->pvt->sig_pvt, chan);
218218 } else {
@@ -225,7 +225,7 @@ index 4d9512aa8e..eb422d2677 100644
225225 }
226226 if (result) {
227227 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", mtd->pvt->channel);
228- @@ -11646 ,10 +11712 ,12 @@ out:
228+ @@ -11668 ,10 +11734 ,12 @@ out:
229229 static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
230230 {
231231 int res;
@@ -238,7 +238,7 @@ index 4d9512aa8e..eb422d2677 100644
238238
239239 /* Handle an event on a given channel for the monitor thread. */
240240
241- @@ -11661 ,6 +11729 ,8 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
241+ @@ -11683 ,6 +11751 ,8 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
242242 case DAHDI_EVENT_RINGOFFHOOK:
243243 if (i->inalarm) break;
244244 if (i->radio) break;
@@ -247,23 +247,23 @@ index 4d9512aa8e..eb422d2677 100644
247247 /* Got a ring/answer. What kind of channel are we? */
248248 switch (i->sig) {
249249 case SIG_FXOLS:
250- @@ -11760 ,6 +11830 ,7 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
250+ @@ -11782 ,6 +11852 ,7 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
251251 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
252252 return NULL;
253253 }
254254+ #endif /* !defined(SIG_ANALOG_HANDLED) */
255255 break;
256256 case DAHDI_EVENT_NOALARM:
257257 switch (i->sig) {
258- @@ -11805 ,6 +11876 ,7 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
259- case DAHDI_EVENT_ONHOOK :
260- if (i->radio)
261- break;
262- + ANALOG_UNREACHABLE_EVENT(analog_handle_init_event, i->oprmode, i, event);
263- /* Back on hook. Hang up. */
264- switch (i->sig) {
265- case SIG_FXOLS:
266- @@ -11849 ,6 +11921 ,8 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
258+ @@ -11850 ,6 +11921 ,7 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
259+ case SIG_FXSGS :
260+ case SIG_FXSKS:
261+ case SIG_FXOKS:
262+ + ANALOG_UNREACHABLE_EVENT(analog_handle_init_event, i->oprmode, i, event);
263+ dahdi_ec_disable(i);
264+ /* Diddle the battery for the zhone */
265+ #ifdef ZHONE_HACK
266+ @@ -11871 ,6 +11943 ,8 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
267267 }
268268 break;
269269 case DAHDI_EVENT_POLARITY:
@@ -272,15 +272,15 @@ index 4d9512aa8e..eb422d2677 100644
272272 switch (i->sig) {
273273 case SIG_FXSLS:
274274 case SIG_FXSKS:
275- @@ -11880 ,6 +11954 ,7 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
275+ @@ -11902 ,6 +11976 ,7 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
276276 "polarity reversal on non-FXO (SIG_FXS) "
277277 "interface %d\n", i->channel);
278278 }
279279+ #endif /* !defined(SIG_ANALOG_HANDLED) */
280280 break;
281281 case DAHDI_EVENT_REMOVED: /* destroy channel, will actually do so in do_monitor */
282282 ast_log(LOG_NOTICE,
283- @@ -12132 ,14 +12207 ,16 @@ static void *do_monitor(void *data)
283+ @@ -12154 ,14 +12229 ,16 @@ static void *do_monitor(void *data)
284284 } else {
285285 energy = calc_energy((unsigned char *) buf, res, AST_LAW(i));
286286 if (!i->mwisendactive && energy > dtmfcid_level) {
@@ -299,7 +299,7 @@ index 4d9512aa8e..eb422d2677 100644
299299 ast_callid callid = 0;
300300 int callid_created = ast_callid_threadstorage_auto(&callid);
301301 chan = dahdi_new(i, AST_STATE_PRERING, 0, SUB_REAL, 0, NULL, NULL, callid);
302- @@ -12155 ,6 +12232 ,7 @@ static void *do_monitor(void *data)
302+ @@ -12177 ,6 +12254 ,7 @@ static void *do_monitor(void *data)
303303 }
304304 }
305305 ast_callid_threadstorage_auto_clean(callid, callid_created);
@@ -308,7 +308,7 @@ index 4d9512aa8e..eb422d2677 100644
308308 ast_mutex_lock(&iflock);
309309 }
310310diff --git a/channels/sig_analog.c b/channels/sig_analog.c
311- index e477d5d0cf..6914449787 100644
311+ index c21b8cae12..112a09c008 100644
312312--- a/channels/sig_analog.c
313313+++ b/channels/sig_analog.c
314314@@ -2798,7 +2798,13 @@ static void analog_publish_channel_alarm_clear(int channel)
0 commit comments