lsquic_parse_common.h revision 229fce07
1/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_parse_common.h 4 */ 5 6#ifndef LSQUIC_PARSE_COMMON_H 7#define LSQUIC_PARSE_COMMON_H 1 8 9struct lsquic_packet_in; 10 11struct packin_parse_state { 12 const unsigned char *pps_p; /* Pointer to packet number */ 13 unsigned pps_nbytes; /* Number of bytes in packet number */ 14}; 15 16int 17lsquic_parse_packet_in_begin (struct lsquic_packet_in *, 18 size_t length, int is_server, struct packin_parse_state *); 19 20int 21lsquic_iquic_parse_packet_in_begin (struct lsquic_packet_in *, 22 size_t length, int is_server, struct packin_parse_state *); 23 24/* Instead of just -1 like CHECK_SPACE(), this macro returns the number 25 * of bytes needed. 26 */ 27#define CHECK_STREAM_SPACE(need, pstart, pend) do { \ 28 if ((intptr_t) (need) > ((pend) - (pstart))) { \ 29 return -((int) (need)); \ 30 } \ 31} while (0) 32 33#endif 34