aboutsummaryrefslogtreecommitdiff
path: root/ssl/packet_locl.h
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2015-08-18 14:55:53 +0200
committerEmilia Kasper <emilia@openssl.org>2015-08-26 13:19:12 +0200
commit2aa815c343357524aa5a3775994d694de65544f8 (patch)
tree3cda04f608b4fbd2b7f4930e78841eaf297f9604 /ssl/packet_locl.h
parentb48357d9953decc43333979ca11ebc1500040f4e (diff)
downloadopenssl-2aa815c343357524aa5a3775994d694de65544f8.zip
openssl-2aa815c343357524aa5a3775994d694de65544f8.tar.gz
openssl-2aa815c343357524aa5a3775994d694de65544f8.tar.bz2
PACKET: constify where possible
The PACKET should hold a 'const unsigned char*' underneath as well but the legacy code passes the record buffer around as 'unsigned char*' (to callbacks, too) so that's a bigger refactor. Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'ssl/packet_locl.h')
-rw-r--r--ssl/packet_locl.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h
index a5e4d00..0d5d823 100644
--- a/ssl/packet_locl.h
+++ b/ssl/packet_locl.h
@@ -82,7 +82,7 @@ typedef struct {
/*
* Returns the number of bytes remaining to be read in the PACKET
*/
-__owur static inline size_t PACKET_remaining(PACKET *pkt)
+__owur static inline size_t PACKET_remaining(const PACKET *pkt)
{
return (size_t)(pkt->end - pkt->curr);
}
@@ -113,8 +113,8 @@ static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf, size_t len)
* Data is not copied: the |subpkt| packet will share its underlying buffer with
* the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|.
*/
-__owur static inline int PACKET_peek_sub_packet(PACKET *pkt, PACKET *subpkt,
- size_t len)
+__owur static inline int PACKET_peek_sub_packet(const PACKET *pkt,
+ PACKET *subpkt, size_t len)
{
if (PACKET_remaining(pkt) < len)
return 0;
@@ -143,7 +143,8 @@ __owur static inline int PACKET_get_sub_packet(PACKET *pkt, PACKET *subpkt,
/* Peek ahead at 2 bytes in network order from |pkt| and store the value in
* |*data|
*/
-__owur static inline int PACKET_peek_net_2(PACKET *pkt, unsigned int *data)
+__owur static inline int PACKET_peek_net_2(const PACKET *pkt,
+ unsigned int *data)
{
if (PACKET_remaining(pkt) < 2)
return 0;
@@ -169,7 +170,8 @@ __owur static inline int PACKET_get_net_2(PACKET *pkt, unsigned int *data)
/* Peek ahead at 3 bytes in network order from |pkt| and store the value in
* |*data|
*/
-__owur static inline int PACKET_peek_net_3(PACKET *pkt, unsigned long *data)
+__owur static inline int PACKET_peek_net_3(const PACKET *pkt,
+ unsigned long *data)
{
if (PACKET_remaining(pkt) < 3)
return 0;
@@ -196,7 +198,8 @@ __owur static inline int PACKET_get_net_3(PACKET *pkt, unsigned long *data)
/* Peek ahead at 4 bytes in network order from |pkt| and store the value in
* |*data|
*/
-__owur static inline int PACKET_peek_net_4(PACKET *pkt, unsigned long *data)
+__owur static inline int PACKET_peek_net_4(const PACKET *pkt,
+ unsigned long *data)
{
if (PACKET_remaining(pkt) < 4)
return 0;
@@ -222,7 +225,7 @@ __owur static inline int PACKET_get_net_4(PACKET *pkt, unsigned long *data)
}
/* Peek ahead at 1 byte from |pkt| and store the value in |*data| */
-__owur static inline int PACKET_peek_1(PACKET *pkt, unsigned int *data)
+__owur static inline int PACKET_peek_1(const PACKET *pkt, unsigned int *data)
{
if (!PACKET_remaining(pkt))
return 0;
@@ -247,7 +250,7 @@ __owur static inline int PACKET_get_1(PACKET *pkt, unsigned int *data)
* Peek ahead at 4 bytes in reverse network order from |pkt| and store the value
* in |*data|
*/
-__owur static inline int PACKET_peek_4(PACKET *pkt, unsigned long *data)
+__owur static inline int PACKET_peek_4(const PACKET *pkt, unsigned long *data)
{
if (PACKET_remaining(pkt) < 4)
return 0;
@@ -281,7 +284,7 @@ __owur static inline int PACKET_get_4(PACKET *pkt, unsigned long *data)
* caller should not free this data directly (it will be freed when the
* underlying buffer gets freed
*/
-__owur static inline int PACKET_peek_bytes(PACKET *pkt, unsigned char **data,
+__owur static inline int PACKET_peek_bytes(const PACKET *pkt, unsigned char **data,
size_t len)
{
if (PACKET_remaining(pkt) < len)
@@ -310,7 +313,7 @@ __owur static inline int PACKET_get_bytes(PACKET *pkt, unsigned char **data,
}
/* Peek ahead at |len| bytes from |pkt| and copy them to |data| */
-__owur static inline int PACKET_peek_copy_bytes(PACKET *pkt,
+__owur static inline int PACKET_peek_copy_bytes(const PACKET *pkt,
unsigned char *data, size_t len)
{
if (PACKET_remaining(pkt) < len)
@@ -356,7 +359,7 @@ __owur static inline int PACKET_forward(PACKET *pkt, size_t len)
}
/* Store a bookmark for the current reading position in |*bm| */
-__owur static inline int PACKET_get_bookmark(PACKET *pkt, size_t *bm)
+__owur static inline int PACKET_get_bookmark(const PACKET *pkt, size_t *bm)
{
*bm = pkt->curr - pkt->start;
@@ -378,7 +381,7 @@ __owur static inline int PACKET_goto_bookmark(PACKET *pkt, size_t bm)
* Stores the total length of the packet we have in the underlying buffer in
* |*len|
*/
-__owur static inline int PACKET_length(PACKET *pkt, size_t *len)
+__owur static inline int PACKET_length(const PACKET *pkt, size_t *len)
{
*len = pkt->end - pkt->start;
@@ -390,4 +393,3 @@ __owur static inline int PACKET_length(PACKET *pkt, size_t *len)
# endif
#endif /* HEADER_PACKET_LOCL_H */
-