diff options
Diffstat (limited to 'net/batman-adv/main.c')
-rw-r--r-- | net/batman-adv/main.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index dc33a0c484a4..f65a222b7b83 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c | |||
@@ -17,6 +17,8 @@ | |||
17 | * 02110-1301, USA | 17 | * 02110-1301, USA |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/crc32c.h> | ||
21 | #include <linux/highmem.h> | ||
20 | #include "main.h" | 22 | #include "main.h" |
21 | #include "sysfs.h" | 23 | #include "sysfs.h" |
22 | #include "debugfs.h" | 24 | #include "debugfs.h" |
@@ -420,6 +422,38 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) | |||
420 | return 0; | 422 | return 0; |
421 | } | 423 | } |
422 | 424 | ||
425 | /** | ||
426 | * batadv_skb_crc32 - calculate CRC32 of the whole packet and skip bytes in | ||
427 | * the header | ||
428 | * @skb: skb pointing to fragmented socket buffers | ||
429 | * @payload_ptr: Pointer to position inside the head buffer of the skb | ||
430 | * marking the start of the data to be CRC'ed | ||
431 | * | ||
432 | * payload_ptr must always point to an address in the skb head buffer and not to | ||
433 | * a fragment. | ||
434 | */ | ||
435 | __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr) | ||
436 | { | ||
437 | u32 crc = 0; | ||
438 | unsigned int from; | ||
439 | unsigned int to = skb->len; | ||
440 | struct skb_seq_state st; | ||
441 | const u8 *data; | ||
442 | unsigned int len; | ||
443 | unsigned int consumed = 0; | ||
444 | |||
445 | from = (unsigned int)(payload_ptr - skb->data); | ||
446 | |||
447 | skb_prepare_seq_read(skb, from, to, &st); | ||
448 | while ((len = skb_seq_read(consumed, &data, &st)) != 0) { | ||
449 | crc = crc32c(crc, data, len); | ||
450 | consumed += len; | ||
451 | } | ||
452 | skb_abort_seq_read(&st); | ||
453 | |||
454 | return htonl(crc); | ||
455 | } | ||
456 | |||
423 | static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) | 457 | static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) |
424 | { | 458 | { |
425 | struct batadv_algo_ops *bat_algo_ops; | 459 | struct batadv_algo_ops *bat_algo_ops; |