func (f *AlternativeSMFIPAddressFields) UnmarshalBinary(b []byte) error {
	l := len(b)
	if l < 2 {
		return io.ErrUnexpectedEOF
	}
	f.Flags = b[0]
	offset := 1
	if f.HasIPv4() {
		if l < offset+4 {
			return io.ErrUnexpectedEOF
		}
		f.IPv4Address = net.IP(b[offset : offset+4])
		offset += 4
	}
	if f.HasIPv6() {
		if l < offset+16 {
			return io.ErrUnexpectedEOF
		}
		f.IPv6Address = net.IP(b[offset : offset+16])
	}
	return nil
}
UnmarshalBinary parses b into IE.
package ie
import (
	"io"
	"net"
)
func NewAlternativeSMFIPAddress(v4, v6 net.IP) *IE {
	fields := NewAlternativeSMFIPAddressFields(v4, v6)
	b, err := fields.Marshal()
	if err != nil {
		return nil
	}
	return New(AlternativeSMFIPAddress, b)
}
func (i *IE) AlternativeSMFIPAddress() (*AlternativeSMFIPAddressFields, error) {
	if i.Type != AlternativeSMFIPAddress {
		return nil, &InvalidTypeError{Type: i.Type}
	}
	fields, err := ParseAlternativeSMFIPAddressFields(i.Payload)
	if err != nil {
		return nil, err
	}
	return fields, nil
}
type AlternativeSMFIPAddressFields struct {
	Flags       uint8
	TEID        uint32
	IPv4Address net.IP
	IPv6Address net.IP
	ChooseID    []byte
}
func NewAlternativeSMFIPAddressFields(v4, v6 net.IP) *AlternativeSMFIPAddressFields {
	f := &AlternativeSMFIPAddressFields{}
	if v4 != nil {
		f.IPv4Address = v4
		f.SetIPv4Flag()
	}
	if v6 != nil {
		f.IPv6Address = v6
		f.SetIPv6Flag()
	}
	return f
}
func (f *AlternativeSMFIPAddressFields) HasIPv4() bool {
	return has2ndBit(f.Flags)
}
func (f *AlternativeSMFIPAddressFields) SetIPv4Flag() {
	f.Flags |= 0x02
}
func (f *AlternativeSMFIPAddressFields) HasIPv6() bool {
	return has1stBit(f.Flags)
}
func (f *AlternativeSMFIPAddressFields) SetIPv6Flag() {
	f.Flags |= 0x01
}
func ParseAlternativeSMFIPAddressFields(b []byte) (*AlternativeSMFIPAddressFields, error) {
	f := &AlternativeSMFIPAddressFields{}
	if err := f.UnmarshalBinary(b); err != nil {
		return nil, err
	}
	return f, nil
}