Documentation
¶
Index ¶
- Constants
- func IsFinalPacket(packet Packet) bool
- func WriteErrorResponse(w io.Writer, err error) error
- func WritePreLoginResponse(w io.Writer) error
- func WriteStreamResponse(w io.Writer, tokens []mssql.Token) error
- type BasicPacket
- type Login7Header
- type Login7Packet
- type Packet
- type PacketHeader
- type PreLoginPacket
- type RPCRequest
- type SQLBatch
Constants ¶
const ( // PacketTypeSQLBatch is the SQLBatch packet type. PacketTypeSQLBatch uint8 = 0x01 // PacketTypeRPCRequest is the RPCRequest packet type. PacketTypeRPCRequest uint8 = 0x03 // PacketTypeResponse is the packet type for server response messages. PacketTypeResponse uint8 = 0x04 // PacketTypeLogin7 is the Login7 packet type. PacketTypeLogin7 uint8 = 0x10 // PacketTypePreLogin is the Pre-Login packet type. PacketTypePreLogin uint8 = 0x12 // PacketStatusLast indicates that the packet is the last in the request. // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/ce398f9a-7d47-4ede-8f36-9dd6fc21ca43 PacketStatusLast uint8 = 0x01 )
Variables ¶
This section is empty.
Functions ¶
func IsFinalPacket ¶
IsFinalPacket returns true there are no more packets on the message.
func WriteErrorResponse ¶
WriteErrorResponse writes error response to the client.
func WritePreLoginResponse ¶
WritePreLoginResponse writes response to the Pre-Login packet to the writer.
Types ¶
type BasicPacket ¶
type BasicPacket struct {
// contains filtered or unexported fields
}
BasicPacket implements the Packet interfaces allowing to operate on PacketHeader and get underlying packet type.
func NewBasicPacket ¶
func NewBasicPacket(header PacketHeader, data []byte) (*BasicPacket, error)
NewBasicPacket creates a new BasicPacket instance with the specified PacketHeader and data.
func ReadPacket ¶
func ReadPacket(r io.Reader) (*BasicPacket, error)
ReadPacket reads a single full packet from the reader.
func (BasicPacket) Data ¶
func (g BasicPacket) Data() []byte
Data is the packet data bytes without header.
func (BasicPacket) Header ¶
func (g BasicPacket) Header() PacketHeader
Header is the parsed packet header.
type Login7Header ¶
type Login7Header struct {
Length uint32
TDSVersion uint32
PacketSize uint32
ClientProgVer uint32
ClientPID uint32
ConnectionID uint32
OptionFlags1 uint8
OptionFlags2 uint8
TypeFlags uint8
OptionFlags3 uint8
ClientTimezone int32
ClientLCID uint32
IbHostName uint16 // offset
CchHostName uint16 // length
IbUserName uint16
CchUserName uint16
IbPassword uint16
CchPassword uint16
IbAppName uint16
CchAppName uint16
IbServerName uint16
CchServerName uint16
IbUnused uint16
CbUnused uint16
IbCltIntName uint16
CchCltIntName uint16
IbLanguage uint16
CchLanguage uint16
IbDatabase uint16
CchDatabase uint16
ClientID [6]byte
IbSSPI uint16
CbSSPI uint16
IbAtchDBFile uint16
CchAtchDBFile uint16
IbChangePassword uint16
CchChangePassword uint16
CbSSPILong uint32
}
Login7Header contains options and offset/length pairs parsed from the Login7 packet sent by client.
Note: the order of fields in the struct matters as it gets unpacked from the binary stream.
type Login7Packet ¶
type Login7Packet struct {
// contains filtered or unexported fields
}
Login7Packet represents a Login7 packet that defines authentication rules between the client and the server.
func ReadLogin7Packet ¶
func ReadLogin7Packet(r io.Reader) (*Login7Packet, error)
ReadLogin7Packet reads Login7 packet from the reader.
func (*Login7Packet) Database ¶
func (p *Login7Packet) Database() string
Database returns the database from the Login7 packet. May be empty.
func (*Login7Packet) OptionFlags1 ¶
func (p *Login7Packet) OptionFlags1() uint8
OptionFlags1 returns the packet's first set of option flags.
func (*Login7Packet) OptionFlags2 ¶
func (p *Login7Packet) OptionFlags2() uint8
OptionFlags2 returns the packet's second set of option flags.
func (*Login7Packet) PacketSize ¶
func (p *Login7Packet) PacketSize() uint16
PacketSize return the packet size from the Login7 packet. Packet size is used by a server to negation the size of max packet length.
func (*Login7Packet) TypeFlags ¶
func (p *Login7Packet) TypeFlags() uint8
TypeFlags returns the packet's set of type flags.
func (*Login7Packet) Username ¶
func (p *Login7Packet) Username() string
Username returns the username from the Login7 packet.
type Packet ¶
type Packet interface {
// Bytes returns whole packet bytes.
Bytes() []byte
// Data returns packet data without data related to Header.
Data() []byte
// Header returns packet Header definition.
Header() PacketHeader
// Type returns packet type ID.
Type() uint8
}
Packet is a packet interface.
func ToSQLPacket ¶
func ToSQLPacket(p *BasicPacket) (out Packet, err error)
ToSQLPacket tries to convert basicPacket to MSServer SQL packet.
type PacketHeader ¶
type PacketHeader struct {
Type uint8
Status uint8
Length uint16 // network byte order (big-endian)
SPID uint16 // network byte order (big-endian)
PacketID uint8
Window uint8
}
PacketHeader represents a 8-byte packet header.
Note: the order of fields in the struct matters as it gets unpacked from the binary stream.
func (*PacketHeader) Marshal ¶
func (h *PacketHeader) Marshal() ([]byte, error)
Marshal marshals the packet header to the wire protocol byte representation.
type PreLoginPacket ¶
type PreLoginPacket struct {
// contains filtered or unexported fields
}
PreLoginPacket represents a Pre-Login packet which is sent by the client to set up context for login.
func ReadPreLoginPacket ¶
func ReadPreLoginPacket(r io.Reader) (*PreLoginPacket, error)
ReadPreLoginPacket reads Pre-Login packet from the reader.
type RPCRequest ¶
type RPCRequest struct {
Packet
// ProcName contains name of the procedure to be executed.
ProcName string
// Parameters contains list of RPC parameters.
Parameters []string
}
RPCRequest defines client RPC Request packet: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/619c43b6-9495-4a58-9e49-a4950db245b3
type SQLBatch ¶
SQLBatch is a representation of MSServer SQL Batch packet. https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/f2026cd3-9a46-4a3f-9a08-f63140bcbbe3