blob: dedd1d587b7038f038ea01cd1ddb8954d17764ee [file] [log] [blame]
Takahiro Suzukid7bf8202020-12-17 20:21:59 +09001// Copyright 2018 The GoPacket Authors. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style license
4// that can be found in the LICENSE file in the root of the source
5// tree.
6
7package layers
8
9import (
10 "errors"
11
12 "github.com/google/gopacket"
13)
14
15// TLSAppDataRecord contains all the information that each AppData Record types should have
16type TLSAppDataRecord struct {
17 TLSRecordHeader
18 Payload []byte
19}
20
21// DecodeFromBytes decodes the slice into the TLS struct.
22func (t *TLSAppDataRecord) decodeFromBytes(h TLSRecordHeader, data []byte, df gopacket.DecodeFeedback) error {
23 // TLS Record Header
24 t.ContentType = h.ContentType
25 t.Version = h.Version
26 t.Length = h.Length
27
28 if len(data) != int(t.Length) {
29 return errors.New("TLS Application Data length mismatch")
30 }
31
32 t.Payload = data
33 return nil
34}