]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/i4b/driver/i4b_isppp.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / i4b / driver / i4b_isppp.c
1 /*-
2  *   Copyright (c) 1997 Joerg Wunsch. All rights reserved.
3  *
4  *   Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *   1. Redistributions of source code must retain the above copyright
11  *      notice, this list of conditions and the following disclaimer.
12  *   2. Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in the
14  *      documentation and/or other materials provided with the distribution.
15  *   
16  *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  *   SUCH DAMAGE.
27  */
28
29 /*---------------------------------------------------------------------------
30  *
31  *      i4b_isppp.c - isdn4bsd kernel SyncPPP driver
32  *      --------------------------------------------
33  *
34  *      Uses Serge Vakulenko's sppp backend (originally contributed with
35  *      the "cx" driver for Cronyx's HDLC-in-hardware device).  This driver
36  *      is only the glue between sppp and i4b.
37  *
38  *      last edit-date: [Sat Mar  9 14:09:27 2002]
39  *
40  *---------------------------------------------------------------------------*/
41
42 #include <sys/cdefs.h>
43 __FBSDID("$FreeBSD$");
44
45 #include "opt_i4b.h"
46
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/mbuf.h>
50 #include <sys/socket.h>
51 #include <sys/errno.h>
52 #include <sys/ioccom.h>
53 #include <sys/sockio.h>
54 #include <sys/kernel.h>
55
56 #include <net/if.h>
57 #include <net/if_types.h>
58 #include <net/if_sppp.h>
59
60 #include <sys/time.h>
61 #include <net/bpf.h>
62
63 #include <i4b/include/i4b_ioctl.h>
64 #include <i4b/include/i4b_debug.h>
65
66 #include <i4b/include/i4b_global.h>
67 #include <i4b/include/i4b_l3l4.h>
68
69 #include <i4b/layer4/i4b_l4.h>
70
71 #error "Cannot be used until I4B is locked."
72
73 #define ISPPP_FMT       "isp%d: "
74 #define ISPPP_ARG(sc)   (sc->sc_ifp->if_dunit)
75 #define PDEVSTATIC      static
76 #define IFP2UNIT(ifp)   (ifp)->if_dunit
77                 
78 #  define CALLOUT_INIT(chan)            callout_handle_init(chan)
79 #  define TIMEOUT(fun, arg, chan, tick) chan = timeout(fun, arg, tick)
80 #  define UNTIMEOUT(fun, arg, chan)     untimeout(fun, arg, chan)
81 #  define IOCTL_CMD_T u_long
82
83 PDEVSTATIC void i4bispppattach(void *);
84 PSEUDO_SET(i4bispppattach, i4b_isppp);
85
86 #define I4BISPPPACCT            1       /* enable accounting messages */
87 #define I4BISPPPACCTINTVL       2       /* accounting msg interval in secs */
88 #define I4BISPPPDISCDEBUG       1       
89
90 #define PPP_HDRLEN              4       /* 4 octetts PPP header length  */
91
92 struct i4bisppp_softc {
93         struct ifnet *sc_ifp;
94
95         int     sc_state;       /* state of the interface       */
96         call_desc_t *sc_cdp;    /* ptr to call descriptor       */
97
98 #ifdef I4BISPPPACCT
99         int sc_iinb;            /* isdn driver # of inbytes     */
100         int sc_ioutb;           /* isdn driver # of outbytes    */
101         int sc_inb;             /* # of bytes rx'd              */
102         int sc_outb;            /* # of bytes tx'd              */
103         int sc_linb;            /* last # of bytes rx'd         */
104         int sc_loutb;           /* last # of bytes tx'd         */
105         int sc_fn;              /* flag, first null acct        */
106 #endif
107
108         struct callout_handle sc_ch;
109 } i4bisppp_softc[NI4BISPPP];
110
111 static void     i4bisppp_init_linktab(int unit);
112 static int      i4bisppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data);
113
114 #if 0
115 static void     i4bisppp_send(struct ifnet *ifp);
116 #endif
117
118 static void     i4bisppp_start(struct ifnet *ifp);
119
120 #if 0 /* never used ??? */
121 static void     i4bisppp_timeout(void *cookie);
122 #endif
123
124 static void     i4bisppp_tls(struct sppp *sp);
125 static void     i4bisppp_tlf(struct sppp *sp);
126 static void     i4bisppp_state_changed(struct sppp *sp, int new_state);
127 static void     i4bisppp_negotiation_complete(struct sppp *sp);
128 static void     i4bisppp_watchdog(struct ifnet *ifp);
129 time_t          i4bisppp_idletime(int unit);
130
131 /* initialized by L4 */
132
133 static drvr_link_t i4bisppp_drvr_linktab[NI4BISPPP];
134 static isdn_link_t *isdn_linktab[NI4BISPPP];
135
136 enum i4bisppp_states {
137         ST_IDLE,                        /* initialized, ready, idle     */
138         ST_DIALING,                     /* dialling out to remote       */
139         ST_CONNECTED,                   /* connected to remote          */
140 };
141
142 /*===========================================================================*
143  *                      DEVICE DRIVER ROUTINES
144  *===========================================================================*/
145
146 /*---------------------------------------------------------------------------*
147  *      interface attach routine at kernel boot time
148  *---------------------------------------------------------------------------*/
149 PDEVSTATIC void
150 i4bispppattach(void *dummy)
151 {
152         struct i4bisppp_softc *sc = i4bisppp_softc;
153         struct ifnet *ifp;
154         int i;
155
156 #ifdef SPPP_VJ
157         printf("i4bisppp: %d ISDN SyncPPP device(s) attached (VJ header compression)\n", NI4BISPPP);
158 #else
159         printf("i4bisppp: %d ISDN SyncPPP device(s) attached\n", NI4BISPPP);
160 #endif
161
162         for(i = 0; i < NI4BISPPP; sc++, i++) {
163                 i4bisppp_init_linktab(i);
164                 ifp = sc->sc_ifp = if_alloc(IFT_PPP);
165                 if (ifp == NULL) {
166                         panic("isp%d: cannot if_alloc()", i);
167                 }
168                 
169                 ifp->if_softc = sc;
170                 if_initname(sc->sc_ifp, "isp", i);
171                 ifp->if_mtu = PP_MTU;
172                 ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
173                 /*
174                  * XXX: If there were a detach function this would
175                  * require that it use if_free_type().  Not sure if this
176                  * type makes sense.
177                  */
178                 ifp->if_type = IFT_ISDNBASIC;
179                 sc->sc_state = ST_IDLE;
180
181                 ifp->if_ioctl = i4bisppp_ioctl;
182
183                 /* actually initialized by sppp_attach() */
184                 /* ifp->if_output = sppp_output; */
185
186                 ifp->if_start = i4bisppp_start;
187
188                 ifp->if_hdrlen = 0;
189                 ifp->if_addrlen = 0;
190                 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
191
192                 ifp->if_ipackets = 0;
193                 ifp->if_ierrors = 0;
194                 ifp->if_opackets = 0;
195                 ifp->if_oerrors = 0;
196                 ifp->if_collisions = 0;
197                 ifp->if_ibytes = 0;
198                 ifp->if_obytes = 0;
199                 ifp->if_imcasts = 0;
200                 ifp->if_omcasts = 0;
201                 ifp->if_iqdrops = 0;
202                 ifp->if_noproto = 0;
203
204 #if I4BISPPPACCT
205                 ifp->if_timer = 0;      
206                 ifp->if_watchdog = i4bisppp_watchdog;   
207                 sc->sc_iinb = 0;
208                 sc->sc_ioutb = 0;
209                 sc->sc_inb = 0;
210                 sc->sc_outb = 0;
211                 sc->sc_linb = 0;
212                 sc->sc_loutb = 0;
213                 sc->sc_fn = 1;
214 #endif
215
216                 IFP2SP(sc->sc_ifp)->pp_tls = i4bisppp_tls;
217                 IFP2SP(sc->sc_ifp)->pp_tlf = i4bisppp_tlf;
218                 IFP2SP(sc->sc_ifp)->pp_con = i4bisppp_negotiation_complete;
219                 IFP2SP(sc->sc_ifp)->pp_chg = i4bisppp_state_changed;
220
221                 sppp_attach(sc->sc_ifp);
222
223                 if_attach(sc->sc_ifp);
224
225                 CALLOUT_INIT(&sc->sc_ch);
226                 
227                 bpfattach(sc->sc_ifp, DLT_PPP, PPP_HDRLEN);
228         }
229 }
230
231 /*---------------------------------------------------------------------------*
232  *      process ioctl
233  *---------------------------------------------------------------------------*/
234 static int
235 i4bisppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data)
236 {
237         struct i4bisppp_softc *sc = ifp->if_softc;
238 #if 0
239         struct sppp *sp = IFP2SP(sc->sc_ifp);
240         struct ifaddr *ifa = (struct ifaddr *) data;
241         struct ifreq *ifr = (struct ifreq *) data;
242 #endif
243
244         int error;
245
246         error = sppp_ioctl(sc->sc_ifp, cmd, data);
247         if (error)
248                 return error;
249
250         switch(cmd) {
251         case SIOCSIFFLAGS:
252 #if 0 /* never used ??? */
253                 x = splimp();
254                 if ((ifp->if_flags & IFF_UP) == 0)
255                         UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
256                 splx(x);
257 #endif
258                 break;
259         }
260
261         return 0;
262 }
263
264 /*---------------------------------------------------------------------------*
265  *      start output to ISDN B-channel
266  *---------------------------------------------------------------------------*/
267 static void
268 i4bisppp_start(struct ifnet *ifp)
269 {
270         struct i4bisppp_softc *sc = ifp->if_softc;
271         struct mbuf *m;
272         /* int s; */
273         int unit = IFP2UNIT(ifp);
274
275         if (sppp_isempty(ifp))
276                 return;
277
278         if(sc->sc_state != ST_CONNECTED)
279                 return;
280
281         /*
282          * s = splimp();
283          * ifp->if_drv_flags |= IFF_DRV_OACTIVE; // - need to clear this somewhere
284          * splx(s);
285          */
286
287         while ((m = sppp_dequeue(sc->sc_ifp)) != NULL)
288         {
289
290                 BPF_MTAP(ifp, m);
291
292                 microtime(&ifp->if_lastchange);
293
294                 IF_LOCK(isdn_linktab[unit]->tx_queue);
295                 if(_IF_QFULL(isdn_linktab[unit]->tx_queue))
296                 {
297                         NDBGL4(L4_ISPDBG, "isp%d, tx queue full!", unit);
298                         m_freem(m);
299                 }
300                 else
301                 {
302 #if 0
303                         sc->sc_ifp->if_obytes += m->m_pkthdr.len;
304 #endif
305                         sc->sc_outb += m->m_pkthdr.len;
306                         sc->sc_ifp->if_opackets++;
307
308                         _IF_ENQUEUE(isdn_linktab[unit]->tx_queue, m);
309                 }
310                 IF_UNLOCK(isdn_linktab[unit]->tx_queue);
311         }
312         isdn_linktab[unit]->bch_tx_start(isdn_linktab[unit]->unit,
313                                          isdn_linktab[unit]->channel);
314 }
315
316 #ifdef I4BISPPPACCT
317 /*---------------------------------------------------------------------------*
318  *      watchdog routine
319  *---------------------------------------------------------------------------*/
320 static void
321 i4bisppp_watchdog(struct ifnet *ifp)
322 {
323         struct i4bisppp_softc *sc = ifp->if_softc;
324         int unit = IFP2UNIT(ifp);
325         bchan_statistics_t bs;
326         
327         (*isdn_linktab[unit]->bch_stat)
328                 (isdn_linktab[unit]->unit, isdn_linktab[unit]->channel, &bs);
329
330         sc->sc_ioutb += bs.outbytes;
331         sc->sc_iinb += bs.inbytes;
332         
333         if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn)
334         {
335                 int ri = (sc->sc_iinb - sc->sc_linb)/I4BISPPPACCTINTVL;
336                 int ro = (sc->sc_ioutb - sc->sc_loutb)/I4BISPPPACCTINTVL;
337
338                 if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
339                         sc->sc_fn = 0;
340                 else
341                         sc->sc_fn = 1;
342                         
343                 sc->sc_linb = sc->sc_iinb;
344                 sc->sc_loutb = sc->sc_ioutb;
345
346                 i4b_l4_accounting(BDRV_ISPPP, unit, ACCT_DURING,
347                          sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb);
348         }
349         sc->sc_ifp->if_timer = I4BISPPPACCTINTVL;       
350
351 #if 0 /* old stuff, keep it around */
352         printf(ISPPP_FMT "transmit timeout\n", ISPPP_ARG(sc));
353         i4bisppp_start(ifp);
354 #endif
355 }
356 #endif /* I4BISPPPACCT */
357
358 /*
359  *===========================================================================*
360  *                      SyncPPP layer interface routines
361  *===========================================================================*
362  */
363
364 #if 0 /* never used ??? */
365 /*---------------------------------------------------------------------------*
366  *      just an alias for i4bisppp_tls, but of type timeout_t
367  *---------------------------------------------------------------------------*/
368 static void
369 i4bisppp_timeout(void *cookie)
370 {
371         i4bisppp_tls((struct sppp *)cookie);
372 }
373 #endif
374
375 /*---------------------------------------------------------------------------*
376  *      PPP this-layer-started action
377  *---------------------------------------------------------------------------*
378  */
379 static void
380 i4bisppp_tls(struct sppp *sp)
381 {
382         struct ifnet *ifp = SP2IFP(sp);
383         struct i4bisppp_softc *sc = ifp->if_softc;
384
385         if(sc->sc_state == ST_CONNECTED)
386                 return;
387
388         i4b_l4_dialout(BDRV_ISPPP, IFP2UNIT(ifp));
389 }
390
391 /*---------------------------------------------------------------------------*
392  *      PPP this-layer-finished action
393  *---------------------------------------------------------------------------*
394  */
395 static void
396 i4bisppp_tlf(struct sppp *sp)
397 {
398         struct ifnet *ifp = SP2IFP(sp);
399         struct i4bisppp_softc *sc = ifp->if_softc;
400 /*      call_desc_t *cd = sc->sc_cdp;   */
401         
402         if(sc->sc_state != ST_CONNECTED)
403                 return;
404
405 #if 0 /* never used ??? */
406         UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
407 #endif
408
409         i4b_l4_drvrdisc(BDRV_ISPPP, IFP2UNIT(ifp));
410 }
411 /*---------------------------------------------------------------------------*
412  *      PPP interface phase change
413  *---------------------------------------------------------------------------*
414  */
415 static void
416 i4bisppp_state_changed(struct sppp *sp, int new_state)
417 {
418         struct i4bisppp_softc *sc = SP2IFP(sp)->if_softc;
419         
420         i4b_l4_ifstate_changed(sc->sc_cdp, new_state);
421 }
422
423 /*---------------------------------------------------------------------------*
424  *      PPP control protocol negotiation complete (run ip-up script now)
425  *---------------------------------------------------------------------------*
426  */
427 static void
428 i4bisppp_negotiation_complete(struct sppp *sp)
429 {
430         struct i4bisppp_softc *sc = SP2IFP(sp)->if_softc;
431         
432         i4b_l4_negcomplete(sc->sc_cdp);
433 }
434
435 /*===========================================================================*
436  *                      ISDN INTERFACE ROUTINES
437  *===========================================================================*/
438
439 /*---------------------------------------------------------------------------*
440  *      this routine is called from L4 handler at connect time
441  *---------------------------------------------------------------------------*/
442 static void
443 i4bisppp_connect(int unit, void *cdp)
444 {
445         struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
446         struct sppp *sp = IFP2SP(sc->sc_ifp);
447         int s = splimp();
448
449         sc->sc_cdp = (call_desc_t *)cdp;
450         sc->sc_state = ST_CONNECTED;
451
452 #if I4BISPPPACCT
453         sc->sc_iinb = 0;
454         sc->sc_ioutb = 0;
455         sc->sc_inb = 0;
456         sc->sc_outb = 0;
457         sc->sc_linb = 0;
458         sc->sc_loutb = 0;
459         sc->sc_ifp->if_timer = I4BISPPPACCTINTVL;
460 #endif
461         
462 #if 0 /* never used ??? */
463         UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
464 #endif
465
466         sp->pp_up(sp);          /* tell PPP we are ready */
467
468         sp->pp_last_sent = sp->pp_last_recv = SECOND;
469
470         splx(s);
471 }
472
473 /*---------------------------------------------------------------------------*
474  *      this routine is called from L4 handler at disconnect time
475  *---------------------------------------------------------------------------*/
476 static void
477 i4bisppp_disconnect(int unit, void *cdp)
478 {
479         call_desc_t *cd = (call_desc_t *)cdp;
480         struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
481         struct sppp *sp = IFP2SP(sc->sc_ifp);
482
483         int s = splimp();
484
485         /* new stuff to check that the active channel is being closed */
486         if (cd != sc->sc_cdp)
487         {
488                 NDBGL4(L4_ISPDBG, "isp%d, channel%d not active!", unit, cd->channelid);
489                 splx(s);
490                 return;
491         }
492
493 #if I4BISPPPACCT
494         sc->sc_ifp->if_timer = 0;
495 #endif
496
497         i4b_l4_accounting(BDRV_ISPPP, unit, ACCT_FINAL,
498                  sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_outb, sc->sc_inb);
499         
500         if (sc->sc_state == ST_CONNECTED)
501         {
502 #if 0 /* never used ??? */
503                 UNTIMEOUT(i4bisppp_timeout, (void *)sp, sc->sc_ch);
504 #endif
505                 sc->sc_cdp = (call_desc_t *)0;  
506                 /* do this here because pp_down calls i4bisppp_tlf */
507                 sc->sc_state = ST_IDLE;
508                 sp->pp_down(sp);        /* tell PPP we have hung up */
509         }
510
511         splx(s);
512 }
513
514 /*---------------------------------------------------------------------------*
515  *      this routine is used to give a feedback from userland demon
516  *      in case of dial problems
517  *---------------------------------------------------------------------------*/
518 static void
519 i4bisppp_dialresponse(int unit, int status, cause_t cause)
520 {
521         struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
522         struct sppp *sp = IFP2SP(sc->sc_ifp);
523
524         NDBGL4(L4_ISPDBG, "isp%d: status=%d, cause=%d", unit, status, cause);
525
526         if(status != DSTAT_NONE)
527         {
528                 struct mbuf *m;
529                 
530                 NDBGL4(L4_ISPDBG, "isp%d: clearing queues", unit);
531
532                 if(!(sppp_isempty(sc->sc_ifp)))
533                 {
534                         while((m = sppp_dequeue(sc->sc_ifp)) != NULL)
535                                 m_freem(m);
536                 }
537
538                 sc->sc_cdp = (call_desc_t *)0;  
539                 /* do this here because pp_down calls i4bisppp_tlf */
540                 sc->sc_state = ST_IDLE;
541
542                 /*
543                  * Ahh, sppp doesn't like to get a down event when
544                  * dialing fails. So first tell it that we are up
545                  * (doesn't hurt us since sc_state != ST_CONNECTED)
546                  * and then go down.
547                  */
548                 sp->pp_up(sp);
549                 sp->pp_down(sp);
550         }
551 }
552         
553 /*---------------------------------------------------------------------------*
554  *      interface up/down
555  *---------------------------------------------------------------------------*/
556 static void
557 i4bisppp_updown(int unit, int updown)
558 {
559         /* could probably do something useful here */
560 }
561         
562 /*---------------------------------------------------------------------------*
563  *      this routine is called from the HSCX interrupt handler
564  *      when a new frame (mbuf) has been received and was put on
565  *      the rx queue.
566  *---------------------------------------------------------------------------*/
567 static void
568 i4bisppp_rx_data_rdy(int unit)
569 {
570         struct i4bisppp_softc *sc = &i4bisppp_softc[unit];
571         struct mbuf *m;
572         int s;
573         
574         if((m = *isdn_linktab[unit]->rx_mbuf) == NULL)
575                 return;
576
577         m->m_pkthdr.rcvif = sc->sc_ifp;
578         m->m_pkthdr.len = m->m_len;
579
580         microtime(&sc->sc_ifp->if_lastchange);
581
582         sc->sc_ifp->if_ipackets++;
583 #if 0
584         sc->sc_ifp->if_ibytes += m->m_pkthdr.len;
585 #endif
586
587 #if I4BISPPPACCT
588         sc->sc_inb += m->m_pkthdr.len;
589 #endif
590         
591 #ifdef I4BISPPPDEBUG
592         printf("i4bisppp_rx_data_ready: received packet!\n");
593 #endif
594
595         BPF_MTAP(sc->sc_ifp, m);
596
597         s = splimp();
598
599         sppp_input(sc->sc_ifp, m);
600
601         splx(s);
602 }
603
604 /*---------------------------------------------------------------------------*
605  *      this routine is called from the HSCX interrupt handler
606  *      when the last frame has been sent out and there is no
607  *      further frame (mbuf) in the tx queue.
608  *---------------------------------------------------------------------------*/
609 static void
610 i4bisppp_tx_queue_empty(int unit)
611 {
612         i4bisppp_start((&i4bisppp_softc[unit])->sc_ifp);        
613 }
614
615 /*---------------------------------------------------------------------------*
616  *      THIS should be used instead of last_active_time to implement
617  *      an activity timeout mechanism.
618  *
619  *      Sending back the time difference unneccessarily complicates the
620  *      idletime checks in i4b_l4.c. Return the largest time instead.
621  *      That way the code in i4b_l4.c needs only minimal changes.
622  *---------------------------------------------------------------------------*/
623 time_t
624 i4bisppp_idletime(int unit)
625 {
626         struct sppp *sp = IFP2SP((&i4bisppp_softc[unit])->sc_ifp);
627
628         return((sp->pp_last_recv < sp->pp_last_sent) ?
629                         sp->pp_last_sent : sp->pp_last_recv);
630 }
631
632 /*---------------------------------------------------------------------------*
633  *      this routine is called from the HSCX interrupt handler
634  *      each time a packet is received or transmitted. It should
635  *      be used to implement an activity timeout mechanism.
636  *---------------------------------------------------------------------------*/
637 static void
638 i4bisppp_activity(int unit, int rxtx)
639 {
640         i4bisppp_softc[unit].sc_cdp->last_active_time = SECOND;
641 }
642
643 /*---------------------------------------------------------------------------*
644  *      return this drivers linktab address
645  *---------------------------------------------------------------------------*/
646 drvr_link_t *
647 i4bisppp_ret_linktab(int unit)
648 {
649         return(&i4bisppp_drvr_linktab[unit]);
650 }
651
652 /*---------------------------------------------------------------------------*
653  *      setup the isdn_linktab for this driver
654  *---------------------------------------------------------------------------*/
655 void
656 i4bisppp_set_linktab(int unit, isdn_link_t *ilt)
657 {
658         isdn_linktab[unit] = ilt;
659 }
660
661 /*---------------------------------------------------------------------------*
662  *      initialize this drivers linktab
663  *---------------------------------------------------------------------------*/
664 static void
665 i4bisppp_init_linktab(int unit)
666 {
667         i4bisppp_drvr_linktab[unit].unit = unit;
668         i4bisppp_drvr_linktab[unit].bch_rx_data_ready = i4bisppp_rx_data_rdy;
669         i4bisppp_drvr_linktab[unit].bch_tx_queue_empty = i4bisppp_tx_queue_empty;
670         i4bisppp_drvr_linktab[unit].bch_activity = i4bisppp_activity;
671         i4bisppp_drvr_linktab[unit].line_connected = i4bisppp_connect;
672         i4bisppp_drvr_linktab[unit].line_disconnected = i4bisppp_disconnect;
673         i4bisppp_drvr_linktab[unit].dial_response = i4bisppp_dialresponse;      
674         i4bisppp_drvr_linktab[unit].updown_ind = i4bisppp_updown;       
675 }
676
677 /*===========================================================================*/