macmaskarg.go
func (m *MACMaskArg) UnmarshalBinary(b []byte) error {
	// Must contain minimum length for argument
	if len(b) < macMaskArgLen {
		return io.ErrUnexpectedEOF
	}

	// 1 byte reserved
	if b[0] != 0 {
		return ErrorBadArgumentParameter
	}

	m.Command = MACMaskCommand(b[1])
	m.Error = MACMaskError(b[2])
	m.DirCount = b[3]

	// Must have at least enough bytes for directives with this count
	if len(b[4:]) < (directiveLen * int(m.DirCount)) {
		return io.ErrUnexpectedEOF
	}

	// Unmarshal each directive bytes and add to slice
	m.Directives = make([]*Directive, m.DirCount)
	for i := 0; i < int(m.DirCount); i++ {
		d := new(Directive)
		if err := d.UnmarshalBinary(b[4+(i*directiveLen) : 4+(i*directiveLen)+directiveLen]); err != nil {
			return err
		}
		m.Directives[i] = d
	}

	return nil
}
func (m *MACMaskArg) UnmarshalBinary(b []byte) error {
	// Must contain minimum length for argument
	if len(b) < macMaskArgLen {
		return io.ErrUnexpectedEOF
	}

	// 1 byte reserved
	if b[0] != 0 {
		return ErrorBadArgumentParameter
	}

	m.Command = MACMaskCommand(b[1])
	m.Error = MACMaskError(b[2])
	m.DirCount = b[3]

	// Must have at least enough bytes for directives with this count
	if len(b[4:]) < (directiveLen * int(m.DirCount)) {
		return io.ErrUnexpectedEOF
	}

	// Unmarshal each directive bytes and add to slice
	m.Directives = make([]*Directive, m.DirCount)
	for i := 0; i < int(m.DirCount); i++ {
		d := new(Directive)
		if err := d.UnmarshalBinary(b[4+(i*directiveLen) : 4+(i*directiveLen)+directiveLen]); err != nil {
			return err
		}
		m.Directives[i] = d
	}

	return nil
}
func ( m * MACMaskArg ) UnmarshalBinary ( b [ ] byte ) error { // Must contain minimum length for argument if len ( b ) < macMaskArgLen { return io . ErrUnexpectedEOF } // 1 byte reserved if b [ 0 ] != 0 { return ErrorBadArgumentParameter } m . Command = MACMaskCommand ( b [ 1 ] ) m . Error = MACMaskError ( b [ 2 ] ) m . DirCount = b [ 3 ] // Must have at least enough bytes for directives with this count if len ( b [ 4 : ] ) < ( directiveLen * int ( m . DirCount ) ) { return io . ErrUnexpectedEOF } // Unmarshal each directive bytes and add to slice m . Directives = make ( [ ] * Directive , m . DirCount ) for i := 0 ; i < int ( m . DirCount ) ; i ++ { d := new ( Directive ) if err := d . UnmarshalBinary ( b [ 4 + ( i * directiveLen ) : 4 + ( i * directiveLen ) + directiveLen ] ) ; err != nil { return err } m . Directives [ i ] = d } return nil }
// UnmarshalBinary unmarshals a byte slice into a MACMaskArg.
//
// If the byte slice does not contain enough bytes to form a valid MACMaskArg,
// or a Directive is malformed, io.ErrUnexpectedEOF is returned.
//
// If byte 0 (reserved byte) is not empty, ErrorBadArgumentParameter is
// returned.
UnmarshalBinary unmarshals a byte slice into a MACMaskArg . If the byte slice does not contain enough bytes to form a valid MACMaskArg or a Directive is malformed io . ErrUnexpectedEOF is returned . If byte 0 ( reserved byte ) is not empty ErrorBadArgumentParameter is returned .