2 * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * i4b daemon - message from kernel handling routines
28 * --------------------------------------------------
32 * last edit-date: [Mon Jul 26 13:55:57 1999]
34 *---------------------------------------------------------------------------*/
38 /*---------------------------------------------------------------------------*
39 * handle incoming CONNECT_IND (=SETUP) message
40 *---------------------------------------------------------------------------*/
42 msg_connect_ind(msg_connect_ind_t *mp)
45 char *src_tela = "ERROR-src_tela";
46 char *dst_tela = "ERROR-dst_tela";
48 #define SRC (aliasing == 0 ? mp->src_telno : src_tela)
49 #define DST (aliasing == 0 ? mp->dst_telno : dst_tela)
51 if((cep = find_matching_entry_incoming(mp)) == NULL)
53 /* log message generated in find_matching_entry_incoming() */
54 sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
58 if(cep->cdid != CDID_UNUSED && cep->cdid != CDID_RESERVED)
61 * This is an incoming call on a number we just dialed out.
62 * Stop our dial-out and accept the incoming call.
64 if(cep->saved_call.cdid != CDID_UNUSED &&
65 cep->saved_call.cdid != CDID_RESERVED)
69 /* disconnect old, not new */
72 cep->cdid = cep->saved_call.cdid;
73 sendm_disconnect_req(cep, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
77 * Shortcut the state machine and mark this
80 /* XXX */ cep->state = ST_IDLE; /* this is an invalid */
82 /* so no next_state() */
83 /* we have to wait here for an incoming */
84 /* disconnect message !!! (-hm) */
90 src_tela = get_alias(mp->src_telno);
91 dst_tela = get_alias(mp->dst_telno);
94 if(cep->inout == DIR_OUTONLY)
96 log(LL_CHD, "%05d %s incoming call from %s to %s not allowed by configuration!",
97 mp->header.cdid, cep->name, SRC, DST);
98 sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
103 cep->last_charge = 0;
105 switch(cep->dialin_reaction)
108 log(LL_CHD, "%05d %s accepting: incoming call from %s to %s",
109 mp->header.cdid, cep->name, SRC, DST);
110 decr_free_channels(mp->controller);
111 next_state(cep, EV_MCI);
115 log(LL_CHD, "%05d %s rejecting: incoming call from %s to %s",
116 mp->header.cdid, cep->name, SRC, DST);
117 sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
118 (CAUSET_I4B << 8) | CAUSE_I4B_REJECT);
119 cep->cdid = CDID_UNUSED;
123 log(LL_CHD, "%05d %s ignoring: incoming call from %s to %s",
124 mp->header.cdid, cep->name, SRC, DST);
125 sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
129 decr_free_channels(mp->controller);
134 log(LL_CHD, "%05d %s alerting: incoming call from %s to %s (%s)",
135 mp->header.cdid, cep->name, SRC, DST, mp->display);
139 log(LL_CHD, "%05d %s alerting: incoming call from %s to %s",
140 mp->header.cdid, cep->name, SRC, DST);
142 next_state(cep, EV_ALRT);
148 log(LL_CHD, "%05d %s answering: incoming call from %s to %s (%s)",
149 mp->header.cdid, cep->name, SRC, DST, mp->display);
153 log(LL_CHD, "%05d %s answering: incoming call from %s to %s",
154 mp->header.cdid, cep->name, SRC, DST);
156 next_state(cep, EV_MCI);
162 /*XXX reserve channel ??? */ decr_free_channels(mp->controller);
164 if(cep->cdid == CDID_RESERVED)
166 log(LL_CHD, "%05d %s reserved: incoming call from %s to %s",
167 mp->header.cdid, cep->name, SRC, DST);
168 sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
169 (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
170 /* no state change */
174 log(LL_CHD, "%05d %s callback: incoming call from %s to %s",
175 mp->header.cdid, cep->name, SRC, DST);
176 sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
177 (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
178 cep->last_release_time = time(NULL);
179 cep->cdid = CDID_RESERVED;
180 next_state(cep, EV_CBRQ);
185 log(LL_WRN, "msg_connect_ind: unknown response type, tx SETUP_RESP_DNTCRE");
186 sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
193 /*---------------------------------------------------------------------------*
194 * handle incoming CONNECT_ACTIVE_IND message
195 *---------------------------------------------------------------------------*/
197 msg_connect_active_ind(msg_connect_active_ind_t *mp)
202 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
204 log(LL_WRN, "msg_connect_active_ind: cdid not found!");
208 cep->isdncontrollerused = mp->controller;
209 cep->isdnchannelused = mp->channel;
211 cep->aoc_now = cep->connect_time = time(NULL);
214 cep->aoc_valid = AOC_INVALID;
216 cep->local_disconnect = DISCON_REM;
218 cep->inbytes = INVALID;
219 cep->outbytes = INVALID;
222 device = bdrivername(cep->usrdevicename);
224 /* set the B-channel to active */
226 if((set_channel_busy(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR)
227 log(LL_ERR, "msg_connect_active_ind: set_channel_busy failed!");
229 if(cep->direction == DIR_OUT)
231 log(LL_CHD, "%05d %s outgoing call active (ctl %d, ch %d, %s%d)",
232 cep->cdid, cep->name,
233 cep->isdncontrollerused, cep->isdnchannelused,
234 bdrivername(cep->usrdevicename), cep->usrdeviceunit);
238 log(LL_CHD, "%05d %s incoming call active (ctl %d, ch %d, %s%d)",
239 cep->cdid, cep->name,
240 cep->isdncontrollerused, cep->isdnchannelused,
241 bdrivername(cep->usrdevicename), cep->usrdeviceunit);
246 display_connect(cep);
248 #ifdef I4B_EXTERNAL_MONITOR
249 if(do_monitor && accepted)
250 monitor_evnt_connect(cep);
253 if(isdntime && (mp->datetime[0] != '\0'))
255 log(LL_DMN, "date/time from exchange = %s", mp->datetime);
258 next_state(cep, EV_MCAI);
261 /*---------------------------------------------------------------------------*
262 * handle incoming PROCEEDING_IND message
263 *---------------------------------------------------------------------------*/
265 msg_proceeding_ind(msg_proceeding_ind_t *mp)
269 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
271 log(LL_WRN, "msg_proceeding_ind: cdid not found!");
275 cep->isdncontrollerused = mp->controller;
276 cep->isdnchannelused = mp->channel;
278 /* set the B-channels active */
280 if((set_channel_busy(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR)
281 log(LL_ERR, "msg_proceeding_ind: set_channel_busy failed!");
283 log(LL_CHD, "%05d %s outgoing call proceeding (ctl %d, ch %d)",
284 cep->cdid, cep->name,
285 cep->isdncontrollerused, cep->isdnchannelused);
288 /*---------------------------------------------------------------------------*
289 * handle incoming ALERT_IND message
290 *---------------------------------------------------------------------------*/
292 msg_alert_ind(msg_alert_ind_t *mp)
296 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
298 log(LL_WRN, "msg_alert_ind: cdid not found!");
302 log(LL_CHD, "%05d %s incoming alert", cep->cdid, cep->name);
306 /*---------------------------------------------------------------------------*
307 * handle incoming L12STAT_IND message
308 *---------------------------------------------------------------------------*/
310 msg_l12stat_ind(msg_l12stat_ind_t *ml)
314 display_l12stat(ml->controller, ml->layer, ml->state);
317 DBGL(DL_CNST, (log(LL_DBG, "msg_l12stat_ind: unit %d, layer %d, state %d",
318 ml->controller, ml->layer, ml->state)));
321 /*---------------------------------------------------------------------------*
322 * handle incoming TEIASG_IND message
323 *---------------------------------------------------------------------------*/
325 msg_teiasg_ind(msg_teiasg_ind_t *mt)
329 display_tei(mt->controller, mt->tei);
332 DBGL(DL_CNST, (log(LL_DBG, "msg_teiasg_ind: unit %d, tei = %d",
333 mt->controller, mt->tei)));
336 /*---------------------------------------------------------------------------*
337 * handle incoming L12STAT_IND message
338 *---------------------------------------------------------------------------*/
340 msg_pdeact_ind(msg_pdeact_ind_t *md)
343 int ctrl = md->controller;
349 display_l12stat(ctrl, LAYER_ONE, LAYER_IDLE);
350 display_l12stat(ctrl, LAYER_TWO, LAYER_IDLE);
351 display_tei(ctrl, -1);
355 DBGL(DL_CNST, (log(LL_DBG, "msg_pdeact_ind: unit %d, persistent deactivation", ctrl)));
357 for(i=0; i < nentries; i++)
359 if((cfg_entry_tab[i].cdid != CDID_UNUSED) &&
360 (cfg_entry_tab[i].isdncontrollerused == ctrl))
362 cep = &cfg_entry_tab[i];
364 if(cep->cdid == CDID_RESERVED)
366 cep->cdid = CDID_UNUSED;
370 cep->cdid = CDID_UNUSED;
372 cep->last_release_time = time(NULL);
374 SET_CAUSE_TYPE(cep->disc_cause, CAUSET_I4B);
375 SET_CAUSE_VAL(cep->disc_cause, CAUSE_I4B_L1ERROR);
377 if(cep->direction == DIR_OUT)
379 log(LL_CHD, "%05d %s outgoing call disconnected (local)",
380 cep->cdid, cep->name);
384 log(LL_CHD, "%05d %s incoming call disconnected (local)",
385 cep->cdid, cep->name);
388 log(LL_CHD, "%05d %s cause %s",
389 cep->cdid, cep->name, print_i4b_cause(cep->disc_cause));
392 if(do_fullscreen && (cep->connect_time > 0))
393 display_disconnect(cep);
396 #ifdef I4B_EXTERNAL_MONITOR
397 if(do_monitor && accepted)
398 monitor_evnt_disconnect(cep);
400 if(cep->disconnectprog)
401 exec_connect_prog(cep, cep->disconnectprog, 1);
403 if(cep->connect_time > 0)
405 if(cep->direction == DIR_OUT)
407 log(LL_CHD, "%05d %s charging: %d units, %d seconds",
408 cep->cdid, cep->name, cep->charge,
409 (int)difftime(time(NULL), cep->connect_time));
413 log(LL_CHD, "%05d %s connected %d seconds",
414 cep->cdid, cep->name,
415 (int)difftime(time(NULL), cep->connect_time));
418 if((cep->inbytes != INVALID) && (cep->outbytes != INVALID))
420 if((cep->ioutbytes != cep->outbytes) ||
421 (cep->iinbytes != cep->inbytes))
423 log(LL_CHD, "%05d %s accounting: in %d, out %d (in %d, out %d)",
424 cep->cdid, cep->name,
425 cep->inbytes, cep->outbytes,
426 cep->iinbytes, cep->ioutbytes);
430 log(LL_CHD, "%05d %s accounting: in %d, out %d",
431 cep->cdid, cep->name,
432 cep->inbytes, cep->outbytes);
437 if(useacctfile && (cep->connect_time > 0))
440 char logdatetime[41];
443 con_secs = difftime(time(NULL), cep->connect_time);
445 tp = localtime(&cep->connect_time);
447 strftime(logdatetime,40,I4B_TIME_FORMAT,tp);
449 if(cep->inbytes != INVALID && cep->outbytes != INVALID)
451 fprintf(acctfp, "%s - %s %s %d (%d) (%d/%d)\n",
452 logdatetime, getlogdatetime(),
453 cep->name, cep->charge, con_secs,
454 cep->inbytes, cep->outbytes);
458 fprintf(acctfp, "%s - %s %s %d (%d)\n",
459 logdatetime, getlogdatetime(),
460 cep->name, cep->charge, con_secs);
464 /* set the B-channel inactive */
466 if((set_channel_idle(cep->isdncontrollerused, cep->isdnchannelused)) == ERROR)
467 log(LL_ERR, "msg_pdeact_ind: set_channel_idle failed!");
469 incr_free_channels(cep->isdncontrollerused);
471 cep->connect_time = 0;
476 /*---------------------------------------------------------------------------*
477 * handle incoming NEGCOMP_IND message
478 *---------------------------------------------------------------------------*/
480 msg_negcomplete_ind(msg_negcomplete_ind_t *mp)
484 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
486 log(LL_WRN, "msg_negcomp_ind: cdid not found");
491 exec_connect_prog(cep, cep->connectprog, 0);
494 /*---------------------------------------------------------------------------*
495 * handle incoming IFSTATE_CHANGED indication
496 *---------------------------------------------------------------------------*/
498 msg_ifstatechg_ind(msg_ifstatechg_ind_t *mp)
503 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
505 log(LL_WRN, "msg_negcomp_ind: cdid not found");
509 device = bdrivername(cep->usrdevicename);
510 log(LL_DBG, "%s%d: switched to state %d", device, cep->usrdeviceunit, mp->state);
513 /*---------------------------------------------------------------------------*
514 * handle incoming DISCONNECT_IND message
515 *---------------------------------------------------------------------------*/
517 msg_disconnect_ind(msg_disconnect_ind_t *mp)
521 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
523 log(LL_WRN, "msg_disconnect_ind: cdid not found");
527 /* is this an aborted out-call prematurely called back? */
528 if (cep->saved_call.cdid == mp->header.cdid)
530 DBGL(DL_CNST, (log(LL_DBG, "aborted outcall %05d disconnected",
532 cep->saved_call.cdid = CDID_UNUSED;
534 set_channel_idle(cep->saved_call.controller, cep->saved_call.channel);
536 incr_free_channels(cep->saved_call.controller);
540 cep->last_release_time = time(NULL);
541 cep->disc_cause = mp->cause;
543 if(cep->direction == DIR_OUT)
545 log(LL_CHD, "%05d %s outgoing call disconnected %s",
546 cep->cdid, cep->name,
547 cep->local_disconnect == DISCON_LOC ?
548 "(local)" : "(remote)");
552 log(LL_CHD, "%05d %s incoming call disconnected %s",
553 cep->cdid, cep->name,
554 cep->local_disconnect == DISCON_LOC ?
555 "(local)" : "(remote)");
558 log(LL_CHD, "%05d %s cause %s",
559 cep->cdid, cep->name, print_i4b_cause(mp->cause));
562 if(do_fullscreen && (cep->connect_time > 0))
563 display_disconnect(cep);
566 #ifdef I4B_EXTERNAL_MONITOR
567 if(do_monitor && accepted)
568 monitor_evnt_disconnect(cep);
571 if(cep->disconnectprog)
572 exec_connect_prog(cep, cep->disconnectprog, 1);
574 if(cep->connect_time > 0)
576 if(cep->direction == DIR_OUT)
578 log(LL_CHD, "%05d %s charging: %d units, %d seconds",
579 cep->cdid, cep->name, cep->charge,
580 (int)difftime(time(NULL), cep->connect_time));
584 log(LL_CHD, "%05d %s connected %d seconds",
585 cep->cdid, cep->name,
586 (int)difftime(time(NULL), cep->connect_time));
589 if((cep->inbytes != INVALID) && (cep->outbytes != INVALID))
591 if((cep->ioutbytes != cep->outbytes) ||
592 (cep->iinbytes != cep->inbytes))
594 log(LL_CHD, "%05d %s accounting: in %d, out %d (in %d, out %d)",
595 cep->cdid, cep->name,
596 cep->inbytes, cep->outbytes,
597 cep->iinbytes, cep->ioutbytes);
601 log(LL_CHD, "%05d %s accounting: in %d, out %d",
602 cep->cdid, cep->name,
603 cep->inbytes, cep->outbytes);
608 if(useacctfile && (cep->connect_time > 0))
611 char logdatetime[41];
614 con_secs = difftime(time(NULL), cep->connect_time);
616 tp = localtime(&cep->connect_time);
618 strftime(logdatetime,40,I4B_TIME_FORMAT,tp);
620 if(cep->inbytes != INVALID && cep->outbytes != INVALID)
622 fprintf(acctfp, "%s - %s %s %d (%d) (%d/%d)\n",
623 logdatetime, getlogdatetime(),
624 cep->name, cep->charge, con_secs,
625 cep->inbytes, cep->outbytes);
629 fprintf(acctfp, "%s - %s %s %d (%d)\n",
630 logdatetime, getlogdatetime(),
631 cep->name, cep->charge, con_secs);
635 /* set the B-channel inactive */
637 set_channel_idle(cep->isdncontrollerused, cep->isdnchannelused);
639 incr_free_channels(cep->isdncontrollerused);
641 cep->connect_time = 0;
643 next_state(cep, EV_MDI);
646 /*---------------------------------------------------------------------------*
647 * handle incoming DIALOUT message
648 *---------------------------------------------------------------------------*/
650 msg_dialout(msg_dialout_ind_t *mp)
654 DBGL(DL_DRVR, (log(LL_DBG, "msg_dialout: dial req from %s, unit %d", bdrivername(mp->driver), mp->driver_unit)));
656 if((cep = find_by_device_for_dialout(mp->driver, mp->driver_unit)) == NULL)
658 DBGL(DL_DRVR, (log(LL_DBG, "msg_dialout: config entry reserved or no match")));
662 if(cep->inout == DIR_INONLY)
664 dialresponse(cep, DSTAT_INONLY);
668 if((cep->cdid = get_cdid()) == 0)
670 DBGL(DL_DRVR, (log(LL_DBG, "msg_dialout: get_cdid() returned 0!")));
675 cep->last_charge = 0;
677 next_state(cep, EV_MDO);
680 /*---------------------------------------------------------------------------*
681 * handle incoming DIALOUTNUMBER message
682 *---------------------------------------------------------------------------*/
684 msg_dialoutnumber(msg_dialoutnumber_ind_t *mp)
688 DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: dial req from %s, unit %d", bdrivername(mp->driver), mp->driver_unit)));
690 if((cep = find_by_device_for_dialoutnumber(mp->driver, mp->driver_unit, mp->cmdlen, mp->cmd)) == NULL)
692 DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: config entry reserved or no match")));
696 if(cep->inout == DIR_INONLY)
698 dialresponse(cep, DSTAT_INONLY);
702 if((cep->cdid = get_cdid()) == 0)
704 DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: get_cdid() returned 0!")));
709 cep->last_charge = 0;
711 next_state(cep, EV_MDO);
714 /*---------------------------------------------------------------------------*
715 * handle incoming DRVRDISC_REQ message
716 *---------------------------------------------------------------------------*/
718 msg_drvrdisc_req(msg_drvrdisc_req_t *mp)
722 DBGL(DL_DRVR, (log(LL_DBG, "msg_drvrdisc_req: req from %s, unit %d", bdrivername(mp->driver), mp->driver_unit)));
724 if((cep = get_cep_by_driver(mp->driver, mp->driver_unit)) == NULL)
726 DBGL(DL_DRVR, (log(LL_DBG, "msg_drvrdisc_req: config entry not found")));
729 next_state(cep, EV_DRQ);
732 /*---------------------------------------------------------------------------*
733 * handle incoming ACCOUNTING message
734 *---------------------------------------------------------------------------*/
736 msg_accounting(msg_accounting_ind_t *mp)
740 if((cep = find_active_entry_by_driver(mp->driver, mp->driver_unit)) == NULL)
742 log(LL_WRN, "msg_accounting: no config entry found!");
746 cep->inbytes = mp->inbytes;
747 cep->iinbytes = mp->iinbytes;
748 cep->outbytes = mp->outbytes;
749 cep->ioutbytes = mp->ioutbytes;
750 cep->inbps = mp->inbps;
751 cep->outbps = mp->outbps;
753 if(mp->accttype == ACCT_DURING)
761 DBGL(DL_DRVR, (log(LL_DBG, "msg_accounting: %s%d, ioutb=%d, iinb=%d, outb=%d, inb=%d, outbps=%d, inbps=%d",
762 bdrivername(mp->driver), mp->driver_unit,
763 mp->ioutbytes, mp->iinbytes,
764 mp->outbytes, mp->inbytes,
765 mp->outbps, mp->inbps)));
770 /*---------------------------------------------------------------------------*
771 * handle incoming CHARGING message
772 *---------------------------------------------------------------------------*/
774 msg_charging_ind(msg_charging_ind_t *mp)
776 static char *cttab[] = {
784 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
786 log(LL_WRN, "msg_charging_ind: cdid not found");
790 if(mp->units_type < CHARGE_INVALID || mp->units_type > CHARGE_CALC)
792 log(LL_ERR, "msg_charging: units_type %d out of range!", mp->units_type);
796 DBGL(DL_DRVR, (log(LL_DBG, "msg_charging: %d unit(s) (%s)",
797 mp->units, cttab[mp->units_type])));
799 switch(mp->units_type)
802 cep->charge = mp->units;
804 if((cep->unitlengthsrc == ULSRC_DYN) &&
805 (cep->charge != cep->last_charge))
807 cep->last_charge = cep->charge;
813 cep->charge = mp->units;
817 cep->charge = mp->units;
820 display_ccharge(cep, mp->units);
822 #ifdef I4B_EXTERNAL_MONITOR
823 if(do_monitor && accepted)
824 monitor_evnt_charge(cep, mp->units, 1);
830 /*---------------------------------------------------------------------------*
831 * handle incoming IDLE_TIMEOUT_IND message
832 *---------------------------------------------------------------------------*/
834 msg_idle_timeout_ind(msg_idle_timeout_ind_t *mp)
838 if((cep = get_cep_by_cdid(mp->header.cdid)) == NULL)
840 log(LL_WRN, "msg_idle_timeout_ind: cdid not found!");
844 cep->local_disconnect = DISCON_LOC;
846 DBGL(DL_DRVR, (log(LL_DBG, "msg_idle_timeout_ind: idletimeout, kernel sent disconnect!")));
851 /*---------------------------------------------------------------------------*
852 * get a cdid from kernel
853 *---------------------------------------------------------------------------*/
861 if((ioctl(isdnfd, I4B_CDID_REQ, &mcr)) < 0)
863 log(LL_ERR, "get_cdid: ioctl I4B_CDID_REQ failed: %s", strerror(errno));
870 /*---------------------------------------------------------------------------*
871 * send message "connect request" to kernel
872 *---------------------------------------------------------------------------*/
874 sendm_connect_req(cfg_entry_t *cep)
876 msg_connect_req_t mcr;
879 cep->local_disconnect = DISCON_REM;
881 cep->unitlength = get_current_rate(cep, 1);
883 mcr.cdid = cep->cdid;
885 mcr.controller = cep->isdncontrollerused;
886 mcr.channel = cep->isdnchannelused;
887 mcr.txdelay = cep->isdntxdelout;
889 mcr.bprot = cep->b1protocol;
891 mcr.driver = cep->usrdevicename;
892 mcr.driver_unit = cep->usrdeviceunit;
894 /* setup the shorthold data */
895 mcr.shorthold_data.shorthold_algorithm = cep->shorthold_algorithm;
896 mcr.shorthold_data.unitlen_time = cep->unitlength;
897 mcr.shorthold_data.idle_time = cep->idle_time_out;
898 mcr.shorthold_data.earlyhup_time = cep->earlyhangup;
900 if(cep->unitlengthsrc == ULSRC_DYN)
901 mcr.unitlen_method = ULEN_METHOD_DYNAMIC;
903 mcr.unitlen_method = ULEN_METHOD_STATIC;
905 strcpy(mcr.dst_telno, cep->remote_phone_dialout);
906 strcpy(mcr.src_telno, cep->local_phone_dialout);
908 cep->last_dial_time = time(NULL);
909 cep->direction = DIR_OUT;
911 DBGL(DL_CNST, (log(LL_DBG, "sendm_connect_req: ctrl = %d, chan = %d", cep->isdncontrollerused, cep->isdnchannelused)));
913 if((ret = ioctl(isdnfd, I4B_CONNECT_REQ, &mcr)) < 0)
915 log(LL_ERR, "sendm_connect_req: ioctl I4B_CONNECT_REQ failed: %s", strerror(errno));
919 decr_free_channels(cep->isdncontrollerused);
921 log(LL_CHD, "%05d %s dialing out from %s to %s",
924 aliasing ? get_alias(cep->local_phone_dialout) : cep->local_phone_dialout,
925 aliasing ? get_alias(cep->remote_phone_dialout) : cep->remote_phone_dialout);
930 /*---------------------------------------------------------------------------*
931 * send message "connect response" to kernel
932 *---------------------------------------------------------------------------*/
934 sendm_connect_resp(cfg_entry_t *cep, int cdid, int response, int cause)
936 msg_connect_resp_t mcr;
941 mcr.response = response;
943 if(response == SETUP_RESP_REJECT)
947 else if(response == SETUP_RESP_ACCEPT)
949 cep->direction = DIR_IN;
951 mcr.txdelay = cep->isdntxdelin;
953 mcr.bprot = cep->b1protocol;
955 mcr.driver = cep->usrdevicename;
956 mcr.driver_unit = cep->usrdeviceunit;
958 mcr.max_idle_time = cep->idle_time_in;
961 if((ret = ioctl(isdnfd, I4B_CONNECT_RESP, &mcr)) < 0)
963 log(LL_ERR, "sendm_connect_resp: ioctl I4B_CONNECT_RESP failed: %s", strerror(errno));
967 DBGL(DL_DRVR, (log(LL_DBG, "sendm_connect_resp: sent CONNECT_RESP")));
972 /*---------------------------------------------------------------------------*
973 * send message "disconnect request" to kernel
974 *---------------------------------------------------------------------------*/
976 sendm_disconnect_req(cfg_entry_t *cep, int cause)
978 msg_discon_req_t mcr;
981 mcr.cdid = cep->cdid;
985 cep->local_disconnect = DISCON_LOC;
987 if((ret = ioctl(isdnfd, I4B_DISCONNECT_REQ, &mcr)) < 0)
989 log(LL_ERR, "sendm_disconnect_req: ioctl I4B_DISCONNECT_REQ failed: %s", strerror(errno));
994 DBGL(DL_DRVR, (log(LL_DBG, "sendm_disconnect_req: sent DISCONNECT_REQ")));
999 /*---------------------------------------------------------------------------*
1000 * send message "alert request" to kernel
1001 *---------------------------------------------------------------------------*/
1003 sendm_alert_req(cfg_entry_t *cep)
1005 msg_alert_req_t mar;
1008 mar.cdid = cep->cdid;
1010 if((ret = ioctl(isdnfd, I4B_ALERT_REQ, &mar)) < 0)
1012 log(LL_ERR, "sendm_alert_req: ioctl I4B_ALERT_REQ failed: %s", strerror(errno));
1017 DBGL(DL_DRVR, (log(LL_DBG, "sendm_alert_req: sent ALERT_REQ")));