2 * Copyright (c) 1997, 2001 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_i4bdrv.c - i4b userland interface driver
28 * --------------------------------------------
30 * $FreeBSD: src/sys/i4b/layer4/i4b_i4bdrv.c,v 1.11.2.5 2001/12/16 15:12:59 hm Exp $
31 * $DragonFly: src/sys/net/i4b/layer4/i4b_i4bdrv.c,v 1.10 2004/05/19 22:53:00 dillon Exp $
33 * last edit-date: [Sat Aug 11 18:08:10 2001]
35 *---------------------------------------------------------------------------*/
38 #include "use_i4bipr.h"
39 #include "use_i4btel.h"
42 #error "only 1 (one) i4b device possible!"
47 #include <sys/param.h>
49 #if defined(__DragonFly__) || defined(__FreeBSD__)
50 #include <sys/ioccom.h>
51 #include <sys/malloc.h>
54 #include <sys/ioctl.h>
57 #include <sys/kernel.h>
58 #include <sys/systm.h>
61 #include <sys/socket.h>
62 #if defined(__FreeBSD__) && __FreeBSD_version >= 500014
63 #include <sys/selinfo.h>
65 #include <sys/select.h>
70 #include <sys/types.h>
73 #if defined(__DragonFly__) || defined(__FreeBSD__)
74 #include "use_i4bing.h"
80 #if defined(__DragonFly__) || defined(__FreeBSD__)
81 #include "use_i4bisppp.h"
83 #include <net/if_sppp.h>
87 #if defined(__DragonFly__) || defined(__FreeBSD__)
89 #if defined(__FreeBSD__) && __FreeBSD__ == 3
90 #include "opt_devfs.h"
94 #include <sys/devfsext.h>
97 #endif /* __FreeBSD__*/
99 #if defined(__DragonFly__) || defined(__FreeBSD__)
100 #include <net/i4b/include/machine/i4b_debug.h>
101 #include <net/i4b/include/machine/i4b_ioctl.h>
102 #include <net/i4b/include/machine/i4b_cause.h>
104 #include <i4b/i4b_debug.h>
105 #include <i4b/i4b_ioctl.h>
106 #include <i4b/i4b_cause.h>
109 #include "../include/i4b_l3l4.h"
110 #include "../include/i4b_mbuf.h"
111 #include "../include/i4b_global.h"
116 #include <sys/poll.h>
119 struct selinfo select_rd_info;
121 static struct ifqueue i4b_rdqueue;
122 static int openflag = 0;
123 static int selflag = 0;
124 static int readflag = 0;
126 #if defined(__FreeBSD__) && __FreeBSD__ == 3
128 static void *devfs_token;
132 #if !defined(__DragonFly__) && !defined(__FreeBSD__)
134 #define PDEVSTATIC /* - not static - */
135 PDEVSTATIC void i4battach (void);
136 PDEVSTATIC int i4bopen (dev_t dev, int flag, int fmt, struct proc *p);
137 PDEVSTATIC int i4bclose (dev_t dev, int flag, int fmt, struct proc *p);
138 PDEVSTATIC int i4bread (dev_t dev, struct uio *uio, int ioflag);
141 PDEVSTATIC int i4bioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p);
143 PDEVSTATIC int i4bioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p);
147 PDEVSTATIC int i4bpoll (dev_t dev, int events, struct proc *p);
149 PDEVSTATIC int i4bselect (dev_t dev, int rw, struct proc *p);
152 #endif /* #ifndef __FreeBSD__ */
154 #if defined(__DragonFly__) || (BSD > 199306 && defined(__FreeBSD__))
156 #define PDEVSTATIC static
158 PDEVSTATIC d_open_t i4bopen;
159 PDEVSTATIC d_close_t i4bclose;
160 PDEVSTATIC d_read_t i4bread;
161 PDEVSTATIC d_ioctl_t i4bioctl;
164 PDEVSTATIC d_poll_t i4bpoll;
165 #define POLLFIELD i4bpoll
167 PDEVSTATIC d_select_t i4bselect;
168 #define POLLFIELD i4bselect
171 #define CDEV_MAJOR 60
173 #if defined(__DragonFly__) || (defined(__FreeBSD__) && __FreeBSD__ >= 4)
174 static struct cdevsw i4b_cdevsw = {
176 /* maj */ CDEV_MAJOR,
182 /* close */ i4bclose,
185 /* ioctl */ i4bioctl,
186 /* poll */ POLLFIELD,
188 /* strategy */ nostrategy,
193 static struct cdevsw i4b_cdevsw = {
194 i4bopen, i4bclose, i4bread, nowrite,
195 i4bioctl, nostop, nullreset, nodevtotty,
196 POLLFIELD, nommap, NULL, "i4b", NULL, -1
200 PDEVSTATIC void i4battach(void *);
201 PSEUDO_SET(i4battach, i4b_i4bdrv);
204 i4b_drvinit(void *unused)
206 #if defined(__DragonFly__) || (defined(__FreeBSD__) && __FreeBSD__ >= 4)
207 cdevsw_add(&i4b_cdevsw, 0, 0);
209 static int i4b_devsw_installed = 0;
212 if( ! i4b_devsw_installed )
214 dev = makedev(CDEV_MAJOR,0);
215 cdevsw_add(&dev,&i4b_cdevsw,NULL);
216 i4b_devsw_installed = 1;
221 SYSINIT(i4bdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,i4b_drvinit,NULL)
223 #endif /* BSD > 199306 && defined(__FreeBSD__) */
226 #include <sys/device.h>
227 int i4bmatch(struct device *parent, struct cfdata *cf, void *aux);
228 void dummy_i4battach(struct device*, struct device *, void *);
230 #define CDEV_MAJOR 65
232 static struct cfdriver i4bcd =
233 { NULL, "i4b", i4bmatch, dummy_i4battach, DV_DULL,
234 sizeof(struct cfdriver) };
237 i4bopen, i4bclose, i4bread, nowrite,
238 i4bioctl, i4bselect, nommap, nostrat,
239 nodump, nopsize, 0, nostop
243 i4bmatch(struct device *parent, struct cfdata *cf, void *aux)
245 printf("i4bmatch: aux=0x%x\n", aux);
249 dummy_i4battach(struct device *parent, struct device *self, void *aux)
251 printf("dummy_i4battach: aux=0x%x\n", aux);
253 #endif /* __bsdi__ */
255 /*---------------------------------------------------------------------------*
256 * interface attach routine
257 *---------------------------------------------------------------------------*/
259 #if defined(__DragonFly__) || defined(__FreeBSD__)
260 i4battach(void *dummy)
265 printf("i4b: ISDN call control device attached\n");
267 i4b_rdqueue.ifq_maxlen = IFQ_MAXLEN;
269 #if defined(__FreeBSD__) && __FreeBSD__ > 4
270 mtx_init(&i4b_rdqueue.ifq_mtx, "i4b_rdqueue", MTX_DEF);
273 #if defined(__DragonFly__) || defined(__FreeBSD__)
274 make_dev(&i4b_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4b");
278 /*---------------------------------------------------------------------------*
279 * i4bopen - device driver open routine
280 *---------------------------------------------------------------------------*/
282 i4bopen(dev_t dev, int flag, int fmt, struct thread *td)
294 i4b_l4_daemon_attached();
300 /*---------------------------------------------------------------------------*
301 * i4bclose - device driver close routine
302 *---------------------------------------------------------------------------*/
304 i4bclose(dev_t dev, int flag, int fmt, struct thread *td)
308 i4b_l4_daemon_detached();
309 i4b_Dcleanifq(&i4b_rdqueue);
314 /*---------------------------------------------------------------------------*
315 * i4bread - device driver read routine
316 *---------------------------------------------------------------------------*/
318 i4bread(dev_t dev, struct uio *uio, int ioflag)
328 IF_LOCK(&i4b_rdqueue);
329 while(IF_QEMPTY(&i4b_rdqueue))
332 #if defined (__FreeBSD__) && __FreeBSD__ > 4
333 error = msleep((caddr_t) &i4b_rdqueue, &i4b_rdqueue.ifq_mtx,
336 error = tsleep((caddr_t) &i4b_rdqueue, PCATCH, "bird", 0);
339 IF_UNLOCK(&i4b_rdqueue);
345 _IF_DEQUEUE(&i4b_rdqueue, m);
346 IF_UNLOCK(&i4b_rdqueue);
351 error = uiomove(m->m_data, m->m_len, uio);
361 /*---------------------------------------------------------------------------*
362 * i4bioctl - device driver ioctl routine
363 *---------------------------------------------------------------------------*/
365 #if defined(__DragonFly__) || (defined (__FreeBSD_version) && __FreeBSD_version >= 300003)
366 i4bioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
367 #elif defined(__bsdi__)
368 i4bioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
370 i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
381 /* cdid request, reserve cd and return cdid */
386 mir = (msg_cdid_req_t *)data;
388 mir->cdid = cd->cdid;
392 /* connect request, dial out to remote */
394 case I4B_CONNECT_REQ:
396 msg_connect_req_t *mcr;
397 mcr = (msg_connect_req_t *)data; /* setup ptr */
399 if((cd = cd_by_cdid(mcr->cdid)) == NULL)/* get cd */
401 NDBGL4(L4_ERR, "I4B_CONNECT_REQ ioctl, cdid not found!");
406 /* prevent dialling on leased lines */
407 if(ctrl_desc[mcr->controller].protocol == PROTOCOL_D64S)
409 SET_CAUSE_TYPE(cd->cause_in, CAUSET_I4B);
410 SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_LLDIAL);
411 i4b_l4_disconnect_ind(cd);
416 cd->controller = mcr->controller; /* fill cd */
417 cd->bprot = mcr->bprot;
418 cd->driver = mcr->driver;
419 cd->driver_unit = mcr->driver_unit;
420 cd->cr = get_rand_cr(ctrl_desc[cd->controller].unit);
422 cd->shorthold_data.shorthold_algorithm = mcr->shorthold_data.shorthold_algorithm;
423 cd->shorthold_data.unitlen_time = mcr->shorthold_data.unitlen_time;
424 cd->shorthold_data.idle_time = mcr->shorthold_data.idle_time;
425 cd->shorthold_data.earlyhup_time = mcr->shorthold_data.earlyhup_time;
427 cd->last_aocd_time = 0;
428 if(mcr->unitlen_method == ULEN_METHOD_DYNAMIC)
435 cd->max_idle_time = 0; /* this is outgoing */
437 cd->dir = DIR_OUTGOING;
439 NDBGL4(L4_TIMO, "I4B_CONNECT_REQ times, algorithm=%ld unitlen=%ld idle=%ld earlyhup=%ld",
440 (long)cd->shorthold_data.shorthold_algorithm, (long)cd->shorthold_data.unitlen_time,
441 (long)cd->shorthold_data.idle_time, (long)cd->shorthold_data.earlyhup_time);
443 strcpy(cd->dst_telno, mcr->dst_telno);
444 strcpy(cd->src_telno, mcr->src_telno);
446 if(mcr->keypad[0] != '\0')
447 strcpy(cd->keypad, mcr->keypad);
449 cd->keypad[0] = '\0';
451 cd->display[0] = '\0';
453 SET_CAUSE_TYPE(cd->cause_in, CAUSET_I4B);
454 SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NORMAL);
460 if(ctrl_desc[mcr->controller].bch_state[mcr->channel] != BCH_ST_FREE)
461 SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
468 i < ctrl_desc[mcr->controller].nbch &&
469 ctrl_desc[mcr->controller].bch_state[i] != BCH_ST_FREE;
471 if (i == ctrl_desc[mcr->controller].nbch)
472 SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
473 /* else mcr->channel = i; XXX */
478 SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
482 cd->channelid = mcr->channel;
484 cd->isdntxdelay = mcr->txdelay;
486 /* check whether we have a pointer. Seems like */
487 /* this should be adequate. GJ 19.09.97 */
488 if(ctrl_desc[cd->controller].N_CONNECT_REQUEST == NULL)
489 /*XXX*/ SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
491 if((GET_CAUSE_VAL(cd->cause_in)) != CAUSE_I4B_NORMAL)
493 i4b_l4_disconnect_ind(cd);
498 (*ctrl_desc[cd->controller].N_CONNECT_REQUEST)(mcr->cdid);
503 /* connect response, accept/reject/ignore incoming call */
505 case I4B_CONNECT_RESP:
507 msg_connect_resp_t *mcrsp;
509 mcrsp = (msg_connect_resp_t *)data;
511 if((cd = cd_by_cdid(mcrsp->cdid)) == NULL)/* get cd */
513 NDBGL4(L4_ERR, "I4B_CONNECT_RESP ioctl, cdid not found!");
520 cd->driver = mcrsp->driver;
521 cd->driver_unit = mcrsp->driver_unit;
522 cd->max_idle_time = mcrsp->max_idle_time;
524 cd->shorthold_data.shorthold_algorithm = SHA_FIXU;
525 cd->shorthold_data.unitlen_time = 0; /* this is incoming */
526 cd->shorthold_data.idle_time = 0;
527 cd->shorthold_data.earlyhup_time = 0;
529 cd->isdntxdelay = mcrsp->txdelay;
531 NDBGL4(L4_TIMO, "I4B_CONNECT_RESP max_idle_time set to %ld seconds", (long)cd->max_idle_time);
533 (*ctrl_desc[cd->controller].N_CONNECT_RESPONSE)(mcrsp->cdid, mcrsp->response, mcrsp->cause);
537 /* disconnect request, actively terminate connection */
539 case I4B_DISCONNECT_REQ:
541 msg_discon_req_t *mdr;
543 mdr = (msg_discon_req_t *)data;
545 if((cd = cd_by_cdid(mdr->cdid)) == NULL)/* get cd */
547 NDBGL4(L4_ERR, "I4B_DISCONNECT_REQ ioctl, cdid not found!");
552 /* preset causes with our cause */
553 cd->cause_in = cd->cause_out = mdr->cause;
555 (*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(mdr->cdid, mdr->cause);
559 /* controller info request */
561 case I4B_CTRL_INFO_REQ:
563 msg_ctrl_info_req_t *mcir;
565 mcir = (msg_ctrl_info_req_t *)data;
566 mcir->ncontroller = nctrl;
568 if(mcir->controller > nctrl)
570 mcir->ctrl_type = -1;
571 mcir->card_type = -1;
576 ctrl_desc[mcir->controller].ctrl_type;
578 ctrl_desc[mcir->controller].card_type;
580 ctrl_desc[mcir->controller].nbch;
582 if(ctrl_desc[mcir->controller].ctrl_type == CTRL_PASSIVE)
583 mcir->tei = ctrl_desc[mcir->controller].tei;
592 case I4B_DIALOUT_RESP:
594 drvr_link_t *dlt = NULL;
595 msg_dialout_resp_t *mdrsp;
597 mdrsp = (msg_dialout_resp_t *)data;
599 switch(mdrsp->driver)
603 dlt = ipr_ret_linktab(mdrsp->driver_unit);
609 dlt = i4bisppp_ret_linktab(mdrsp->driver_unit);
615 dlt = tel_ret_linktab(mdrsp->driver_unit);
621 dlt = ibc_ret_linktab(mdrsp->driver_unit);
627 dlt = ing_ret_linktab(mdrsp->driver_unit);
633 (*dlt->dial_response)(mdrsp->driver_unit, mdrsp->stat, mdrsp->cause);
637 /* update timeout value */
639 case I4B_TIMEOUT_UPD:
641 msg_timeout_upd_t *mtu;
644 mtu = (msg_timeout_upd_t *)data;
646 NDBGL4(L4_TIMO, "I4B_TIMEOUT_UPD ioctl, alg %d, unit %d, idle %d, early %d!",
647 mtu->shorthold_data.shorthold_algorithm, mtu->shorthold_data.unitlen_time,
648 mtu->shorthold_data.idle_time, mtu->shorthold_data.earlyhup_time);
650 if((cd = cd_by_cdid(mtu->cdid)) == NULL)/* get cd */
652 NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, cdid not found!");
657 switch( mtu->shorthold_data.shorthold_algorithm )
661 * For this algorithm unitlen_time,
662 * idle_time and earlyhup_time are used.
665 if(!(mtu->shorthold_data.unitlen_time >= 0 &&
666 mtu->shorthold_data.idle_time >= 0 &&
667 mtu->shorthold_data.earlyhup_time >= 0))
669 NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for fix unit algorithm!");
676 * For this algorithm unitlen_time and
677 * idle_time are used. both must be
678 * positive integers. earlyhup_time is
679 * not used and must be 0.
682 if(!(mtu->shorthold_data.unitlen_time > 0 &&
683 mtu->shorthold_data.idle_time >= 0 &&
684 mtu->shorthold_data.earlyhup_time == 0))
686 NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for var unit algorithm!");
692 NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid algorithm!");
698 * any error set above requires us to break
699 * out of the outer switch
705 cd->shorthold_data.shorthold_algorithm = mtu->shorthold_data.shorthold_algorithm;
706 cd->shorthold_data.unitlen_time = mtu->shorthold_data.unitlen_time;
707 cd->shorthold_data.idle_time = mtu->shorthold_data.idle_time;
708 cd->shorthold_data.earlyhup_time = mtu->shorthold_data.earlyhup_time;
713 /* soft enable/disable interface */
717 msg_updown_ind_t *mui;
719 mui = (msg_updown_ind_t *)data;
722 if(mui->driver == BDRV_IPR)
725 dlt = ipr_ret_linktab(mui->driver_unit);
726 (*dlt->updown_ind)(mui->driver_unit, mui->updown);
732 /* send ALERT request */
736 msg_alert_req_t *mar;
738 mar = (msg_alert_req_t *)data;
740 if((cd = cd_by_cdid(mar->cdid)) == NULL)
742 NDBGL4(L4_ERR, "I4B_ALERT_REQ ioctl, cdid not found!");
749 (*ctrl_desc[cd->controller].N_ALERT_REQUEST)(mar->cdid);
754 /* version/release number request */
760 mvr = (msg_vr_req_t *)data;
762 mvr->version = VERSION;
768 /* set D-channel protocol for a controller */
774 mpi = (msg_prot_ind_t *)data;
776 ctrl_desc[mpi->controller].protocol = mpi->protocol;
781 /* Download request */
783 case I4B_CTRL_DOWNLOAD:
785 struct isdn_dr_prot *prots = NULL, *prots2 = NULL;
786 struct isdn_download_request *r =
787 (struct isdn_download_request*)data;
790 if (r->controller < 0 || r->controller >= nctrl)
796 if(!ctrl_desc[r->controller].N_DOWNLOAD)
802 prots = malloc(r->numprotos * sizeof(struct isdn_dr_prot),
805 prots2 = malloc(r->numprotos * sizeof(struct isdn_dr_prot),
808 if(!prots || !prots2)
814 copyin(r->protocols, prots, r->numprotos * sizeof(struct isdn_dr_prot));
816 for(i = 0; i < r->numprotos; i++)
818 prots2[i].microcode = malloc(prots[i].bytecount, M_DEVBUF, M_WAITOK);
819 copyin(prots[i].microcode, prots2[i].microcode, prots[i].bytecount);
820 prots2[i].bytecount = prots[i].bytecount;
823 error = ctrl_desc[r->controller].N_DOWNLOAD(
824 ctrl_desc[r->controller].unit,
825 r->numprotos, prots2);
830 for(i = 0; i < r->numprotos; i++)
832 if(prots2[i].microcode)
834 free(prots2[i].microcode, M_DEVBUF);
837 free(prots2, M_DEVBUF);
842 free(prots, M_DEVBUF);
847 /* Diagnostic request */
849 case I4B_ACTIVE_DIAGNOSTIC:
851 struct isdn_diagnostic_request req, *r =
852 (struct isdn_diagnostic_request*)data;
854 req.in_param = req.out_param = NULL;
855 if (r->controller < 0 || r->controller >= nctrl)
861 if(!ctrl_desc[r->controller].N_DIAGNOSTICS)
867 memcpy(&req, r, sizeof(req));
871 /* XXX arbitrary limit */
872 if (req.in_param_len >
873 I4B_ACTIVE_DIAGNOSTIC_MAXPARAMLEN) {
878 req.in_param = malloc(r->in_param_len, M_DEVBUF, M_WAITOK);
885 error = copyin(r->in_param, req.in_param, req.in_param_len);
890 if(req.out_param_len)
892 req.out_param = malloc(r->out_param_len, M_DEVBUF, M_WAITOK);
901 error = ctrl_desc[r->controller].N_DIAGNOSTICS(r->controller, &req);
903 if(!error && req.out_param_len)
904 error = copyout(req.out_param, r->out_param, req.out_param_len);
908 free(req.in_param, M_DEVBUF);
911 free(req.out_param, M_DEVBUF);
926 #ifdef OS_USES_SELECT
928 /*---------------------------------------------------------------------------*
929 * i4bselect - device driver select routine
930 *---------------------------------------------------------------------------*/
932 i4bselect(dev_t dev, int rw, struct thread *td)
942 if(!IF_QEMPTY(&i4b_rdqueue))
945 selrecord(td, &select_rd_info);
958 #else /* OS_USES_SELECT */
960 /*---------------------------------------------------------------------------*
961 * i4bpoll - device driver poll routine
962 *---------------------------------------------------------------------------*/
964 i4bpoll(dev_t dev, int events, struct thread *td)
971 if((events & POLLIN) || (events & POLLRDNORM))
973 if(!IF_QEMPTY(&i4b_rdqueue))
977 selrecord(td, &select_rd_info);
982 else if((events & POLLOUT) || (events & POLLWRNORM))
990 #endif /* OS_USES_SELECT */
992 /*---------------------------------------------------------------------------*
993 * i4bputqueue - put message into queue to userland
994 *---------------------------------------------------------------------------*/
996 i4bputqueue(struct mbuf *m)
1008 IF_LOCK(&i4b_rdqueue);
1009 if(_IF_QFULL(&i4b_rdqueue))
1012 _IF_DEQUEUE(&i4b_rdqueue, m1);
1014 NDBGL4(L4_ERR, "ERROR, queue full, removing entry!");
1017 _IF_ENQUEUE(&i4b_rdqueue, m);
1018 IF_UNLOCK(&i4b_rdqueue);
1025 wakeup((caddr_t) &i4b_rdqueue);
1031 selwakeup(&select_rd_info);
1035 /*---------------------------------------------------------------------------*
1036 * i4bputqueue_hipri - put message into front of queue to userland
1037 *---------------------------------------------------------------------------*/
1039 i4bputqueue_hipri(struct mbuf *m)
1051 IF_LOCK(&i4b_rdqueue);
1052 if(_IF_QFULL(&i4b_rdqueue))
1055 _IF_DEQUEUE(&i4b_rdqueue, m1);
1057 NDBGL4(L4_ERR, "ERROR, queue full, removing entry!");
1060 _IF_PREPEND(&i4b_rdqueue, m);
1061 IF_UNLOCK(&i4b_rdqueue);
1068 wakeup((caddr_t) &i4b_rdqueue);
1074 selwakeup(&select_rd_info);
1078 #endif /* NI4B > 0 */