Documentation
¶
Overview ¶
Package pdu models connection-oriented DCE/RPC protocol data units (PDUs): the 16-byte common header and the Bind, Bind_Ack, Bind_Nak, Request, Response, and Fault bodies ([C706] section 12, [MS-RPCE] section 2.2).
Each PDU type embeds the common Header and represents a whole PDU. Marshal returns the complete on-the-wire bytes (header included) and sets the header's frag_length; Unmarshal parses a complete PDU and returns the number of bytes consumed.
Only the little-endian data representation (DREP first byte 0x10) is supported, which is what Windows and Samba always send; a big-endian DREP is rejected on Unmarshal rather than silently mis-parsed.
Index ¶
Constants ¶
const ( ResultAcceptance uint16 = 0 ResultUserRejection uint16 = 1 ResultProviderRejection uint16 = 2 ResultNegotiateAck uint16 = 3 // [MS-RPCE] bind-time feature negotiation )
Presentation context negotiation result codes (p_cont_def_result_t), as returned in the result field of each p_result_t in a bind_ack PDU.
References:
- [C706] section 12.6.3.1 ("The bind_ack PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.4 Presentation Context and Transfer Syntax Negotiation: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/ca4d3552-4647-4f40-830b-fd2090adec8f
- [MS-RPCE] negotiate_ack member of p_cont_def_result_t: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/8df5c4d4-364d-468c-81fe-ec94c1b40917
const ( ReasonNotSpecified uint16 = 0 ReasonAbstractSyntaxNotSupported uint16 = 1 ReasonProposedTransferSyntaxesNotSupported uint16 = 2 ReasonLocalLimitExceeded uint16 = 3 )
Provider reject reasons (p_provider_reason_t / p_reject_reason_t).
Reference: [C706] section 12.6.3.1: https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
const ( NCASStatusOK uint32 = 0x00000000 NCASOpRngError uint32 = 0x1C010002 // nca_s_op_rng_error: invalid opnum NCASUnkIf uint32 = 0x1C010003 // nca_s_unk_if: unknown interface NCASProtoError uint32 = 0x1C01000B // nca_s_proto_error NCASFaultIntDivByZero uint32 = 0x1C000001 // nca_s_fault_int_div_by_zero NCASFaultAddrError uint32 = 0x1C000002 // nca_s_fault_addr_error NCASFaultNDR uint32 = 0x000006F7 // nca_s_fault_ndr: NDR could not decode NCASFaultAccessDenied uint32 = 0x00000005 // nca_s_fault_access_denied NCASFaultContextMismatch uint32 = 0x1C00001A // nca_s_fault_context_mismatch )
Common connection-oriented RPC fault status codes (nca_* / rpc_s_*). This is a subset; unknown codes are reported numerically by FaultStatus.String.
References:
- [C706] section 12.6.3.1 ("The fault PDU") and Appendix E (reject status codes): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.5 Fault PDU: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/55c10f44-9037-4d51-aaff-c146bd0f1988
const HeaderSize = 16
HeaderSize is the size, in bytes, of the connection-oriented common header.
Variables ¶
var DataRepresentationLittleEndian = [4]byte{0x10, 0x00, 0x00, 0x00}
DataRepresentationLittleEndian is the canonical packed_drep for little-endian integers, ASCII characters, and IEEE floating point.
Functions ¶
This section is empty.
Types ¶
type Bind ¶
type Bind struct {
Header Header
MaxXmitFrag uint16
MaxRecvFrag uint16
AssocGroupID uint32
ContextList []ContextElement
}
Bind is a bind PDU: it proposes the maximum fragment sizes, an association group, and a list of presentation contexts to negotiate.
References:
- [C706] section 12.6.3.1 ("The bind PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.4 Presentation Context and Transfer Syntax Negotiation: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/ca4d3552-4647-4f40-830b-fd2090adec8f
type BindAck ¶
type BindAck struct {
Header Header
MaxXmitFrag uint16
MaxRecvFrag uint16
AssocGroupID uint32
SecondaryAddress string // port_spec, without the trailing NUL
Results []PresentationResult
}
BindAck is a bind_ack PDU: the server's response to a bind, echoing the negotiated fragment sizes and reporting per-context negotiation results.
References:
- [C706] section 12.6.3.1 ("The bind_ack PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.4 Presentation Context and Transfer Syntax Negotiation: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/ca4d3552-4647-4f40-830b-fd2090adec8f
type BindNak ¶
type BindNak struct {
Header Header
RejectReason uint16
Versions []ProtocolVersion
}
BindNak is a bind_nak PDU: the server's rejection of a bind, with a reason and the list of RPC protocol versions it supports.
Reference: [C706] section 12.6.3.1 ("The bind_nak PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
type ContextElement ¶
type ContextElement struct {
ContextID uint16
AbstractSyntax syntax.SyntaxID
TransferSyntaxes []syntax.SyntaxID
}
ContextElement is a single presentation context proposed in a bind (or alter_context) PDU: a context id, an abstract syntax (the target interface), and one or more candidate transfer syntaxes (p_cont_elem_t).
References:
- [C706] section 12.6.3.1 ("The bind PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.4 Presentation Context and Transfer Syntax Negotiation: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/ca4d3552-4647-4f40-830b-fd2090adec8f
func (*ContextElement) Marshal ¶
func (c *ContextElement) Marshal() ([]byte, error)
Marshal serializes a presentation context element.
type Fault ¶
type Fault struct {
Header Header
AllocHint uint32
ContextID uint16
CancelCount uint8
Status uint32
Stub []byte
}
Fault is a fault PDU: it reports that a call failed, carrying a status code and any error stub data.
References:
- [C706] section 12.6.3.1 ("The fault PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.5 Fault PDU: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/55c10f44-9037-4d51-aaff-c146bd0f1988
func (*Fault) Error ¶
Error implements the error interface so a Fault can be returned directly from a call. The message includes the mnemonic status code.
type FaultStatus ¶
type FaultStatus uint32
FaultStatus is a fault PDU status code, with a descriptive String.
func (FaultStatus) String ¶
func (s FaultStatus) String() string
String returns a mnemonic for known status codes, otherwise the hex value.
type Header ¶
type Header struct {
RPCVersion uint8
RPCVersionMinor uint8
PacketType PacketType
PacketFlags PFCFlags
DataRepresentation [4]byte
FragLength uint16
AuthLength uint16
CallID uint32
}
Header is the connection-oriented common header present at the start of every PDU.
References:
- [C706] section 12.6.3.1 (common fields of the connection-oriented PDU): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.10 PDU Types: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/cef9d684-f09f-4533-a54c-9255079d3e1d
func NewHeader ¶
func NewHeader(pt PacketType, flags PFCFlags, callID uint32) Header
NewHeader returns a header initialized for protocol version 5.0 with little-endian data representation and the given packet type, flags, and call id.
func PeekHeader ¶
PeekHeader parses just the common header from the front of a complete PDU buffer. It is a convenience for dispatching on PacketType before fully unmarshalling.
type PFCFlags ¶
type PFCFlags uint8
PFCFlags is the set of PFC_* flags carried in the pfc_flags field of the common header.
References:
- [C706] section 12.6.3.1 (pfc_flags): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.3 PFC_SUPPORT_HEADER_SIGN and related flags: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/4886f349-2a73-4f9e-9262-a8404462c7e9
const ( // PFCFirstFrag marks the first fragment of a multi-fragment PDU. PFCFirstFrag PFCFlags = 0x01 // PFCLastFrag marks the last fragment of a multi-fragment PDU. PFCLastFrag PFCFlags = 0x02 // PFCPendingCancel signals a pending cancel (request) or a cancel was pending // (response). PFCPendingCancel PFCFlags = 0x04 // PFCReserved is reserved. PFCReserved PFCFlags = 0x08 // PFCConcMpx indicates support for concurrent multiplexing on the connection. PFCConcMpx PFCFlags = 0x10 // PFCDidNotExecute indicates the server did not execute the call (response/fault). PFCDidNotExecute PFCFlags = 0x20 // PFCMaybe indicates a "maybe" call with no response expected. PFCMaybe PFCFlags = 0x40 // PFCObjectUuid indicates an object UUID is present in the PDU body. PFCObjectUuid PFCFlags = 0x80 )
type PacketType ¶
type PacketType uint8
PacketType identifies the kind of a connection-oriented DCE/RPC PDU, as carried in the ptype field of the common header.
References:
- [C706] section 12.6.4 (PDU types): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
- [MS-RPCE] 2.2.2.10 PDU Types: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/cef9d684-f09f-4533-a54c-9255079d3e1d
const ( PacketTypeRequest PacketType = 0 PacketTypePing PacketType = 1 PacketTypeResponse PacketType = 2 PacketTypeFault PacketType = 3 PacketTypeWorking PacketType = 4 PacketTypeNoCall PacketType = 5 PacketTypeReject PacketType = 6 PacketTypeAck PacketType = 7 PacketTypeClCancel PacketType = 8 PacketTypeFack PacketType = 9 PacketTypeCancelAck PacketType = 10 PacketTypeBind PacketType = 11 PacketTypeBindAck PacketType = 12 PacketTypeBindNak PacketType = 13 PacketTypeAlterContext PacketType = 14 PacketTypeAlterContextResp PacketType = 15 PacketTypeShutdown PacketType = 17 PacketTypeCoCancel PacketType = 18 PacketTypeOrphaned PacketType = 19 )
func (PacketType) String ¶
func (t PacketType) String() string
String returns the mnemonic name of the packet type.
type PresentationResult ¶
PresentationResult is one server response in a bind_ack p_result_list (p_result_t): the negotiation result, an optional reason, and the accepted transfer syntax.
Reference: [C706] section 12.6.3.1 ("The bind_ack PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
func (*PresentationResult) Marshal ¶
func (r *PresentationResult) Marshal() ([]byte, error)
Marshal serializes a single presentation result (24 bytes).
type ProtocolVersion ¶
ProtocolVersion is one supported RPC protocol version (p_rt_version_t).
type Request ¶
type Request struct {
Header Header
AllocHint uint32
ContextID uint16
Opnum uint16
ObjectUUID *guid.GUID // present iff PFC_OBJECT_UUID is set
Stub []byte
}
Request is a request PDU: it carries a method call (opnum) and its marshalled arguments (stub data) to the server.
When the PFC_OBJECT_UUID flag is set, a 16-byte object UUID precedes the stub data; otherwise it is absent. Stub data is 8-octet aligned, which the fixed 8-byte body (plus an optional 16-byte object UUID) already satisfies.
Reference: [C706] section 12.6.3.1 ("The request PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm
type Response ¶
type Response struct {
Header Header
AllocHint uint32
ContextID uint16
CancelCount uint8
Stub []byte
}
Response is a response PDU: it carries the marshalled return values (stub data) of a successful call back to the client.
Reference: [C706] section 12.6.3.1 ("The response PDU"): https://pubs.opengroup.org/onlinepubs/9629399/chap12.htm