* Re: [PATCH v2 46/46] net: mark drivers that drop packets from rx queue head under memory pressure
From: Eilon Greenstein @ 2011-07-11 10:16 UTC (permalink / raw)
To: Michał Mirosław
Cc: netdev@vger.kernel.org, Hartley Sweeten, Michael Chan,
Guo-Fu Tseng, Realtek linux nic maintainers, Francois Romieu,
Stephen Hemminger, Matthew Carlson, Jon Mason
In-Reply-To: <20110711100447.GA7532@rere.qmqm.pl>
On Mon, 2011-07-11 at 03:04 -0700, Michał Mirosław wrote:
> On Mon, Jul 11, 2011 at 09:47:08AM +0300, Eilon Greenstein wrote:
> > On Sun, 2011-07-10 at 17:52 -0700, Michał Mirosław wrote:
> > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > ---
> >
> > > diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
> > > index 4f9164c..a6da01a 100644
> > > --- a/drivers/net/bnx2x/bnx2x_cmn.c
> > > +++ b/drivers/net/bnx2x/bnx2x_cmn.c
> > > @@ -673,6 +673,9 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
> > > goto reuse_rx;
> > > }
> > >
> > > +#warning drops packets from rx queue head on memory pressure
> > > +#warning (like dev_skb_finish_rx_dma_refill() users)
> > > +
> >
> > We have the dropless_fc module parameter that can be configured if the
> > user prefers pausing on host memory pressure - the problem with that
> > feature is that it is enough that one of the ring runs out of memory and
> > the entire port is stopped. When running with 16 rings, this can lead to
> > serious throughput degradation - this is why it is kept as a user
> > configurable option.
>
> From the code it look like dropless_fc just enables sending of pause
> frames. If that's disabled, then what happens when one queue runs out
> of free rx buffers?
>
Actually, I was too fast before and did not read it all through. After I
did, I saw that Dave already replied...
The dropless_fc is not really related to this case. It is about the
driver not keeping up with the FW/HW and not about the driver failing to
allocate a buffer (well, not directly - if that will happen with the
suggested patch we will run out of space on the ring). If the ring is
full, the FW will drop the packet. But if the FW is not fast enough and
the internal chip buffer is getting full - the HW will send pause. So
when pause is enabled, without dropless_fc packets will still be dropped
if the host is too slow but not if the chip is too slow (when exceeding
the chip max PPS with small packets). When dropless_fc is set, packet
will not be dropped but in multi-ring scenario we are likely to be under
utilizing the link in case some (possibly only one) ring on one CPU is
not keeping up while the other rings (on other CPUs) still have room and
possibly idling.
Regards,
Eilon
^ permalink raw reply
* Re: [PATCH net-next-2.6] net: introduce build_skb()
From: Michał Mirosław @ 2011-07-11 10:53 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
In-Reply-To: <1310363206.2512.26.camel@edumazet-laptop>
On Mon, Jul 11, 2011 at 07:46:46AM +0200, Eric Dumazet wrote:
> Le lundi 11 juillet 2011 à 02:52 +0200, Michał Mirosław a écrit :
> > Introduce __netdev_alloc_skb_aligned() to return skb with skb->data
> > aligned at specified 2^n multiple.
> >
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Hi Michal
>
> Could we synchronize our work to not introduce things that might
> disappear shortly ?
Sure. Are you saying that you'll convert all drivers to build_skb()? :-)
> Here is the RFC patch about build_skb() :
>
> [PATCH] net: introduce build_skb()
>
> One of the thing we discussed during netdev 2011 conference was the idea
> to change network drivers to allocate/populate their skb at RX
> completion time, right before feeding the skb to network stack.
>
> Right now, we allocate skbs when populating the RX ring, and thats a
> waste of CPU cache, since allocating skb means a full memset() to clear
> the skb and its skb_shared_info portion. By the time NIC fills a frame
> in data buffer and host can get it, cpu probably threw away the cache
> lines from its caches, because of huge RX ring sizes.
>
> So the deal would be to allocate only the data buffer for the NIC to
> populate its RX ring buffer. And use build_skb() at RX completion to
> attach a data buffer (now filled with an ethernet frame) to a new skb,
> initialize the skb_shared_info portion, and give the hot skb to network
> stack.
>
> build_skb() is the function to allocate an skb, caller providing the
> data buffer that should be attached to it. Drivers are expected to call
> skb_reserve() right after build_skb() to let skb->data points to the
> Ethernet frame (usually skipping NET_SKB_PAD and NET_IP_ALIGN)
[...]
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -234,6 +234,54 @@ nodata:
[...]
> /**
> + * build_skb - build a network buffer
> + * @data: data buffer provider by caller
> + * @size: size of data buffer, not including skb_shared_info
> + *
> + * Allocate a new &sk_buff. Caller provides space holding head and
> + * skb_shared_info. Mostly used in driver RX path.
> + * The return is the buffer. On a failure the return is %NULL.
> + * Notes :
> + * Before IO, driver allocates only data buffer where NIC put incoming frame
> + * Driver SHOULD add room at head (NET_SKB_PAD) and
> + * MUST add room tail (to hold skb_shared_info)
> + * After IO, driver calls build_skb(), to get a hot skb instead of a cold one
> + * before giving packet to stack. RX rings only contains data buffers, not
> + * full skbs.
> + */
> +struct sk_buff *build_skb(void *data, unsigned int size)
> +{
> + struct skb_shared_info *shinfo;
> + struct sk_buff *skb;
> +
> + skb = kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC);
> + if (!skb)
> + return NULL;
> +
> + size = SKB_DATA_ALIGN(size);
> +
> + memset(skb, 0, offsetof(struct sk_buff, tail));
> + skb->truesize = size + sizeof(struct sk_buff);
> + atomic_set(&skb->users, 1);
> + skb->head = data;
> + skb->data = data;
> + skb_reset_tail_pointer(skb);
> + skb->end = skb->tail + size;
> +#ifdef NET_SKBUFF_DATA_USES_OFFSET
> + skb->mac_header = ~0U;
> +#endif
> +
> + /* make sure we initialize shinfo sequentially */
> + shinfo = skb_shinfo(skb);
> + memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
> + atomic_set(&shinfo->dataref, 1);
> + kmemcheck_annotate_variable(shinfo->destructor_arg);
> +
> + return skb;
> +}
> +EXPORT_SYMBOL(build_skb);
I like the idea. From driver writer perspective I would like to also
see a function that given max frame size and DMA aligment would allocate
the buffer for me.
In short:
* rx_refill:
[ptr, size] = alloc_rx_buffer(size, alignment, offset);
[dma_addr] = map_buffer(ptr, size);
append to rx buffer list
* rx_poll:
unmap_buffer(dma_addr, size);
[skb] = build_skb(ptr, size);
if (!skb)
reuse_buffer
return
skb_reserve(skb, rx_offset);
skb_put(skb, pkt_len);
(indicate offloads)
rx_skb(skb);
call rx_refill
* rx_poll with copybreak:
sync_buffer_to_cpu(dma_addr, data_len);
[skb, copied] = build_or_copy_skb(ptr, size, hw_rx_offset, pkt_len);
if (copied || !skb)
append to rx buffer list
else
unmap_buffer(dma_addr, size);
if (!skb)
return;
(indicate offloads)
rx_skb(skb);
if (!copied)
call rx_refill
For even less driver code this could happen:
* rx_refill(ptr, dma_addr)
[size/alignment stored in queue or net_device struct]
if (is_rx_free_list_full)
return -EBUSY;
append to rx buffer list [ptr, dma_addr, size]
return !is_rx_free_list_full;
* rx_poll with copybreak:
[copy threshold stored in queue or net_device struct]
[skb] = finish_rx(ptr, dma_addr, size, hw_rx_offset, pkt_len);
if (!skb)
return;
(fill in offloads: checksum/etc)
rx_skb(skb);
This could be extended to handle frames spanning multiple buffers.
BTW, napi_get_frags() + napi_gro_frags() use similar idea of allocating
skb late.
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [PATCH v2 00/46] Clean up RX copybreak and DMA handling
From: Michał Mirosław @ 2011-07-11 11:17 UTC (permalink / raw)
To: David Miller; +Cc: netdev
In-Reply-To: <20110711.031128.635136897396133223.davem@davemloft.net>
On Mon, Jul 11, 2011 at 03:11:28AM -0700, David Miller wrote:
> From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Date: Mon, 11 Jul 2011 11:47:23 +0200
>
> > Catch 22: The chips are not tested because they have always free buffers,
> > they are provided with endless rx buffers because they are not being
> > tested. I'd rather test them well rather than workaround a phantom issue.
> > Tripping on empty free rx buffer ring is still possible even with scheme
> > #1 (eg. with lots of NICs receiving heavy traffic) --- just harder to
> > recognise and debug (if it breaks at all) when it happens.
> I do not support taking this risk.
The problem will be waiting, just pushed into dark corner. ;)
The card+driver need to survive empty rx buffer list anyway.
This issue will come back with people attacking bufferbloat issues
(they will want to reduce queue sizes and so increase the frequency
when free rx buffers run out).
> Please do not submit patches which move away from the long
> standing allocation failure handling scheme.
Sure. In this series it's patch 16 --- because it was trivial to do. Pending
patches only wrap the existing behaviour (where clearly scheme #1 or #2
is used).
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [RFC 43/72] a2065/ariadne: Move the a2065/ariadne drivers
From: Christoph Hellwig @ 2011-07-11 11:31 UTC (permalink / raw)
To: Jeff Kirsher
Cc: Geert Uytterhoeven, davem@davemloft.net, netdev@vger.kernel.org
In-Reply-To: <1310377198.26989.90.camel@jtkirshe-mobl>
On Mon, Jul 11, 2011 at 02:39:57AM -0700, Jeff Kirsher wrote:
> It may just be me, these statements seem negative and bitter and is not
> helping us "solve" the issue. While the statements may be true, I
> would like to try and find a solution, what ever it may be, to better
> organize drivers/net/ethernet/ drivers to help with maintenance and
> future development.
It would help what the whole point of shuffling these drivers around
in arbitrary ways is. Splitting them up for the actual protocols might
make some sense, as would giving a subdirectory to every non-trivial
driver. But what whole vendor split, even if consistently implemented
seems like a lot of wanking for very little juice.
^ permalink raw reply
* Re: [RFC 43/72] a2065/ariadne: Move the a2065/ariadne drivers
From: David Miller @ 2011-07-11 11:41 UTC (permalink / raw)
To: hch; +Cc: jeffrey.t.kirsher, geert, netdev
In-Reply-To: <20110711113128.GA21187@infradead.org>
From: Christoph Hellwig <hch@infradead.org>
Date: Mon, 11 Jul 2011 07:31:28 -0400
> But what whole vendor split, even if consistently implemented seems
> like a lot of wanking for very little juice.
There's simply too much stuff under drivers/net right now, I
want TAB completion to actually start being useful again.
^ permalink raw reply
* Re: [PATCH 1/2] neigh: Store hash shift instead of mask.
From: Michał Mirosław @ 2011-07-11 11:58 UTC (permalink / raw)
To: David Miller; +Cc: roland, johnwheffner, mj, netdev
In-Reply-To: <20110711.014841.1004194674075047305.davem@davemloft.net>
2011/7/11 David Miller <davem@davemloft.net>:
> And mask the hash function result by simply shifting
> down the "->hash_shift" most significant bits.
>
> Currently which bits we use is arbitrary since jhash
> produces entropy evenly across the whole hash function
> result.
>
> But soon we'll be using universal hashing functions,
> and in those cases more entropy exists in the higher
> bits than the lower bits, because they use multiplies.
You could use some evil shift tricks to cut some instructions if you like. ;-)
Examples below.
[...]
> - for (i = 0; i <= nht->hash_mask; i++) {
> + for (i = 0; i < (1 << nht->hash_shift); i++) {
for (i = 0; !(i >> nth->hash_shift); i++)
[...]
> - size_t size = entries * sizeof(struct neighbour *);
> + size_t size = (1 << shift) * sizeof(struct neighbour *);
size_t size = sizeof(struct neighbour *) << shift;
Or, since later get_order(size) is used:
unsinged int size_shift = shift + order_base_2(sizeof(struct neighbour *));
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [PATCH v2 00/46] Clean up RX copybreak and DMA handling
From: Ben Hutchings @ 2011-07-11 12:36 UTC (permalink / raw)
To: David Miller; +Cc: mirq-linux, netdev
In-Reply-To: <20110710.235458.1549578255936886669.davem@davemloft.net>
On Sun, 2011-07-10 at 23:54 -0700, David Miller wrote:
> From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Date: Mon, 11 Jul 2011 02:52:46 +0200 (CEST)
>
> > 1. under packet storm and memory pressure NIC keeps generating interrupts
> > (if non-NAPI) and indicating new buffers because it always has free
> > RX buffers --- this only wastes CPU and bus bandwidth transferring
> > data that is going to be immediately discarded;
>
> Actually, this is exactly how I, and others advise people to implement
> drivers. It is the right thing to do.
>
> The worst thing that can happen is to let the RX ring empty of
> buffers. Some cards hang as a result of this, and also it causes head
> of line blocking on multiqueue cards, etc.
The controllers you are familiar with might do head-of-line blocking
when a single RX queue is empty. But any multiqueue controller that is
supposed to support untrusted queues (required for SR-IOV) had better
not. This is certainly not done on Solarflare controllers (packets for
that queue just get dropped until it's refilled) and I doubt it's done
on many others.
I also think it's quite reasonable for the RX queue to stop interrupting
when the host is already too busy to refill it. Some drivers might not
recover correctly, but this is not a hardware issue.
> So the first thing the driver should do is try to allocate a
> replacement buffer.
>
> And if that fails, it should give the RX packet right back to the
> card, and not pass it up the stack.
I agree this is a reasonable and generic way to deal with empty RX
queues.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* [PATCH] inetpeer: kill inet_putpeer race
From: Eric Dumazet @ 2011-07-11 12:49 UTC (permalink / raw)
To: David Miller; +Cc: netdev
We currently can free inetpeer entries too early :
[ 782.636674] WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (f130f44c)
[ 782.636677] 1f7b13c100000000000000000000000002000000000000000000000000000000
[ 782.636686] i i i i u u u u i i i i u u u u i i i i u u u u u u u u u u u u
[ 782.636694] ^
[ 782.636696]
[ 782.636698] Pid: 4638, comm: ssh Not tainted 3.0.0-rc5+ #270 Hewlett-Packard HP Compaq 6005 Pro SFF PC/3047h
[ 782.636702] EIP: 0060:[<c13fefbb>] EFLAGS: 00010286 CPU: 0
[ 782.636707] EIP is at inet_getpeer+0x25b/0x5a0
[ 782.636709] EAX: 00000002 EBX: 00010080 ECX: f130f3c0 EDX: f0209d30
[ 782.636711] ESI: 0000bc87 EDI: 0000ea60 EBP: f0209ddc ESP: c173134c
[ 782.636712] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[ 782.636714] CR0: 8005003b CR2: f0beca80 CR3: 30246000 CR4: 000006d0
[ 782.636716] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
[ 782.636717] DR6: ffff4ff0 DR7: 00000400
[ 782.636718] [<c13fbf76>] rt_set_nexthop.clone.45+0x56/0x220
[ 782.636722] [<c13fc449>] __ip_route_output_key+0x309/0x860
[ 782.636724] [<c141dc54>] tcp_v4_connect+0x124/0x450
[ 782.636728] [<c142ce43>] inet_stream_connect+0xa3/0x270
[ 782.636731] [<c13a8da1>] sys_connect+0xa1/0xb0
[ 782.636733] [<c13a99dd>] sys_socketcall+0x25d/0x2a0
[ 782.636736] [<c149deb8>] sysenter_do_call+0x12/0x28
[ 782.636738] [<ffffffff>] 0xffffffff
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/ipv4/inetpeer.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index dafbf2c..90c5f0d 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -373,11 +373,14 @@ static int inet_peer_gc(struct inet_peer_base *base,
while (stackptr > stack) {
stackptr--;
p = rcu_deref_locked(**stackptr, base);
- delta = (__u32)jiffies - p->dtime;
- if (atomic_read(&p->refcnt) == 0 && delta >= ttl &&
- atomic_cmpxchg(&p->refcnt, 0, -1) == 0) {
- p->gc_next = gchead;
- gchead = p;
+ if (atomic_read(&p->refcnt) == 0) {
+ smp_rmb();
+ delta = (__u32)jiffies - p->dtime;
+ if (delta >= ttl &&
+ atomic_cmpxchg(&p->refcnt, 0, -1) == 0) {
+ p->gc_next = gchead;
+ gchead = p;
+ }
}
}
while ((p = gchead) != NULL) {
@@ -456,6 +459,7 @@ EXPORT_SYMBOL_GPL(inet_getpeer);
void inet_putpeer(struct inet_peer *p)
{
p->dtime = (__u32)jiffies;
+ smp_mb__before_atomic_dec();
atomic_dec(&p->refcnt);
}
EXPORT_SYMBOL_GPL(inet_putpeer);
^ permalink raw reply related
* Re: [PATCH 3/3] iwlagn: Add missing comma between constant string array
From: Guy, Wey-Yi @ 2011-07-11 13:42 UTC (permalink / raw)
To: Joe Perches
Cc: Intel Linux Wireless, John W. Linville,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <2c8a6e15b0f320e4b4b761ae6434862fc3c15924.1310187270.git.joe@perches.com>
On Fri, 2011-07-08 at 23:20 -0700, Joe Perches wrote:
> Multiple quoted strings are concatenated without comma separators.
>
> Make the array const while there.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> ---
> drivers/net/wireless/iwlwifi/iwl-agn.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
> index 7e6c463..de1a0c1 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-agn.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
> @@ -1563,7 +1563,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
> release_firmware(ucode_raw);
> }
>
> -static const char *desc_lookup_text[] = {
> +static const char * const desc_lookup_text[] = {
> "OK",
> "FAIL",
> "BAD_PARAM",
> @@ -1587,7 +1587,7 @@ static const char *desc_lookup_text[] = {
> "NMI_INTERRUPT_DATA_ACTION_PT",
> "NMI_TRM_HW_ER",
> "NMI_INTERRUPT_TRM",
> - "NMI_INTERRUPT_BREAK_POINT"
> + "NMI_INTERRUPT_BREAK_POINT",
> "DEBUG_0",
> "DEBUG_1",
> "DEBUG_2",
Thanks
Wey
^ permalink raw reply
* recommended way to support duplicate IP addresses on different VLANs?
From: Chris Friesen @ 2011-07-11 14:58 UTC (permalink / raw)
To: netdev
Hi all,
We've got a server that sits on multiple VLANs. Each VLAN is segregated
and doesn't know about the others. The IP address ranges in each of the
VLANs may overlap, and the server may be assigned the same IP address in
multiple VLANs.
We've got a messy solution now involving unique internal addresses and
NATing between those and the duplicate external addresses, but I'm
wondering if there is a cleaner way to handle this.
It seems like network namespaces would work, but it would require
multiple instances of our software which is a dealbreaker.
Is there any other way to deal with this scenario?
Thanks,
Chris
^ permalink raw reply
* Re: recommended way to support duplicate IP addresses on different VLANs?
From: Rémi Denis-Courmont @ 2011-07-11 15:04 UTC (permalink / raw)
To: Chris Friesen; +Cc: netdev
In-Reply-To: <4E1B0F86.2040508@mail.usask.ca>
Le lundi 11 juillet 2011 17:58:14 Chris Friesen, vous avez écrit :
> Hi all,
>
> We've got a server that sits on multiple VLANs. Each VLAN is segregated
> and doesn't know about the others. The IP address ranges in each of the
> VLANs may overlap, and the server may be assigned the same IP address in
> multiple VLANs.
>
> We've got a messy solution now involving unique internal addresses and
> NATing between those and the duplicate external addresses, but I'm
> wondering if there is a cleaner way to handle this.
>
> It seems like network namespaces would work, but it would require
> multiple instances of our software which is a dealbreaker.
>
> Is there any other way to deal with this scenario?
Namespace file descriptors if/when they get accepted.
Or then binding sockets to devices (SO_BINDTODEVICE) might work.
--
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis
^ permalink raw reply
* Re: [PATCH v2 04/46] net/wireless: p54: remove useless dma_sync_single_for_device(DMA_FROM_DEVICE)
From: Pavel Roskin @ 2011-07-11 15:15 UTC (permalink / raw)
To: Michał Mirosław
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Christian Lamparter,
John W. Linville, linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <86c8bde08b005ca7eb4806ea77aec1f3212d63fc.1310339688.git.mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
On 07/10/2011 08:52 PM, Michał Mirosław wrote:
> Also constify pointers used in frame parsers to verify assumptions.
Cleanups are better done separately.
> - u16 type = le16_to_cpu(*((__le16 *)skb->data));
> + u16 type = le16_to_cpu(*(const __le16 *)skb->data);
I think it would be more appropriate to use get_unaligned_le16() here.
No casts should be needed then.
That's not an objection, just a suggestion :)
--
Regards,
Pavel Roskin
--
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: [PATCH v2 46/46] net: mark drivers that drop packets from rx queue head under memory pressure
From: Stephen Hemminger @ 2011-07-11 15:24 UTC (permalink / raw)
To: Michał Mirosław
Cc: netdev, Hartley Sweeten, Michael Chan, Eilon Greenstein,
Guo-Fu Tseng, Realtek linux nic maintainers, Francois Romieu,
Matt Carlson, Jon Mason
In-Reply-To: <c84a04a957128ae664f4a80da23fad4b9f71a85f.1310339689.git.mirq-linux@rere.qmqm.pl>
On Mon, 11 Jul 2011 02:52:50 +0200 (CEST)
Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> drivers/net/arm/ep93xx_eth.c | 3 +++
> drivers/net/bnx2.c | 3 +++
> drivers/net/bnx2x/bnx2x_cmn.c | 3 +++
> drivers/net/cassini.c | 3 +++
> drivers/net/jme.c | 3 +++
> drivers/net/mlx4/en_rx.c | 6 ++++++
> drivers/net/r8169.c | 3 +++
> drivers/net/skge.c | 3 +++
> drivers/net/sky2.c | 2 ++
> drivers/net/tg3.c | 2 ++
> drivers/net/tokenring/olympic.c | 2 ++
> drivers/net/vxge/vxge-main.c | 3 +++
> 12 files changed, 36 insertions(+), 0 deletions(-)
>
Nak. This is normal behavior and putting in a compile warning is just
useless extra noise.
^ permalink raw reply
* Re: [PATCH] bridge: mask forwarding of IEEE 802 local multicast groups
From: Stephen Hemminger @ 2011-07-11 15:27 UTC (permalink / raw)
To: Nick Carter; +Cc: netdev, Michał Mirosław, David Lamparter, davem
In-Reply-To: <CAEJpZP1cr4B9qX6gH9O4iXwWvEdxs2aebL21FnX1BE0dJPHrEw@mail.gmail.com>
On Sun, 10 Jul 2011 17:04:30 +0100
Nick Carter <ncarter100@gmail.com> wrote:
> Updated diffs so they apply to net-next (Original diffs were based off 2.6.38).
>
> Any chance of getting these diffs applied? The default behaviour of
> the bridge code is unchanged. They solve the problem of
> authenticating a virtual 802.1x supplicant machine against an external
> 802.1X authenticator. It is also a general solution that allows the
> forwarding of any combination of the IEEE 802 local multicast groups.
>
> Signed-off-by: Nick Carter <ncarter100@gmail.com>
> Reviewed-by: David Lamparter <equinox@diac24.net>
I am still undecided on this. Understand the need, but don't like idea
of bridge behaving in non-conforming manner. Will see if IEEE 802 committee
has any input.
Also, don't want to build more knobs in with sysfs that are per-bridge.
Eventually, the plan is to make all the setting per-port with sysctl's
like IPv6.
^ permalink raw reply
* Re: recommended way to support duplicate IP addresses on different VLANs?
From: Chris Friesen @ 2011-07-11 15:48 UTC (permalink / raw)
To: Rémi Denis-Courmont; +Cc: Chris Friesen, netdev
In-Reply-To: <201107111804.26500.remi@remlab.net>
On 07/11/2011 09:04 AM, Rémi Denis-Courmont wrote:
> Le lundi 11 juillet 2011 17:58:14 Chris Friesen, vous avez écrit :
>> Hi all,
>>
>> We've got a server that sits on multiple VLANs. Each VLAN is segregated
>> and doesn't know about the others. The IP address ranges in each of the
>> VLANs may overlap, and the server may be assigned the same IP address in
>> multiple VLANs.
>> Is there any other way to deal with this scenario?
> Or then binding sockets to devices (SO_BINDTODEVICE) might work.
Hmm...SO_BINDTODEVICE looks interesting. I would imagine we'd still
need to do some funky stuff around ARP handling.
Chris
--
Chris Friesen
Software Developer
GENBAND
chris.friesen@genband.com
www.genband.com
^ permalink raw reply
* Re: [ath5k-devel] [PATCH 3/5] ath5k: Add missing breaks in switch/case
From: Pavel Roskin @ 2011-07-11 15:50 UTC (permalink / raw)
To: Joe Perches
Cc: Jiri Slaby, Nick Kossifidis, Luis R. Rodriguez, Bob Copeland,
netdev, ath5k-devel, linux-wireless, John W. Linville,
linux-kernel
In-Reply-To: <e554bed5c753a3fe85d3be34983a15e6110a6e35.1310289795.git.joe@perches.com>
On 07/10/2011 05:28 AM, Joe Perches wrote:
> Signed-off-by: Joe Perches<joe@perches.com>
Acked-by: Pavel Roskin <proski@gnu.org>
> ---
> 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;
> }
The intention here is to replace frame types from enum ath5k_pkt_type
with their AR5210-specific counterparts. So the intention is definitely
to have breaks here.
Unfortunately, AR5210 cards are extremely rare these days. I have one,
but it only works with old motherboards. It would take me half a day to
dust off that system, compile the kernel and check the patch. But I
assume your patch is fine. At least it's very unlikely to break anything.
--
Regards,
Pavel Roskin
^ permalink raw reply
* Re: recommended way to support duplicate IP addresses on different VLANs?
From: Ben Greear @ 2011-07-11 15:56 UTC (permalink / raw)
To: Chris Friesen; +Cc: Rémi Denis-Courmont, Chris Friesen, netdev
In-Reply-To: <4E1B1B33.5060300@genband.com>
On 07/11/2011 08:48 AM, Chris Friesen wrote:
> On 07/11/2011 09:04 AM, Rémi Denis-Courmont wrote:
>> Le lundi 11 juillet 2011 17:58:14 Chris Friesen, vous avez écrit :
>>> Hi all,
>>>
>>> We've got a server that sits on multiple VLANs. Each VLAN is segregated
>>> and doesn't know about the others. The IP address ranges in each of the
>>> VLANs may overlap, and the server may be assigned the same IP address in
>>> multiple VLANs.
>
>>> Is there any other way to deal with this scenario?
>
>
>> Or then binding sockets to devices (SO_BINDTODEVICE) might work.
>
> Hmm...SO_BINDTODEVICE looks interesting. I would imagine we'd still need
> to do some funky stuff around ARP handling.
arp_filter should help.
Also, you may want to use conn-trck tables. This lets packets coming
in one or more interfaces use a specific conn-track cache. Might help
keep the identical IPs from colliding in their conn tracking.
iptables -t raw -A PREROUTING -i eth0.7 -j CT --zone 7
Thanks,
Ben
>
> Chris
>
>
>
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply
* Re: [LTP] Update for CAN LTP tests
From: Cyril Hrubis @ 2011-07-11 16:15 UTC (permalink / raw)
To: Oliver Hartkopp
Cc: Subrata Modak, ltp-list, socketcan-users, Oliver Hartkopp,
Wolfgang Grandegger, netdev
In-Reply-To: <4E19987B.2030507@hartkopp.net>
Hi!
> > 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.
Could you pretty please create signed patch(es) (git could create them
for you) so we could commit them into LTP repository.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply
* "tm->when" at /proc/net/tcp shows some negative numbers.
From: Andreas O @ 2011-07-11 16:47 UTC (permalink / raw)
To: netdev
Dear devnet list,
I am doing some performance improvements on linux-2.6.33.15 with
real-time support. When my tests fails I observe that "tm->when" at
/proc/net/tcp shows
some negative numbers. That negative number is the difference of
"timer_expires - jeffies" and in this case timer_expires is smaller
than jiffies.
Does this negative number indicates a bug in the stack?
from /proc/net/tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when
retrnsmt uid timeout inode
0: 0100007F:09A4 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 11905 1 ffff88057b9df9c0 300 0 0 2 -1
1: 00000000:1BC7 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 14746 1 ffff880579bfac80 300 0 0 2 -1
2: 0100007F:00C7 00000000:0000 0A 00000000:00000000 00:00000000
00000000 0 0 11734 1 ffff88097a7980c0 300 0 0 2 -1
3: 00000000:078F 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 14733 1 ffff880974e9acc0 300 0 0 2 -1
4: 00000000:2710 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 14748 1 ffff88097385e740 300 0 0 2 -1
5: 00000000:0050 00000000:0000 0A 00000000:00000000 02:0000000E
00000000 499 0 14732 2 ffff88097933d980 300 0 0 2 -1
6: 14041AAC:0050 FE081AAC:93FD 03 00000000:00000000
01:FFFFFFFFFFFFFFE2 00000000 499 0 0 2 ffff8804dc549dc0
7: 14041AAC:0050 FA081AAC:B0E0 03 00000000:00000000
01:FFFFFFFFFFFFFFE2 00000000 499 0 0 2 ffff880524d79e40
8: 14041AAC:0050 F2011AAC:E53F 03 00000000:00000000
01:FFFFFFFFFFFFFFE4 00000000 499 0 0 2 ffff880524d7ccc0
9: 14041AAC:0050 F2011AAC:C73F 03 00000000:00000000
01:FFFFFFFFFFFFFFE5 00000000 499 0 0 2 ffff880524d5ba40
10: 14041AAC:0050 FB011AAC:D89A 03 00000000:00000000
01:FFFFFFFFFFFFFFE1 00000000 499 0 0 2 ffff8804a9290b40
11: 14041AAC:0050 F2011AAC:C9CD 03 00000000:00000000
01:FFFFFFFFFFFFFFE4 00000000 499 0 0 2 ffff8804e6c9af40
12: 14041AAC:0050 FE081AAC:8EC9 03 00000000:00000000
01:FFFFFFFFFFFFFFE2 00000000 499 0 0 2 ffff8804dc59d940
13: 14041AAC:0050 FE081AAC:E7C0 03 00000000:00000000
01:FFFFFFFFFFFFFFE2 00000000 499 0 0 2 ffff8804dc798840
sl local_address rem_address st tx_queue rx_queue tr tm->when
retrnsmt uid timeout inode
0: 0100007F:09A4 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 11905 1 ffff88057b9df9c0 300 0 0 2 -1
1: 00000000:1BC7 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 14746 1 ffff880579bfac80 300 0 0 2 -1
2: 0100007F:00C7 00000000:0000 0A 00000000:00000000 00:00000000
00000000 0 0 11734 1 ffff88097a7980c0 300 0 0 2 -1
3: 00000000:078F 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 14733 1 ffff880974e9acc0 300 0 0 2 -1
4: 00000000:2710 00000000:0000 0A 00000000:00000000 00:00000000
00000000 499 0 14748 1 ffff88097385e740 300 0 0 2 -1
5: 00000000:0050 00000000:0000 0A 00000000:00000000 02:00000009
00000000 499 0 14732 2 ffff88097933d980 300 0 0 2 -1
6: 14041AAC:0050 FE081AAC:93FD 03 00000000:00000000
01:FFFFFFFFFFFFFFB5 00000000 499 0 0 2 ffff8804dc549dc0
7: 14041AAC:0050 FA081AAC:B0E0 03 00000000:00000000
01:FFFFFFFFFFFFFFB5 00000000 499 0 0 2 ffff880524d79e40
8: 14041AAC:0050 F2011AAC:E53F 03 00000000:00000000
01:FFFFFFFFFFFFFFB7 00000000 499 0 0 2 ffff880524d7ccc0
9: 14041AAC:0050 F2011AAC:C73F 03 00000000:00000000
01:FFFFFFFFFFFFFFB8 00000000 499 0 0 2 ffff880524d5ba40
10: 14041AAC:0050 FB011AAC:D89A 03 00000000:00000000
01:FFFFFFFFFFFFFFB4 00000000 499 0 0 2 ffff8804a9290b40
11: 14041AAC:0050 F2011AAC:C9CD 03 00000000:00000000
01:FFFFFFFFFFFFFFB7 00000000 499 0 0 2 ffff8804e6c9af40
12: 14041AAC:0050 FE081AAC:8EC9 03 00000000:00000000
01:FFFFFFFFFFFFFFB5 00000000 499 0 0 2 ffff8804dc59d940
13: 14041AAC:0050 F2081AAC:E7BF 03 00000000:00000000
01:FFFFFFFFFFFFFFB7 00000000 499 0 0 2 ffff8804ce339c40
Any ideas?
Kind regards
Andreas
^ permalink raw reply
* Re: [PATCH] iproute2: fix minor typo in comments
From: Stephen Hemminger @ 2011-07-11 17:12 UTC (permalink / raw)
To: Gilles Espinasse; +Cc: netdev
In-Reply-To: <1310312737-2296-1-git-send-email-g.esp@free.fr>
Applied
^ permalink raw reply
* Re: [PATCH] iproute2: Remove unreachable code
From: Stephen Hemminger @ 2011-07-11 17:19 UTC (permalink / raw)
To: Petr Sabata; +Cc: netdev
In-Reply-To: <1307711947-586-1-git-send-email-contyk@redhat.com>
On Fri, 10 Jun 2011 15:19:07 +0200
Petr Sabata <contyk@redhat.com> wrote:
> This patch removes unreachable, useless code.
>
> Signed-off-by: Petr Sabata <contyk@redhat.com>
Applied
^ permalink raw reply
* Re: [PATCH iproute2] xfrm: Update documentation
From: Stephen Hemminger @ 2011-07-11 17:19 UTC (permalink / raw)
To: David Ward; +Cc: netdev
In-Reply-To: <201106120405.p5C44N7I010008@outgoing.mit.edu>
On Sat, 11 Jun 2011 22:13:30 -0400
David Ward <david.ward@ll.mit.edu> wrote:
> The ip(8) man page and the "ip xfrm [ XFRM-OBJECT ] help" command output
> are updated to include missing options, fix errors, and improve grammar.
> There are no functional changes made.
>
> The documentation for the ip command has many different meanings for the
> same formatting symbols (which really needs to be fixed). This patch makes
> consistent use of brackets [ ] to indicate optional parameters, pipes | to
> mean "OR", braces { } to group things together, and dashes - instead of
> underscores _ inside of parameter names. The parameters are listed in the
> order in which they are parsed in the source code.
>
> There are several parameters and options that are still not mentioned or
> need to be described more thoroughly in the "COMMAND SYNTAX" section of
> the ip(8) man page. I would appreciate help from the developers with this.
>
> Signed-off-by: David Ward <david.ward@ll.mit.edu>
Applied
^ permalink raw reply
* Re: "tm->when" at /proc/net/tcp shows some negative numbers.
From: Eric Dumazet @ 2011-07-11 17:28 UTC (permalink / raw)
To: Andreas O; +Cc: netdev
In-Reply-To: <CAAVaN8wcu+=p9sD76s7m3=M6hqPScOsq3WPJmAN5TBp4fAoLGQ@mail.gmail.com>
Le lundi 11 juillet 2011 à 17:47 +0100, Andreas O a écrit :
> Dear devnet list,
>
> I am doing some performance improvements on linux-2.6.33.15 with
> real-time support. When my tests fails I observe that "tm->when" at
> /proc/net/tcp shows
> some negative numbers. That negative number is the difference of
> "timer_expires - jeffies" and in this case timer_expires is smaller
> than jiffies.
> Does this negative number indicates a bug in the stack?
>
>
Not necessarly.
If the thread handling timers is delayed (because of other more urgent
RT things), the delay between timer is fired and handled could be long.
^ permalink raw reply
* CAN: major update for the Controller Area Network LTP tests
From: Oliver Hartkopp @ 2011-07-11 17:32 UTC (permalink / raw)
To: Cyril Hrubis
Cc: Subrata Modak, ltp-list, socketcan-users, Oliver Hartkopp,
Wolfgang Grandegger, netdev
In-Reply-To: <20110711161513.GB31575@saboteur.suse.cz>
CAN: major update for the Controller Area Network LTP tests
This update for the LTP tests are 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
that has been originally used to pick the tests from. The two new tools
also reside in the SocketCAN SVN svn://svn.berlios.de/socketcan/trunk/test
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.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
diff --git a/testcases/network/can/filter-tests/Makefile b/testcases/network/can/filter-tests/Makefile
index 192c3b0..c88f704 100644
--- a/testcases/network/can/filter-tests/Makefile
+++ b/testcases/network/can/filter-tests/Makefile
@@ -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 @@ CFLAGS = -O2 -Wall -Wno-parentheses \
-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 @@ install:
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 --git a/testcases/network/can/filter-tests/canecho.c b/testcases/network/can/filter-tests/canecho.c
deleted file mode 100644
index e87f063..0000000
--- a/testcases/network/can/filter-tests/canecho.c
+++ /dev/null
@@ -1,163 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/run_ltp-can_tests.sh b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
index 6d7aafc..8070c9a 100644
--- a/testcases/network/can/filter-tests/run_ltp-can_tests.sh
+++ b/testcases/network/can/filter-tests/run_ltp-can_tests.sh
@@ -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 @@ if [ $(id -ru) -ne 0 ]; then
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 --git a/testcases/network/can/filter-tests/tst-bcm-cycle.c b/testcases/network/can/filter-tests/tst-bcm-cycle.c
deleted file mode 100644
index 7f4c8ac..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-cycle.c
+++ /dev/null
@@ -1,137 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-dump.c b/testcases/network/can/filter-tests/tst-bcm-dump.c
deleted file mode 100644
index 5004d3a..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-dump.c
+++ /dev/null
@@ -1,200 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-filter.c b/testcases/network/can/filter-tests/tst-bcm-filter.c
deleted file mode 100644
index 873e871..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-filter.c
+++ /dev/null
@@ -1,515 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-rtr.c b/testcases/network/can/filter-tests/tst-bcm-rtr.c
deleted file mode 100644
index 955864d..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-rtr.c
+++ /dev/null
@@ -1,145 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-rx-sendto.c b/testcases/network/can/filter-tests/tst-bcm-rx-sendto.c
deleted file mode 100644
index 7d3dcaf..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-rx-sendto.c
+++ /dev/null
@@ -1,162 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-server.c b/testcases/network/can/filter-tests/tst-bcm-server.c
deleted file mode 100644
index c057780..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-server.c
+++ /dev/null
@@ -1,263 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-single.c b/testcases/network/can/filter-tests/tst-bcm-single.c
deleted file mode 100644
index 829343c..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-single.c
+++ /dev/null
@@ -1,110 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-throttle.c b/testcases/network/can/filter-tests/tst-bcm-throttle.c
deleted file mode 100644
index 8585ade..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-throttle.c
+++ /dev/null
@@ -1,464 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-tx-sendto.c b/testcases/network/can/filter-tests/tst-bcm-tx-sendto.c
deleted file mode 100644
index bb2dbef..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-tx-sendto.c
+++ /dev/null
@@ -1,122 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-bcm-tx_read.c b/testcases/network/can/filter-tests/tst-bcm-tx_read.c
deleted file mode 100644
index 39e9400..0000000
--- a/testcases/network/can/filter-tests/tst-bcm-tx_read.c
+++ /dev/null
@@ -1,158 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-err.c b/testcases/network/can/filter-tests/tst-err.c
deleted file mode 100644
index 86d0ad1..0000000
--- a/testcases/network/can/filter-tests/tst-err.c
+++ /dev/null
@@ -1,166 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-filter-master.c b/testcases/network/can/filter-tests/tst-filter-master.c
deleted file mode 100644
index 42d6e53..0000000
--- a/testcases/network/can/filter-tests/tst-filter-master.c
+++ /dev/null
@@ -1,165 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-filter-server.c b/testcases/network/can/filter-tests/tst-filter-server.c
deleted file mode 100644
index 46903a5..0000000
--- a/testcases/network/can/filter-tests/tst-filter-server.c
+++ /dev/null
@@ -1,210 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-filter.c b/testcases/network/can/filter-tests/tst-filter.c
new file mode 100644
index 0000000..a2d46f1
--- /dev/null
+++ b/testcases/network/can/filter-tests/tst-filter.c
@@ -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 --git a/testcases/network/can/filter-tests/tst-packet.c b/testcases/network/can/filter-tests/tst-packet.c
deleted file mode 100644
index 12432bb..0000000
--- a/testcases/network/can/filter-tests/tst-packet.c
+++ /dev/null
@@ -1,167 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-proc.c b/testcases/network/can/filter-tests/tst-proc.c
deleted file mode 100644
index a33c600..0000000
--- a/testcases/network/can/filter-tests/tst-proc.c
+++ /dev/null
@@ -1,120 +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;
-
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-raw-filter.c b/testcases/network/can/filter-tests/tst-raw-filter.c
deleted file mode 100644
index a244ead..0000000
--- a/testcases/network/can/filter-tests/tst-raw-filter.c
+++ /dev/null
@@ -1,177 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-raw-sendto.c b/testcases/network/can/filter-tests/tst-raw-sendto.c
deleted file mode 100644
index 94808b4..0000000
--- a/testcases/network/can/filter-tests/tst-raw-sendto.c
+++ /dev/null
@@ -1,115 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-raw.c b/testcases/network/can/filter-tests/tst-raw.c
deleted file mode 100644
index fd3958f..0000000
--- a/testcases/network/can/filter-tests/tst-raw.c
+++ /dev/null
@@ -1,186 +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;
-}
\ No newline at end of file
diff --git a/testcases/network/can/filter-tests/tst-rcv-own-msgs.c b/testcases/network/can/filter-tests/tst-rcv-own-msgs.c
new file mode 100644
index 0000000..593e9fb
--- /dev/null
+++ b/testcases/network/can/filter-tests/tst-rcv-own-msgs.c
@@ -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 related
* Re: [PATCH] iproute2: Check getline() return code correctly
From: Stephen Hemminger @ 2011-07-11 17:37 UTC (permalink / raw)
To: Petr Sabata; +Cc: netdev
In-Reply-To: <1307710167-28868-1-git-send-email-contyk@redhat.com>
On Fri, 10 Jun 2011 14:49:27 +0200
Petr Sabata <contyk@redhat.com> wrote:
> The current implementation is always false, no matter what happens.
>
> Signed-off-by: Petr Sabata <contyk@redhat.com>
> ---
> lib/utils.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/lib/utils.c b/lib/utils.c
> index 1b42222..76cadea 100644
> --- a/lib/utils.c
> +++ b/lib/utils.c
> @@ -702,7 +702,7 @@ ssize_t getcmdline(char **linep, size_t *lenp, FILE *in)
> size_t len1 = 0;
> size_t cc1;
>
> - if ((cc1 = getline(&line1, &len1, in)) < 0) {
> + if ((cc1 = getline(&line1, &len1, in)) == (size_t)-1) {
> fprintf(stderr, "Missing continuation line\n");
> return cc1;
> }
The correct fix is to make cc1 a signed variable.
^ 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