reservereleasearg.go
func (r *ReserveReleaseArg) MarshalBinary() ([]byte, error) {
	// Must indicate correct number of hardware addresses
	if int(r.NMACs) != len(r.MACs) {
		return nil, ErrorBadArgumentParameter
	}

	// Allocate byte slice for argument and hardware addresses
	b := make([]byte, reserveReleaseArgLen+(r.NMACs*6))

	b[0] = uint8(r.Command)
	b[1] = uint8(r.NMACs)

	// Copy each hardware address into byte slice, after verifying exactly
	// 6 bytes in length
	n := 2
	for _, m := range r.MACs {
		if len(m) != 6 {
			return nil, ErrorBadArgumentParameter
		}

		copy(b[n:n+6], m)
		n += 6
	}

	return b, nil
}
func (r *ReserveReleaseArg) MarshalBinary() ([]byte, error) {
	// Must indicate correct number of hardware addresses
	if int(r.NMACs) != len(r.MACs) {
		return nil, ErrorBadArgumentParameter
	}

	// Allocate byte slice for argument and hardware addresses
	b := make([]byte, reserveReleaseArgLen+(r.NMACs*6))

	b[0] = uint8(r.Command)
	b[1] = uint8(r.NMACs)

	// Copy each hardware address into byte slice, after verifying exactly
	// 6 bytes in length
	n := 2
	for _, m := range r.MACs {
		if len(m) != 6 {
			return nil, ErrorBadArgumentParameter
		}

		copy(b[n:n+6], m)
		n += 6
	}

	return b, nil
}
func ( r * ReserveReleaseArg ) MarshalBinary ( ) ( [ ] byte , error ) { // Must indicate correct number of hardware addresses if int ( r . NMACs ) != len ( r . MACs ) { return nil , ErrorBadArgumentParameter } // Allocate byte slice for argument and hardware addresses b := make ( [ ] byte , reserveReleaseArgLen + ( r . NMACs * 6 ) ) b [ 0 ] = uint8 ( r . Command ) b [ 1 ] = uint8 ( r . NMACs ) // Copy each hardware address into byte slice, after verifying exactly // 6 bytes in length n := 2 for _ , m := range r . MACs { if len ( m ) != 6 { return nil , ErrorBadArgumentParameter } copy ( b [ n : n + 6 ] , m ) n += 6 } return b , nil }
// MarshalBinary allocates a byte slice containing the data from a
// ReserveReleaseArg.
//
// If r.NMACs does not indicate the actual length of r.MACs, or one or more
// hardware addresses are not exactly 6 bytes in length,
// ErrorBadArgumentParameter is returned.
MarshalBinary allocates a byte slice containing the data from a ReserveReleaseArg . If r . NMACs does not indicate the actual length of r . MACs or one or more hardware addresses are not exactly 6 bytes in length ErrorBadArgumentParameter is returned .