<commit_before>package ipmi

import (
	"net"
	"bytes"
	"encoding/binary"
	"log"
	"github.com/rmxymh/infra-ecosphere/bmc"
	"github.com/rmxymh/infra-ecosphere/utils"
	"github.com/rmxymh/infra-ecosphere/vm"
)

const (
	BOOT_SET_IN_PROGRESS = 			0
	BOOT_SERVICE_PARTITION_SELECTOR = 	1
	BOOT_SERVICE_PARTITION_SCAN = 		2
	BOOT_BMC_BOOT_FLAG_VALID_BIT_CLEARING =	3
	BOOT_INFO_ACK =				4
	BOOT_FLAG =				5
	BOOT_INITIATOR_INFO =			6
	BOOT_INITIATOR_MAILBOX =		7
)

type IPMI_Chassis_BootOpt_Handler func(addr *net.UDPAddr, server *net.UDPConn, wrapper IPMISessionWrapper, message IPMIMessage, selector IPMIChassisBootOptionParameterSelector)

type IPMIChassisBootOptHandlerSet struct {
	SetInProgressHandler			IPMI_Chassis_BootOpt_Handler
	ServicePartitionSelectorHandler		IPMI_Chassis_BootOpt_Handler
	ServicePartitionScanHandler		IPMI_Chassis_BootOpt_Handler
	BMCBootFlagValidBitClearingHandler	IPMI_Chassis_BootOpt_Handler
	BootInfoAcknowledgementHandler		IPMI_Chassis_BootOpt_Handler
	BootFlagHandler				IPMI_Chassis_BootOpt_Handler
	BootInitiatorInfoHandler		IPMI_Chassis_BootOpt_Handler
	BootInitiatorMailbox			IPMI_Chassis_BootOpt_Handler
	Unsupported				IPMI_Chassis_BootOpt_Handler
}

var IPMIChassisBootOptHandler IPMIChassisBootOptHandlerSet = IPMIChassisBootOptHandlerSet{}

func IPMI_CHASSIS_BOOT_OPTION_SetHandler(command int, handler IPMI_Chassis_BootOpt_Handler) {
	switch command {
	case BOOT_SET_IN_PROGRESS:
		IPMIChassisBootOptHandler.SetInProgressHandler = handler
	case BOOT_SERVICE_PARTITION_SELECTOR:
		IPMIChassisBootOptHandler.ServicePartitionSelectorHandler = handler
	case BOOT_SERVICE_PARTITION_SCAN:
		IPMIChassisBootOptHandler.ServicePartitionScanHandler = handler
	case BOOT_BMC_BOOT_FLAG_VALID_BIT_CLEARING:
		IPMIChassisBootOptHandler.BMCBootFlagValidBitClearingHandler = handler
	case BOOT_INFO_ACK:
		IPMIChassisBootOptHandler.BootInfoAcknowledgementHandler = handler
	case BOOT_FLAG:
		IPMIChassisBootOptHandler.BootFlagHandler = handler
	case BOOT_INITIATOR_INFO:
		IPMIChassisBootOptHandler.BootInitiatorInfoHandler = handler
	case BOOT_INITIATOR_MAILBOX:
		IPMIChassisBootOptHandler.BootInitiatorMailbox = handler
	}
}

func init() {
	IPMIChassisBootOptHandler.Unsupported = HandleIPMIChassisBootOptionNotSupport

	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_SET_IN_PROGRESS, HandleIPMIChassisBootOptionSetInProgress)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_INFO_ACK, HandleIPMIChassisBootOptionBootInfoAck)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_FLAG, HandleIPMIChassisBootOptionBootFlags)

	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_SERVICE_PARTITION_SELECTOR, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_SERVICE_PARTITION_SCAN, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_BMC_BOOT_FLAG_VALID_BIT_CLEARING, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_INITIATOR_INFO, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_INITIATOR_MAILBOX, HandleIPMIChassisBootOptionNotSupport)
}<commit_msg>Use pointer as global variable.<commit_after>package ipmi

import (
	"net"
	"bytes"
	"encoding/binary"
	"log"
	"github.com/rmxymh/infra-ecosphere/bmc"
	"github.com/rmxymh/infra-ecosphere/utils"
	"github.com/rmxymh/infra-ecosphere/vm"
)

const (
	BOOT_SET_IN_PROGRESS = 			0
	BOOT_SERVICE_PARTITION_SELECTOR = 	1
	BOOT_SERVICE_PARTITION_SCAN = 		2
	BOOT_BMC_BOOT_FLAG_VALID_BIT_CLEARING =	3
	BOOT_INFO_ACK =				4
	BOOT_FLAG =				5
	BOOT_INITIATOR_INFO =			6
	BOOT_INITIATOR_MAILBOX =		7
)

type IPMI_Chassis_BootOpt_Handler func(addr *net.UDPAddr, server *net.UDPConn, wrapper IPMISessionWrapper, message IPMIMessage, selector IPMIChassisBootOptionParameterSelector)

type IPMIChassisBootOptHandlerSet struct {
	SetInProgressHandler			IPMI_Chassis_BootOpt_Handler
	ServicePartitionSelectorHandler		IPMI_Chassis_BootOpt_Handler
	ServicePartitionScanHandler		IPMI_Chassis_BootOpt_Handler
	BMCBootFlagValidBitClearingHandler	IPMI_Chassis_BootOpt_Handler
	BootInfoAcknowledgementHandler		IPMI_Chassis_BootOpt_Handler
	BootFlagHandler				IPMI_Chassis_BootOpt_Handler
	BootInitiatorInfoHandler		IPMI_Chassis_BootOpt_Handler
	BootInitiatorMailbox			IPMI_Chassis_BootOpt_Handler
	Unsupported				IPMI_Chassis_BootOpt_Handler
}

var IPMIChassisBootOptHandler *IPMIChassisBootOptHandlerSet

func IPMI_CHASSIS_BOOT_OPTION_SetHandler(command int, handler IPMI_Chassis_BootOpt_Handler) {
	switch command {
	case BOOT_SET_IN_PROGRESS:
		IPMIChassisBootOptHandler.SetInProgressHandler = handler
	case BOOT_SERVICE_PARTITION_SELECTOR:
		IPMIChassisBootOptHandler.ServicePartitionSelectorHandler = handler
	case BOOT_SERVICE_PARTITION_SCAN:
		IPMIChassisBootOptHandler.ServicePartitionScanHandler = handler
	case BOOT_BMC_BOOT_FLAG_VALID_BIT_CLEARING:
		IPMIChassisBootOptHandler.BMCBootFlagValidBitClearingHandler = handler
	case BOOT_INFO_ACK:
		IPMIChassisBootOptHandler.BootInfoAcknowledgementHandler = handler
	case BOOT_FLAG:
		IPMIChassisBootOptHandler.BootFlagHandler = handler
	case BOOT_INITIATOR_INFO:
		IPMIChassisBootOptHandler.BootInitiatorInfoHandler = handler
	case BOOT_INITIATOR_MAILBOX:
		IPMIChassisBootOptHandler.BootInitiatorMailbox = handler
	}
}

func init() {
	handlers := IPMIChassisBootOptHandlerSet{}
	
	IPMIChassisBootOptHandler = &handlers
	IPMIChassisBootOptHandler.Unsupported = HandleIPMIChassisBootOptionNotSupport

	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_SET_IN_PROGRESS, HandleIPMIChassisBootOptionSetInProgress)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_INFO_ACK, HandleIPMIChassisBootOptionBootInfoAck)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_FLAG, HandleIPMIChassisBootOptionBootFlags)

	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_SERVICE_PARTITION_SELECTOR, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_SERVICE_PARTITION_SCAN, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_BMC_BOOT_FLAG_VALID_BIT_CLEARING, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_INITIATOR_INFO, HandleIPMIChassisBootOptionNotSupport)
	IPMI_CHASSIS_BOOT_OPTION_SetHandler(BOOT_INITIATOR_MAILBOX, HandleIPMIChassisBootOptionNotSupport)
}
{'fraction_non_alphanumeric': 0.03980660757453666, 'fraction_numerical': 0.0025785656728444803, 'mean_word_length': 9.964664310954063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1978176', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2269, 'n_words': 253}