lsquic_parse_common.h revision 229fce07
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE. */ 29626cfc2SDmitri Tikhonov/* 39626cfc2SDmitri Tikhonov * lsquic_parse_common.h 49626cfc2SDmitri Tikhonov */ 59626cfc2SDmitri Tikhonov 69626cfc2SDmitri Tikhonov#ifndef LSQUIC_PARSE_COMMON_H 79626cfc2SDmitri Tikhonov#define LSQUIC_PARSE_COMMON_H 1 89626cfc2SDmitri Tikhonov 99626cfc2SDmitri Tikhonovstruct lsquic_packet_in; 109626cfc2SDmitri Tikhonov 119626cfc2SDmitri Tikhonovstruct packin_parse_state { 129626cfc2SDmitri Tikhonov const unsigned char *pps_p; /* Pointer to packet number */ 139626cfc2SDmitri Tikhonov unsigned pps_nbytes; /* Number of bytes in packet number */ 149626cfc2SDmitri Tikhonov}; 159626cfc2SDmitri Tikhonov 169626cfc2SDmitri Tikhonovint 179626cfc2SDmitri Tikhonovlsquic_parse_packet_in_begin (struct lsquic_packet_in *, 189626cfc2SDmitri Tikhonov size_t length, int is_server, struct packin_parse_state *); 199626cfc2SDmitri Tikhonov 209626cfc2SDmitri Tikhonovint 219626cfc2SDmitri Tikhonovlsquic_iquic_parse_packet_in_begin (struct lsquic_packet_in *, 229626cfc2SDmitri Tikhonov size_t length, int is_server, struct packin_parse_state *); 239626cfc2SDmitri Tikhonov 2414e3680dSDmitri Tikhonov/* Instead of just -1 like CHECK_SPACE(), this macro returns the number 2514e3680dSDmitri Tikhonov * of bytes needed. 2614e3680dSDmitri Tikhonov */ 2714e3680dSDmitri Tikhonov#define CHECK_STREAM_SPACE(need, pstart, pend) do { \ 2814e3680dSDmitri Tikhonov if ((intptr_t) (need) > ((pend) - (pstart))) { \ 2914e3680dSDmitri Tikhonov return -((int) (need)); \ 3014e3680dSDmitri Tikhonov } \ 3114e3680dSDmitri Tikhonov} while (0) 3214e3680dSDmitri Tikhonov 339626cfc2SDmitri Tikhonov#endif 34