github.com/gopacket/gopacket@v1.1.0/layers/tls_appdata.go (about) 1 // 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 7 package layers 8 9 import ( 10 "errors" 11 12 "github.com/gopacket/gopacket" 13 ) 14 15 // TLSAppDataRecord contains all the information that each AppData Record types should have 16 type TLSAppDataRecord struct { 17 TLSRecordHeader 18 Payload []byte 19 } 20 21 // DecodeFromBytes decodes the slice into the TLS struct. 22 func (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 }