func (f *RedirectInformationFields) MarshalTo(b []byte) error {
	l := len(b)
	if l < 1 {
		return io.ErrUnexpectedEOF
	}
	b[0] = f.RedirectAddressType
	offset := 1
	if l < offset+int(f.ServerAddrLength) {
		return io.ErrUnexpectedEOF
	}
	binary.BigEndian.PutUint16(b[1:3], f.ServerAddrLength)
	offset += 2
	copy(b[offset:offset+int(f.ServerAddrLength)], f.RedirectServerAddress)
	offset += int(f.ServerAddrLength)
	if f.OtherRedirectServerAddress == "" {
		binary.BigEndian.PutUint16(b[offset:offset+2], f.OtherServerAddrLength)
		return nil
	}
	if l < offset+int(f.OtherServerAddrLength) {
		return io.ErrUnexpectedEOF
	}
	binary.BigEndian.PutUint16(b[offset:offset+2], f.OtherServerAddrLength)
	offset += 2
	copy(b[offset:offset+int(f.OtherServerAddrLength)], f.OtherRedirectServerAddress)
	return nil
}
MarshalTo puts the byte sequence in the byte array given as b.
package ie
import (
	"encoding/binary"
	"io"
)
func NewRedirectInformation(addrType uint8, addrs ...string) *IE {
	fields := NewRedirectInformationFields(addrType, addrs...)
	b, err := fields.Marshal()
	if err != nil {
		return nil
	}
	return New(RedirectInformation, b)
}
func (i *IE) RedirectInformation() (*RedirectInformationFields, error) {
	switch i.Type {
	case RedirectInformation:
		f, err := ParseRedirectInformationFields(i.Payload)
		if err != nil {
			return nil, err
		}
		return f, nil
	case ForwardingParameters:
		ies, err := i.ForwardingParameters()
		if err != nil {
			return nil, err
		}
		for _, x := range ies {
			if x.Type == RedirectInformation {
				return x.RedirectInformation()
			}
		}
		return nil, ErrIENotFound
	case UpdateForwardingParameters:
		ies, err := i.UpdateForwardingParameters()
		if err != nil {
			return nil, err
		}
		for _, x := range ies {
			if x.Type == RedirectInformation {
				return x.RedirectInformation()
			}
		}
		return nil, ErrIENotFound
	default:
		return nil, &InvalidTypeError{Type: i.Type}
	}
}
const (
	RedirectAddrIPv4        uint8 = 0
	RedirectAddrIPv6        uint8 = 1
	RedirectAddrURL         uint8 = 2
	RedirectAddrSIPURI      uint8 = 3
	RedirectAddrIPv4AndIPv6 uint8 = 4
)
type RedirectInformationFields struct {
	RedirectAddressType        uint8  
	ServerAddrLength           uint16
	RedirectServerAddress      string
	OtherServerAddrLength      uint16
	OtherRedirectServerAddress string
}
func NewRedirectInformationFields(addrType uint8, addrs ...string) *RedirectInformationFields {
	if len(addrs) < 1 {
		return nil
	}
	f := &RedirectInformationFields{
		RedirectAddressType:   addrType,
		ServerAddrLength:      uint16(len(addrs[0])),
		RedirectServerAddress: addrs[0],
	}
	if len(addrs) >= 2 {
		f.OtherServerAddrLength = uint16(len(addrs[1]))
		f.OtherRedirectServerAddress = addrs[1]
	}
	return f
}
func ParseRedirectInformationFields(b []byte) (*RedirectInformationFields, error) {
	f := &RedirectInformationFields{}
	if err := f.UnmarshalBinary(b); err != nil {
		return nil, err
	}
	return f, nil
}
func (f *RedirectInformationFields) UnmarshalBinary(b []byte) error {
	l := len(b)
	if l < 3 {
		return io.ErrUnexpectedEOF
	}
	f.RedirectAddressType = b[0]
	offset := 1
	f.ServerAddrLength = binary.BigEndian.Uint16(b[offset : offset+2])
	offset += 2
	if l < offset+int(f.ServerAddrLength) {
		return io.ErrUnexpectedEOF
	}
	f.RedirectServerAddress = string(b[offset : offset+int(f.ServerAddrLength)])
	f.OtherServerAddrLength = binary.BigEndian.Uint16(b[1:3])
	if f.OtherServerAddrLength != 0 {
		offset += 2
		if l < offset+int(f.OtherServerAddrLength) {
			return io.ErrUnexpectedEOF
		}
		f.OtherRedirectServerAddress = string(b[offset : offset+int(f.OtherServerAddrLength)])
	}
	return nil
}
func (f *RedirectInformationFields) Marshal() ([]byte, error) {
	b := make([]byte, f.MarshalLen())
	if err := f.MarshalTo(b); err != nil {
		return nil, err
	}
	return b, nil
}