func (h *Header) String() string {
	return fmt.Sprintf("{Version: %d, Flags: {FO: %t, MP: %t, S: %t}, Type: %d, Length: %d, SEID: %#016x, SequenceNumber: %#x, MessagePriority: %d, Payload: %#x}",
		h.Version(),
		h.HasFO(), h.HasMP(), h.HasSEID(),
		h.Type,
		h.Length,
		h.SEID,
		h.SequenceNumber,
		h.MessagePriority,
		h.Payload,
	)
}
String returns the GTPv2 header values in human readable format.
package message
import (
	"encoding/binary"
	"fmt"
	"io"
)
type Header struct {
	Flags           uint8  
	Type            uint8
	Length          uint16
	SEID            uint64
	SequenceNumber  uint32  
	MessagePriority uint8   
	Payload         []byte
}
func NewHeader(ver, fo, mp, s, mtype uint8, seid uint64, seq uint32, pri uint8, payload []byte) *Header {
	h := &Header{
		Flags:           ((ver & 0x7) << 5) | (fo << 2) | (mp << 1) | s,
		Type:            mtype,
		SEID:            seid,
		SequenceNumber:  seq,
		MessagePriority: pri,
		Payload:         payload,
	}
	h.SetLength()
	return h
}
func NewHeaderNodeRelated(ver, mtype uint8, seq uint32, payload []byte) *Header {
	return NewHeader(ver, 0, 0, 0, mtype, 0, seq, 0, payload)
}
func NewHeaderSessionRelated(ver, fo, mp, s, mtype uint8, seid uint64, seq uint32, pri uint8, payload []byte) *Header {
	return NewHeader(ver, fo, mp, s, mtype, seid, seq, pri, payload)
}
func (h *Header) HasFO() bool {
	return has3rdBit(h.Flags)
}
func (h *Header) HasMP() bool {
	return has2ndBit(h.Flags)
}
func (h *Header) HasSEID() bool {
	return has1stBit(h.Flags)
}
func (h *Header) Marshal() ([]byte, error) {
	b := make([]byte, h.MarshalLen())
	if err := h.MarshalTo(b); err != nil {
		return nil, err
	}
	return b, nil
}
func (h *Header) MarshalTo(b []byte) error {
	b[0] = h.Flags
	b[1] = h.Type
	binary.BigEndian.PutUint16(b[2:4], h.Length)
	offset := 4
	if h.HasSEID() {
		binary.BigEndian.PutUint64(b[offset:offset+8], h.SEID)
		offset += 8
	}
	copy(b[offset:offset+3], uint32To24(h.SequenceNumber))
	b[offset+3] = h.MessagePriority
	copy(b[offset+4:h.MarshalLen()], h.Payload)
	return nil
}
func ParseHeader(b []byte) (*Header, error) {
	h := &Header{}
	if err := h.UnmarshalBinary(b); err != nil {
		return nil, err
	}
	return h, nil
}
func (h *Header) UnmarshalBinary(b []byte) error {
	l := len(b)
	if l < 8 {
		return io.ErrUnexpectedEOF
	}
	h.Flags = b[0]
	h.Type = b[1]
	h.Length = binary.BigEndian.Uint16(b[2:4])
	offset := 4
	if h.HasSEID() {
		if l < offset+8 {
			return io.ErrUnexpectedEOF
		}
		h.SEID = binary.BigEndian.Uint64(b[offset : offset+8])
		offset += 8
	}
	if l < offset+4 {
		return io.ErrUnexpectedEOF
	}
	h.SequenceNumber = uint24To32(b[offset : offset+3])
	h.MessagePriority = b[offset+3]
	offset += 4
	if int(h.Length)+offset != l {
		h.Payload = b[offset:]
		return nil
	}
	if l < offset+int(h.Length) {
		return io.ErrUnexpectedEOF
	}
	h.Payload = b[offset : offset+int(h.Length)]
	return nil
}
func (h *Header) MarshalLen() int {
	l := 8 + len(h.Payload)
	if h.HasSEID() {
		l += 8
	}
	return l
}
func (h *Header) SetLength() {
	h.Length = uint16(4 + len(h.Payload))
	if h.HasSEID() {
		h.Length += 8
	}
}
func (h *Header) Version() int {
	return 1
}
func (h *Header) MessageType() uint8 {
	return h.Type
}
func (h *Header) seid() uint64 {
	if !h.HasSEID() {
		return 0
	}
	return h.SEID
}
func (h *Header) SetSEID(seid uint64) {
	h.Flags |= 0x01
	h.SEID = seid
}
func (h *Header) Sequence() uint32 {
	return h.SequenceNumber
}
func (h *Header) SetSequenceNumber(seq uint32) {
	h.SequenceNumber = seq
}
func (h *Header) SetMP(mp uint8) {
	h.Flags |= (1 << 2)
	h.MessagePriority = (mp << 4) & 0xf0
}
func (h *Header) MP() uint8 {
	return (h.MessagePriority & 0xf0) >> 4
}