fletcher16.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Eistec AB
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef CHECKSUM_FLETCHER16_H
21 #define CHECKSUM_FLETCHER16_H
22 
23 #include <stdlib.h>
24 #include <stdint.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
33 typedef struct {
34  uint16_t sum1;
35  uint16_t sum2;
37 
51 uint16_t fletcher16(const uint8_t *buf, size_t bytes);
52 
61 
69 void fletcher16_update(fletcher16_ctx_t *ctx, const uint8_t *data, size_t len);
70 
78 uint16_t fletcher16_finish(fletcher16_ctx_t *ctx);
79 
80 
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif /* CHECKSUM_FLETCHER16_H */
87 
fletcher16
uint16_t fletcher16(const uint8_t *buf, size_t bytes)
Fletcher's 16 bit checksum.
fletcher16_ctx_t::sum1
uint16_t sum1
First sum of the checksum.
Definition: fletcher16.h:34
fletcher16_update
void fletcher16_update(fletcher16_ctx_t *ctx, const uint8_t *data, size_t len)
Update the fletcher16 context with new data.
fletcher16_ctx_t
Fletcher's 16 bit checksum context struct.
Definition: fletcher16.h:33
fletcher16_ctx_t::sum2
uint16_t sum2
Second sum of the checksum.
Definition: fletcher16.h:35
fletcher16_init
void fletcher16_init(fletcher16_ctx_t *ctx)
Initialize a fletcher16 context.
fletcher16_finish
uint16_t fletcher16_finish(fletcher16_ctx_t *ctx)
Finalize the checksum operation and return the checksum.