lsquic_parse_common.c revision 229fce07
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE. */ 29626cfc2SDmitri Tikhonov#include <string.h> 39626cfc2SDmitri Tikhonov#include <sys/queue.h> 49626cfc2SDmitri Tikhonov#include <sys/types.h> 59626cfc2SDmitri Tikhonov 69626cfc2SDmitri Tikhonov#include "lsquic_types.h" 79626cfc2SDmitri Tikhonov#include "lsquic_int_types.h" 89626cfc2SDmitri Tikhonov#include "lsquic_packet_common.h" 99626cfc2SDmitri Tikhonov#include "lsquic_packet_in.h" 109626cfc2SDmitri Tikhonov#include "lsquic_parse_common.h" 119626cfc2SDmitri Tikhonov#include "lsquic_parse.h" 129626cfc2SDmitri Tikhonov 139626cfc2SDmitri Tikhonov 149626cfc2SDmitri Tikhonovint 159626cfc2SDmitri Tikhonovlsquic_parse_packet_in_begin (lsquic_packet_in_t *packet_in, size_t length, 169626cfc2SDmitri Tikhonov int is_server, struct packin_parse_state *state) 179626cfc2SDmitri Tikhonov{ 189626cfc2SDmitri Tikhonov if (length > 0) 199626cfc2SDmitri Tikhonov { 209626cfc2SDmitri Tikhonov switch (packet_in->pi_data[0] & 0x88) 219626cfc2SDmitri Tikhonov { 229626cfc2SDmitri Tikhonov case 0x88: 239626cfc2SDmitri Tikhonov case 0x80: 249626cfc2SDmitri Tikhonov return lsquic_iquic_parse_packet_in_long_begin(packet_in, length, 259626cfc2SDmitri Tikhonov is_server, state); 269626cfc2SDmitri Tikhonov case 0x08: 279626cfc2SDmitri Tikhonov return lsquic_gquic_parse_packet_in_begin(packet_in, length, 289626cfc2SDmitri Tikhonov is_server, state); 299626cfc2SDmitri Tikhonov default: 309626cfc2SDmitri Tikhonov return lsquic_iquic_parse_packet_in_short_begin(packet_in, length, 319626cfc2SDmitri Tikhonov is_server, state); 329626cfc2SDmitri Tikhonov } 339626cfc2SDmitri Tikhonov } 349626cfc2SDmitri Tikhonov else 359626cfc2SDmitri Tikhonov return -1; 369626cfc2SDmitri Tikhonov} 379626cfc2SDmitri Tikhonov 389626cfc2SDmitri Tikhonov 399626cfc2SDmitri Tikhonovint 409626cfc2SDmitri Tikhonovlsquic_iquic_parse_packet_in_begin (struct lsquic_packet_in *packet_in, 419626cfc2SDmitri Tikhonov size_t length, int is_server, struct packin_parse_state *state) 429626cfc2SDmitri Tikhonov{ 439626cfc2SDmitri Tikhonov if (length > 0) 449626cfc2SDmitri Tikhonov { 459626cfc2SDmitri Tikhonov if (0 == (packet_in->pi_data[0] & 0x80)) 469626cfc2SDmitri Tikhonov return lsquic_iquic_parse_packet_in_short_begin(packet_in, length, 479626cfc2SDmitri Tikhonov is_server, state); 489626cfc2SDmitri Tikhonov else 499626cfc2SDmitri Tikhonov return lsquic_iquic_parse_packet_in_long_begin(packet_in, length, 509626cfc2SDmitri Tikhonov is_server, state); 519626cfc2SDmitri Tikhonov } 529626cfc2SDmitri Tikhonov else 539626cfc2SDmitri Tikhonov return -1; 549626cfc2SDmitri Tikhonov} 559626cfc2SDmitri Tikhonov 569626cfc2SDmitri Tikhonov 57