Documentation
¶
Overview ¶
Package bmc holds the runtime state of a Baseboard Management Controller.
Nothing in this package does I/O; it is pure in-memory state backed by the abstractions in pkg/hal. The server layer (pkg/server) wires transport, clock, and HAL together with this state to produce a working BMC.
Index ¶
- Constants
- Variables
- func FormatV15AuthTypes(types []V15AuthType) string
- func GenerateChallenge(dst *[16]byte) error
- func GenerateInboundSeq() (uint32, error)
- func InboundSeqValid(last, seq uint32) bool
- func PackSessionIDLE(id uint32) []byte
- func StorageMissing(err error) bool
- func SupportedCipherSuite(id types.CipherSuiteID) bool
- func V15AuthTypeName(t V15AuthType) string
- func V15AuthTypeToCapsBit(t V15AuthType) uint8
- func V15InboundSeqValid(sess *V15Session, seq uint32) bool
- type BMC
- func (b *BMC) Clock() clock.Clock
- func (b *BMC) FRUInventory() *FRUInventory
- func (b *BMC) HAL() hal.HAL
- func (b *BMC) ResolvedCipherSuites() []types.CipherSuiteID
- func (b *BMC) ResolvedV15AuthTypes() []V15AuthType
- func (b *BMC) SDRRepository() *SDRRepository
- func (b *BMC) SetCipherSuites(ids []types.CipherSuiteID)
- func (b *BMC) V15AuthTypeEnabled(authType V15AuthType) bool
- func (b *BMC) V15LANEnabled() bool
- type Channel
- type ChannelAccessMode
- type ChannelMedium
- type ChannelStore
- type DeviceInfo
- type FRUInventory
- type Option
- type PrivilegeLevel
- type SDRCapabilities
- type SDRRepoAllocInfo
- type SDRRepoInfo
- type SDRRepoStore
- type SDRRepository
- func (r *SDRRepository) AllocInfo(ctx context.Context) (*SDRRepoAllocInfo, error)
- func (r *SDRRepository) GetRecord(ctx context.Context, recordID uint16) (record []byte, nextID uint16, err error)
- func (r *SDRRepository) Info(ctx context.Context) (*SDRRepoInfo, error)
- func (r *SDRRepository) RecordIDs(ctx context.Context) ([]uint16, error)
- type Session
- type SessionState
- type SessionStore
- func (s *SessionStore) Allocate(consoleID uint32, authAlg types.AuthAlg, integrityAlg types.IntegrityAlg, ...) (*Session, error)
- func (s *SessionStore) Close(bmcID uint32) error
- func (s *SessionStore) Count() int
- func (s *SessionStore) EvictExpired() int
- func (s *SessionStore) Get(bmcID uint32) (*Session, error)
- type SessionStoreOption
- type User
- type UserChannelAccess
- type UserStore
- func (s *UserStore) Add(id uint8, name string) (*User, error)
- func (s *UserStore) Count() int
- func (s *UserStore) Delete(id uint8) error
- func (s *UserStore) FindEnabledByNameOnChannel(name string, channel uint8) (*User, error)
- func (s *UserStore) Get(id uint8) (*User, error)
- func (s *UserStore) GetByName(name string) (*User, error)
- type V15AuthType
- type V15Session
- type V15SessionState
- type V15SessionStore
- func (s *V15SessionStore) Activate(pending *V15Session, permanentID, inboundSeq, outboundSeq uint32, ...) error
- func (s *V15SessionStore) Close(id uint32) error
- func (s *V15SessionStore) CountActiveSessions() int
- func (s *V15SessionStore) CountActiveSessionsForUser(userID uint8) int
- func (s *V15SessionStore) CountActiveSessionsWithMaxPrivilegeAtLeast(min PrivilegeLevel) int
- func (s *V15SessionStore) CreatePending(authType V15AuthType, user *User, challenge [16]byte, channel uint8) (*V15Session, error)
- func (s *V15SessionStore) EvictExpired() int
- func (s *V15SessionStore) Get(id uint32) (*V15Session, error)
- func (s *V15SessionStore) Touch(sess *V15Session)
Constants ¶
const ( MaxUsers = 63 // IPMI spec allows user IDs 1-63 MaxUserNameLen = 16 MaxPasswordLen = 20 // 20 bytes for IPMI 2.0 passwords )
const DefaultInactivityTimeout = 60 * time.Second
Session inactivity timeout per IPMI spec:
- v1.5 §6.11.13 Session Inactivity Timeout
- v2.0 §6.12.15 Session Inactivity Timeout
const DefaultInactivityTimeoutTolerance = 3 * time.Second
DefaultInactivityTimeoutTolerance is the LAN inactivity tolerance per IPMI v1.5 Table 6-7 (+/- 3 seconds).
const DefaultSessionEvictInterval = 3 * time.Second
DefaultSessionEvictInterval is how often the server scans for idle sessions. The spec defines the 60-second inactivity limit, not the scan period.
const MaxSessions = 4
MaxSessions is the minimum number of concurrent sessions required by the spec.
Variables ¶
var DefaultCipherSuites = []types.CipherSuiteID{types.CipherSuiteID3, types.CipherSuiteID17}
DefaultCipherSuites is the cipher suite set advertised when no explicit configuration is provided. It contains the spec-mandatory suite 3 plus the recommended SHA256 suite 17.
var DefaultV15AuthTypes = []V15AuthType{V15AuthTypeMD5}
DefaultV15AuthTypes is the default set of v1.5 auth types the reference BMC advertises and accepts.
var ErrChannelNotFound = errors.New("channel not found")
ErrChannelNotFound is returned when the requested channel number is not configured.
var ErrInvalidUserID = errors.New("user ID must be between 1 and 63")
ErrInvalidUserID is returned for user IDs outside the valid range 1-63.
var ErrNoSession = errors.New("session not found")
ErrNoSession is returned when the session ID is not in the store.
var ErrSessionFull = errors.New("no session slots available")
ErrSessionFull is returned when the store has reached capacity.
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound is returned when a user ID or name does not exist.
var ErrUsernameTaken = errors.New("username already taken")
ErrUsernameTaken is returned when trying to create a user with an already-used name.
Functions ¶
func FormatV15AuthTypes ¶
func FormatV15AuthTypes(types []V15AuthType) string
FormatV15AuthTypes formats auth types for logging (e.g. "md5,md2").
func GenerateChallenge ¶
GenerateChallenge fills dst with random bytes for Get Session Challenge.
func GenerateInboundSeq ¶
GenerateInboundSeq returns a non-zero initial inbound sequence number.
func InboundSeqValid ¶
InboundSeqValid checks whether seq is within the acceptable sliding window defined by the IPMI spec (section 6.12.13): +15 / -16 of the last accepted value. Session sequence numbers start at 1; 0 is reserved for pre-session packets.
func PackSessionIDLE ¶
PackSessionIDLE is a helper for auth code input construction.
func StorageMissing ¶
StorageMissing reports whether err indicates a missing FRU device or SDR record (mapped to completion code CBh by storage handlers).
func SupportedCipherSuite ¶
func SupportedCipherSuite(id types.CipherSuiteID) bool
SupportedCipherSuite reports whether the reference server implements every algorithm in the named cipher suite. Configuring an unsupported suite would cause a runtime handshake failure, so callers validate with this before installing a cipher suite list.
func V15AuthTypeName ¶
func V15AuthTypeName(t V15AuthType) string
V15AuthTypeName returns a human-readable name for t.
func V15AuthTypeToCapsBit ¶
func V15AuthTypeToCapsBit(t V15AuthType) uint8
V15AuthTypeToCapsBit maps an auth type to the corresponding bit in Get Channel Authentication Capabilities response byte 3 (bits [5:0]).
func V15InboundSeqValid ¶
func V15InboundSeqValid(sess *V15Session, seq uint32) bool
V15InboundSeqValid reports whether seq is acceptable under Option 1 without mutating session state (for tests).
Types ¶
type BMC ¶
type BMC struct {
Info DeviceInfo
GUID [16]byte
KG []byte // BMC key (Kg); nil means "one-key" mode using Kuid only
// CipherSuites is the set of RMCP+ cipher suites the server advertises and
// accepts during the Open Session handshake. Defaults to
// [DefaultCipherSuites] when nil. Each suite must be supported by the
// reference server (see [SupportedCipherSuite]); this is validated in
// [WithCipherSuites].
CipherSuites []types.CipherSuiteID
Users *UserStore
Channels *ChannelStore
Sessions *SessionStore
// V15Sessions tracks IPMI v1.5 LAN sessions (separate from RMCP+ sessions).
V15Sessions *V15SessionStore
// V15AuthTypes lists the v1.5 authentication types this BMC advertises and accepts.
V15AuthTypes []V15AuthType
// SDRRepo tracks SDR repository reservation state (v2.0§33.11).
SDRRepo *SDRRepoStore
// contains filtered or unexported fields
}
BMC is the central state object for an IPMI server.
Callers create a BMC via New and pass it to the server together with a transport and HAL. The BMC does not own any goroutines; lifecycle management belongs to the server.
func New ¶
New creates a BMC with sane defaults.
h is required; it provides hardware access. opts are applied in order.
func (*BMC) FRUInventory ¶
func (b *BMC) FRUInventory() *FRUInventory
FRUInventory returns the FRU inventory , or nil when the backing HAL provides no FRU storage.
func (*BMC) ResolvedCipherSuites ¶
func (b *BMC) ResolvedCipherSuites() []types.CipherSuiteID
ResolvedCipherSuites returns the cipher suite list to use for advertisement, falling back to DefaultCipherSuites when none was configured.
func (*BMC) ResolvedV15AuthTypes ¶
func (b *BMC) ResolvedV15AuthTypes() []V15AuthType
ResolvedV15AuthTypes returns the v1.5 auth type list, defaulting to MD5.
func (*BMC) SDRRepository ¶
func (b *BMC) SDRRepository() *SDRRepository
SDRRepository returns the cached SDR record repository, or nil when the backing HAL provides no SDR storage.
func (*BMC) SetCipherSuites ¶
func (b *BMC) SetCipherSuites(ids []types.CipherSuiteID)
SetCipherSuites replaces the configured cipher suite list. Each ID must be supported by the reference server (SupportedCipherSuite); an unsupported ID panics, failing at configuration time rather than at handshake time.
func (*BMC) V15AuthTypeEnabled ¶
func (b *BMC) V15AuthTypeEnabled(authType V15AuthType) bool
V15AuthTypeEnabled reports whether authType is configured on this BMC.
func (*BMC) V15LANEnabled ¶
V15LANEnabled reports whether the BMC advertises and accepts IPMI v1.5 sessions.
type Channel ¶
type Channel struct {
Number uint8
Medium ChannelMedium
AccessMode ChannelAccessMode
// MaxPrivilege is the maximum privilege level allowed on this channel.
MaxPrivilege PrivilegeLevel
// PerMessageAuth and UserLevelAuth reflect the channel security settings.
PerMessageAuth bool
UserLevelAuth bool
// PEFAlerts controls whether PEF alerting is enabled on this channel.
PEFAlerts bool
}
Channel holds the configuration for a single IPMI channel.
type ChannelAccessMode ¶
type ChannelAccessMode uint8
ChannelAccessMode controls whether a channel accepts connections.
const ( ChannelAccessDisabled ChannelAccessMode = 0x00 ChannelAccessPreBootOnly ChannelAccessMode = 0x01 ChannelAccessAlways ChannelAccessMode = 0x02 )
type ChannelMedium ¶
type ChannelMedium uint8
ChannelMedium identifies the physical medium of a channel (LAN, serial, etc.).
const ( ChannelMediumIPMBv10 ChannelMedium = 0x01 ChannelMediumICMB ChannelMedium = 0x02 ChannelMediumLAN ChannelMedium = 0x04 ChannelMediumSerial ChannelMedium = 0x05 ChannelMediumSMBus ChannelMedium = 0x06 ChannelMediumSMBusv20 ChannelMedium = 0x07 ChannelMediumUSBv1 ChannelMedium = 0x08 ChannelMediumUSBv2 ChannelMedium = 0x09 ChannelMediumSystemIF ChannelMedium = 0x0C )
type ChannelStore ¶
type ChannelStore struct {
// contains filtered or unexported fields
}
ChannelStore holds the configuration for all BMC channels.
Channel numbers follow the IPMI spec:
- 0x00 – primary IPMB
- 0x01-0x0B – implementation-specific
- 0x0E – current channel (self-reference, resolved by caller)
- 0x0F – system interface
func NewChannelStore ¶
func NewChannelStore() *ChannelStore
NewChannelStore returns a ChannelStore pre-populated with a default LAN channel (1) and the system interface (15 / 0x0F).
func (*ChannelStore) All ¶
func (s *ChannelStore) All() []*Channel
All returns a snapshot of all configured channels.
func (*ChannelStore) Get ¶
func (s *ChannelStore) Get(n uint8) (*Channel, error)
Get returns the channel at number n, or ErrChannelNotFound.
func (*ChannelStore) Set ¶
func (s *ChannelStore) Set(ch *Channel)
Set adds or replaces the channel at number n.
type DeviceInfo ¶
type DeviceInfo struct {
DeviceID uint8
DeviceRevision uint8
FirmwareMajor uint8 // major revision (bits 6:0)
FirmwareMinor uint8 // minor revision, BCD
IPMIVersion uint8 // 0x20 for IPMI 2.0
ManufacturerID uint32
ProductID uint16
AuxFirmwareRev [4]byte
// AdditionalDeviceSupport bitfield per Table 20-2.
AdditionalDeviceSupport uint8
}
DeviceInfo contains the identification data returned by Get Device ID.
type FRUInventory ¶
type FRUInventory struct {
// contains filtered or unexported fields
}
FRUInventory reads FRU inventory blobs from hal.FRUStore and implements FRU Device semantics for Storage NetFn handlers (v2.0§34).
func NewFRUInventory ¶
func NewFRUInventory(store hal.FRUStore) *FRUInventory
NewFRUInventory returns an inventory backed by store.
type Option ¶
type Option func(*BMC)
Option configures a BMC.
func WithCipherSuites ¶
func WithCipherSuites(ids []types.CipherSuiteID) Option
WithCipherSuites sets the RMCP+ cipher suites the server advertises and accepts. Each ID must be a suite the reference server implements (SupportedCipherSuite); otherwise an error is returned by New and the default suite list is kept. Pass nil/empty to restore DefaultCipherSuites.
func WithClock ¶
WithClock injects a custom clock.Clock. Defaults to clock.Real.
func WithKG ¶
WithKG sets the BMC-level key (Kg) used for two-key RAKP authentication. Leave unset (or pass nil) to use one-key mode (Kuid only).
func WithV15AuthTypes ¶
func WithV15AuthTypes(types []V15AuthType) Option
WithV15AuthTypes sets the IPMI v1.5 authentication types the BMC advertises and accepts. Pass nil/empty to restore DefaultV15AuthTypes.
func WithV15Disabled ¶
func WithV15Disabled() Option
WithV15Disabled turns off IPMI v1.5 LAN session support. RMCP+ (v2.0) is unaffected.
type PrivilegeLevel ¶
type PrivilegeLevel uint8
PrivilegeLevel mirrors types.PrivilegeLevel so bmc stays free of wire-type conversions in session state; handlers map to types before sending responses.
const ( PrivilegeLevelCallback PrivilegeLevel = 0x01 PrivilegeLevelUser PrivilegeLevel = 0x02 PrivilegeLevelOperator PrivilegeLevel = 0x03 PrivilegeLevelAdministrator PrivilegeLevel = 0x04 PrivilegeLevelOEM PrivilegeLevel = 0x05 PrivilegeLevelNoAccess PrivilegeLevel = 0x0F )
type SDRCapabilities ¶
type SDRCapabilities struct {
ModalUpdate bool
NonModalUpdate bool
DeleteSDR bool
PartialAddSDR bool
ReserveRepo bool
GetAllocInfo bool
}
SDRCapabilities describes which SDR repository operations this BMC supports. Handlers map these flags onto storage.SDROperationSupport (v2.0§33.9).
type SDRRepoAllocInfo ¶
type SDRRepoAllocInfo struct {
PossibleAllocUnits uint16
AllocUnitSize uint16
FreeAllocUnits uint16
LargestFreeBlock uint16
MaximumRecordSize uint8
}
SDRRepoAllocInfo is BMC-side allocation accounting (not a wire response). Handlers map this to storage.GetSDRRepoAllocInfoResponse (v2.0§33.10).
type SDRRepoInfo ¶
type SDRRepoInfo struct {
SDRVersion uint8
RecordCount uint16
FreeBytes int // raw free capacity; §33.9 wire encoding is the handler's job
MostRecentAdd time.Time
MostRecentErase time.Time
Overflow bool
Capabilities SDRCapabilities
}
SDRRepoInfo is BMC-side repository status (not a wire response). Handlers map this to storage.GetSDRRepoInfoResponse (v2.0§33.9).
type SDRRepoStore ¶
type SDRRepoStore struct {
// contains filtered or unexported fields
}
SDRRepoStore tracks the active SDR repository reservation (v2.0§33.11).
func NewSDRRepoStore ¶
func NewSDRRepoStore() *SDRRepoStore
NewSDRRepoStore returns an empty SDR reservation tracker.
func (*SDRRepoStore) Reserve ¶
func (s *SDRRepoStore) Reserve() uint16
Reserve invalidates any prior reservation and returns a new non-zero ID.
func (*SDRRepoStore) Validate ¶
func (s *SDRRepoStore) Validate(id uint16) bool
Validate reports whether id matches the active reservation.
type SDRRepository ¶
type SDRRepository struct {
// contains filtered or unexported fields
}
SDRRepository reads SDR records from hal.SDRStore and implements repository semantics for Storage NetFn handlers (v2.0§33).
func NewSDRRepository ¶
func NewSDRRepository(store hal.SDRStore, clk clock.Clock) *SDRRepository
NewSDRRepository returns a repository backed by store.
func (*SDRRepository) AllocInfo ¶
func (r *SDRRepository) AllocInfo(ctx context.Context) (*SDRRepoAllocInfo, error)
AllocInfo returns BMC-side allocation accounting per v2.0§33.10 semantics.
func (*SDRRepository) GetRecord ¶
func (r *SDRRepository) GetRecord(ctx context.Context, recordID uint16) (record []byte, nextID uint16, err error)
GetRecord returns the wire record and next Record ID for repository traversal. Per v2.0§33.12: recordID 0000h maps to the first SDR; FFFFh maps to the last.
func (*SDRRepository) Info ¶
func (r *SDRRepository) Info(ctx context.Context) (*SDRRepoInfo, error)
Info returns BMC-side SDR repository status per v2.0§33.9 semantics.
type Session ¶
type Session struct {
// BMCID is the session ID assigned by the BMC (sent in Open Session Response).
BMCID uint32
// ConsoleID is the session ID chosen by the remote console.
ConsoleID uint32
State SessionState
// Negotiated algorithms
AuthAlg types.AuthAlg
IntegrityAlg types.IntegrityAlg
CryptAlg types.CryptAlg
// Sequence tracking.
// InboundSeq is the last accepted sequence number from the console.
// OutboundSeq is the next sequence number the BMC will use.
InboundSeq uint32
OutboundSeq uint32
// Session keys derived during RAKP.
SIK []byte
K1 []byte
K2 []byte
// RAKP exchange state (zeroed once session is active).
ConsoleRand [16]byte
BMCRand [16]byte
Role uint8 // whole byte from RAKP1, used in HMAC input
// User and privilege
User *User
PrivilegeLevel PrivilegeLevel
MaxPrivilege PrivilegeLevel
// Channel this session arrived on.
Channel uint8
// Timing
CreatedAt time.Time
LastActivity time.Time
}
Session holds all state for one active or pending IPMI session.
type SessionState ¶
type SessionState uint8
SessionState tracks which phase of session negotiation has been reached.
const ( // SessionStatePending means Open Session was received but RAKP is incomplete. SessionStatePending SessionState = iota // SessionStateActive means RAKP completed and commands may flow. SessionStateActive // SessionStateClosed means the session was explicitly closed or timed out. SessionStateClosed )
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore is a thread-safe registry of active and pending sessions.
func NewSessionStore ¶
func NewSessionStore(clk clock.Clock) *SessionStore
NewSessionStore creates a SessionStore limited to MaxSessions concurrent sessions with the default inactivity timeout.
func NewSessionStoreWithOptions ¶
func NewSessionStoreWithOptions(clk clock.Clock, opts ...SessionStoreOption) *SessionStore
NewSessionStoreWithOptions creates a SessionStore with custom options.
func (*SessionStore) Allocate ¶
func (s *SessionStore) Allocate(consoleID uint32, authAlg types.AuthAlg, integrityAlg types.IntegrityAlg, cryptAlg types.CryptAlg) (*Session, error)
Allocate creates a new pending session and returns it. If capacity is reached, it evicts the oldest pending session (LRU per spec). Returns ErrSessionFull only when all slots are occupied by active sessions.
func (*SessionStore) Close ¶
func (s *SessionStore) Close(bmcID uint32) error
Close marks a session as closed and removes it from the store.
func (*SessionStore) Count ¶
func (s *SessionStore) Count() int
Count returns the number of sessions currently in the store.
func (*SessionStore) EvictExpired ¶
func (s *SessionStore) EvictExpired() int
EvictExpired removes all sessions that have been inactive beyond the timeout. Called periodically by the server.
func (*SessionStore) Get ¶
func (s *SessionStore) Get(bmcID uint32) (*Session, error)
Get returns the session for bmcID, or ErrNoSession. It also updates Session.LastActivity.
type SessionStoreOption ¶
type SessionStoreOption func(*SessionStore)
Option configures a SessionStore.
func WithInactivityTimeout ¶
func WithInactivityTimeout(d time.Duration) SessionStoreOption
WithInactivityTimeout overrides the default 60-second inactivity timeout.
func WithMaxSessions ¶
func WithMaxSessions(n int) SessionStoreOption
WithMaxSessions overrides the default session limit.
type User ¶
type User struct {
// ID is the IPMI user slot (1-63). Slot 1 is the anonymous/null user.
ID uint8
Name string
// Password is stored as a 20-byte padded value per the IPMI 2.0 spec.
// Index 0 is valid; a zero-length slice means no password is set.
Password [MaxPasswordLen]byte
Enabled bool
// ChannelAccess holds per-channel access settings keyed by channel number.
ChannelAccess map[uint8]UserChannelAccess
}
User represents a single BMC user account.
func (*User) PasswordV15Padded ¶
PasswordV15Padded returns the user's password zero-padded to 16 bytes per IPMI v1.5 AuthCode algorithms (spec v1.5§18.15.1 / v2.0§22.17.1).
func (*User) SetPassword ¶
SetPassword copies up to MaxPasswordLen bytes from raw into the User's password field.
func (*User) VerifyPassword ¶
VerifyPassword returns true when the supplied raw bytes match the stored password. Uses constant-time comparison to avoid timing attacks.
type UserChannelAccess ¶
type UserChannelAccess struct {
// MaxPrivilege is the highest privilege the user may request on this channel.
MaxPrivilege PrivilegeLevel
// CallbackOnly restricts the user to callback sessions only.
CallbackOnly bool
// Enabled controls whether the user is allowed on this channel at all.
Enabled bool
}
UserChannelAccess records per-channel privilege settings for a user.
type UserStore ¶
type UserStore struct {
// contains filtered or unexported fields
}
UserStore is a thread-safe registry of BMC users.
func NewUserStore ¶
func NewUserStore() *UserStore
NewUserStore creates a UserStore with the mandatory anonymous user (ID 1).
func (*UserStore) Add ¶
Add creates a new user at the given ID. Returns ErrInvalidUserID for IDs outside 1-63, or ErrUsernameTaken if name is non-empty and already in use.
func (*UserStore) FindEnabledByNameOnChannel ¶
FindEnabledByNameOnChannel scans user IDs 1..MaxUsers in order and returns the first enabled user with a matching name and channel access (spec v1.5§18.24 / v2.0§22.27).
func (*UserStore) Get ¶
Get returns the user at the given ID, or ErrUserNotFound.
type V15AuthType ¶
type V15AuthType uint8
V15AuthType mirrors IPMI v1.5 authentication type codes.
const ( V15AuthTypeNone V15AuthType = 0x00 V15AuthTypeMD2 V15AuthType = 0x01 V15AuthTypeMD5 V15AuthType = 0x02 V15AuthTypePassword V15AuthType = 0x04 V15AuthTypeOEM V15AuthType = 0x05 )
func ParseV15AuthType ¶
func ParseV15AuthType(name string) (V15AuthType, error)
ParseV15AuthType parses a single auth type name (case-insensitive).
func ParseV15AuthTypes ¶
func ParseV15AuthTypes(raw string) ([]V15AuthType, error)
ParseV15AuthTypes parses a comma-separated list of v1.5 auth type names.
type V15Session ¶
type V15Session struct {
TempSessionID uint32
SessionID uint32
State V15SessionState
AuthType V15AuthType
Challenge [16]byte
InboundSeq uint32
InboundRcvd uint8 // bitmap: bit i => (InboundSeq - i) received
OutboundSeq uint32
User *User
PrivilegeLevel PrivilegeLevel
MaxPrivilege PrivilegeLevel
Channel uint8
CreatedAt time.Time
LastActivity time.Time
}
V15Session holds IPMI v1.5 session state.
func (*V15Session) NextOutboundSeq ¶
func (sess *V15Session) NextOutboundSeq() uint32
NextOutboundSeq returns the sequence number for the current outbound message and advances the counter for the next one. Sequence 0 is reserved for pre-session packets and is skipped on wrap (v1.5§6.11.9 / v2.0§6.12.9).
func (*V15Session) TryAcceptInboundSeq ¶
func (sess *V15Session) TryAcceptInboundSeq(seq uint32) bool
TryAcceptInboundSeq implements spec v1.5§6.11.11 Option 1 / v2.0§6.12.11 Option 1 (+/-8 window, no dupes).
type V15SessionState ¶
type V15SessionState uint8
V15SessionState tracks IPMI v1.5 session negotiation progress.
const ( V15SessionStatePending V15SessionState = iota V15SessionStateActive V15SessionStateClosed )
type V15SessionStore ¶
type V15SessionStore struct {
// contains filtered or unexported fields
}
V15SessionStore is a thread-safe registry of IPMI v1.5 sessions.
func NewV15SessionStore ¶
func NewV15SessionStore(clk clock.Clock) *V15SessionStore
NewV15SessionStore creates a V15SessionStore with the default limits.
func (*V15SessionStore) Activate ¶
func (s *V15SessionStore) Activate(pending *V15Session, permanentID, inboundSeq, outboundSeq uint32, maxPrivilege PrivilegeLevel) error
Activate transitions a pending session to active with a new permanent ID. maxPrivilege is the requested ceiling; initial privilege is USER per v1.5§6.8 / v2.0§6.8 (Callback when max is Callback).
inboundSeq is the Activate Session response "Session inbound sequence number" (spec v1.5§18.15 / v2.0§6.12.9): the starting sequence the remote console must use on its first authenticated packet. InboundSeq on the session tracks the highest sequence already accepted, so it is seeded to inboundSeq-1 (wrapping) with an empty receive bitmap — otherwise the first packet (seq == inboundSeq) is rejected as a duplicate and clients such as ipmitool stall for a full LAN timeout before retrying with inboundSeq+1.
func (*V15SessionStore) Close ¶
func (s *V15SessionStore) Close(id uint32) error
Close removes a session by permanent or temp ID.
func (*V15SessionStore) CountActiveSessions ¶
func (s *V15SessionStore) CountActiveSessions() int
CountActiveSessions returns the number of active v1.5 sessions.
func (*V15SessionStore) CountActiveSessionsForUser ¶
func (s *V15SessionStore) CountActiveSessionsForUser(userID uint8) int
CountActiveSessionsForUser returns active sessions owned by userID.
func (*V15SessionStore) CountActiveSessionsWithMaxPrivilegeAtLeast ¶
func (s *V15SessionStore) CountActiveSessionsWithMaxPrivilegeAtLeast(min PrivilegeLevel) int
CountActiveSessionsWithMaxPrivilegeAtLeast counts active sessions whose negotiated maximum privilege is >= min (for Table 18-17 completion 0x83).
func (*V15SessionStore) CreatePending ¶
func (s *V15SessionStore) CreatePending(authType V15AuthType, user *User, challenge [16]byte, channel uint8) (*V15Session, error)
CreatePending allocates a pending v1.5 session after Get Session Challenge.
func (*V15SessionStore) EvictExpired ¶
func (s *V15SessionStore) EvictExpired() int
EvictExpired removes inactive v1.5 sessions past the timeout.
func (*V15SessionStore) Get ¶
func (s *V15SessionStore) Get(id uint32) (*V15Session, error)
Get returns a session by its current lookup ID without updating activity.
func (*V15SessionStore) Touch ¶
func (s *V15SessionStore) Touch(sess *V15Session)
Touch records valid session activity for inactivity timeout (spec v1.5§6.11.13 / v2.0§6.12.15).