Lines Matching +full:multi +full:- +full:socket
1 // SPDX-License-Identifier: GPL-2.0-or-later
15 Value 3 = BRI (multi channel frame, not supported yet)
16 Value 4 = PRI (multi channel frame, not supported yet)
17 A multi channel frame reduces overhead to a single frame for all
18 b-channels, but increases delay.
19 (NOTE: Multi channel frames are not implemented yet.)
28 0 = we use a-Law (default)
29 1 = we use u-Law
32 limitation of B-channels to control bandwidth (1...126)
34 PRI: 1-30, 31-126 (126, because dchannel ist not counted here)
40 byte representation of remote ip address (127.0.0.1 -> 127,0,0,1)
72 p1 = bytes 0-3 : remote IP address in network order (left element first)
73 p2 = bytes 1-2 : remote port in network order (high byte first)
75 p2 = bytes 3-4 : local port in network order (high byte first)
83 L1oIP-Protocol
84 --------------
89 +---------------+
91 +---------------+
93 +---------------+
95 +---------------+
97 +---------------+
99 +---------------+
101 +---------------+
103 +---------------+
105 +---------------+
107 +---------------+
113 +---------------+
115 +---------------+
117 +---------------+
119 +---------------+
121 +---------------+
129 - Ver = Version
132 - T = Type of interface
135 - I = Id present
138 - ID = Connection ID
142 - Coding = Type of codec
143 Must be 0 for no transcoding. Also for D-channel and other HDLC frames.
144 1 and 2 are reserved for explicitly use of a-LAW or u-LAW codec.
147 - M = More channels to come. If this flag is 1, the following byte contains
152 - Channel = Channel number
154 1-3 channel data for S0 (3 is D-channel)
155 1-31 channel data for E1 (16 is D-channel)
156 32-127 channel data for extended E1 (16 is D-channel)
158 - The length is used if the M-flag is 1. It is used to find the next channel
161 -> For larger data blocks, a single frame must be used.
162 -> For larger streams, a single frame or multiple blocks with same channel ID
165 - Time Base = Timestamp of first sample in frame
198 Socket and Thread
199 -----------------
201 The complete socket opening and closing is done by a thread.
202 When the thread opened a socket, the hc->socket descriptor is set. Whenever a
203 packet shall be sent to the socket, the hc->socket must be checked wheter not
204 NULL. To prevent change in socket descriptor, the hc->socket_lock must be used.
205 To change the socket, a recall of l1oip_socket_open() will safely kill the
206 socket process and create a new one.
261 * send a frame via socket, if open and restart timer
269 struct socket *socket = NULL; in l1oip_socket_send() local
272 printk(KERN_DEBUG "%s: sending data to socket (len = %d)\n", in l1oip_socket_send()
278 if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) in l1oip_socket_send()
279 mod_timer(&hc->keep_tl, jiffies + L1OIP_KEEPALIVE * HZ); in l1oip_socket_send()
281 hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ; in l1oip_socket_send()
287 if (!hc->sin_remote.sin_addr.s_addr || !hc->sin_remote.sin_port) { in l1oip_socket_send()
296 | (hc->pri ? 0x20 : 0x00) /* type */ in l1oip_socket_send()
297 | (hc->id ? 0x10 : 0x00) /* id */ in l1oip_socket_send()
299 if (hc->id) { in l1oip_socket_send()
300 *p++ = hc->id >> 24; /* id */ in l1oip_socket_send()
301 *p++ = hc->id >> 16; in l1oip_socket_send()
302 *p++ = hc->id >> 8; in l1oip_socket_send()
303 *p++ = hc->id; in l1oip_socket_send()
305 *p++ = 0x00 + channel; /* m-flag, channel */ in l1oip_socket_send()
316 &hc->chan[channel].codecstate); in l1oip_socket_send()
320 len += p - frame; in l1oip_socket_send()
322 /* check for socket in safe condition */ in l1oip_socket_send()
323 spin_lock(&hc->socket_lock); in l1oip_socket_send()
324 if (!hc->socket) { in l1oip_socket_send()
325 spin_unlock(&hc->socket_lock); in l1oip_socket_send()
328 /* seize socket */ in l1oip_socket_send()
329 socket = hc->socket; in l1oip_socket_send()
330 hc->socket = NULL; in l1oip_socket_send()
331 spin_unlock(&hc->socket_lock); in l1oip_socket_send()
334 printk(KERN_DEBUG "%s: sending packet to socket (len " in l1oip_socket_send()
336 hc->sendiov.iov_base = frame; in l1oip_socket_send()
337 hc->sendiov.iov_len = len; in l1oip_socket_send()
338 len = kernel_sendmsg(socket, &hc->sendmsg, &hc->sendiov, 1, len); in l1oip_socket_send()
339 /* give socket back */ in l1oip_socket_send()
340 hc->socket = socket; /* no locking required */ in l1oip_socket_send()
347 * receive channel data from socket
371 printk(KERN_WARNING "%s: packet error - channel %d out of " in l1oip_socket_recv()
375 dch = hc->chan[channel].dch; in l1oip_socket_recv()
376 bch = hc->chan[channel].bch; in l1oip_socket_recv()
378 printk(KERN_WARNING "%s: packet error - channel %d not in " in l1oip_socket_recv()
402 dch->rx_skb = nskb; in l1oip_socket_recv()
407 rx_counter = hc->chan[channel].rx_counter; in l1oip_socket_recv()
408 if (((s16)(timebase - rx_counter)) >= 0) { in l1oip_socket_recv()
422 rx_counter = ((rx_counter & 0xffff0000) - 0x10000) in l1oip_socket_recv()
425 hc->chan[channel].rx_counter = rx_counter; in l1oip_socket_recv()
428 if (hc->chan[channel].disorder_flag) { in l1oip_socket_recv()
429 swap(hc->chan[channel].disorder_skb, nskb); in l1oip_socket_recv()
430 swap(hc->chan[channel].disorder_cnt, rx_counter); in l1oip_socket_recv()
432 hc->chan[channel].disorder_flag ^= 1; in l1oip_socket_recv()
435 queue_ch_frame(&bch->ch, PH_DATA_IND, rx_counter, nskb); in l1oip_socket_recv()
452 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_socket_parse()
460 printk(KERN_WARNING "%s: packet error - length %d below " in l1oip_socket_parse()
467 printk(KERN_WARNING "%s: packet error - unknown version %d\n", in l1oip_socket_parse()
473 if (((*buf) & 0x20) && !hc->pri) { in l1oip_socket_parse()
474 printk(KERN_WARNING "%s: packet error - received E1 packet " in l1oip_socket_parse()
478 if (!((*buf) & 0x20) && hc->pri) { in l1oip_socket_parse()
479 printk(KERN_WARNING "%s: packet error - received S0 packet " in l1oip_socket_parse()
490 printk(KERN_WARNING "%s: packet error - remotecodec %d " in l1oip_socket_parse()
495 len--; in l1oip_socket_parse()
499 if (!hc->id) { in l1oip_socket_parse()
500 printk(KERN_WARNING "%s: packet error - packet has id " in l1oip_socket_parse()
505 printk(KERN_WARNING "%s: packet error - packet too " in l1oip_socket_parse()
513 len -= 4; in l1oip_socket_parse()
515 if (packet_id != hc->id) { in l1oip_socket_parse()
516 printk(KERN_WARNING "%s: packet error - ID mismatch, " in l1oip_socket_parse()
518 __func__, packet_id, hc->id); in l1oip_socket_parse()
522 if (hc->id) { in l1oip_socket_parse()
523 printk(KERN_WARNING "%s: packet error - packet has no " in l1oip_socket_parse()
531 printk(KERN_WARNING "%s: packet error - packet too short, " in l1oip_socket_parse()
533 __func__, len-len_start + 1); in l1oip_socket_parse()
541 len--; in l1oip_socket_parse()
546 printk(KERN_WARNING "%s: packet error - packet too " in l1oip_socket_parse()
548 __func__, len_start - len - 1); in l1oip_socket_parse()
553 len--; in l1oip_socket_parse()
557 printk(KERN_WARNING "%s: packet error - length %d at " in l1oip_socket_parse()
559 __func__, mlen, len_start-len - 1, len_start); in l1oip_socket_parse()
563 printk(KERN_WARNING "%s: packet error - length %d at " in l1oip_socket_parse()
566 __func__, mlen, len_start-len + 1); in l1oip_socket_parse()
570 mlen = len - 2; /* single frame, subtract timebase */ in l1oip_socket_parse()
573 printk(KERN_WARNING "%s: packet error - packet too short, time " in l1oip_socket_parse()
575 __func__, len-len_start + 1); in l1oip_socket_parse()
582 len -= 2; in l1oip_socket_parse()
585 if (!test_bit(FLG_ACTIVE, &dch->Flags)) { in l1oip_socket_parse()
589 test_and_set_bit(FLG_ACTIVE, &dch->Flags); in l1oip_socket_parse()
590 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, in l1oip_socket_parse()
597 len -= mlen; in l1oip_socket_parse()
604 if (time_before(hc->timeout_tl.expires, jiffies + 5 * HZ) || !hc->timeout_on) { in l1oip_socket_parse()
605 hc->timeout_on = 1; in l1oip_socket_parse()
606 mod_timer(&hc->timeout_tl, jiffies + L1OIP_TIMEOUT * HZ); in l1oip_socket_parse()
608 hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ; in l1oip_socket_parse()
611 if ((hc->sin_remote.sin_addr.s_addr != sin->sin_addr.s_addr) in l1oip_socket_parse()
612 || (hc->sin_remote.sin_port != sin->sin_port)) { in l1oip_socket_parse()
616 ntohl(hc->sin_remote.sin_addr.s_addr), in l1oip_socket_parse()
617 ntohl(sin->sin_addr.s_addr), in l1oip_socket_parse()
618 ntohs(hc->sin_remote.sin_port), in l1oip_socket_parse()
619 ntohs(sin->sin_port)); in l1oip_socket_parse()
620 hc->sin_remote.sin_addr.s_addr = sin->sin_addr.s_addr; in l1oip_socket_parse()
621 hc->sin_remote.sin_port = sin->sin_port; in l1oip_socket_parse()
627 * socket stuff
641 struct socket *socket = NULL; in l1oip_socket_thread() local
648 ret = -ENOMEM; in l1oip_socket_thread()
658 /* create socket */ in l1oip_socket_thread()
659 if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &socket)) { in l1oip_socket_thread()
660 printk(KERN_ERR "%s: Failed to create socket.\n", __func__); in l1oip_socket_thread()
661 ret = -EIO; in l1oip_socket_thread()
666 hc->sin_local.sin_family = AF_INET; in l1oip_socket_thread()
667 hc->sin_local.sin_addr.s_addr = INADDR_ANY; in l1oip_socket_thread()
668 hc->sin_local.sin_port = htons((unsigned short)hc->localport); in l1oip_socket_thread()
671 hc->sin_remote.sin_family = AF_INET; in l1oip_socket_thread()
672 hc->sin_remote.sin_addr.s_addr = htonl(hc->remoteip); in l1oip_socket_thread()
673 hc->sin_remote.sin_port = htons((unsigned short)hc->remoteport); in l1oip_socket_thread()
676 if (socket->ops->bind(socket, (struct sockaddr *)&hc->sin_local, in l1oip_socket_thread()
677 sizeof(hc->sin_local))) { in l1oip_socket_thread()
678 printk(KERN_ERR "%s: Failed to bind socket to port %d.\n", in l1oip_socket_thread()
679 __func__, hc->localport); in l1oip_socket_thread()
680 ret = -EINVAL; in l1oip_socket_thread()
685 if (socket->sk == NULL) { in l1oip_socket_thread()
686 printk(KERN_ERR "%s: socket->sk == NULL\n", __func__); in l1oip_socket_thread()
687 ret = -EIO; in l1oip_socket_thread()
692 hc->sendmsg.msg_name = &hc->sin_remote; in l1oip_socket_thread()
693 hc->sendmsg.msg_namelen = sizeof(hc->sin_remote); in l1oip_socket_thread()
694 hc->sendmsg.msg_control = NULL; in l1oip_socket_thread()
695 hc->sendmsg.msg_controllen = 0; in l1oip_socket_thread()
697 /* give away socket */ in l1oip_socket_thread()
698 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
699 hc->socket = socket; in l1oip_socket_thread()
700 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
704 printk(KERN_DEBUG "%s: socket created and open\n", in l1oip_socket_thread()
708 recvlen = sock_recvmsg(socket, &msg, 0); in l1oip_socket_thread()
714 "%s: broken pipe on socket\n", __func__); in l1oip_socket_thread()
718 /* get socket back, check first if in use, maybe by send function */ in l1oip_socket_thread()
719 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
720 /* if hc->socket is NULL, it is in use until it is given back */ in l1oip_socket_thread()
721 while (!hc->socket) { in l1oip_socket_thread()
722 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
724 spin_lock(&hc->socket_lock); in l1oip_socket_thread()
726 hc->socket = NULL; in l1oip_socket_thread()
727 spin_unlock(&hc->socket_lock); in l1oip_socket_thread()
730 printk(KERN_DEBUG "%s: socket thread terminating\n", in l1oip_socket_thread()
737 /* close socket */ in l1oip_socket_thread()
738 if (socket) in l1oip_socket_thread()
739 sock_release(socket); in l1oip_socket_thread()
742 complete(&hc->socket_complete); in l1oip_socket_thread()
743 hc->socket_thread = NULL; /* show termination of thread */ in l1oip_socket_thread()
746 printk(KERN_DEBUG "%s: socket thread terminated\n", in l1oip_socket_thread()
754 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_socket_close()
757 if (hc->socket_thread) { in l1oip_socket_close()
759 printk(KERN_DEBUG "%s: socket thread exists, " in l1oip_socket_close()
761 send_sig(SIGTERM, hc->socket_thread, 0); in l1oip_socket_close()
762 wait_for_completion(&hc->socket_complete); in l1oip_socket_close()
766 if (test_bit(FLG_ACTIVE, &dch->Flags)) { in l1oip_socket_close()
770 test_and_clear_bit(FLG_ACTIVE, &dch->Flags); in l1oip_socket_close()
771 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, in l1oip_socket_close()
782 init_completion(&hc->socket_complete); in l1oip_socket_open()
785 hc->socket_thread = kthread_run(l1oip_socket_thread, hc, "l1oip_%s", in l1oip_socket_open()
786 hc->name); in l1oip_socket_open()
787 if (IS_ERR(hc->socket_thread)) { in l1oip_socket_open()
788 int err = PTR_ERR(hc->socket_thread); in l1oip_socket_open()
789 printk(KERN_ERR "%s: Failed (%d) to create socket process.\n", in l1oip_socket_open()
791 hc->socket_thread = NULL; in l1oip_socket_open()
792 sock_release(hc->socket); in l1oip_socket_open()
796 printk(KERN_DEBUG "%s: socket thread created\n", __func__); in l1oip_socket_open()
811 /* send an empty l1oip frame at D-channel */ in l1oip_send_bh()
812 l1oip_socket_send(hc, 0, hc->d_idx, 0, 0, NULL, 0); in l1oip_send_bh()
824 schedule_work(&hc->workq); in l1oip_keepalive()
832 struct dchannel *dch = hc->chan[hc->d_idx].dch; in l1oip_timeout()
838 hc->timeout_on = 0; /* state that timer must be initialized next time */ in l1oip_timeout()
841 if (test_bit(FLG_ACTIVE, &dch->Flags)) { in l1oip_timeout()
845 test_and_clear_bit(FLG_ACTIVE, &dch->Flags); in l1oip_timeout()
846 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, in l1oip_timeout()
851 if (hc->ondemand) { in l1oip_timeout()
855 hc->sin_remote.sin_addr.s_addr = 0; in l1oip_timeout()
868 struct l1oip *hc = dch->hw; in handle_dmsg()
870 int ret = -EINVAL; in handle_dmsg()
874 switch (hh->prim) { in handle_dmsg()
876 if (skb->len < 1) { in handle_dmsg()
881 if (skb->len > MAX_DFRAME_LEN_L1 || skb->len > L1OIP_MAX_LEN) { in handle_dmsg()
887 p = skb->data; in handle_dmsg()
888 l = skb->len; in handle_dmsg()
895 l1oip_socket_send(hc, 0, dch->slot, 0, in handle_dmsg()
896 hc->chan[dch->slot].tx_counter++, p, ll); in handle_dmsg()
898 l -= ll; in handle_dmsg()
901 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); in handle_dmsg()
906 , __func__, dch->slot, hc->b_num + 1); in handle_dmsg()
908 if (test_bit(FLG_ACTIVE, &dch->Flags)) in handle_dmsg()
909 queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb); in handle_dmsg()
911 queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb); in handle_dmsg()
916 "(1..%d)\n", __func__, dch->slot, in handle_dmsg()
917 hc->b_num + 1); in handle_dmsg()
919 if (test_bit(FLG_ACTIVE, &dch->Flags)) in handle_dmsg()
920 queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb); in handle_dmsg()
922 queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb); in handle_dmsg()
934 struct l1oip *hc = dch->hw; in channel_dctrl()
936 switch (cq->op) { in channel_dctrl()
938 cq->op = MISDN_CTRL_SETPEER | MISDN_CTRL_UNSETPEER in channel_dctrl()
942 hc->remoteip = (u32)cq->p1; in channel_dctrl()
943 hc->remoteport = cq->p2 & 0xffff; in channel_dctrl()
944 hc->localport = cq->p2 >> 16; in channel_dctrl()
945 if (!hc->remoteport) in channel_dctrl()
946 hc->remoteport = hc->localport; in channel_dctrl()
956 hc->remoteip = 0; in channel_dctrl()
963 cq->p1 = hc->remoteip; in channel_dctrl()
964 cq->p2 = hc->remoteport | (hc->localport << 16); in channel_dctrl()
968 __func__, cq->op); in channel_dctrl()
969 ret = -EINVAL; in channel_dctrl()
980 dch->dev.id, __builtin_return_address(0)); in open_dchannel()
981 if (rq->protocol == ISDN_P_NONE) in open_dchannel()
982 return -EINVAL; in open_dchannel()
983 if ((dch->dev.D.protocol != ISDN_P_NONE) && in open_dchannel()
984 (dch->dev.D.protocol != rq->protocol)) { in open_dchannel()
987 __func__, dch->dev.D.protocol, rq->protocol); in open_dchannel()
989 if (dch->dev.D.protocol != rq->protocol) in open_dchannel()
990 dch->dev.D.protocol = rq->protocol; in open_dchannel()
992 if (test_bit(FLG_ACTIVE, &dch->Flags)) { in open_dchannel()
993 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY, in open_dchannel()
996 rq->ch = &dch->dev.D; in open_dchannel()
1008 if (!test_channelmap(rq->adr.channel, dch->dev.channelmap)) in open_bchannel()
1009 return -EINVAL; in open_bchannel()
1010 if (rq->protocol == ISDN_P_NONE) in open_bchannel()
1011 return -EINVAL; in open_bchannel()
1012 ch = rq->adr.channel; /* BRI: 1=B1 2=B2 PRI: 1..15,17.. */ in open_bchannel()
1013 bch = hc->chan[ch].bch; in open_bchannel()
1017 return -EINVAL; in open_bchannel()
1019 if (test_and_set_bit(FLG_OPEN, &bch->Flags)) in open_bchannel()
1020 return -EBUSY; /* b-channel can be only open once */ in open_bchannel()
1021 bch->ch.protocol = rq->protocol; in open_bchannel()
1022 rq->ch = &bch->ch; in open_bchannel()
1033 struct l1oip *hc = dch->hw; in l1oip_dctrl()
1037 if (dch->debug & DEBUG_HW) in l1oip_dctrl()
1043 switch (rq->protocol) { in l1oip_dctrl()
1046 if (hc->pri) { in l1oip_dctrl()
1047 err = -EINVAL; in l1oip_dctrl()
1054 if (!hc->pri) { in l1oip_dctrl()
1055 err = -EINVAL; in l1oip_dctrl()
1067 __func__, dch->dev.id, in l1oip_dctrl()
1075 if (dch->debug & DEBUG_HW) in l1oip_dctrl()
1078 err = -EINVAL; in l1oip_dctrl()
1087 struct l1oip *hc = bch->hw; in handle_bmsg()
1088 int ret = -EINVAL; in handle_bmsg()
1093 switch (hh->prim) { in handle_bmsg()
1095 if (skb->len <= 0) { in handle_bmsg()
1100 if (skb->len > MAX_DFRAME_LEN_L1 || skb->len > L1OIP_MAX_LEN) { in handle_bmsg()
1105 /* check for AIS / ulaw-silence */ in handle_bmsg()
1106 l = skb->len; in handle_bmsg()
1107 if (!memchr_inv(skb->data, 0xff, l)) { in handle_bmsg()
1111 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1113 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); in handle_bmsg()
1117 l = skb->len; in handle_bmsg()
1118 if (!memchr_inv(skb->data, 0x2a, l)) { in handle_bmsg()
1122 hc->chan[bch->slot].tx_counter += l; in handle_bmsg()
1124 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); in handle_bmsg()
1129 p = skb->data; in handle_bmsg()
1130 l = skb->len; in handle_bmsg()
1137 l1oip_socket_send(hc, hc->codec, bch->slot, 0, in handle_bmsg()
1138 hc->chan[bch->slot].tx_counter, p, ll); in handle_bmsg()
1139 hc->chan[bch->slot].tx_counter += ll; in handle_bmsg()
1141 l -= ll; in handle_bmsg()
1144 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); in handle_bmsg()
1149 , __func__, bch->slot, hc->b_num + 1); in handle_bmsg()
1150 hc->chan[bch->slot].codecstate = 0; in handle_bmsg()
1151 test_and_set_bit(FLG_ACTIVE, &bch->Flags); in handle_bmsg()
1153 queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb); in handle_bmsg()
1158 "(1..%d)\n", __func__, bch->slot, in handle_bmsg()
1159 hc->b_num + 1); in handle_bmsg()
1160 test_and_clear_bit(FLG_ACTIVE, &bch->Flags); in handle_bmsg()
1162 queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb); in handle_bmsg()
1175 (struct dsp_features *)(*((u_long *)&cq->p1)); in channel_bctrl()
1177 switch (cq->op) { in channel_bctrl()
1179 cq->op = MISDN_CTRL_HW_FEATURES_OP; in channel_bctrl()
1186 features->unclocked = 1; in channel_bctrl()
1187 features->unordered = 1; in channel_bctrl()
1191 __func__, cq->op); in channel_bctrl()
1192 ret = -EINVAL; in channel_bctrl()
1202 int err = -EINVAL; in l1oip_bctrl()
1204 if (bch->debug & DEBUG_HW) in l1oip_bctrl()
1209 test_and_clear_bit(FLG_OPEN, &bch->Flags); in l1oip_bctrl()
1210 test_and_clear_bit(FLG_ACTIVE, &bch->Flags); in l1oip_bctrl()
1211 ch->protocol = ISDN_P_NONE; in l1oip_bctrl()
1212 ch->peer = NULL; in l1oip_bctrl()
1235 if (timer_pending(&hc->keep_tl)) in release_card()
1236 del_timer(&hc->keep_tl); in release_card()
1238 if (timer_pending(&hc->timeout_tl)) in release_card()
1239 del_timer(&hc->timeout_tl); in release_card()
1241 cancel_work_sync(&hc->workq); in release_card()
1243 if (hc->socket_thread) in release_card()
1246 if (hc->registered && hc->chan[hc->d_idx].dch) in release_card()
1247 mISDN_unregister_device(&hc->chan[hc->d_idx].dch->dev); in release_card()
1249 if (hc->chan[ch].dch) { in release_card()
1250 mISDN_freedchannel(hc->chan[ch].dch); in release_card()
1251 kfree(hc->chan[ch].dch); in release_card()
1253 if (hc->chan[ch].bch) { in release_card()
1254 mISDN_freebchannel(hc->chan[ch].bch); in release_card()
1255 kfree(hc->chan[ch].bch); in release_card()
1257 dev_kfree_skb(hc->chan[ch].disorder_skb); in release_card()
1263 list_del(&hc->list); in release_card()
1292 spin_lock_init(&hc->socket_lock); in init_card()
1293 hc->idx = l1oip_cnt; in init_card()
1294 hc->pri = pri; in init_card()
1295 hc->d_idx = pri ? 16 : 3; in init_card()
1296 hc->b_num = pri ? 30 : 2; in init_card()
1297 hc->bundle = bundle; in init_card()
1298 if (hc->pri) in init_card()
1299 sprintf(hc->name, "l1oip-e1.%d", l1oip_cnt + 1); in init_card()
1301 sprintf(hc->name, "l1oip-s0.%d", l1oip_cnt + 1); in init_card()
1312 return -EINVAL; in init_card()
1314 hc->codec = codec[l1oip_cnt]; in init_card()
1317 __func__, hc->codec); in init_card()
1324 hc->id = id[l1oip_cnt]; in init_card()
1326 printk(KERN_DEBUG "%s: using id 0x%x\n", __func__, hc->id); in init_card()
1328 hc->ondemand = ondemand[l1oip_cnt]; in init_card()
1329 if (hc->ondemand && !hc->id) { in init_card()
1332 return -EINVAL; in init_card()
1336 hc->b_num = limit[l1oip_cnt]; in init_card()
1337 if (!pri && hc->b_num > 2) { in init_card()
1340 return -EINVAL; in init_card()
1342 if (pri && hc->b_num > 126) { in init_card()
1345 return -EINVAL; in init_card()
1347 if (pri && hc->b_num > 30) { in init_card()
1351 "supported by application.\n", hc->limit); in init_card()
1354 hc->remoteip = ip[l1oip_cnt << 2] << 24 in init_card()
1358 hc->localport = port[l1oip_cnt]?:(L1OIP_DEFAULTPORT + l1oip_cnt); in init_card()
1360 hc->remoteport = remoteport[l1oip_cnt]; in init_card()
1362 hc->remoteport = hc->localport; in init_card()
1366 hc->localport, hc->remoteip >> 24, in init_card()
1367 (hc->remoteip >> 16) & 0xff, in init_card()
1368 (hc->remoteip >> 8) & 0xff, hc->remoteip & 0xff, in init_card()
1369 hc->remoteport, hc->ondemand); in init_card()
1373 return -ENOMEM; in init_card()
1374 dch->debug = debug; in init_card()
1376 dch->hw = hc; in init_card()
1378 dch->dev.Dprotocols = (1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1); in init_card()
1380 dch->dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0); in init_card()
1381 dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | in init_card()
1383 dch->dev.D.send = handle_dmsg; in init_card()
1384 dch->dev.D.ctrl = l1oip_dctrl; in init_card()
1385 dch->dev.nrbchan = hc->b_num; in init_card()
1386 dch->slot = hc->d_idx; in init_card()
1387 hc->chan[hc->d_idx].dch = dch; in init_card()
1389 for (ch = 0; ch < dch->dev.nrbchan; ch++) { in init_card()
1396 return -ENOMEM; in init_card()
1398 bch->nr = i + ch; in init_card()
1399 bch->slot = i + ch; in init_card()
1400 bch->debug = debug; in init_card()
1402 bch->hw = hc; in init_card()
1403 bch->ch.send = handle_bmsg; in init_card()
1404 bch->ch.ctrl = l1oip_bctrl; in init_card()
1405 bch->ch.nr = i + ch; in init_card()
1406 list_add(&bch->ch.list, &dch->dev.bchannels); in init_card()
1407 hc->chan[i + ch].bch = bch; in init_card()
1408 set_channelmap(bch->nr, dch->dev.channelmap); in init_card()
1411 ret = mISDN_register_device(&dch->dev, NULL, hc->name); in init_card()
1414 hc->registered = 1; in init_card()
1423 timer_setup(&hc->keep_tl, l1oip_keepalive, 0); in init_card()
1424 hc->keep_tl.expires = jiffies + 2 * HZ; /* two seconds first time */ in init_card()
1425 add_timer(&hc->keep_tl); in init_card()
1427 timer_setup(&hc->timeout_tl, l1oip_timeout, 0); in init_card()
1428 hc->timeout_on = 0; /* state that we have timer off */ in init_card()
1440 printk(KERN_INFO "mISDN: Layer-1-over-IP driver Rev. %s\n", in l1oip_init()
1447 return -ENOMEM; in l1oip_init()
1472 return -EINVAL; in l1oip_init()
1478 bundle ? "bundled IP packet for all B-channels" : in l1oip_init()
1479 "separate IP packets for every B-channel"); in l1oip_init()
1483 printk(KERN_ERR "No kmem for L1-over-IP driver.\n"); in l1oip_init()
1485 return -ENOMEM; in l1oip_init()
1487 INIT_WORK(&hc->workq, (void *)l1oip_send_bh); in l1oip_init()
1490 list_add_tail(&hc->list, &l1oip_ilist); in l1oip_init()