4 * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, the following disclaimer and
12 * the referenced file 'COPYING'.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of Volkswagen nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * Alternatively, provided that this notice is retained in full, this
21 * software may be distributed under the terms of the GNU General
22 * Public License ("GPL") version 2 as distributed in the 'COPYING'
23 * file from the main directory of the linux kernel source.
25 * The provided data structures and external interfaces from this code
26 * are not restricted to be used by modules with a GPL compatible license.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
41 * Send feedback to <socketcan-users@lists.berlios.de>
45 #include <linux/config.h>
46 #include <linux/module.h>
47 #include <linux/version.h>
48 #include <linux/slab.h>
49 #include <linux/kmod.h>
50 #include <linux/init.h>
51 #include <linux/list.h>
52 #include <linux/spinlock.h>
53 #include <linux/rcupdate.h>
54 #include <linux/socket.h>
55 #include <linux/skbuff.h>
56 #include <linux/net.h>
57 #include <linux/netdevice.h>
59 #include <asm/uaccess.h>
61 #include <linux/can.h>
62 #include <linux/can/version.h>
69 #define NAME "Volkswagen AG - Low Level CAN Framework (LLCF)"
70 #define IDENT "af_can"
71 static __initdata const char banner[] = BANNER(NAME);
73 MODULE_DESCRIPTION(NAME);
74 MODULE_LICENSE("Dual BSD/GPL");
75 MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>, "
76 "Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
78 int stats_timer = 1; /* default: on */
79 module_param(stats_timer, int, S_IRUGO);
81 #ifdef CONFIG_CAN_DEBUG_CORE
83 module_param(debug, int, S_IRUGO);
84 #define DBG(args...) (debug & 1 ? \
85 (printk(KERN_DEBUG "CAN %s: ", __func__), \
87 #define DBG_FRAME(args...) (debug & 2 ? can_debug_cframe(args) : 0)
88 #define DBG_SKB(skb) (debug & 4 ? can_debug_skb(skb) : 0)
91 #define DBG_FRAME(args...)
95 static __init int can_init(void);
96 static __exit void can_exit(void);
98 static int can_create(struct socket *sock, int protocol);
99 static int can_notifier(struct notifier_block *nb,
100 unsigned long msg, void *data);
101 static int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
102 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
103 static int can_rcv(struct sk_buff *skb, struct net_device *dev,
104 struct packet_type *pt, struct net_device *orig_dev);
106 static int can_rcv(struct sk_buff *skb, struct net_device *dev,
107 struct packet_type *pt);
109 static int can_rcv_filter(struct dev_rcv_lists *d, struct sk_buff *skb);
110 static struct dev_rcv_lists *find_dev_rcv_lists(struct net_device *dev);
111 static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask,
112 struct dev_rcv_lists *d);
113 static void can_rcv_lists_delete(struct rcu_head *rp);
114 static void can_rx_delete(struct rcu_head *rp);
115 static void can_rx_delete_all(struct hlist_head *rl);
119 struct list_head list;
120 struct net_device *dev;
121 void (*func)(unsigned long msg, void *data);
125 static LIST_HEAD(notifier_list);
126 static rwlock_t notifier_lock = RW_LOCK_UNLOCKED;
128 HLIST_HEAD(rx_dev_list);
129 struct dev_rcv_lists rx_alldev_list;
130 static spinlock_t rcv_lists_lock = SPIN_LOCK_UNLOCKED;
132 static kmem_cache_t *rcv_cache;
134 static struct packet_type can_packet = {
135 .type = __constant_htons(ETH_P_CAN),
140 static struct net_proto_family can_family_ops = {
142 .create = can_create,
143 .owner = THIS_MODULE,
146 /* notifier block for netdevice event */
147 static struct notifier_block can_netdev_notifier = {
148 .notifier_call = can_notifier,
151 /* table of registered CAN protocols */
152 static struct can_proto *proto_tab[CAN_NPROTO];
154 extern struct timer_list stattimer; /* timer for statistics update */
155 extern struct s_stats stats; /* packet statistics */
156 extern struct s_pstats pstats; /* receive list statistics */
158 module_init(can_init);
159 module_exit(can_exit);
161 /**************************************************/
162 /* af_can module init/exit functions */
163 /**************************************************/
165 static __init int can_init(void)
169 rcv_cache = kmem_cache_create("can_receiver", sizeof(struct receiver),
175 /* statistics init */
176 init_timer(&stattimer);
182 /* protocol register */
183 sock_register(&can_family_ops);
184 register_netdevice_notifier(&can_netdev_notifier);
185 dev_add_pack(&can_packet);
190 static __exit void can_exit(void)
193 /* stop statistics timer */
194 del_timer(&stattimer);
200 /* protocol unregister */
201 dev_remove_pack(&can_packet);
202 unregister_netdevice_notifier(&can_netdev_notifier);
203 sock_unregister(PF_CAN);
205 kmem_cache_destroy(rcv_cache);
208 /**************************************************/
209 /* af_can protocol functions */
210 /**************************************************/
212 void can_proto_register(struct can_proto *cp)
214 int proto = cp->protocol;
215 if (proto < 0 || proto >= CAN_NPROTO) {
216 printk(KERN_ERR "CAN: protocol number %d out of range\n", proto);
219 if (proto_tab[proto]) {
220 printk(KERN_ERR "CAN: protocol %d already registered\n", proto);
224 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
225 if (proto_register(cp->prot, 0) != 0) {
229 proto_tab[proto] = cp;
231 /* use our generic ioctl function if the module doesn't bring its own */
233 cp->ops->ioctl = can_ioctl;
236 void can_proto_unregister(struct can_proto *cp)
238 int proto = cp->protocol;
239 if (!proto_tab[proto]) {
240 printk(KERN_ERR "CAN: protocol %d is not registered\n", proto);
243 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
244 proto_unregister(cp->prot);
246 proto_tab[proto] = NULL;
249 void can_dev_register(struct net_device *dev,
250 void (*func)(unsigned long msg, void *), void *data)
254 DBG("called for %s\n", dev->name);
256 if (!(n = kmalloc(sizeof(*n), GFP_KERNEL)))
263 write_lock(¬ifier_lock);
264 list_add(&n->list, ¬ifier_list);
265 write_unlock(¬ifier_lock);
268 void can_dev_unregister(struct net_device *dev,
269 void (*func)(unsigned long msg, void *), void *data)
271 struct notifier *n, *next;
273 DBG("called for %s\n", dev->name);
275 write_lock(¬ifier_lock);
276 list_for_each_entry_safe(n, next, ¬ifier_list, list) {
277 if (n->dev == dev && n->func == func && n->data == data) {
283 write_unlock(¬ifier_lock);
286 /**************************************************/
287 /* af_can socket functions */
288 /**************************************************/
290 static void can_sock_destruct(struct sock *sk)
292 DBG("called for sock %p\n", sk);
294 skb_queue_purge(&sk->sk_receive_queue);
296 kfree(sk->sk_protinfo);
299 static int can_create(struct socket *sock, int protocol)
302 struct can_proto *cp;
305 DBG("socket %p, type %d, proto %d\n", sock, sock->type, protocol);
307 sock->state = SS_UNCONNECTED;
309 if (protocol < 0 || protocol >= CAN_NPROTO)
312 DBG("looking up proto %d in proto_tab[]\n", protocol);
314 /* try to load protocol module, when CONFIG_KMOD is defined */
315 if (!proto_tab[protocol]) {
316 char module_name[30];
317 sprintf(module_name, "can-proto-%d", protocol);
318 if (request_module(module_name) == -ENOSYS)
319 printk(KERN_INFO "af_can: request_module(%s) not implemented.\n",
323 /* check for success and correct type */
324 if (!(cp = proto_tab[protocol]) || cp->type != sock->type)
325 return -EPROTONOSUPPORT;
327 if (cp->capability >= 0 && !capable(cp->capability))
332 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
333 sk = sk_alloc(PF_CAN, GFP_KERNEL, cp->prot, 1);
337 sk = sk_alloc(PF_CAN, GFP_KERNEL, 1, 0);
341 !(sk->sk_protinfo = kmalloc(cp->obj_size, GFP_KERNEL))) {
345 sk_set_owner(sk, proto_tab[protocol]->owner);
347 sock_init_data(sock, sk);
348 sk->sk_destruct = can_sock_destruct;
350 DBG("created sock: %p\n", sk);
353 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
354 if (sk->sk_prot->init)
355 ret = sk->sk_prot->init(sk);
361 /* we must release sk */
373 static int can_notifier(struct notifier_block *nb,
374 unsigned long msg, void *data)
376 struct net_device *dev = (struct net_device *)data;
379 DBG("called for %s, msg = %lu\n", dev->name, msg);
382 if (dev->type != ARPHRD_CAN)
387 struct dev_rcv_lists *d;
390 case NETDEV_REGISTER:
392 /* create new dev_rcv_lists for this device */
394 DBG("creating new dev_rcv_lists for %s\n", dev->name);
395 if (!(d = kmalloc(sizeof(*d), GFP_KERNEL))) {
396 printk(KERN_ERR "CAN: allocation of receive list failed\n");
399 /* N.B. zeroing the struct is the correct initialization
400 for the embedded hlist_head structs.
401 Another list type, e.g. list_head, would require
402 explicit initialization. */
403 memset(d, 0, sizeof(*d));
406 spin_lock(&rcv_lists_lock);
407 hlist_add_head_rcu(&d->list, &rx_dev_list);
408 spin_unlock(&rcv_lists_lock);
412 case NETDEV_UNREGISTER:
413 spin_lock(&rcv_lists_lock);
415 if (!(d = find_dev_rcv_lists(dev))) {
416 printk(KERN_ERR "CAN: notifier: receive list not "
417 "found for dev %s\n", dev->name);
421 hlist_del_rcu(&d->list);
423 /* remove all receivers hooked at this netdevice */
424 can_rx_delete_all(&d->rx_err);
425 can_rx_delete_all(&d->rx_all);
426 can_rx_delete_all(&d->rx_fil);
427 can_rx_delete_all(&d->rx_inv);
428 can_rx_delete_all(&d->rx_eff);
429 for (i = 0; i < 2048; i++)
430 can_rx_delete_all(&d->rx_sff[i]);
433 spin_unlock(&rcv_lists_lock);
436 call_rcu(&d->rcu, can_rcv_lists_delete);
441 read_lock(¬ifier_lock);
442 list_for_each_entry(n, ¬ifier_list, list) {
444 n->func(msg, n->data);
446 read_unlock(¬ifier_lock);
451 static int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
453 struct sock *sk = sock->sk;
457 return sock_get_timestamp(sk, (struct timeval __user *)arg);
459 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
462 return dev_ioctl(cmd, (void __user *)arg);
468 /**************************************************/
470 /**************************************************/
472 int can_send(struct sk_buff *skb, int loop)
476 if (loop) { /* local loopback (default) */
477 *(struct sock **)skb->cb = skb->sk; /* tx sock reference */
479 /* interface not capabable to do the loopback itself? */
480 if (!(skb->dev->flags & IFF_LOOPBACK)) {
481 struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
482 newskb->protocol = htons(ETH_P_CAN);
483 newskb->ip_summed = CHECKSUM_UNNECESSARY;
484 netif_rx(newskb); /* perform local loopback here */
487 *(struct sock **)skb->cb = NULL; /* no loopback required */
489 if (!(skb->dev->flags & IFF_UP))
491 else if ((err = dev_queue_xmit(skb)) > 0) /* send to netdevice */
492 err = net_xmit_errno(err);
494 /* update statistics */
496 stats.tx_frames_delta++;
501 /**************************************************/
503 /**************************************************/
505 void can_rx_register(struct net_device *dev, canid_t can_id, canid_t mask,
506 void (*func)(struct sk_buff *, void *), void *data,
510 struct hlist_head *rl;
511 struct dev_rcv_lists *d;
513 /* insert new receiver (dev,canid,mask) -> (func,data) */
515 DBG("dev %p, id %03X, mask %03X, callback %p, data %p, ident %s\n",
516 dev, can_id, mask, func, data, ident);
518 if (!(r = kmem_cache_alloc(rcv_cache, GFP_KERNEL)))
521 spin_lock(&rcv_lists_lock);
523 if (!(d = find_dev_rcv_lists(dev))) {
524 printk(KERN_ERR "CAN: receive list not found for "
525 "dev %s, id %03X, mask %03X\n", dev->name, can_id, mask);
526 kmem_cache_free(rcv_cache, r);
530 rl = find_rcv_list(&can_id, &mask, d);
539 hlist_add_head_rcu(&r->list, rl);
542 pstats.rcv_entries++;
543 if (pstats.rcv_entries_max < pstats.rcv_entries)
544 pstats.rcv_entries_max = pstats.rcv_entries;
547 spin_unlock(&rcv_lists_lock);
552 static void can_rcv_lists_delete(struct rcu_head *rp)
554 struct dev_rcv_lists *d = container_of(rp, struct dev_rcv_lists, rcu);
558 static void can_rx_delete(struct rcu_head *rp)
560 struct receiver *r = container_of(rp, struct receiver, rcu);
561 kmem_cache_free(rcv_cache, r);
564 static void can_rx_delete_all(struct hlist_head *rl)
567 struct hlist_node *n;
569 hlist_for_each_entry_rcu(r, n, rl, list) {
570 hlist_del_rcu(&r->list);
571 call_rcu(&r->rcu, can_rx_delete);
575 void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
576 void (*func)(struct sk_buff *, void *), void *data)
579 struct hlist_head *rl;
580 struct hlist_node *next;
581 struct dev_rcv_lists *d;
583 DBG("dev %p, id %03X, mask %03X, callback %p, data %p\n",
584 dev, can_id, mask, func, data);
588 spin_lock(&rcv_lists_lock);
590 if (!(d = find_dev_rcv_lists(dev))) {
591 printk(KERN_ERR "CAN: receive list not found for "
592 "dev %s, id %03X, mask %03X\n", dev->name, can_id, mask);
596 rl = find_rcv_list(&can_id, &mask, d);
598 /* Search the receiver list for the item to delete. This should
599 * exist, since no receiver may be unregistered that hasn't
600 * been registered before.
603 hlist_for_each_entry(r, next, rl, list) {
604 if (r->can_id == can_id && r->mask == mask
605 && r->func == func && r->data == data)
609 /* Check for bug in CAN protocol implementations:
610 * If no matching list item was found, the list cursor variable next
611 * will be NULL, while r will point to the last item of the list.
615 printk(KERN_ERR "CAN: receive list entry not found for "
616 "dev %s, id %03X, mask %03X\n", dev->name, can_id, mask);
621 hlist_del_rcu(&r->list);
624 if (pstats.rcv_entries > 0)
625 pstats.rcv_entries--;
628 spin_unlock(&rcv_lists_lock);
630 /* schedule the receiver item for deletion */
632 call_rcu(&r->rcu, can_rx_delete);
635 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
636 static int can_rcv(struct sk_buff *skb, struct net_device *dev,
637 struct packet_type *pt, struct net_device *orig_dev)
639 static int can_rcv(struct sk_buff *skb, struct net_device *dev,
640 struct packet_type *pt)
643 struct dev_rcv_lists *d;
646 DBG("received skbuff on device %s, ptype %04x\n",
647 dev->name, ntohs(pt->type));
649 DBG_FRAME("af_can: can_rcv: received CAN frame",
650 (struct can_frame *)skb->data);
652 /* update statistics */
654 stats.rx_frames_delta++;
658 /* deliver the packet to sockets listening on all devices */
659 matches = can_rcv_filter(&rx_alldev_list, skb);
661 /* find receive list for this device */
662 if ((d = find_dev_rcv_lists(dev)))
663 matches += can_rcv_filter(d, skb);
667 /* free the skbuff allocated by the netdevice driver */
668 DBG("freeing skbuff %p\n", skb);
673 stats.matches_delta++;
680 static inline void deliver(struct sk_buff *skb, struct receiver *r)
682 struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
683 DBG("skbuff %p cloned to %p\n", skb, clone);
685 r->func(clone, r->data);
686 r->matches++; /* update specific statistics */
690 static int can_rcv_filter(struct dev_rcv_lists *d, struct sk_buff *skb)
693 struct hlist_node *n;
695 struct can_frame *cf = (struct can_frame*)skb->data;
696 canid_t can_id = cf->can_id;
701 if (can_id & CAN_ERR_FLAG) {
702 /* check for error frame entries only */
703 hlist_for_each_entry_rcu(r, n, &d->rx_err, list) {
704 if (can_id & r->mask) {
705 DBG("match on rx_err skbuff %p\n", skb);
713 /* check for unfiltered entries */
714 hlist_for_each_entry_rcu(r, n, &d->rx_all, list) {
715 DBG("match on rx_all skbuff %p\n", skb);
720 /* check for can_id/mask entries */
721 hlist_for_each_entry_rcu(r, n, &d->rx_fil, list) {
722 if ((can_id & r->mask) == r->can_id) {
723 DBG("match on rx_fil skbuff %p\n", skb);
729 /* check for inverted can_id/mask entries */
730 hlist_for_each_entry_rcu(r, n, &d->rx_inv, list) {
731 if ((can_id & r->mask) != r->can_id) {
732 DBG("match on rx_inv skbuff %p\n", skb);
738 /* check CAN_ID specific entries */
739 if (can_id & CAN_EFF_FLAG) {
740 hlist_for_each_entry_rcu(r, n, &d->rx_eff, list) {
741 if (r->can_id == can_id) {
742 DBG("match on rx_eff skbuff %p\n", skb);
748 can_id &= CAN_SFF_MASK;
749 hlist_for_each_entry_rcu(r, n, &d->rx_sff[can_id], list) {
750 DBG("match on rx_sff skbuff %p\n", skb);
760 static struct dev_rcv_lists *find_dev_rcv_lists(struct net_device *dev)
762 struct dev_rcv_lists *d;
763 struct hlist_node *n;
765 /* find receive list for this device */
768 return &rx_alldev_list;
770 /* The hlist_for_each_entry*() macros curse through the list
771 * using the pointer variable n and set d to the containing
772 * struct in each list iteration. Therefore, after list
773 * iteration, d is unmodified when the list is empty, and it
774 * points to last list element, when the list is non-empty
775 * but no match in the loop body is found. I.e. d is *not*
776 * NULL when no match is found. We can, however, use the
777 * cursor variable n to decide if a match was found.
780 hlist_for_each_entry(d, n, &rx_dev_list, list)
787 static struct hlist_head *find_rcv_list(canid_t *can_id, canid_t *mask,
788 struct dev_rcv_lists *d)
790 canid_t inv = *can_id & CAN_INV_FILTER; /* save flag before masking values */
791 canid_t eff = *can_id & *mask & CAN_EFF_FLAG; /* correct EFF check? */
792 canid_t rtr = *can_id & *mask & CAN_RTR_FLAG; /* correct RTR check? */
793 canid_t err = *mask & CAN_ERR_FLAG; /* mask for error frames only */
795 /* make some paranoic operations */
796 if (*can_id & CAN_EFF_FLAG)
797 *mask &= (CAN_EFF_MASK | eff | rtr);
799 *mask &= (CAN_SFF_MASK | rtr);
803 if (err) /* error frames */
806 if (inv) /* inverse can_id/can_mask filter and RTR */
809 if (*can_id & CAN_RTR_FLAG) /* positive filter RTR */
812 if (!(*mask)) /* mask == 0 => no filter */
815 if (*can_id & CAN_EFF_FLAG) {
816 if (*mask == CAN_EFF_MASK) /* filter exact EFF can_id */
819 if (*mask == CAN_SFF_MASK) /* filter exact SFF can_id */
820 return &d->rx_sff[*can_id];
823 return &d->rx_fil; /* filter via can_id/can_mask */
826 /**************************************************/
827 /* af_can utility stuff */
828 /**************************************************/
830 unsigned long timeval2jiffies(struct timeval *tv, int round_up)
833 unsigned long sec = tv->tv_sec;
834 unsigned long usec = tv->tv_usec;
836 if (sec > ULONG_MAX / HZ) /* check for overflow */
839 if (round_up) /* any usec below one HZ? */
840 usec += 1000000 / HZ - 1; /* pump it up */
842 jif = usec / (1000000 / HZ);
844 if (sec * HZ > ULONG_MAX - jif) /* check for overflow */
847 return jif + sec * HZ;
851 /**************************************************/
852 /* af_can debugging stuff */
853 /**************************************************/
855 #ifdef CONFIG_CAN_DEBUG_CORE
857 void can_debug_cframe(const char *msg, struct can_frame *cf, ...)
864 len = sprintf(buf, KERN_DEBUG);
866 len += snprintf(buf + len, sizeof(buf) - 64, msg, ap);
871 if ((dlc = cf->can_dlc) > 8)
874 if (cf->can_id & CAN_EFF_FLAG)
875 len += sprintf(buf + len, "<%08X> [%X] ",
876 cf->can_id & CAN_EFF_MASK, dlc);
878 len += sprintf(buf + len, "<%03X> [%X] ",
879 cf->can_id & CAN_SFF_MASK, dlc);
881 for (i = 0; i < dlc; i++)
882 len += sprintf(buf + len, "%02X ", cf->data[i]);
884 if (cf->can_id & CAN_RTR_FLAG)
885 len += sprintf(buf + len, "(RTR)");
892 void can_debug_skb(struct sk_buff *skb)
898 KERN_DEBUG " skbuff at %p, dev: %d, proto: %04x\n"
899 KERN_DEBUG " users: %d, dataref: %d, nr_frags: %d, "
900 "h,d,t,e,l: %p %+d %+d %+d, %d",
901 skb, skb->dev ? skb->dev->ifindex : -1,
902 ntohs(skb->protocol),
903 atomic_read(&skb->users),
904 atomic_read(&(skb_shinfo(skb)->dataref)),
905 skb_shinfo(skb)->nr_frags,
906 skb->head, skb->data - skb->head,
907 skb->tail - skb->head, skb->end - skb->head, skb->len);
908 nbytes = skb->end - skb->head;
909 for (i = 0; i < nbytes; i++) {
911 len += sprintf(buf + len, "\n" KERN_DEBUG " ");
912 if (len < sizeof(buf) - 16) {
913 len += sprintf(buf + len, " %02x", skb->head[i]);
915 len += sprintf(buf + len, "...");
924 EXPORT_SYMBOL(can_debug_cframe);
925 EXPORT_SYMBOL(can_debug_skb);
929 /**************************************************/
930 /* Exported symbols */
931 /**************************************************/
932 EXPORT_SYMBOL(can_proto_register);
933 EXPORT_SYMBOL(can_proto_unregister);
934 EXPORT_SYMBOL(can_rx_register);
935 EXPORT_SYMBOL(can_rx_unregister);
936 EXPORT_SYMBOL(can_dev_register);
937 EXPORT_SYMBOL(can_dev_unregister);
938 EXPORT_SYMBOL(can_send);
939 EXPORT_SYMBOL(timeval2jiffies);