4 * Copyright (C) 2001 Convergence integrated media GmbH
5 * Ralph Metzler <ralph@convergence.de>
6 * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
8 * ULE Decapsulation code:
9 * Copyright (C) 2003, 2004 gcs - Global Communication & Services GmbH.
10 * and Department of Scientific Computing
11 * Paris Lodron University of Salzburg.
12 * Hilmar Linder <hlinder@cosy.sbg.ac.at>
13 * and Wolfram Stering <wstering@cosy.sbg.ac.at>
15 * ULE Decaps according to RFC 4326.
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 * To obtain the license, point your browser to
27 * http://www.gnu.org/copyleft/gpl.html
32 * Feb 2004: hl/ws v1: Implementing draft-fair-ipdvb-ule-01.txt
34 * Dec 2004: hl/ws v2: Implementing draft-ietf-ipdvb-ule-03.txt:
35 * ULE Extension header handling.
36 * Bugreports by Moritz Vieth and Hanno Tersteegen,
37 * Fraunhofer Institute for Open Communication Systems
38 * Competence Center for Advanced Satellite Communications.
39 * Bugfixes and robustness improvements.
40 * Filtering on dest MAC addresses, if present (D-Bit = 0)
41 * DVB_ULE_DEBUG compile-time option.
42 * Apr 2006: cp v3: Bugfixes and compliency with RFC 4326 (ULE) by
43 * Christian Praehauser <cpraehaus@cosy.sbg.ac.at>,
44 * Paris Lodron University of Salzburg.
48 * FIXME / TODO (dvb_net.c):
50 * Unloading does not work for 2.6.9 kernels: a refcount doesn't go to zero.
54 #define pr_fmt(fmt) "dvb_net: " fmt
56 #include <linux/module.h>
57 #include <linux/kernel.h>
58 #include <linux/netdevice.h>
59 #include <linux/nospec.h>
60 #include <linux/etherdevice.h>
61 #include <linux/dvb/net.h>
62 #include <linux/uio.h>
63 #include <linux/uaccess.h>
64 #include <linux/crc32.h>
65 #include <linux/mutex.h>
66 #include <linux/sched.h>
68 #include <media/dvb_demux.h>
69 #include <media/dvb_net.h>
71 static inline __u32 iov_crc32( __u32 c, struct kvec *iov, unsigned int cnt )
74 for (j = 0; j < cnt; j++)
75 c = crc32_be( c, iov[j].iov_base, iov[j].iov_len );
80 #define DVB_NET_MULTICAST_MAX 10
84 * The code inside DVB_ULE_DEBUG keeps a history of the
85 * last 100 TS cells processed.
87 static unsigned char ule_hist[100*TS_SZ] = { 0 };
88 static unsigned char *ule_where = ule_hist, ule_dump;
90 static void hexdump(const unsigned char *buf, unsigned short len)
92 print_hex_dump_debug("", DUMP_PREFIX_OFFSET, 16, 1, buf, len, true);
99 struct net_device *net;
100 struct dvb_net *host;
101 struct dmx_demux *demux;
102 struct dmx_section_feed *secfeed;
103 struct dmx_section_filter *secfilter;
104 struct dmx_ts_feed *tsfeed;
106 struct dmx_section_filter *multi_secfilter[DVB_NET_MULTICAST_MAX];
107 unsigned char multi_macs[DVB_NET_MULTICAST_MAX][6];
109 #define RX_MODE_UNI 0
110 #define RX_MODE_MULTI 1
111 #define RX_MODE_ALL_MULTI 2
112 #define RX_MODE_PROMISC 3
113 struct work_struct set_multicast_list_wq;
114 struct work_struct restart_net_feed_wq;
115 unsigned char feedtype; /* Either FEED_TYPE_ or FEED_TYPE_ULE */
116 int need_pusi; /* Set to 1, if synchronization on PUSI required. */
117 unsigned char tscc; /* TS continuity counter after sync on PUSI. */
118 struct sk_buff *ule_skb; /* ULE SNDU decodes into this buffer. */
119 unsigned char *ule_next_hdr; /* Pointer into skb to next ULE extension header. */
120 unsigned short ule_sndu_len; /* ULE SNDU length in bytes, w/o D-Bit. */
121 unsigned short ule_sndu_type; /* ULE SNDU type field, complete. */
122 unsigned char ule_sndu_type_1; /* ULE SNDU type field, if split across 2 TS cells. */
123 unsigned char ule_dbit; /* Whether the DestMAC address present
124 * or not (bit is set). */
125 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */
126 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */
127 unsigned long ts_count; /* Current ts cell counter. */
133 * Determine the packet's protocol ID. The rule here is that we
134 * assume 802.3 if the type field is short enough to be a length.
135 * This is normal practice and works for any 'now in use' protocol.
137 * stolen from eth.c out of the linux kernel, hacked for dvb-device
138 * by Michael Holzt <kju@debian.org>
140 static __be16 dvb_net_eth_type_trans(struct sk_buff *skb,
141 struct net_device *dev)
146 skb_reset_mac_header(skb);
147 skb_pull(skb,dev->hard_header_len);
150 if (*eth->h_dest & 1) {
151 if(ether_addr_equal(eth->h_dest,dev->broadcast))
152 skb->pkt_type=PACKET_BROADCAST;
154 skb->pkt_type=PACKET_MULTICAST;
157 if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN)
163 * This is a magic hack to spot IPX packets. Older Novell breaks
164 * the protocol design and runs IPX over 802.3 without an 802.2 LLC
165 * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
166 * won't work for fault tolerant netware but does for the rest.
168 if (*(unsigned short *)rawp == 0xFFFF)
169 return htons(ETH_P_802_3);
174 return htons(ETH_P_802_2);
185 /* ULE Extension Header handlers. */
188 #define ULE_BRIDGED 1
190 #define ULE_OPTEXTHDR_PADDING 0
192 static int ule_test_sndu( struct dvb_net_priv *p )
197 static int ule_bridged_sndu( struct dvb_net_priv *p )
199 struct ethhdr *hdr = (struct ethhdr*) p->ule_next_hdr;
200 if(ntohs(hdr->h_proto) < ETH_P_802_3_MIN) {
201 int framelen = p->ule_sndu_len - ((p->ule_next_hdr+sizeof(struct ethhdr)) - p->ule_skb->data);
202 /* A frame Type < ETH_P_802_3_MIN for a bridged frame, introduces a LLC Length field. */
203 if(framelen != ntohs(hdr->h_proto)) {
209 * "A bridged SNDU is a Mandatory Extension Header of Type 1.
210 * It must be the final (or only) extension header specified in the header chain of a SNDU."
211 * The 'ule_bridged' flag will cause the extension header processing loop to terminate.
217 static int ule_exthdr_padding(struct dvb_net_priv *p)
223 * Handle ULE extension headers.
224 * Function is called after a successful CRC32 verification of an ULE SNDU to complete its decoding.
225 * Returns: >= 0: nr. of bytes consumed by next extension header
226 * -1: Mandatory extension header that is not recognized or TEST SNDU; discard.
228 static int handle_one_ule_extension( struct dvb_net_priv *p )
230 /* Table of mandatory extension header handlers. The header type is the index. */
231 static int (*ule_mandatory_ext_handlers[255])( struct dvb_net_priv *p ) =
232 { [0] = ule_test_sndu, [1] = ule_bridged_sndu, [2] = NULL, };
234 /* Table of optional extension header handlers. The header type is the index. */
235 static int (*ule_optional_ext_handlers[255])( struct dvb_net_priv *p ) =
236 { [0] = ule_exthdr_padding, [1] = NULL, };
239 unsigned char hlen = (p->ule_sndu_type & 0x0700) >> 8;
240 unsigned char htype = p->ule_sndu_type & 0x00FF;
242 /* Discriminate mandatory and optional extension headers. */
244 /* Mandatory extension header */
245 if (ule_mandatory_ext_handlers[htype]) {
246 ext_len = ule_mandatory_ext_handlers[htype]( p );
248 p->ule_next_hdr += ext_len;
249 if (!p->ule_bridged) {
250 p->ule_sndu_type = ntohs(*(__be16 *)p->ule_next_hdr);
251 p->ule_next_hdr += 2;
253 p->ule_sndu_type = ntohs(*(__be16 *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN)));
254 /* This assures the extension handling loop will terminate. */
257 // else: extension handler failed or SNDU should be discarded
259 ext_len = -1; /* SNDU has to be discarded. */
261 /* Optional extension header. Calculate the length. */
263 /* Process the optional extension header according to its type. */
264 if (ule_optional_ext_handlers[htype])
265 (void)ule_optional_ext_handlers[htype]( p );
266 p->ule_next_hdr += ext_len;
267 p->ule_sndu_type = ntohs( *(__be16 *)(p->ule_next_hdr-2) );
269 * note: the length of the next header type is included in the
270 * length of THIS optional extension header
277 static int handle_ule_extensions( struct dvb_net_priv *p )
279 int total_ext_len = 0, l;
281 p->ule_next_hdr = p->ule_skb->data;
283 l = handle_one_ule_extension( p );
285 return l; /* Stop extension header processing and discard SNDU. */
287 pr_debug("ule_next_hdr=%p, ule_sndu_type=%i, l=%i, total_ext_len=%i\n",
288 p->ule_next_hdr, (int)p->ule_sndu_type,
291 } while (p->ule_sndu_type < ETH_P_802_3_MIN);
293 return total_ext_len;
297 /* Prepare for a new ULE SNDU: reset the decoder state. */
298 static inline void reset_ule( struct dvb_net_priv *p )
301 p->ule_next_hdr = NULL;
303 p->ule_sndu_type = 0;
304 p->ule_sndu_type_1 = 0;
305 p->ule_sndu_remain = 0;
311 * Decode ULE SNDUs according to draft-ietf-ipdvb-ule-03.txt from a sequence of
312 * TS cells of a single PID.
315 struct dvb_net_ule_handle {
316 struct net_device *dev;
317 struct dvb_net_priv *priv;
321 unsigned long skipped;
322 const u8 *ts, *ts_end, *from_where;
323 u8 ts_remain, how_much, new_ts;
327 static int dvb_net_ule_new_ts_cell(struct dvb_net_ule_handle *h)
329 /* We are about to process a new TS cell. */
332 if (ule_where >= &ule_hist[100*TS_SZ])
333 ule_where = ule_hist;
334 memcpy(ule_where, h->ts, TS_SZ);
336 hexdump(ule_where, TS_SZ);
343 * Check TS h->error conditions: sync_byte, transport_error_indicator,
344 * scrambling_control .
346 if ((h->ts[0] != TS_SYNC) || (h->ts[1] & TS_TEI) ||
347 ((h->ts[3] & TS_SC) != 0)) {
348 pr_warn("%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n",
349 h->priv->ts_count, h->ts[0],
350 (h->ts[1] & TS_TEI) >> 7,
351 (h->ts[3] & TS_SC) >> 6);
353 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
354 if (h->priv->ule_skb) {
355 dev_kfree_skb(h->priv->ule_skb);
356 /* Prepare for next SNDU. */
357 h->dev->stats.rx_errors++;
358 h->dev->stats.rx_frame_errors++;
361 h->priv->need_pusi = 1;
363 /* Continue with next TS cell. */
370 h->from_where = h->ts + 4;
375 static int dvb_net_ule_ts_pusi(struct dvb_net_ule_handle *h)
377 if (h->ts[1] & TS_PUSI) {
378 /* Find beginning of first ULE SNDU in current TS cell. */
379 /* Synchronize continuity counter. */
380 h->priv->tscc = h->ts[3] & 0x0F;
381 /* There is a pointer field here. */
382 if (h->ts[4] > h->ts_remain) {
383 pr_err("%lu: Invalid ULE packet (pointer field %d)\n",
384 h->priv->ts_count, h->ts[4]);
389 /* Skip to destination of pointer field. */
390 h->from_where = &h->ts[5] + h->ts[4];
391 h->ts_remain -= 1 + h->ts[4];
403 static int dvb_net_ule_new_ts(struct dvb_net_ule_handle *h)
405 /* Check continuity counter. */
406 if ((h->ts[3] & 0x0F) == h->priv->tscc)
407 h->priv->tscc = (h->priv->tscc + 1) & 0x0F;
409 /* TS discontinuity handling: */
410 pr_warn("%lu: TS discontinuity: got %#x, expected %#x.\n",
411 h->priv->ts_count, h->ts[3] & 0x0F,
413 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
414 if (h->priv->ule_skb) {
415 dev_kfree_skb(h->priv->ule_skb);
416 /* Prepare for next SNDU. */
417 // reset_ule(h->priv); moved to below.
418 h->dev->stats.rx_errors++;
419 h->dev->stats.rx_frame_errors++;
422 /* skip to next PUSI. */
423 h->priv->need_pusi = 1;
427 * If we still have an incomplete payload, but PUSI is
428 * set; some TS cells are missing.
429 * This is only possible here, if we missed exactly 16 TS
430 * cells (continuity counter wrap).
432 if (h->ts[1] & TS_PUSI) {
433 if (!h->priv->need_pusi) {
434 if (!(*h->from_where < (h->ts_remain-1)) ||
435 *h->from_where != h->priv->ule_sndu_remain) {
437 * Pointer field is invalid.
438 * Drop this TS cell and any started ULE SNDU.
440 pr_warn("%lu: Invalid pointer field: %u.\n",
445 * Drop partly decoded SNDU, reset state,
448 if (h->priv->ule_skb) {
450 dev_kfree_skb(h->priv->ule_skb);
453 if (h->error || h->priv->ule_sndu_remain) {
454 h->dev->stats.rx_errors++;
455 h->dev->stats.rx_frame_errors++;
460 h->priv->need_pusi = 1;
464 * Skip pointer field (we're processing a
470 h->priv->need_pusi = 0;
472 if (h->priv->ule_sndu_remain > 183) {
474 * Current SNDU lacks more data than there
475 * could be available in the current TS cell.
477 h->dev->stats.rx_errors++;
478 h->dev->stats.rx_length_errors++;
479 pr_warn("%lu: Expected %d more SNDU bytes, but got PUSI (pf %d, h->ts_remain %d). Flushing incomplete payload.\n",
481 h->priv->ule_sndu_remain,
482 h->ts[4], h->ts_remain);
483 dev_kfree_skb(h->priv->ule_skb);
484 /* Prepare for next SNDU. */
487 * Resync: go to where pointer field points to:
488 * start of next ULE SNDU.
490 h->from_where += h->ts[4];
491 h->ts_remain -= h->ts[4];
499 * Start a new payload with skb.
500 * Find ULE header. It is only guaranteed that the
501 * length field (2 bytes) is contained in the current
503 * Check h.ts_remain has to be >= 2 here.
505 static int dvb_net_ule_new_payload(struct dvb_net_ule_handle *h)
507 if (h->ts_remain < 2) {
508 pr_warn("Invalid payload packing: only %d bytes left in TS. Resyncing.\n",
510 h->priv->ule_sndu_len = 0;
511 h->priv->need_pusi = 1;
516 if (!h->priv->ule_sndu_len) {
517 /* Got at least two bytes, thus extrace the SNDU length. */
518 h->priv->ule_sndu_len = h->from_where[0] << 8 |
520 if (h->priv->ule_sndu_len & 0x8000) {
521 /* D-Bit is set: no dest mac present. */
522 h->priv->ule_sndu_len &= 0x7FFF;
523 h->priv->ule_dbit = 1;
525 h->priv->ule_dbit = 0;
527 if (h->priv->ule_sndu_len < 5) {
528 pr_warn("%lu: Invalid ULE SNDU length %u. Resyncing.\n",
530 h->priv->ule_sndu_len);
531 h->dev->stats.rx_errors++;
532 h->dev->stats.rx_length_errors++;
533 h->priv->ule_sndu_len = 0;
534 h->priv->need_pusi = 1;
540 h->ts_remain -= 2; /* consume the 2 bytes SNDU length. */
544 h->priv->ule_sndu_remain = h->priv->ule_sndu_len + 2;
546 * State of current TS:
547 * h->ts_remain (remaining bytes in the current TS cell)
548 * 0 ule_type is not available now, we need the next TS cell
549 * 1 the first byte of the ule_type is present
550 * >=2 full ULE header present, maybe some payload data as well.
552 switch (h->ts_remain) {
554 h->priv->ule_sndu_remain--;
555 h->priv->ule_sndu_type = h->from_where[0] << 8;
557 /* first byte of ule_type is set. */
558 h->priv->ule_sndu_type_1 = 1;
568 default: /* complete ULE header is present in current TS. */
569 /* Extract ULE type field. */
570 if (h->priv->ule_sndu_type_1) {
571 h->priv->ule_sndu_type_1 = 0;
572 h->priv->ule_sndu_type |= h->from_where[0];
573 h->from_where += 1; /* points to payload start. */
576 /* Complete type is present in new TS. */
577 h->priv->ule_sndu_type = h->from_where[0] << 8 |
579 h->from_where += 2; /* points to payload start. */
586 * Allocate the skb (decoder target buffer) with the correct size,
589 * prepare for the largest case: bridged SNDU with MAC address
592 h->priv->ule_skb = dev_alloc_skb(h->priv->ule_sndu_len +
593 ETH_HLEN + ETH_ALEN);
594 if (!h->priv->ule_skb) {
595 pr_notice("%s: Memory squeeze, dropping packet.\n",
597 h->dev->stats.rx_dropped++;
601 /* This includes the CRC32 _and_ dest mac, if !dbit. */
602 h->priv->ule_sndu_remain = h->priv->ule_sndu_len;
603 h->priv->ule_skb->dev = h->dev;
605 * Leave space for Ethernet or bridged SNDU header
606 * (eth hdr plus one MAC addr).
608 skb_reserve(h->priv->ule_skb, ETH_HLEN + ETH_ALEN);
614 static int dvb_net_ule_should_drop(struct dvb_net_ule_handle *h)
616 static const u8 bc_addr[ETH_ALEN] = { [0 ... ETH_ALEN - 1] = 0xff };
619 * The destination MAC address is the next data in the skb. It comes
620 * before any extension headers.
622 * Check if the payload of this SNDU should be passed up the stack.
624 if (h->priv->rx_mode == RX_MODE_PROMISC)
627 if (h->priv->ule_skb->data[0] & 0x01) {
628 /* multicast or broadcast */
629 if (!ether_addr_equal(h->priv->ule_skb->data, bc_addr)) {
631 if (h->priv->rx_mode == RX_MODE_MULTI) {
634 for (i = 0; i < h->priv->multi_num &&
635 !ether_addr_equal(h->priv->ule_skb->data,
636 h->priv->multi_macs[i]);
639 if (i == h->priv->multi_num)
641 } else if (h->priv->rx_mode != RX_MODE_ALL_MULTI)
642 return 1; /* no broadcast; */
645 * all multicast mode: accept all multicast packets
648 /* else: broadcast */
649 } else if (!ether_addr_equal(h->priv->ule_skb->data, h->dev->dev_addr))
656 static void dvb_net_ule_check_crc(struct dvb_net_ule_handle *h,
658 u32 ule_crc, u32 expected_crc)
660 u8 dest_addr[ETH_ALEN];
662 if (ule_crc != expected_crc) {
663 pr_warn("%lu: CRC32 check FAILED: %08x / %08x, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
664 h->priv->ts_count, ule_crc, expected_crc,
665 h->priv->ule_sndu_len, h->priv->ule_sndu_type,
668 *(unsigned short *)h->from_where : 0);
671 hexdump(iov[0].iov_base, iov[0].iov_len);
672 hexdump(iov[1].iov_base, iov[1].iov_len);
673 hexdump(iov[2].iov_base, iov[2].iov_len);
675 if (ule_where == ule_hist) {
676 hexdump(&ule_hist[98*TS_SZ], TS_SZ);
677 hexdump(&ule_hist[99*TS_SZ], TS_SZ);
678 } else if (ule_where == &ule_hist[TS_SZ]) {
679 hexdump(&ule_hist[99*TS_SZ], TS_SZ);
680 hexdump(ule_hist, TS_SZ);
682 hexdump(ule_where - TS_SZ - TS_SZ, TS_SZ);
683 hexdump(ule_where - TS_SZ, TS_SZ);
688 h->dev->stats.rx_errors++;
689 h->dev->stats.rx_crc_errors++;
690 dev_kfree_skb(h->priv->ule_skb);
695 /* CRC32 verified OK. */
697 /* CRC32 was OK, so remove it from skb. */
698 h->priv->ule_skb->tail -= 4;
699 h->priv->ule_skb->len -= 4;
701 if (!h->priv->ule_dbit) {
702 if (dvb_net_ule_should_drop(h)) {
704 "Dropping SNDU: MAC destination address does not match: dest addr: %pM, h->dev addr: %pM\n",
705 h->priv->ule_skb->data, h->dev->dev_addr);
706 dev_kfree_skb(h->priv->ule_skb);
710 skb_copy_from_linear_data(h->priv->ule_skb, dest_addr,
712 skb_pull(h->priv->ule_skb, ETH_ALEN);
714 /* dest_addr buffer is only valid if h->priv->ule_dbit == 0 */
715 eth_zero_addr(dest_addr);
718 /* Handle ULE Extension Headers. */
719 if (h->priv->ule_sndu_type < ETH_P_802_3_MIN) {
720 /* There is an extension header. Handle it accordingly. */
721 int l = handle_ule_extensions(h->priv);
725 * Mandatory extension header unknown or TEST SNDU.
729 // pr_warn("Dropping SNDU, extension headers.\n" );
730 dev_kfree_skb(h->priv->ule_skb);
733 skb_pull(h->priv->ule_skb, l);
737 * Construct/assure correct ethernet header.
738 * Note: in bridged mode (h->priv->ule_bridged != 0)
739 * we already have the (original) ethernet
740 * header at the start of the payload (after
741 * optional dest. address and any extension
744 if (!h->priv->ule_bridged) {
745 skb_push(h->priv->ule_skb, ETH_HLEN);
746 h->ethh = (struct ethhdr *)h->priv->ule_skb->data;
747 memcpy(h->ethh->h_dest, dest_addr, ETH_ALEN);
748 eth_zero_addr(h->ethh->h_source);
749 h->ethh->h_proto = htons(h->priv->ule_sndu_type);
751 /* else: skb is in correct state; nothing to do. */
752 h->priv->ule_bridged = 0;
754 /* Stuff into kernel's protocol stack. */
755 h->priv->ule_skb->protocol = dvb_net_eth_type_trans(h->priv->ule_skb,
758 * If D-bit is set (i.e. destination MAC address not present),
759 * receive the packet anyhow.
762 if (h->priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST)
763 h->priv->ule_skb->pkt_type = PACKET_HOST;
765 h->dev->stats.rx_packets++;
766 h->dev->stats.rx_bytes += h->priv->ule_skb->len;
767 netif_rx(h->priv->ule_skb);
770 static void dvb_net_ule(struct net_device *dev, const u8 *buf, size_t buf_len)
773 struct dvb_net_ule_handle h = {
775 .priv = netdev_priv(dev),
790 * For all TS cells in current buffer.
791 * Appearently, we are called for every single TS cell.
793 for (h.ts = h.buf, h.ts_end = h.buf + h.buf_len;
794 h.ts < h.ts_end; /* no incr. */) {
796 /* We are about to process a new TS cell. */
797 if (dvb_net_ule_new_ts_cell(&h))
801 /* Synchronize on PUSI, if required. */
802 if (h.priv->need_pusi) {
803 if (dvb_net_ule_ts_pusi(&h))
808 if (dvb_net_ule_new_ts(&h))
812 /* Check if new payload needs to be started. */
813 if (h.priv->ule_skb == NULL) {
814 ret = dvb_net_ule_new_payload(&h);
821 /* Copy data into our current skb. */
822 h.how_much = min(h.priv->ule_sndu_remain, (int)h.ts_remain);
823 skb_put_data(h.priv->ule_skb, h.from_where, h.how_much);
824 h.priv->ule_sndu_remain -= h.how_much;
825 h.ts_remain -= h.how_much;
826 h.from_where += h.how_much;
828 /* Check for complete payload. */
829 if (h.priv->ule_sndu_remain <= 0) {
830 /* Check CRC32, we've got it in our skb already. */
831 __be16 ulen = htons(h.priv->ule_sndu_len);
832 __be16 utype = htons(h.priv->ule_sndu_type);
834 struct kvec iov[3] = {
835 { &ulen, sizeof ulen },
836 { &utype, sizeof utype },
837 { h.priv->ule_skb->data,
838 h.priv->ule_skb->len - 4 }
840 u32 ule_crc = ~0L, expected_crc;
841 if (h.priv->ule_dbit) {
842 /* Set D-bit for CRC32 verification,
843 * if it was set originally. */
844 ulen |= htons(0x8000);
847 ule_crc = iov_crc32(ule_crc, iov, 3);
848 tail = skb_tail_pointer(h.priv->ule_skb);
849 expected_crc = *(tail - 4) << 24 |
854 dvb_net_ule_check_crc(&h, iov, ule_crc, expected_crc);
856 /* Prepare for next SNDU. */
860 /* More data in current TS (look at the bytes following the CRC32)? */
861 if (h.ts_remain >= 2 && *((unsigned short *)h.from_where) != 0xFFFF) {
862 /* Next ULE SNDU starts right there. */
864 h.priv->ule_skb = NULL;
865 h.priv->ule_sndu_type_1 = 0;
866 h.priv->ule_sndu_len = 0;
867 // pr_warn("More data in current TS: [%#x %#x %#x %#x]\n",
868 // *(h.from_where + 0), *(h.from_where + 1),
869 // *(h.from_where + 2), *(h.from_where + 3));
870 // pr_warn("h.ts @ %p, stopped @ %p:\n", h.ts, h.from_where + 0);
871 // hexdump(h.ts, 188);
876 if (h.priv->ule_skb == NULL) {
877 h.priv->need_pusi = 1;
878 h.priv->ule_sndu_type_1 = 0;
879 h.priv->ule_sndu_len = 0;
882 } /* for all available TS cells */
885 static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
886 const u8 *buffer2, size_t buffer2_len,
887 struct dmx_ts_feed *feed,
890 struct net_device *dev = feed->priv;
893 pr_warn("buffer2 not NULL: %p.\n", buffer2);
894 if (buffer1_len > 32768)
895 pr_warn("length > 32k: %zu.\n", buffer1_len);
896 /* pr_info("TS callback: %u bytes, %u TS cells @ %p.\n",
897 buffer1_len, buffer1_len / TS_SZ, buffer1); */
898 dvb_net_ule(dev, buffer1, buffer1_len);
903 static void dvb_net_sec(struct net_device *dev,
904 const u8 *pkt, int pkt_len)
908 struct net_device_stats *stats = &dev->stats;
911 /* note: pkt_len includes a 32bit checksum */
913 pr_warn("%s: IP/MPE packet length = %d too small.\n",
916 stats->rx_length_errors++;
919 /* it seems some ISPs manage to screw up here, so we have to
920 * relax the error checks... */
922 if ((pkt[5] & 0xfd) != 0xc1) {
923 /* drop scrambled or broken packets */
925 if ((pkt[5] & 0x3c) != 0x00) {
929 stats->rx_crc_errors++;
933 /* handle LLC/SNAP, see rfc-1042 */
934 if (pkt_len < 24 || memcmp(&pkt[12], "\xaa\xaa\x03\0\0\0", 6)) {
941 /* FIXME: assemble datagram from multiple sections */
943 stats->rx_frame_errors++;
947 /* we have 14 byte ethernet header (ip header follows);
948 * 12 byte MPE header; 4 byte checksum; + 2 byte alignment, 8 byte LLC/SNAP
950 if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2 - snap))) {
951 //pr_notice("%s: Memory squeeze, dropping packet.\n", dev->name);
955 skb_reserve(skb, 2); /* longword align L3 header */
958 /* copy L3 payload */
959 eth = skb_put(skb, pkt_len - 12 - 4 + 14 - snap);
960 memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap);
962 /* create ethernet header: */
970 eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0;
976 /* protocol numbers are from rfc-1700 or
977 * http://www.iana.org/assignments/ethernet-numbers
979 if (pkt[12] >> 4 == 6) { /* version field from IP header */
980 eth[12] = 0x86; /* IPv6 */
983 eth[12] = 0x08; /* IPv4 */
988 skb->protocol = dvb_net_eth_type_trans(skb, dev);
991 stats->rx_bytes+=skb->len;
995 static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len,
996 const u8 *buffer2, size_t buffer2_len,
997 struct dmx_section_filter *filter, u32 *buffer_flags)
999 struct net_device *dev = filter->priv;
1002 * we rely on the DVB API definition where exactly one complete
1003 * section is delivered in buffer1
1005 dvb_net_sec (dev, buffer1, buffer1_len);
1009 static netdev_tx_t dvb_net_tx(struct sk_buff *skb, struct net_device *dev)
1012 return NETDEV_TX_OK;
1015 static u8 mask_normal[6]={0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1016 static u8 mask_allmulti[6]={0xff, 0xff, 0xff, 0x00, 0x00, 0x00};
1017 static u8 mac_allmulti[6]={0x01, 0x00, 0x5e, 0x00, 0x00, 0x00};
1018 static u8 mask_promisc[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1020 static int dvb_net_filter_sec_set(struct net_device *dev,
1021 struct dmx_section_filter **secfilter,
1022 u8 *mac, u8 *mac_mask)
1024 struct dvb_net_priv *priv = netdev_priv(dev);
1028 ret = priv->secfeed->allocate_filter(priv->secfeed, secfilter);
1030 pr_err("%s: could not get filter\n", dev->name);
1034 (*secfilter)->priv=(void *) dev;
1036 memset((*secfilter)->filter_value, 0x00, DMX_MAX_FILTER_SIZE);
1037 memset((*secfilter)->filter_mask, 0x00, DMX_MAX_FILTER_SIZE);
1038 memset((*secfilter)->filter_mode, 0xff, DMX_MAX_FILTER_SIZE);
1040 (*secfilter)->filter_value[0]=0x3e;
1041 (*secfilter)->filter_value[3]=mac[5];
1042 (*secfilter)->filter_value[4]=mac[4];
1043 (*secfilter)->filter_value[8]=mac[3];
1044 (*secfilter)->filter_value[9]=mac[2];
1045 (*secfilter)->filter_value[10]=mac[1];
1046 (*secfilter)->filter_value[11]=mac[0];
1048 (*secfilter)->filter_mask[0] = 0xff;
1049 (*secfilter)->filter_mask[3] = mac_mask[5];
1050 (*secfilter)->filter_mask[4] = mac_mask[4];
1051 (*secfilter)->filter_mask[8] = mac_mask[3];
1052 (*secfilter)->filter_mask[9] = mac_mask[2];
1053 (*secfilter)->filter_mask[10] = mac_mask[1];
1054 (*secfilter)->filter_mask[11]=mac_mask[0];
1056 netdev_dbg(dev, "filter mac=%pM mask=%pM\n", mac, mac_mask);
1061 static int dvb_net_feed_start(struct net_device *dev)
1064 struct dvb_net_priv *priv = netdev_priv(dev);
1065 struct dmx_demux *demux = priv->demux;
1066 unsigned char *mac = (unsigned char *) dev->dev_addr;
1068 netdev_dbg(dev, "rx_mode %i\n", priv->rx_mode);
1069 mutex_lock(&priv->mutex);
1070 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
1071 pr_err("%s: BUG %d\n", __func__, __LINE__);
1074 priv->secfilter=NULL;
1075 priv->tsfeed = NULL;
1077 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
1078 netdev_dbg(dev, "alloc secfeed\n");
1079 ret=demux->allocate_section_feed(demux, &priv->secfeed,
1080 dvb_net_sec_callback);
1082 pr_err("%s: could not allocate section feed\n",
1087 ret = priv->secfeed->set(priv->secfeed, priv->pid, 1);
1090 pr_err("%s: could not set section feed\n", dev->name);
1091 priv->demux->release_section_feed(priv->demux, priv->secfeed);
1096 if (priv->rx_mode != RX_MODE_PROMISC) {
1097 netdev_dbg(dev, "set secfilter\n");
1098 dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_normal);
1101 switch (priv->rx_mode) {
1103 for (i = 0; i < priv->multi_num; i++) {
1104 netdev_dbg(dev, "set multi_secfilter[%d]\n", i);
1105 dvb_net_filter_sec_set(dev, &priv->multi_secfilter[i],
1106 priv->multi_macs[i], mask_normal);
1109 case RX_MODE_ALL_MULTI:
1111 netdev_dbg(dev, "set multi_secfilter[0]\n");
1112 dvb_net_filter_sec_set(dev, &priv->multi_secfilter[0],
1113 mac_allmulti, mask_allmulti);
1115 case RX_MODE_PROMISC:
1117 netdev_dbg(dev, "set secfilter\n");
1118 dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_promisc);
1122 netdev_dbg(dev, "start filtering\n");
1123 priv->secfeed->start_filtering(priv->secfeed);
1124 } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) {
1125 ktime_t timeout = ns_to_ktime(10 * NSEC_PER_MSEC);
1127 /* we have payloads encapsulated in TS */
1128 netdev_dbg(dev, "alloc tsfeed\n");
1129 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback);
1131 pr_err("%s: could not allocate ts feed\n", dev->name);
1135 /* Set netdevice pointer for ts decaps callback. */
1136 priv->tsfeed->priv = (void *)dev;
1137 ret = priv->tsfeed->set(priv->tsfeed,
1138 priv->pid, /* pid */
1139 TS_PACKET, /* type */
1140 DMX_PES_OTHER, /* pes type */
1141 timeout /* timeout */
1145 pr_err("%s: could not set ts feed\n", dev->name);
1146 priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
1147 priv->tsfeed = NULL;
1151 netdev_dbg(dev, "start filtering\n");
1152 priv->tsfeed->start_filtering(priv->tsfeed);
1157 mutex_unlock(&priv->mutex);
1161 static int dvb_net_feed_stop(struct net_device *dev)
1163 struct dvb_net_priv *priv = netdev_priv(dev);
1166 mutex_lock(&priv->mutex);
1167 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
1168 if (priv->secfeed) {
1169 if (priv->secfeed->is_filtering) {
1170 netdev_dbg(dev, "stop secfeed\n");
1171 priv->secfeed->stop_filtering(priv->secfeed);
1174 if (priv->secfilter) {
1175 netdev_dbg(dev, "release secfilter\n");
1176 priv->secfeed->release_filter(priv->secfeed,
1178 priv->secfilter=NULL;
1181 for (i=0; i<priv->multi_num; i++) {
1182 if (priv->multi_secfilter[i]) {
1183 netdev_dbg(dev, "release multi_filter[%d]\n",
1185 priv->secfeed->release_filter(priv->secfeed,
1186 priv->multi_secfilter[i]);
1187 priv->multi_secfilter[i] = NULL;
1191 priv->demux->release_section_feed(priv->demux, priv->secfeed);
1192 priv->secfeed = NULL;
1194 pr_err("%s: no feed to stop\n", dev->name);
1195 } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) {
1197 if (priv->tsfeed->is_filtering) {
1198 netdev_dbg(dev, "stop tsfeed\n");
1199 priv->tsfeed->stop_filtering(priv->tsfeed);
1201 priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
1202 priv->tsfeed = NULL;
1205 pr_err("%s: no ts feed to stop\n", dev->name);
1208 mutex_unlock(&priv->mutex);
1213 static int dvb_set_mc_filter(struct net_device *dev, unsigned char *addr)
1215 struct dvb_net_priv *priv = netdev_priv(dev);
1217 if (priv->multi_num == DVB_NET_MULTICAST_MAX)
1220 memcpy(priv->multi_macs[priv->multi_num], addr, ETH_ALEN);
1227 static void wq_set_multicast_list (struct work_struct *work)
1229 struct dvb_net_priv *priv =
1230 container_of(work, struct dvb_net_priv, set_multicast_list_wq);
1231 struct net_device *dev = priv->net;
1233 dvb_net_feed_stop(dev);
1234 priv->rx_mode = RX_MODE_UNI;
1235 netif_addr_lock_bh(dev);
1237 if (dev->flags & IFF_PROMISC) {
1238 netdev_dbg(dev, "promiscuous mode\n");
1239 priv->rx_mode = RX_MODE_PROMISC;
1240 } else if ((dev->flags & IFF_ALLMULTI)) {
1241 netdev_dbg(dev, "allmulti mode\n");
1242 priv->rx_mode = RX_MODE_ALL_MULTI;
1243 } else if (!netdev_mc_empty(dev)) {
1244 struct netdev_hw_addr *ha;
1246 netdev_dbg(dev, "set_mc_list, %d entries\n",
1247 netdev_mc_count(dev));
1249 priv->rx_mode = RX_MODE_MULTI;
1250 priv->multi_num = 0;
1252 netdev_for_each_mc_addr(ha, dev)
1253 dvb_set_mc_filter(dev, ha->addr);
1256 netif_addr_unlock_bh(dev);
1257 dvb_net_feed_start(dev);
1261 static void dvb_net_set_multicast_list (struct net_device *dev)
1263 struct dvb_net_priv *priv = netdev_priv(dev);
1264 schedule_work(&priv->set_multicast_list_wq);
1268 static void wq_restart_net_feed (struct work_struct *work)
1270 struct dvb_net_priv *priv =
1271 container_of(work, struct dvb_net_priv, restart_net_feed_wq);
1272 struct net_device *dev = priv->net;
1274 if (netif_running(dev)) {
1275 dvb_net_feed_stop(dev);
1276 dvb_net_feed_start(dev);
1281 static int dvb_net_set_mac (struct net_device *dev, void *p)
1283 struct dvb_net_priv *priv = netdev_priv(dev);
1284 struct sockaddr *addr=p;
1286 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
1288 if (netif_running(dev))
1289 schedule_work(&priv->restart_net_feed_wq);
1295 static int dvb_net_open(struct net_device *dev)
1297 struct dvb_net_priv *priv = netdev_priv(dev);
1300 dvb_net_feed_start(dev);
1305 static int dvb_net_stop(struct net_device *dev)
1307 struct dvb_net_priv *priv = netdev_priv(dev);
1310 return dvb_net_feed_stop(dev);
1313 static const struct header_ops dvb_header_ops = {
1314 .create = eth_header,
1315 .parse = eth_header_parse,
1319 static const struct net_device_ops dvb_netdev_ops = {
1320 .ndo_open = dvb_net_open,
1321 .ndo_stop = dvb_net_stop,
1322 .ndo_start_xmit = dvb_net_tx,
1323 .ndo_set_rx_mode = dvb_net_set_multicast_list,
1324 .ndo_set_mac_address = dvb_net_set_mac,
1325 .ndo_validate_addr = eth_validate_addr,
1328 static void dvb_net_setup(struct net_device *dev)
1332 dev->header_ops = &dvb_header_ops;
1333 dev->netdev_ops = &dvb_netdev_ops;
1335 dev->max_mtu = 4096;
1337 dev->flags |= IFF_NOARP;
1340 static int get_if(struct dvb_net *dvbnet)
1344 for (i=0; i<DVB_NET_DEVICES_MAX; i++)
1345 if (!dvbnet->state[i])
1348 if (i == DVB_NET_DEVICES_MAX)
1355 static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1357 struct net_device *net;
1358 struct dvb_net_priv *priv;
1362 if (feedtype != DVB_NET_FEEDTYPE_MPE && feedtype != DVB_NET_FEEDTYPE_ULE)
1364 if ((if_num = get_if(dvbnet)) < 0)
1367 net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb",
1368 NET_NAME_UNKNOWN, dvb_net_setup);
1372 if (dvbnet->dvbdev->id)
1373 snprintf(net->name, IFNAMSIZ, "dvb%d%u%d",
1374 dvbnet->dvbdev->adapter->num, dvbnet->dvbdev->id, if_num);
1376 /* compatibility fix to keep dvb0_0 format */
1377 snprintf(net->name, IFNAMSIZ, "dvb%d_%d",
1378 dvbnet->dvbdev->adapter->num, if_num);
1381 memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
1383 dvbnet->device[if_num] = net;
1385 priv = netdev_priv(net);
1387 priv->demux = dvbnet->demux;
1389 priv->rx_mode = RX_MODE_UNI;
1390 priv->need_pusi = 1;
1392 priv->feedtype = feedtype;
1395 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list);
1396 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed);
1397 mutex_init(&priv->mutex);
1399 net->base_addr = pid;
1401 if ((result = register_netdev(net)) < 0) {
1402 dvbnet->device[if_num] = NULL;
1406 pr_info("created network interface %s\n", net->name);
1411 static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num)
1413 struct net_device *net = dvbnet->device[num];
1414 struct dvb_net_priv *priv;
1416 if (!dvbnet->state[num])
1418 priv = netdev_priv(net);
1423 flush_work(&priv->set_multicast_list_wq);
1424 flush_work(&priv->restart_net_feed_wq);
1425 pr_info("removed network interface %s\n", net->name);
1426 unregister_netdev(net);
1427 dvbnet->state[num]=0;
1428 dvbnet->device[num] = NULL;
1434 static int dvb_net_do_ioctl(struct file *file,
1435 unsigned int cmd, void *parg)
1437 struct dvb_device *dvbdev = file->private_data;
1438 struct dvb_net *dvbnet = dvbdev->priv;
1441 if (((file->f_flags&O_ACCMODE)==O_RDONLY))
1444 if (mutex_lock_interruptible(&dvbnet->ioctl_mutex))
1445 return -ERESTARTSYS;
1450 struct dvb_net_if *dvbnetif = parg;
1453 if (!capable(CAP_SYS_ADMIN)) {
1458 if (!try_module_get(dvbdev->adapter->module)) {
1463 result=dvb_net_add_if(dvbnet, dvbnetif->pid, dvbnetif->feedtype);
1465 module_put(dvbdev->adapter->module);
1469 dvbnetif->if_num=result;
1474 struct net_device *netdev;
1475 struct dvb_net_priv *priv_data;
1476 struct dvb_net_if *dvbnetif = parg;
1477 int if_num = dvbnetif->if_num;
1479 if (if_num >= DVB_NET_DEVICES_MAX) {
1483 if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX);
1485 if (!dvbnet->state[if_num]) {
1490 netdev = dvbnet->device[if_num];
1492 priv_data = netdev_priv(netdev);
1493 dvbnetif->pid=priv_data->pid;
1494 dvbnetif->feedtype=priv_data->feedtype;
1499 if (!capable(CAP_SYS_ADMIN)) {
1503 if ((unsigned long) parg >= DVB_NET_DEVICES_MAX) {
1507 ret = dvb_net_remove_if(dvbnet, (unsigned long) parg);
1509 module_put(dvbdev->adapter->module);
1513 /* binary compatibility cruft */
1514 case __NET_ADD_IF_OLD:
1516 struct __dvb_net_if_old *dvbnetif = parg;
1519 if (!capable(CAP_SYS_ADMIN)) {
1524 if (!try_module_get(dvbdev->adapter->module)) {
1529 result=dvb_net_add_if(dvbnet, dvbnetif->pid, DVB_NET_FEEDTYPE_MPE);
1531 module_put(dvbdev->adapter->module);
1535 dvbnetif->if_num=result;
1538 case __NET_GET_IF_OLD:
1540 struct net_device *netdev;
1541 struct dvb_net_priv *priv_data;
1542 struct __dvb_net_if_old *dvbnetif = parg;
1543 int if_num = dvbnetif->if_num;
1545 if (if_num >= DVB_NET_DEVICES_MAX) {
1549 if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX);
1551 if (!dvbnet->state[if_num]) {
1556 netdev = dvbnet->device[if_num];
1558 priv_data = netdev_priv(netdev);
1559 dvbnetif->pid=priv_data->pid;
1568 mutex_unlock(&dvbnet->ioctl_mutex);
1572 static long dvb_net_ioctl(struct file *file,
1573 unsigned int cmd, unsigned long arg)
1575 return dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
1578 static int locked_dvb_net_open(struct inode *inode, struct file *file)
1580 struct dvb_device *dvbdev = file->private_data;
1581 struct dvb_net *dvbnet = dvbdev->priv;
1584 if (mutex_lock_interruptible(&dvbnet->remove_mutex))
1585 return -ERESTARTSYS;
1588 mutex_unlock(&dvbnet->remove_mutex);
1592 ret = dvb_generic_open(inode, file);
1594 mutex_unlock(&dvbnet->remove_mutex);
1599 static int dvb_net_close(struct inode *inode, struct file *file)
1601 struct dvb_device *dvbdev = file->private_data;
1602 struct dvb_net *dvbnet = dvbdev->priv;
1604 mutex_lock(&dvbnet->remove_mutex);
1606 dvb_generic_release(inode, file);
1608 if (dvbdev->users == 1 && dvbnet->exit == 1) {
1609 mutex_unlock(&dvbnet->remove_mutex);
1610 wake_up(&dvbdev->wait_queue);
1612 mutex_unlock(&dvbnet->remove_mutex);
1619 static const struct file_operations dvb_net_fops = {
1620 .owner = THIS_MODULE,
1621 .unlocked_ioctl = dvb_net_ioctl,
1622 .open = locked_dvb_net_open,
1623 .release = dvb_net_close,
1624 .llseek = noop_llseek,
1627 static const struct dvb_device dvbdev_net = {
1631 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
1634 .fops = &dvb_net_fops,
1637 void dvb_net_release (struct dvb_net *dvbnet)
1641 mutex_lock(&dvbnet->remove_mutex);
1643 mutex_unlock(&dvbnet->remove_mutex);
1645 if (dvbnet->dvbdev->users < 1)
1646 wait_event(dvbnet->dvbdev->wait_queue,
1647 dvbnet->dvbdev->users == 1);
1649 dvb_unregister_device(dvbnet->dvbdev);
1651 for (i=0; i<DVB_NET_DEVICES_MAX; i++) {
1652 if (!dvbnet->state[i])
1654 dvb_net_remove_if(dvbnet, i);
1657 EXPORT_SYMBOL(dvb_net_release);
1660 int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,
1661 struct dmx_demux *dmx)
1665 mutex_init(&dvbnet->ioctl_mutex);
1666 mutex_init(&dvbnet->remove_mutex);
1667 dvbnet->demux = dmx;
1669 for (i=0; i<DVB_NET_DEVICES_MAX; i++)
1670 dvbnet->state[i] = 0;
1672 return dvb_register_device(adap, &dvbnet->dvbdev, &dvbdev_net,
1673 dvbnet, DVB_DEVICE_NET, 0);
1675 EXPORT_SYMBOL(dvb_net_init);