From: Victor Julien Date: Wed, 27 Apr 2022 13:48:18 +0000 (+0200) Subject: decode/checksums: constify pointer args X-Git-Tag: suricata-7.0.0-beta1~621 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=002b335b4a71cc527f3229bbc47828db536aea39;p=thirdparty%2Fsuricata.git decode/checksums: constify pointer args --- diff --git a/src/decode-icmpv4.h b/src/decode-icmpv4.h index 8d44c17875..ed1f657013 100644 --- a/src/decode-icmpv4.h +++ b/src/decode-icmpv4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -292,7 +292,6 @@ typedef struct ICMPV4Timestamp_ { void DecodeICMPV4RegisterTests(void); /** ------ Inline functions ------ */ -static inline uint16_t ICMPV4CalculateChecksum(uint16_t *, uint16_t); /** * \brief Calculates the checksum for the ICMP packet @@ -302,7 +301,7 @@ static inline uint16_t ICMPV4CalculateChecksum(uint16_t *, uint16_t); * * \retval csum Checksum for the ICMP packet */ -static inline uint16_t ICMPV4CalculateChecksum(uint16_t *pkt, uint16_t tlen) +static inline uint16_t ICMPV4CalculateChecksum(const uint16_t *pkt, uint16_t tlen) { uint16_t pad = 0; uint32_t csum = pkt[0]; @@ -350,4 +349,3 @@ static inline uint16_t ICMPV4CalculateChecksum(uint16_t *pkt, uint16_t tlen) int ICMPv4GetCounterpart(uint8_t type); #endif /* __DECODE_ICMPV4_H__ */ - diff --git a/src/decode-icmpv6.h b/src/decode-icmpv6.h index 39b2e3d478..3b836499b5 100644 --- a/src/decode-icmpv6.h +++ b/src/decode-icmpv6.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -195,7 +195,6 @@ void DecodeICMPV6RegisterTests(void); int ICMPv6GetCounterpart(uint8_t type); /** -------- Inline functions --------- */ -static inline uint16_t ICMPV6CalculateChecksum(uint16_t *, uint16_t *, uint16_t); /** * \brief Calculates the checksum for the ICMPV6 packet @@ -207,8 +206,8 @@ static inline uint16_t ICMPV6CalculateChecksum(uint16_t *, uint16_t *, uint16_t) * * \retval csum Checksum for the ICMPV6 packet */ -static inline uint16_t ICMPV6CalculateChecksum(uint16_t *shdr, uint16_t *pkt, - uint16_t tlen) +static inline uint16_t ICMPV6CalculateChecksum( + const uint16_t *shdr, const uint16_t *pkt, uint16_t tlen) { uint16_t pad = 0; uint32_t csum = shdr[0]; @@ -269,6 +268,4 @@ static inline uint16_t ICMPV6CalculateChecksum(uint16_t *shdr, uint16_t *pkt, return (uint16_t) ~csum; } - #endif /* __DECODE_ICMPV6_H__ */ - diff --git a/src/decode-ipv4.h b/src/decode-ipv4.h index 4802753b8e..0da5ab5b8e 100644 --- a/src/decode-ipv4.h +++ b/src/decode-ipv4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -180,7 +180,6 @@ typedef struct IPV4Vars_ void DecodeIPV4RegisterTests(void); /** ----- Inline functions ----- */ -static inline uint16_t IPV4Checksum(uint16_t *, uint16_t, uint16_t); /** * \brief Calculateor validate the checksum for the IP packet @@ -192,7 +191,7 @@ static inline uint16_t IPV4Checksum(uint16_t *, uint16_t, uint16_t); * \retval csum For validation 0 will be returned for success, for calculation * this will be the checksum. */ -static inline uint16_t IPV4Checksum(uint16_t *pkt, uint16_t hlen, uint16_t init) +static inline uint16_t IPV4Checksum(const uint16_t *pkt, uint16_t hlen, uint16_t init) { uint32_t csum = init; @@ -243,4 +242,3 @@ static inline uint16_t IPV4Checksum(uint16_t *pkt, uint16_t hlen, uint16_t init) } #endif /* __DECODE_IPV4_H__ */ - diff --git a/src/decode-ipv6.h b/src/decode-ipv6.h index b855b21510..651939ae56 100644 --- a/src/decode-ipv6.h +++ b/src/decode-ipv6.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -243,4 +243,3 @@ typedef struct IPV6ExtHdrs_ void DecodeIPV6RegisterTests(void); #endif /* __DECODE_IPV6_H__ */ - diff --git a/src/decode-tcp.h b/src/decode-tcp.h index 01c3903261..8ef6caedd1 100644 --- a/src/decode-tcp.h +++ b/src/decode-tcp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -176,8 +176,6 @@ typedef struct TCPVars_ void DecodeTCPRegisterTests(void); /** -------- Inline functions ------- */ -static inline uint16_t TCPChecksum(uint16_t *, uint16_t *, uint16_t, uint16_t); -static inline uint16_t TCPV6Checksum(uint16_t *, uint16_t *, uint16_t, uint16_t); /** * \brief Calculate or validate the checksum for the TCP packet @@ -191,8 +189,8 @@ static inline uint16_t TCPV6Checksum(uint16_t *, uint16_t *, uint16_t, uint16_t) * \retval csum For validation 0 will be returned for success, for calculation * this will be the checksum. */ -static inline uint16_t TCPChecksum(uint16_t *shdr, uint16_t *pkt, - uint16_t tlen, uint16_t init) +static inline uint16_t TCPChecksum( + const uint16_t *shdr, const uint16_t *pkt, uint16_t tlen, uint16_t init) { uint16_t pad = 0; uint32_t csum = init; @@ -256,8 +254,8 @@ static inline uint16_t TCPChecksum(uint16_t *shdr, uint16_t *pkt, * \retval csum For validation 0 will be returned for success, for calculation * this will be the checksum. */ -static inline uint16_t TCPV6Checksum(uint16_t *shdr, uint16_t *pkt, - uint16_t tlen, uint16_t init) +static inline uint16_t TCPV6Checksum( + const uint16_t *shdr, const uint16_t *pkt, uint16_t tlen, uint16_t init) { uint16_t pad = 0; uint32_t csum = init; @@ -309,6 +307,4 @@ static inline uint16_t TCPV6Checksum(uint16_t *shdr, uint16_t *pkt, return (uint16_t)~csum; } - #endif /* __DECODE_TCP_H__ */ - diff --git a/src/decode-udp.h b/src/decode-udp.h index a033e086e1..6f695bd177 100644 --- a/src/decode-udp.h +++ b/src/decode-udp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -54,8 +54,6 @@ typedef struct UDPHdr_ void DecodeUDPV4RegisterTests(void); /** ------ Inline function ------ */ -static inline uint16_t UDPV4Checksum(uint16_t *, uint16_t *, uint16_t, uint16_t); -static inline uint16_t UDPV6Checksum(uint16_t *, uint16_t *, uint16_t, uint16_t); /** * \brief Calculate or valid the checksum for the UDP packet @@ -70,8 +68,8 @@ static inline uint16_t UDPV6Checksum(uint16_t *, uint16_t *, uint16_t, uint16_t) * \retval csum For validation 0 will be returned for success, for calculation * this will be the checksum. */ -static inline uint16_t UDPV4Checksum(uint16_t *shdr, uint16_t *pkt, - uint16_t tlen, uint16_t init) +static inline uint16_t UDPV4Checksum( + const uint16_t *shdr, const uint16_t *pkt, uint16_t tlen, uint16_t init) { uint16_t pad = 0; uint32_t csum = init; @@ -137,8 +135,8 @@ static inline uint16_t UDPV4Checksum(uint16_t *shdr, uint16_t *pkt, * \retval csum For validation 0 will be returned for success, for calculation * this will be the checksum. */ -static inline uint16_t UDPV6Checksum(uint16_t *shdr, uint16_t *pkt, - uint16_t tlen, uint16_t init) +static inline uint16_t UDPV6Checksum( + const uint16_t *shdr, const uint16_t *pkt, uint16_t tlen, uint16_t init) { uint16_t pad = 0; uint32_t csum = init; @@ -193,5 +191,4 @@ static inline uint16_t UDPV6Checksum(uint16_t *shdr, uint16_t *pkt, return csum_u16; } - #endif /* __DECODE_UDP_H__ */