decode/checksums: constify pointer args

pull/7392/head
Victor Julien 5 years ago
parent 350be6cbac
commit 002b335b4a

@ -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__ */

@ -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__ */

@ -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__ */

@ -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__ */

@ -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__ */

@ -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__ */

Loading…
Cancel
Save