/*
* 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);
}
* 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;
/* 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;
/* 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;
/* 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;
}
/* 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;
* 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;
* 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)
}
/* 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)
}
/* 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;
* 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;
# endif
#endif /* HEADER_PACKET_LOCL_H */
-