import { decode , encode , types } from "binary-data" ; import { ProtocolVersion } from "../../handshake/binary" ; export class DtlsPlaintextHeader { static readonly spec = { contentType : types . uint8 , protocolVersion : ProtocolVersion , epoch : types . uint16be , sequenceNumber : types . uint48be , contentLen : types . uint16be , } ; constructor ( public contentType , public protocolVersion , public epoch , public sequenceNumber , public contentLen ) { } static createEmpty ( ) { return new DtlsPlaintextHeader ( undefined as any , undefined as any , undefined as any , undefined as any , undefined as any ) ; } static deSerialize ( buf ) { return new DtlsPlaintextHeader ( ... Object . values ( decode ( buf , DtlsPlaintextHeader . spec ) ) ) ; } serialize ( ) { const res = encode ( this , DtlsPlaintextHeader . spec ) . slice ( ) ; return Buffer . from ( res ) ; } } export class MACHeader { static readonly spec = { epoch : types . uint16be , sequenceNumber : types . uint48be , contentType : types . uint8 , protocolVersion : ProtocolVersion , contentLen : types . uint16be , } ; constructor ( public epoch , public sequenceNumber , public contentType , public protocolVersion , public contentLen ) { } static createEmpty ( ) { return new MACHeader ( undefined as any , undefined as any , undefined as any , undefined as any , undefined as any ) ; } static deSerialize ( buf ) { return new MACHeader ( ... Object . values ( decode ( buf , MACHeader . spec ) ) ) ; } serialize ( ) { const res = encode ( this , MACHeader . spec ) . slice ( ) ; return Buffer . from ( res ) ; } }