lsquic_packet_in.c revision 50aadb33
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov#include <assert.h> 350aadb33SDmitri Tikhonov#include <stdint.h> 450aadb33SDmitri Tikhonov#include <string.h> 550aadb33SDmitri Tikhonov 650aadb33SDmitri Tikhonov#include "lsquic_int_types.h" 750aadb33SDmitri Tikhonov#include "lsquic_types.h" 850aadb33SDmitri Tikhonov#include "lsquic_packet_in.h" 950aadb33SDmitri Tikhonov 1050aadb33SDmitri Tikhonov 1150aadb33SDmitri Tikhonovint 1250aadb33SDmitri Tikhonovpacket_in_ver_first (const lsquic_packet_in_t *packet_in, struct ver_iter *vi, 1350aadb33SDmitri Tikhonov lsquic_ver_tag_t *ver_tag) 1450aadb33SDmitri Tikhonov{ 1550aadb33SDmitri Tikhonov vi->packet_in = packet_in; 1650aadb33SDmitri Tikhonov vi->off = packet_in->pi_quic_ver; 1750aadb33SDmitri Tikhonov return packet_in_ver_next(vi, ver_tag); 1850aadb33SDmitri Tikhonov} 1950aadb33SDmitri Tikhonov 2050aadb33SDmitri Tikhonov 2150aadb33SDmitri Tikhonovint 2250aadb33SDmitri Tikhonovpacket_in_ver_next (struct ver_iter *vi, lsquic_ver_tag_t *ver_tag) 2350aadb33SDmitri Tikhonov{ 2450aadb33SDmitri Tikhonov if (vi->off + 4 <= vi->packet_in->pi_header_sz) 2550aadb33SDmitri Tikhonov { 2650aadb33SDmitri Tikhonov memcpy(ver_tag, vi->packet_in->pi_data + vi->off, 4); 2750aadb33SDmitri Tikhonov vi->off += 4; 2850aadb33SDmitri Tikhonov return 1; 2950aadb33SDmitri Tikhonov } 3050aadb33SDmitri Tikhonov else 3150aadb33SDmitri Tikhonov { 3250aadb33SDmitri Tikhonov assert(vi->packet_in->pi_header_sz == vi->off); 3350aadb33SDmitri Tikhonov return 0; 3450aadb33SDmitri Tikhonov } 3550aadb33SDmitri Tikhonov} 36