]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode/checksums: constify pointer args
authorVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 13:48:18 +0000 (15:48 +0200)
committerVictor Julien <vjulien@oisf.net>
Mon, 9 May 2022 14:06:38 +0000 (16:06 +0200)
src/decode-icmpv4.h
src/decode-icmpv6.h
src/decode-ipv4.h
src/decode-ipv6.h
src/decode-tcp.h
src/decode-udp.h

index 8d44c17875fe96998fd1547cd5a2136f45f68c48..ed1f657013a1b83f8e37046431a48eff43f16563 100644 (file)
@@ -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__ */
-
index 39b2e3d47879f73843fedbe149987c95ce5b9e27..3b836499b5d3dd172afb44d5796df4c37dd55843 100644 (file)
@@ -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__ */
-
index 4802753b8ee4ec152e3807d2405d91894115836b..0da5ab5b8ec870f64daf19ac24019ec772e3a0b0 100644 (file)
@@ -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__ */
-
index b855b2151018a8cad510e5937269bf7bc4c51bfc..651939ae567f5c913c426cc61f43f70a4ccf1795 100644 (file)
@@ -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__ */
-
index 01c39032617e1105bb0f126d3cea15de98cf43d6..8ef6caedd1de02b6aeb2e74ce5cff318dbc77033 100644 (file)
@@ -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__ */
-
index a033e086e1a57774d120075a861b04f08a9d6745..6f695bd1779ea906af4e6f03d715fc77bb08913c 100644 (file)
@@ -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__ */