]>
git.proxmox.com Git - mirror_frr.git/blob - isisd/iso_checksum.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * IS-IS Rout(e)ing protocol - iso_checksum.c
4 * ISO checksum related routines
6 * Copyright (C) 2001,2002 Sampo Saaristo
7 * Tampere University of Technology
8 * Institute of Communications Engineering
12 #include "iso_checksum.h"
16 * Calculations of the OSI checksum.
17 * ISO/IEC 8473 defines the sum as
24 * sum (L-i+1)a (mod 255) = 0
30 * Verifies that the checksum is correct.
31 * Return 0 on correct and 1 on invalid checksum.
32 * Based on Annex C.4 of ISO/IEC 8473
35 int iso_csum_verify(uint8_t *buffer
, int len
, uint16_t csum
, int offset
)
45 * If both are zero return correct
47 if (c0
== 0 && c1
== 0)
51 * If either, but not both are zero return incorrect
53 if (c0
== 0 || c1
== 0)
56 checksum
= fletcher_checksum(buffer
, len
, offset
);
57 if (checksum
== htons(csum
))