lsquic_parse_common.c revision c7d81ce1
1/* Copyright (c) 2017 - 2019 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] & 0xC8) 21 { 22 case 0x88: 23 case 0x80: 24 case 0xC8: 25 case 0xC0: 26 return lsquic_iquic_parse_packet_in_long_begin(packet_in, length, 27 is_server, state); 28 case 0x08: 29 return lsquic_gquic_parse_packet_in_begin(packet_in, length, 30 is_server, state); 31 default: 32 return lsquic_iquic_parse_packet_in_short_begin(packet_in, length, 33 is_server, state); 34 } 35 } 36 else 37 return -1; 38} 39 40 41int 42lsquic_iquic_parse_packet_in_begin (struct lsquic_packet_in *packet_in, 43 size_t length, int is_server, struct packin_parse_state *state) 44{ 45 if (length > 0) 46 { 47 if (0 == (packet_in->pi_data[0] & 0x80)) 48 return lsquic_iquic_parse_packet_in_short_begin(packet_in, length, 49 is_server, state); 50 else 51 return lsquic_iquic_parse_packet_in_long_begin(packet_in, length, 52 is_server, state); 53 } 54 else 55 return -1; 56} 57 58 59