lsquic_parse_common.c revision 9626cfc2
1/* Copyright (c) 2017 - 2018 LiteSpeed Technologies Inc. See LICENSE. */ 2#include <string.h> 3#include <sys/queue.h> 4#include <sys/types.h> 5 6#include "lsquic_types.h" 7#include "lsquic_int_types.h" 8#include "lsquic_packet_common.h" 9#include "lsquic_packet_in.h" 10#include "lsquic_parse_common.h" 11#include "lsquic_parse.h" 12 13 14int 15lsquic_parse_packet_in_begin (lsquic_packet_in_t *packet_in, size_t length, 16 int is_server, struct packin_parse_state *state) 17{ 18 if (length > 0) 19 { 20 switch (packet_in->pi_data[0] & 0x88) 21 { 22 case 0x88: 23 case 0x80: 24 return lsquic_iquic_parse_packet_in_long_begin(packet_in, length, 25 is_server, state); 26 case 0x08: 27 return lsquic_gquic_parse_packet_in_begin(packet_in, length, 28 is_server, state); 29 default: 30 return lsquic_iquic_parse_packet_in_short_begin(packet_in, length, 31 is_server, state); 32 } 33 } 34 else 35 return -1; 36} 37 38 39int 40lsquic_iquic_parse_packet_in_begin (struct lsquic_packet_in *packet_in, 41 size_t length, int is_server, struct packin_parse_state *state) 42{ 43 if (length > 0) 44 { 45 if (0 == (packet_in->pi_data[0] & 0x80)) 46 return lsquic_iquic_parse_packet_in_short_begin(packet_in, length, 47 is_server, state); 48 else 49 return lsquic_iquic_parse_packet_in_long_begin(packet_in, length, 50 is_server, state); 51 } 52 else 53 return -1; 54} 55 56 57