/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <assert.h>
#include <strings.h>
#ifdef _BIG_ENDIAN
#else
#endif
static int
{
int rc;
/*
* Perform the (un)marshalling
*/
return (NDR_DRC_OK);
case NDR_ERR_MALLOC_FAILED:
break;
break;
case NDR_ERR_UNDERFLOW:
break;
case NDR_ERR_GROW_FAILED:
break;
default:
else
break;
}
return (rc);
}
{
return (NULL);
return (NULL);
}
return (nbuf);
}
void
{
}
/*
* Decode an NDR encoded buffer. The buffer is expected to contain
* a single fragment packet with a valid PDU header followed by NDR
* encoded data. The structure to which result points should be
* of the appropriate type to hold the decoded output. For example:
*
* pac_info_t info;
*
* if ((nbuf = ndr_buf_init(&TYPEINFO(ndr_pac)) != NULL) {
* rc = ndr_decode_buf(nbuf, opnum, data, datalen, &info);
* ...
* ndr_buf_fini(nbuf);
* }
*/
int
{
unsigned pdu_size_hint;
int rc;
if (datalen < NDR_PDU_SIZE_HINT_DEFAULT)
else
if (NDR_DRC_IS_FAULT(rc))
return (rc);
switch (hdr_type) {
case NDR_PTYPE_COMMON:
if (NDR_DRC_IS_FAULT(rc))
return (rc);
return (NDR_DRC_FAULT_DECODE_FAILED);
break;
case NDR_PTYPE_PAC:
if (NDR_DRC_IS_FAULT(rc))
return (rc);
return (NDR_DRC_FAULT_DECODE_FAILED);
break;
default:
return (NDR_ERR_UNIMPLEMENTED);
}
result);
return (rc);
}
/*
* Use the receive stream to unmarshall data (NDR_MODE_CALL_RECV).
*/
int
{
int rc;
return (NDR_DRC_FAULT_MODE_MISMATCH);
return (rc + NDR_PTYPE_REQUEST);
}
/*
* Use the send stream to marshall data (NDR_MODE_RETURN_SEND).
*/
int
{
int rc;
return (NDR_DRC_FAULT_MODE_MISMATCH);
return (rc + NDR_PTYPE_RESPONSE);
}
/*
* Use the send stream to marshall data (NDR_MODE_CALL_SEND).
*/
int
{
int rc;
return (NDR_DRC_FAULT_MODE_MISMATCH);
return (rc + NDR_PTYPE_REQUEST);
}
/*
* Use the receive stream to unmarshall data (NDR_MODE_RETURN_RECV).
*/
int
{
int rc;
return (NDR_DRC_FAULT_MODE_MISMATCH);
return (rc + NDR_PTYPE_RESPONSE);
}
int
{
int rc;
if (NDR_DRC_IS_FAULT(rc))
return (rc);
/*
* Verify the protocol version.
*/
return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
return (NDR_DRC_OK);
}
static int
{
int ptype;
int rc;
int charset;
int byte_order;
return (NDR_DRC_FAULT_RPCHDR_MODE_MISMATCH);
/*
* All PDU headers are at least this big
*/
if (!rc)
return (NDR_DRC_FAULT_RPCHDR_RECEIVED_RUNT);
/*
* Peek at the first eight bytes to figure out what we're doing.
*/
if (!rc)
return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
/*
* Check for ASCII as the character set. This is an ASCII
* versus EBCDIC option and has nothing to do with Unicode.
*/
if (charset != NDR_REPLAB_CHAR_ASCII)
return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
/*
* Set the byte swap flag if the PDU byte-order
* is different from the local byte-order.
*/
if (ptype == NDR_PTYPE_REQUEST &&
}
return (NDR_DRC_PTYPE_RPCHDR(rc));
}
static int
{
int rc;
return (NDR_DRC_FAULT_RPCHDR_MODE_MISMATCH);
/*
* All PDU headers are at least this big
*/
if (!rc)
return (NDR_DRC_FAULT_RPCHDR_RECEIVED_RUNT);
/*
* Peek at the first eight bytes to figure out what we're doing.
*/
if (!rc)
return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
/* Must be set to 1 to indicate type serialization version 1. */
return (NDR_DRC_FAULT_RPCHDR_DECODE_FAILED);
/*
* Set the byte swap flag if the PDU byte-order
* is different from the local byte-order.
*/
return (NDR_DRC_PTYPE_RPCHDR(rc));
}
/*
* Decode an RPC fragment header. Use ndr_decode_pdu_hdr() to process
* the first fragment header then this function to process additional
* fragment headers.
*/
void
{
int byte_order;
/*
* Swap non-byte fields if the PDU byte-order
* is different from the local byte-order.
*/
if (byte_order != ndr_native_byte_order) {
/*LINTED E_BAD_PTR_CAST_ALIGN*/
sizeof (WORD));
sizeof (WORD));
}
}
/*
* Remove an RPC fragment header from the received data stream.
*
* NDR stream on entry:
*
* |<--- frag --->|
* +-----+--------+-----+--------+-----+---------+-----+
* | hdr | data | hdr | data | hdr | data | ... |
* +-----+--------+-----+--------+-----+---------+-----+
* <----
*
* NDR stream on return:
*
* +-----+----------------+-----+---------+-----+
* | hdr | data | hdr | data | ... |
* +-----+----------------+-----+---------+-----+
*/
void
{
char *hdr;
char *data;
int nbytes;
}
void
{
char *fragtype;
return;
}
fragtype = "single";
fragtype = "first";
fragtype = "last";
else
fragtype = "intermediate";
"ndr hdr: %d.%d ptype=%d, %s frag (flags=0x%08x) len=%d",
}
int
{
int ptype;
int rc;
return (NDR_DRC_FAULT_RPCHDR_MODE_MISMATCH);
if (ptype == NDR_PTYPE_REQUEST &&
}
return (NDR_DRC_PTYPE_RPCHDR(rc));
}
/*
* This is a hand-coded derivative of the automatically generated
* (un)marshalling routine for bind_ack headers. bind_ack headers
* have an interior conformant array, which is inconsistent with
*/
extern struct ndr_typeinfo ndt__uchar;
extern struct ndr_typeinfo ndt__ushort;
extern struct ndr_typeinfo ndt__ulong;
1, /* NDR version */
3, /* alignment */
NDR_F_STRUCT, /* flags */
ndr__ndr_bind_ack_hdr, /* ndr_func */
68, /* pdu_size_fixed_part */
0, /* pdu_size_variable_part */
68, /* c_size_fixed_part */
0, /* c_size_variable_part */
};
/*
* [_no_reorder]
*/
int
{
unsigned long offset;
myref.packed_alignment = 0;
/* do all members in order */
/* port any is the conformant culprit */
offset = 24UL;
case NDR_M_OP_MARSHALL:
break;
case NDR_M_OP_UNMARSHALL:
break;
default:
return (0);
}
offset += 2;
return (1);
}
/*
* Assume a single presentation context element in the result list.
*/
unsigned
{
unsigned offset;
unsigned length;
/* port any is the conformant culprit */
offset = 24UL;
offset += 2;
offset += sizeof (ndr_p_result_list_t);
return (offset);
}
/*
* This is a hand-coded derivative of the automatically generated
* (un)marshalling routine for alter_context_rsp headers.
* Alter context response headers have an interior conformant array,
*/
1, /* NDR version */
3, /* alignment */
NDR_F_STRUCT, /* flags */
ndr__ndr_alter_context_rsp_hdr, /* ndr_func */
56, /* pdu_size_fixed_part */
0, /* pdu_size_variable_part */
56, /* c_size_fixed_part */
0, /* c_size_variable_part */
};
/*
* [_no_reorder]
*/
int
{
unsigned long offset;
myref.packed_alignment = 0;
/* do all members in order */
case NDR_M_OP_MARSHALL:
break;
case NDR_M_OP_UNMARSHALL:
break;
default:
return (0);
}
return (1);
}
/*
* Assume a single presentation context element in the result list.
*/
unsigned
{
unsigned offset;
offset += sizeof (ndr_p_result_list_t);
return (offset);
}