* Re: [PATCH 00/21] clean up rx_copybreak handling [split version]
From: Joe Perches @ 2011-07-09 18:20 UTC (permalink / raw)
To: Michał Mirosław
Cc: netdev, Steffen Klassert, Santiago Leon, Tim Hockin, Don Fry,
Francois Romieu, Ion Badulescu, Matt Carlson, Michael Chan,
Grant Grundler, David Dillow, Roger Luethi, David S. Miller
In-Reply-To: <cover.1310229312.git.mirq-linux@rere.qmqm.pl>
On Sat, 2011-07-09 at 19:17 +0200, Michał Mirosław wrote:
> Split version of rx_copybreak cleanup patch.
Hello Michał.
Looks good, thanks for doing this work.
One style quibble.
You use this style:
+ skb = dev_skb_finish_rx_dma(&np->rx_skbuff[entry],
+ pkt_len, rx_copybreak,
+ &np->pci_dev->dev,
+ le32_to_cpu(desc->frag[0].addr),
+ np->rx_buf_sz);
where almost all other uses throughout drivers/net
align arguments to open parenthesis instead.
+ skb = dev_skb_finish_rx_dma(&np->rx_skbuff[entry],
+ pkt_len, rx_copybreak,
+ &np->pci_dev->dev,
+ le32_to_cpu(desc->frag[0].addr),
+ np->rx_buf_sz);
^ permalink raw reply
* Re: [PATCH] natsemi: silence dma-debug warnings
From: Jim Cromie @ 2011-07-09 20:11 UTC (permalink / raw)
To: David Miller; +Cc: fujita.tomonori, thockin, netdev
In-Reply-To: <20110703.223448.458910310802724750.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 641 bytes --]
On Sun, Jul 3, 2011 at 11:34 PM, David Miller <davem@davemloft.net> wrote:
> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> Date: Mon, 4 Jul 2011 14:30:19 +0900
>
>> This silences dma-debug warnings:
>>
>> https://lkml.org/lkml/2011/6/30/341
> ...
>> Reported-by: Jim Cromie <jim.cromie@gmail.com>
>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>> Tested-by: Jim Cromie <jim.cromie@gmail.com>
>
> Applied, thanks!
>
I have since seen a similar warning on shutdown,
heres a patch for it.
theres one other callsite, but I havent seen the warning from it,
will try to tickle it at some point.
[-- Attachment #2: 0001-natsemi-fix-another-dma-debug-report.patch --]
[-- Type: text/x-patch, Size: 3026 bytes --]
From 2d81b28645b22100271bdbe2d6859cb49a49166d Mon Sep 17 00:00:00 2001
From: Jim Cromie <jim.cromie@gmail.com>
Date: Sat, 9 Jul 2011 11:44:38 -0600
Subject: [PATCH 1/3] natsemi: fix another dma-debug report
commit 2fb83cd618be34546fb526a9051eceaa95517026
Author: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Date: Sun Jul 3 22:34:29 2011 -0700
Above commit fixed previously reported warning, but I later
noticed another one at shutdown. This commit fixes it.
Theres one other callsite to pci_unmap_single, but I havent seen
it report a problem, so havent included it here.
------------[ cut here ]------------
WARNING: at /home/jimc/projects/lx/linux-2.6/lib/dma-debug.c:820 check_unmap+0x1fe/0x56c()
natsemi 0000:00:06.0: DMA-API: device driver frees DMA memory with different size [device address=0x0000000007356840] [map size=1538 bytes] [unmap size=1522 bytes]
Modules linked in: bridge stp llc x_tables ipv6 pc87360 hwmon_vid scx200_hrt pc8736x_gpio scx200_gpio nsc_gpio scx200_acb i2c_core arc4 rtl8180 mac80211 eeprom_93cx6 cfg80211 pcspkr scx200 rfkill ide_gd_mod ide_pci_generic ohci_hcd usbcore sc1200 ide_core [last unloaded: ebtables]
Pid: 3996, comm: ifconfig Not tainted 3.0.0-rc6-skc-dyndbg+ #104
Call Trace:
[<c011ca97>] warn_slowpath_common+0x4a/0x5f
[<c0261ca5>] ? check_unmap+0x1fe/0x56c
[<c011cb10>] warn_slowpath_fmt+0x26/0x2a
[<c0261ca5>] check_unmap+0x1fe/0x56c
[<c0116505>] ? check_preempt_curr+0x5a/0x6a
[<c0262186>] debug_dma_unmap_page+0x53/0x5b
[<c02aaaf9>] pci_unmap_single+0x4d/0x57
[<c02aab51>] drain_rx+0x4e/0x74
[<c02acc6e>] netdev_close+0x103/0x1b8
[<c02f097e>] ? spin_unlock_bh.clone.30+0x12/0x14
[<c02f10aa>] ? dev_deactivate_many+0xc1/0xef
[<c02e05e9>] __dev_close_many+0x69/0x86
[<c02e0625>] __dev_close+0x1f/0x2c
[<c02e3200>] __dev_change_flags+0x92/0x107
[<c02e32db>] dev_change_flags+0x13/0x3f
[<c031e7ea>] devinet_ioctl+0x248/0x4b3
[<c02e3a9e>] ? dev_ioctl+0x50a/0x54c
[<c031f509>] inet_ioctl+0x8e/0xa7
[<c02d506f>] sock_ioctl+0x1b6/0x1da
[<c02d4eb9>] ? sock_fasync+0x61/0x61
[<c0183db4>] do_vfs_ioctl+0x44d/0x47f
[<c0113cdb>] ? do_page_fault+0x268/0x299
[<c01339d0>] ? __put_cred+0x34/0x36
[<c0177d83>] ? sys_faccessat+0x13e/0x14b
[<c0183e14>] sys_ioctl+0x2e/0x4a
[<c035bc95>] syscall_call+0x7/0xb
---[ end trace 7013a1bdac403e56 ]---
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
drivers/net/natsemi.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 8f8b65a..e4bd202 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -2028,8 +2028,8 @@ static void drain_rx(struct net_device *dev)
np->rx_ring[i].cmd_status = 0;
np->rx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid address. */
if (np->rx_skbuff[i]) {
- pci_unmap_single(np->pci_dev,
- np->rx_dma[i], buflen,
+ pci_unmap_single(np->pci_dev, np->rx_dma[i],
+ buflen + NATSEMI_PADDING,
PCI_DMA_FROMDEVICE);
dev_kfree_skb(np->rx_skbuff[i]);
}
--
1.7.4.1
^ permalink raw reply related
* [PATCH 7/7] drivers/net: static should be at beginning of declaration
From: Jesper Juhl @ 2011-07-09 21:24 UTC (permalink / raw)
To: linux-kernel
Cc: trivial, Greg Kroah-Hartman, linux-usb, netdev, David S. Miller,
Marius Bjoernstad Kotsbak
In-Reply-To: <alpine.LNX.2.00.1107092304160.25516@swampdragon.chaosbits.net>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1973 bytes --]
Make sure that the 'static' keywork is at the beginning of declaration
for drivers/net/usb/kalmia.c
This gets rid of warnings like
warning: ‘static’ is not at beginning of declaration
when building with -Wold-style-declaration (and/or -Wextra which also
enables it).
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
drivers/net/usb/kalmia.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c
index a9b6c63..5a6d0f8 100644
--- a/drivers/net/usb/kalmia.c
+++ b/drivers/net/usb/kalmia.c
@@ -100,13 +100,13 @@ kalmia_send_init_packet(struct usbnet *dev, u8 *init_msg, u8 init_msg_len,
static int
kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr)
{
- const static char init_msg_1[] =
+ static const char init_msg_1[] =
{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
0x00, 0x00 };
- const static char init_msg_2[] =
+ static const char init_msg_2[] =
{ 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4,
0x00, 0x00 };
- const static int buflen = 28;
+ static const int buflen = 28;
char *usb_buf;
int status;
@@ -239,11 +239,11 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
* Our task here is to strip off framing, leaving skb with one
* data frame for the usbnet framework code to process.
*/
- const static u8 HEADER_END_OF_USB_PACKET[] =
+ static const u8 HEADER_END_OF_USB_PACKET[] =
{ 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 };
- const static u8 EXPECTED_UNKNOWN_HEADER_1[] =
+ static const u8 EXPECTED_UNKNOWN_HEADER_1[] =
{ 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 };
- const static u8 EXPECTED_UNKNOWN_HEADER_2[] =
+ static const u8 EXPECTED_UNKNOWN_HEADER_2[] =
{ 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 };
int i = 0;
--
1.7.6
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related
* Re: [PATCH 20/21] net: via-velocity: use common rx_copybreak handling
From: Francois Romieu @ 2011-07-09 22:19 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev
In-Reply-To: <fde4e58b4575124aaa9878ea2329dcb3445c50f0.1310229312.git.mirq-linux@rere.qmqm.pl>
Michał Mirosław <mirq-linux@rere.qmqm.pl> :
[...]
> diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
> index f929242..cdc51de 100644
> --- a/drivers/net/via-velocity.c
> +++ b/drivers/net/via-velocity.c
[...]
> @@ -2027,10 +1996,10 @@ static int velocity_rx_copy(struct sk_buff **rx_skb, int pkt_size,
> * configured by the user.
> */
> static inline void velocity_iph_realign(struct velocity_info *vptr,
> - struct sk_buff *skb, int pkt_size)
> + struct sk_buff *skb)
> {
> if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
> - memmove(skb->data + 2, skb->data, pkt_size);
> + memmove(skb->data + 2, skb->data, skb->len);
> skb_reserve(skb, 2);
> }
> }
[...]
> @@ -2078,30 +2044,25 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
> }
> }
>
> - pci_action = pci_dma_sync_single_for_device;
> + skb = dev_skb_finish_rx_dma(&rd_info->skb,
> + pkt_len - ETH_FCS_LEN, rx_copybreak,
> + &vptr->pdev->dev, rd_info->skb_dma, vptr->rx.buf_sz);
> + if (!skb)
> + /* not copied */
> + velocity_iph_realign(vptr, skb);
s/if (!skb)/if (!rd_info->skb)/ ?
--
Ueimor
^ permalink raw reply
* Re: [PATCH 02/21] net: 3c59x: use common rx_copybreak handling
From: Francois Romieu @ 2011-07-09 22:22 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev, Steffen Klassert
In-Reply-To: <5a242c5dbd6222d87b77a22b9c6fe6cdfa0351f3.1310229312.git.mirq-linux@rere.qmqm.pl>
Michał Mirosław <mirq-linux@rere.qmqm.pl> :
[...]
> diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
> index 8cc2256..456726c 100644
> --- a/drivers/net/3c59x.c
> +++ b/drivers/net/3c59x.c
[...]
> + skb = dev_skb_finish_rx_dma(&vp->rx_skbuff[entry],
> + pkt_len, rx_copybreak,
> + &VORTEX_PCI(vp)->dev, dma, PKT_BUF_SZ);
> + if (skb)
s/if (skb)/if (vp->rx_skbuff[entry])/ probably
--
Ueimor
^ permalink raw reply
* Re: [PATCH 07/21] net: lib82596: use common rx_copybreak handling [strict refill!]
From: Francois Romieu @ 2011-07-09 22:25 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev
In-Reply-To: <041aed2721ea22ee6e7d122c3c21a59b4042f431.1310229312.git.mirq-linux@rere.qmqm.pl>
Michał Mirosław <mirq-linux@rere.qmqm.pl> :
[...]
> diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
> index 9e04289..d19e05b 100644
> --- a/drivers/net/lib82596.c
> +++ b/drivers/net/lib82596.c
> @@ -679,67 +679,29 @@ static inline int i596_rx(struct net_device *dev)
> if (rbd != NULL && (rfd->stat & SWAP16(STAT_OK))) {
> /* a good frame */
> int pkt_len = SWAP16(rbd->count) & 0x3fff;
> - struct sk_buff *skb = rbd->skb;
> - int rx_in_place = 0;
> + struct sk_buff *skb;
> + dma_addr_t dma_addr;
>
> DEB(DEB_RXADDR, print_eth(rbd->v_data, "received"));
> frames++;
>
> - /* Check if the packet is long enough to just accept
> - * without copying to a properly sized skbuff.
> - */
> + dma_addr = SWAP32(rbd->b_data);
> + skb = dev_skb_finish_rx_dma_refill(&rbd->skb,
> + pkt_len, rx_copybreak, NET_IP_ALIGN, 0,
> + dev->dev.parent, &dma_addr, PKT_BUF_SZ);
[...]
> + if (likely(skb)) {
s/skb/rbd->skb/
--
Ueimor
^ permalink raw reply
* Re: [PATCH 09/21] net: pcnet32: use common rx_copybreak handling [strict refill!]
From: Francois Romieu @ 2011-07-09 22:28 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev, Don Fry
In-Reply-To: <0f270b4469acf1db6e18025c7097f6e4e338ad5d.1310229312.git.mirq-linux@rere.qmqm.pl>
Michał Mirosław <mirq-linux@rere.qmqm.pl> :
[...]
> diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
> index 8b3090d..baae404 100644
> --- a/drivers/net/pcnet32.c
> +++ b/drivers/net/pcnet32.c
> @@ -1147,51 +1146,18 @@ static void pcnet32_rx_entry(struct net_device *dev,
> return;
> }
>
> - if (pkt_len > rx_copybreak) {
> - struct sk_buff *newskb;
> -
> - newskb = dev_alloc_skb(PKT_BUF_SKB);
> - if (newskb) {
> - skb_reserve(newskb, NET_IP_ALIGN);
> - skb = lp->rx_skbuff[entry];
> - pci_unmap_single(lp->pci_dev,
> - lp->rx_dma_addr[entry],
> - PKT_BUF_SIZE,
> - PCI_DMA_FROMDEVICE);
> - skb_put(skb, pkt_len);
> - lp->rx_skbuff[entry] = newskb;
> - lp->rx_dma_addr[entry] =
> - pci_map_single(lp->pci_dev,
> - newskb->data,
> - PKT_BUF_SIZE,
> - PCI_DMA_FROMDEVICE);
> - rxp->base = cpu_to_le32(lp->rx_dma_addr[entry]);
> - rx_in_place = 1;
> - } else
> - skb = NULL;
> - } else
> - skb = dev_alloc_skb(pkt_len + NET_IP_ALIGN);
> + skb = dev_skb_finish_rx_dma_refill(&lp->rx_skbuff[entry],
> + pkt_len, rx_copybreak, NET_IP_ALIGN, 0,
> + &lp->pci_dev->dev, &lp->rx_dma_addr[entry],
> + PKT_BUF_SIZE);
> + rxp->base = cpu_to_le32(lp->rx_dma_addr[entry]);
>
> if (skb == NULL) {
s/skb/lp->rx_skbuff[entry]/
--
Ueimor
^ permalink raw reply
* Re: [PATCH 15/21] net: tulip/de2104x: use common rx_copybreak handling [strict refill!]
From: Francois Romieu @ 2011-07-09 22:31 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev, Grant Grundler
In-Reply-To: <29374e542d6211f31b9ed0571a60b795f4aed1bb.1310229312.git.mirq-linux@rere.qmqm.pl>
Michał Mirosław <mirq-linux@rere.qmqm.pl> :
[...]
> diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
> index ce90efc..80a34b6 100644
> --- a/drivers/net/tulip/de2104x.c
> +++ b/drivers/net/tulip/de2104x.c
> @@ -432,42 +431,22 @@ static void de_rx (struct de_private *de)
> goto rx_next;
> }
>
> - copying_skb = (len <= rx_copybreak);
> -
> netif_dbg(de, rx_status, de->dev,
> "rx slot %d status 0x%x len %d copying? %d\n",
> - rx_tail, status, len, copying_skb);
> + rx_tail, status, len, len <= rx_copybreak);
>
> - buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz;
> - copy_skb = dev_alloc_skb (buflen);
> - if (unlikely(!copy_skb)) {
> + skb = dev_skb_finish_rx_dma_refill(&de->rx_skb[rx_tail].skb,
> + len, rx_copybreak, 0, RX_OFFSET,
> + &de->pdev->dev, &mapping, de->rx_buf_sz);
> + de->rx_skb[rx_tail].mapping = mapping;
> +
> + if (unlikely(!skb)) {
s/skb/de->rx_skb[rx_tail].skb/
--
Ueimor
^ permalink raw reply
* Re: [PATCH 02/21] net: 3c59x: use common rx_copybreak handling
From: Michał Mirosław @ 2011-07-09 23:23 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, Steffen Klassert
In-Reply-To: <20110709222258.GA5642@electric-eye.fr.zoreil.com>
On Sun, Jul 10, 2011 at 12:22:58AM +0200, Francois Romieu wrote:
> Michał Mirosław <mirq-linux@rere.qmqm.pl> :
> [...]
> > diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
> > index 8cc2256..456726c 100644
> > --- a/drivers/net/3c59x.c
> > +++ b/drivers/net/3c59x.c
> [...]
> > + skb = dev_skb_finish_rx_dma(&vp->rx_skbuff[entry],
> > + pkt_len, rx_copybreak,
> > + &VORTEX_PCI(vp)->dev, dma, PKT_BUF_SZ);
> > + if (skb)
> s/if (skb)/if (vp->rx_skbuff[entry])/ probably
For this driver and via-velocity - you're right (fixed). For others no -
they always refill the rx ring, possibly discarding the packet.
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [PATCH] natsemi: silence dma-debug warnings
From: Jim Cromie @ 2011-07-10 1:45 UTC (permalink / raw)
To: FUJITA Tomonori; +Cc: davem, thockin, netdev
In-Reply-To: <20110710.102039.1305564732068163396.fujita.tomonori@lab.ntt.co.jp>
On Sat, Jul 9, 2011 at 7:20 PM, FUJITA Tomonori
<fujita.tomonori@lab.ntt.co.jp> wrote:
> On Sat, 9 Jul 2011 14:11:25 -0600
> Jim Cromie <jim.cromie@gmail.com> wrote:
>
>> On Sun, Jul 3, 2011 at 11:34 PM, David Miller <davem@davemloft.net> wrote:
>>> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>> Date: Mon, 4 Jul 2011 14:30:19 +0900
>>>
>>>> This silences dma-debug warnings:
>>>>
>>>> https://lkml.org/lkml/2011/6/30/341
>>> ...
>>>> Reported-by: Jim Cromie <jim.cromie@gmail.com>
>>>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>>> Tested-by: Jim Cromie <jim.cromie@gmail.com>
>>>
>>> Applied, thanks!
>>>
>>
>> I have since seen a similar warning on shutdown,
>> heres a patch for it.
>
> Oops, I noticed this too but I forgot to send a patch.
>
> The patch looks good to me.
>
>
>> theres one other callsite, but I havent seen the warning from it,
>> will try to tickle it at some point.
>
> Which pci_unmap_single are you talking about?
>
2131 static void netdev_tx_done(struct net_device *dev)
2132 {
...
2160 pci_unmap_single(np->pci_dev,np->tx_dma[entry],
2161 np->tx_skbuff[entry]->len,
2162 PCI_DMA_TODEVICE);
^ permalink raw reply
* Re: [PATCH] natsemi: silence dma-debug warnings
From: FUJITA Tomonori @ 2011-07-10 1:57 UTC (permalink / raw)
To: jim.cromie; +Cc: davem, thockin, netdev
In-Reply-To: <CAJfuBxxs=CEBV+v+8GkYyabVobhwiXKYc5qHhZE-ZKFxywkQaQ@mail.gmail.com>
On Sat, 9 Jul 2011 19:45:22 -0600
Jim Cromie <jim.cromie@gmail.com> wrote:
> On Sat, Jul 9, 2011 at 7:20 PM, FUJITA Tomonori
> <fujita.tomonori@lab.ntt.co.jp> wrote:
>> On Sat, 9 Jul 2011 14:11:25 -0600
>> Jim Cromie <jim.cromie@gmail.com> wrote:
>>
>>> On Sun, Jul 3, 2011 at 11:34 PM, David Miller <davem@davemloft.net> wrote:
>>>> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>>> Date: Mon, 4 Jul 2011 14:30:19 +0900
>>>>
>>>>> This silences dma-debug warnings:
>>>>>
>>>>> https://lkml.org/lkml/2011/6/30/341
>>>> ...
>>>>> Reported-by: Jim Cromie <jim.cromie@gmail.com>
>>>>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>>>> Tested-by: Jim Cromie <jim.cromie@gmail.com>
>>>>
>>>> Applied, thanks!
>>>>
>>>
>>> I have since seen a similar warning on shutdown,
>>> heres a patch for it.
>>
>> Oops, I noticed this too but I forgot to send a patch.
>>
>> The patch looks good to me.
>>
>>
>>> theres one other callsite, but I havent seen the warning from it,
>>> will try to tickle it at some point.
>>
>> Which pci_unmap_single are you talking about?
>>
>
>
> 2131 static void netdev_tx_done(struct net_device *dev)
> 2132 {
> ...
> 2160 pci_unmap_single(np->pci_dev,np->tx_dma[entry],
> 2161 np->tx_skbuff[entry]->len,
> 2162 PCI_DMA_TODEVICE);
It's pci_unmap_single call for tx_dma buffers. We fixed
pci_unmap_single calls for rx_dma buffers.
Looks like the driver correctlly uses pci_map_single and
pci_unmap_single for tx_dma buffers.
^ permalink raw reply
* Re: [PATCH] natsemi: silence dma-debug warnings
From: FUJITA Tomonori @ 2011-07-10 1:20 UTC (permalink / raw)
To: jim.cromie; +Cc: davem, thockin, netdev
In-Reply-To: <CAJfuBxxKYNvaw5t4jWMP4+hYcw42SkwLiiahVdeezpfh6AsLBA@mail.gmail.com>
On Sat, 9 Jul 2011 14:11:25 -0600
Jim Cromie <jim.cromie@gmail.com> wrote:
> On Sun, Jul 3, 2011 at 11:34 PM, David Miller <davem@davemloft.net> wrote:
>> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>> Date: Mon, 4 Jul 2011 14:30:19 +0900
>>
>>> This silences dma-debug warnings:
>>>
>>> https://lkml.org/lkml/2011/6/30/341
>> ...
>>> Reported-by: Jim Cromie <jim.cromie@gmail.com>
>>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>> Tested-by: Jim Cromie <jim.cromie@gmail.com>
>>
>> Applied, thanks!
>>
>
> I have since seen a similar warning on shutdown,
> heres a patch for it.
Oops, I noticed this too but I forgot to send a patch.
The patch looks good to me.
> theres one other callsite, but I havent seen the warning from it,
> will try to tickle it at some point.
Which pci_unmap_single are you talking about?
^ permalink raw reply
* Re: [PATCH] natsemi: silence dma-debug warnings
From: Jim Cromie @ 2011-07-10 2:10 UTC (permalink / raw)
To: FUJITA Tomonori; +Cc: davem, thockin, netdev
In-Reply-To: <20110710.105730.1305564732068163754.fujita.tomonori@lab.ntt.co.jp>
>>> Which pci_unmap_single are you talking about?
>>>
>>
>>
>> 2131 static void netdev_tx_done(struct net_device *dev)
>> 2132 {
>> ...
>> 2160 pci_unmap_single(np->pci_dev,np->tx_dma[entry],
>> 2161 np->tx_skbuff[entry]->len,
>> 2162 PCI_DMA_TODEVICE);
>
> It's pci_unmap_single call for tx_dma buffers. We fixed
> pci_unmap_single calls for rx_dma buffers.
>
> Looks like the driver correctlly uses pci_map_single and
> pci_unmap_single for tx_dma buffers.
>
thanks for checking.
and oops, the one I was referring to was this one,
patched locally.
possible dma-debug error, unseen
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index e4bd202..0df7a47 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -2007,8 +2007,8 @@ static void drain_tx(struct net_device *dev)
for (i = 0; i < TX_RING_SIZE; i++) {
if (np->tx_skbuff[i]) {
- pci_unmap_single(np->pci_dev,
- np->tx_dma[i], np->tx_skbuff[i]->len,
+ pci_unmap_single(np->pci_dev, np->tx_dma[i],
+ np->tx_skbuff[i]->len + NATSEMI_PADDING,
PCI_DMA_TODEVICE);
dev_kfree_skb(np->tx_skbuff[i]);
dev->stats.tx_dropped++;
again, I havent seen a warning here,
either with or without this patch.
Given the wording of the warning (mismatch, ie > or <, not ==)
I presume I should get a warning if the PADDING is wrong here,
and I actually run this codepath ?
^ permalink raw reply related
* Re: [PATCH] natsemi: silence dma-debug warnings
From: FUJITA Tomonori @ 2011-07-10 2:18 UTC (permalink / raw)
To: jim.cromie; +Cc: davem, thockin, netdev
In-Reply-To: <CAJfuBxwhxhMpxBS6L7FANcqeyipjCR1cjhPraYVpOv55_weC6g@mail.gmail.com>
On Sat, 9 Jul 2011 20:10:17 -0600
Jim Cromie <jim.cromie@gmail.com> wrote:
>>>> Which pci_unmap_single are you talking about?
>>>>
>>>
>>>
>>> 2131 static void netdev_tx_done(struct net_device *dev)
>>> 2132 {
>>> ...
>>> 2160 pci_unmap_single(np->pci_dev,np->tx_dma[entry],
>>> 2161 np->tx_skbuff[entry]->len,
>>> 2162 PCI_DMA_TODEVICE);
>>
>> It's pci_unmap_single call for tx_dma buffers. We fixed
>> pci_unmap_single calls for rx_dma buffers.
>>
>> Looks like the driver correctlly uses pci_map_single and
>> pci_unmap_single for tx_dma buffers.
>>
>
> thanks for checking.
>
> and oops, the one I was referring to was this one,
> patched locally.
>
>
> possible dma-debug error, unseen
>
> diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
> index e4bd202..0df7a47 100644
> --- a/drivers/net/natsemi.c
> +++ b/drivers/net/natsemi.c
> @@ -2007,8 +2007,8 @@ static void drain_tx(struct net_device *dev)
>
> for (i = 0; i < TX_RING_SIZE; i++) {
> if (np->tx_skbuff[i]) {
> - pci_unmap_single(np->pci_dev,
> - np->tx_dma[i], np->tx_skbuff[i]->len,
> + pci_unmap_single(np->pci_dev, np->tx_dma[i],
> + np->tx_skbuff[i]->len + NATSEMI_PADDING,
> PCI_DMA_TODEVICE);
> dev_kfree_skb(np->tx_skbuff[i]);
> dev->stats.tx_dropped++;
>
> again, I havent seen a warning here,
> either with or without this patch.
>
> Given the wording of the warning (mismatch, ie > or <, not ==)
> I presume I should get a warning if the PADDING is wrong here,
> and I actually run this codepath ?
I don't think you run this code path. And as I wrote, the current code
looks correct.
^ permalink raw reply
* Re: [PATCH 02/21] net: 3c59x: use common rx_copybreak handling
From: Francois Romieu @ 2011-07-10 7:24 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev, Steffen Klassert
In-Reply-To: <20110709232339.GA15588@rere.qmqm.pl>
Michał Mirosław <mirq-linux@rere.qmqm.pl> :
[...]
> For this driver and via-velocity - you're right (fixed). For others no -
> they always refill the rx ring, possibly discarding the packet.
Ok, I completely missed the "_refill" part.
--
Ueimor
^ permalink raw reply
* Re: [PATCH] natsemi: silence dma-debug warnings
From: Michał Mirosław @ 2011-07-10 8:58 UTC (permalink / raw)
To: Jim Cromie; +Cc: David Miller, fujita.tomonori, thockin, netdev
In-Reply-To: <CAJfuBxxKYNvaw5t4jWMP4+hYcw42SkwLiiahVdeezpfh6AsLBA@mail.gmail.com>
2011/7/9 Jim Cromie <jim.cromie@gmail.com>:
> On Sun, Jul 3, 2011 at 11:34 PM, David Miller <davem@davemloft.net> wrote:
>> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>> Date: Mon, 4 Jul 2011 14:30:19 +0900
>>
>>> This silences dma-debug warnings:
>>>
>>> https://lkml.org/lkml/2011/6/30/341
>> ...
>>> Reported-by: Jim Cromie <jim.cromie@gmail.com>
>>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>> Tested-by: Jim Cromie <jim.cromie@gmail.com>
>>
>> Applied, thanks!
>>
>
> I have since seen a similar warning on shutdown,
> heres a patch for it.
>
> theres one other callsite, but I havent seen the warning from it,
> will try to tickle it at some point.
[about attached patch]
Why not increase buflen, like in refill_rx()?
Best Regards,
Michał Mirosław
^ permalink raw reply
* [PATCH 0/5] treewide: Add missing breaks in switch/case
From: Joe Perches @ 2011-07-10 9:28 UTC (permalink / raw)
To: linux-wireless, ath5k-devel, linux-usb; +Cc: linux-kernel, netdev, alsa-devel
Found by grep. Uncompiled/untested.
Joe Perches (5):
gpio-tps65910.c: Add missing breaks in switch/case
tps65910-irq: Add missing breaks in switch/case
ath5k: Add missing breaks in switch/case
fusb300_udc: Add missing breaks in switch/case
dbri: Add missing breaks in switch/case
drivers/gpio/gpio-tps65910.c | 2 ++
drivers/mfd/tps65910-irq.c | 2 ++
drivers/net/wireless/ath/ath5k/desc.c | 3 +++
drivers/usb/gadget/fusb300_udc.c | 3 +++
sound/sparc/dbri.c | 5 +++++
5 files changed, 15 insertions(+), 0 deletions(-)
--
1.7.6.131.g99019
^ permalink raw reply
* [PATCH 3/5] ath5k: Add missing breaks in switch/case
From: Joe Perches @ 2011-07-10 9:28 UTC (permalink / raw)
To: Jiri Slaby, Nick Kossifidis, Luis R. Rodriguez, Bob Copeland
Cc: John W. Linville, linux-wireless, ath5k-devel, netdev,
linux-kernel
In-Reply-To: <cover.1310289795.git.joe@perches.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/net/wireless/ath/ath5k/desc.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/desc.c b/drivers/net/wireless/ath/ath5k/desc.c
index 62172d5..f82383b 100644
--- a/drivers/net/wireless/ath/ath5k/desc.c
+++ b/drivers/net/wireless/ath/ath5k/desc.c
@@ -107,10 +107,13 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
case AR5K_PKT_TYPE_BEACON:
case AR5K_PKT_TYPE_PROBE_RESP:
frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_NO_DELAY;
+ break;
case AR5K_PKT_TYPE_PIFS:
frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS;
+ break;
default:
frame_type = type;
+ break;
}
tx_ctl->tx_control_0 |=
--
1.7.6.131.g99019
^ permalink raw reply related
* 3.0-rc6-git6: Reported regressions from 2.6.39
From: Rafael J. Wysocki @ 2011-07-10 10:19 UTC (permalink / raw)
To: Linux Kernel Mailing List
Cc: Maciej Rutecki, Florian Mickler, Andrew Morton, Linus Torvalds,
Kernel Testers List, Network Development, Linux ACPI,
Linux PM List, Linux SCSI List, Linux Wireless List, DRI
This message contains a list of some regressions from 2.6.39,
for which there are no fixes in the mainline known to the tracking team.
If any of them have been fixed already, please let us know.
If you know of any other unresolved regressions from 2.6.39, please let us
know either and we'll add them to the list. Also, please let us know
if any of the entries below are invalid.
Each entry from the list will be sent additionally in an automatic reply
to this message with CCs to the people involved in reporting and handling
the issue.
Listed regressions statistics:
Date Total Pending Unresolved
----------------------------------------
2011-07-10 38 16 13
2011-06-26 22 14 12
2011-06-12 8 7 7
Unresolved regressions
----------------------
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=39052
Subject : .tmp_depmod owned by root after modules_install
Submitter : Christian Kujau <lists-AanptEQQ3TL9uQeqpI+JUg@public.gmane.org>
Date : 2011-07-04 9:49 (7 days old)
Message-ID : <alpine.DEB.2.01.1107040242180.9183-yMVncJ7Z0T9hhup4ARC/jw@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130977296812731&w=2
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38802
Subject : Not work hotkey of Microsoft Comfort Curve Keyboard 2000
Submitter : Cristian Aravena Romero <caravena-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-07-05 20:43 (6 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38732
Subject : Linux 3.0-rc5 doesnt boot and hangs at rcu_sched_state ()
Submitter : RKK <kulkarni.ravi4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-06-29 13:38 (12 days old)
Message-ID : <BANLkTikW6Xk8UMsOHLCnLn7STRzy8RaiJA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130935402722869&w=2
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38702
Subject : 3.0.0-rc4-git6 - INFO: possible circular locking dependency detected - (&rdev->mtx){+.+.+.}, at: [<ffffffffa00e27e0>] cfg80211_netdev_notifier_call+0x275/0x4ff [cfg80211]
Submitter : Miles Lane <miles.lane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-06-26 21:54 (15 days old)
Message-ID : <BANLkTikztsFnPkJZ7VxRC-zsitwCCvVmeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130912559804336&w=2
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38672
Subject : KVM guest boot crashed
Submitter : Steve <stefan.bosak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-07-02 06:56 (9 days old)
First-Bad-Commit: http://git.kernel.org/linus/6506e4f995967b1a48cc34418c77b318df92ce35
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38622
Subject : [radeon cayman regresion] artefacts on screen
Submitter : Marek Hobler, 'neutrinus' <kernellist-X/h6sc6Dz0uakBO8gow8eQ@public.gmane.org>
Date : 2011-07-01 09:35 (10 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38612
Subject : Boot time warnings in APIC
Submitter : Bill Huey <bill.huey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-07-01 06:44 (10 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38582
Subject : T510 43495KG won't resume with 32bit installation
Submitter : Marc Koschewski <marc-e1Wt+8K1Ta8ZEwqihLH0+Q@public.gmane.org>
Date : 2011-06-30 22:39 (11 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38522
Subject : address space collision error message on boot
Submitter : Jools Wills <jools-ApNQbik20ZdhgJEaYHuxyvXRex20P6io@public.gmane.org>
Date : 2011-06-29 02:28 (12 days old)
First-Bad-Commit: http://git.kernel.org/linus/5d94e81f69d4b1d1102d3ab557ce0a817c11fbbb
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38332
Subject : System hang when enable rc6
Submitter : Gu Rui <chaos.proton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-06-27 08:16 (14 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37872
Subject : CPU lockup during boot
Submitter : Bruno Wolff III <bruno-bdMChIhFSYk@public.gmane.org>
Date : 2011-06-19 15:00 (22 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37482
Subject : Driver: i915 - Starting with kernel 3.0.0-rc3, dual monitor freezes a Dell Latitude E6410 when a second monitor is connected at boot time
Submitter : David Hill <hilld-HTiBYHdybX7UkGsOFmftXw@public.gmane.org>
Date : 2011-06-14 18:42 (27 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37432
Subject : sdhci-pci fails on 3.0.0-rc1 on Dell E6510
Submitter : Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
Date : 2011-06-07 20:06 (34 days old)
First-Bad-Commit: http://git.kernel.org/linus/da7822e5ad71ec9b745b412639f1e5e0ba795a20
References : http://article.gmane.org/gmane.linux.kernel.mmc/8442
https://lkml.org/lkml/2011/6/23/660
Regressions with patches
------------------------
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38972
Subject : Kernel panic when syncing while cifs is mounted
Submitter : <farbing-S0/GAf8tV78@public.gmane.org>
Date : 2011-07-08 15:39 (3 days old)
First-Bad-Commit: http://git.kernel.org/linus/dd8544661947ad6d8d87b3c9d4333bfa1583d1bc
Handled-By : Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Patch : https://bugzilla.kernel.org/attachment.cgi?id=65082
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38302
Subject : NFS crash in un-modified 3.0.0-rc3+, list corruption.
Submitter : Ben Greear <greearb-my8/4N5VtI7c+919tysfdA@public.gmane.org>
Date : 2011-06-20 22:42 (21 days old)
Message-ID : <4DFFCCDC.2070106-my8/4N5VtI7c+919tysfdA@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130860979610651&w=2
Patch : https://bugzilla.kernel.org/attachment.cgi?id=63902
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38152
Subject : acpi_power_off lockdep splat
Submitter : Borislav Petkov <bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>
Date : 2011-06-19 13:30 (22 days old)
Message-ID : <20110619133049.GA18168-f9CnO7I+Q6zU6FkGJEIX5A@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130849028317365&w=2
Handled-By : Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>
Patch : https://patchwork.kernel.org/patch/950852/
For details, please visit the bug entries and follow the links given in
references.
As you can see, there is a Bugzilla entry for each of the listed regressions.
There also is a Bugzilla entry used for tracking the regressions from 2.6.39,
unresolved as well as resolved, at:
http://bugzilla.kernel.org/show_bug.cgi?id=36912
Please let the tracking team know if there are any Bugzilla entries that
should be added to the list in there.
Thanks!
^ permalink raw reply
* Re: 3.0-rc6-git6: Reported regressions from 2.6.39
From: Johannes Berg @ 2011-07-10 10:54 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux Kernel Mailing List, Maciej Rutecki, Florian Mickler,
Andrew Morton, Linus Torvalds, Kernel Testers List,
Network Development, Linux ACPI, Linux PM List, Linux SCSI List,
Linux Wireless List, DRI
In-Reply-To: <Y7LyOsOBwFM.A.kJG.kBYGOB@chimera>
On Sun, 2011-07-10 at 12:19 +0200, Rafael J. Wysocki wrote:
> Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38702
> Subject : 3.0.0-rc4-git6 - INFO: possible circular locking dependency detected - (&rdev->mtx){+.+.+.}, at: [<ffffffffa00e27e0>] cfg80211_netdev_notifier_call+0x275/0x4ff [cfg80211]
> Submitter : Miles Lane <miles.lane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Date : 2011-06-26 21:54 (15 days old)
> Message-ID : <BANLkTikztsFnPkJZ7VxRC-zsitwCCvVmeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> References : http://marc.info/?l=linux-kernel&m=130912559804336&w=2
Should be fixed by c10841ca722a0bc960dc541c51582773f9a24f98 which was
part of John's latest pull request and is in net-2.6 now on its way up.
johannes
^ permalink raw reply
* 3.0-rc6-git6: Reported regressions 2.6.38 -> 2.6.39
From: Rafael J. Wysocki @ 2011-07-10 10:54 UTC (permalink / raw)
To: Linux Kernel Mailing List
Cc: Maciej Rutecki, Florian Mickler, Andrew Morton, Linus Torvalds,
Kernel Testers List, Network Development, Linux ACPI,
Linux PM List, Linux SCSI List, Linux Wireless List, DRI
This message contains a list of some post-2.6.38 regressions introduced before
2.6.39, for which there are no fixes in the mainline known to the tracking team.
If any of them have been fixed already, please let us know.
If you know of any other unresolved post-2.6.38 regressions, please let us know
either and we'll add them to the list. Also, please let us know if any
of the entries below are invalid.
Each entry from the list will be sent additionally in an automatic reply to
this message with CCs to the people involved in reporting and handling the
issue.
Listed regressions statistics:
Date Total Pending Unresolved
----------------------------------------
2011-07-10 99 26 24
2011-06-27 94 25 23
2011-06-12 81 21 18
2011-05-15 50 12 11
2011-04-30 38 17 16
2011-04-17 17 11 10
Unresolved regressions
----------------------
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38842
Subject : panic in elv_completed_request on safe remove usb hard drive
Submitter : leniviy <basinilya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-07-06 09:20 (5 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38742
Subject : After hard power-off, btrfs cannot be recovered except booting 2.6.38 or below kernel
Submitter : Ryan Underwood <nemesis-RBwgCYbvQ+vk1uMJSBkQmQ@public.gmane.org>
Date : 2011-07-03 18:57 (8 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38572
Subject : New NFS: directory XXX contains a readdir loop seems to be triggered by well-behaving server
Submitter : Petr Vandrovec <petr-vPk2MGR0e28uaRcfnNAh7A@public.gmane.org>
Date : 2011-06-30 19:38 (11 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38132
Subject : [Warning] 2.6.39.x latencytop
Submitter : Andrew Watts <akwatts-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org>
Date : 2011-06-14 17:07 (27 days old)
Message-ID : <80098.5633.qm-tGSp4LqzbTn6X00i2u5GFvu2YVrzzGjVVpNB7YpNyf8@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130807128506490&w=2
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38102
Subject : BUG kmalloc-2048: Poison overwritten
Submitter : Alexey Zaytsev <alexey.zaytsev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-06-23 17:33 (18 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37772
Subject : Sometimes, sound disappears and doesn't want to idle.
Submitter : <merkil-kt3qwsSULN8dnm+yROfE0A@public.gmane.org>
Date : 2011-06-17 22:06 (24 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37752
Subject : Kernel Panic in drm_vblank_put+0x13/0x50 on P4 HT machine with 82915G/GV/910GL Integrated Graphics Controller
Submitter : Martin Rogge <marogge-53koH/AXb86i2/dY4+mD5w@public.gmane.org>
Date : 2011-06-17 13:02 (24 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37712
Subject : reboot / "shutdown -r now" hangs ; works fine on 2.6.38.7-1
Submitter : Dave Hooper <dave-kId6I2PxnVtBDgjK7y7TUQ@public.gmane.org>
Date : 2011-06-16 20:50 (25 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37692
Subject : Linux 2.6.39.x fails to boot - unable to mount root fs
Submitter : Dan Dart <dandart-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
Date : 2011-06-16 18:55 (25 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37622
Subject : Poor wireless performance with Intel 4965AGN with iwl-legacy/iwl4965
Submitter : <MDstr_1-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
Date : 2011-06-16 11:22 (25 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37472
Subject : Lenovo U160 (i915 black screen)
Submitter : Robse <rob-se-Dz115AEZgoU@public.gmane.org>
Date : 2011-06-14 15:17 (27 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37322
Subject : high load, unresponsive system spinning in rcu_kthread
Submitter : Ferenc Wágner <wferi-eEbw3PyuezQ@public.gmane.org>
Date : 2011-06-12 14:53 (29 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37312
Subject : Intel 5100 wifi stopped working with 2.6.39.1
Submitter : Thibault Dory <dory.thibault-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-06-12 12:43 (29 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37292
Subject : kernel BUG at fs/ecryptfs/read_write.c:47!
Submitter : <rems14-fqJXh2VwIQ9ByuSxxbvQtw@public.gmane.org>
Date : 2011-06-12 10:25 (29 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=37042
Subject : linux 3.0.0-rc2 libata-eh.c:4018 ata_scsi_port_error_handler+0x80/0x53d on s2disk
Submitter : Alex Zhavnerchik <alex.vizor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-06-09 08:22 (32 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=36952
Subject : [2.6.39] CIFS write failures where 2.6.38 works
Submitter : Helge Hafting <helge.hafting-CND4fxrytsY@public.gmane.org>
Date : 2011-06-01 10:11 (40 days old)
Message-ID : <4DE6103E.6010100-CND4fxrytsY@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130692387613423&w=2
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=36392
Subject : 2.6.39, 3.0-rc2 Intel DRI Regression: Black Screen after trying to play video
Submitter : Dennis Jansen <dennis.jansen-S0/GAf8tV78@public.gmane.org>
Date : 2011-06-01 04:41 (40 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=36332
Subject : Intel gpu turns external monitor off when X starts
Submitter : rocko <rockorequin-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
Date : 2011-05-31 02:53 (41 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=36182
Subject : Erroneous package power limit notification since kernel 2.6.39
Submitter : Olaf Freyer <aaron667-hi6Y0CQ0nG0@public.gmane.org>
Date : 2011-05-22 13:01 (50 days old)
Message-ID : <4DD9092A.4080507-hi6Y0CQ0nG0@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130606930631131&w=2
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=35922
Subject : SND_USB_AUDIO recording device not initializing correctly
Submitter : <bjoern.online-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-05-26 10:30 (46 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=35662
Subject : softlockup with kernel 2.6.39
Submitter : Hussam Al-Tayeb <ht990332-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date : 2011-05-23 08:13 (49 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=35242
Subject : NULL pointer dereference in intel_sdvo_write_cmd (was Black screen after boot)
Submitter : Ko Mi <chaostya.test-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
Date : 2011-05-17 10:27 (55 days old)
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=35142
Subject : 2.6.39-rc7-git1 boot error message (no crash)
Submitter : werner <w.landgraf-ow1r9FSYgO0@public.gmane.org>
Date : 2011-05-11 4:58 (61 days old)
Message-ID : <web-520830057-zcyLqNHFQq3Ee+7He9zlJw@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130512952706444&w=2
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=34942
Subject : [Bug] Kdump does not work when panic triggered due to MCE
Submitter : K.Prasad <prasad-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date : 2011-05-06 16:54 (66 days old)
Message-ID : <20110506165412.GB2719-xthvdsQ13ZrQT0dZR+AlfA@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130470087226270&w=2
Regressions with patches
------------------------
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=35642
Subject : On resume, I sometimes get a kernel oops with led_trigger_unregister_simple
Submitter : Sven-Hendrik Haase <sh-5wni8d9J0yJl57MIdRCFDg@public.gmane.org>
Date : 2011-05-23 00:15 (49 days old)
Patch : https://patchwork.kernel.org/patch/927582/
https://patchwork.kernel.org/patch/927612/
Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=33242
Subject : Lockdep splat in autofs with 2.6.39-rc2
Submitter : Nick Bowler <nbowler-7BP4RkwGw0uXmMXjJBpWqg@public.gmane.org>
Date : 2011-04-07 19:44 (95 days old)
Message-ID : <20110407194403.GA29404-7BP4RkwGw0uXmMXjJBpWqg@public.gmane.org>
References : http://marc.info/?l=linux-kernel&m=130220545614682&w=2
Patch : http://marc.info/?l=linux-kernel&m=130342115008659&w=2
For details, please visit the bug entries and follow the links given in
references.
As you can see, there is a Bugzilla entry for each of the listed regressions.
There also is a Bugzilla entry used for tracking the regressions introduced
between 2.6.38 and 2.6.39, unresolved as well as resolved, at:
http://bugzilla.kernel.org/show_bug.cgi?id=32012
Please let the tracking team know if there are any Bugzilla entries that
should be added to the list in there.
Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: 3.0-rc6-git6: Reported regressions from 2.6.39
From: Rafael J. Wysocki @ 2011-07-10 11:12 UTC (permalink / raw)
To: Johannes Berg
Cc: Linux Kernel Mailing List, Maciej Rutecki, Florian Mickler,
Andrew Morton, Linus Torvalds, Kernel Testers List,
Network Development, Linux ACPI, Linux PM List, Linux SCSI List,
Linux Wireless List, DRI
In-Reply-To: <1310295277.3942.1.camel@jlt3.sipsolutions.net>
On Sunday, July 10, 2011, Johannes Berg wrote:
> On Sun, 2011-07-10 at 12:19 +0200, Rafael J. Wysocki wrote:
>
> > Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=38702
> > Subject : 3.0.0-rc4-git6 - INFO: possible circular locking dependency detected - (&rdev->mtx){+.+.+.}, at: [<ffffffffa00e27e0>] cfg80211_netdev_notifier_call+0x275/0x4ff [cfg80211]
> > Submitter : Miles Lane <miles.lane@gmail.com>
> > Date : 2011-06-26 21:54 (15 days old)
> > Message-ID : <BANLkTikztsFnPkJZ7VxRC-zsitwCCvVmeg@mail.gmail.com>
> > References : http://marc.info/?l=linux-kernel&m=130912559804336&w=2
>
> Should be fixed by c10841ca722a0bc960dc541c51582773f9a24f98 which was
> part of John's latest pull request and is in net-2.6 now on its way up.
Thanks, closing.
Rafael
^ permalink raw reply
* Re: [PATCH 00/21] clean up rx_copybreak handling [split version]
From: Michał Mirosław @ 2011-07-10 11:28 UTC (permalink / raw)
To: Joe Perches
Cc: netdev, Steffen Klassert, Santiago Leon, Tim Hockin, Don Fry,
Francois Romieu, Ion Badulescu, Matt Carlson, Michael Chan,
Grant Grundler, David Dillow, Roger Luethi, David S. Miller
In-Reply-To: <1310235632.3848.13.camel@Joe-Laptop>
On Sat, Jul 09, 2011 at 11:20:32AM -0700, Joe Perches wrote:
> On Sat, 2011-07-09 at 19:17 +0200, Michał Mirosław wrote:
> > Split version of rx_copybreak cleanup patch.
>
> Hello Michał.
>
> Looks good, thanks for doing this work.
>
> One style quibble.
>
> You use this style:
>
> + skb = dev_skb_finish_rx_dma(&np->rx_skbuff[entry],
> + pkt_len, rx_copybreak,
> + &np->pci_dev->dev,
> + le32_to_cpu(desc->frag[0].addr),
> + np->rx_buf_sz);
>
> where almost all other uses throughout drivers/net
> align arguments to open parenthesis instead.
>
> + skb = dev_skb_finish_rx_dma(&np->rx_skbuff[entry],
> + pkt_len, rx_copybreak,
> + &np->pci_dev->dev,
> + le32_to_cpu(desc->frag[0].addr),
> + np->rx_buf_sz);
I'll fix that in v2 where the style differs.
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [PATCH 00/21] clean up rx_copybreak handling [split version]
From: Michał Mirosław @ 2011-07-10 11:52 UTC (permalink / raw)
To: Joe Perches
Cc: netdev, Steffen Klassert, Santiago Leon, Tim Hockin, Don Fry,
Francois Romieu, Ion Badulescu, Matt Carlson, Michael Chan,
Grant Grundler, David Dillow, Roger Luethi, David S. Miller
In-Reply-To: <20110710112818.GA24325@rere.qmqm.pl>
On Sun, Jul 10, 2011 at 01:28:18PM +0200, Michał Mirosław wrote:
> On Sat, Jul 09, 2011 at 11:20:32AM -0700, Joe Perches wrote:
> > On Sat, 2011-07-09 at 19:17 +0200, Michał Mirosław wrote:
> > > Split version of rx_copybreak cleanup patch.
> >
> > Hello Michał.
> >
> > Looks good, thanks for doing this work.
> >
> > One style quibble.
> >
> > You use this style:
> >
> > + skb = dev_skb_finish_rx_dma(&np->rx_skbuff[entry],
> > + pkt_len, rx_copybreak,
> > + &np->pci_dev->dev,
> > + le32_to_cpu(desc->frag[0].addr),
> > + np->rx_buf_sz);
> >
> > where almost all other uses throughout drivers/net
> > align arguments to open parenthesis instead.
> >
> > + skb = dev_skb_finish_rx_dma(&np->rx_skbuff[entry],
> > + pkt_len, rx_copybreak,
> > + &np->pci_dev->dev,
> > + le32_to_cpu(desc->frag[0].addr),
> > + np->rx_buf_sz);
>
> I'll fix that in v2 where the style differs.
I modified patches where surrounding code had been consistent. I'm now
convinced I don't like this style, especially when combined with 80-column
limit and no limit on indentation levels.
Best Regards,
Michał Mirosław
^ permalink raw reply
* Update for CAN LTP tests
From: Oliver Hartkopp @ 2011-07-10 12:18 UTC (permalink / raw)
To: Subrata Modak
Cc: Oliver Hartkopp, Wolfgang Grandegger, ltp-list, socketcan-users,
netdev
In-Reply-To: <20090512094631.26592.81609.sendpatchset@subratamodak.linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]
Subrata Modak wrote:
> Would you also like to send a patch to update the testcases for CAN in LTP
> (http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testcases/network/can/filter-tests/) ?
> These tests were originally picked up from:
> http://svn.berlios.de/wsvn/socketcan/trunk/test/?rev=877&sc=1
Dear Subrata,
attached you'll find a major update for the LTP tests dealing with CAN filters
and the CAN frame flow down to the CAN netdevice and vice versa.
The patch removes all the obsolete stuff from the source code directory you
originally picked the tests from. I added two new tools that also reside on
the referenced SVN:
tst-filter: New filter test tool in *one* programm (easy to use & handle)
tst-rcv-own-msgs: Checks the CAN frame flow inside the networking stack
Additionally the virtual CAN driver needs to be loaded with a special
commandline option to perform the CAN frame flow test correctly.
The tests & the scripts are much clearer to me now. If it meets your
requirements consider to apply this patch to the LTP repository.
Best regards,
Oliver
[-- Attachment #2: can-ltp-update.patch --]
[-- Type: text/x-patch, Size: 157350 bytes --]
diff -u -N -r filter-tests/canecho.c filter-tests-new/canecho.c
--- filter-tests/canecho.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/canecho.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,164 +0,0 @@
-/*
- * $Id: canecho.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * canecho.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <libgen.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-
-extern int optind, opterr, optopt;
-
-static int s = -1;
-static int running = 1;
-
-void print_usage(char *prg)
-{
- fprintf(stderr, "Usage: %s [can-interface]\n", prg);
-}
-
-void sigterm(int signo)
-{
- printf("got signal %d\n", signo);
- running = 0;
-}
-
-int main(int argc, char **argv)
-{
- int family = PF_CAN, type = SOCK_RAW, proto = CAN_RAW;
- int opt;
- struct sockaddr_can addr;
- struct ifreq ifr;
- struct can_frame frame;
- int nbytes, i;
- int verbose = 0;
-
- signal(SIGTERM, sigterm);
- signal(SIGHUP, sigterm);
-
- while ((opt = getopt(argc, argv, "f:t:p:v")) != -1) {
- switch (opt) {
- case 'f':
- family = atoi(optarg);
- break;
-
- case 't':
- type = atoi(optarg);
- break;
-
- case 'p':
- proto = atoi(optarg);
- break;
-
- case 'v':
- verbose = 1;
- break;
-
- case '?':
- break;
-
- default:
- fprintf(stderr, "Unknown option %c\n", opt);
- break;
- }
- }
-
- if (optind == argc) {
- print_usage(basename(argv[0]));
- exit(0);
- }
-
- printf("interface = %s, family = %d, type = %d, proto = %d\n",
- argv[optind], family, type, proto);
- if ((s = socket(family, type, proto)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = family;
- strcpy(ifr.ifr_name, argv[optind]);
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
-
- while (running) {
- if ((nbytes = read(s, &frame, sizeof(frame))) < 0) {
- perror("read");
- return 1;
- }
- if (verbose) {
- printf("%03X: ", frame.can_id & CAN_EFF_MASK);
- if (frame.can_id & CAN_RTR_FLAG) {
- printf("remote request");
- } else {
- printf("[%d]", frame.can_dlc);
- for (i = 0; i < frame.can_dlc; i++) {
- printf(" %02X", frame.data[i]);
- }
- }
- printf("\n");
- }
- frame.can_id++;
- write(s, &frame, sizeof(frame));
- }
-
- return 0;
-}
-
diff -u -N -r filter-tests/Makefile filter-tests-new/Makefile
--- filter-tests/Makefile 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/Makefile 2011-07-10 13:17:01.447711796 +0200
@@ -1,43 +1,6 @@
#
# $Id: Makefile,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
#
-# Copyright (c) 2002-2007 Volkswagen Group Electronic Research
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions, the following disclaimer and
-# the referenced file 'COPYING'.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Volkswagen nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# Alternatively, provided that this notice is retained in full, this
-# software may be distributed under the terms of the GNU General
-# Public License ("GPL") version 2 as distributed in the 'COPYING'
-# file from the main directory of the linux kernel source.
-#
-# The provided data structures and external interfaces from this code
-# are not restricted to be used by modules with a GPL compatible license.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-# DAMAGE.
-#
# Send feedback to <socketcan-users@lists.berlios.de>
CFLAGS = -O2 -Wall -Wno-parentheses \
@@ -46,25 +9,7 @@
-DPF_CAN=29 \
-DAF_CAN=PF_CAN
-PROGRAMS = tst-raw \
- tst-raw-filter \
- tst-err \
- tst-raw-sendto \
- tst-packet \
- tst-filter-master \
- tst-filter-server \
- tst-bcm-cycle \
- tst-bcm-server \
- tst-bcm-tx_read \
- tst-bcm-rtr \
- tst-bcm-single \
- tst-bcm-filter \
- tst-bcm-throttle \
- tst-bcm-rx-sendto \
- tst-bcm-tx-sendto \
- tst-bcm-dump \
- tst-proc \
- canecho
+PROGRAMS = tst-filter tst-rcv-own-msgs
all: $(PROGRAMS)
@@ -72,8 +17,8 @@
cp -f $(PROGRAMS) /usr/local/bin
clean:
- rm -f $(PROGRAMS) output_ltp-can.txt output_ltp-can-verify.txt /etc/modprobe.d/vcan
+ rm -f $(PROGRAMS)
distclean:
- rm -f $(PROGRAMS) *~ output_ltp-can.txt output_ltp-can-verify.txt /etc/modprobe.d/vcan
+ rm -f $(PROGRAMS) *~
diff -u -N -r filter-tests/run_ltp-can_tests.sh filter-tests-new/run_ltp-can_tests.sh
--- filter-tests/run_ltp-can_tests.sh 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/run_ltp-can_tests.sh 2011-07-10 13:51:44.839639383 +0200
@@ -1,6 +1,6 @@
#!/bin/sh
################################################################################
-## Copyright (c) Oliver Hartkopp <oliver.hartkopp@volkswagen.de>, 2009 ##
+## Copyright (c) Oliver Hartkopp <oliver.hartkopp@volkswagen.de>, 2011 ##
## Copyright (c) International Business Machines Corp., 2009 ##
## ##
## This program is free software; you can redistribute it and#or modify ##
@@ -24,25 +24,34 @@
exit 1
fi
-cat <<-EOF > /etc/modprobe.d/vcan
-# protocol family PF_CAN
-alias net-pf-29 can
-# protocols in PF_CAN
-alias can-proto-1 can-raw
-alias can-proto-2 can-bcm
-alias can-proto-3 can-tp16
-alias can-proto-4 can-tp20
-alias can-proto-5 can-mcnet
-alias can-proto-6 can-isotp
-EOF
-
+# load needed CAN networklayer modules
modprobe -f can
modprobe -f can_raw
-modprobe -f vcan
-ip link add dev vcan0 type vcan
-ifconfig vcan0 up
-./tst-filter-server > output_ltp-can.txt &
-./tst-filter-master | tee output_ltp-can-verify.txt
+# ensure the vcan driver to perform the ECHO on driver level
+modprobe -r vcan
+modprobe -f vcan echo=1
+
+VCAN=vcan0
+
+# create virtual CAN device
+ip link add dev $VCAN type vcan || exit 1
+ifconfig $VCAN up
+
+# check precondition for CAN frame flow test
+HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
+
+if [ $HAS_ECHO -ne 1 ]
+then
+ exit 1
+fi
+
+# test of CAN filters on af_can.c
+./tst-filter $VCAN || exit 1
+
+# test of CAN frame flow down to the netdevice and up again
+./tst-rcv-own-msgs $VCAN || exit 1
+
+exit 0
diff -u -N -r filter-tests/tst-bcm-cycle.c filter-tests-new/tst-bcm-cycle.c
--- filter-tests/tst-bcm-cycle.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-cycle.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,138 +0,0 @@
-/*
- * $Id: tst-bcm-cycle.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-cycle.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame[4];
- } msg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- msg.msg_head.opcode = TX_SETUP;
- msg.msg_head.can_id = 0x42;
- msg.msg_head.flags = SETTIMER|STARTTIMER;
- msg.msg_head.nframes = 1;
- msg.msg_head.count = 10;
- msg.msg_head.ival1.tv_sec = 1;
- msg.msg_head.ival1.tv_usec = 0;
- msg.msg_head.ival2.tv_sec = 0;
- msg.msg_head.ival2.tv_usec = 0;
- msg.frame[0].can_id = 0x42;
- msg.frame[0].can_dlc = 8;
- U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
-
- printf("Press any key to stop the cycle ...\n");
-
- getchar();
-
- msg.msg_head.opcode = TX_SETUP;
- msg.msg_head.can_id = 0x42;
- msg.msg_head.flags = SETTIMER|STARTTIMER;
- msg.msg_head.nframes = 1;
- msg.msg_head.count = 0;
- msg.msg_head.ival1.tv_sec = 0;
- msg.msg_head.ival1.tv_usec = 0;
- msg.msg_head.ival2.tv_sec = 0;
- msg.msg_head.ival2.tv_usec = 0;
- msg.frame[0].can_id = 0x42;
- msg.frame[0].can_dlc = 8;
- U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
-
- printf("Press any key to close the socket ...\n");
-
- getchar();
-
- close(s);
-
- printf("Press any key to end the program ...\n");
-
- getchar();
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-dump.c filter-tests-new/tst-bcm-dump.c
--- filter-tests/tst-bcm-dump.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-dump.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,202 +0,0 @@
-/*
- * $Id: tst-bcm-dump.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-dump.c
- *
- * Copyright (c) 2008 Oliver Hartkopp
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the version 2 of the GNU General Public License
- * as published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <time.h>
-#include <libgen.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define DEFAULT_IFACE "vcan0"
-#define DEFAULT_CANID 0x42
-
-void print_usage(char *prg)
-{
- fprintf(stderr, "\nUsage: %s [options]\n", prg);
- fprintf(stderr, "Options: -i <interface> (CAN interface. Default: '%s')\n", DEFAULT_IFACE);
- fprintf(stderr, " -c <can_id> (used CAN ID. Default: 0x%03X)\n", DEFAULT_CANID);
- fprintf(stderr, " -o <timeout> (Timeout value in nsecs. Default: 0)\n");
- fprintf(stderr, " -t <throttle> (Throttle value in nsecs. Default: 0)\n");
- fprintf(stderr, " -q <msgs> (Quit after receiption of #msgs)\n");
- fprintf(stderr, " -s (set STARTTIMER flag. Default: off)\n");
- fprintf(stderr, "\n");
-}
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- int nbytes;
- int i;
- struct ifreq ifr;
- char *ifname = DEFAULT_IFACE;
- canid_t canid = DEFAULT_CANID;
- int opt;
- struct timeval tv;
- unsigned long starttimer = 0;
- unsigned long long timeout = 0;
- unsigned long long throttle = 0;
- unsigned long msgs = 0;
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame;
- } msg;
-
- while ((opt = getopt(argc, argv, "i:c:o:t:q:s")) != -1) {
- switch (opt) {
-
- case 'i':
- ifname = optarg;
- break;
-
- case 'c':
- canid = strtoul(optarg, (char **)NULL, 16);
- break;
-
- case 'o':
- timeout = strtoull(optarg, (char **)NULL, 10);
- break;
-
- case 't':
- throttle = strtoull(optarg, (char **)NULL, 10);
- break;
-
- case 'q':
- msgs = strtoul(optarg, (char **)NULL, 10);
- break;
-
- case 's':
- starttimer = STARTTIMER;
- break;
-
- case '?':
- default:
- print_usage(basename(argv[0]));
- exit(1);
- break;
- }
- }
-
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- if (strcmp(ifname, "any") == 0)
- addr.can_ifindex = 0;
- else {
- strcpy(ifr.ifr_name, ifname);
- if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
- perror("SIOCGIFINDEX");
- return 1;
- }
- addr.can_ifindex = ifr.ifr_ifindex;
- }
-
- addr.can_family = PF_CAN;
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- msg.msg_head.opcode = RX_SETUP;
- msg.msg_head.can_id = canid;
- msg.msg_head.flags = SETTIMER|RX_FILTER_ID|starttimer;
- msg.msg_head.ival1.tv_sec = timeout / 1000000;
- msg.msg_head.ival1.tv_usec = timeout % 1000000;
- msg.msg_head.ival2.tv_sec = throttle / 1000000;
- msg.msg_head.ival2.tv_usec = throttle % 1000000;
- msg.msg_head.nframes = 0;
-
- gettimeofday(&tv, NULL);
- printf("[%ld.%06ld] ", tv.tv_sec, tv.tv_usec);
- printf("Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
- msg.msg_head.can_id);
-
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
-
- while (1) {
-
- nbytes = read(s, &msg, sizeof(msg));
- if (nbytes < 0) {
- perror("read");
- return 1;
- }
- gettimeofday(&tv, NULL);
- printf("[%ld.%06ld] ", tv.tv_sec, tv.tv_usec);
-
- if (nbytes == sizeof(msg)) {
-
- if (ioctl(s, SIOCGSTAMP, &tv) < 0)
- perror("SIOCGSTAMP");
- else
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (msg.msg_head.opcode != RX_CHANGED) {
- printf("missing RX_CHANGED.\n");
- return 1;
- }
-
- printf("RX_CHANGED ");
-
- for (i=0; i < msg.frame.can_dlc; i++)
- printf("%02X ", msg.frame.data[i]);
-
- } else {
-
- if (msg.msg_head.opcode != RX_TIMEOUT) {
- printf("missing RX_TIMEOUT.\n");
- return 1;
- }
-
- printf("RX_TIMEOUT");
- }
-
- printf("\n");
- fflush(stdout);
-
- if (msgs && !(--msgs))
- break;
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-filter.c filter-tests-new/tst-bcm-filter.c
--- filter-tests/tst-bcm-filter.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-filter.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,517 +0,0 @@
-/*
- * $Id: tst-bcm-filter.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-filter.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
- int s,nbytes;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct timeval tv;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame[4];
- } txmsg, rxmsg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x042;
- txmsg.msg_head.flags = SETTIMER|RX_FILTER_ID;
- txmsg.msg_head.ival1.tv_sec = 1;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 0;
-
- printf("<*>Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- /* test for RX_DELETE */
- txmsg.msg_head.opcode = RX_DELETE;
- txmsg.msg_head.can_id = 0x042; /* everything we need for RX_DELETE */
-
- printf("<*>Writing RX_DELETE for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x042;
- txmsg.msg_head.flags = SETTIMER|RX_FILTER_ID;
- txmsg.msg_head.ival1.tv_sec = 1;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 0;
-
- printf("<*>Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- /* obsolete for TX_SEND ... */
-#if 0
- txmsg.msg_head.can_id = 0x43;
- txmsg.msg_head.flags = SETTIMER|STARTTIMER|TX_CP_CAN_ID;
- txmsg.msg_head.count = 0;
- txmsg.msg_head.ival1.tv_sec = 0;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
-#endif
- txmsg.frame[0].can_id = 0x43;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<2>Writing TX_SEND with wrong can_id <%03X>\n",
- txmsg.frame[0].can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<3>Writing TX_SEND with correct can_id <%03X>\n",
- txmsg.frame[0].can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<3>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- /* growing number of nframes => RX_DELETE instead of simple update */
- txmsg.msg_head.opcode = RX_DELETE;
- txmsg.msg_head.can_id = 0x042; /* everything we need for RX_DELETE */
-
- printf("<*>Writing RX_DELETE for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x042;
- txmsg.msg_head.flags = SETTIMER|RX_CHECK_DLC;
- txmsg.msg_head.ival1.tv_sec = 1;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 1;
- /* txmsg.frame[0].can_dlc = 8; obsolete for RX_SETUP */
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
-
- printf("<*>Writing simple RX_SETUP for can_id <%03X> with msgbits 0x%016llX\n",
- txmsg.msg_head.can_id, U64_DATA(&txmsg.frame[0]));
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<5>Writing TX_SEND with correct can_id <%03X>\n",
- txmsg.frame[0].can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<5>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<6>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("no changed data\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- /* no change here */
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<7>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("changed relevant msgbits\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<7>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<8>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("changed irrelevant msgbits\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 7;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<9>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("changed Data Length Code DLC\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<9>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = RX_DELETE;
- txmsg.msg_head.can_id = 0x042; /* everything we need for RX_DELETE */
-
- printf("<*>Writing RX_DELETE for can_id <%03X> for RX_SETUP with growing nframes\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- /* no problems ;-) but NOW we try MUX messages ... and timeouts */
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x042;
- txmsg.msg_head.flags = SETTIMER|RX_CHECK_DLC;
- txmsg.msg_head.ival1.tv_sec = 1;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.nframes = 3;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
- U64_DATA(&txmsg.frame[1]) = (__u64) 0x01000000000000FFULL;
- U64_DATA(&txmsg.frame[2]) = (__u64) 0x02000000000000FFULL;
-
- printf("<*>Writing multiplex RX_SETUP for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x4200000000000000ULL;
-
- printf("<A>Writing TX_SEND with wrong MUX ID 42\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
- printf("<B>Writing TX_SEND with correct MUX ID 01\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<B>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
- printf("<C>Writing TX_SEND with correct MUX ID 01 but no data change\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567800ULL;
-
- printf("<D>Writing TX_SEND with correct MUX ID 01 but no relevant data change\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567801ULL;
-
- printf("<E>Writing TX_SEND with correct MUX ID 01 with relevant data change\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<E>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000000ULL;
-
- printf("<F>Writing TX_SEND with correct MUX ID 02\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<F>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
- printf("<10>Writing TX_SEND with correct MUX ID 02 with relevant data change\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<10>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 7;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
- printf("<11>Writing TX_SEND with correct MUX ID 02 no data change but DLC\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<11>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 7;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0300000000000001ULL;
-
- printf("<12>Writing TX_SEND with wrong MUX ID 03\n");
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_TIMEOUT &&
- nbytes == sizeof(struct bcm_msg_head) &&
- rxmsg.msg_head.can_id == 0x42) {
- printf("<-->Received correct RX_TIMEOUT message for can_id <%03X> >> OK!\n",
- rxmsg.msg_head.can_id);
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-rtr.c filter-tests-new/tst-bcm-rtr.c
--- filter-tests/tst-bcm-rtr.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-rtr.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,146 +0,0 @@
-/*
- * $Id: tst-bcm-rtr.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-rtr.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define RTR_SETUP
-
-int main(int argc, char **argv)
-{
- int s,nbytes;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct timeval tv;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame;
- } txmsg, rxmsg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
-#ifdef RTR_SETUP
- /* specify CAN-Frame to send as reply to a RTR-request */
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x359 | CAN_RTR_FLAG;
- txmsg.msg_head.flags = RX_RTR_FRAME; /* | TX_CP_CAN_ID */;
- txmsg.msg_head.ival1.tv_sec = 0; /* no timers in RTR-mode */
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 1; /* exact 1 */
-
- /* the frame to send as reply ... */
- txmsg.frame.can_id = 0x359; /* 'should' be the same */
- txmsg.frame.can_dlc = 3;
- txmsg.frame.data[0] = 0x12;
- txmsg.frame.data[1] = 0x34;
- txmsg.frame.data[2] = 0x56;
-
-#else
- /* normal receiption of RTR-frames in Userspace */
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x359 | CAN_RTR_FLAG;
- txmsg.msg_head.flags = RX_FILTER_ID;
- txmsg.msg_head.ival1.tv_sec = 0;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 0;
-#endif
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- while (1) {
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
- (rxmsg.msg_head.can_id & CAN_SFF_MASK) == 0x359 &&
- (rxmsg.frame.can_id & CAN_SFF_MASK) == 0x359) {
- printf("RX_CHANGED message for can_id <%03X> RTR = %d\n",
- rxmsg.frame.can_id, (rxmsg.frame.can_id & CAN_RTR_FLAG)?1:0);
- }
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-rx-sendto.c filter-tests-new/tst-bcm-rx-sendto.c
--- filter-tests/tst-bcm-rx-sendto.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-rx-sendto.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,163 +0,0 @@
-/*
- * $Id: tst-bcm-rx-sendto.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-rx-sendto.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-int main(int argc, char **argv)
-{
- int s,nbytes;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct timeval tv;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame;
- } txmsg, rxmsg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- addr.can_ifindex = 0; /* bind to 'any' device */
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- memset(&txmsg, 0, sizeof(txmsg)); /* clear timers, nframes, etc. */
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x123;
- txmsg.msg_head.flags = RX_FILTER_ID;
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x321;
- txmsg.msg_head.flags = RX_FILTER_ID;
-
- if (sendto(s, &txmsg, sizeof(txmsg), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0)
- perror("sendto");
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan1");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x424;
- txmsg.msg_head.flags = RX_FILTER_ID;
-
- if (sendto(s, &txmsg, sizeof(txmsg), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0)
- perror("sendto");
-
- while (1) {
- socklen_t len = sizeof(addr);
- nbytes = recvfrom(s, &rxmsg, sizeof(rxmsg),
- 0, (struct sockaddr*)&addr, &len);
- if (nbytes < 0) {
- perror("recvfrom");
- return 1;
- } else if (nbytes < sizeof(rxmsg)) {
- fprintf(stderr, "recvfrom: incomplete BCM message from iface %d\n",
- addr.can_ifindex);
- return 1;
- } else {
- int i;
-
- ioctl(s, SIOCGSTAMP, &tv);
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- ifr.ifr_ifindex = addr.can_ifindex;
- ioctl(s, SIOCGIFNAME, &ifr);
-
- printf(" %-5s ", ifr.ifr_name);
- if (rxmsg.frame.can_id & CAN_EFF_FLAG)
- printf("%8X ", rxmsg.frame.can_id & CAN_EFF_MASK);
- else
- printf("%3X ", rxmsg.frame.can_id & CAN_SFF_MASK);
-
- printf("[%d] ", rxmsg.frame.can_dlc);
-
- for (i = 0; i < rxmsg.frame.can_dlc; i++) {
- printf("%02X ", rxmsg.frame.data[i]);
- }
- if (rxmsg.frame.can_id & CAN_RTR_FLAG)
- printf("remote request");
- printf("\n");
- fflush(stdout);
- }
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-server.c filter-tests-new/tst-bcm-server.c
--- filter-tests/tst-bcm-server.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-server.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,265 +0,0 @@
-/*
- * $Id: tst-bcm-server.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-server.c
- *
- * Test programm that implements a socket server which understands ASCII
- * messages for simple broadcast manager frame send commands.
- *
- * < interface command ival_s ival_us can_id can_dlc [data]* >
- *
- * The commands are 'A'dd, 'U'pdate, 'D'elete and 'S'end.
- * e.g.
- *
- * Send the CAN frame 123#1122334455667788 every second on vcan1
- * < vcan1 A 1 0 123 8 11 22 33 44 55 66 77 88 >
- *
- * Send the CAN frame 123#1122334455667788 every 10 usecs on vcan1
- * < vcan1 A 0 10 123 8 11 22 33 44 55 66 77 88 >
- *
- * Send the CAN frame 123#42424242 every 20 msecs on vcan1
- * < vcan1 A 0 20000 123 4 42 42 42 42 >
- *
- * Update the CAN frame 123#42424242 with 123#112233 - no change of timers
- * < vcan1 U 0 0 123 3 11 22 33 >
- *
- * Delete the cyclic send job from above
- * < vcan1 D 0 0 123 0 >
- *
- * Send a single CAN frame without cyclic transmission
- * < can0 S 0 0 123 0 >
- *
- * When the socket is closed the cyclic transmissions are terminated.
- *
- * Authors:
- * Andre Naujoks (the socket server stuff)
- * Oliver Hartkopp (the rest)
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-#include <netinet/in.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-void readmsg(int sock, char *buf, int maxlen) {
-
- int ptr = 0;
-
- while (read(sock, buf+ptr, 1) == 1) {
-
- if (ptr) {
- if (*(buf+ptr) == '>') {
- *(buf+ptr+1) = 0;
- return;
- }
- if (++ptr > maxlen-2)
- ptr = 0;
- }
- else
- if (*(buf+ptr) == '<')
- ptr++;
- }
-
- *buf = 0;
-}
-
-
-int main(int argc, char **argv)
-{
-
- int sl, sa, sc;
- struct sockaddr_in saddr, clientaddr;
- struct sockaddr_can caddr;
- struct ifreq ifr;
- socklen_t sin_size = sizeof(clientaddr);
-
- char buf[100];
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame;
- } msg;
-
- if((sl = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
- perror("inetsocket");
- exit(1);
- }
-
- saddr.sin_family = AF_INET;
- saddr.sin_addr.s_addr = htonl(INADDR_ANY);
- saddr.sin_port = htons(28600);
-
- while(bind(sl,(struct sockaddr*)&saddr, sizeof(saddr)) < 0) {
- printf(".");fflush(NULL);
- usleep(100000);
- }
-
- if (listen(sl,3) != 0) {
- perror("listen");
- exit(1);
- }
-
- while (1) {
- sa = accept(sl,(struct sockaddr *)&clientaddr, &sin_size);
- if (sa > 0 ){
-
- if (fork())
- close(sa);
- else
- break;
- }
- else {
- if (errno != EINTR) {
- /*
- * If the cause for the error was NOT the signal from
- * a dying child, than give an error
- */
- perror("accept");
- exit(1);
- }
- }
- }
-
- /* open BCM socket */
-
- if ((sc = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("bcmsocket");
- return 1;
- }
-
- caddr.can_family = PF_CAN;
- caddr.can_ifindex = 0; /* any device => need for sendto() */
-
- if (connect(sc, (struct sockaddr *)&caddr, sizeof(caddr)) < 0) {
- perror("connect");
- return 1;
- }
-
- /* prepare stable settings */
- msg.msg_head.nframes = 1;
- msg.msg_head.count = 0;
- msg.msg_head.ival1.tv_sec = 0;
- msg.msg_head.ival1.tv_usec = 0;
-
- while (1) {
-
- char cmd;
- int items;
-
- readmsg(sa, buf, sizeof(buf));
-
- // printf("read '%s'\n", buf);
-
- items = sscanf(buf, "< %6s %c %lu %lu %x %hhu "
- "%hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx >",
- ifr.ifr_name,
- &cmd,
- &msg.msg_head.ival2.tv_sec,
- &msg.msg_head.ival2.tv_usec,
- &msg.msg_head.can_id,
- &msg.frame.can_dlc,
- &msg.frame.data[0],
- &msg.frame.data[1],
- &msg.frame.data[2],
- &msg.frame.data[3],
- &msg.frame.data[4],
- &msg.frame.data[5],
- &msg.frame.data[6],
- &msg.frame.data[7]);
-
- if (items < 6)
- break;
- if (msg.frame.can_dlc > 8)
- break;
- if (items != 6 + msg.frame.can_dlc)
- break;
-
- msg.frame.can_id = msg.msg_head.can_id;
-
- switch (cmd) {
- case 'S':
- msg.msg_head.opcode = TX_SEND;
- break;
- case 'A':
- msg.msg_head.opcode = TX_SETUP;
- msg.msg_head.flags |= SETTIMER|STARTTIMER;
- break;
- case 'U':
- msg.msg_head.opcode = TX_SETUP;
- msg.msg_head.flags = 0;
- break;
- case 'D':
- msg.msg_head.opcode = TX_DELETE;
- break;
-
- default:
- printf("unknown command '%c'.\n", cmd);
- exit(1);
- }
-
- if (!ioctl(sc, SIOCGIFINDEX, &ifr)) {
- caddr.can_ifindex = ifr.ifr_ifindex;
- sendto(sc, &msg, sizeof(msg), 0,
- (struct sockaddr*)&caddr, sizeof(caddr));
- }
-
- }
-
- close(sc);
- close(sa);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-single.c filter-tests-new/tst-bcm-single.c
--- filter-tests/tst-bcm-single.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-single.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,112 +0,0 @@
-/*
- * $Id: tst-bcm-single.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-single.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame;
- } msg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- msg.msg_head.opcode = TX_SEND;
- msg.msg_head.can_id = 0x760;
- msg.msg_head.flags = 0;
- msg.msg_head.nframes = 1;
- msg.msg_head.count = 0;
- msg.msg_head.ival1.tv_sec = 0;
- msg.msg_head.ival1.tv_usec = 0;
- msg.msg_head.ival2.tv_sec = 0;
- msg.msg_head.ival2.tv_usec = 0;
- msg.frame.can_id = 0x760;
- msg.frame.can_dlc = 6;
- msg.frame.data[0] = 0xA1;
- msg.frame.data[1] = 0x0F;
- msg.frame.data[2] = 0x10;
- msg.frame.data[3] = 0x00;
- msg.frame.data[4] = 0x00;
- msg.frame.data[5] = 0x00;
-
-
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-throttle.c filter-tests-new/tst-bcm-throttle.c
--- filter-tests/tst-bcm-throttle.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-throttle.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,466 +0,0 @@
-/*
- * $Id: tst-bcm-throttle.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-throttle.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-#define BCM_1FRAME_LEN (sizeof(struct bcm_msg_head) + sizeof(struct can_frame))
-int main(int argc, char **argv)
-{
- int s,nbytes;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame[3];
- } txmsg, rxmsg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x042;
- txmsg.msg_head.flags = SETTIMER|RX_FILTER_ID;
- txmsg.msg_head.ival1.tv_sec = 4;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 2;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 0;
-
- printf("<*>Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(struct bcm_msg_head)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- /* obsolete for TX_SEND ... */
-#if 0
- txmsg.msg_head.can_id = 0x43;
- txmsg.msg_head.flags = SETTIMER|STARTTIMER|TX_CP_CAN_ID;
- txmsg.msg_head.count = 0;
- txmsg.msg_head.ival1.tv_sec = 0;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
-#endif
- txmsg.frame[0].can_id = 0x43;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<2>Writing TX_SEND with wrong can_id <%03X>\n",
- txmsg.frame[0].can_id);
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<3>Writing TX_SEND with correct can_id <%03X>\n",
- txmsg.frame[0].can_id);
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<3>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- /* growing number of nframes => RX_DELETE instead of simple update */
- txmsg.msg_head.opcode = RX_DELETE;
- txmsg.msg_head.can_id = 0x042; /* everything we need for RX_DELETE */
-
- printf("<*>Writing RX_DELETE for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(struct bcm_msg_head)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x042;
- txmsg.msg_head.flags = SETTIMER|RX_CHECK_DLC;
- txmsg.msg_head.ival1.tv_sec = 4;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 2;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 1;
- /* txmsg.frame[0].can_dlc = 8; obsolete for RX_SETUP */
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
-
- printf("<*>Writing simple RX_SETUP for can_id <%03X> with msgbits 0x%016llX\n",
- txmsg.msg_head.can_id, U64_DATA(&txmsg.frame[0]));
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<5>Writing TX_SEND with correct can_id <%03X>\n",
- txmsg.frame[0].can_id);
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<5>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<6>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("no changed data\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- /* no change here */
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<7>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("changed relevant msgbits\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<7>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<8>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("changed irrelevant msgbits\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 7;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- printf("<9>Writing TX_SEND with correct can_id <%03X> ",
- txmsg.frame[0].can_id);
- printf("changed Data Length Code DLC\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<9>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- /* no problems ;-) but NOW we try MUX messages ... and timeouts */
-
- /* growing number of nframes => RX_DELETE instead of simple update */
- txmsg.msg_head.opcode = RX_DELETE;
- txmsg.msg_head.can_id = 0x042; /* everything we need for RX_DELETE */
-
- printf("<*>Writing RX_DELETE for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(struct bcm_msg_head)) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = RX_SETUP;
- txmsg.msg_head.can_id = 0x042;
- txmsg.msg_head.flags = SETTIMER|RX_CHECK_DLC;
- txmsg.msg_head.ival1.tv_sec = 4;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 2;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.msg_head.nframes = 3;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
- U64_DATA(&txmsg.frame[1]) = (__u64) 0x01000000000000FFULL;
- U64_DATA(&txmsg.frame[2]) = (__u64) 0x02000000000000FFULL;
-
- printf("<*>Writing multiplex RX_SETUP for can_id <%03X>\n",
- txmsg.msg_head.can_id);
-
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x4200000000000000ULL;
-
- printf("<A>Writing TX_SEND with wrong MUX ID 42\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
- printf("<B>Writing TX_SEND with correct MUX ID 01\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<B>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
- printf("<C>Writing TX_SEND with correct MUX ID 01 but no data change\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567800ULL;
-
- printf("<D>Writing TX_SEND with correct MUX ID 01 but no relevant data change\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567801ULL;
-
- printf("<E>Writing TX_SEND with correct MUX ID 01 with relevant data change\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<E>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000000ULL;
-
- printf("<F>Writing TX_SEND with correct MUX ID 02\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<F>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 8;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
- printf("<10>Writing TX_SEND with correct MUX ID 02 with relevant data change\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<10>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 7;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
- printf("<11>Writing TX_SEND with correct MUX ID 02 no data change but DLC\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_CHANGED &&
- nbytes == BCM_1FRAME_LEN &&
- rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
- printf("<11>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
- rxmsg.frame[0].can_id);
- }
-
- txmsg.msg_head.opcode = TX_SEND;
- txmsg.msg_head.nframes = 1;
- txmsg.frame[0].can_id = 0x42;
- txmsg.frame[0].can_dlc = 7;
- U64_DATA(&txmsg.frame[0]) = (__u64) 0x0300000000000001ULL;
-
- printf("<12>Writing TX_SEND with wrong MUX ID 03\n");
-
- if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
- perror("write");
-
- if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
- perror("read");
-
- if (rxmsg.msg_head.opcode == RX_TIMEOUT &&
- nbytes == sizeof(struct bcm_msg_head) &&
- rxmsg.msg_head.can_id == 0x42) {
- printf("<-->Received correct RX_TIMEOUT message for can_id <%03X> >> OK!\n",
- rxmsg.msg_head.can_id);
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-tx_read.c filter-tests-new/tst-bcm-tx_read.c
--- filter-tests/tst-bcm-tx_read.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-tx_read.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,159 +0,0 @@
-/*
- * $Id: tst-bcm-tx_read.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-tx_read.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
- int s,i,nbytes;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame[4];
- } msg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- msg.msg_head.opcode = TX_SETUP;
- msg.msg_head.can_id = 0x42;
- msg.msg_head.flags = SETTIMER|STARTTIMER|TX_CP_CAN_ID|TX_COUNTEVT;
- msg.msg_head.nframes = 1;
- msg.msg_head.count = 2;
- msg.msg_head.ival1.tv_sec = 3;
- msg.msg_head.ival1.tv_usec = 0;
- msg.msg_head.ival2.tv_sec = 5;
- msg.msg_head.ival2.tv_usec = 0;
- msg.frame[0].can_id = 0xAA;
- msg.frame[0].can_dlc = 8;
- U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
-
- printf("Press any key to stop the cycle ...\n");
-
- getchar();
-
- msg.msg_head.opcode = TX_SETUP;
- msg.msg_head.can_id = 0x42;
- msg.msg_head.flags = SETTIMER|STARTTIMER|TX_CP_CAN_ID;
- msg.msg_head.nframes = 1;
- msg.msg_head.count = 0;
- msg.msg_head.ival1.tv_sec = 0;
- msg.msg_head.ival1.tv_usec = 0;
- msg.msg_head.ival2.tv_sec = 0;
- msg.msg_head.ival2.tv_usec = 0;
- msg.frame[0].can_id = 0xAA;
- msg.frame[0].can_dlc = 8;
- U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
-
- printf("Press any key to read the entry ...\n");
-
- getchar();
-
- msg.msg_head.opcode = TX_READ;
- msg.msg_head.can_id = 0x42;
- msg.msg_head.nframes = 0;
-
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
-
- printf("Press any key to read from the socket ...\n");
-
- getchar();
-
- if ((nbytes = read(s, &msg, sizeof(msg))) < 0)
- perror("read");
- for (i = 0; i < nbytes; i++)
- printf(" %02x", ((unsigned char*)&msg)[i]);
- putchar('\n');
-
- printf("Press any key to close the socket ...\n");
-
- getchar();
-
- close(s);
-
- printf("Press any key to end the program ...\n");
-
- getchar();
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-tx-sendto.c filter-tests-new/tst-bcm-tx-sendto.c
--- filter-tests/tst-bcm-tx-sendto.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-tx-sendto.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,123 +0,0 @@
-/*
- * $Id: tst-bcm-tx-sendto.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-tx-sendto.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct ifreq ifr;
-
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame;
- } txmsg;
-
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- addr.can_ifindex = 0; /* bind to 'any' device */
-
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
-
- txmsg.msg_head.opcode = TX_SETUP;
- txmsg.msg_head.can_id = 0x42;
- txmsg.msg_head.flags = SETTIMER|STARTTIMER;
- txmsg.msg_head.nframes = 1;
- txmsg.msg_head.count = 10;
- txmsg.msg_head.ival1.tv_sec = 1;
- txmsg.msg_head.ival1.tv_usec = 0;
- txmsg.msg_head.ival2.tv_sec = 0;
- txmsg.msg_head.ival2.tv_usec = 0;
- txmsg.frame.can_id = 0x42;
- txmsg.frame.can_dlc = 8;
- U64_DATA(&txmsg.frame) = (__u64) 0xdeadbeefdeadbeefULL;
-
- /* should cause an error due to ifindex = 0 */
- if (write(s, &txmsg, sizeof(txmsg)) < 0)
- perror("write");
-
- printf("Press any key to send on valid device ...\n");
- getchar();
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (sendto(s, &txmsg, sizeof(txmsg), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0)
- perror("sendto");
-
- printf("Press any key to close the socket ...\n");
- getchar();
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-err.c filter-tests-new/tst-err.c
--- filter-tests/tst-err.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-err.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,168 +0,0 @@
-/*
- * $Id: tst-err.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-err.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-#include <linux/can/error.h>
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct can_filter rfilter;
- struct can_frame frame;
- can_err_mask_t err_mask = CAN_ERR_MASK; /* all */
- int nbytes;
- struct ifreq ifr;
- char *ifname = "vcan2";
- int ifindex;
- int opt;
- struct timeval tv;
-
- while ((opt = getopt(argc, argv, "i:m:")) != -1) {
- switch (opt) {
- case 'i':
- ifname = optarg;
- break;
- case 'm':
- err_mask = strtoul(optarg, (char **)NULL, 16);
- break;
- default:
- fprintf(stderr, "Unknown option %c\n", opt);
- break;
- }
- }
-
-
- if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
-
- rfilter.can_id = CAN_INV_FILTER; /* no normal CAN frames */
- rfilter.can_mask = 0; /* all: INV(all) == nothing */
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &err_mask, sizeof(err_mask));
-
- strcpy(ifr.ifr_name, ifname);
- ioctl(s, SIOCGIFINDEX, &ifr);
- ifindex = ifr.ifr_ifindex;
-
- addr.can_family = AF_CAN;
- addr.can_ifindex = ifindex;
-
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
-
- while (1) {
-
- if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
- perror("read");
- return 1;
- } else if (nbytes < sizeof(struct can_frame)) {
- fprintf(stderr, "read: incomplete CAN frame\n");
- return 1;
- } else {
- if (ioctl(s, SIOCGSTAMP, &tv) < 0)
- perror("SIOCGSTAMP");
- else
- printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
- if (frame.can_id & CAN_ERR_BUSOFF)
- printf("(bus off) ");
-
- if (frame.can_id & CAN_ERR_TX_TIMEOUT)
- printf("(tx timeout) ");
-
- if (frame.can_id & CAN_ERR_ACK)
- printf("(ack) ");
-
- if (frame.can_id & CAN_ERR_LOSTARB) {
- printf("(lost arb)");
- if (frame.data[0])
- printf("[%d]", frame.data[0]);
- printf(" ");
- }
-
- if (frame.can_id & CAN_ERR_CRTL) {
- printf("(crtl)");
- if (frame.data[1] & CAN_ERR_CRTL_RX_OVERFLOW)
- printf("[RX buffer overflow]");
- if (frame.data[1] & CAN_ERR_CRTL_TX_OVERFLOW)
- printf("[TX buffer overflow]");
- if (frame.data[1] & CAN_ERR_CRTL_RX_WARNING)
- printf("[RX warning]");
- if (frame.data[1] & CAN_ERR_CRTL_TX_WARNING)
- printf("[TX warning]");
- printf(" ");
- }
-
- /* to be continued */
-
- printf("\n");
- fflush(stdout);
- }
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-filter.c filter-tests-new/tst-filter.c
--- filter-tests/tst-filter.c 1970-01-01 01:00:00.000000000 +0100
+++ filter-tests-new/tst-filter.c 2011-07-10 13:17:38.035710992 +0200
@@ -0,0 +1,244 @@
+/*
+ * $Id: tst-filter.c 1263 2011-07-09 18:00:41Z hartkopp $
+ */
+
+/*
+ * tst-filter.c
+ *
+ * Copyright (c) 2011 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-users@lists.berlios.de>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <net/if.h>
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#define ID 0x123
+#define TC 18 /* # of testcases */
+
+const int rx_res[TC] = {4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1};
+const int rxbits_res[TC] = {4369, 4369, 4369, 4369, 17, 4352, 17, 4352, 257, 257, 4112, 4112, 1, 256, 16, 4096, 1, 256};
+
+canid_t calc_id(int testcase)
+{
+ canid_t id = ID;
+
+ if (testcase & 1)
+ id |= CAN_EFF_FLAG;
+ if (testcase & 2)
+ id |= CAN_RTR_FLAG;
+
+ return id;
+}
+
+canid_t calc_mask(int testcase)
+{
+ canid_t mask = CAN_SFF_MASK;
+
+ if (testcase > 15)
+ return (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG);
+
+ if (testcase & 4)
+ mask |= CAN_EFF_FLAG;
+ if (testcase & 8)
+ mask |= CAN_RTR_FLAG;
+
+ return mask;
+}
+
+int main(int argc, char **argv)
+{
+ fd_set rdfs;
+ struct timeval tv;
+ int s;
+ struct sockaddr_can addr;
+ struct can_filter rfilter;
+ struct can_frame frame;
+ int testcase;
+ int have_rx;
+ int rx;
+ int rxbits, rxbitval;
+ int ret;
+ int recv_own_msgs = 1;
+ struct ifreq ifr;
+
+ /* check command line options */
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <device>\n", argv[0]);
+ return 1;
+ }
+
+ if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+ perror("socket");
+ return 1;
+ }
+
+ strcpy(ifr.ifr_name, argv[1]);
+ if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
+ perror("SIOCGIFINDEX");
+ return 1;
+ }
+ addr.can_family = AF_CAN;
+ addr.can_ifindex = ifr.ifr_ifindex;
+
+ setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
+ &recv_own_msgs, sizeof(recv_own_msgs));
+
+ if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ perror("bind");
+ return 1;
+ }
+
+ printf("---\n");
+
+ for (testcase = 0; testcase < TC; testcase++) {
+
+ rfilter.can_id = calc_id(testcase);
+ rfilter.can_mask = calc_mask(testcase);
+ setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER,
+ &rfilter, sizeof(rfilter));
+
+ printf("testcase %2d filters : can_id = 0x%08X can_mask = 0x%08X\n",
+ testcase, rfilter.can_id, rfilter.can_mask);
+
+ printf("testcase %2d sending patterns ... ", testcase);
+
+ frame.can_dlc = 1;
+ frame.data[0] = testcase;
+
+ frame.can_id = ID;
+ if (write(s, &frame, sizeof(frame)) < 0) {
+ perror("write");
+ exit(1);
+ }
+ frame.can_id = (ID | CAN_RTR_FLAG);
+ if (write(s, &frame, sizeof(frame)) < 0) {
+ perror("write");
+ exit(1);
+ }
+ frame.can_id = (ID | CAN_EFF_FLAG);
+ if (write(s, &frame, sizeof(frame)) < 0) {
+ perror("write");
+ exit(1);
+ }
+ frame.can_id = (ID | CAN_EFF_FLAG | CAN_RTR_FLAG);
+ if (write(s, &frame, sizeof(frame)) < 0) {
+ perror("write");
+ exit(1);
+ }
+
+ printf("ok\n");
+
+ have_rx = 1;
+ rx = 0;
+ rxbits = 0;
+
+ while (have_rx) {
+
+ have_rx = 0;
+ FD_ZERO(&rdfs);
+ FD_SET(s, &rdfs);
+ tv.tv_sec = 0;
+ tv.tv_usec = 50000; /* 50ms timeout */
+
+ ret = select(s+1, &rdfs, NULL, NULL, &tv);
+ if (ret < 0) {
+ perror("select");
+ exit(1);
+ }
+
+ if (FD_ISSET(s, &rdfs)) {
+ have_rx = 1;
+ ret = read(s, &frame, sizeof(struct can_frame));
+ if (ret < 0) {
+ perror("read");
+ exit(1);
+ }
+ if ((frame.can_id & CAN_SFF_MASK) != ID) {
+ fprintf(stderr, "received wrong can_id!\n");
+ exit(1);
+ }
+ if (frame.data[0] != testcase) {
+ fprintf(stderr, "received wrong testcase!\n");
+ exit(1);
+ }
+
+ /* test & calc rxbits */
+ rxbitval = 1 << ((frame.can_id & (CAN_EFF_FLAG|CAN_RTR_FLAG|CAN_ERR_FLAG)) >> 28);
+
+ /* only receive a rxbitval once */
+ if ((rxbits & rxbitval) == rxbitval) {
+ fprintf(stderr, "received rxbitval %d twice!\n", rxbitval);
+ exit(1);
+ }
+ rxbits |= rxbitval;
+ rx++;
+
+ printf("testcase %2d rx : can_id = 0x%08X rx = %d rxbits = %d\n",
+ testcase, frame.can_id, rx, rxbits);
+ }
+ }
+ /* rx timed out -> check the received results */
+ if (rx_res[testcase] != rx) {
+ fprintf(stderr, "wrong rx value in testcase %d : %d (expected %d)\n",
+ testcase, rx, rx_res[testcase]);
+ exit(1);
+ }
+ if (rxbits_res[testcase] != rxbits) {
+ fprintf(stderr, "wrong rxbits value in testcase %d : %d (expected %d)\n",
+ testcase, rxbits, rxbits_res[testcase]);
+ exit(1);
+ }
+ printf("testcase %2d ok\n---\n", testcase);
+ }
+
+ close(s);
+
+ return 0;
+}
diff -u -N -r filter-tests/tst-filter-master.c filter-tests-new/tst-filter-master.c
--- filter-tests/tst-filter-master.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-filter-master.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,167 +0,0 @@
-/*
- * $Id: tst-filter-master.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-filter-master.c
- *
- * Copyright (c) 2008 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct can_filter rfilter;
- struct can_frame frame;
- int testcase;
- int nbytes;
- struct ifreq ifr;
- int ifindex;
-
-
- if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
-
- strcpy(ifr.ifr_name, "vcan0");
- ioctl(s, SIOCGIFINDEX, &ifr);
- ifindex = ifr.ifr_ifindex;
-
- addr.can_family = AF_CAN;
- addr.can_ifindex = ifindex;
-
- rfilter.can_id = 0xFA; /* receive only the filter ack */
- rfilter.can_mask = CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG;
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
-
- /* send testcases 0 .. 17 and a terminating 18 to quit */
- for (testcase = 0; testcase < 19; testcase++) {
-
- printf("Sending testcase %2d ... ", testcase);
- frame.can_id = 0x0F;
- frame.can_dlc = 1;
- frame.data[0] = testcase;
-
- if (write(s, &frame, sizeof(frame)) < 0) {
- perror("write");
- exit(1);
- }
-
- /* wait for ACK from server */
- if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
- perror("read");
- exit(1);
- }
-
- if (nbytes < sizeof(struct can_frame)) {
- fprintf(stderr, "read: incomplete CAN frame\n");
- exit(1);
- }
-
- if ((frame.can_id != 0xFA) || (frame.can_dlc != 1) ||
- (frame.data[0] != testcase)) {
- fprintf(stderr, "\nWrong answer from server!\n");
- exit(1);
- }
-
- printf("acked. ");
- if (testcase > 17)
- break;
-
- /* interactive mode, when there is any commandline option */
- if (argc == 2) {
- printf("[press enter] ");
- getchar();
- }
-
- printf("Sending patterns ... ");
-
- frame.can_dlc = 0;
-
- frame.can_id = 0x123;
- if (write(s, &frame, sizeof(frame)) < 0) {
- perror("write");
- exit(1);
- }
- frame.can_id = (0x123 | CAN_RTR_FLAG);
- if (write(s, &frame, sizeof(frame)) < 0) {
- perror("write");
- exit(1);
- }
- frame.can_id = (0x123 | CAN_EFF_FLAG);
- if (write(s, &frame, sizeof(frame)) < 0) {
- perror("write");
- exit(1);
- }
- frame.can_id = (0x123 | CAN_EFF_FLAG | CAN_RTR_FLAG);
- if (write(s, &frame, sizeof(frame)) < 0) {
- perror("write");
- exit(1);
- }
-
- printf("ok\n");
- }
-
- printf("Filtertest done.\n");
-
- close(s);
- return 0;
-}
-
diff -u -N -r filter-tests/tst-filter-server.c filter-tests-new/tst-filter-server.c
--- filter-tests/tst-filter-server.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-filter-server.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,212 +0,0 @@
-/*
- * $Id: tst-filter-server.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-filter-server.c
- *
- * Copyright (c) 2008 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define ID 0x123
-#define FIL 0x7FF
-#define EFF CAN_EFF_FLAG
-#define RTR CAN_RTR_FLAG
-
-canid_t calc_id(int testcase)
-{
- canid_t id = ID;
-
- if (testcase & 1)
- id |= EFF;
- if (testcase & 2)
- id |= RTR;
-
- return id;
-}
-
-canid_t calc_mask(int testcase)
-{
- canid_t mask = FIL;
-
- if (testcase > 15)
- return (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG);
-
- if (testcase & 4)
- mask |= EFF;
- if (testcase & 8)
- mask |= RTR;
-
- return mask;
-}
-
-int main(int argc, char **argv)
-{
- fd_set rdfs;
- int s, t;
- struct sockaddr_can addr;
- struct can_filter rfilter;
- struct can_frame frame;
- int testcase = 0;
- int nbytes, ret;
- struct ifreq ifr;
- int ifindex;
-
-
- if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
- if ((t = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
-
- strcpy(ifr.ifr_name, "vcan0");
- ioctl(s, SIOCGIFINDEX, &ifr);
- ifindex = ifr.ifr_ifindex;
-
- addr.can_family = AF_CAN;
- addr.can_ifindex = ifindex;
-
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
- if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
-
- rfilter.can_id = 0xF; /* receive only the filter requests */
- rfilter.can_mask = CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG;
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
- /* disable default receive filter on the test socket */
- setsockopt(t, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
-
- while (1) {
-
- FD_ZERO(&rdfs);
- FD_SET(s, &rdfs);
- FD_SET(t, &rdfs);
-
- if ((ret = select(t+1, &rdfs, NULL, NULL, NULL)) < 0) {
- perror("select");
- break;
- }
-
- if (FD_ISSET(s, &rdfs)) {
-
- if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
- perror("read");
- exit(1);
- }
-
- if (nbytes < sizeof(struct can_frame)) {
- fprintf(stderr, "read: incomplete CAN frame\n");
- exit(1);
- }
-
- if ((frame.can_id != 0xF) || (frame.can_dlc != 1)) {
- fprintf(stderr, "\nWrong request from master!\n");
- exit(1);
- }
-
- testcase = frame.data[0];
-
- if (testcase < 18) {
- rfilter.can_id = calc_id(testcase);
- rfilter.can_mask = calc_mask(testcase);
- setsockopt(t, SOL_CAN_RAW, CAN_RAW_FILTER,
- &rfilter, sizeof(rfilter));
-
- printf("testcase %2d : can_id = 0x%08X can_mask = 0x%08X\n",
- testcase, rfilter.can_id, rfilter.can_mask);
- }
-
- frame.can_id = 0xFA; /* filter ack */
-
- if (write(s, &frame, sizeof(frame)) < 0) {
- perror("write");
- exit(1);
- }
-
- if (testcase > 17)
- break;
- }
-
- if (FD_ISSET(t, &rdfs)) {
-
- if ((nbytes = read(t, &frame, sizeof(struct can_frame))) < 0) {
- perror("read");
- exit(1);
- }
-
- if (nbytes < sizeof(struct can_frame)) {
- fprintf(stderr, "read: incomplete CAN frame\n");
- exit(1);
- }
-
- printf ("%08X\n", frame.can_id);
- }
- }
-
- printf("testcase %2d : Filtertest done.\n", testcase);
-
- close(s);
- close(t);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-packet.c filter-tests-new/tst-packet.c
--- filter-tests/tst-packet.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-packet.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,168 +0,0 @@
-/*
- * $Id: tst-packet.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-packet.c - send and receive CAN frames via PF_PACKET sockets
- *
- * Remark: The sending of CAN frames via PF_PACKET does not work for
- * virtual CAN devices (vcan) as the packet type is not set to
- * PACKET_LOOPBACK by the packet socket, so you'll never get something
- * back (btw the outgoing vcan packet counters are updated correctly).
- *
- * Copyright (c) 2002-2009 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <netinet/in.h> /* for htons() */
-
-#include <linux/if_packet.h>
-#include <linux/if_ether.h> /* for ETH_P_CAN */
-#include <linux/can.h> /* for struct can_frame */
-
-int main(int argc, char **argv)
-{
- int s;
- struct can_frame frame;
- int nbytes, i;
- static struct ifreq ifr;
- static struct sockaddr_ll sll;
- char *ifname = "vcan2";
- int ifindex;
- int opt;
- int send_one_frame = 0;
-
- while ((opt = getopt(argc, argv, "i:s")) != -1) {
- switch (opt) {
-
- case 'i':
- ifname = optarg;
- break;
-
- case 's':
- send_one_frame = 1;
- break;
-
- default:
- fprintf(stderr, "Unknown option %c\n", opt);
- break;
- }
- }
-
- s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_CAN));
- if (s < 0) {
- perror("socket");
- return 1;
- }
-
- if (strcmp(ifname, "any") == 0)
- ifindex = 0;
- else {
- strcpy(ifr.ifr_name, ifname);
- ioctl(s, SIOCGIFINDEX, &ifr);
- ifindex = ifr.ifr_ifindex;
- }
-
- sll.sll_family = AF_PACKET;
- sll.sll_ifindex = ifindex;
- sll.sll_protocol = htons(ETH_P_CAN);
-
- if (bind(s, (struct sockaddr *)&sll, sizeof(sll)) < 0) {
- perror("bind");
- return 1;
- }
-
- if(send_one_frame) {
-
- frame.can_id = 0x123;
- frame.can_dlc = 2;
- frame.data[0] = 0x11;
- frame.data[1] = 0x22;
-
- nbytes = write(s, &frame, sizeof(struct can_frame));
- if (nbytes < 0) {
- perror("write");
- return 1;
- }
- if (nbytes != sizeof(struct can_frame)) {
- perror("write_len");
- return 1;
- }
- }
-
- while (1) {
-
- if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
- perror("read");
- return 1;
- } else if (nbytes < sizeof(struct can_frame)) {
- fprintf(stderr, "read: incomplete CAN frame\n");
- return 1;
- } else {
- if (frame.can_id & CAN_EFF_FLAG)
- printf("%8X ", frame.can_id & CAN_EFF_MASK);
- else
- printf("%3X ", frame.can_id & CAN_SFF_MASK);
-
- printf("[%d] ", frame.can_dlc);
-
- for (i = 0; i < frame.can_dlc; i++) {
- printf("%02X ", frame.data[i]);
- }
- if (frame.can_id & CAN_RTR_FLAG)
- printf("remote request");
- printf("\n");
- fflush(stdout);
- }
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-proc.c filter-tests-new/tst-proc.c
--- filter-tests/tst-proc.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-proc.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,121 +0,0 @@
-/*
- * $Id: tst-proc.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-proc.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define MAX_RAW 800
-
-int main(int argc, char **argv)
-{
- int s[MAX_RAW];
- struct sockaddr_can addr;
- struct ifreq ifr;
- int i,numsock;
-
- if (argc != 2) {
- fprintf(stderr, "Error: Wrong number of arguments. Try %s <number of created sockets>.\n", argv[0]);
- exit(1);
- }
-
- numsock = atoi(argv[1]);
-
- if (numsock >= MAX_RAW) {
- fprintf(stderr, "Error: more than %d sockets to open (see #define MAX_RAW).\n", MAX_RAW);
- exit(1);
- }
-
- printf("\ncreating %d raw sockets ... ", numsock);
-
- if (numsock) {
- for (i=0; i < numsock; i++) {
- if ((s[i] = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
-
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s[i], SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
-
- if (bind(s[i], (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
- }
- }
-
- printf("done.\n");
-
- printf("Waiting for keyboard input ...");
-
- getchar();
-
- printf("closing %d raw sockets ... ", numsock);
-
- if (numsock)
- for (i=0; i < numsock; i++)
- close(s[i]);
-
- printf("done.\n\n");
-
- return 0;
-
-}
-
diff -u -N -r filter-tests/tst-raw.c filter-tests-new/tst-raw.c
--- filter-tests/tst-raw.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-raw.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,188 +0,0 @@
-/*
- * $Id: tst-raw.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-raw.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct can_filter rfilter[4];
- struct can_frame frame;
- int nbytes, i;
- struct ifreq ifr;
- char *ifname = "vcan2";
- int ifindex;
- int opt;
-
- /* sockopt test */
- int loopback = 0;
- int set_loopback = 0;
- int recv_own_msgs = 0;
- int set_recv_own_msgs = 0;
- int send_one_frame = 0;
- int ignore_errors = 0;
-
- while ((opt = getopt(argc, argv, "i:l:r:se")) != -1) {
- switch (opt) {
-
- case 'i':
- ifname = optarg;
- break;
-
- case 'l':
- loopback = atoi(optarg);
- set_loopback = 1;
- break;
-
- case 'r':
- recv_own_msgs = atoi(optarg);
- set_recv_own_msgs = 1;
- break;
-
- case 's':
- send_one_frame = 1;
- break;
-
- case 'e':
- ignore_errors = 1;
- break;
-
- default:
- fprintf(stderr, "Unknown option %c\n", opt);
- break;
- }
- }
-
-
- if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
-
- rfilter[0].can_id = 0x123;
- rfilter[0].can_mask = CAN_SFF_MASK;
- rfilter[1].can_id = 0x200;
- rfilter[1].can_mask = 0x700;
- rfilter[2].can_id = 0x80123456;
- rfilter[2].can_mask = 0x1FFFF000;
- rfilter[3].can_id = 0x80333333;
- rfilter[3].can_mask = CAN_EFF_MASK;
-
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
- if(set_loopback)
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback, sizeof(loopback));
-
- if(set_recv_own_msgs)
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, &recv_own_msgs, sizeof(recv_own_msgs));
-
- strcpy(ifr.ifr_name, ifname);
- ioctl(s, SIOCGIFINDEX, &ifr);
- ifindex = ifr.ifr_ifindex;
-
- addr.can_family = AF_CAN;
- addr.can_ifindex = ifindex;
-
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
-
- if(send_one_frame) {
-
- frame.can_id = 0x123;
- frame.can_dlc = 2;
- frame.data[0] = 0x11;
- frame.data[1] = 0x22;
-
- nbytes = write(s, &frame, sizeof(struct can_frame));
- }
-
- while (1) {
-
- if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
- perror("read");
- if (!ignore_errors)
- return 1;
- } else if (nbytes < sizeof(struct can_frame)) {
- fprintf(stderr, "read: incomplete CAN frame\n");
- return 1;
- } else {
- if (frame.can_id & CAN_EFF_FLAG)
- printf("%8X ", frame.can_id & CAN_EFF_MASK);
- else
- printf("%3X ", frame.can_id & CAN_SFF_MASK);
-
- printf("[%d] ", frame.can_dlc);
-
- for (i = 0; i < frame.can_dlc; i++) {
- printf("%02X ", frame.data[i]);
- }
- if (frame.can_id & CAN_RTR_FLAG)
- printf("remote request");
- printf("\n");
- fflush(stdout);
- }
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-raw-filter.c filter-tests-new/tst-raw-filter.c
--- filter-tests/tst-raw-filter.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-raw-filter.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,179 +0,0 @@
-/*
- * $Id: tst-raw-filter.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-raw-filter.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define MAXFILTERS 32
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct can_filter rfilter[MAXFILTERS];
- struct can_frame frame;
- int nbytes, i;
- struct ifreq ifr;
- char *ifname = "any";
- int ifindex;
- int opt;
- int peek = 0;
- int nfilters = 0;
- int deflt = 0;
-
- while ((opt = getopt(argc, argv, "i:p:f:d")) != -1) {
- switch (opt) {
- case 'i': /* specify different interface than default */
- ifname = optarg;
- break;
- case 'p': /* MSG_PEEK 'p' times before consuming the frame */
- peek = atoi(optarg);
- break;
- case 'd': /* use default settings from CAN_RAW socket */
- deflt = 1;
- break;
- case 'f': /* add this filter can_id:can_mask */
- if (nfilters >= MAXFILTERS) {
- fputs("too many filters\n", stderr);
- break;
- }
- rfilter[nfilters].can_id = strtoul(strtok(optarg, ":"), NULL, 16);
- rfilter[nfilters].can_mask = strtoul(strtok(NULL, ":"), NULL, 16);
- nfilters++;
- break;
- default:
- fprintf(stderr, "Unknown option %c\n", opt);
- break;
- }
- }
-
-
- if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
-
- if (deflt) {
- printf("%s: using CAN_RAW socket default filter.\n", argv[0]);
- } else {
- printf("%s: setting %d CAN filter(s).\n", argv[0], nfilters);
- setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter,
- sizeof(*rfilter) * nfilters);
- }
-
- if (strcmp(ifname, "any") == 0)
- ifindex = 0;
- else {
- strcpy(ifr.ifr_name, ifname);
- ioctl(s, SIOCGIFINDEX, &ifr);
- ifindex = ifr.ifr_ifindex;
- }
-
- addr.can_family = AF_CAN;
- addr.can_ifindex = ifindex;
-
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
-
- while (1) {
- socklen_t len = sizeof(addr);
- int flags;
-
- if (peek && peek--)
- flags = MSG_PEEK;
- else
- flags = 0;
-
- nbytes = recvfrom(s, &frame, sizeof(struct can_frame),
- flags, (struct sockaddr*)&addr, &len);
- if (nbytes < 0) {
- perror("read");
- return 1;
- } else if (nbytes < sizeof(struct can_frame)) {
- fprintf(stderr, "read: incomplete CAN frame from iface %d\n",
- addr.can_ifindex);
- return 1;
- } else {
- ifr.ifr_ifindex = addr.can_ifindex;
- ioctl(s, SIOCGIFNAME, &ifr);
- printf(" %-5s ", ifr.ifr_name);
- if (frame.can_id & CAN_EFF_FLAG)
- printf("%8X ", frame.can_id & CAN_EFF_MASK);
- else
- printf("%3X ", frame.can_id & CAN_SFF_MASK);
-
- printf("[%d] ", frame.can_dlc);
-
- for (i = 0; i < frame.can_dlc; i++) {
- printf("%02X ", frame.data[i]);
- }
- if (frame.can_id & CAN_RTR_FLAG)
- printf("remote request");
- if (flags & MSG_PEEK)
- printf(" (MSG_PEEK)");
- printf("\n");
- fflush(stdout);
- }
- }
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-raw-sendto.c filter-tests-new/tst-raw-sendto.c
--- filter-tests/tst-raw-sendto.c 2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-raw-sendto.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,118 +0,0 @@
-/*
- * $Id: tst-raw-sendto.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-raw-sendto.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-int main(int argc, char **argv)
-{
- int s;
- struct sockaddr_can addr;
- struct can_frame frame;
- int nbytes;
- struct ifreq ifr;
- char *ifname = "vcan2";
- int ifindex;
- int opt;
-
- while ((opt = getopt(argc, argv, "i:")) != -1) {
- switch (opt) {
- case 'i':
- ifname = optarg;
- break;
- default:
- fprintf(stderr, "Unknown option %c\n", opt);
- break;
- }
- }
-
-
- if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
- perror("socket");
- return 1;
- }
-
- strcpy(ifr.ifr_name, ifname);
- ioctl(s, SIOCGIFINDEX, &ifr);
- ifindex = ifr.ifr_ifindex;
-
- addr.can_family = AF_CAN;
- addr.can_ifindex = 0; /* bind to all interfaces */
-
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("bind");
- return 1;
- }
-
-
- /* fill CAN frame */
- frame.can_id = 0x123;
- frame.can_dlc = 3;
- frame.data[0] = 0x11;
- frame.data[1] = 0x22;
- frame.data[2] = 0x33;
-
- addr.can_family = AF_CAN;
- addr.can_ifindex = ifindex; /* send via this interface */
-
- nbytes = sendto(s, &frame, sizeof(struct can_frame), 0, (struct sockaddr*)&addr, sizeof(addr));
-
- close(s);
-
- return 0;
-}
-
diff -u -N -r filter-tests/tst-rcv-own-msgs.c filter-tests-new/tst-rcv-own-msgs.c
--- filter-tests/tst-rcv-own-msgs.c 1970-01-01 01:00:00.000000000 +0100
+++ filter-tests-new/tst-rcv-own-msgs.c 2011-07-10 13:17:47.059710684 +0200
@@ -0,0 +1,247 @@
+/*
+ * $Id: tst-rcv-own-msgs.c 1193 2010-08-09 14:00:21Z hartkopp $
+ */
+
+/*
+ * tst-rcv-own-msgs.c
+ *
+ * Copyright (c) 2010 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-users@lists.berlios.de>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <net/if.h>
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+
+#define max(a,b) (a > b ? a : b)
+
+struct rxs {
+ int s;
+ int t;
+};
+
+struct rxs test_sockets(int s, int t, canid_t can_id)
+{
+ fd_set rdfs;
+ struct timeval tv;
+ int m = max(s,t)+1;
+ int have_rx = 1;
+ struct can_frame frame;
+ struct rxs rx;
+ int ret;
+
+ frame.can_id = can_id;
+ frame.can_dlc = 0;
+ if (write(s, &frame, sizeof(frame)) < 0) {
+ perror("write");
+ exit(1);
+ }
+
+ rx.s = rx.t = 0;
+
+ while (have_rx) {
+
+ FD_ZERO(&rdfs);
+ FD_SET(s, &rdfs);
+ FD_SET(t, &rdfs);
+ tv.tv_sec = 0;
+ tv.tv_usec = 50000; /* 50ms timeout */
+ have_rx = 0;
+
+ ret = select(m, &rdfs, NULL, NULL, &tv);
+ if (ret < 0) {
+ perror("select");
+ exit(1);
+ }
+
+ if (FD_ISSET(s, &rdfs)) {
+
+ have_rx = 1;
+ ret = read(s, &frame, sizeof(struct can_frame));
+ if (ret < 0) {
+ perror("read");
+ exit(1);
+ }
+ if (frame.can_id != can_id) {
+ fprintf(stderr, "received wrong can_id!\n");
+ exit(1);
+ }
+ rx.s++;
+ }
+
+ if (FD_ISSET(t, &rdfs)) {
+
+ have_rx = 1;
+ ret = read(t, &frame, sizeof(struct can_frame));
+ if (ret < 0) {
+ perror("read");
+ exit(1);
+ }
+ if (frame.can_id != can_id) {
+ fprintf(stderr, "received wrong can_id!\n");
+ exit(1);
+ }
+ rx.t++;
+ }
+ }
+
+ /* timeout */
+
+ return rx;
+}
+
+void setopts(int s, int loopback, int recv_own_msgs)
+{
+ setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK,
+ &loopback, sizeof(loopback));
+ setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
+ &recv_own_msgs, sizeof(recv_own_msgs));
+
+ printf("check loopback %d recv_own_msgs %d ... ",
+ loopback, recv_own_msgs);
+}
+
+
+int main(int argc, char **argv)
+{
+ int s, t;
+ struct sockaddr_can addr;
+ struct ifreq ifr;
+ struct rxs rx;
+
+ /* check command line options */
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <device>\n", argv[0]);
+ return 1;
+ }
+
+ if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+ perror("socket");
+ return 1;
+ }
+ if ((t = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+ perror("socket");
+ return 1;
+ }
+
+ strcpy(ifr.ifr_name, argv[1]);
+ if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
+ perror("SIOCGIFINDEX");
+ return 1;
+ }
+ addr.can_ifindex = ifr.ifr_ifindex;
+ addr.can_family = AF_CAN;
+
+ if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ perror("bind");
+ return 1;
+ }
+ if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ perror("bind");
+ return 1;
+ }
+
+ printf("Starting PF_CAN frame flow test.\n");
+ printf("checking socket default settings ... ");
+ rx = test_sockets(s, t, 0x340);
+ if (rx.s == 0 && rx.t == 1)
+ printf("ok.\n");
+ else {
+ printf("failure!\n");
+ return 1;
+ }
+
+ /* check loopback 0 recv_own_msgs 0 */
+ setopts(s, 0, 0);
+ rx = test_sockets(s, t, 0x341);
+ if (rx.s == 0 && rx.t == 0)
+ printf("ok.\n");
+ else {
+ printf("failure!\n");
+ return 1;
+ }
+
+ /* check loopback 0 recv_own_msgs 1 */
+ setopts(s, 0, 1);
+ rx = test_sockets(s, t, 0x342);
+ if (rx.s == 0 && rx.t == 0)
+ printf("ok.\n");
+ else {
+ printf("failure!\n");
+ return 1;
+ }
+
+ /* check loopback 1 recv_own_msgs 0 */
+ setopts(s, 1, 0);
+ rx = test_sockets(s, t, 0x343);
+ if (rx.s == 0 && rx.t == 1)
+ printf("ok.\n");
+ else {
+ printf("failure!\n");
+ return 1;
+ }
+
+ /* check loopback 1 recv_own_msgs 1 */
+ setopts(s, 1, 1);
+ rx = test_sockets(s, t, 0x344);
+ if (rx.s == 1 && rx.t == 1)
+ printf("ok.\n");
+ else {
+ printf("failure!\n");
+ return 1;
+ }
+
+ printf("PF_CAN frame flow test was successful.\n");
+
+ close(s);
+ close(t);
+
+ return 0;
+}
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox