// Len returns the length of the Message in bytes. func (m *Message) Len() int { l := HeaderLength for _, avp := range m.AVP { l += avp.Len() } return l }
// SerializeTo writes the serialized bytes of the Message into b. func (m *Message) SerializeTo(b []byte) (err error) { m.Header.SerializeTo(b[0:HeaderLength]) offset := HeaderLength for _, avp := range m.AVP { if err = avp.SerializeTo(b[offset:]); err != nil { return err } offset += avp.Len() } return nil }