mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Stezenbach <js@linuxtv.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [DVB patch 08/37] dvb_net: handle IPv6 and LLC/SNAP
Date: Sun, 08 May 2005 20:42:37 +0200	[thread overview]
Message-ID: <20050508184346.120434000@abc> (raw)
In-Reply-To: <20050508184229.957247000@abc>

[-- Attachment #1: dvb-core-dvb-net-ipv6-llcsnap.patch --]
[-- Type: text/plain, Size: 2802 bytes --]

handle IPv6 and LLC/SNAP (Bertrand Mazieres, Matthieu Castet, Johannes Stezenbach)

Signed-off-by: Johannes Stezenbach <js@linuxtv.org>
---

 drivers/media/dvb/dvb-core/dvb_net.c |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)

Index: linux-2.6.12-rc4/drivers/media/dvb/dvb-core/dvb_net.c
===================================================================
--- linux-2.6.12-rc4.orig/drivers/media/dvb/dvb-core/dvb_net.c	2005-05-08 16:10:01.000000000 +0200
+++ linux-2.6.12-rc4/drivers/media/dvb/dvb-core/dvb_net.c	2005-05-08 16:10:07.000000000 +0200
@@ -727,6 +727,7 @@ static void dvb_net_sec(struct net_devic
         u8 *eth;
         struct sk_buff *skb;
 	struct net_device_stats *stats = &(((struct dvb_net_priv *) dev->priv)->stats);
+	int snap = 0;
 
 	/* note: pkt_len includes a 32bit checksum */
 	if (pkt_len < 16) {
@@ -750,9 +751,12 @@ static void dvb_net_sec(struct net_devic
 		return;
 	}
 	if (pkt[5] & 0x02) {
-		//FIXME: handle LLC/SNAP
-                stats->rx_dropped++;
-                return;
+		/* handle LLC/SNAP, see rfc-1042 */
+		if (pkt_len < 24 || memcmp(&pkt[12], "\xaa\xaa\x03\0\0\0", 6)) {
+			stats->rx_dropped++;
+			return;
+		}
+		snap = 8;
         }
 	if (pkt[7]) {
 		/* FIXME: assemble datagram from multiple sections */
@@ -762,9 +766,9 @@ static void dvb_net_sec(struct net_devic
 	}
 
 	/* we have 14 byte ethernet header (ip header follows);
-	 * 12 byte MPE header; 4 byte checksum; + 2 byte alignment
+	 * 12 byte MPE header; 4 byte checksum; + 2 byte alignment, 8 byte LLC/SNAP
 	 */
-	if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2))) {
+	if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2 - snap))) {
 		//printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
 		stats->rx_dropped++;
 		return;
@@ -773,8 +777,8 @@ static void dvb_net_sec(struct net_devic
 	skb->dev = dev;
 
 	/* copy L3 payload */
-	eth = (u8 *) skb_put(skb, pkt_len - 12 - 4 + 14);
-	memcpy(eth + 14, pkt + 12, pkt_len - 12 - 4);
+	eth = (u8 *) skb_put(skb, pkt_len - 12 - 4 + 14 - snap);
+	memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap);
 
 	/* create ethernet header: */
         eth[0]=pkt[0x0b];
@@ -786,8 +790,21 @@ static void dvb_net_sec(struct net_devic
 
         eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0;
 
-	eth[12] = 0x08;	/* ETH_P_IP */
-	eth[13] = 0x00;
+	if (snap) {
+		eth[12] = pkt[18];
+		eth[13] = pkt[19];
+	} else {
+		/* protocol numbers are from rfc-1700 or
+		 * http://www.iana.org/assignments/ethernet-numbers
+		 */
+		if (pkt[12] >> 4 == 6) { /* version field from IP header */
+			eth[12] = 0x86;	/* IPv6 */
+			eth[13] = 0xdd;
+		} else {
+			eth[12] = 0x08;	/* IPv4 */
+			eth[13] = 0x00;
+		}
+	}
 
 	skb->protocol = dvb_net_eth_type_trans(skb, dev);
 

--


  parent reply	other threads:[~2005-05-08 19:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-08 18:42 [DVB patch 00/37] DVB updates for 2.6.12-rc4 Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 01/37] support for TT/Hauppauge Nexus-S Rev 2.3 Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 02/37] saa7146: no need to initialize static/global variables to 0 Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 03/37] dvb_frontend: fix module param Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 04/37] av7110: audio out fix Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 05/37] add support for KNC-1 cards Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 06/37] remove unnecessary casts in dvb-core Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 07/37] make dvb_class static Johannes Stezenbach
2005-05-08 18:42 ` Johannes Stezenbach [this message]
2005-05-08 18:42 ` [DVB patch 09/37] av7110: fix VIDEO_SET_DISPLAY_FORMAT Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 10/37] av7110: fix NTSC/PAL switching Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 11/37] av7110: fix comment Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 12/37] av7110: fix indentation Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 13/37] nxt6000: support frontend status reads Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 14/37] tda1004x: formatting cleanups Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 15/37] stv0299: fix FE_DISHNETWORK_SEND_LEGACY_CMD Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 16/37] remove unnecessary casts in frontends Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 17/37] dib3000: add NULL pointer check Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 18/37] ves1820: remove unnecessary msleep Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 19/37] mt352: embed struct mt352_config in mt352_state Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 20/37] tda1004x: dont use bitfields Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 21/37] tda1004x: allow N_I2C to be overridden by the card driver Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 22/37] tda10046: support for different firmware versions Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 23/37] dvb-pll.h: prevent multiple inclusion Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 24/37] make needlessly global code static or drop it Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 25/37] frontends: misc. minor cleanups Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 26/37] modified dvb_register_adapter() to avoid kmalloc/kfree Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 27/37] bt8xx: update documentation Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 28/37] DST: reorganize Twinhan DST driver to support CI Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 29/37] DST: add support for Twinhan 200103A Johannes Stezenbach
2005-05-08 18:42 ` [DVB patch 30/37] DST: fixed tuning problem Johannes Stezenbach
2005-05-08 18:43 ` [DVB patch 31/37] DST: fix for descrambling failure Johannes Stezenbach
2005-05-08 18:43 ` [DVB patch 32/37] DST: misc. fixes Johannes Stezenbach
2005-05-08 18:43 ` [DVB patch 33/37] bt8xx: updated documentation Johannes Stezenbach
2005-05-08 18:43 ` [DVB patch 34/37] DST: fix a bug in the module parameter Johannes Stezenbach
2005-05-08 18:43 ` [DVB patch 35/37] DST: fixed CI debug output Johannes Stezenbach
2005-05-08 18:43 ` [DVB patch 36/37] bt8xx: whitespace cleanup Johannes Stezenbach
2005-05-08 18:43 ` [DVB patch 37/37] budget-av: CI fixes Johannes Stezenbach
2005-05-10  1:04 ` [DVB patch 00/37] DVB updates for 2.6.12-rc4 Andrew Morton
2005-05-10  8:52   ` Johannes Stezenbach
2005-05-10  9:16     ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050508184346.120434000@abc \
    --to=js@linuxtv.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome