fibrechannel

package module
v0.0.0-...-8e48038 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2015 License: MIT Imports: 5 Imported by: 0

README

fibrechannel Build Status Coverage Status GoDoc

Package fibrechannel implements marshaling and unmarshaling of Fibre Channel frames. MIT Licensed.

Documentation

Overview

Package fibrechannel implements marshaling and unmarshaling of Fibre Channel frames.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidFrame is returned when one of the following occur:
	//  - an invalid SOF or EOF sequence is detected
	//  - a payload does not end on a word (4 byte) boundary
	//  - no Header is present when attempting to binary marshal a Frame
	ErrInvalidFrame = errors.New("invalid frame")

	// ErrInvalidCRC is returned when Frame.UnmarshalBinary detects an incorrect
	// CRC checksum in a byte slice for a Frame.
	ErrInvalidCRC = errors.New("invalid frame checksum")
)

Functions

This section is empty.

Types

type EOF

type EOF byte

A EOF is an End-of-Frame byte, which appears at the end of a Fibre Channel frame.

const (
	EOFn   EOF = 0x41 // Normal (not last frame of sequence)
	EOFt   EOF = 0x42 // Terminate (last frame of sequence)
	EOFrt  EOF = 0x44
	EOFdt  EOF = 0x46 // Disconnect-terminate class-1
	EOFni  EOF = 0x49 // Normal-invalid
	EOFdti EOF = 0x4e // Disconnect-terminate-invalid
	EOFrti EOF = 0x4f
	EOFa   EOF = 0x50 // Abort
)

EOF constants which indicate continuation or termination.

func (EOF) String

func (i EOF) String() string

type Frame

type Frame struct {
	// SOF specifies the Start-of-Frame byte contained in this Frame.
	SOF SOF

	// Header specifies a Fibre Channel header, which contains metadata
	// regarding this Frame.
	Header *Header

	// Payload is a variable length data payload encapsulated by this Frame.
	// Payload is automatically padded to the next word (4 byte) boundary when
	// marshaled into binary form.
	Payload []byte

	// EOF specifies the End-of-Frame byte contained in this Frame.
	EOF EOF
}

A Frame is a Fibre Channel frame. A Frame contains information such as SOF and EOF bytes, a header, and payload data.

func (*Frame) MarshalBinary

func (f *Frame) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice and marshals a Frame into binary form.

Frame.Header must not be nil, or ErrInvalidFrame will be returned.

func (*Frame) UnmarshalBinary

func (f *Frame) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a byte slice into a Frame.

If the byte slice does not contain enough data to unmarshal a valid Frame, io.ErrUnexpectedEOF is returned.

If an invalid SOF or EOF sequence is detected, or a payload does not end on a word (4 byte) boundary, ErrInvalidFrame is returned.

If the CRC checksum present in the byte slice does not match the one computed by UnmarshalBinary, ErrInvalidCRC is returned.

type Header struct {
	// RoutingControl (R_CTL) identifies a frame's type and information category.
	RoutingControl RoutingControl

	// DestinationID (D_ID) identifies a frame's destination.
	DestinationID [3]byte

	// Priority (CS_CTL/PRI or Class Specific Control) identifies the priority
	// of traffic contained in a frame.
	Priority byte

	// SourceID (S_ID) identifies a frame's source.
	SourceID [3]byte

	// Type identifies the type of traffic contained in a frame.
	Type byte

	// FrameControl (F_CTL) contains a variety of frame options.
	FrameControl [3]byte

	// SequenceID (SEQ_ID) identifies which sequence a frame belongs to.
	SequenceID uint8

	// DataFieldControl (DF_CTL) indicates the presence of optional headers
	// and their size.
	DataFieldControl byte

	// SequenceCount (SEQ_CNT) identifies a frame's number within a sequence.
	SequenceCount uint16

	// OriginatorExchangeID (OX_ID) is an ID assigned by an initiator, used to
	// group related sequences.
	OriginatorExchangeID uint16

	// ResponderExchangeID (RX_ID) is an ID assigned by a target, also used to
	// group related sequences.
	ResponderExchangeID uint16

	// Parameter is used as a relative offset in sequences.
	Parameter uint32
}

A Header is a Fibre Channel header. A Header contains metadata regarding a Frame.

func (*Header) MarshalBinary

func (h *Header) MarshalBinary() ([]byte, error)

MarshalBinary allocates a byte slice and marshals a Frame into binary form.

MarshalBinary never returns an error.

func (*Header) UnmarshalBinary

func (h *Header) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a byte slice into a Header.

If the byte slice does not contain exactly enough data to unmarshal a valid Header, io.ErrUnexpectedEOF is returned.

type RoutingControl

type RoutingControl byte

A RoutingControl is a byte which appears in the R_CTL field of a Fibre Channel header.

const (
	RoutingControlDeviceDataUncategorized       RoutingControl = 0x00
	RoutingControlDeviceDataSolicitedData       RoutingControl = 0x01
	RoutingControlDeviceDataUnsolicitiedControl RoutingControl = 0x02
	RoutingControlDeviceDataSolicitedControl    RoutingControl = 0x03
	RoutingControlDeviceDataUnsolicitedData     RoutingControl = 0x04
	RoutingControlDeviceDataDataDescriptor      RoutingControl = 0x05
	RoutingControlDeviceDataUnsolicitedCommand  RoutingControl = 0x06
	RoutingControlDeviceDataCommandStatus       RoutingControl = 0x07
)

RoutingControl constants which indicate different frame types and information categories.

func (RoutingControl) String

func (i RoutingControl) String() string

type SOF

type SOF byte

A SOF is a Start-of-Frame byte, which appears at the beginning of a Fibre Channel frame.

const (
	SOFf  SOF = 0x28 // Start fabric
	SOFi2 SOF = 0x2d // Start class 2
	SOFi3 SOF = 0x2e // Start class 3
	SOFi4 SOF = 0x29 // Start class 4
	SOFn2 SOF = 0x35 // Normal (continue) class 2
	SOFn3 SOF = 0x36 // Normal (continue) class 3
	SOFn4 SOF = 0x31 // Normal (continue) class 4
	SOFc4 SOF = 0x39
)

SOF constants which indicate different types of Frame traffic.

func (SOF) String

func (i SOF) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL