mlrpc_encdec.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* 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
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <strings.h>
#ifdef _BIG_ENDIAN
static const int mlrpc_native_byte_order = MLRPC_REPLAB_INTG_BIG_ENDIAN;
#else
static const int mlrpc_native_byte_order = MLRPC_REPLAB_INTG_LITTLE_ENDIAN;
#endif
int
{
struct mlndr_stream *mlnds;
int rc;
if (m_op == NDR_M_OP_MARSHALL)
else
/*
* Make sure that mlnds is in the correct mode
*/
return (MLRPC_DRC_FAULT_MODE_MISMATCH);
/*
* Perform the (un)marshalling
*/
return (MLRPC_DRC_OK);
case NDR_ERR_MALLOC_FAILED:
break;
break;
case NDR_ERR_UNDERFLOW:
break;
case NDR_ERR_GROW_FAILED:
break;
default:
if (m_op == NDR_M_OP_MARSHALL)
else
break;
}
return (rc);
}
int
{
int rc;
return (rc + MLRPC_PTYPE_REQUEST);
}
int
{
int rc;
return (rc + MLRPC_PTYPE_RESPONSE);
}
int
{
int rc;
return (rc + MLRPC_PTYPE_REQUEST);
}
int
{
int rc;
return (rc + MLRPC_PTYPE_RESPONSE);
}
int
{
int ptype;
int rc;
int charset;
int byte_order;
return (MLRPC_DRC_FAULT_MODE_MISMATCH + 0xFF);
/*
* All PDU headers are at least this big
*/
if (!rc)
return (MLRPC_DRC_FAULT_RECEIVED_RUNT + 0xFF);
/*
* Peek at the first eight bytes to figure out what we're doing.
*/
if (!rc)
return (MLRPC_DRC_FAULT_DECODE_FAILED + 0xFF);
/*
* Verify the protocol version.
*/
return (MLRPC_DRC_FAULT_DECODE_FAILED + 0xFF);
/*
* Check for ASCII as the character set. This is an ASCII
* versus EBCDIC option and has nothing to do with Unicode.
*/
if (charset != MLRPC_REPLAB_CHAR_ASCII)
return (MLRPC_DRC_FAULT_DECODE_FAILED + 0xFF);
/*
* Set the byte swap flag if the PDU byte-order
* is different from the local byte-order.
*/
if (ptype == MLRPC_PTYPE_REQUEST &&
}
return (rc + 0xFF);
}
/*
* Decode an RPC fragment header. Use mlrpc_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 != mlrpc_native_byte_order) {
/*LINTED E_BAD_PTR_CAST_ALIGN*/
sizeof (WORD));
sizeof (WORD));
}
}
int
{
int ptype;
int rc;
return (MLRPC_DRC_FAULT_MODE_MISMATCH + 0xFF);
if (ptype == MLRPC_PTYPE_REQUEST &&
}
return (rc + 0xFF);
}
/*
* 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;
struct ndr_typeinfo ndt__mlrpcconn_bind_ack_hdr = {
1, /* NDR version */
3, /* alignment */
NDR_F_STRUCT, /* flags */
mlndr__mlrpcconn_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
{
struct ndr_reference myref;
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);
}
unsigned
{
unsigned offset;
unsigned length;
/* port any is the conformant culprit */
offset = 24UL;
offset += 2;
return (offset);
}